├── .gitignore
├── ai
├── config.js
├── ViewStory.js
├── LoadStory.js
├── UpdatePack.js
├── mem.js
├── ExportStory.js
└── agent.js
├── assets
├── agent.png
├── NewStory.png
├── WriteSeg.png
├── EditStory.png
└── ExportStory.png
├── .idea
├── .gitignore
├── encodings.xml
├── vcs.xml
├── modules.xml
└── StoryWriter.iml
├── disk.json
├── setup.template.js
├── app.config.js
├── tabstudio.project.json
├── gears.json
├── license.txt
├── LICENSE
├── README.md
├── app.html
├── app.js
├── cody.project.json
├── app.svg
├── cokemake.config.js
├── cfg
└── appCfg.js
└── ui
├── BoxSeg.js
└── DlgSegs.js
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/ai/config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | PACK_SEG_NUM:2
3 | };
--------------------------------------------------------------------------------
/assets/agent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Avdpro/StoryWriter/HEAD/assets/agent.png
--------------------------------------------------------------------------------
/assets/NewStory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Avdpro/StoryWriter/HEAD/assets/NewStory.png
--------------------------------------------------------------------------------
/assets/WriteSeg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Avdpro/StoryWriter/HEAD/assets/WriteSeg.png
--------------------------------------------------------------------------------
/assets/EditStory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Avdpro/StoryWriter/HEAD/assets/EditStory.png
--------------------------------------------------------------------------------
/assets/ExportStory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Avdpro/StoryWriter/HEAD/assets/ExportStory.png
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/disk.json:
--------------------------------------------------------------------------------
1 | {
2 | "imports": {
3 | "StdUI": "V1",
4 | "cokemake": "v1",
5 | "terser": "v1",
6 | "rollup": "v1"
7 | },
8 | "cloudId": "StoryWrite@avdpro@me.com",
9 | "versionIdx": 5,
10 | "version": "0.0.5"
11 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/setup.template.js:
--------------------------------------------------------------------------------
1 | export default {
2 | versionIdx:"$$BuildVersionIdx$$",
3 | disks:"$$ZipDirs$$",
4 | files:{
5 | },
6 | runOnPreSetup:async function(){
7 | //TODO: codes runs only before setup
8 | },
9 | runOnPostSetup:async function(){
10 | //TODO: codes runs only after setup
11 | },
12 | run:async function(){
13 | //TODO: codes runs before entner the entry.
14 | },
15 | entry:"$$Entry$$",
16 | };
17 |
--------------------------------------------------------------------------------
/.idea/StoryWriter.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app.config.js:
--------------------------------------------------------------------------------
1 | import pathLib from "/@path";
2 | let url=import.meta.url;
3 | let dir=pathLib.dirname(url);
4 | //This is your app meta:
5 | export default {
6 | type:"app",
7 | name:"Dev. App",
8 | caption:"Dev. App",
9 | main:`${dir}/app.html`,
10 | package:"",
11 | catalog:["My Applications"],
12 | icon:`${dir}/app.svg`,
13 | iconApp:null,
14 | appFrame:{
15 | main:`${dir}/app.html`,
16 | group:`${dir}/app.html`,
17 | title:"Dev. App",
18 | icon:`${dir}/app.svg`,
19 | multiFrame:true,
20 | width:360,height:600,
21 | maxable:false,
22 | }
23 | };
24 |
--------------------------------------------------------------------------------
/tabstudio.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "edit": {
3 | "indent": 4
4 | },
5 | "run": [
6 | {
7 | "profileName": "Debug Agent",
8 | "profileIcon": "/~/-tabos/shared/assets/lab.svg",
9 | "arg": {
10 | "file": "ai/agent.js"
11 | },
12 | "main": "/@aichat/debug.html",
13 | "icon": "app.svg",
14 | "mode": "FrameApp",
15 | "width": 1000,
16 | "height": 800
17 | },
18 | {
19 | "profileName": "Run Chat App",
20 | "profileIcon": "/~/-tabos/shared/assets/run.svg",
21 | "main": "app.html",
22 | "mode": "FrameApp",
23 | "width": 800,
24 | "height": 600
25 | }
26 | ],
27 | "addOns": [
28 | "/@editkit/EditAddOn.js",
29 | "/@editkit/EditAIAddOn.js"
30 | ]
31 | }
--------------------------------------------------------------------------------
/gears.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "libs": [
4 | "/@StdUI",
5 | "/@aichat"
6 | ],
7 | "preloads": [],
8 | "fonts": null,
9 | "datas": {},
10 | "views": {},
11 | "gears": {
12 | "BoxSeg": {
13 | "name": "BoxSeg",
14 | "path": "ui/BoxSeg.js",
15 | "icon": "gears.svg",
16 | "showName": "BoxSeg",
17 | "catalog": ""
18 | },
19 | "DlgSegs": {
20 | "name": "DlgSegs",
21 | "path": "ui/DlgSegs.js",
22 | "icon": "gears.svg",
23 | "showName": "标准对话框",
24 | "catalog": ""
25 | }
26 | },
27 | "gearIndexes": {
28 | "Gear1HIASUKH50": {
29 | "path": "ui/BoxSeg.js"
30 | },
31 | "Gear1GGJKM84D0": {
32 | "path": "ui/MainUI.js",
33 | "expose": false
34 | },
35 | "Gear1HIARMBHP0": {
36 | "path": "ui/DlgSegs.js",
37 | "expose": false
38 | }
39 | },
40 | "templates": {
41 | "ui/DlgSegs.js": {
42 | "template": true,
43 | "name": "Template1HIARMBHP0",
44 | "showName": "Standard Dialog",
45 | "path": "ui/DlgSegs.js",
46 | "description": "",
47 | "icon": "gears.svg",
48 | "catalog": "ViewTemplates"
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 tab-os.com, Avdpro Pang
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Avdpro Pang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # StoryWriter
2 | 这是一个 撰写短篇文章/小说的 Agent,受到了MidReal等项目的启发。
3 |
4 | ## 系统特点
5 |
6 | - 该项目生成的是网页 PWA App,可以在浏览器中直接运行
7 | - 支持桌面(宽屏)和移动(窄屏)
8 | - 可以切换 AI 模型,现在可以在 ChatGPT 3.5 和 ChatGPT 4 之间切换
9 | - 创建项目的时候指定绘画风格,在编写的时候可以绘制封面和插画
10 | - 精确的无限长文编写,虽然主要目的是编写短篇的文章,但是通过文章背景设定和内容提炼辅助,可以撰写无限长的文章。
11 | - 强大的编辑文章能力,支持逐段落的修改,包括内容和插图,修改的时候可以选择是否由 AI 辅助完成
12 | - 输出HTML格式或者Markdown格式的文章
13 |
14 | ## 快速开始
15 | 有几种方式部署这个工程
16 | 1. 在[www.ai2apps.com](www.ai2apps.com)里,使用项目向导创建 AI Agent,选择 StoryWriter 模版即可
17 | 2. 在本地部署的AI2Apps环境中,使用项目向导,创建 AI Agent,选择 StoryWriter 模版即可
18 | 3. 在[www.ai2apps.com](www.ai2apps.com)或者本地部署的AI2Apps环境里,创建一个目录,把本工程的内容同步到目录中,在用IDE打开。
19 |
20 |
21 | ## 主要Agent(智能体)说明
22 |
23 | ### agent.js:主智能体
24 |
25 | 
26 |
27 | Agent App 的主逻辑智能。
28 |
29 | ### NewStory.js: 创建新的文章
30 |
31 | 
32 |
33 | - 询问用户文章标题
34 | - 根据用户提示由AI生成文章的背景设定
35 | - 设置文章插图绘制风格
36 | - 可选:绘制文章封面
37 |
38 |
39 | ### WriteSeg.js: 撰写一段文章
40 |
41 | 
42 |
43 | - 根据用户指示撰写一段文章
44 | - 每次生成三个备选供用户选择
45 | - 可选:自动无题事续写
46 | - 可选:增加插图
47 |
48 | ### EditStory.js: 编辑文章
49 |
50 | 
51 |
52 | - 更改标题
53 | - 修改文章背景设定
54 | - 选择段落,修改段落内容
55 | - 手动修改段落内容
56 | - AI 辅助修改段落内容
57 | - 删除段落
58 | - 添加/更换段落插图
59 | - 删除段落插图
60 |
61 | ### ExportStory.js: 输出文章
62 |
63 | 
64 |
65 | - 输出为HTML文件
66 | - 输出为Markdown文件
67 | - 输出JSON工程文件
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Tab-OS App
13 |
24 |
25 |
29 |
30 |
31 |
34 |
37 |
38 |
39 |
40 |
43 |
47 |
49 |
50 |
51 |
52 |
53 |
57 |
58 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {tabOS,tabFS,tabTask} from "/@tabos";
3 | import {VFACT} from "/@vfact";
4 | import {} from "/@vfact/vfact_app.js";
5 | import{appCfg} from "./cfg/appCfg.js";
6 | /*#{MoreImports*/
7 | import {AppLib} from "/@homekit/data/AppLib.js";
8 | import pathLib from "/@path";
9 | import {MainUI} from "./ui/MainUI.js";
10 | import {DlgTask} from "/@homekit/ui/DlgTask.js";
11 | /*}#MoreImports*/
12 | VFACT.appCfg=appCfg;
13 | /*#{StartApp*/
14 | /*}#StartApp*/
15 | //----------------------------------------------------------------------------
16 | //Start the app:
17 | async function startApp() {
18 | /*#{AppCode*/
19 | let app,uiDef;
20 |
21 | document.title="Tab-OS App";
22 | //------------------------------------------------------------------------
23 | //Check if we are in appFrame:
24 | let appFrame=null;
25 | //CheckAppFrame:
26 | {
27 | let pw;
28 | appFrame=null;
29 | pw=window.parent;
30 | if(pw!==window){
31 | if(pw.getAppFrame){
32 | appFrame=window.appFrame=pw.getAppFrame(window);
33 | }
34 | }
35 | }
36 | window.tabOSApp=app=await VFACT.createApp();
37 |
38 | //setup open (openPath, openMeta...) API:
39 | await AppLib.setupOpenAPI(app,appFrame);
40 |
41 | uiDef=MainUI(app,appFrame);
42 | if(!appFrame){
43 | //uiDef=AppLib.setupMiniDocker(app,uiDef);
44 | }
45 | //init app, create app UI tree:
46 | await VFACT.initApp(app,uiDef,{
47 | wait:1,
48 | shortcuts:appCfg.shortcuts,
49 | DlgTask:DlgTask,
50 | appFrame:appFrame,
51 | });
52 | /*}#AppCode*/
53 | }
54 | tabOS.setup().then(()=>{startApp();});
55 | /*#{EndDoc*/
56 | /*}#EndDoc*/
57 |
58 | /*Cody Project Doc*/
59 | //{
60 | // "type": "docfile",
61 | // "def": "app",
62 | // "jaxId": "1GGJKJ38Q0",
63 | // "editVersion": 52,
64 | // "attrs": {
65 | // "fonts": {
66 | // "type": "object",
67 | // "def": "Fonts",
68 | // "jaxId": "1GGJKJ38Q1",
69 | // "editVersion": 0,
70 | // "attrs": {}
71 | // },
72 | // "exportTarget": "VFACT document",
73 | // "localize": {
74 | // "type": "array",
75 | // "def": "StringArray",
76 | // "attrs": [
77 | // "EN",
78 | // {
79 | // "type": "string",
80 | // "valText": "CN"
81 | // }
82 | // ]
83 | // },
84 | // "language": "EN",
85 | // "useTabOS": "true",
86 | // "title": "Tab-OS App",
87 | // "bgColor": "[255,255,255]",
88 | // "icon": "",
89 | // "fullScreen": "false",
90 | // "multiTouch": "false",
91 | // "location": "false",
92 | // "camera": "false",
93 | // "photo": "false",
94 | // "notification": "false",
95 | // "contacts": "false",
96 | // "payment": "false"
97 | // }
98 | //}
--------------------------------------------------------------------------------
/cody.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "object",
3 | "def": "EditPrj",
4 | "jaxId": "1GGJKJ3BS0",
5 | "editVersion": 20,
6 | "attrs": {
7 | "docDatas": {
8 | "type": "object",
9 | "def": "DocsObj",
10 | "jaxId": "1GGJKJ3BS1",
11 | "editVersion": 0,
12 | "attrs": {}
13 | },
14 | "docAIAgents": {
15 | "type": "object",
16 | "def": "DocsObj",
17 | "jaxId": "1HDBOSUQQ0",
18 | "editVersion": 18,
19 | "attrs": {
20 | "agent.js": {
21 | "type": "docfile",
22 | "def": "DocAIAgent",
23 | "jaxId": "1HDBOSUN90",
24 | "editVersion": 52,
25 | "path": "ai/agent.js"
26 | },
27 | "mem.js": {
28 | "type": "docfile",
29 | "def": "DocAIAgent",
30 | "jaxId": "1HE544DRT0",
31 | "editVersion": 24,
32 | "path": "ai/mem.js"
33 | },
34 | "NewStory.js": {
35 | "type": "docfile",
36 | "def": "DocAIAgent",
37 | "jaxId": "1HI79QI6P0",
38 | "editVersion": 37,
39 | "path": "ai/NewStory.js"
40 | },
41 | "WriteSeg.js": {
42 | "type": "docfile",
43 | "def": "DocAIAgent",
44 | "jaxId": "1HI7BOT5S0",
45 | "editVersion": 34,
46 | "path": "ai/WriteSeg.js"
47 | },
48 | "LoadStory.js": {
49 | "type": "docfile",
50 | "def": "DocAIAgent",
51 | "jaxId": "1HI98V9M00",
52 | "editVersion": 40,
53 | "path": "ai/LoadStory.js"
54 | },
55 | "ViewStory.js": {
56 | "type": "docfile",
57 | "def": "DocAIAgent",
58 | "jaxId": "1HI9A49JT0",
59 | "editVersion": 28,
60 | "path": "ai/ViewStory.js"
61 | },
62 | "ExportStory.js": {
63 | "type": "docfile",
64 | "def": "DocAIAgent",
65 | "jaxId": "1HIAN9JQ30",
66 | "editVersion": 28,
67 | "path": "ai/ExportStory.js"
68 | },
69 | "EditStory.js": {
70 | "type": "docfile",
71 | "def": "DocAIAgent",
72 | "jaxId": "1HIAPD7FP0",
73 | "editVersion": 30,
74 | "path": "ai/EditStory.js"
75 | },
76 | "UpdatePack.js": {
77 | "type": "docfile",
78 | "def": "DocAIAgent",
79 | "jaxId": "1HIBTGACI0",
80 | "editVersion": 28,
81 | "path": "ai/UpdatePack.js"
82 | }
83 | }
84 | },
85 | "docGears": {
86 | "type": "object",
87 | "def": "DocsObj",
88 | "jaxId": "1GGJKJ3BS2",
89 | "editVersion": 2,
90 | "attrs": {
91 | "BoxSeg.js": {
92 | "type": "docfile",
93 | "def": "GearButton",
94 | "jaxId": "1HIASUKH50",
95 | "editVersion": 67,
96 | "path": "ui/BoxSeg.js"
97 | }
98 | }
99 | },
100 | "docViews": {
101 | "type": "object",
102 | "def": "DocsObj",
103 | "jaxId": "1GGJKJ3BS3",
104 | "editVersion": 4,
105 | "attrs": {
106 | "MainUI.js": {
107 | "type": "docfile",
108 | "def": "UIView",
109 | "jaxId": "1GGJKM84D0",
110 | "editVersion": 49,
111 | "path": "ui/MainUI.js"
112 | },
113 | "DlgSegs.js": {
114 | "type": "docfile",
115 | "def": "GearHud",
116 | "jaxId": "1HIARMBHP0",
117 | "editVersion": 152,
118 | "path": "ui/DlgSegs.js"
119 | }
120 | }
121 | }
122 | },
123 | "externGearLibs": [
124 | "/@StdUI",
125 | "/@aichat"
126 | ],
127 | "preloadFiles": []
128 | }
--------------------------------------------------------------------------------
/app.svg:
--------------------------------------------------------------------------------
1 |
2 |
80 |
--------------------------------------------------------------------------------
/cokemake.config.js:
--------------------------------------------------------------------------------
1 | import {tabFS} from "/@tabos";
2 | import pathLib from "/@path";
3 | import terser from "/@terser/cokemake-plugin.js";
4 | import terserRorllup from "/@terser/rollup-plugin.js";
5 | //Make for HTML-Relase:
6 | let workDir=tabFS.cwd();
7 | let dirName=workDir.substring(1);
8 | let dist={
9 | steps:[
10 | {
11 | action:"clean",
12 | dirs:["dist"]
13 | },
14 | {
15 | action:"rollup",
16 | config:{
17 | input:["./app.js"],
18 | external:[/\/@/],
19 | output:{
20 | format:"es",
21 | exportDir:"dist",
22 | },
23 | plugins:[
24 | {
25 | name:"importPatch",
26 | renderChunk: async function(code, chunk, outputOptions) {
27 | code=code.replaceAll("import('../@","import('/@");
28 | code=code.replaceAll(`import("../@`,`import("/@`);
29 | return code;
30 | },
31 | },
32 | terserRorllup()
33 | ]
34 | }
35 | },
36 | `Copy "assets" dir, "ai" dir and entry html...`,
37 | {
38 | action:"copy",
39 | dirs:{
40 | "assets":"dist/assets",
41 | "ai":"dist/ai",
42 | },
43 | files:{
44 | "app.html":"dist/",
45 | "app.svg":"dist/app.svg",
46 | "app.config.js":"dist/app.config.js",
47 | }
48 | },
49 | `Copy "assets" dir, "ai" dir and entry html...`,
50 | ],
51 | options:{
52 | }
53 | };
54 | //Make for app package:
55 | let buildVersionIdx=0;
56 | let zipDisks=["coke","-tabos","-homekit","-StdUI","-aichat"];
57 | let zipCommands=[];
58 | let protocol,domain;
59 | let app={
60 | steps:[
61 | async function(){
62 | let info,dir;
63 | try{
64 | info=await tabFS.readFile(`${workDir}/build.info.json`,"utf8");
65 | info=JSON.parse(info);
66 | }catch(err){
67 | info={};
68 | }
69 | protocol=info.protocol||"app";
70 | domain=info.domain||"www.ai2apps.com";
71 | buildVersionIdx=parseInt(info.buildVersionIdx)||0;
72 | buildVersionIdx+=1;
73 | //Generate zip disk commands:
74 | for(dir of zipDisks){
75 | zipCommands.push(`zip /${dir}/* /tmpinst/${dir}.zip`);
76 | }
77 | },
78 | `Clean dist dir...`,
79 | {
80 | action:"clean",
81 | dirs:["dist"]
82 | },
83 | `Roll up apps...`,
84 | {
85 | action:"rollup",
86 | config:{
87 | input:["./app.js"],
88 | external:[/\/@/],
89 | output:{
90 | format:"es",
91 | exportDir:"dist",
92 | },
93 | plugins:[
94 | {
95 | name:"importPatch",
96 | renderChunk: async function(code, chunk, outputOptions) {
97 | code=code.replaceAll("import('../@","import('/@");
98 | code=code.replaceAll(`import("../@`,`import("/@`);
99 | return code;
100 | },
101 | },
102 | terserRorllup()
103 | ]
104 | }
105 | },
106 | `Copy "assets" dir, "ai" dir and entry html...`,
107 | {
108 | action:"copy",
109 | dirs:{
110 | "assets":"dist/assets",
111 | "ai":"dist/ai",
112 | },
113 | files:{
114 | "app.html":"dist/",
115 | }
116 | },
117 | `Init temp dir...`,
118 | {
119 | action:"command",
120 | commands:[
121 | "disk drop tmpinst",
122 | "disk new tmpinst",
123 | ]
124 | },
125 | `Generating project disk zip image...`,
126 | {
127 | action:"command",
128 | command:`zip ${workDir}/dist/* /tmpinst/${dirName}.zip`,
129 | },
130 | `Generating dependency zip images...`,
131 | {
132 | action:"command",
133 | commands:zipCommands
134 | },
135 | `Clear dist dir...`,
136 | {
137 | action:"clean",
138 | dirs:["dist"]
139 | },
140 | `Generating setup.js...`,
141 | async function(){
142 | let codes,dirs,zipVO,dir;
143 | dirs=[...zipDisks,dirName];
144 | zipVO={};
145 | for(dir of dirs){
146 | zipVO[dir]=dir+".zip";
147 | }
148 | codes=await tabFS.readFile(`${workDir}/setup.template.js`,"utf8");
149 | codes=codes.replace(`"$$BuildVersionIdx$$"`,""+buildVersionIdx);
150 | codes=codes.replace(`"$$ZipDirs$$"`,""+JSON.stringify(zipVO));
151 | codes=codes.replace(`"$$Entry$$"`,""+`"${protocol}://${domain}/~${workDir}/app.html"`);
152 | await tabFS.writeFile(`/tmpinst/setup.js`,codes,"utf8");
153 | },
154 | `Make package zip...`,
155 | {
156 | action:"command",
157 | commands:[
158 | `zip /tmpinst/* ${workDir}/dist/setup.zip`,
159 | ]
160 | },
161 | `Clear temp dir...`,
162 | {
163 | action:"clean",
164 | dirs:["/tmpinst"]
165 | },
166 | `Finishing build, update build.info.json.`,
167 | async function(){
168 | let info={
169 | buildVersionIdx:buildVersionIdx,
170 | lastBuildTime:""+Date(),
171 | protocol:protocol,
172 | domain:domain
173 | };
174 | info=JSON.stringify(info,null,"\t");
175 | await tabFS.writeFile(`${workDir}/build.info.json`,info,"utf8");
176 | },
177 | `Build done, build-version-idx: ${buildVersionIdx}.`,
178 | `Download ${workDir}/dist/setup.zip.`,
179 | `Remove your mobile app project's "setup" dir in "app" dir.`,
180 | `Unzip setup.zip in your mobile app project's "app" dir as "setup" dir.`,
181 | `Build and run your mobile app project to test it.`,
182 | ],
183 | options:{
184 | }
185 | };
186 | export default dist;
187 | export {dist,app};
188 |
--------------------------------------------------------------------------------
/ai/ViewStory.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {$P,VFACT,callAfter} from "/@vfact";
3 | import pathLib from "/@path";
4 | import inherits from "/@inherits";
5 | import Base64 from "/@tabos/utils/base64.js";
6 | import {trimJSON} from "/@aichat/utils.js";
7 | /*#{1HI9A49JT0MoreImports*/
8 | /*}#1HI9A49JT0MoreImports*/
9 | const agentURL=(new URL(import.meta.url)).pathname;
10 | const basePath=pathLib.dirname(agentURL);
11 | const $ln=VFACT.lanCode||"EN";
12 | /*#{1HI9A49JT0StartDoc*/
13 | /*}#1HI9A49JT0StartDoc*/
14 | //----------------------------------------------------------------------------
15 | let ViewStory=async function(session){
16 | let context,globalContext;
17 | let self;
18 | let SEG1HI9A4MPT0;
19 | /*#{1HI9A49JT0LocalVals*/
20 | /*}#1HI9A49JT0LocalVals*/
21 |
22 | /*#{1HI9A49JT0PreContext*/
23 | /*}#1HI9A49JT0PreContext*/
24 | globalContext=session.globalContext;
25 | context={};
26 | context=VFACT.flexState(context);
27 | /*#{1HI9A49JT0PostContext*/
28 | /*}#1HI9A49JT0PostContext*/
29 | let agent,segs={};
30 | segs["SEG1HI9A4MPT0"]=SEG1HI9A4MPT0=async function(input){//:1HI9A4MPT0
31 | let result=""
32 | /*#{1HI9A4MPT0Code*/
33 | let segs=globalContext.StorySegs;
34 | segs=segs.map(item=>item.text);
35 | console.log(segs.join("\n\n"));
36 | /*}#1HI9A4MPT0Code*/
37 | return {result:result};
38 | };
39 | SEG1HI9A4MPT0.jaxId="1HI9A4MPT0"
40 | SEG1HI9A4MPT0.url="SEG1HI9A4MPT0@"+agentURL
41 |
42 | agent={
43 | isAIAgent:true,
44 | session:session,
45 | name:"ViewStory",
46 | url:agentURL,
47 | autoStart:true,
48 | jaxId:"1HI9A49JT0",
49 | context:context,
50 | livingSeg:null,
51 | execChat:async function(input){
52 | let result;
53 | /*#{1HI9A49JT0PreEntry*/
54 | /*}#1HI9A49JT0PreEntry*/
55 | result={seg:SEG1HI9A4MPT0,"input":input};
56 | /*#{1HI9A49JT0PostEntry*/
57 | /*}#1HI9A49JT0PostEntry*/
58 | return result;
59 | },
60 | /*#{1HI9A49JT0MoreAgentAttrs*/
61 | /*}#1HI9A49JT0MoreAgentAttrs*/
62 | };
63 | /*#{1HI9A49JT0PostAgent*/
64 | /*}#1HI9A49JT0PostAgent*/
65 | return agent;
66 | };
67 | /*#{1HI9A49JT0ExCodes*/
68 | /*}#1HI9A49JT0ExCodes*/
69 |
70 |
71 | export default ViewStory;
72 | export{ViewStory};
73 | /*Cody Project Doc*/
74 | //{
75 | // "type": "docfile",
76 | // "def": "DocAIAgent",
77 | // "jaxId": "1HI9A49JT0",
78 | // "editVersion": 28,
79 | // "attrs": {
80 | // "editObjs": {
81 | // "type": "object",
82 | // "def": "Object",
83 | // "jaxId": "1HI9A49JT1",
84 | // "editVersion": 2,
85 | // "attrs": {
86 | // "ViewStory": {
87 | // "type": "objclass",
88 | // "def": "ObjClass",
89 | // "jaxId": "1HI9A49JU0",
90 | // "editVersion": 14,
91 | // "attrs": {
92 | // "constructArgs": {
93 | // "type": "object",
94 | // "jaxId": "1HI9A49JU1",
95 | // "editVersion": 0,
96 | // "attrs": {}
97 | // },
98 | // "superClass": "",
99 | // "properties": {
100 | // "type": "object",
101 | // "def": "Object",
102 | // "jaxId": "1HI9A49JU2",
103 | // "editVersion": 0,
104 | // "attrs": {}
105 | // },
106 | // "functions": {
107 | // "type": "object",
108 | // "def": "Functions",
109 | // "jaxId": "1HI9A49JU3",
110 | // "editVersion": 0,
111 | // "attrs": {}
112 | // },
113 | // "mockupOnly": "false",
114 | // "nullMockup": "false"
115 | // },
116 | // "mockups": {}
117 | // }
118 | // }
119 | // },
120 | // "agent": {
121 | // "type": "object",
122 | // "def": "Object",
123 | // "jaxId": "1HI9A49JT2",
124 | // "editVersion": 0,
125 | // "attrs": {}
126 | // },
127 | // "segs": {
128 | // "type": "array",
129 | // "attrs": [
130 | // {
131 | // "type": "aiseg",
132 | // "def": "code",
133 | // "jaxId": "1HI9A4MPT0",
134 | // "editVersion": 28,
135 | // "attrs": {
136 | // "id": "",
137 | // "label": "New AI Seg",
138 | // "x": "160",
139 | // "y": "260",
140 | // "context": {
141 | // "type": "object",
142 | // "def": "Object",
143 | // "jaxId": "1HI9A61U00",
144 | // "editVersion": 0,
145 | // "attrs": {}
146 | // },
147 | // "global": {
148 | // "type": "object",
149 | // "def": "Object",
150 | // "jaxId": "1HI9A61U01",
151 | // "editVersion": 0,
152 | // "attrs": {}
153 | // },
154 | // "desc": "这是一个AISeg。",
155 | // "codes": "true",
156 | // "mkpInput": "$$input$$",
157 | // "outlet": {
158 | // "type": "aioutlet",
159 | // "def": "AISegOutlet",
160 | // "jaxId": "1HI9A4MPT1",
161 | // "editVersion": 4,
162 | // "attrs": {
163 | // "id": "Result",
164 | // "desc": "输出节点。"
165 | // }
166 | // },
167 | // "result": ""
168 | // }
169 | // }
170 | // ]
171 | // },
172 | // "entry": "",
173 | // "autoStart": "true",
174 | // "debug": "true",
175 | // "localVars": {
176 | // "type": "object",
177 | // "def": "Object",
178 | // "jaxId": "1HI9A49JT3",
179 | // "editVersion": 0,
180 | // "attrs": {}
181 | // },
182 | // "context": {
183 | // "type": "object",
184 | // "def": "Object",
185 | // "jaxId": "1HI9A49JT4",
186 | // "editVersion": 0,
187 | // "attrs": {}
188 | // },
189 | // "globalMockup": {
190 | // "type": "object",
191 | // "def": "Object",
192 | // "jaxId": "1HI9A49JT5",
193 | // "editVersion": 0,
194 | // "attrs": {}
195 | // },
196 | // "desc": "这是一个AI代理。",
197 | // "exportAPI": "false",
198 | // "apiArgs": {
199 | // "type": "object",
200 | // "def": "Object",
201 | // "jaxId": "1HI9A49JT6",
202 | // "editVersion": 0,
203 | // "attrs": {}
204 | // }
205 | // }
206 | //}
--------------------------------------------------------------------------------
/ai/LoadStory.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {$P,VFACT,callAfter} from "/@vfact";
3 | import pathLib from "/@path";
4 | import inherits from "/@inherits";
5 | import Base64 from "/@tabos/utils/base64.js";
6 | import {trimJSON} from "/@aichat/utils.js";
7 | /*#{1HI98V9M00MoreImports*/
8 | import {tabFS} from "/@tabos";
9 | /*}#1HI98V9M00MoreImports*/
10 | const agentURL=(new URL(import.meta.url)).pathname;
11 | const basePath=pathLib.dirname(agentURL);
12 | const $ln=VFACT.lanCode||"EN";
13 | /*#{1HI98V9M00StartDoc*/
14 | /*}#1HI98V9M00StartDoc*/
15 | //----------------------------------------------------------------------------
16 | let LoadStory=async function(session){
17 | let context,globalContext;
18 | let self;
19 | let ChooseFile,ParseData;
20 | /*#{1HI98V9M00LocalVals*/
21 | /*}#1HI98V9M00LocalVals*/
22 |
23 | /*#{1HI98V9M00PreContext*/
24 | /*}#1HI98V9M00PreContext*/
25 | globalContext=session.globalContext;
26 | context={};
27 | context=VFACT.flexState(context);
28 | /*#{1HI98V9M00PostContext*/
29 | /*}#1HI98V9M00PostContext*/
30 | let agent,segs={};
31 | segs["ChooseFile"]=ChooseFile=async function(input){//:1HI990Q8I0
32 | let prompt=("请选择故事文件")||input;
33 | let resultText="";
34 | let fileData=null;
35 | let enc=null;
36 | let ext=null;
37 | let fileSys="tabos";
38 | let result="";
39 | let path=("/doc/");
40 | let filter=("*.json");
41 | [resultText,result]=await session.askUserRaw({type:"input",prompt:prompt,text:"",path:path,file:fileSys,filter:filter,});
42 | return {seg:ParseData,result:(result),preSeg:"1HI990Q8I0",outlet:"1HI990Q8J0"};
43 | };
44 | ChooseFile.jaxId="1HI990Q8I0"
45 | ChooseFile.url="ChooseFile@"+agentURL
46 |
47 | segs["ParseData"]=ParseData=async function(input){//:1HI995AAQ0
48 | let result=""
49 | /*#{1HI995AAQ0Code*/
50 | let fileData,path;
51 | path=input;
52 | try{
53 | fileData=(await (await fetch(path)).text());
54 | result=JSON.parse(fileData);
55 | }catch(err){
56 | if(path.startsWith("//")){
57 | path=path.substring(1);
58 | }
59 | if(path.startsWith("/~/")){
60 | path=path.substring(2);
61 | }
62 | fileData=await tabFS.readFile(path,"utf8");
63 | result=JSON.parse(fileData);
64 | }
65 | delete result.context;
66 | Object.assign(globalContext,result);
67 | if(!globalContext.LLMMode){
68 | globalContext.LLMMode="gpt-3.5-turbo-1106";
69 | }
70 | VFACT.app.emit("StoryReady",globalContext);
71 | /*}#1HI995AAQ0Code*/
72 | return {result:result};
73 | };
74 | ParseData.jaxId="1HI995AAQ0"
75 | ParseData.url="ParseData@"+agentURL
76 |
77 | agent={
78 | isAIAgent:true,
79 | session:session,
80 | name:"LoadStory",
81 | url:agentURL,
82 | autoStart:true,
83 | jaxId:"1HI98V9M00",
84 | context:context,
85 | livingSeg:null,
86 | execChat:async function(input){
87 | let result;
88 | /*#{1HI98V9M00PreEntry*/
89 | /*}#1HI98V9M00PreEntry*/
90 | result={seg:ChooseFile,"input":input};
91 | /*#{1HI98V9M00PostEntry*/
92 | /*}#1HI98V9M00PostEntry*/
93 | return result;
94 | },
95 | /*#{1HI98V9M00MoreAgentAttrs*/
96 | /*}#1HI98V9M00MoreAgentAttrs*/
97 | };
98 | /*#{1HI98V9M00PostAgent*/
99 | /*}#1HI98V9M00PostAgent*/
100 | return agent;
101 | };
102 | /*#{1HI98V9M00ExCodes*/
103 | /*}#1HI98V9M00ExCodes*/
104 |
105 |
106 | export default LoadStory;
107 | export{LoadStory};
108 | /*Cody Project Doc*/
109 | //{
110 | // "type": "docfile",
111 | // "def": "DocAIAgent",
112 | // "jaxId": "1HI98V9M00",
113 | // "editVersion": 40,
114 | // "attrs": {
115 | // "editObjs": {
116 | // "type": "object",
117 | // "def": "Object",
118 | // "jaxId": "1HI98V9M01",
119 | // "editVersion": 2,
120 | // "attrs": {
121 | // "LoadStory": {
122 | // "type": "objclass",
123 | // "def": "ObjClass",
124 | // "jaxId": "1HI98V9M10",
125 | // "editVersion": 28,
126 | // "attrs": {
127 | // "constructArgs": {
128 | // "type": "object",
129 | // "jaxId": "1HI98V9M11",
130 | // "editVersion": 0,
131 | // "attrs": {}
132 | // },
133 | // "superClass": "",
134 | // "properties": {
135 | // "type": "object",
136 | // "def": "Object",
137 | // "jaxId": "1HI98V9M12",
138 | // "editVersion": 0,
139 | // "attrs": {}
140 | // },
141 | // "functions": {
142 | // "type": "object",
143 | // "def": "Functions",
144 | // "jaxId": "1HI98V9M13",
145 | // "editVersion": 0,
146 | // "attrs": {}
147 | // },
148 | // "mockupOnly": "false",
149 | // "nullMockup": "false"
150 | // },
151 | // "mockups": {}
152 | // }
153 | // }
154 | // },
155 | // "agent": {
156 | // "type": "object",
157 | // "def": "Object",
158 | // "jaxId": "1HI98V9M02",
159 | // "editVersion": 0,
160 | // "attrs": {}
161 | // },
162 | // "segs": {
163 | // "type": "array",
164 | // "attrs": [
165 | // {
166 | // "type": "aiseg",
167 | // "def": "askFile",
168 | // "jaxId": "1HI990Q8I0",
169 | // "editVersion": 96,
170 | // "attrs": {
171 | // "id": "ChooseFile",
172 | // "label": "New AI Seg",
173 | // "x": "140",
174 | // "y": "260",
175 | // "context": {
176 | // "type": "object",
177 | // "def": "Object",
178 | // "jaxId": "1HI990Q8M0",
179 | // "editVersion": 0,
180 | // "attrs": {}
181 | // },
182 | // "global": {
183 | // "type": "object",
184 | // "def": "Object",
185 | // "jaxId": "1HI990Q8M1",
186 | // "editVersion": 0,
187 | // "attrs": {}
188 | // },
189 | // "desc": "这是一个AISeg。",
190 | // "codes": "false",
191 | // "mkpInput": "$$input$$",
192 | // "prompt": "请选择故事文件",
193 | // "path": "/doc/",
194 | // "fileSys": "tabos",
195 | // "filter": "*.json",
196 | // "read": "No",
197 | // "outlet": {
198 | // "type": "aioutlet",
199 | // "def": "AISegOutlet",
200 | // "jaxId": "1HI990Q8J0",
201 | // "editVersion": 18,
202 | // "attrs": {
203 | // "id": "Result",
204 | // "desc": "输出节点。"
205 | // },
206 | // "linkedSeg": "1HI995AAQ0"
207 | // }
208 | // }
209 | // },
210 | // {
211 | // "type": "aiseg",
212 | // "def": "code",
213 | // "jaxId": "1HI995AAQ0",
214 | // "editVersion": 52,
215 | // "attrs": {
216 | // "id": "ParseData",
217 | // "label": "New AI Seg",
218 | // "x": "380",
219 | // "y": "260",
220 | // "context": {
221 | // "type": "object",
222 | // "def": "Object",
223 | // "jaxId": "1HI995AAR0",
224 | // "editVersion": 0,
225 | // "attrs": {}
226 | // },
227 | // "global": {
228 | // "type": "object",
229 | // "def": "Object",
230 | // "jaxId": "1HI995AAR1",
231 | // "editVersion": 0,
232 | // "attrs": {}
233 | // },
234 | // "desc": "这是一个AISeg。",
235 | // "codes": "true",
236 | // "mkpInput": "$$input$$",
237 | // "outlet": {
238 | // "type": "aioutlet",
239 | // "def": "AISegOutlet",
240 | // "jaxId": "1HI995AAQ1",
241 | // "editVersion": 14,
242 | // "attrs": {
243 | // "id": "Result",
244 | // "desc": "输出节点。"
245 | // }
246 | // },
247 | // "result": ""
248 | // }
249 | // }
250 | // ]
251 | // },
252 | // "entry": "",
253 | // "autoStart": "true",
254 | // "debug": "true",
255 | // "localVars": {
256 | // "type": "object",
257 | // "def": "Object",
258 | // "jaxId": "1HI98V9M03",
259 | // "editVersion": 0,
260 | // "attrs": {}
261 | // },
262 | // "context": {
263 | // "type": "object",
264 | // "def": "Object",
265 | // "jaxId": "1HI98V9M04",
266 | // "editVersion": 0,
267 | // "attrs": {}
268 | // },
269 | // "globalMockup": {
270 | // "type": "object",
271 | // "def": "Object",
272 | // "jaxId": "1HI98V9M05",
273 | // "editVersion": 0,
274 | // "attrs": {}
275 | // },
276 | // "desc": "这是一个AI代理。",
277 | // "exportAPI": "false",
278 | // "apiArgs": {
279 | // "type": "object",
280 | // "def": "Object",
281 | // "jaxId": "1HI98V9M06",
282 | // "editVersion": 0,
283 | // "attrs": {}
284 | // }
285 | // }
286 | //}
--------------------------------------------------------------------------------
/ai/UpdatePack.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {$P,VFACT,callAfter} from "/@vfact";
3 | import pathLib from "/@path";
4 | import inherits from "/@inherits";
5 | import Base64 from "/@tabos/utils/base64.js";
6 | import {trimJSON} from "/@aichat/utils.js";
7 | /*#{1HIBTGACI0MoreImports*/
8 | import config from "./config.js";
9 | /*}#1HIBTGACI0MoreImports*/
10 | const agentURL=(new URL(import.meta.url)).pathname;
11 | const basePath=pathLib.dirname(agentURL);
12 | const $ln=VFACT.lanCode||"EN";
13 | /*#{1HIBTGACI0StartDoc*/
14 | /*}#1HIBTGACI0StartDoc*/
15 | //----------------------------------------------------------------------------
16 | let UpdatePack=async function(session){
17 | let context,globalContext;
18 | let self;
19 | let DoPack,PackMem;
20 | /*#{1HIBTGACI0LocalVals*/
21 | let PACK_SEG_NUM=config.PACK_SEG_NUM;
22 | /*}#1HIBTGACI0LocalVals*/
23 |
24 | /*#{1HIBTGACI0PreContext*/
25 | /*}#1HIBTGACI0PreContext*/
26 | globalContext=session.globalContext;
27 | context={};
28 | context=VFACT.flexState(context);
29 | /*#{1HIBTGACI0PostContext*/
30 | /*}#1HIBTGACI0PostContext*/
31 | let agent,segs={};
32 | segs["DoPack"]=DoPack=async function(input){//:1HIBTKJ2N0
33 | let result=""
34 | /*#{1HIBTKJ2N0Code*/
35 | let mode,segIdx;
36 | let packs=globalContext.PackedSegs;
37 | let segs=globalContext.StorySegs;
38 | let packedSegNum=packs.length*PACK_SEG_NUM;
39 | mode=input.mode;
40 | segIdx=input.seg;
41 | if(segIdx>=packedSegNum){
42 | return {result:result};//No need to update:
43 | }
44 | if(mode==="delete"){
45 | let startCnt;
46 | let endCnt;
47 | let i,list,content;
48 | endCnt=Math.floor(segIdx/PACK_SEG_NUM)-1;
49 | startCnt=Math.floor(segIdx/PACK_SEG_NUM);
50 | for(i=startCnt;iitem.text);
52 | content=list.join("\n");
53 | packs[i]=(await PackMem(content)).result.brief;
54 | }
55 | }else{
56 | let packIdx;
57 | let content="";
58 | let i;
59 | packIdx=Math.floor(segIdx/PACK_SEG_NUM);
60 | for(i=packIdx*PACK_SEG_NUM;i=PACK_SEG_NUM*2){
41 | list=list.slice(packed*PACK_SEG_NUM,packed*PACK_SEG_NUM+PACK_SEG_NUM).map(item=>item.text);
42 | input=list.join("\n");
43 | }else{
44 | input="";
45 | return {result:null};
46 | }
47 | /*}#1HE54ITR30Input*/
48 |
49 | let opts={
50 | mode:"gpt-4-1106-preview",
51 | maxToken:2800,
52 | temperature:0,
53 | topP:1,
54 | fqcP:0,
55 | prcP:0,
56 | secret:false,
57 | responseFormat:"json_object"
58 | };
59 | let chatMem=PackMem.messages
60 | let seed="";
61 | if(seed!==undefined){opts.seed=seed;}
62 | let messages=[
63 | {role:"system",content:"你是一个提炼总结小说段落内容的AI。根据用户提供的小说段落内容,提炼摘要,注意要包括对故事情节可能产生影响的内容。\n请使用JSON输出,格式为:\n{\n\t\"brief\":\"总结的摘要内容\"\n}"},
64 | ];
65 | /*#{1HE54ITR30PrePrompt*/
66 | /*}#1HE54ITR30PrePrompt*/
67 | prompt=`
68 | 需要提炼内容的小说段落:
69 |
70 | \`\`\`
71 | ${input}
72 | \`\`\`
73 |
74 | 请用JSON格式输出提炼后的内容:
75 | `;
76 | if(prompt!==null){
77 | messages.push({role:"user",content:prompt});
78 | }
79 | /*#{1HE54ITR30PreCall*/
80 | /*}#1HE54ITR30PreCall*/
81 | result=(result===null)?(await session.callSegLLM("PackMem@"+agentURL,opts,messages,true)):result;
82 | result=trimJSON(result);
83 | /*#{1HE54ITR30PostCall*/
84 | let memory;
85 | memory=result.brief;
86 | if(memory){
87 | globalContext.PackedSegs.push(memory);
88 | result=memory;
89 | }else{
90 | memory=null;
91 | }
92 | /*}#1HE54ITR30PostCall*/
93 | return {seg:LogMemory,result:(result),preSeg:"1HE54ITR30",outlet:"1HE54ITR31"};
94 | };
95 | PackMem.jaxId="1HE54ITR30"
96 | PackMem.url="PackMem@"+agentURL
97 |
98 | segs["LogMemory"]=LogMemory=async function(input){//:1HE5KFKGL0
99 | let result=input;
100 | let role="event";
101 | let content=`New memory: ${globalContext.PackedSegs.join("\n")}`;
102 | /*#{1HE5KFKGL0PreCodes*/
103 | /*}#1HE5KFKGL0PreCodes*/
104 | session.addChatText(role,content);
105 | /*#{1HE5KFKGL0PostCodes*/
106 | /*}#1HE5KFKGL0PostCodes*/
107 | return {result:result};
108 | };
109 | LogMemory.jaxId="1HE5KFKGL0"
110 | LogMemory.url="LogMemory@"+agentURL
111 |
112 | agent={
113 | isAIAgent:true,
114 | session:session,
115 | name:"mem",
116 | url:agentURL,
117 | autoStart:true,
118 | jaxId:"1HE544DRT0",
119 | context:context,
120 | livingSeg:null,
121 | execChat:async function(input){
122 | let result;
123 | /*#{1HE544DRT0PreEntry*/
124 | /*}#1HE544DRT0PreEntry*/
125 | result={seg:PackMem,"input":input};
126 | /*#{1HE544DRT0PostEntry*/
127 | /*}#1HE544DRT0PostEntry*/
128 | return result;
129 | },
130 | /*#{1HE544DRT0MoreAgentAttrs*/
131 | /*}#1HE544DRT0MoreAgentAttrs*/
132 | };
133 | /*#{1HE544DRT0PostAgent*/
134 | /*}#1HE544DRT0PostAgent*/
135 | return agent;
136 | };
137 | /*#{1HE544DRT0ExCodes*/
138 | /*}#1HE544DRT0ExCodes*/
139 |
140 |
141 | export default mem;
142 | export{mem};
143 | /*Cody Project Doc*/
144 | //{
145 | // "type": "docfile",
146 | // "def": "DocAIAgent",
147 | // "jaxId": "1HE544DRT0",
148 | // "editVersion": 24,
149 | // "attrs": {
150 | // "editObjs": {
151 | // "type": "object",
152 | // "def": "Object",
153 | // "jaxId": "1HE544DRT1",
154 | // "editVersion": 2,
155 | // "attrs": {
156 | // "mem": {
157 | // "type": "objclass",
158 | // "def": "ObjClass",
159 | // "jaxId": "1HE544DRT6",
160 | // "editVersion": 20,
161 | // "attrs": {
162 | // "constructArgs": {
163 | // "type": "object",
164 | // "jaxId": "1HE544DRU0",
165 | // "editVersion": 0,
166 | // "attrs": {}
167 | // },
168 | // "superClass": "",
169 | // "properties": {
170 | // "type": "object",
171 | // "def": "Object",
172 | // "jaxId": "1HE544DRU1",
173 | // "editVersion": 0,
174 | // "attrs": {}
175 | // },
176 | // "functions": {
177 | // "type": "object",
178 | // "def": "Functions",
179 | // "jaxId": "1HE544DRU2",
180 | // "editVersion": 0,
181 | // "attrs": {}
182 | // },
183 | // "mockupOnly": "false",
184 | // "nullMockup": "false"
185 | // },
186 | // "mockups": {}
187 | // }
188 | // }
189 | // },
190 | // "agent": {
191 | // "type": "object",
192 | // "def": "Object",
193 | // "jaxId": "1HE544DRT2",
194 | // "editVersion": 0,
195 | // "attrs": {}
196 | // },
197 | // "segs": {
198 | // "type": "array",
199 | // "attrs": [
200 | // {
201 | // "type": "aiseg",
202 | // "def": "callLLM",
203 | // "jaxId": "1HE54ITR30",
204 | // "editVersion": 173,
205 | // "attrs": {
206 | // "id": "PackMem",
207 | // "label": "New AI Seg",
208 | // "x": "140",
209 | // "y": "220",
210 | // "context": {
211 | // "type": "object",
212 | // "def": "Object",
213 | // "jaxId": "1HE54ITR60",
214 | // "editVersion": 0,
215 | // "attrs": {}
216 | // },
217 | // "global": {
218 | // "type": "object",
219 | // "def": "Object",
220 | // "jaxId": "1HE54ITR61",
221 | // "editVersion": 0,
222 | // "attrs": {}
223 | // },
224 | // "desc": "执行一次LLM调用。",
225 | // "codes": "true",
226 | // "mkpInput": "[\t{\"role\":\"user\":\"My name is Bob\"},\t{\"role\":\"assistant\":\"Hello bob.\"},]",
227 | // "mode": "GPT-4 Turbo",
228 | // "system": "你是一个提炼总结小说段落内容的AI。根据用户提供的小说段落内容,提炼摘要,注意要包括对故事情节可能产生影响的内容。\n请使用JSON输出,格式为:\n{\n\t\"brief\":\"总结的摘要内容\"\n}",
229 | // "temperature": "0",
230 | // "maxToken": "2800",
231 | // "topP": "1",
232 | // "fqcP": "0",
233 | // "prcP": "0",
234 | // "messages": {
235 | // "type": "array",
236 | // "attrs": []
237 | // },
238 | // "prompt": "#`\n需要提炼内容的小说段落:\n\n\\`\\`\\`\n${input}\n\\`\\`\\`\n\n请用JSON格式输出提炼后的内容:\n`",
239 | // "seed": "",
240 | // "outlet": {
241 | // "type": "aioutlet",
242 | // "def": "AISegOutlet",
243 | // "jaxId": "1HE54ITR31",
244 | // "editVersion": 42,
245 | // "attrs": {
246 | // "id": "Result",
247 | // "desc": "输出节点。"
248 | // },
249 | // "linkedSeg": "1HE5KFKGL0"
250 | // },
251 | // "secret": "false",
252 | // "allowCheat": "false",
253 | // "GPTCheats": {
254 | // "type": "array",
255 | // "attrs": []
256 | // },
257 | // "shareChatName": "",
258 | // "keepChat": "No",
259 | // "clearChat": "2",
260 | // "apiFiles": {
261 | // "type": "array",
262 | // "def": "FileArray",
263 | // "attrs": []
264 | // },
265 | // "parallelFunction": "false",
266 | // "responseFormat": "json_object",
267 | // "inputPrefix": "",
268 | // "inputPostfix": ""
269 | // }
270 | // },
271 | // {
272 | // "type": "aiseg",
273 | // "def": "output",
274 | // "jaxId": "1HE5KFKGL0",
275 | // "editVersion": 96,
276 | // "attrs": {
277 | // "id": "LogMemory",
278 | // "label": "New AI Seg",
279 | // "x": "350",
280 | // "y": "220",
281 | // "context": {
282 | // "type": "object",
283 | // "def": "Object",
284 | // "jaxId": "1HE5KHHTS0",
285 | // "editVersion": 0,
286 | // "attrs": {}
287 | // },
288 | // "global": {
289 | // "type": "object",
290 | // "def": "Object",
291 | // "jaxId": "1HE5KHHTS1",
292 | // "editVersion": 0,
293 | // "attrs": {}
294 | // },
295 | // "desc": "这是一个AISeg。",
296 | // "codes": "true",
297 | // "mkpInput": "$$input$$",
298 | // "role": "Event",
299 | // "text": "#`New memory: ${globalContext.PackedSegs.join(\"\\n\")}`",
300 | // "outlet": {
301 | // "type": "aioutlet",
302 | // "def": "AISegOutlet",
303 | // "jaxId": "1HE5KFKGL1",
304 | // "editVersion": 26,
305 | // "attrs": {
306 | // "id": "Result",
307 | // "desc": "输出节点。"
308 | // }
309 | // }
310 | // }
311 | // }
312 | // ]
313 | // },
314 | // "entry": "",
315 | // "autoStart": "true",
316 | // "debug": "true",
317 | // "localVars": {
318 | // "type": "object",
319 | // "def": "Object",
320 | // "jaxId": "1HE544DRT3",
321 | // "editVersion": 0,
322 | // "attrs": {}
323 | // },
324 | // "context": {
325 | // "type": "object",
326 | // "def": "Object",
327 | // "jaxId": "1HE544DRT4",
328 | // "editVersion": 0,
329 | // "attrs": {}
330 | // },
331 | // "globalMockup": {
332 | // "type": "object",
333 | // "def": "Object",
334 | // "jaxId": "1HE544DRT5",
335 | // "editVersion": 16,
336 | // "attrs": {
337 | // "memory": {
338 | // "type": "string",
339 | // "valText": "user like red"
340 | // },
341 | // "packMemMode": {
342 | // "type": "string",
343 | // "valText": "GPT4"
344 | // }
345 | // }
346 | // },
347 | // "desc": "这是一个AI代理。",
348 | // "exportAPI": "false",
349 | // "apiArgs": {
350 | // "type": "object",
351 | // "def": "Object",
352 | // "jaxId": "1HI96L9970",
353 | // "editVersion": 0,
354 | // "attrs": {}
355 | // }
356 | // }
357 | //}
--------------------------------------------------------------------------------
/cfg/appCfg.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {VFACT} from "/@vfact";
3 | /*#{Imports*/
4 | /*}#Imports*/
5 | var cfgURL=import.meta.url+"1GGJKJ2SR0;"
6 | /*#{StartDoc*/
7 | if(VFACT.lanCode===null){
8 | let userLanguages = navigator.languages || [navigator.language || navigator.userLanguage];
9 | let userLanguage = userLanguages[0];
10 | let languageCode = userLanguage.substring(0, 2).toUpperCase();
11 | switch(languageCode){
12 | case "ZH":
13 | languageCode="CN";
14 | break;
15 | }
16 | VFACT.lanCode=languageCode;
17 | }
18 | /*}#StartDoc*/
19 | let darkMode=false;
20 | let colors={
21 | "primary":[13,110,253,1],"secondary":[108,117,125,1],"success":[0,128,0,1],"warning":[255,128,12,1],"error":[240,0,0,1],"dark":[30,30,30,1],"light":[250,250,250,1]
22 | };
23 | darkMode=VFACT.darkMode===null?darkMode:VFACT.darkMode;
24 | VFACT.darkMode=darkMode;
25 | if(!window.codyAppCfgs){
26 | window.codyAppCfgs={};
27 | }
28 | /*#{StartObj*/
29 | /*}#StartObj*/
30 | //----------------------------------------------------------------------------
31 | let appCfg=window.codyAppCfgs[cfgURL]||{//"jaxId":"1GGJKJ2SQ0"
32 | "darkMode":darkMode,"version":"0.0.1",
33 | "txtSize":{
34 | "small":12,"mid":16,"big":20,"smallPlus":14,"midPlus":18,"bigPlus":25,"large":30,"largePlus":35,"huge":40,"hugePlus":50
35 | },
36 | "size":{
37 | "menuLineH":24
38 | },
39 | "color":{
40 | "body":darkMode?[55,55,55,1.00]:[255,255,255,1.00],"primary":colors.primary,"secondary":colors.secondary,"success":colors.success,"warning":colors.warning,
41 | "error":colors.error,"fontBody":darkMode?[255,255,255,1]:[0,0,0,1.00],"fontBodySub":darkMode?[240,240,240,1.00]:[80,80,80,1.00],"fontBodyLit":darkMode?[120,120,120,1]:[180,180,180,1.00],
42 | "fontPrimary":[255,255,255,1],"fontPrimarySub":[...colors.primary,80],"fontPrimaryLit":[...colors.primary,40],"fontSecondary":[255,255,255,1],"fontSecondarySub":[...colors.secondary,80.00],
43 | "fontSecondaryLit":[...colors.secondary,40.00],"fontSuccess":[255,255,255,1],"fontSuccessSub":[...colors.success,80.00],"fontSuccessLit":[...colors.success,40.00],
44 | "fontWarning":[255,255,255,1],"fontWarningSub":[...colors.warning,80],"fontWarningLit":[...colors.warning,40],"fontError":[255,255,255,1],"fontErrorSub":[...colors.error,80],
45 | "fontErrorLit":[...colors.error,40],"lineBody":darkMode?[255,255,255,1]:[0,0,0,1.00],"lineBodySub":darkMode?[240,240,240,1.00]:[80,80,80,1.00],"lineBodyLit":darkMode?[120,120,120,1]:[180,180,180,1.00],
46 | "front":[0,0,0,1],"fontFront":[255,255,255,1],"fontFrontSub":[240,240,240,1],"fontFrontLit":[80,80,80,1],"itemOver":[240,240,240,1],"itemDown":[200,200,200,1],
47 | "itemFocus":[13,110,253,1,80],"itemGray":[200,200,200,1]
48 | },
49 | "sharedAssets":"/~/-tabos/shared/assets","lanCode":"CN",
50 | /*#{ExAttrs*/
51 | /*}#ExAttrs*/
52 | };
53 | window.codyAppCfgs[cfgURL]=appCfg;
54 | appCfg.lanCode=VFACT.lanCode===null?"EN":(VFACT.lanCode||"EN");
55 | VFACT.lanCode=appCfg.lanCode;
56 | if(!VFACT.appCfg){
57 | VFACT.appCfg=appCfg;
58 | window.jaxAppCfg=appCfg;
59 | }
60 | appCfg.applyCfg=function(){
61 | let majorCfg,attrName,cAttr,mAttr;
62 | majorCfg=VFACT.appCfg||window.jaxAppCfg;
63 | if(majorCfg && majorCfg!==appCfg){
64 | for(attrName in appCfg){
65 | if(attrName in majorCfg){
66 | cAttr=appCfg[attrName];
67 | mAttr=majorCfg[attrName];
68 | if(typeof(cAttr)==="object"){
69 | if(typeof(mAttr)==="object"){
70 | Object.assign(cAttr,mAttr);
71 | }
72 | }else if(attrName!=="applyCfg" && attrName!=="proxyCfg"){
73 | appCfg[attrName]=mAttr;
74 | }
75 | }
76 | }
77 | }
78 | };
79 | appCfg.proxyCfg=function(proxy){
80 | if(window.codyAppCfgs[cfgURL]===appCfg){
81 | window.codyAppCfgs[cfgURL]=proxy;
82 | }
83 | appCfg=proxy;
84 | };
85 |
86 | /*#{EndDoc*/
87 | /*}#EndDoc*/
88 |
89 | export{appCfg};
90 | /*Cody Project Doc*/
91 | //{
92 | // "type": "docfile",
93 | // "def": "appCfg",
94 | // "jaxId": "1GGJKJ2SR0",
95 | // "editVersion": 8,
96 | // "attrs": {
97 | // "localVars": {
98 | // "type": "object",
99 | // "jaxId": "1GGJKJ2SR1",
100 | // "editVersion": 10,
101 | // "attrs": {
102 | // "darkMode": "false",
103 | // "colors": {
104 | // "type": "object",
105 | // "def": "Object",
106 | // "jaxId": "1GGJM2JI80",
107 | // "editVersion": 56,
108 | // "attrs": {
109 | // "primary": {
110 | // "type": "colorRGBA",
111 | // "valText": "[13,110,253,1]"
112 | // },
113 | // "secondary": {
114 | // "type": "colorRGBA",
115 | // "valText": "[108,117,125,1]"
116 | // },
117 | // "success": {
118 | // "type": "colorRGBA",
119 | // "valText": "[0,128,0,1.00]"
120 | // },
121 | // "warning": {
122 | // "type": "colorRGBA",
123 | // "valText": "[255,128,12,1]"
124 | // },
125 | // "error": {
126 | // "type": "colorRGBA",
127 | // "valText": "[240,0,0,1.00]"
128 | // },
129 | // "dark": {
130 | // "type": "colorRGBA",
131 | // "valText": "[30,30,30,1.00]"
132 | // },
133 | // "light": {
134 | // "type": "colorRGBA",
135 | // "valText": "[250,250,250,1]"
136 | // }
137 | // }
138 | // }
139 | // }
140 | // },
141 | // "editObjs": {
142 | // "type": "object",
143 | // "jaxId": "1GGJKJ2SR2",
144 | // "editVersion": 2,
145 | // "attrs": {
146 | // "appCfg": {
147 | // "type": "object",
148 | // "jaxId": "1GGJKJ2SQ0",
149 | // "editVersion": 16,
150 | // "attrs": {
151 | // "darkMode": "#darkMode",
152 | // "version": "0.0.1",
153 | // "txtSize": {
154 | // "type": "object",
155 | // "def": "Object",
156 | // "jaxId": "1GGJKJ2SR3",
157 | // "editVersion": 94,
158 | // "attrs": {
159 | // "small": "12",
160 | // "mid": "16",
161 | // "big": "20",
162 | // "smallPlus": {
163 | // "type": "int",
164 | // "valText": "14"
165 | // },
166 | // "midPlus": {
167 | // "type": "int",
168 | // "valText": "18"
169 | // },
170 | // "bigPlus": {
171 | // "type": "int",
172 | // "valText": "25"
173 | // },
174 | // "large": {
175 | // "type": "int",
176 | // "valText": "30"
177 | // },
178 | // "largePlus": {
179 | // "type": "int",
180 | // "valText": "35"
181 | // },
182 | // "huge": {
183 | // "type": "int",
184 | // "valText": "40"
185 | // },
186 | // "hugePlus": {
187 | // "type": "int",
188 | // "valText": "50"
189 | // }
190 | // }
191 | // },
192 | // "size": {
193 | // "type": "object",
194 | // "def": "Object",
195 | // "jaxId": "1GGJKJ2SR4",
196 | // "editVersion": 2,
197 | // "attrs": {
198 | // "menuLineH": "24"
199 | // }
200 | // },
201 | // "color": {
202 | // "type": "object",
203 | // "def": "Object",
204 | // "jaxId": "1GGJKJ2SR5",
205 | // "editVersion": 382,
206 | // "attrs": {
207 | // "body": {
208 | // "type": "colorRGBA",
209 | // "valText": "#darkMode?[55,55,55,1.00]:[255,255,255,1.00]"
210 | // },
211 | // "primary": {
212 | // "type": "colorRGBA",
213 | // "valText": "#colors.primary"
214 | // },
215 | // "secondary": {
216 | // "type": "colorRGBA",
217 | // "valText": "#colors.secondary"
218 | // },
219 | // "success": {
220 | // "type": "colorRGBA",
221 | // "valText": "#colors.success"
222 | // },
223 | // "warning": {
224 | // "type": "colorRGBA",
225 | // "valText": "#colors.warning"
226 | // },
227 | // "error": {
228 | // "type": "colorRGBA",
229 | // "valText": "#colors.error"
230 | // },
231 | // "fontBody": {
232 | // "type": "colorRGBA",
233 | // "valText": "#darkMode?[255,255,255,1]:[0,0,0,1.00]"
234 | // },
235 | // "fontBodySub": {
236 | // "type": "colorRGBA",
237 | // "valText": "#darkMode?[240,240,240,1.00]:[80,80,80,1.00]"
238 | // },
239 | // "fontBodyLit": {
240 | // "type": "colorRGBA",
241 | // "valText": "#darkMode?[120,120,120,1]:[180,180,180,1.00]"
242 | // },
243 | // "fontPrimary": {
244 | // "type": "colorRGBA",
245 | // "valText": "[255,255,255,1.00]"
246 | // },
247 | // "fontPrimarySub": {
248 | // "type": "colorRGBA",
249 | // "valText": "#[...colors.primary,80]"
250 | // },
251 | // "fontPrimaryLit": {
252 | // "type": "colorRGBA",
253 | // "valText": "#[...colors.primary,40]"
254 | // },
255 | // "fontSecondary": {
256 | // "type": "colorRGBA",
257 | // "valText": "[255,255,255,1.00]"
258 | // },
259 | // "fontSecondarySub": {
260 | // "type": "colorRGBA",
261 | // "valText": "#[...colors.secondary,80.00]"
262 | // },
263 | // "fontSecondaryLit": {
264 | // "type": "colorRGBA",
265 | // "valText": "#[...colors.secondary,40.00]"
266 | // },
267 | // "fontSuccess": {
268 | // "type": "colorRGBA",
269 | // "valText": "[255,255,255,1.00]"
270 | // },
271 | // "fontSuccessSub": {
272 | // "type": "colorRGBA",
273 | // "valText": "#[...colors.success,80.00]"
274 | // },
275 | // "fontSuccessLit": {
276 | // "type": "colorRGBA",
277 | // "valText": "#[...colors.success,40.00]"
278 | // },
279 | // "fontWarning": {
280 | // "type": "colorRGBA",
281 | // "valText": "[255,255,255,1.00]"
282 | // },
283 | // "fontWarningSub": {
284 | // "type": "colorRGBA",
285 | // "valText": "#[...colors.warning,80]"
286 | // },
287 | // "fontWarningLit": {
288 | // "type": "colorRGBA",
289 | // "valText": "#[...colors.warning,40]"
290 | // },
291 | // "fontError": {
292 | // "type": "colorRGBA",
293 | // "valText": "[255,255,255,1.00]"
294 | // },
295 | // "fontErrorSub": {
296 | // "type": "colorRGBA",
297 | // "valText": "#[...colors.error,80]"
298 | // },
299 | // "fontErrorLit": {
300 | // "type": "colorRGBA",
301 | // "valText": "#[...colors.error,40]"
302 | // },
303 | // "lineBody": {
304 | // "type": "colorRGBA",
305 | // "valText": "#darkMode?[255,255,255,1]:[0,0,0,1.00]"
306 | // },
307 | // "lineBodySub": {
308 | // "type": "colorRGBA",
309 | // "valText": "#darkMode?[240,240,240,1.00]:[80,80,80,1.00]"
310 | // },
311 | // "lineBodyLit": {
312 | // "type": "colorRGBA",
313 | // "valText": "#darkMode?[120,120,120,1]:[180,180,180,1.00]"
314 | // },
315 | // "front": "[0,0,0,1]",
316 | // "fontFront": "[255,255,255,1]",
317 | // "fontFrontSub": "[240,240,240,1]",
318 | // "fontFrontLit": "[80,80,80,1]",
319 | // "itemOver": "[240,240,240,1]",
320 | // "itemDown": "[200,200,200,1]",
321 | // "itemFocus": "[13,110,253,1,80]",
322 | // "itemGray": "[200,200,200,1]"
323 | // }
324 | // },
325 | // "sharedAssets": "\"/~/-tabos/shared/assets\"",
326 | // "lanCode": "\"CN\""
327 | // }
328 | // }
329 | // }
330 | // }
331 | // }
332 | //}
--------------------------------------------------------------------------------
/ai/ExportStory.js:
--------------------------------------------------------------------------------
1 | //Auto genterated by Cody
2 | import {$P,VFACT,callAfter} from "/@vfact";
3 | import pathLib from "/@path";
4 | import inherits from "/@inherits";
5 | import Base64 from "/@tabos/utils/base64.js";
6 | import {trimJSON} from "/@aichat/utils.js";
7 | /*#{1HIAN9JQ30MoreImports*/
8 | import markdownit from "/@markdownit";
9 | /*}#1HIAN9JQ30MoreImports*/
10 | const agentURL=(new URL(import.meta.url)).pathname;
11 | const basePath=pathLib.dirname(agentURL);
12 | const $ln=VFACT.lanCode||"EN";
13 | /*#{1HIAN9JQ30StartDoc*/
14 | /*}#1HIAN9JQ30StartDoc*/
15 | //----------------------------------------------------------------------------
16 | let ExportStory=async function(session){
17 | let context,globalContext;
18 | let self;
19 | let GetMode,Markdown,HTML,JSON,Download,Done,Report,Abort;
20 | /*#{1HIAN9JQ30LocalVals*/
21 | /*}#1HIAN9JQ30LocalVals*/
22 |
23 | /*#{1HIAN9JQ30PreContext*/
24 | /*}#1HIAN9JQ30PreContext*/
25 | globalContext=session.globalContext;
26 | context={
27 | "fileName":"",
28 | /*#{1HIAN9JQ43ExCtxAttrs*/
29 | /*}#1HIAN9JQ43ExCtxAttrs*/
30 | };
31 | context=VFACT.flexState(context);
32 | /*#{1HIAN9JQ30PostContext*/
33 | /*}#1HIAN9JQ30PostContext*/
34 | let agent,segs={};
35 | segs["GetMode"]=GetMode=async function(input){//:1HIANEKMB0
36 | let prompt=("请选择输出格式:")||input;
37 | let items=[
38 | {icon:"/~/-tabos/shared/assets/web.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:`输出为HTML文件(${globalContext.StoryTitle}.html)`,code:0},
39 | {icon:"/~/-tabos/shared/assets/filemd.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:`输出为Mardown格式文件(${globalContext.StoryTitle}.md)`,code:1},
40 | {icon:"/~/-tabos/shared/assets/appdata.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:`工程文件(${globalContext.StoryTitle}.json)`,code:2},
41 | {icon:"/~/-tabos/shared/assets/close.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"放弃输出",code:3},
42 | ];
43 | let result="";
44 | let item=null;
45 | let multi=false;
46 |
47 | [result,item]=await session.askUserRaw({type:"menu",prompt:prompt,multiSelect:multi,items:items});
48 | if(multi){
49 | return {seg:HTML,result:(result),preSeg:"1HIANEKMB0",outlet:"1HIANA1F40"};
50 | }
51 | if(item.code===0){
52 | return {seg:HTML,result:(result),preSeg:"1HIANEKMB0",outlet:"1HIANA1F40"};
53 | }
54 | if(item.code===1){
55 | return {seg:Markdown,result:(result),preSeg:"1HIANEKMB0",outlet:"1HIANA1F30"};
56 | }
57 | if(item.code===2){
58 | return {seg:JSON,result:(result),preSeg:"1HIANEKMB0",outlet:"1HIANA1F41"};
59 | }
60 | if(item.code===3){
61 | return {seg:Abort,result:(result),preSeg:"1HIANEKMB0",outlet:"1HIANO1TE0"};
62 | }
63 | return {result:result};
64 |
65 | };
66 | GetMode.jaxId="1HIANEKMB0"
67 | GetMode.url="GetMode@"+agentURL
68 |
69 | segs["Markdown"]=Markdown=async function(input){//:1HIANO1TE1
70 | let result=""
71 | /*#{1HIANO1TE1Code*/
72 | let story=globalContext;
73 | let content;
74 | let segs=story.StorySegs;
75 | segs=segs.map((item)=>{
76 | if(item.image){
77 | return ` \n\n${item.text}`;
78 | }
79 | return " "+item.text;
80 | });
81 | content=segs.join("\n\n");
82 | content=`## ${story.StoryTitle}\n${content}`;
83 | if(story.StoryCover){
84 | content=`\n${content}`;
85 | }
86 | result=content;
87 | context.fileName=`${globalContext.StoryTitle}.md`;
88 | /*}#1HIANO1TE1Code*/
89 | return {seg:Download,result:(result),preSeg:"1HIANO1TE1",outlet:"1HIANO1TE2"};
90 | };
91 | Markdown.jaxId="1HIANO1TE1"
92 | Markdown.url="Markdown@"+agentURL
93 |
94 | segs["HTML"]=HTML=async function(input){//:1HIANO1TE3
95 | let result=""
96 | /*#{1HIANO1TE3Code*/
97 | let mdContent,webObj,content;
98 | let list,i,n,blk,pNode;
99 | mdContent=(await Markdown(input)).result;
100 | webObj=document.createElement("div");
101 | content=markdownit().render(mdContent);
102 | webObj.innerHTML=content;
103 | list=webObj.querySelectorAll("img");
104 | n=list.length;
105 | for(i=0;i
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | ${globalContext.StoryTitle}
125 |
126 |
127 |
128 | Create by StoryWriter, a www.ai2apps.com demo project.
129 |
130 | ${webObj.innerHTML}
131 |
132 | Create by StoryWriter, a www.ai2apps.com demo project.
133 |
134 |
135 |