├── .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 | ![agent.js](assets/agent.png) 26 | 27 | Agent App 的主逻辑智能。 28 | 29 | ### NewStory.js: 创建新的文章 30 | 31 | ![agent.js](assets/NewStory.png) 32 | 33 | - 询问用户文章标题 34 | - 根据用户提示由AI生成文章的背景设定 35 | - 设置文章插图绘制风格 36 | - 可选:绘制文章封面 37 | 38 | 39 | ### WriteSeg.js: 撰写一段文章 40 | 41 | ![agent.js](assets/WriteSeg.png) 42 | 43 | - 根据用户指示撰写一段文章 44 | - 每次生成三个备选供用户选择 45 | - 可选:自动无题事续写 46 | - 可选:增加插图 47 | 48 | ### EditStory.js: 编辑文章 49 | 50 | ![agent.js](assets/EditStory.png) 51 | 52 | - 更改标题 53 | - 修改文章背景设定 54 | - 选择段落,修改段落内容 55 | - 手动修改段落内容 56 | - AI 辅助修改段落内容 57 | - 删除段落 58 | - 添加/更换段落插图 59 | - 删除段落插图 60 | 61 | ### ExportStory.js: 输出文章 62 | 63 | ![agent.js](assets/ExportStory.png) 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 | 17 | 19 | 39 | 42 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 59 | 66 | 70 | 74 | 78 | 79 | 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 `![pic](${item.image}) \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=`![cover](${story.StoryCover})\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 | 136 | ` 137 | context.fileName=`${globalContext.StoryTitle}.html`; 138 | /*}#1HIANO1TE3Code*/ 139 | return {seg:Download,result:(result),preSeg:"1HIANO1TE3",outlet:"1HIANO1TE4"}; 140 | }; 141 | HTML.jaxId="1HIANO1TE3" 142 | HTML.url="HTML@"+agentURL 143 | 144 | segs["JSON"]=JSON=async function(input){//:1HIANO1TE5 145 | let result="" 146 | /*#{1HIANO1TE5Code*/ 147 | let saveVO={}; 148 | saveVO.StoryTitle=globalContext.StoryTitle; 149 | saveVO.StorySegs=globalContext.StorySegs; 150 | saveVO.PackedSegs=globalContext.PackedSegs; 151 | saveVO.DrawStyle=globalContext.DrawStyle; 152 | if(globalContext.StoryCover){ 153 | saveVO.StoryCover=globalContext.StoryCover; 154 | } 155 | result=JSON.stringify(saveVO,null,"\t"); 156 | context.fileName=`${globalContext.StoryTitle}.json`; 157 | /*}#1HIANO1TE5Code*/ 158 | return {seg:Download,result:(result),preSeg:"1HIANO1TE5",outlet:"1HIANO1TE6"}; 159 | }; 160 | JSON.jaxId="1HIANO1TE5" 161 | JSON.url="JSON@"+agentURL 162 | 163 | segs["Download"]=Download=async function(input){//:1HIANO1TE7 164 | let result="" 165 | /*#{1HIANO1TE7Code*/ 166 | let fileName=context.fileName; 167 | function downloadFile(data){ 168 | let e,blob,url; 169 | blob = new Blob([data], {type: "application/octet-stream"}); 170 | url = URL.createObjectURL(blob); 171 | VFACT.webFileDownload.download = fileName; 172 | VFACT.webFileDownload.href = url; 173 | 174 | //Generate a mouse click: 175 | e = document.createEvent('MouseEvents'); 176 | e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 177 | VFACT.webFileDownload.dispatchEvent(e); 178 | 179 | //Release the URLData: 180 | window.setTimeout(() => { 181 | URL.revokeObjectURL(url); 182 | }, 10000); 183 | } 184 | const encoder = new TextEncoder(); 185 | let data = encoder.encode(input); 186 | downloadFile(data); 187 | /*}#1HIANO1TE7Code*/ 188 | return {seg:Report,result:(result),preSeg:"1HIANO1TE7",outlet:"1HIANO1TE8"}; 189 | }; 190 | Download.jaxId="1HIANO1TE7" 191 | Download.url="Download@"+agentURL 192 | 193 | segs["Report"]=Report=async function(input){//:1HIAP2FQE0 194 | let result=input; 195 | let role="event"; 196 | let content="故事输出完毕"; 197 | session.addChatText(role,content); 198 | return {seg:Done,result:(result),preSeg:"1HIAP2FQE0",outlet:"1HIAP2FQE1"}; 199 | }; 200 | Report.jaxId="1HIAP2FQE0" 201 | Report.url="Report@"+agentURL 202 | 203 | segs["Abort"]=Abort=async function(input){//:1HIAP2VKO0 204 | let result=input; 205 | let role="event"; 206 | let content="已取消输出故事"; 207 | session.addChatText(role,content); 208 | return {seg:Done,result:(result),preSeg:"1HIAP2VKO0",outlet:"1HIAP2VKO3"}; 209 | }; 210 | Abort.jaxId="1HIAP2VKO0" 211 | Abort.url="Abort@"+agentURL 212 | 213 | agent={ 214 | isAIAgent:true, 215 | session:session, 216 | name:"ExportStory", 217 | url:agentURL, 218 | autoStart:true, 219 | jaxId:"1HIAN9JQ30", 220 | context:context, 221 | livingSeg:null, 222 | execChat:async function(input){ 223 | let result; 224 | /*#{1HIAN9JQ30PreEntry*/ 225 | /*}#1HIAN9JQ30PreEntry*/ 226 | result={seg:GetMode,"input":input}; 227 | /*#{1HIAN9JQ30PostEntry*/ 228 | /*}#1HIAN9JQ30PostEntry*/ 229 | return result; 230 | }, 231 | /*#{1HIAN9JQ30MoreAgentAttrs*/ 232 | /*}#1HIAN9JQ30MoreAgentAttrs*/ 233 | }; 234 | /*#{1HIAN9JQ30PostAgent*/ 235 | /*}#1HIAN9JQ30PostAgent*/ 236 | return agent; 237 | }; 238 | /*#{1HIAN9JQ30ExCodes*/ 239 | /*}#1HIAN9JQ30ExCodes*/ 240 | 241 | 242 | export default ExportStory; 243 | export{ExportStory}; 244 | /*Cody Project Doc*/ 245 | //{ 246 | // "type": "docfile", 247 | // "def": "DocAIAgent", 248 | // "jaxId": "1HIAN9JQ30", 249 | // "editVersion": 28, 250 | // "attrs": { 251 | // "editObjs": { 252 | // "type": "object", 253 | // "def": "Object", 254 | // "jaxId": "1HIAN9JQ40", 255 | // "editVersion": 2, 256 | // "attrs": { 257 | // "ExportStory": { 258 | // "type": "objclass", 259 | // "def": "ObjClass", 260 | // "jaxId": "1HIAN9JQ50", 261 | // "editVersion": 22, 262 | // "attrs": { 263 | // "constructArgs": { 264 | // "type": "object", 265 | // "jaxId": "1HIAN9JQ51", 266 | // "editVersion": 0, 267 | // "attrs": {} 268 | // }, 269 | // "superClass": "", 270 | // "properties": { 271 | // "type": "object", 272 | // "def": "Object", 273 | // "jaxId": "1HIAN9JQ52", 274 | // "editVersion": 0, 275 | // "attrs": {} 276 | // }, 277 | // "functions": { 278 | // "type": "object", 279 | // "def": "Functions", 280 | // "jaxId": "1HIAN9JQ53", 281 | // "editVersion": 0, 282 | // "attrs": {} 283 | // }, 284 | // "mockupOnly": "false", 285 | // "nullMockup": "false" 286 | // }, 287 | // "mockups": {} 288 | // } 289 | // } 290 | // }, 291 | // "agent": { 292 | // "type": "object", 293 | // "def": "Object", 294 | // "jaxId": "1HIAN9JQ41", 295 | // "editVersion": 0, 296 | // "attrs": {} 297 | // }, 298 | // "segs": { 299 | // "type": "array", 300 | // "attrs": [ 301 | // { 302 | // "type": "aiseg", 303 | // "def": "askMenu", 304 | // "jaxId": "1HIANEKMB0", 305 | // "editVersion": 65, 306 | // "attrs": { 307 | // "id": "GetMode", 308 | // "label": "New AI Seg", 309 | // "x": "150", 310 | // "y": "270", 311 | // "context": { 312 | // "type": "object", 313 | // "def": "Object", 314 | // "jaxId": "1HIANOKE70", 315 | // "editVersion": 0, 316 | // "attrs": {} 317 | // }, 318 | // "global": { 319 | // "type": "object", 320 | // "def": "Object", 321 | // "jaxId": "1HIANOKE71", 322 | // "editVersion": 0, 323 | // "attrs": {} 324 | // }, 325 | // "desc": "这是一个AISeg。", 326 | // "codes": "false", 327 | // "mkpInput": "$$input$$", 328 | // "prompt": "请选择输出格式:", 329 | // "multi": "false", 330 | // "outlets": { 331 | // "type": "array", 332 | // "attrs": [ 333 | // { 334 | // "type": "aioutlet", 335 | // "def": "AIButtonOutlet", 336 | // "jaxId": "1HIANA1F40", 337 | // "editVersion": 41, 338 | // "attrs": { 339 | // "id": "HTML", 340 | // "text": "#`输出为HTML文件(${globalContext.StoryTitle}.html)`", 341 | // "result": "", 342 | // "codes": "false", 343 | // "icon": "/-tabos/shared/assets/web.svg" 344 | // }, 345 | // "linkedSeg": "1HIANO1TE3" 346 | // }, 347 | // { 348 | // "type": "aioutlet", 349 | // "def": "AIButtonOutlet", 350 | // "jaxId": "1HIANA1F30", 351 | // "editVersion": 35, 352 | // "attrs": { 353 | // "id": "Markdown", 354 | // "text": "#`输出为Mardown格式文件(${globalContext.StoryTitle}.md)`", 355 | // "result": "", 356 | // "codes": "false", 357 | // "icon": "/-tabos/shared/assets/filemd.svg" 358 | // }, 359 | // "linkedSeg": "1HIANO1TE1" 360 | // }, 361 | // { 362 | // "type": "aioutlet", 363 | // "def": "AIButtonOutlet", 364 | // "jaxId": "1HIANA1F41", 365 | // "editVersion": 30, 366 | // "attrs": { 367 | // "id": "JSON", 368 | // "text": "#`工程文件(${globalContext.StoryTitle}.json)`", 369 | // "result": "", 370 | // "codes": "false", 371 | // "icon": "/-tabos/shared/assets/appdata.svg" 372 | // }, 373 | // "linkedSeg": "1HIANO1TE5" 374 | // }, 375 | // { 376 | // "type": "aioutlet", 377 | // "def": "AIButtonOutlet", 378 | // "jaxId": "1HIANO1TE0", 379 | // "editVersion": 37, 380 | // "attrs": { 381 | // "id": "Cancel", 382 | // "text": "放弃输出", 383 | // "result": "", 384 | // "codes": "false", 385 | // "icon": "/-tabos/shared/assets/close.svg" 386 | // }, 387 | // "linkedSeg": "1HIAP2VKO0" 388 | // } 389 | // ] 390 | // } 391 | // } 392 | // }, 393 | // { 394 | // "type": "aiseg", 395 | // "def": "code", 396 | // "jaxId": "1HIANO1TE1", 397 | // "editVersion": 69, 398 | // "attrs": { 399 | // "id": "Markdown", 400 | // "label": "New AI Seg", 401 | // "x": "430", 402 | // "y": "160", 403 | // "context": { 404 | // "type": "object", 405 | // "def": "Object", 406 | // "jaxId": "1HIANOKE73", 407 | // "editVersion": 0, 408 | // "attrs": {} 409 | // }, 410 | // "global": { 411 | // "type": "object", 412 | // "def": "Object", 413 | // "jaxId": "1HIANOKE74", 414 | // "editVersion": 0, 415 | // "attrs": {} 416 | // }, 417 | // "desc": "这是一个AISeg。", 418 | // "codes": "true", 419 | // "mkpInput": "$$input$$", 420 | // "outlet": { 421 | // "type": "aioutlet", 422 | // "def": "AISegOutlet", 423 | // "jaxId": "1HIANO1TE2", 424 | // "editVersion": 15, 425 | // "attrs": { 426 | // "id": "Result", 427 | // "desc": "输出节点。" 428 | // }, 429 | // "linkedSeg": "1HIANO1TE7" 430 | // }, 431 | // "result": "" 432 | // } 433 | // }, 434 | // { 435 | // "type": "aiseg", 436 | // "def": "code", 437 | // "jaxId": "1HIANO1TE3", 438 | // "editVersion": 79, 439 | // "attrs": { 440 | // "id": "HTML", 441 | // "label": "New AI Seg", 442 | // "x": "430", 443 | // "y": "100", 444 | // "context": { 445 | // "type": "object", 446 | // "def": "Object", 447 | // "jaxId": "1HIANOKE75", 448 | // "editVersion": 0, 449 | // "attrs": {} 450 | // }, 451 | // "global": { 452 | // "type": "object", 453 | // "def": "Object", 454 | // "jaxId": "1HIANOKE76", 455 | // "editVersion": 0, 456 | // "attrs": {} 457 | // }, 458 | // "desc": "这是一个AISeg。", 459 | // "codes": "true", 460 | // "mkpInput": "$$input$$", 461 | // "outlet": { 462 | // "type": "aioutlet", 463 | // "def": "AISegOutlet", 464 | // "jaxId": "1HIANO1TE4", 465 | // "editVersion": 21, 466 | // "attrs": { 467 | // "id": "Result", 468 | // "desc": "输出节点。" 469 | // }, 470 | // "linkedSeg": "1HIANO1TE7" 471 | // }, 472 | // "result": "" 473 | // } 474 | // }, 475 | // { 476 | // "type": "aiseg", 477 | // "def": "code", 478 | // "jaxId": "1HIANO1TE5", 479 | // "editVersion": 68, 480 | // "attrs": { 481 | // "id": "JSON", 482 | // "label": "New AI Seg", 483 | // "x": "430", 484 | // "y": "220", 485 | // "context": { 486 | // "type": "object", 487 | // "def": "Object", 488 | // "jaxId": "1HIANOKE77", 489 | // "editVersion": 0, 490 | // "attrs": {} 491 | // }, 492 | // "global": { 493 | // "type": "object", 494 | // "def": "Object", 495 | // "jaxId": "1HIANOKE78", 496 | // "editVersion": 0, 497 | // "attrs": {} 498 | // }, 499 | // "desc": "这是一个AISeg。", 500 | // "codes": "true", 501 | // "mkpInput": "$$input$$", 502 | // "outlet": { 503 | // "type": "aioutlet", 504 | // "def": "AISegOutlet", 505 | // "jaxId": "1HIANO1TE6", 506 | // "editVersion": 14, 507 | // "attrs": { 508 | // "id": "Result", 509 | // "desc": "输出节点。" 510 | // }, 511 | // "linkedSeg": "1HIANO1TE7" 512 | // }, 513 | // "result": "" 514 | // } 515 | // }, 516 | // { 517 | // "type": "aiseg", 518 | // "def": "code", 519 | // "jaxId": "1HIANO1TE7", 520 | // "editVersion": 56, 521 | // "attrs": { 522 | // "id": "Download", 523 | // "label": "New AI Seg", 524 | // "x": "660", 525 | // "y": "220", 526 | // "context": { 527 | // "type": "object", 528 | // "def": "Object", 529 | // "jaxId": "1HIANOKE79", 530 | // "editVersion": 0, 531 | // "attrs": {} 532 | // }, 533 | // "global": { 534 | // "type": "object", 535 | // "def": "Object", 536 | // "jaxId": "1HIANOKE710", 537 | // "editVersion": 0, 538 | // "attrs": {} 539 | // }, 540 | // "desc": "这是一个AISeg。", 541 | // "codes": "true", 542 | // "mkpInput": "$$input$$", 543 | // "outlet": { 544 | // "type": "aioutlet", 545 | // "def": "AISegOutlet", 546 | // "jaxId": "1HIANO1TE8", 547 | // "editVersion": 20, 548 | // "attrs": { 549 | // "id": "Result", 550 | // "desc": "输出节点。" 551 | // }, 552 | // "linkedSeg": "1HIAP2FQE0" 553 | // }, 554 | // "result": "" 555 | // } 556 | // }, 557 | // { 558 | // "type": "aiseg", 559 | // "def": "note", 560 | // "jaxId": "1HIANOKE72", 561 | // "editVersion": 44, 562 | // "attrs": { 563 | // "id": "Done", 564 | // "label": "", 565 | // "x": "1110", 566 | // "y": "310", 567 | // "from": "", 568 | // "desc": "这是一个注释。" 569 | // } 570 | // }, 571 | // { 572 | // "type": "aiseg", 573 | // "def": "output", 574 | // "jaxId": "1HIAP2FQE0", 575 | // "editVersion": 66, 576 | // "attrs": { 577 | // "id": "Report", 578 | // "label": "New AI Seg", 579 | // "x": "890", 580 | // "y": "220", 581 | // "context": { 582 | // "type": "object", 583 | // "def": "Object", 584 | // "jaxId": "1HIAP2FQL0", 585 | // "editVersion": 0, 586 | // "attrs": {} 587 | // }, 588 | // "global": { 589 | // "type": "object", 590 | // "def": "Object", 591 | // "jaxId": "1HIAP2FQL1", 592 | // "editVersion": 0, 593 | // "attrs": {} 594 | // }, 595 | // "desc": "这是一个AISeg。", 596 | // "codes": "false", 597 | // "mkpInput": "$$input$$", 598 | // "role": "Event", 599 | // "text": "故事输出完毕", 600 | // "outlet": { 601 | // "type": "aioutlet", 602 | // "def": "AISegOutlet", 603 | // "jaxId": "1HIAP2FQE1", 604 | // "editVersion": 12, 605 | // "attrs": { 606 | // "id": "Result", 607 | // "desc": "输出节点。" 608 | // }, 609 | // "linkedSeg": "1HIANOKE72" 610 | // } 611 | // } 612 | // }, 613 | // { 614 | // "type": "aiseg", 615 | // "def": "output", 616 | // "jaxId": "1HIAP2VKO0", 617 | // "editVersion": 89, 618 | // "attrs": { 619 | // "id": "Abort", 620 | // "label": "New AI Seg", 621 | // "x": "890", 622 | // "y": "310", 623 | // "context": { 624 | // "type": "object", 625 | // "def": "Object", 626 | // "jaxId": "1HIAP2VKO1", 627 | // "editVersion": 0, 628 | // "attrs": {} 629 | // }, 630 | // "global": { 631 | // "type": "object", 632 | // "def": "Object", 633 | // "jaxId": "1HIAP2VKO2", 634 | // "editVersion": 0, 635 | // "attrs": {} 636 | // }, 637 | // "desc": "这是一个AISeg。", 638 | // "codes": "false", 639 | // "mkpInput": "$$input$$", 640 | // "role": "Event", 641 | // "text": "已取消输出故事", 642 | // "outlet": { 643 | // "type": "aioutlet", 644 | // "def": "AISegOutlet", 645 | // "jaxId": "1HIAP2VKO3", 646 | // "editVersion": 12, 647 | // "attrs": { 648 | // "id": "Result", 649 | // "desc": "输出节点。" 650 | // }, 651 | // "linkedSeg": "1HIANOKE72" 652 | // } 653 | // } 654 | // } 655 | // ] 656 | // }, 657 | // "entry": "", 658 | // "autoStart": "true", 659 | // "debug": "true", 660 | // "localVars": { 661 | // "type": "object", 662 | // "def": "Object", 663 | // "jaxId": "1HIAN9JQ42", 664 | // "editVersion": 0, 665 | // "attrs": {} 666 | // }, 667 | // "context": { 668 | // "type": "object", 669 | // "def": "Object", 670 | // "jaxId": "1HIAN9JQ43", 671 | // "editVersion": 4, 672 | // "attrs": { 673 | // "fileName": { 674 | // "type": "string", 675 | // "valText": "" 676 | // } 677 | // } 678 | // }, 679 | // "globalMockup": { 680 | // "type": "object", 681 | // "def": "Object", 682 | // "jaxId": "1HIAN9JQ44", 683 | // "editVersion": 0, 684 | // "attrs": {} 685 | // }, 686 | // "desc": "这是一个AI代理。", 687 | // "exportAPI": "false", 688 | // "apiArgs": { 689 | // "type": "object", 690 | // "def": "Object", 691 | // "jaxId": "1HIAN9JQ45", 692 | // "editVersion": 0, 693 | // "attrs": {} 694 | // } 695 | // } 696 | //} -------------------------------------------------------------------------------- /ui/BoxSeg.js: -------------------------------------------------------------------------------- 1 | //Auto genterated by Cody 2 | import {$P,VFACT,callAfter,sleep} from "/@vfact"; 3 | import inherits from "/@inherits"; 4 | import {appCfg} from "../cfg/appCfg.js"; 5 | /*#{1HIASUKH50StartDoc*/ 6 | /*}#1HIASUKH50StartDoc*/ 7 | const $ln=appCfg.lanCode||VFACT.lanCode||"EN"; 8 | //---------------------------------------------------------------------------- 9 | let BoxSeg=function(seg){ 10 | let cfgColor,cfgSize,txtSize,state; 11 | let cssVO,self; 12 | const $ln=appCfg.lanCode||VFACT.lanCode||"EN"; 13 | cfgColor=appCfg.color; 14 | cfgSize=appCfg.size; 15 | txtSize=appCfg.txtSize; 16 | 17 | 18 | /*#{1HIASUKH51LocalVals*/ 19 | /*}#1HIASUKH51LocalVals*/ 20 | 21 | /*#{1HIASUKH51PreState*/ 22 | /*}#1HIASUKH51PreState*/ 23 | /*#{1HIASUKH51PostState*/ 24 | /*}#1HIASUKH51PostState*/ 25 | cssVO={ 26 | "hash":"1HIASUKH51",nameHost:true, 27 | "type":"button","position":"relative","x":0,"y":0,"w":"100%","h":"","cursor":"pointer","margin":[5,0,5,0],"padding":10,"minW":"","minH":50,"maxW":"", 28 | "maxH":"","styleClass":"","contentLayout":"flex-y", 29 | children:[ 30 | { 31 | "hash":"1HIASVB5T0", 32 | "type":"box","id":"BoxBG","x":0,"y":0,"w":"100%","h":"100%","minW":"","minH":"","maxW":"","maxH":"","styleClass":"","background":[255,255,255,1],"border":1, 33 | "corner":8, 34 | }, 35 | { 36 | "hash":"1HIAT14TV0", 37 | "type":"text","position":"relative","x":0,"y":0,"w":"100%","h":"","uiEvent":-1,"minW":"","minH":"","maxW":"","maxH":"","styleClass":"","color":cfgColor["fontBodySub"], 38 | "text":`段落${seg.idx+1}:`,"fontSize":txtSize.small,"fontWeight":"normal","fontStyle":"normal","textDecoration":"","alignH":1, 39 | }, 40 | { 41 | "hash":"1HIAT6MCT0", 42 | "type":"image","position":"relative","x":0,"y":0,"w":"100%","h":"","uiEvent":-1,"minW":"","minH":"","maxW":"","maxH":"","styleClass":"","image":seg.image, 43 | "fitSize":"contain","repeat":false,"alignX":1,"aspect":"2","attached":!!seg.image, 44 | }, 45 | { 46 | "hash":"1HIATFCDJ0", 47 | "type":"text","position":"relative","x":0,"y":0,"w":"100%","h":"","uiEvent":-1,"minW":"","minH":"","maxW":"","maxH":"","styleClass":"","color":[0,0,0], 48 | "text":seg.text,"fontSize":txtSize.smallPlus,"fontWeight":"normal","fontStyle":"normal","textDecoration":"","wrap":true, 49 | } 50 | ], 51 | /*#{1HIASUKH51ExtraCSS*/ 52 | /*}#1HIASUKH51ExtraCSS*/ 53 | faces:{ 54 | "up":{ 55 | /*BoxBG*/"#1HIASVB5T0":{ 56 | "background":cfgColor["body"] 57 | } 58 | },"over":{ 59 | /*BoxBG*/"#1HIASVB5T0":{ 60 | "background":cfgColor["fontPrimarySub"] 61 | } 62 | },"down":{ 63 | /*BoxBG*/"#1HIASVB5T0":{ 64 | "background":cfgColor["fontPrimaryLit"] 65 | } 66 | } 67 | }, 68 | OnCreate:function(){ 69 | self=this; 70 | 71 | /*#{1HIASUKH51Create*/ 72 | /*}#1HIASUKH51Create*/ 73 | }, 74 | /*#{1HIASUKH51EndCSS*/ 75 | /*}#1HIASUKH51EndCSS*/ 76 | }; 77 | /*#{1HIASUKH51PostCSSVO*/ 78 | /*}#1HIASUKH51PostCSSVO*/ 79 | return cssVO; 80 | }; 81 | /*#{1HIASUKH51ExCodes*/ 82 | /*}#1HIASUKH51ExCodes*/ 83 | 84 | BoxSeg.gearExport={ 85 | framework: "jax", 86 | hudType: "button", 87 | "showName":"",icon:"gears.svg",previewImg:false, 88 | fixPose:false,initW:100,initH:100, 89 | catalog:"", 90 | args: { 91 | "seg": { 92 | "name": "seg", "showName": "seg", "type": "auto", "key": true, "fixed": true, 93 | "initVal": {"idx":3,"text":"abcd","image":"/~/-tabos/shared/assets/close.svg"}, "initValText": "#{idx:3,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 94 | } 95 | }, 96 | state:{ 97 | }, 98 | properties:["id","position","x","y","display"], 99 | faces:["up","over","down"], 100 | subContainers:{ 101 | }, 102 | /*#{1HIASUKH50ExGearInfo*/ 103 | /*}#1HIASUKH50ExGearInfo*/ 104 | }; 105 | export default BoxSeg; 106 | export{BoxSeg}; 107 | /*Cody Project Doc*/ 108 | //{ 109 | // "type": "docfile", 110 | // "def": "GearButton", 111 | // "jaxId": "1HIASUKH50", 112 | // "editVersion": 67, 113 | // "attrs": { 114 | // "editEnv": { 115 | // "type": "object", 116 | // "jaxId": "1HIASUKH60", 117 | // "editVersion": 10, 118 | // "attrs": { 119 | // "device": "Custom Size", 120 | // "screenW": "375", 121 | // "screenH": "750", 122 | // "bgColor": "[255,255,255]", 123 | // "bgChecker": "false" 124 | // } 125 | // }, 126 | // "editObjs": { 127 | // "type": "object", 128 | // "jaxId": "1HIASUKH61", 129 | // "editVersion": 0, 130 | // "attrs": {} 131 | // }, 132 | // "model": { 133 | // "type": "object", 134 | // "def": "Object", 135 | // "jaxId": "1HIASUKH62", 136 | // "editVersion": 0, 137 | // "attrs": {} 138 | // }, 139 | // "createArgs": { 140 | // "type": "object", 141 | // "def": "Object", 142 | // "jaxId": "1HIASUKH63", 143 | // "editVersion": 22, 144 | // "attrs": { 145 | // "seg": { 146 | // "type": "auto", 147 | // "valText": "#{idx:3,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 148 | // } 149 | // } 150 | // }, 151 | // "localVars": { 152 | // "type": "object", 153 | // "def": "Object", 154 | // "jaxId": "1HIASUKH64", 155 | // "editVersion": 0, 156 | // "attrs": {} 157 | // }, 158 | // "oneHud": "false", 159 | // "state": { 160 | // "type": "object", 161 | // "def": "StateObj", 162 | // "jaxId": "1HIASUKH65", 163 | // "editVersion": 0, 164 | // "attrs": {} 165 | // }, 166 | // "segs": { 167 | // "type": "array", 168 | // "attrs": [] 169 | // }, 170 | // "exportTarget": "\"jax\"", 171 | // "gearName": "", 172 | // "gearIcon": "gears.svg", 173 | // "gearW": "100", 174 | // "gearH": "100", 175 | // "gearCatalog": "", 176 | // "description": "", 177 | // "fixPose": "false", 178 | // "previewImg": "", 179 | // "faceTags": { 180 | // "type": "object", 181 | // "def": "FaceTags", 182 | // "jaxId": "1HIASUKH66", 183 | // "editVersion": 6, 184 | // "attrs": { 185 | // "up": { 186 | // "type": "facetag", 187 | // "def": "FaceTag", 188 | // "jaxId": "1HIBDVQ100", 189 | // "editVersion": 16, 190 | // "attrs": { 191 | // "mockup": "false", 192 | // "previewEntry": "false", 193 | // "mockupNext": "", 194 | // "description": "", 195 | // "preFunc": "false", 196 | // "faceFunc": "false", 197 | // "delay": "0", 198 | // "faceTimes": { 199 | // "type": "object", 200 | // "jaxId": "1HIBE18NA0", 201 | // "editVersion": 0, 202 | // "attrs": {} 203 | // } 204 | // } 205 | // }, 206 | // "over": { 207 | // "type": "facetag", 208 | // "def": "FaceTag", 209 | // "jaxId": "1HIBE070V0", 210 | // "editVersion": 16, 211 | // "attrs": { 212 | // "mockup": "false", 213 | // "previewEntry": "false", 214 | // "mockupNext": "", 215 | // "description": "", 216 | // "preFunc": "false", 217 | // "faceFunc": "false", 218 | // "delay": "0", 219 | // "faceTimes": { 220 | // "type": "object", 221 | // "jaxId": "1HIBE18NA1", 222 | // "editVersion": 0, 223 | // "attrs": {} 224 | // } 225 | // } 226 | // }, 227 | // "down": { 228 | // "type": "facetag", 229 | // "def": "FaceTag", 230 | // "jaxId": "1HIBE0TML0", 231 | // "editVersion": 16, 232 | // "attrs": { 233 | // "mockup": "false", 234 | // "previewEntry": "false", 235 | // "mockupNext": "", 236 | // "description": "", 237 | // "preFunc": "false", 238 | // "faceFunc": "false", 239 | // "delay": "0", 240 | // "faceTimes": { 241 | // "type": "object", 242 | // "jaxId": "1HIBE18NA2", 243 | // "editVersion": 0, 244 | // "attrs": {} 245 | // } 246 | // } 247 | // } 248 | // } 249 | // }, 250 | // "mockupStates": { 251 | // "type": "object", 252 | // "def": "MockupObj", 253 | // "jaxId": "1HIASUKH67", 254 | // "editVersion": 5, 255 | // "attrs": { 256 | // "pic": { 257 | // "type": "mockState", 258 | // "def": "MockState", 259 | // "jaxId": "1HIATEDNG0", 260 | // "editVersion": 4, 261 | // "attrs": { 262 | // "createArgs": { 263 | // "type": "object", 264 | // "def": "Object", 265 | // "jaxId": "1HIASUKH63", 266 | // "editVersion": 16, 267 | // "attrs": { 268 | // "seg": { 269 | // "type": "auto", 270 | // "valText": "#{idx:3,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 271 | // } 272 | // } 273 | // }, 274 | // "stateObj": { 275 | // "type": "object", 276 | // "def": "Object", 277 | // "jaxId": "1HIASUKH65", 278 | // "editVersion": 0, 279 | // "attrs": {} 280 | // } 281 | // } 282 | // }, 283 | // "noPic": { 284 | // "type": "mockState", 285 | // "def": "MockState", 286 | // "jaxId": "1HIATK8960", 287 | // "editVersion": 4, 288 | // "attrs": { 289 | // "createArgs": { 290 | // "type": "object", 291 | // "def": "Object", 292 | // "jaxId": "1HIASUKH63", 293 | // "editVersion": 22, 294 | // "attrs": { 295 | // "seg": { 296 | // "type": "auto", 297 | // "valText": "#{idx:3,text:\"abcd\"}" 298 | // } 299 | // } 300 | // }, 301 | // "stateObj": { 302 | // "type": "object", 303 | // "def": "Object", 304 | // "jaxId": "1HIASUKH65", 305 | // "editVersion": 0, 306 | // "attrs": {} 307 | // } 308 | // } 309 | // } 310 | // } 311 | // }, 312 | // "hud": { 313 | // "type": "hudobj", 314 | // "def": "button", 315 | // "jaxId": "1HIASUKH51", 316 | // "editVersion": 20, 317 | // "attrs": { 318 | // "properties": { 319 | // "type": "object", 320 | // "jaxId": "1HIASUKH68", 321 | // "editVersion": 126, 322 | // "attrs": { 323 | // "type": "button", 324 | // "id": "", 325 | // "position": "Relative", 326 | // "x": "0", 327 | // "y": "0", 328 | // "w": "100%", 329 | // "h": "", 330 | // "anchorH": "Left", 331 | // "anchorV": "Top", 332 | // "autoLayout": "false", 333 | // "display": "On", 334 | // "clip": "Off", 335 | // "uiEvent": "On", 336 | // "alpha": "1", 337 | // "rotate": "0", 338 | // "scale": "", 339 | // "filter": "", 340 | // "cursor": "pointer", 341 | // "zIndex": "0", 342 | // "margin": "[5,0,5,0]", 343 | // "padding": "10", 344 | // "minW": "", 345 | // "minH": "50", 346 | // "maxW": "", 347 | // "maxH": "", 348 | // "face": "", 349 | // "styleClass": "", 350 | // "enable": "true", 351 | // "drag": "NA", 352 | // "flex": "false", 353 | // "contentLayout": "Flex Y" 354 | // } 355 | // }, 356 | // "subHuds": { 357 | // "type": "array", 358 | // "attrs": [ 359 | // { 360 | // "type": "hudobj", 361 | // "def": "box", 362 | // "jaxId": "1HIASVB5T0", 363 | // "editVersion": 35, 364 | // "attrs": { 365 | // "properties": { 366 | // "type": "object", 367 | // "jaxId": "1HIAT0EOJ0", 368 | // "editVersion": 100, 369 | // "attrs": { 370 | // "type": "box", 371 | // "id": "BoxBG", 372 | // "position": "Absolute", 373 | // "x": "0", 374 | // "y": "0", 375 | // "w": "100%", 376 | // "h": "100%", 377 | // "anchorH": "Left", 378 | // "anchorV": "Top", 379 | // "autoLayout": "false", 380 | // "display": "On", 381 | // "clip": "Off", 382 | // "uiEvent": "On", 383 | // "alpha": "1", 384 | // "rotate": "0", 385 | // "scale": "", 386 | // "filter": "", 387 | // "cursor": "", 388 | // "zIndex": "0", 389 | // "margin": "", 390 | // "padding": "", 391 | // "minW": "", 392 | // "minH": "", 393 | // "maxW": "", 394 | // "maxH": "", 395 | // "face": "", 396 | // "styleClass": "", 397 | // "background": "[255,255,255,1.00]", 398 | // "border": "1", 399 | // "borderStyle": "Solid", 400 | // "borderColor": "[0,0,0,1.00]", 401 | // "corner": "8", 402 | // "shadow": "false", 403 | // "shadowX": "2", 404 | // "shadowY": "2", 405 | // "shadowBlur": "3", 406 | // "shadowSpread": "0", 407 | // "shadowColor": "[0,0,0,0.50]" 408 | // } 409 | // }, 410 | // "subHuds": { 411 | // "type": "array", 412 | // "attrs": [] 413 | // }, 414 | // "faces": { 415 | // "type": "object", 416 | // "jaxId": "1HIAT0EOJ1", 417 | // "editVersion": 6, 418 | // "attrs": { 419 | // "1HIBDVQ100": { 420 | // "type": "hudface", 421 | // "def": "HudFace", 422 | // "jaxId": "1HIBE18NA3", 423 | // "editVersion": 4, 424 | // "attrs": { 425 | // "properties": { 426 | // "type": "object", 427 | // "jaxId": "1HIBE18NA4", 428 | // "editVersion": 8, 429 | // "attrs": { 430 | // "background": "#cfgColor[\"body\"]" 431 | // } 432 | // }, 433 | // "anis": { 434 | // "type": "array", 435 | // "def": "Array", 436 | // "attrs": [] 437 | // } 438 | // }, 439 | // "faceTagId": "1HIBDVQ100", 440 | // "faceTagName": "up" 441 | // }, 442 | // "1HIBE070V0": { 443 | // "type": "hudface", 444 | // "def": "HudFace", 445 | // "jaxId": "1HIBE18NA5", 446 | // "editVersion": 4, 447 | // "attrs": { 448 | // "properties": { 449 | // "type": "object", 450 | // "jaxId": "1HIBE18NA6", 451 | // "editVersion": 8, 452 | // "attrs": { 453 | // "background": "#cfgColor[\"fontPrimarySub\"]" 454 | // } 455 | // }, 456 | // "anis": { 457 | // "type": "array", 458 | // "def": "Array", 459 | // "attrs": [] 460 | // } 461 | // }, 462 | // "faceTagId": "1HIBE070V0", 463 | // "faceTagName": "over" 464 | // }, 465 | // "1HIBE0TML0": { 466 | // "type": "hudface", 467 | // "def": "HudFace", 468 | // "jaxId": "1HIBE18NA7", 469 | // "editVersion": 4, 470 | // "attrs": { 471 | // "properties": { 472 | // "type": "object", 473 | // "jaxId": "1HIBE18NA8", 474 | // "editVersion": 8, 475 | // "attrs": { 476 | // "background": "#cfgColor[\"fontPrimaryLit\"]" 477 | // } 478 | // }, 479 | // "anis": { 480 | // "type": "array", 481 | // "def": "Array", 482 | // "attrs": [] 483 | // } 484 | // }, 485 | // "faceTagId": "1HIBE0TML0", 486 | // "faceTagName": "down" 487 | // } 488 | // } 489 | // }, 490 | // "functions": { 491 | // "type": "object", 492 | // "jaxId": "1HIAT0EOJ2", 493 | // "editVersion": 0, 494 | // "attrs": {} 495 | // }, 496 | // "extraPpts": { 497 | // "type": "object", 498 | // "def": "Object", 499 | // "jaxId": "1HIAT0EOJ3", 500 | // "editVersion": 0, 501 | // "attrs": {} 502 | // }, 503 | // "mockup": "false", 504 | // "codes": "false", 505 | // "locked": "true", 506 | // "container": "false", 507 | // "nameVal": "false" 508 | // } 509 | // }, 510 | // { 511 | // "type": "hudobj", 512 | // "def": "text", 513 | // "jaxId": "1HIAT14TV0", 514 | // "editVersion": 20, 515 | // "attrs": { 516 | // "properties": { 517 | // "type": "object", 518 | // "jaxId": "1HIAT1KCG0", 519 | // "editVersion": 132, 520 | // "attrs": { 521 | // "type": "text", 522 | // "id": "", 523 | // "position": "relative", 524 | // "x": "0", 525 | // "y": "0", 526 | // "w": "100%", 527 | // "h": "", 528 | // "anchorH": "Left", 529 | // "anchorV": "Top", 530 | // "autoLayout": "false", 531 | // "display": "On", 532 | // "clip": "Off", 533 | // "uiEvent": "Tree Off", 534 | // "alpha": "1", 535 | // "rotate": "0", 536 | // "scale": "", 537 | // "filter": "", 538 | // "cursor": "", 539 | // "zIndex": "0", 540 | // "margin": "", 541 | // "padding": "", 542 | // "minW": "", 543 | // "minH": "", 544 | // "maxW": "", 545 | // "maxH": "", 546 | // "face": "", 547 | // "styleClass": "", 548 | // "color": "#cfgColor[\"fontBodySub\"]", 549 | // "text": "#`段落${seg.idx+1}:`", 550 | // "font": "", 551 | // "fontSize": "#txtSize.small", 552 | // "bold": "false", 553 | // "italic": "false", 554 | // "underline": "false", 555 | // "alignH": "Center", 556 | // "alignV": "Top", 557 | // "wrap": "false", 558 | // "ellipsis": "false", 559 | // "select": "false", 560 | // "shadow": "false", 561 | // "shadowX": "0", 562 | // "shadowY": "2", 563 | // "shadowBlur": "3", 564 | // "shadowColor": "[0,0,0,1.00]", 565 | // "shadowEx": "", 566 | // "maxTextW": "0" 567 | // } 568 | // }, 569 | // "subHuds": { 570 | // "type": "array", 571 | // "attrs": [] 572 | // }, 573 | // "faces": { 574 | // "type": "object", 575 | // "jaxId": "1HIAT1KCG1", 576 | // "editVersion": 8, 577 | // "attrs": { 578 | // "1HIBDVQ100": { 579 | // "type": "hudface", 580 | // "def": "HudFace", 581 | // "jaxId": "1HIBE18NA9", 582 | // "editVersion": 4, 583 | // "attrs": { 584 | // "properties": { 585 | // "type": "object", 586 | // "jaxId": "1HIBE18NA10", 587 | // "editVersion": 0, 588 | // "attrs": {} 589 | // }, 590 | // "anis": { 591 | // "type": "array", 592 | // "def": "Array", 593 | // "attrs": [] 594 | // } 595 | // }, 596 | // "faceTagId": "1HIBDVQ100", 597 | // "faceTagName": "up" 598 | // }, 599 | // "1HIBE070V0": { 600 | // "type": "hudface", 601 | // "def": "HudFace", 602 | // "jaxId": "1HIBE18NA11", 603 | // "editVersion": 4, 604 | // "attrs": { 605 | // "properties": { 606 | // "type": "object", 607 | // "jaxId": "1HIBE18NA12", 608 | // "editVersion": 0, 609 | // "attrs": {} 610 | // }, 611 | // "anis": { 612 | // "type": "array", 613 | // "def": "Array", 614 | // "attrs": [] 615 | // } 616 | // }, 617 | // "faceTagId": "1HIBE070V0", 618 | // "faceTagName": "over" 619 | // } 620 | // } 621 | // }, 622 | // "functions": { 623 | // "type": "object", 624 | // "jaxId": "1HIAT1KCG2", 625 | // "editVersion": 0, 626 | // "attrs": {} 627 | // }, 628 | // "extraPpts": { 629 | // "type": "object", 630 | // "def": "Object", 631 | // "jaxId": "1HIAT1KCG3", 632 | // "editVersion": 0, 633 | // "attrs": {} 634 | // }, 635 | // "mockup": "false", 636 | // "codes": "false", 637 | // "locked": "false", 638 | // "container": "false", 639 | // "nameVal": "false" 640 | // } 641 | // }, 642 | // { 643 | // "type": "hudobj", 644 | // "def": "image", 645 | // "jaxId": "1HIAT6MCT0", 646 | // "editVersion": 20, 647 | // "attrs": { 648 | // "properties": { 649 | // "type": "object", 650 | // "jaxId": "1HIATBUBD0", 651 | // "editVersion": 142, 652 | // "attrs": { 653 | // "type": "image", 654 | // "id": "", 655 | // "position": "relative", 656 | // "x": "0", 657 | // "y": "0", 658 | // "w": "100%", 659 | // "h": "", 660 | // "anchorH": "Left", 661 | // "anchorV": "Top", 662 | // "autoLayout": "false", 663 | // "display": "On", 664 | // "clip": "Off", 665 | // "uiEvent": "Tree Off", 666 | // "alpha": "1", 667 | // "rotate": "0", 668 | // "scale": "", 669 | // "filter": "", 670 | // "cursor": "", 671 | // "zIndex": "0", 672 | // "margin": "", 673 | // "padding": "", 674 | // "minW": "", 675 | // "minH": "", 676 | // "maxW": "", 677 | // "maxH": "", 678 | // "face": "", 679 | // "styleClass": "", 680 | // "image": "#seg.image", 681 | // "autoSize": "false", 682 | // "fitSize": "Contain", 683 | // "repeat": "false", 684 | // "alignX": "Center", 685 | // "alignY": "Top", 686 | // "aspect": "2", 687 | // "attach": "#!!seg.image" 688 | // } 689 | // }, 690 | // "subHuds": { 691 | // "type": "array", 692 | // "attrs": [] 693 | // }, 694 | // "faces": { 695 | // "type": "object", 696 | // "jaxId": "1HIATBUBD5", 697 | // "editVersion": 8, 698 | // "attrs": { 699 | // "1HIBDVQ100": { 700 | // "type": "hudface", 701 | // "def": "HudFace", 702 | // "jaxId": "1HIBE18NA15", 703 | // "editVersion": 4, 704 | // "attrs": { 705 | // "properties": { 706 | // "type": "object", 707 | // "jaxId": "1HIBE18NA16", 708 | // "editVersion": 0, 709 | // "attrs": {} 710 | // }, 711 | // "anis": { 712 | // "type": "array", 713 | // "def": "Array", 714 | // "attrs": [] 715 | // } 716 | // }, 717 | // "faceTagId": "1HIBDVQ100", 718 | // "faceTagName": "up" 719 | // }, 720 | // "1HIBE070V0": { 721 | // "type": "hudface", 722 | // "def": "HudFace", 723 | // "jaxId": "1HIBE18NA17", 724 | // "editVersion": 4, 725 | // "attrs": { 726 | // "properties": { 727 | // "type": "object", 728 | // "jaxId": "1HIBE18NA18", 729 | // "editVersion": 0, 730 | // "attrs": {} 731 | // }, 732 | // "anis": { 733 | // "type": "array", 734 | // "def": "Array", 735 | // "attrs": [] 736 | // } 737 | // }, 738 | // "faceTagId": "1HIBE070V0", 739 | // "faceTagName": "over" 740 | // } 741 | // } 742 | // }, 743 | // "functions": { 744 | // "type": "object", 745 | // "jaxId": "1HIATBUBD6", 746 | // "editVersion": 0, 747 | // "attrs": {} 748 | // }, 749 | // "extraPpts": { 750 | // "type": "object", 751 | // "def": "Object", 752 | // "jaxId": "1HIATBUBD7", 753 | // "editVersion": 0, 754 | // "attrs": {} 755 | // }, 756 | // "mockup": "false", 757 | // "codes": "false", 758 | // "locked": "false", 759 | // "container": "true", 760 | // "nameVal": "false" 761 | // } 762 | // }, 763 | // { 764 | // "type": "hudobj", 765 | // "def": "text", 766 | // "jaxId": "1HIATFCDJ0", 767 | // "editVersion": 20, 768 | // "attrs": { 769 | // "properties": { 770 | // "type": "object", 771 | // "jaxId": "1HIATFCDJ1", 772 | // "editVersion": 124, 773 | // "attrs": { 774 | // "type": "text", 775 | // "id": "", 776 | // "position": "Relative", 777 | // "x": "0", 778 | // "y": "0", 779 | // "w": "100%", 780 | // "h": "", 781 | // "anchorH": "Left", 782 | // "anchorV": "Top", 783 | // "autoLayout": "false", 784 | // "display": "On", 785 | // "clip": "Off", 786 | // "uiEvent": "Tree Off", 787 | // "alpha": "1", 788 | // "rotate": "0", 789 | // "scale": "", 790 | // "filter": "", 791 | // "cursor": "", 792 | // "zIndex": "0", 793 | // "margin": "", 794 | // "padding": "", 795 | // "minW": "", 796 | // "minH": "", 797 | // "maxW": "", 798 | // "maxH": "", 799 | // "face": "", 800 | // "styleClass": "", 801 | // "color": "[0,0,0]", 802 | // "text": "#seg.text", 803 | // "font": "", 804 | // "fontSize": "#txtSize.smallPlus", 805 | // "bold": "false", 806 | // "italic": "false", 807 | // "underline": "false", 808 | // "alignH": "Left", 809 | // "alignV": "Top", 810 | // "wrap": "true", 811 | // "ellipsis": "false", 812 | // "select": "false", 813 | // "shadow": "false", 814 | // "shadowX": "0", 815 | // "shadowY": "2", 816 | // "shadowBlur": "3", 817 | // "shadowColor": "[0,0,0,1.00]", 818 | // "shadowEx": "", 819 | // "maxTextW": "0" 820 | // } 821 | // }, 822 | // "subHuds": { 823 | // "type": "array", 824 | // "attrs": [] 825 | // }, 826 | // "faces": { 827 | // "type": "object", 828 | // "jaxId": "1HIATFCDJ2", 829 | // "editVersion": 8, 830 | // "attrs": { 831 | // "1HIBDVQ100": { 832 | // "type": "hudface", 833 | // "def": "HudFace", 834 | // "jaxId": "1HIBE18NB0", 835 | // "editVersion": 4, 836 | // "attrs": { 837 | // "properties": { 838 | // "type": "object", 839 | // "jaxId": "1HIBE18NB1", 840 | // "editVersion": 0, 841 | // "attrs": {} 842 | // }, 843 | // "anis": { 844 | // "type": "array", 845 | // "def": "Array", 846 | // "attrs": [] 847 | // } 848 | // }, 849 | // "faceTagId": "1HIBDVQ100", 850 | // "faceTagName": "up" 851 | // }, 852 | // "1HIBE070V0": { 853 | // "type": "hudface", 854 | // "def": "HudFace", 855 | // "jaxId": "1HIBE18NB2", 856 | // "editVersion": 4, 857 | // "attrs": { 858 | // "properties": { 859 | // "type": "object", 860 | // "jaxId": "1HIBE18NB3", 861 | // "editVersion": 0, 862 | // "attrs": {} 863 | // }, 864 | // "anis": { 865 | // "type": "array", 866 | // "def": "Array", 867 | // "attrs": [] 868 | // } 869 | // }, 870 | // "faceTagId": "1HIBE070V0", 871 | // "faceTagName": "over" 872 | // } 873 | // } 874 | // }, 875 | // "functions": { 876 | // "type": "object", 877 | // "jaxId": "1HIATFCDJ3", 878 | // "editVersion": 0, 879 | // "attrs": {} 880 | // }, 881 | // "extraPpts": { 882 | // "type": "object", 883 | // "def": "Object", 884 | // "jaxId": "1HIATFCDJ4", 885 | // "editVersion": 0, 886 | // "attrs": {} 887 | // }, 888 | // "mockup": "false", 889 | // "codes": "false", 890 | // "locked": "false", 891 | // "container": "false", 892 | // "nameVal": "false" 893 | // } 894 | // } 895 | // ] 896 | // }, 897 | // "faces": { 898 | // "type": "object", 899 | // "jaxId": "1HIASUKH69", 900 | // "editVersion": 8, 901 | // "attrs": { 902 | // "1HIBDVQ100": { 903 | // "type": "hudface", 904 | // "def": "HudFace", 905 | // "jaxId": "1HIBE18NB6", 906 | // "editVersion": 4, 907 | // "attrs": { 908 | // "properties": { 909 | // "type": "object", 910 | // "jaxId": "1HIBE18NB7", 911 | // "editVersion": 0, 912 | // "attrs": {} 913 | // }, 914 | // "anis": { 915 | // "type": "array", 916 | // "def": "Array", 917 | // "attrs": [] 918 | // } 919 | // }, 920 | // "faceTagId": "1HIBDVQ100", 921 | // "faceTagName": "up" 922 | // }, 923 | // "1HIBE070V0": { 924 | // "type": "hudface", 925 | // "def": "HudFace", 926 | // "jaxId": "1HIBE18NB8", 927 | // "editVersion": 4, 928 | // "attrs": { 929 | // "properties": { 930 | // "type": "object", 931 | // "jaxId": "1HIBE18NB9", 932 | // "editVersion": 0, 933 | // "attrs": {} 934 | // }, 935 | // "anis": { 936 | // "type": "array", 937 | // "def": "Array", 938 | // "attrs": [] 939 | // } 940 | // }, 941 | // "faceTagId": "1HIBE070V0", 942 | // "faceTagName": "over" 943 | // } 944 | // } 945 | // }, 946 | // "functions": { 947 | // "type": "object", 948 | // "jaxId": "1HIASUKH610", 949 | // "editVersion": 0, 950 | // "attrs": {} 951 | // }, 952 | // "extraPpts": { 953 | // "type": "object", 954 | // "def": "Object", 955 | // "jaxId": "1HIASUKH611", 956 | // "editVersion": 0, 957 | // "attrs": {} 958 | // }, 959 | // "mockup": "false", 960 | // "codes": "false", 961 | // "locked": "false", 962 | // "container": "true", 963 | // "nameVal": "false" 964 | // } 965 | // }, 966 | // "exposeGear": "true", 967 | // "exposeTemplate": "false", 968 | // "exposeAttrs": { 969 | // "type": "object", 970 | // "def": "exposeAttrs", 971 | // "jaxId": "1HIASUKH612", 972 | // "editVersion": 68, 973 | // "attrs": { 974 | // "id": "true", 975 | // "position": "true", 976 | // "x": "true", 977 | // "y": "true", 978 | // "w": "false", 979 | // "h": "false", 980 | // "anchorH": "false", 981 | // "anchorV": "false", 982 | // "autoLayout": "false", 983 | // "display": "true", 984 | // "contentLayout": "false", 985 | // "subAlign": "false", 986 | // "itemsAlign": "false", 987 | // "itemsWrap": "false", 988 | // "clip": "false", 989 | // "uiEvent": "false", 990 | // "alpha": "false", 991 | // "rotate": "false", 992 | // "scale": "false", 993 | // "filter": "false", 994 | // "aspect": "false", 995 | // "cursor": "false", 996 | // "zIndex": "false", 997 | // "flex": "false", 998 | // "margin": "false", 999 | // "traceSize": "false", 1000 | // "padding": "false", 1001 | // "minW": "false", 1002 | // "minH": "false", 1003 | // "maxW": "false", 1004 | // "maxH": "false", 1005 | // "styleClass": "false", 1006 | // "enable": "false", 1007 | // "drag": "false" 1008 | // } 1009 | // }, 1010 | // "exposeStateAttrs": { 1011 | // "type": "array", 1012 | // "def": "StringArray", 1013 | // "attrs": [] 1014 | // } 1015 | // } 1016 | //} -------------------------------------------------------------------------------- /ui/DlgSegs.js: -------------------------------------------------------------------------------- 1 | //Auto genterated by Cody 2 | import {$P,VFACT,callAfter,sleep} from "/@vfact"; 3 | import inherits from "/@inherits"; 4 | import {appCfg} from "../cfg/appCfg.js"; 5 | import {BoxSeg} from "./BoxSeg.js"; 6 | import {BtnIcon} from "/@StdUI/ui/BtnIcon.js"; 7 | /*#{1HIARMBHP0StartDoc*/ 8 | /* 9 | This is a template for standard dialog. 10 | */ 11 | /*}#1HIARMBHP0StartDoc*/ 12 | const $ln=appCfg.lanCode||VFACT.lanCode||"EN"; 13 | //---------------------------------------------------------------------------- 14 | let DlgSegs=function(){ 15 | let cfgColor,cfgSize,txtSize,state; 16 | let cssVO,self; 17 | const $ln=appCfg.lanCode||VFACT.lanCode||"EN"; 18 | let txtTitle,boxContent; 19 | 20 | cfgColor=appCfg.color; 21 | cfgSize=appCfg.size; 22 | txtSize=appCfg.txtSize; 23 | 24 | 25 | /*#{1H1T7ISV51LocalVals*/ 26 | let app,dlgVO,story,segs; 27 | app=window.tabOSApp; 28 | dlgVO=null; 29 | story=null; 30 | segs=null; 31 | /*}#1H1T7ISV51LocalVals*/ 32 | 33 | /*#{1H1T7ISV51PreState*/ 34 | /*}#1H1T7ISV51PreState*/ 35 | state={ 36 | "title":"请选择段落:", 37 | /*#{1H1T7ISV56ExState*/ 38 | /*}#1H1T7ISV56ExState*/ 39 | }; 40 | state=VFACT.flexState(state); 41 | /*#{1H1T7ISV51PostState*/ 42 | /*}#1H1T7ISV51PostState*/ 43 | cssVO={ 44 | "hash":"1H1T7ISV51",nameHost:true, 45 | "type":"hud","x":"50%","y":"50%","w":360,"h":"80%","anchorX":1,"anchorY":1,"padding":10,"minW":"","minH":"","maxW":"","maxH":"","styleClass":"","contentLayout":"flex-y", 46 | children:[ 47 | { 48 | "hash":"1H1T7LGH40", 49 | "type":"box","id":"BoxBG","x":0,"y":0,"w":"100%","h":"100%","minW":"","minH":"","maxW":"","maxH":"","styleClass":"","background":cfgColor.body,"border":2, 50 | "borderColor":cfgColor["fontBodySub"],"corner":5,"shadow":true,"shadowX":3,"shadowY":6,"shadowBlur":5,"shadowColor":[0,0,0,0.3], 51 | }, 52 | { 53 | "hash":"1H1T7O2SA0", 54 | "type":"text","id":"TxtTitle","position":"relative","x":0,"y":0,"w":"100%","h":"","uiEvent":-1,"margin":[0,0,10,0],"minW":"","minH":"","maxW":"","maxH":"", 55 | "styleClass":"","color":cfgColor.fontBodySub,"text":$P(()=>(state.title),state),"fontSize":txtSize.big,"fontWeight":"bold","fontStyle":"normal","textDecoration":"", 56 | }, 57 | { 58 | "hash":"1H1T7S0BE0", 59 | "type":"hud","id":"BoxContent","position":"relative","x":0,"y":0,"w":"100%","h":"","overflow":"auto-y","minW":"","minH":30,"maxW":"","maxH":"","styleClass":"", 60 | "flex":true,"contentLayout":"flex-y", 61 | children:[ 62 | { 63 | "hash":"1HIAUBB680", 64 | "type":"hud","id":"BoxSegs","x":0,"y":0,"w":"100%","h":"100%","overflow":"auto-y","minW":"","minH":"","maxW":"","maxH":"","styleClass":"","contentLayout":"flex-y", 65 | children:[ 66 | ], 67 | } 68 | ], 69 | }, 70 | { 71 | "hash":"1HIARRB8R0", 72 | "type":BtnIcon("front",30,0,appCfg.sharedAssets+"/close.svg",null),"id":"BtnClose","x":">calc(100% - 40px)","y":10,"padding":2, 73 | "OnClick":function(event){ 74 | self.btnCloseOnClick(this,event); 75 | }, 76 | } 77 | ], 78 | /*#{1H1T7ISV51ExtraCSS*/ 79 | /*}#1H1T7ISV51ExtraCSS*/ 80 | faces:{ 81 | }, 82 | OnCreate:function(){ 83 | self=this; 84 | txtTitle=self.TxtTitle;boxContent=self.BoxContent; 85 | /*#{1H1T7ISV51Create*/ 86 | //Apply drag to move: 87 | VFACT.applyMoveDrag(self.BoxBG,self); 88 | /*}#1H1T7ISV51Create*/ 89 | }, 90 | /*#{1H1T7ISV51EndCSS*/ 91 | /*}#1H1T7ISV51EndCSS*/ 92 | }; 93 | //------------------------------------------------------------------------ 94 | cssVO.btnCloseOnClick=async function(sender,event){ 95 | /*#{1HIAUH66I0Start*/ 96 | /*}#1HIAUH66I0Start*/ 97 | /*#{1HIAUHFN80*/ 98 | self.close(null); 99 | /*}#1HIAUHFN80*/ 100 | }; 101 | //------------------------------------------------------------------------ 102 | cssVO.showSegs=async function(segs){ 103 | /*#{1HIAULQS10Start*/ 104 | /*}#1HIAULQS10Start*/ 105 | /*#{1HIAUMQ120*/ 106 | /*}#1HIAUMQ120*/ 107 | VFACT.syncDataList2View(self.BoxSegs,segs,self.segBox,true); 108 | }; 109 | /*#{1H1T7ISV51PostCSSVO*/ 110 | //------------------------------------------------------------------------ 111 | cssVO.segBox=function(seg){ 112 | return { 113 | type:BoxSeg(seg), 114 | OnClick(){ 115 | self.close(seg.idx); 116 | } 117 | }; 118 | }; 119 | //------------------------------------------------------------------------ 120 | cssVO.showDlg=function(vo){ 121 | dlgVO=vo; 122 | story=vo.story; 123 | segs=story.StorySegs.map((item,idx)=>{return {idx:idx,...item}}); 124 | self.showSegs(segs); 125 | self.animate({type:"in",alpha:0,scale:0.9,time:100}); 126 | }; 127 | 128 | //------------------------------------------------------------------------ 129 | cssVO.close=function(result){ 130 | //Maybe animation: 131 | app.closeDlg(self,result); 132 | if(dlgVO){ 133 | let next; 134 | next=dlgVO.next||dlgVO.callback; 135 | if(next){ 136 | next(result); 137 | } 138 | } 139 | }; 140 | /*}#1H1T7ISV51PostCSSVO*/ 141 | return cssVO; 142 | }; 143 | /*#{1H1T7ISV51ExCodes*/ 144 | /*}#1H1T7ISV51ExCodes*/ 145 | 146 | DlgSegs.gearExport={ 147 | framework: "jax", 148 | hudType: "hud", 149 | "showName":(($ln==="CN")?("标准对话框"):("Standard Dialog")),icon:"gears.svg",previewImg:false, 150 | fixPose:false,initW:360,initH:500, 151 | catalog:"", 152 | args: {}, 153 | state:{ 154 | }, 155 | properties:["id","position","x","y","w","h","display"], 156 | faces:[], 157 | subContainers:{ 158 | "1H1T7S0BE0":{"showName":"BoxContent","contentLayout":"flex-y"} 159 | }, 160 | /*#{1HIARMBHP0ExGearInfo*/ 161 | /*}#1HIARMBHP0ExGearInfo*/ 162 | }; 163 | export default DlgSegs; 164 | export{DlgSegs}; 165 | /*Cody Project Doc*/ 166 | //{ 167 | // "type": "docfile", 168 | // "def": "GearHud", 169 | // "jaxId": "1HIARMBHP0", 170 | // "editVersion": 152, 171 | // "attrs": { 172 | // "editEnv": { 173 | // "type": "object", 174 | // "jaxId": "1H1T7ISV52", 175 | // "editVersion": 10, 176 | // "attrs": { 177 | // "device": "Custom Size", 178 | // "screenW": "375", 179 | // "screenH": "750", 180 | // "bgColor": "[255,255,255]", 181 | // "bgChecker": "false" 182 | // } 183 | // }, 184 | // "editObjs": { 185 | // "type": "object", 186 | // "jaxId": "1H1T7ISV53", 187 | // "editVersion": 0, 188 | // "attrs": {} 189 | // }, 190 | // "model": { 191 | // "type": "object", 192 | // "def": "Object", 193 | // "jaxId": "1H8H690AD0", 194 | // "editVersion": 0, 195 | // "attrs": {} 196 | // }, 197 | // "createArgs": { 198 | // "type": "object", 199 | // "def": "Object", 200 | // "jaxId": "1H1T7ISV54", 201 | // "editVersion": 118, 202 | // "attrs": {} 203 | // }, 204 | // "localVars": { 205 | // "type": "object", 206 | // "def": "Object", 207 | // "jaxId": "1H1T7ISV55", 208 | // "editVersion": 10, 209 | // "attrs": {} 210 | // }, 211 | // "oneHud": "false", 212 | // "state": { 213 | // "type": "object", 214 | // "def": "StateObj", 215 | // "jaxId": "1H1T7ISV56", 216 | // "editVersion": 44, 217 | // "attrs": { 218 | // "title": { 219 | // "type": "string", 220 | // "valText": "请选择段落:", 221 | // "localizable": true 222 | // } 223 | // } 224 | // }, 225 | // "segs": { 226 | // "type": "array", 227 | // "attrs": [ 228 | // { 229 | // "type": "flowseg", 230 | // "def": "Entry", 231 | // "jaxId": "1HIAUH66I0", 232 | // "editVersion": 30, 233 | // "attrs": { 234 | // "id": "btnCloseOnClick", 235 | // "label": "New AI Seg", 236 | // "x": "100", 237 | // "y": "50", 238 | // "desc": "", 239 | // "codes": "false", 240 | // "args": { 241 | // "type": "object", 242 | // "def": "Object", 243 | // "jaxId": "1HIAUI0L70", 244 | // "editVersion": 4, 245 | // "attrs": { 246 | // "sender": { 247 | // "valText": "null" 248 | // }, 249 | // "event": { 250 | // "valText": "" 251 | // } 252 | // } 253 | // }, 254 | // "async": "true", 255 | // "localVars": { 256 | // "type": "object", 257 | // "def": "Object", 258 | // "jaxId": "1HIAUI0L71", 259 | // "editVersion": 0, 260 | // "attrs": {} 261 | // }, 262 | // "segs": { 263 | // "type": "array", 264 | // "attrs": [ 265 | // { 266 | // "type": "flowseg", 267 | // "def": "Code", 268 | // "jaxId": "1HIAUHFN80", 269 | // "editVersion": 18, 270 | // "attrs": { 271 | // "id": "", 272 | // "label": "New AI Seg", 273 | // "x": "330", 274 | // "y": "50", 275 | // "desc": "", 276 | // "codes": "false", 277 | // "outlet": { 278 | // "type": "aioutlet", 279 | // "def": "AISegOutlet", 280 | // "jaxId": "1HIAUI0L72", 281 | // "editVersion": 4, 282 | // "attrs": { 283 | // "id": "Next", 284 | // "desc": "输出节点。" 285 | // } 286 | // } 287 | // } 288 | // } 289 | // ] 290 | // }, 291 | // "outlet": { 292 | // "type": "aioutlet", 293 | // "def": "AISegOutlet", 294 | // "jaxId": "1HIAUI0L73", 295 | // "editVersion": 4, 296 | // "attrs": { 297 | // "id": "Next", 298 | // "desc": "输出节点。" 299 | // }, 300 | // "linkedSeg": "1HIAUHFN80" 301 | // } 302 | // } 303 | // }, 304 | // { 305 | // "type": "flowseg", 306 | // "def": "Entry", 307 | // "jaxId": "1HIAULQS10", 308 | // "editVersion": 40, 309 | // "attrs": { 310 | // "id": "showSegs", 311 | // "label": "New AI Seg", 312 | // "x": "100", 313 | // "y": "140", 314 | // "desc": "", 315 | // "codes": "false", 316 | // "args": { 317 | // "type": "object", 318 | // "def": "Object", 319 | // "jaxId": "1HIAUMQ170", 320 | // "editVersion": 8, 321 | // "attrs": { 322 | // "segs": { 323 | // "type": "auto", 324 | // "valText": "[]" 325 | // } 326 | // } 327 | // }, 328 | // "async": "true", 329 | // "localVars": { 330 | // "type": "object", 331 | // "def": "Object", 332 | // "jaxId": "1HIAUMQ171", 333 | // "editVersion": 0, 334 | // "attrs": {} 335 | // }, 336 | // "segs": { 337 | // "type": "array", 338 | // "attrs": [ 339 | // { 340 | // "type": "flowseg", 341 | // "def": "RenderData", 342 | // "jaxId": "1HIAUMQ120", 343 | // "editVersion": 58, 344 | // "attrs": { 345 | // "id": "", 346 | // "label": "New AI Seg", 347 | // "x": "310", 348 | // "y": "140", 349 | // "desc": "", 350 | // "codes": "true", 351 | // "view": "self.BoxSegs", 352 | // "data": "segs", 353 | // "uiDef": "self.segBox", 354 | // "clear": "true", 355 | // "assign": "", 356 | // "outlet": { 357 | // "type": "aioutlet", 358 | // "def": "AISegOutlet", 359 | // "jaxId": "1HIAUMQ172", 360 | // "editVersion": 4, 361 | // "attrs": { 362 | // "id": "Next", 363 | // "desc": "输出节点。" 364 | // } 365 | // } 366 | // } 367 | // } 368 | // ] 369 | // }, 370 | // "outlet": { 371 | // "type": "aioutlet", 372 | // "def": "AISegOutlet", 373 | // "jaxId": "1HIAUMQ173", 374 | // "editVersion": 4, 375 | // "attrs": { 376 | // "id": "Next", 377 | // "desc": "输出节点。" 378 | // }, 379 | // "linkedSeg": "1HIAUMQ120" 380 | // } 381 | // } 382 | // } 383 | // ] 384 | // }, 385 | // "exportTarget": "\"jax\"", 386 | // "gearName": { 387 | // "type": "string", 388 | // "valText": "Standard Dialog", 389 | // "localize": { 390 | // "EN": "Standard Dialog", 391 | // "CN": "标准对话框" 392 | // }, 393 | // "localizable": true 394 | // }, 395 | // "gearIcon": "gears.svg", 396 | // "gearW": "360", 397 | // "gearH": "500", 398 | // "gearCatalog": "", 399 | // "description": "", 400 | // "fixPose": "false", 401 | // "previewImg": "", 402 | // "faceTags": { 403 | // "type": "object", 404 | // "def": "FaceTags", 405 | // "jaxId": "1H1T7ISV57", 406 | // "editVersion": 0, 407 | // "attrs": {} 408 | // }, 409 | // "mockupStates": { 410 | // "type": "object", 411 | // "def": "MockupObj", 412 | // "jaxId": "1HIARMBLP0", 413 | // "editVersion": 0, 414 | // "attrs": {} 415 | // }, 416 | // "hud": { 417 | // "type": "hudobj", 418 | // "def": "hud", 419 | // "jaxId": "1H1T7ISV51", 420 | // "editVersion": 20, 421 | // "attrs": { 422 | // "properties": { 423 | // "type": "object", 424 | // "jaxId": "1H1T7ISV58", 425 | // "editVersion": 182, 426 | // "attrs": { 427 | // "type": "hud", 428 | // "id": "", 429 | // "position": "Absolute", 430 | // "x": "50%", 431 | // "y": "50%", 432 | // "w": "360", 433 | // "h": "80%", 434 | // "anchorH": "Center", 435 | // "anchorV": "Center", 436 | // "autoLayout": "false", 437 | // "display": "On", 438 | // "clip": "Off", 439 | // "uiEvent": "On", 440 | // "alpha": "1", 441 | // "rotate": "0", 442 | // "scale": "", 443 | // "filter": "", 444 | // "cursor": "", 445 | // "zIndex": "0", 446 | // "margin": "", 447 | // "padding": "10", 448 | // "minW": "", 449 | // "minH": "", 450 | // "maxW": "", 451 | // "maxH": "", 452 | // "face": "", 453 | // "styleClass": "", 454 | // "contentLayout": "Flex Y" 455 | // } 456 | // }, 457 | // "subHuds": { 458 | // "type": "array", 459 | // "attrs": [ 460 | // { 461 | // "type": "hudobj", 462 | // "def": "box", 463 | // "jaxId": "1H1T7LGH40", 464 | // "editVersion": 37, 465 | // "attrs": { 466 | // "properties": { 467 | // "type": "object", 468 | // "jaxId": "1H1T83E7O0", 469 | // "editVersion": 152, 470 | // "attrs": { 471 | // "type": "box", 472 | // "id": "BoxBG", 473 | // "position": "Absolute", 474 | // "x": "0", 475 | // "y": "0", 476 | // "w": "100%", 477 | // "h": "100%", 478 | // "anchorH": "Left", 479 | // "anchorV": "Top", 480 | // "autoLayout": "false", 481 | // "display": "On", 482 | // "clip": "Off", 483 | // "uiEvent": "On", 484 | // "alpha": "1", 485 | // "rotate": "0", 486 | // "scale": "", 487 | // "filter": "", 488 | // "cursor": "", 489 | // "zIndex": "0", 490 | // "margin": "", 491 | // "padding": "", 492 | // "minW": "", 493 | // "minH": "", 494 | // "maxW": "", 495 | // "maxH": "", 496 | // "face": "", 497 | // "styleClass": "", 498 | // "background": "#cfgColor.body", 499 | // "border": "2", 500 | // "borderStyle": "Solid", 501 | // "borderColor": "#cfgColor[\"fontBodySub\"]", 502 | // "corner": "5", 503 | // "shadow": "true", 504 | // "shadowX": "3", 505 | // "shadowY": "6", 506 | // "shadowBlur": "5", 507 | // "shadowSpread": "0", 508 | // "shadowColor": "[0,0,0,0.30]" 509 | // } 510 | // }, 511 | // "subHuds": { 512 | // "type": "array", 513 | // "attrs": [] 514 | // }, 515 | // "faces": { 516 | // "type": "object", 517 | // "jaxId": "1H1T83E7O1", 518 | // "editVersion": 0, 519 | // "attrs": {} 520 | // }, 521 | // "functions": { 522 | // "type": "object", 523 | // "jaxId": "1H1T83E7O2", 524 | // "editVersion": 0, 525 | // "attrs": {} 526 | // }, 527 | // "extraPpts": { 528 | // "type": "object", 529 | // "def": "Object", 530 | // "jaxId": "1H1T83E7O3", 531 | // "editVersion": 0, 532 | // "attrs": {} 533 | // }, 534 | // "mockup": "false", 535 | // "codes": "false", 536 | // "locked": "false", 537 | // "container": "false", 538 | // "nameVal": "false" 539 | // } 540 | // }, 541 | // { 542 | // "type": "hudobj", 543 | // "def": "text", 544 | // "jaxId": "1H1T7O2SA0", 545 | // "editVersion": 52, 546 | // "attrs": { 547 | // "properties": { 548 | // "type": "object", 549 | // "jaxId": "1H1T83E7O4", 550 | // "editVersion": 176, 551 | // "attrs": { 552 | // "type": "text", 553 | // "id": "TxtTitle", 554 | // "position": "relative", 555 | // "x": "0", 556 | // "y": "0", 557 | // "w": "100%", 558 | // "h": "\"\"", 559 | // "anchorH": "Left", 560 | // "anchorV": "Top", 561 | // "autoLayout": "false", 562 | // "display": "On", 563 | // "clip": "Off", 564 | // "uiEvent": "Tree Off", 565 | // "alpha": "1", 566 | // "rotate": "0", 567 | // "scale": "", 568 | // "filter": "", 569 | // "cursor": "", 570 | // "zIndex": "0", 571 | // "margin": "[0,0,10,0]", 572 | // "padding": "", 573 | // "minW": "", 574 | // "minH": "", 575 | // "maxW": "", 576 | // "maxH": "", 577 | // "face": "", 578 | // "styleClass": "", 579 | // "color": "#cfgColor.fontBodySub", 580 | // "text": "${state.title},state", 581 | // "font": "", 582 | // "fontSize": "#txtSize.big", 583 | // "bold": "true", 584 | // "italic": "false", 585 | // "underline": "false", 586 | // "alignH": "Left", 587 | // "alignV": "Top", 588 | // "wrap": "false", 589 | // "ellipsis": "false", 590 | // "select": "false", 591 | // "shadow": "false", 592 | // "shadowX": "0", 593 | // "shadowY": "2", 594 | // "shadowBlur": "3", 595 | // "shadowColor": "[0,0,0,1.00]", 596 | // "shadowEx": "", 597 | // "maxTextW": "0", 598 | // "autoSizeW": "false", 599 | // "autoSizeH": "false" 600 | // } 601 | // }, 602 | // "subHuds": { 603 | // "type": "array", 604 | // "attrs": [] 605 | // }, 606 | // "faces": { 607 | // "type": "object", 608 | // "jaxId": "1H1T83E7O5", 609 | // "editVersion": 0, 610 | // "attrs": {} 611 | // }, 612 | // "functions": { 613 | // "type": "object", 614 | // "jaxId": "1H1T83E7O6", 615 | // "editVersion": 0, 616 | // "attrs": {} 617 | // }, 618 | // "extraPpts": { 619 | // "type": "object", 620 | // "def": "Object", 621 | // "jaxId": "1H1T83E7O7", 622 | // "editVersion": 0, 623 | // "attrs": {} 624 | // }, 625 | // "mockup": "false", 626 | // "codes": "false", 627 | // "locked": "false", 628 | // "container": "false", 629 | // "nameVal": "true" 630 | // } 631 | // }, 632 | // { 633 | // "type": "hudobj", 634 | // "def": "hud", 635 | // "jaxId": "1H1T7S0BE0", 636 | // "editVersion": 54, 637 | // "attrs": { 638 | // "properties": { 639 | // "type": "object", 640 | // "jaxId": "1H1T83E7O8", 641 | // "editVersion": 104, 642 | // "attrs": { 643 | // "type": "hud", 644 | // "id": "BoxContent", 645 | // "position": "relative", 646 | // "x": "0", 647 | // "y": "0", 648 | // "w": "100%", 649 | // "h": "\"\"", 650 | // "anchorH": "Left", 651 | // "anchorV": "Top", 652 | // "autoLayout": "false", 653 | // "display": "On", 654 | // "clip": "Auto Scroll Y", 655 | // "uiEvent": "On", 656 | // "alpha": "1", 657 | // "rotate": "0", 658 | // "scale": "", 659 | // "filter": "", 660 | // "cursor": "", 661 | // "zIndex": "0", 662 | // "margin": "", 663 | // "padding": "", 664 | // "minW": "", 665 | // "minH": "30", 666 | // "maxW": "", 667 | // "maxH": "", 668 | // "face": "", 669 | // "styleClass": "", 670 | // "flex": "true", 671 | // "contentLayout": "Flex Y" 672 | // } 673 | // }, 674 | // "subHuds": { 675 | // "type": "array", 676 | // "attrs": [ 677 | // { 678 | // "type": "hudobj", 679 | // "def": "hud", 680 | // "jaxId": "1HIAUBB680", 681 | // "editVersion": 24, 682 | // "attrs": { 683 | // "properties": { 684 | // "type": "object", 685 | // "jaxId": "1HIAUG13S0", 686 | // "editVersion": 82, 687 | // "attrs": { 688 | // "type": "hud", 689 | // "id": "BoxSegs", 690 | // "position": "Absolute", 691 | // "x": "0", 692 | // "y": "0", 693 | // "w": "100%", 694 | // "h": "100%", 695 | // "anchorH": "Left", 696 | // "anchorV": "Top", 697 | // "autoLayout": "false", 698 | // "display": "On", 699 | // "clip": "Auto Scroll Y", 700 | // "uiEvent": "On", 701 | // "alpha": "1", 702 | // "rotate": "0", 703 | // "scale": "", 704 | // "filter": "", 705 | // "cursor": "", 706 | // "zIndex": "0", 707 | // "margin": "", 708 | // "padding": "", 709 | // "minW": "", 710 | // "minH": "", 711 | // "maxW": "", 712 | // "maxH": "", 713 | // "face": "", 714 | // "styleClass": "", 715 | // "contentLayout": "Flex Y" 716 | // } 717 | // }, 718 | // "subHuds": { 719 | // "type": "array", 720 | // "attrs": [ 721 | // { 722 | // "type": "hudobj", 723 | // "def": "Gear1HIASUKH50", 724 | // "jaxId": "1HIAUC7740", 725 | // "editVersion": 36, 726 | // "attrs": { 727 | // "createArgs": { 728 | // "type": "object", 729 | // "def": "gearCrateArgs", 730 | // "jaxId": "1HIAUC7741", 731 | // "editVersion": 10, 732 | // "attrs": { 733 | // "seg": "#{idx:1,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 734 | // } 735 | // }, 736 | // "properties": { 737 | // "type": "object", 738 | // "jaxId": "1HIAUC7742", 739 | // "editVersion": 25, 740 | // "attrs": { 741 | // "type": "#null#>BoxSeg({idx:1,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"})", 742 | // "id": "", 743 | // "position": "relative", 744 | // "x": "0", 745 | // "y": "0", 746 | // "display": "On", 747 | // "face": "" 748 | // } 749 | // }, 750 | // "subHuds": { 751 | // "type": "array", 752 | // "attrs": [] 753 | // }, 754 | // "faces": { 755 | // "type": "object", 756 | // "jaxId": "1HIAUC7750", 757 | // "editVersion": 0, 758 | // "attrs": {} 759 | // }, 760 | // "functions": { 761 | // "type": "object", 762 | // "jaxId": "1HIAUC7751", 763 | // "editVersion": 0, 764 | // "attrs": {} 765 | // }, 766 | // "extraPpts": { 767 | // "type": "object", 768 | // "def": "Object", 769 | // "jaxId": "1HIAUC7752", 770 | // "editVersion": 0, 771 | // "attrs": {} 772 | // }, 773 | // "mockup": "true", 774 | // "codes": "false", 775 | // "locked": "false", 776 | // "container": "false", 777 | // "nameVal": "false", 778 | // "containerSlots": { 779 | // "type": "object", 780 | // "jaxId": "1HIAUC7753", 781 | // "editVersion": 0, 782 | // "attrs": {} 783 | // } 784 | // } 785 | // }, 786 | // { 787 | // "type": "hudobj", 788 | // "def": "Gear1HIASUKH50", 789 | // "jaxId": "1HIAUCBC70", 790 | // "editVersion": 41, 791 | // "attrs": { 792 | // "createArgs": { 793 | // "type": "object", 794 | // "def": "gearCrateArgs", 795 | // "jaxId": "1HIAUCBC71", 796 | // "editVersion": 16, 797 | // "attrs": { 798 | // "seg": "#{idx:2,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 799 | // } 800 | // }, 801 | // "properties": { 802 | // "type": "object", 803 | // "jaxId": "1HIAUCBC72", 804 | // "editVersion": 27, 805 | // "attrs": { 806 | // "type": "#null#>BoxSeg({idx:2,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"})", 807 | // "id": "", 808 | // "position": "relative", 809 | // "x": "0", 810 | // "y": "0", 811 | // "display": "On", 812 | // "face": "" 813 | // } 814 | // }, 815 | // "subHuds": { 816 | // "type": "array", 817 | // "attrs": [] 818 | // }, 819 | // "faces": { 820 | // "type": "object", 821 | // "jaxId": "1HIAUCBC73", 822 | // "editVersion": 0, 823 | // "attrs": {} 824 | // }, 825 | // "functions": { 826 | // "type": "object", 827 | // "jaxId": "1HIAUCBC74", 828 | // "editVersion": 0, 829 | // "attrs": {} 830 | // }, 831 | // "extraPpts": { 832 | // "type": "object", 833 | // "def": "Object", 834 | // "jaxId": "1HIAUCBC75", 835 | // "editVersion": 0, 836 | // "attrs": {} 837 | // }, 838 | // "mockup": "true", 839 | // "codes": "false", 840 | // "locked": "false", 841 | // "container": "false", 842 | // "nameVal": "false", 843 | // "containerSlots": { 844 | // "type": "object", 845 | // "jaxId": "1HIAUCBC76", 846 | // "editVersion": 0, 847 | // "attrs": {} 848 | // } 849 | // } 850 | // }, 851 | // { 852 | // "type": "hudobj", 853 | // "def": "Gear1HIASUKH50", 854 | // "jaxId": "1HIAUCFIA0", 855 | // "editVersion": 42, 856 | // "attrs": { 857 | // "createArgs": { 858 | // "type": "object", 859 | // "def": "gearCrateArgs", 860 | // "jaxId": "1HIAUCFIA1", 861 | // "editVersion": 16, 862 | // "attrs": { 863 | // "seg": "#{idx:2,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"}" 864 | // } 865 | // }, 866 | // "properties": { 867 | // "type": "object", 868 | // "jaxId": "1HIAUCFIA2", 869 | // "editVersion": 28, 870 | // "attrs": { 871 | // "type": "#null#>BoxSeg({idx:2,text:\"abcd\",image:appCfg.sharedAssets+\"/close.svg\"})", 872 | // "id": "", 873 | // "position": "relative", 874 | // "x": "0", 875 | // "y": "0", 876 | // "display": "On", 877 | // "face": "" 878 | // } 879 | // }, 880 | // "subHuds": { 881 | // "type": "array", 882 | // "attrs": [] 883 | // }, 884 | // "faces": { 885 | // "type": "object", 886 | // "jaxId": "1HIAUCFIA3", 887 | // "editVersion": 0, 888 | // "attrs": {} 889 | // }, 890 | // "functions": { 891 | // "type": "object", 892 | // "jaxId": "1HIAUCFIA4", 893 | // "editVersion": 0, 894 | // "attrs": {} 895 | // }, 896 | // "extraPpts": { 897 | // "type": "object", 898 | // "def": "Object", 899 | // "jaxId": "1HIAUCFIA5", 900 | // "editVersion": 0, 901 | // "attrs": {} 902 | // }, 903 | // "mockup": "true", 904 | // "codes": "false", 905 | // "locked": "false", 906 | // "container": "false", 907 | // "nameVal": "false", 908 | // "containerSlots": { 909 | // "type": "object", 910 | // "jaxId": "1HIAUCFIA6", 911 | // "editVersion": 0, 912 | // "attrs": {} 913 | // } 914 | // } 915 | // } 916 | // ] 917 | // }, 918 | // "faces": { 919 | // "type": "object", 920 | // "jaxId": "1HIAUG13S1", 921 | // "editVersion": 0, 922 | // "attrs": {} 923 | // }, 924 | // "functions": { 925 | // "type": "object", 926 | // "jaxId": "1HIAUG13S2", 927 | // "editVersion": 0, 928 | // "attrs": {} 929 | // }, 930 | // "extraPpts": { 931 | // "type": "object", 932 | // "def": "Object", 933 | // "jaxId": "1HIAUG13S3", 934 | // "editVersion": 0, 935 | // "attrs": {} 936 | // }, 937 | // "mockup": "false", 938 | // "codes": "false", 939 | // "locked": "false", 940 | // "container": "true", 941 | // "nameVal": "false", 942 | // "exposeContainer": "false" 943 | // } 944 | // } 945 | // ] 946 | // }, 947 | // "faces": { 948 | // "type": "object", 949 | // "jaxId": "1H1T83E7O9", 950 | // "editVersion": 0, 951 | // "attrs": {} 952 | // }, 953 | // "functions": { 954 | // "type": "object", 955 | // "jaxId": "1H1T83E7O10", 956 | // "editVersion": 0, 957 | // "attrs": {} 958 | // }, 959 | // "extraPpts": { 960 | // "type": "object", 961 | // "def": "Object", 962 | // "jaxId": "1H1T83E7O11", 963 | // "editVersion": 0, 964 | // "attrs": {} 965 | // }, 966 | // "mockup": "false", 967 | // "codes": "false", 968 | // "locked": "false", 969 | // "container": "true", 970 | // "nameVal": "true", 971 | // "exposeContainer": "true" 972 | // } 973 | // }, 974 | // { 975 | // "type": "hudobj", 976 | // "def": "Gear/@StdUI/ui/BtnIcon.js", 977 | // "jaxId": "1HIARRB8R0", 978 | // "editVersion": 31, 979 | // "attrs": { 980 | // "createArgs": { 981 | // "type": "object", 982 | // "def": "gearCrateArgs", 983 | // "jaxId": "1HIASS5BN0", 984 | // "editVersion": 16, 985 | // "attrs": { 986 | // "style": "\"front\"", 987 | // "w": "30", 988 | // "h": "0", 989 | // "icon": "#appCfg.sharedAssets+\"/close.svg\"", 990 | // "colorBG": "null" 991 | // } 992 | // }, 993 | // "properties": { 994 | // "type": "object", 995 | // "jaxId": "1HIASS5BN1", 996 | // "editVersion": 48, 997 | // "attrs": { 998 | // "type": "#null#>BtnIcon(\"front\",30,0,appCfg.sharedAssets+\"/close.svg\",null)", 999 | // "id": "BtnClose", 1000 | // "position": "Absolute", 1001 | // "x": "100%-40", 1002 | // "y": "10", 1003 | // "display": "On", 1004 | // "face": "", 1005 | // "padding": "2" 1006 | // } 1007 | // }, 1008 | // "subHuds": { 1009 | // "type": "array", 1010 | // "attrs": [] 1011 | // }, 1012 | // "faces": { 1013 | // "type": "object", 1014 | // "jaxId": "1HIASS5BN2", 1015 | // "editVersion": 0, 1016 | // "attrs": {} 1017 | // }, 1018 | // "functions": { 1019 | // "type": "object", 1020 | // "jaxId": "1HIASS5BN3", 1021 | // "editVersion": 2, 1022 | // "attrs": { 1023 | // "OnClick": { 1024 | // "type": "fixedFunc", 1025 | // "jaxId": "1HIAUI0L80", 1026 | // "editVersion": 6, 1027 | // "attrs": { 1028 | // "callArgs": { 1029 | // "type": "object", 1030 | // "jaxId": "1HIAUI0L81", 1031 | // "editVersion": 2, 1032 | // "attrs": { 1033 | // "event": "" 1034 | // } 1035 | // }, 1036 | // "seg": "1HIAUH66I0" 1037 | // } 1038 | // } 1039 | // } 1040 | // }, 1041 | // "extraPpts": { 1042 | // "type": "object", 1043 | // "def": "Object", 1044 | // "jaxId": "1HIASS5BN4", 1045 | // "editVersion": 0, 1046 | // "attrs": {} 1047 | // }, 1048 | // "mockup": "false", 1049 | // "codes": "false", 1050 | // "locked": "false", 1051 | // "container": "false", 1052 | // "nameVal": "false", 1053 | // "containerSlots": { 1054 | // "type": "object", 1055 | // "jaxId": "1HIASS5BN5", 1056 | // "editVersion": 0, 1057 | // "attrs": {} 1058 | // } 1059 | // } 1060 | // } 1061 | // ] 1062 | // }, 1063 | // "faces": { 1064 | // "type": "object", 1065 | // "jaxId": "1H1T7ISV59", 1066 | // "editVersion": 0, 1067 | // "attrs": {} 1068 | // }, 1069 | // "functions": { 1070 | // "type": "object", 1071 | // "jaxId": "1H1T7ISV510", 1072 | // "editVersion": 0, 1073 | // "attrs": {} 1074 | // }, 1075 | // "extraPpts": { 1076 | // "type": "object", 1077 | // "def": "Object", 1078 | // "jaxId": "1H1T7ISV511", 1079 | // "editVersion": 0, 1080 | // "attrs": {} 1081 | // }, 1082 | // "mockup": "false", 1083 | // "codes": "false", 1084 | // "locked": "false", 1085 | // "container": "true", 1086 | // "nameVal": "false", 1087 | // "exposeContainer": "false" 1088 | // } 1089 | // }, 1090 | // "exposeGear": "true", 1091 | // "exposeTemplate": "true", 1092 | // "exposeAttrs": { 1093 | // "type": "object", 1094 | // "def": "exposeAttrs", 1095 | // "jaxId": "1H1T7ISV512", 1096 | // "editVersion": 84, 1097 | // "attrs": { 1098 | // "id": "true", 1099 | // "position": "true", 1100 | // "x": "true", 1101 | // "y": "true", 1102 | // "w": "true", 1103 | // "h": "true", 1104 | // "anchorH": "false", 1105 | // "anchorV": "false", 1106 | // "autoLayout": "false", 1107 | // "display": "true", 1108 | // "contentLayout": "false", 1109 | // "subAlign": "false", 1110 | // "itemsAlign": "false", 1111 | // "itemsWrap": "false", 1112 | // "clip": "false", 1113 | // "uiEvent": "false", 1114 | // "alpha": "false", 1115 | // "rotate": "false", 1116 | // "scale": "false", 1117 | // "filter": "false", 1118 | // "aspect": "false", 1119 | // "cursor": "false", 1120 | // "zIndex": "false", 1121 | // "flex": "false", 1122 | // "margin": "false", 1123 | // "traceSize": "false", 1124 | // "padding": "false", 1125 | // "minW": "false", 1126 | // "minH": "false", 1127 | // "maxW": "false", 1128 | // "maxH": "false", 1129 | // "styleClass": "false", 1130 | // "innerLayout": { 1131 | // "valText": "false" 1132 | // }, 1133 | // "marginL": { 1134 | // "valText": "false" 1135 | // }, 1136 | // "marginR": { 1137 | // "valText": "false" 1138 | // }, 1139 | // "marginT": { 1140 | // "valText": "false" 1141 | // }, 1142 | // "marginB": { 1143 | // "valText": "false" 1144 | // }, 1145 | // "paddingL": { 1146 | // "valText": "false" 1147 | // }, 1148 | // "paddingR": { 1149 | // "valText": "false" 1150 | // }, 1151 | // "paddingT": { 1152 | // "valText": "false" 1153 | // }, 1154 | // "paddingB": { 1155 | // "valText": "false" 1156 | // }, 1157 | // "attach": { 1158 | // "valText": "false" 1159 | // } 1160 | // } 1161 | // }, 1162 | // "exposeStateAttrs": { 1163 | // "type": "array", 1164 | // "def": "StringArray", 1165 | // "attrs": [] 1166 | // } 1167 | // } 1168 | //} -------------------------------------------------------------------------------- /ai/agent.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 | /*#{1HDBOSUN90MoreImports*/ 8 | /*}#1HDBOSUN90MoreImports*/ 9 | const agentURL=(new URL(import.meta.url)).pathname; 10 | const basePath=pathLib.dirname(agentURL); 11 | const $ln=VFACT.lanCode||"EN"; 12 | /*#{1HDBOSUN90StartDoc*/ 13 | //---------------------------------------------------------------------------- 14 | const app=VFACT.app; 15 | /*}#1HDBOSUN90StartDoc*/ 16 | //---------------------------------------------------------------------------- 17 | let agent=async function(session){ 18 | let context,globalContext; 19 | let self; 20 | let Start,NewStory,StartWrite,WriteSeg,SaveStory,StarMenu,LoadStory,NextMenu,ShowStory,ExportStory,EditStory,SaveEdit; 21 | /*#{1HDBOSUN90LocalVals*/ 22 | /*}#1HDBOSUN90LocalVals*/ 23 | 24 | /*#{1HDBOSUN90PreContext*/ 25 | /*}#1HDBOSUN90PreContext*/ 26 | globalContext=session.globalContext; 27 | context={}; 28 | context=VFACT.flexState(context); 29 | /*#{1HDBOSUN90PostContext*/ 30 | globalContext.memory=""; 31 | /*}#1HDBOSUN90PostContext*/ 32 | let agent,segs={}; 33 | segs["Start"]=Start=async function(input){//:1HDBPEGBH0 34 | let result=input; 35 | let role="assistant"; 36 | let content=(($ln==="CN")?("你好!这是一个通过 AI 撰写短篇小说的 Agent 演示"):("Hello! This is a demo of an AI-powered agent for writing short stories.")); 37 | session.addChatText(role,content); 38 | return {seg:StarMenu,result:(result),preSeg:"1HDBPEGBH0",outlet:"1HDBPEGBH1"}; 39 | }; 40 | Start.jaxId="1HDBPEGBH0" 41 | Start.url="Start@"+agentURL 42 | 43 | segs["NewStory"]=NewStory=async function(input){//:1HI79NVUM0 44 | let result; 45 | let sourcePath=pathLib.join(basePath,"./NewStory.js"); 46 | result= await session.pipeChat(sourcePath,input,false); 47 | return {seg:StartWrite,result:(result),preSeg:"1HI79NVUM0",outlet:"1HI79NVUM1"}; 48 | }; 49 | NewStory.jaxId="1HI79NVUM0" 50 | NewStory.url="NewStory@"+agentURL 51 | 52 | segs["StartWrite"]=StartWrite=async function(input){//:1HI79NVUM2 53 | let result=input; 54 | let role="assistant"; 55 | let content="太好了,我们现在可以开始写故事了!"; 56 | session.addChatText(role,content); 57 | return {seg:WriteSeg,result:(result),preSeg:"1HI79NVUM2",outlet:"1HI79NVUM3"}; 58 | }; 59 | StartWrite.jaxId="1HI79NVUM2" 60 | StartWrite.url="StartWrite@"+agentURL 61 | 62 | segs["WriteSeg"]=WriteSeg=async function(input){//:1HI79NVUM4 63 | let result; 64 | let sourcePath=pathLib.join(basePath,"./WriteSeg.js"); 65 | result= await session.pipeChat(sourcePath,input,false); 66 | return {seg:SaveStory,result:(result),preSeg:"1HI79NVUM4",outlet:"1HI79NVUM5"}; 67 | }; 68 | WriteSeg.jaxId="1HI79NVUM4" 69 | WriteSeg.url="WriteSeg@"+agentURL 70 | 71 | segs["SaveStory"]=SaveStory=async function(input){//:1HI79NVUM6 72 | let saveVO={context:{}}; 73 | let ctxVO=saveVO.context; 74 | let result=saveVO; 75 | /*#{1HI79NVUM6PreCodes*/ 76 | saveVO.StoryTitle=globalContext.StoryTitle; 77 | saveVO.StorySegs=globalContext.StorySegs; 78 | saveVO.PackedSegs=globalContext.PackedSegs; 79 | saveVO.DrawStyle=globalContext.DrawStyle; 80 | saveVO.LLMMode=globalContext.LLMMode; 81 | if(globalContext.StoryCover){ 82 | saveVO.StoryCover=globalContext.StoryCover; 83 | } 84 | /*}#1HI79NVUM6PreCodes*/ 85 | /*#{1HI79NVUM6PostCodes*/ 86 | /*}#1HI79NVUM6PostCodes*/ 87 | { 88 | let tabFS=(await import("/@tabos")).tabFS; 89 | let fileName=`/doc/story_${globalContext.StoryTitle}.json`; 90 | let content=JSON.stringify(saveVO,null," "); 91 | fileName=fileName[0]==="/"?fileName:basePath+"/"+fileName; 92 | fileName=fileName.startsWith("/~/")?fileName.substring(2):fileName; 93 | fileName=fileName.startsWith("//")?fileName.substring(1):fileName; 94 | /*#{1HI79NVUM6SaveData*/ 95 | /*}#1HI79NVUM6SaveData*/ 96 | await tabFS.writeFile(fileName,content,"utf8"); 97 | } 98 | /*#{1HI79NVUM6FinCodes*/ 99 | app.emit("StoryUpdate",globalContext); 100 | /*}#1HI79NVUM6FinCodes*/ 101 | return {seg:NextMenu,result:(result),preSeg:"1HI79NVUM6",outlet:"1HI79NVUM7"}; 102 | }; 103 | SaveStory.jaxId="1HI79NVUM6" 104 | SaveStory.url="SaveStory@"+agentURL 105 | 106 | segs["StarMenu"]=StarMenu=async function(input){//:1HI79NVUM8 107 | let prompt=("新建故事还是读取已存在的项目")||input; 108 | let items=[ 109 | {icon:"/~/-tabos/shared/assets/hudbox.svg",text:"新建一个故事",code:0}, 110 | {icon:"/~/-tabos/shared/assets/folder.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"加载故事",code:1}, 111 | ]; 112 | let result=""; 113 | let item=null; 114 | let multi=false; 115 | 116 | [result,item]=await session.askUserRaw({type:"menu",prompt:prompt,multiSelect:multi,items:items}); 117 | if(multi){ 118 | return {seg:NewStory,result:(result),preSeg:"1HI79NVUM8",outlet:"1HI78J1HI0"}; 119 | } 120 | if(item.code===0){ 121 | return {seg:NewStory,result:(result),preSeg:"1HI79NVUM8",outlet:"1HI78J1HI0"}; 122 | } 123 | if(item.code===1){ 124 | return {seg:LoadStory,result:(result),preSeg:"1HI79NVUM8",outlet:"1HI78J1HI1"}; 125 | } 126 | return {result:result}; 127 | 128 | }; 129 | StarMenu.jaxId="1HI79NVUM8" 130 | StarMenu.url="StarMenu@"+agentURL 131 | 132 | segs["LoadStory"]=LoadStory=async function(input){//:1HI79NVUM9 133 | let result; 134 | let sourcePath=pathLib.join(basePath,"./LoadStory.js"); 135 | result= await session.pipeChat(sourcePath,input,false); 136 | return {seg:ShowStory,result:(result),preSeg:"1HI79NVUM9",outlet:"1HI79NVUM10"}; 137 | }; 138 | LoadStory.jaxId="1HI79NVUM9" 139 | LoadStory.url="LoadStory@"+agentURL 140 | 141 | segs["NextMenu"]=NextMenu=async function(input){//:1HI79NVUM11 142 | let prompt=("请选择下一步的操作")||input; 143 | let items=[ 144 | {icon:"/~/-tabos/shared/assets/inc.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"继续撰写",code:0}, 145 | {icon:"/~/-tabos/shared/assets/file.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"查看当前故事",code:1}, 146 | {icon:"/~/-tabos/shared/assets/edit.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"编辑文章",code:2}, 147 | {icon:"/~/-tabos/shared/assets/share.svg"||"/~/-tabos/shared/assets/hudbox.svg",text:"输出故事",code:3}, 148 | ]; 149 | let result=""; 150 | let item=null; 151 | let multi=false; 152 | 153 | [result,item]=await session.askUserRaw({type:"menu",prompt:prompt,multiSelect:multi,items:items}); 154 | if(multi){ 155 | return {seg:WriteSeg,result:(result),preSeg:"1HI79NVUM11",outlet:"1HI78SAD81"}; 156 | } 157 | if(item.code===0){ 158 | return {seg:WriteSeg,result:(result),preSeg:"1HI79NVUM11",outlet:"1HI78SAD81"}; 159 | } 160 | if(item.code===1){ 161 | return {seg:ShowStory,result:(result),preSeg:"1HI79NVUM11",outlet:"1HI78SAD80"}; 162 | } 163 | if(item.code===2){ 164 | return {seg:EditStory,result:(result),preSeg:"1HI79NVUM11",outlet:"1HI7D5NNL0"}; 165 | } 166 | if(item.code===3){ 167 | return {seg:ExportStory,result:(result),preSeg:"1HI79NVUM11",outlet:"1HI78SAD82"}; 168 | } 169 | return {result:result}; 170 | 171 | }; 172 | NextMenu.jaxId="1HI79NVUM11" 173 | NextMenu.url="NextMenu@"+agentURL 174 | 175 | segs["ShowStory"]=ShowStory=async function(input){//:1HI79NVUM12 176 | let result=input; 177 | let role="assistant"; 178 | let content=input; 179 | /*#{1HI79NVUM12PreCodes*/ 180 | /* 181 | let segs=globalContext.StorySegs; 182 | segs=segs.map((item)=>{ 183 | if(item.image){ 184 | return `![pic](${item.image}) \n\n${item.text}`; 185 | } 186 | return " "+item.text 187 | }); 188 | content=segs.join("\n\n"); 189 | content=`## ${globalContext.StoryTitle}\n${content}`; 190 | if(globalContext.StoryCover){ 191 | content=`![cover](${globalContext.StoryCover})\n${content}`; 192 | } 193 | //console.log(content); 194 | */ 195 | content="显示当前文章。"; 196 | /*}#1HI79NVUM12PreCodes*/ 197 | session.addChatText(role,content); 198 | /*#{1HI79NVUM12PostCodes*/ 199 | app.emit("StoryUpdate",globalContext); 200 | app.emit("ShowStory",globalContext); 201 | /*}#1HI79NVUM12PostCodes*/ 202 | return {seg:NextMenu,result:(result),preSeg:"1HI79NVUM12",outlet:"1HI79NVUM13"}; 203 | }; 204 | ShowStory.jaxId="1HI79NVUM12" 205 | ShowStory.url="ShowStory@"+agentURL 206 | 207 | segs["ExportStory"]=ExportStory=async function(input){//:1HI79NVUM14 208 | let result; 209 | let sourcePath=pathLib.join(basePath,"./ExportStory.js"); 210 | result= await session.pipeChat(sourcePath,input,false); 211 | return {seg:NextMenu,result:(result),preSeg:"1HI79NVUM14",outlet:"1HI79NVUM15"}; 212 | }; 213 | ExportStory.jaxId="1HI79NVUM14" 214 | ExportStory.url="ExportStory@"+agentURL 215 | 216 | segs["EditStory"]=EditStory=async function(input){//:1HI7D5NNL1 217 | let result; 218 | let sourcePath=pathLib.join(basePath,"./EditStory.js"); 219 | result= await session.pipeChat(sourcePath,input,false); 220 | return {seg:SaveEdit,result:(result),preSeg:"1HI7D5NNL1",outlet:"1HI7D5NNL2"}; 221 | }; 222 | EditStory.jaxId="1HI7D5NNL1" 223 | EditStory.url="EditStory@"+agentURL 224 | 225 | segs["SaveEdit"]=SaveEdit=async function(input){//:1HIBJ7OVI0 226 | let saveVO={context:{}}; 227 | let ctxVO=saveVO.context; 228 | let result=saveVO; 229 | /*#{1HIBJ7OVI0PreCodes*/ 230 | saveVO.StoryTitle=globalContext.StoryTitle; 231 | saveVO.StorySegs=globalContext.StorySegs; 232 | saveVO.PackedSegs=globalContext.PackedSegs; 233 | saveVO.DrawStyle=globalContext.DrawStyle; 234 | if(globalContext.StoryCover){ 235 | saveVO.StoryCover=globalContext.StoryCover; 236 | } 237 | /*}#1HIBJ7OVI0PreCodes*/ 238 | /*#{1HIBJ7OVI0PostCodes*/ 239 | /*}#1HIBJ7OVI0PostCodes*/ 240 | { 241 | let tabFS=(await import("/@tabos")).tabFS; 242 | let fileName=`/doc/story_${globalContext.StoryTitle}.json`; 243 | let content=JSON.stringify(saveVO,null," "); 244 | fileName=fileName[0]==="/"?fileName:basePath+"/"+fileName; 245 | fileName=fileName.startsWith("/~/")?fileName.substring(2):fileName; 246 | fileName=fileName.startsWith("//")?fileName.substring(1):fileName; 247 | /*#{1HIBJ7OVI0SaveData*/ 248 | /*}#1HIBJ7OVI0SaveData*/ 249 | await tabFS.writeFile(fileName,content,"utf8"); 250 | } 251 | /*#{1HIBJ7OVI0FinCodes*/ 252 | app.emit("StoryUpdate",globalContext); 253 | /*}#1HIBJ7OVI0FinCodes*/ 254 | return {seg:NextMenu,result:(result),preSeg:"1HIBJ7OVI0",outlet:"1HIBJ7OVJ0"}; 255 | }; 256 | SaveEdit.jaxId="1HIBJ7OVI0" 257 | SaveEdit.url="SaveEdit@"+agentURL 258 | 259 | agent={ 260 | isAIAgent:true, 261 | session:session, 262 | name:"agent", 263 | url:agentURL, 264 | autoStart:true, 265 | jaxId:"1HDBOSUN90", 266 | context:context, 267 | livingSeg:null, 268 | execChat:async function(input){ 269 | let result; 270 | /*#{1HDBOSUN90PreEntry*/ 271 | /*}#1HDBOSUN90PreEntry*/ 272 | result={seg:Start,"input":input}; 273 | /*#{1HDBOSUN90PostEntry*/ 274 | /*}#1HDBOSUN90PostEntry*/ 275 | return result; 276 | }, 277 | /*#{1HDBOSUN90MoreAgentAttrs*/ 278 | /*}#1HDBOSUN90MoreAgentAttrs*/ 279 | }; 280 | /*#{1HDBOSUN90PostAgent*/ 281 | /*}#1HDBOSUN90PostAgent*/ 282 | return agent; 283 | }; 284 | /*#{1HDBOSUN90ExCodes*/ 285 | /*}#1HDBOSUN90ExCodes*/ 286 | 287 | 288 | export default agent; 289 | export{agent}; 290 | /*Cody Project Doc*/ 291 | //{ 292 | // "type": "docfile", 293 | // "def": "DocAIAgent", 294 | // "jaxId": "1HDBOSUN90", 295 | // "editVersion": 52, 296 | // "attrs": { 297 | // "editObjs": { 298 | // "type": "object", 299 | // "def": "Object", 300 | // "jaxId": "1HDBOSUNA0", 301 | // "editVersion": 2, 302 | // "attrs": { 303 | // "agent": { 304 | // "type": "objclass", 305 | // "def": "ObjClass", 306 | // "jaxId": "1HDBOSUNA4", 307 | // "editVersion": 84, 308 | // "attrs": { 309 | // "constructArgs": { 310 | // "type": "object", 311 | // "jaxId": "1HDBOSUNB0", 312 | // "editVersion": 0, 313 | // "attrs": {} 314 | // }, 315 | // "superClass": "", 316 | // "properties": { 317 | // "type": "object", 318 | // "def": "Object", 319 | // "jaxId": "1HDBOSUNB1", 320 | // "editVersion": 0, 321 | // "attrs": {} 322 | // }, 323 | // "functions": { 324 | // "type": "object", 325 | // "def": "Functions", 326 | // "jaxId": "1HDBOSUNB2", 327 | // "editVersion": 0, 328 | // "attrs": {} 329 | // }, 330 | // "mockupOnly": "false", 331 | // "nullMockup": "false" 332 | // }, 333 | // "mockups": {} 334 | // } 335 | // } 336 | // }, 337 | // "agent": { 338 | // "type": "object", 339 | // "def": "Object", 340 | // "jaxId": "1HDBOSUNA1", 341 | // "editVersion": 0, 342 | // "attrs": {} 343 | // }, 344 | // "segs": { 345 | // "type": "array", 346 | // "attrs": [ 347 | // { 348 | // "type": "aiseg", 349 | // "def": "output", 350 | // "jaxId": "1HDBPEGBH0", 351 | // "editVersion": 253, 352 | // "attrs": { 353 | // "id": "Start", 354 | // "label": "Greating", 355 | // "x": "40", 356 | // "y": "510", 357 | // "context": { 358 | // "type": "object", 359 | // "def": "Object", 360 | // "jaxId": "1HDBPEGBK0", 361 | // "editVersion": 0, 362 | // "attrs": {} 363 | // }, 364 | // "global": { 365 | // "type": "object", 366 | // "def": "Object", 367 | // "jaxId": "1HDIJB7SK0", 368 | // "editVersion": 0, 369 | // "attrs": {} 370 | // }, 371 | // "desc": "Start agent. Greeting to user.", 372 | // "codes": "false", 373 | // "mkpInput": "$$input$$", 374 | // "role": "Assistant", 375 | // "text": { 376 | // "type": "string", 377 | // "valText": "Hello! This is a demo of an AI-powered agent for writing short stories.", 378 | // "localize": { 379 | // "EN": "Hello! This is a demo of an AI-powered agent for writing short stories.", 380 | // "CN": "你好!这是一个通过 AI 撰写短篇小说的 Agent 演示" 381 | // }, 382 | // "localizable": true 383 | // }, 384 | // "outlet": { 385 | // "type": "aioutlet", 386 | // "def": "AISegOutlet", 387 | // "jaxId": "1HDBPEGBH1", 388 | // "editVersion": 165, 389 | // "attrs": { 390 | // "id": "Result", 391 | // "desc": "输出节点。" 392 | // }, 393 | // "linkedSeg": "1HI79NVUM8" 394 | // } 395 | // } 396 | // }, 397 | // { 398 | // "type": "aiseg", 399 | // "def": "aiBot", 400 | // "jaxId": "1HI79NVUM0", 401 | // "editVersion": 168, 402 | // "attrs": { 403 | // "id": "NewStory", 404 | // "label": "New AI Seg", 405 | // "x": "490", 406 | // "y": "370", 407 | // "context": { 408 | // "type": "object", 409 | // "def": "Object", 410 | // "jaxId": "1HI79NVUQ0", 411 | // "editVersion": 0, 412 | // "attrs": {} 413 | // }, 414 | // "global": { 415 | // "type": "object", 416 | // "def": "Object", 417 | // "jaxId": "1HI79NVUQ1", 418 | // "editVersion": 0, 419 | // "attrs": {} 420 | // }, 421 | // "desc": "调用其它AI Agent,把调用的结果作为输出", 422 | // "codes": "false", 423 | // "mkpInput": "$$input$$", 424 | // "source": "ai/NewStory.js", 425 | // "secret": "false", 426 | // "outlet": { 427 | // "type": "aioutlet", 428 | // "def": "AISegOutlet", 429 | // "jaxId": "1HI79NVUM1", 430 | // "editVersion": 92, 431 | // "attrs": { 432 | // "id": "Result", 433 | // "desc": "输出节点。" 434 | // }, 435 | // "linkedSeg": "1HI79NVUM2" 436 | // } 437 | // } 438 | // }, 439 | // { 440 | // "type": "aiseg", 441 | // "def": "output", 442 | // "jaxId": "1HI79NVUM2", 443 | // "editVersion": 168, 444 | // "attrs": { 445 | // "id": "StartWrite", 446 | // "label": "New AI Seg", 447 | // "x": "740", 448 | // "y": "370", 449 | // "context": { 450 | // "type": "object", 451 | // "def": "Object", 452 | // "jaxId": "1HI79NVUQ2", 453 | // "editVersion": 0, 454 | // "attrs": {} 455 | // }, 456 | // "global": { 457 | // "type": "object", 458 | // "def": "Object", 459 | // "jaxId": "1HI79NVUQ3", 460 | // "editVersion": 0, 461 | // "attrs": {} 462 | // }, 463 | // "desc": "这是一个AISeg。", 464 | // "codes": "false", 465 | // "mkpInput": "$$input$$", 466 | // "role": "Assistant", 467 | // "text": "太好了,我们现在可以开始写故事了!", 468 | // "outlet": { 469 | // "type": "aioutlet", 470 | // "def": "AISegOutlet", 471 | // "jaxId": "1HI79NVUM3", 472 | // "editVersion": 92, 473 | // "attrs": { 474 | // "id": "Result", 475 | // "desc": "输出节点。" 476 | // }, 477 | // "linkedSeg": "1HI79NVUM4" 478 | // } 479 | // } 480 | // }, 481 | // { 482 | // "type": "aiseg", 483 | // "def": "aiBot", 484 | // "jaxId": "1HI79NVUM4", 485 | // "editVersion": 163, 486 | // "attrs": { 487 | // "id": "WriteSeg", 488 | // "label": "New AI Seg", 489 | // "x": "1000", 490 | // "y": "370", 491 | // "context": { 492 | // "type": "object", 493 | // "def": "Object", 494 | // "jaxId": "1HI79NVUQ4", 495 | // "editVersion": 0, 496 | // "attrs": {} 497 | // }, 498 | // "global": { 499 | // "type": "object", 500 | // "def": "Object", 501 | // "jaxId": "1HI79NVUQ5", 502 | // "editVersion": 0, 503 | // "attrs": {} 504 | // }, 505 | // "desc": "调用其它AI Agent,把调用的结果作为输出", 506 | // "codes": "false", 507 | // "mkpInput": "$$input$$", 508 | // "source": "ai/WriteSeg.js", 509 | // "secret": "false", 510 | // "outlet": { 511 | // "type": "aioutlet", 512 | // "def": "AISegOutlet", 513 | // "jaxId": "1HI79NVUM5", 514 | // "editVersion": 82, 515 | // "attrs": { 516 | // "id": "Result", 517 | // "desc": "输出节点。" 518 | // }, 519 | // "linkedSeg": "1HI79NVUM6" 520 | // } 521 | // } 522 | // }, 523 | // { 524 | // "type": "aiseg", 525 | // "def": "save", 526 | // "jaxId": "1HI79NVUM6", 527 | // "editVersion": 162, 528 | // "attrs": { 529 | // "id": "SaveStory", 530 | // "label": "New AI Seg", 531 | // "x": "1260", 532 | // "y": "370", 533 | // "context": { 534 | // "type": "object", 535 | // "def": "Object", 536 | // "jaxId": "1HI79NVUQ6", 537 | // "editVersion": 0, 538 | // "attrs": {} 539 | // }, 540 | // "global": { 541 | // "type": "object", 542 | // "def": "Object", 543 | // "jaxId": "1HI79NVUQ7", 544 | // "editVersion": 0, 545 | // "attrs": {} 546 | // }, 547 | // "desc": "这是一个AISeg。", 548 | // "codes": "true", 549 | // "mkpInput": "$$input$$", 550 | // "fileName": "#`/doc/story_${globalContext.StoryTitle}.json`", 551 | // "saveContext": { 552 | // "type": "array", 553 | // "def": "StringArray", 554 | // "attrs": [] 555 | // }, 556 | // "outlet": { 557 | // "type": "aioutlet", 558 | // "def": "AISegOutlet", 559 | // "jaxId": "1HI79NVUM7", 560 | // "editVersion": 82, 561 | // "attrs": { 562 | // "id": "Result", 563 | // "desc": "输出节点。" 564 | // }, 565 | // "linkedSeg": "1HI79NVUM11" 566 | // } 567 | // } 568 | // }, 569 | // { 570 | // "type": "aiseg", 571 | // "def": "askMenu", 572 | // "jaxId": "1HI79NVUM8", 573 | // "editVersion": 173, 574 | // "attrs": { 575 | // "id": "StarMenu", 576 | // "label": "New AI Seg", 577 | // "x": "230", 578 | // "y": "510", 579 | // "context": { 580 | // "type": "object", 581 | // "def": "Object", 582 | // "jaxId": "1HI79NVUQ8", 583 | // "editVersion": 0, 584 | // "attrs": {} 585 | // }, 586 | // "global": { 587 | // "type": "object", 588 | // "def": "Object", 589 | // "jaxId": "1HI79NVUQ9", 590 | // "editVersion": 0, 591 | // "attrs": {} 592 | // }, 593 | // "desc": "这是一个AISeg。", 594 | // "codes": "false", 595 | // "mkpInput": "$$input$$", 596 | // "prompt": "新建故事还是读取已存在的项目", 597 | // "multi": "false", 598 | // "outlets": { 599 | // "type": "array", 600 | // "attrs": [ 601 | // { 602 | // "type": "aioutlet", 603 | // "def": "AIButtonOutlet", 604 | // "jaxId": "1HI78J1HI0", 605 | // "editVersion": 118, 606 | // "attrs": { 607 | // "id": "NewStory", 608 | // "text": "新建一个故事", 609 | // "result": "", 610 | // "codes": "false" 611 | // }, 612 | // "linkedSeg": "1HI79NVUM0" 613 | // }, 614 | // { 615 | // "type": "aioutlet", 616 | // "def": "AIButtonOutlet", 617 | // "jaxId": "1HI78J1HI1", 618 | // "editVersion": 110, 619 | // "attrs": { 620 | // "id": "LoadStory", 621 | // "text": "加载故事", 622 | // "result": "", 623 | // "codes": "false", 624 | // "icon": "/-tabos/shared/assets/folder.svg" 625 | // }, 626 | // "linkedSeg": "1HI79NVUM9" 627 | // } 628 | // ] 629 | // } 630 | // } 631 | // }, 632 | // { 633 | // "type": "aiseg", 634 | // "def": "aiBot", 635 | // "jaxId": "1HI79NVUM9", 636 | // "editVersion": 146, 637 | // "attrs": { 638 | // "id": "LoadStory", 639 | // "label": "New AI Seg", 640 | // "x": "480", 641 | // "y": "560", 642 | // "context": { 643 | // "type": "object", 644 | // "def": "Object", 645 | // "jaxId": "1HI79NVUQ10", 646 | // "editVersion": 0, 647 | // "attrs": {} 648 | // }, 649 | // "global": { 650 | // "type": "object", 651 | // "def": "Object", 652 | // "jaxId": "1HI79NVUQ11", 653 | // "editVersion": 0, 654 | // "attrs": {} 655 | // }, 656 | // "desc": "调用其它AI Agent,把调用的结果作为输出", 657 | // "codes": "false", 658 | // "mkpInput": "$$input$$", 659 | // "source": "ai/LoadStory.js", 660 | // "secret": "false", 661 | // "outlet": { 662 | // "type": "aioutlet", 663 | // "def": "AISegOutlet", 664 | // "jaxId": "1HI79NVUM10", 665 | // "editVersion": 95, 666 | // "attrs": { 667 | // "id": "Result", 668 | // "desc": "输出节点。" 669 | // }, 670 | // "linkedSeg": "1HI9B1M0J0" 671 | // } 672 | // } 673 | // }, 674 | // { 675 | // "type": "aiseg", 676 | // "def": "askMenu", 677 | // "jaxId": "1HI79NVUM11", 678 | // "editVersion": 235, 679 | // "attrs": { 680 | // "id": "NextMenu", 681 | // "label": "New AI Seg", 682 | // "x": "1500", 683 | // "y": "560", 684 | // "context": { 685 | // "type": "object", 686 | // "def": "Object", 687 | // "jaxId": "1HI79NVUQ12", 688 | // "editVersion": 0, 689 | // "attrs": {} 690 | // }, 691 | // "global": { 692 | // "type": "object", 693 | // "def": "Object", 694 | // "jaxId": "1HI79NVUQ13", 695 | // "editVersion": 0, 696 | // "attrs": {} 697 | // }, 698 | // "desc": "这是一个AISeg。", 699 | // "codes": "false", 700 | // "mkpInput": "$$input$$", 701 | // "prompt": "请选择下一步的操作", 702 | // "multi": "false", 703 | // "outlets": { 704 | // "type": "array", 705 | // "attrs": [ 706 | // { 707 | // "type": "aioutlet", 708 | // "def": "AIButtonOutlet", 709 | // "jaxId": "1HI78SAD81", 710 | // "editVersion": 88, 711 | // "attrs": { 712 | // "id": "WriteMore", 713 | // "text": "继续撰写", 714 | // "result": "", 715 | // "codes": "false", 716 | // "icon": "/-tabos/shared/assets/inc.svg" 717 | // }, 718 | // "linkedSeg": "1HI79NVUQ14" 719 | // }, 720 | // { 721 | // "type": "aioutlet", 722 | // "def": "AIButtonOutlet", 723 | // "jaxId": "1HI78SAD80", 724 | // "editVersion": 97, 725 | // "attrs": { 726 | // "id": "ViewSotry", 727 | // "text": "查看当前故事", 728 | // "result": "", 729 | // "codes": "false", 730 | // "icon": "/-tabos/shared/assets/file.svg" 731 | // }, 732 | // "linkedSeg": "1HI79NVUM12" 733 | // }, 734 | // { 735 | // "type": "aioutlet", 736 | // "def": "AIButtonOutlet", 737 | // "jaxId": "1HI7D5NNL0", 738 | // "editVersion": 124, 739 | // "attrs": { 740 | // "id": "Edit", 741 | // "text": "编辑文章", 742 | // "result": "", 743 | // "codes": "false", 744 | // "icon": "/-tabos/shared/assets/edit.svg" 745 | // }, 746 | // "linkedSeg": "1HI7D5NNL1" 747 | // }, 748 | // { 749 | // "type": "aioutlet", 750 | // "def": "AIButtonOutlet", 751 | // "jaxId": "1HI78SAD82", 752 | // "editVersion": 90, 753 | // "attrs": { 754 | // "id": "Export", 755 | // "text": "输出故事", 756 | // "result": "", 757 | // "codes": "false", 758 | // "icon": "/-tabos/shared/assets/share.svg" 759 | // }, 760 | // "linkedSeg": "1HI79NVUM14" 761 | // } 762 | // ] 763 | // } 764 | // } 765 | // }, 766 | // { 767 | // "type": "aiseg", 768 | // "def": "output", 769 | // "jaxId": "1HI79NVUM12", 770 | // "editVersion": 202, 771 | // "attrs": { 772 | // "id": "ShowStory", 773 | // "label": "New AI Seg", 774 | // "x": "1780", 775 | // "y": "480", 776 | // "context": { 777 | // "type": "object", 778 | // "def": "Object", 779 | // "jaxId": "1HI79NVUQ15", 780 | // "editVersion": 0, 781 | // "attrs": {} 782 | // }, 783 | // "global": { 784 | // "type": "object", 785 | // "def": "Object", 786 | // "jaxId": "1HI79NVUQ16", 787 | // "editVersion": 0, 788 | // "attrs": {} 789 | // }, 790 | // "desc": "这是一个AISeg。", 791 | // "codes": "true", 792 | // "mkpInput": "$$input$$", 793 | // "role": "Assistant", 794 | // "text": "#input", 795 | // "outlet": { 796 | // "type": "aioutlet", 797 | // "def": "AISegOutlet", 798 | // "jaxId": "1HI79NVUM13", 799 | // "editVersion": 104, 800 | // "attrs": { 801 | // "id": "Result", 802 | // "desc": "输出节点。" 803 | // }, 804 | // "linkedSeg": "1HI79NVUR0" 805 | // } 806 | // } 807 | // }, 808 | // { 809 | // "type": "aiseg", 810 | // "def": "aiBot", 811 | // "jaxId": "1HI79NVUM14", 812 | // "editVersion": 184, 813 | // "attrs": { 814 | // "id": "ExportStory", 815 | // "label": "New AI Seg", 816 | // "x": "1780", 817 | // "y": "660", 818 | // "context": { 819 | // "type": "object", 820 | // "def": "Object", 821 | // "jaxId": "1HI79NVUR1", 822 | // "editVersion": 0, 823 | // "attrs": {} 824 | // }, 825 | // "global": { 826 | // "type": "object", 827 | // "def": "Object", 828 | // "jaxId": "1HI79NVUR2", 829 | // "editVersion": 0, 830 | // "attrs": {} 831 | // }, 832 | // "desc": "调用其它AI Agent,把调用的结果作为输出", 833 | // "codes": "false", 834 | // "mkpInput": "$$input$$", 835 | // "source": "ai/ExportStory.js", 836 | // "secret": "false", 837 | // "outlet": { 838 | // "type": "aioutlet", 839 | // "def": "AISegOutlet", 840 | // "jaxId": "1HI79NVUM15", 841 | // "editVersion": 70, 842 | // "attrs": { 843 | // "id": "Result", 844 | // "desc": "输出节点。" 845 | // }, 846 | // "linkedSeg": "1HIBJCD5K0" 847 | // } 848 | // } 849 | // }, 850 | // { 851 | // "type": "aiseg", 852 | // "def": "connector", 853 | // "jaxId": "1HI79NVUQ14", 854 | // "editVersion": 87, 855 | // "attrs": { 856 | // "id": "", 857 | // "label": "New AI Seg", 858 | // "x": "1660", 859 | // "y": "270", 860 | // "outlet": { 861 | // "type": "aioutlet", 862 | // "def": "AISegOutlet", 863 | // "jaxId": "1HI79NVUR4", 864 | // "editVersion": 74, 865 | // "attrs": { 866 | // "id": "Outlet", 867 | // "desc": "输出节点。" 868 | // }, 869 | // "linkedSeg": "1HI79NVUR5" 870 | // }, 871 | // "dir": "R2L" 872 | // } 873 | // }, 874 | // { 875 | // "type": "aiseg", 876 | // "def": "connector", 877 | // "jaxId": "1HI79NVUR5", 878 | // "editVersion": 91, 879 | // "attrs": { 880 | // "id": "", 881 | // "label": "New AI Seg", 882 | // "x": "1030", 883 | // "y": "270", 884 | // "outlet": { 885 | // "type": "aioutlet", 886 | // "def": "AISegOutlet", 887 | // "jaxId": "1HI79NVUR6", 888 | // "editVersion": 74, 889 | // "attrs": { 890 | // "id": "Outlet", 891 | // "desc": "输出节点。" 892 | // }, 893 | // "linkedSeg": "1HI79NVUM4" 894 | // }, 895 | // "dir": "R2L" 896 | // } 897 | // }, 898 | // { 899 | // "type": "aiseg", 900 | // "def": "connectorT", 901 | // "jaxId": "1HI79NVUR0", 902 | // "editVersion": 123, 903 | // "attrs": { 904 | // "id": "", 905 | // "label": "New AI Seg", 906 | // "x": "2050", 907 | // "y": "620", 908 | // "outlet": { 909 | // "type": "aioutlet", 910 | // "def": "AISegOutlet", 911 | // "jaxId": "1HI79NVUR7", 912 | // "editVersion": 104, 913 | // "attrs": { 914 | // "id": "Outlet", 915 | // "desc": "输出节点。" 916 | // }, 917 | // "linkedSeg": "1HIBJCD5K0" 918 | // }, 919 | // "dir": "T2B" 920 | // } 921 | // }, 922 | // { 923 | // "type": "aiseg", 924 | // "def": "connector", 925 | // "jaxId": "1HI79NVUR3", 926 | // "editVersion": 127, 927 | // "attrs": { 928 | // "id": "", 929 | // "label": "New AI Seg", 930 | // "x": "1940", 931 | // "y": "810", 932 | // "outlet": { 933 | // "type": "aioutlet", 934 | // "def": "AISegOutlet", 935 | // "jaxId": "1HI79NVUR8", 936 | // "editVersion": 116, 937 | // "attrs": { 938 | // "id": "Outlet", 939 | // "desc": "输出节点。" 940 | // }, 941 | // "linkedSeg": "1HI79NVUR9" 942 | // }, 943 | // "dir": "R2L" 944 | // } 945 | // }, 946 | // { 947 | // "type": "aiseg", 948 | // "def": "connector", 949 | // "jaxId": "1HI79NVUR9", 950 | // "editVersion": 123, 951 | // "attrs": { 952 | // "id": "", 953 | // "label": "New AI Seg", 954 | // "x": "1360", 955 | // "y": "810", 956 | // "outlet": { 957 | // "type": "aioutlet", 958 | // "def": "AISegOutlet", 959 | // "jaxId": "1HI79NVUR10", 960 | // "editVersion": 116, 961 | // "attrs": { 962 | // "id": "Outlet", 963 | // "desc": "输出节点。" 964 | // }, 965 | // "linkedSeg": "1HI79NVUR11" 966 | // }, 967 | // "dir": "R2L" 968 | // } 969 | // }, 970 | // { 971 | // "type": "aiseg", 972 | // "def": "connectorB", 973 | // "jaxId": "1HI79NVUR11", 974 | // "editVersion": 111, 975 | // "attrs": { 976 | // "id": "", 977 | // "label": "New AI Seg", 978 | // "x": "1210", 979 | // "y": "730", 980 | // "outlet": { 981 | // "type": "aioutlet", 982 | // "def": "AISegOutlet", 983 | // "jaxId": "1HI79NVUR12", 984 | // "editVersion": 116, 985 | // "attrs": { 986 | // "id": "Outlet", 987 | // "desc": "输出节点。" 988 | // }, 989 | // "linkedSeg": "1HIBJ7OVI0" 990 | // }, 991 | // "dir": "B2T" 992 | // } 993 | // }, 994 | // { 995 | // "type": "aiseg", 996 | // "def": "aiBot", 997 | // "jaxId": "1HI7D5NNL1", 998 | // "editVersion": 164, 999 | // "attrs": { 1000 | // "id": "EditStory", 1001 | // "label": "New AI Seg", 1002 | // "x": "1830", 1003 | // "y": "600", 1004 | // "context": { 1005 | // "type": "object", 1006 | // "def": "Object", 1007 | // "jaxId": "1HI7D5NNO0", 1008 | // "editVersion": 0, 1009 | // "attrs": {} 1010 | // }, 1011 | // "global": { 1012 | // "type": "object", 1013 | // "def": "Object", 1014 | // "jaxId": "1HI7D5NNO1", 1015 | // "editVersion": 0, 1016 | // "attrs": {} 1017 | // }, 1018 | // "desc": "调用其它AI Agent,把调用的结果作为输出", 1019 | // "codes": "false", 1020 | // "mkpInput": "$$input$$", 1021 | // "source": "ai/EditStory.js", 1022 | // "secret": "false", 1023 | // "outlet": { 1024 | // "type": "aioutlet", 1025 | // "def": "AISegOutlet", 1026 | // "jaxId": "1HI7D5NNL2", 1027 | // "editVersion": 81, 1028 | // "attrs": { 1029 | // "id": "Result", 1030 | // "desc": "输出节点。" 1031 | // }, 1032 | // "linkedSeg": "1HI79NVUR3" 1033 | // } 1034 | // } 1035 | // }, 1036 | // { 1037 | // "type": "aiseg", 1038 | // "def": "connectorL", 1039 | // "jaxId": "1HI9B1M0J0", 1040 | // "editVersion": 62, 1041 | // "attrs": { 1042 | // "id": "", 1043 | // "label": "New AI Seg", 1044 | // "x": "740", 1045 | // "y": "440", 1046 | // "outlet": { 1047 | // "type": "aioutlet", 1048 | // "def": "AISegOutlet", 1049 | // "jaxId": "1HI9B1M0J1", 1050 | // "editVersion": 59, 1051 | // "attrs": { 1052 | // "id": "Outlet", 1053 | // "desc": "输出节点。" 1054 | // }, 1055 | // "linkedSeg": "1HI9B1M0J2" 1056 | // }, 1057 | // "dir": "L2R" 1058 | // } 1059 | // }, 1060 | // { 1061 | // "type": "aiseg", 1062 | // "def": "connectorL", 1063 | // "jaxId": "1HI9B1M0J2", 1064 | // "editVersion": 66, 1065 | // "attrs": { 1066 | // "id": "", 1067 | // "label": "New AI Seg", 1068 | // "x": "1630", 1069 | // "y": "440", 1070 | // "outlet": { 1071 | // "type": "aioutlet", 1072 | // "def": "AISegOutlet", 1073 | // "jaxId": "1HI9B1M0J3", 1074 | // "editVersion": 59, 1075 | // "attrs": { 1076 | // "id": "Outlet", 1077 | // "desc": "输出节点。" 1078 | // }, 1079 | // "linkedSeg": "1HI79NVUM12" 1080 | // }, 1081 | // "dir": "L2R" 1082 | // } 1083 | // }, 1084 | // { 1085 | // "type": "aiseg", 1086 | // "def": "save", 1087 | // "jaxId": "1HIBJ7OVI0", 1088 | // "editVersion": 179, 1089 | // "attrs": { 1090 | // "id": "SaveEdit", 1091 | // "label": "New AI Seg", 1092 | // "x": "1280", 1093 | // "y": "560", 1094 | // "context": { 1095 | // "type": "object", 1096 | // "def": "Object", 1097 | // "jaxId": "1HIBJ7OVI1", 1098 | // "editVersion": 0, 1099 | // "attrs": {} 1100 | // }, 1101 | // "global": { 1102 | // "type": "object", 1103 | // "def": "Object", 1104 | // "jaxId": "1HIBJ7OVI2", 1105 | // "editVersion": 0, 1106 | // "attrs": {} 1107 | // }, 1108 | // "desc": "这是一个AISeg。", 1109 | // "codes": "true", 1110 | // "mkpInput": "$$input$$", 1111 | // "fileName": "#`/doc/story_${globalContext.StoryTitle}.json`", 1112 | // "saveContext": { 1113 | // "type": "array", 1114 | // "def": "StringArray", 1115 | // "attrs": [] 1116 | // }, 1117 | // "outlet": { 1118 | // "type": "aioutlet", 1119 | // "def": "AISegOutlet", 1120 | // "jaxId": "1HIBJ7OVJ0", 1121 | // "editVersion": 83, 1122 | // "attrs": { 1123 | // "id": "Result", 1124 | // "desc": "输出节点。" 1125 | // }, 1126 | // "linkedSeg": "1HI79NVUM11" 1127 | // } 1128 | // } 1129 | // }, 1130 | // { 1131 | // "type": "aiseg", 1132 | // "def": "connector", 1133 | // "jaxId": "1HIBJCD5K0", 1134 | // "editVersion": 25, 1135 | // "attrs": { 1136 | // "id": "", 1137 | // "label": "New AI Seg", 1138 | // "x": "1930", 1139 | // "y": "740", 1140 | // "outlet": { 1141 | // "type": "aioutlet", 1142 | // "def": "AISegOutlet", 1143 | // "jaxId": "1HIBJCD5K1", 1144 | // "editVersion": 14, 1145 | // "attrs": { 1146 | // "id": "Outlet", 1147 | // "desc": "输出节点。" 1148 | // }, 1149 | // "linkedSeg": "1HIBJCD5K2" 1150 | // }, 1151 | // "dir": "R2L" 1152 | // } 1153 | // }, 1154 | // { 1155 | // "type": "aiseg", 1156 | // "def": "connector", 1157 | // "jaxId": "1HIBJCD5K2", 1158 | // "editVersion": 25, 1159 | // "attrs": { 1160 | // "id": "", 1161 | // "label": "New AI Seg", 1162 | // "x": "1540", 1163 | // "y": "740", 1164 | // "outlet": { 1165 | // "type": "aioutlet", 1166 | // "def": "AISegOutlet", 1167 | // "jaxId": "1HIBJCD5K3", 1168 | // "editVersion": 14, 1169 | // "attrs": { 1170 | // "id": "Outlet", 1171 | // "desc": "输出节点。" 1172 | // }, 1173 | // "linkedSeg": "1HI79NVUM11" 1174 | // }, 1175 | // "dir": "R2L" 1176 | // } 1177 | // } 1178 | // ] 1179 | // }, 1180 | // "entry": "", 1181 | // "autoStart": "true", 1182 | // "debug": "true", 1183 | // "localVars": { 1184 | // "type": "object", 1185 | // "def": "Object", 1186 | // "jaxId": "1HDBOSUNA2", 1187 | // "editVersion": 0, 1188 | // "attrs": {} 1189 | // }, 1190 | // "context": { 1191 | // "type": "object", 1192 | // "def": "Object", 1193 | // "jaxId": "1HDBOSUNA3", 1194 | // "editVersion": 14, 1195 | // "attrs": {} 1196 | // }, 1197 | // "globalMockup": { 1198 | // "type": "object", 1199 | // "def": "Object", 1200 | // "jaxId": "1HDIJB7SK6", 1201 | // "editVersion": 4, 1202 | // "attrs": { 1203 | // "memory": { 1204 | // "type": "string", 1205 | // "valText": "" 1206 | // } 1207 | // } 1208 | // }, 1209 | // "desc": "This is an AI Agent that use message compress to keep memory about chats.", 1210 | // "exportAPI": "false", 1211 | // "apiArgs": { 1212 | // "type": "object", 1213 | // "def": "Object", 1214 | // "jaxId": "1HI79NVUR13", 1215 | // "editVersion": 0, 1216 | // "attrs": {} 1217 | // } 1218 | // } 1219 | //} --------------------------------------------------------------------------------