@tomflow/chatloop-tools 0.9.16 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +4 -0
- package/lib/gateway.mjs +15 -3
- package/lib/mcp-tool-router.mjs +50 -3
- package/node_modules/@tomflow/chatloop-context/README.md +240 -0
- package/node_modules/@tomflow/chatloop-context/bin/cli.mjs +48 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/approval.mjs +151 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/context.mjs +376 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/document.mjs +266 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/evidence.mjs +134 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/presentation.mjs +82 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/project.mjs +349 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/sdk.mjs +72 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/start.mjs +73 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/task.mjs +507 -0
- package/node_modules/@tomflow/chatloop-context/capabilities.generated.mjs +11 -0
- package/node_modules/@tomflow/chatloop-context/docs/interfaces.md +182 -0
- package/node_modules/@tomflow/chatloop-context/docs/operator-and-migration.md +277 -0
- package/node_modules/@tomflow/chatloop-context/index.mjs +233 -0
- package/node_modules/@tomflow/chatloop-context/lib/api-log.mjs +86 -0
- package/node_modules/@tomflow/chatloop-context/lib/approval-policy.mjs +24 -0
- package/node_modules/@tomflow/chatloop-context/lib/capability-catalog.generated.json +1989 -0
- package/node_modules/@tomflow/chatloop-context/lib/capability-router.mjs +67 -0
- package/node_modules/@tomflow/chatloop-context/lib/cli-commands.mjs +280 -0
- package/node_modules/@tomflow/chatloop-context/lib/context-cli.mjs +298 -0
- package/node_modules/@tomflow/chatloop-context/lib/context-migration.mjs +280 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/context.mjs +115 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/evidence.mjs +51 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/health.mjs +55 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/migration.mjs +262 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/project.mjs +246 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/review.mjs +147 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/run.mjs +343 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/store.mjs +391 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/task.mjs +166 -0
- package/node_modules/@tomflow/chatloop-context/lib/line-review.mjs +13 -0
- package/node_modules/@tomflow/chatloop-context/lib/methods.mjs +111 -0
- package/node_modules/@tomflow/chatloop-context/lib/operations.mjs +107 -0
- package/node_modules/@tomflow/chatloop-context/lib/orphan-operator.mjs +117 -0
- package/node_modules/@tomflow/chatloop-context/lib/process-inventory.mjs +20 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-branch.mjs +312 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-diagnostic.mjs +153 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-guards.mjs +19 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-store.mjs +115 -0
- package/node_modules/@tomflow/chatloop-context/lib/trusted-run.mjs +86 -0
- package/node_modules/@tomflow/chatloop-context/lib/workspace-operator.mjs +169 -0
- package/node_modules/@tomflow/chatloop-context/package.json +40 -0
- package/node_modules/@tomflow/chatloop-context/scripts/build-capabilities.mjs +114 -0
- package/node_modules/@tomflow/chatloop-extension/README.md +94 -0
- package/node_modules/@tomflow/chatloop-extension/actions.generated.mjs +11 -0
- package/node_modules/@tomflow/chatloop-extension/bin/cli.mjs +141 -0
- package/node_modules/@tomflow/chatloop-extension/bin/native-host.mjs +109 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_dom.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_screenshot.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_text.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/clean.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/continue.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/handoff.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/reload.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/start.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/status.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/clean.js +120 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/common.js +180 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/continue.js +322 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/dom.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/handoff.js +378 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/index.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/model-intent.js +54 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/read-mode.js +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/reload.js +20 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/screenshot.js +69 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/start.js +287 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/status.js +23 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/text.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/background.js +16 -0
- package/node_modules/@tomflow/chatloop-extension/extension/clean.html +5 -0
- package/node_modules/@tomflow/chatloop-extension/extension/content.js +40 -0
- package/node_modules/@tomflow/chatloop-extension/extension/continue.html +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/dom.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/handoff.html +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/action-catalog.generated.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-aspect.generated.js +275 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-observation-queue.generated.js +76 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/core.js +107 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/index.js +36 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-approval.js +227 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-inspect.js +144 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-poll.js +171 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-recovery.js +109 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer.js +154 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/resources.js +254 -0
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +42 -0
- package/node_modules/@tomflow/chatloop-extension/extension/popup.html +25 -0
- package/node_modules/@tomflow/chatloop-extension/extension/popup.js +93 -0
- package/node_modules/@tomflow/chatloop-extension/extension/reload.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/screenshot.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/start.html +6 -0
- package/node_modules/@tomflow/chatloop-extension/extension/status.html +6 -0
- package/node_modules/@tomflow/chatloop-extension/extension/text.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-result.js +136 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-take.js +220 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/admission.js +122 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +155 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-recovery.js +185 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-result.js +120 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/bootstrap.js +172 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/manual.js +165 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/readiness.js +244 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/router.js +181 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/scheduler.js +147 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-failure.js +197 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-finished.js +200 -0
- package/node_modules/@tomflow/chatloop-extension/index.mjs +71 -0
- package/node_modules/@tomflow/chatloop-extension/lib/action-routing.mjs +18 -0
- package/node_modules/@tomflow/chatloop-extension/lib/api-observation-queue.mjs +74 -0
- package/node_modules/@tomflow/chatloop-extension/lib/bridge.mjs +208 -0
- package/node_modules/@tomflow/chatloop-extension/lib/browser-launch.mjs +40 -0
- package/node_modules/@tomflow/chatloop-extension/lib/context-binding.mjs +45 -0
- package/node_modules/@tomflow/chatloop-extension/lib/context-ipc.mjs +111 -0
- package/node_modules/@tomflow/chatloop-extension/lib/owner-evidence.mjs +67 -0
- package/node_modules/@tomflow/chatloop-extension/lib/session-file.mjs +120 -0
- package/node_modules/@tomflow/chatloop-extension/package.json +38 -0
- package/node_modules/@tomflow/chatloop-extension/scripts/build-actions.mjs +133 -0
- package/node_modules/@tomflow/chatloop-trace/README.md +105 -0
- package/node_modules/@tomflow/chatloop-trace/events/context.api.mjs +23 -0
- package/node_modules/@tomflow/chatloop-trace/events/typed.api.call.mjs +22 -0
- package/node_modules/@tomflow/chatloop-trace/events.generated.mjs +4 -0
- package/node_modules/@tomflow/chatloop-trace/index.mjs +59 -0
- package/node_modules/@tomflow/chatloop-trace/lib/api-aspect.mjs +273 -0
- package/node_modules/@tomflow/chatloop-trace/lib/trace-reader.mjs +265 -0
- package/node_modules/@tomflow/chatloop-trace/lib/trace.mjs +205 -0
- package/node_modules/@tomflow/chatloop-trace/package.json +30 -0
- package/node_modules/@tomflow/chatloop-trace/scripts/build-events.mjs +68 -0
- package/node_modules/ps-list/index.d.ts +76 -0
- package/node_modules/ps-list/index.js +366 -0
- package/node_modules/ps-list/license +9 -0
- package/node_modules/ps-list/package.json +44 -0
- package/node_modules/ps-list/readme.md +56 -0
- package/node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe +0 -0
- package/node_modules/ps-list/vendor/fastlist-0.3.0-x86.exe +0 -0
- package/package.json +23 -8
- package/providers/form.mjs +68 -8
- package/scripts/build-form-app.mjs +27 -0
- package/ui/form/review-app.js +128 -0
- package/ui/form/review.html +859 -0
- package/ui/form/review.template.html +45 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Deterministic, self-contained MCP App HTML artifact. SDK is build-only.
|
|
2
|
+
import {build} from 'esbuild';
|
|
3
|
+
import {readFileSync,writeFileSync} from 'node:fs';
|
|
4
|
+
import {dirname,join} from 'node:path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
const base=dirname(dirname(fileURLToPath(import.meta.url)));
|
|
7
|
+
const template=readFileSync(join(base,'ui/form/review.template.html'),'utf8');
|
|
8
|
+
const result=await build({
|
|
9
|
+
entryPoints:[join(base,'ui/form/review-app.js')],
|
|
10
|
+
bundle:true,platform:'browser',format:'iife',target:'es2022',
|
|
11
|
+
minify:true,write:false,legalComments:'none',
|
|
12
|
+
logLevel:'silent'
|
|
13
|
+
});
|
|
14
|
+
if(result.outputFiles.length!==1)throw Error('FORM_BUNDLE_INVALID');
|
|
15
|
+
const script=result.outputFiles[0].text.replace(/<\/script/gi,'<\\/script');
|
|
16
|
+
const token='<!-- CHAT_LOOP_FORM_SCRIPT -->';
|
|
17
|
+
if(template.split(token).length!==2)throw Error('FORM_TEMPLATE_INVALID');
|
|
18
|
+
const rendered=template.replace(token,'<script>'+script+'</script>');
|
|
19
|
+
const path=join(base,'ui/form/review.html');
|
|
20
|
+
if(process.argv.includes('--check')){
|
|
21
|
+
let actual;try{actual=readFileSync(path,'utf8')}catch{}
|
|
22
|
+
if(actual!==rendered)throw Error('FORM_APP_BUILD_STALE');
|
|
23
|
+
console.log('MCP_FORM_APP_CURRENT bytes='+Buffer.byteLength(rendered));
|
|
24
|
+
}else{
|
|
25
|
+
writeFileSync(path,rendered);
|
|
26
|
+
console.log('MCP_FORM_APP_BUILT bytes='+Buffer.byteLength(rendered));
|
|
27
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {App} from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
|
|
3
|
+
// A host-connected MCP App, not a standalone approval authority.
|
|
4
|
+
// Only TEST_ONLY/GENERAL submits are enabled until real user Turn proof exists.
|
|
5
|
+
const app=new App({name:'Chat Loop Review',version:'1.0.0'});
|
|
6
|
+
const $=id=>document.getElementById(id);
|
|
7
|
+
const radios=[...document.querySelectorAll('input[name="choice"]')];
|
|
8
|
+
let prepared=null,toolInput=null,locked=false;
|
|
9
|
+
const idPattern=/^[A-Za-z0-9_-]{8,80}$/;
|
|
10
|
+
function status(message,state='info'){
|
|
11
|
+
$('status').textContent=message;
|
|
12
|
+
$('status').dataset.state=state;
|
|
13
|
+
}
|
|
14
|
+
function decode(result){
|
|
15
|
+
if(result?.isError)throw Error('FORM_TOOL_REJECTED');
|
|
16
|
+
if(result?.structuredContent?.status)return result.structuredContent;
|
|
17
|
+
const text=result?.content?.find(x=>x.type==='text')?.text;
|
|
18
|
+
if(typeof text!=='string'||text.length>20000)throw Error('FORM_RECEIPT_MISSING');
|
|
19
|
+
return JSON.parse(text);
|
|
20
|
+
}
|
|
21
|
+
function selected(){return radios.find(x=>x.checked)?.value||null}
|
|
22
|
+
function update(){
|
|
23
|
+
const choice=selected();
|
|
24
|
+
$('modify').hidden=choice!=='B';
|
|
25
|
+
const enabled=Boolean(prepared)&&!locked&&choice
|
|
26
|
+
&&(choice!=='B'||$('comment').value.trim());
|
|
27
|
+
$('submit').disabled=!enabled;
|
|
28
|
+
}
|
|
29
|
+
function render(value){
|
|
30
|
+
const view=value?.view;
|
|
31
|
+
if(!view||view.template!=='chat-loop-review-card-v1'
|
|
32
|
+
||!idPattern.test(value.formId||'')
|
|
33
|
+
||view.formId!==value.formId
|
|
34
|
+
||!['GENERAL','TEST_ONLY','MANAGED'].includes(view.mode)
|
|
35
|
+
||view.options?.length!==2||view.options[0]?.value!=='A'
|
|
36
|
+
||view.options[1]?.value!=='B')
|
|
37
|
+
throw Error('FORM_VIEW_INVALID');
|
|
38
|
+
const safeMode=view.mode==='TEST_ONLY'||view.mode==='GENERAL';
|
|
39
|
+
prepared={...value,mode:view.mode};
|
|
40
|
+
$('title').textContent=view.title;
|
|
41
|
+
$('description').textContent=view.description;
|
|
42
|
+
$('a-label').textContent=view.options[0].label;
|
|
43
|
+
$('b-label').textContent=view.options[1].label;
|
|
44
|
+
$('comment').placeholder=view.modifyField?.placeholder||'填写修改意见';
|
|
45
|
+
$('submit').textContent=view.submit?.label||'提交';
|
|
46
|
+
$('footer').textContent=view.footer||'';
|
|
47
|
+
$('options').disabled=!safeMode;
|
|
48
|
+
radios.forEach(x=>{x.checked=false});
|
|
49
|
+
$('comment').value='';
|
|
50
|
+
locked=!safeMode;
|
|
51
|
+
status(safeMode?'已连接 Form prepare;请选择 A 或 B。'
|
|
52
|
+
:'正式审批需要宿主真实用户消息身份,目前禁止从组件直接代签。',safeMode?'ok':'error');
|
|
53
|
+
update();
|
|
54
|
+
}
|
|
55
|
+
app.ontoolinput=params=>{
|
|
56
|
+
if(params?.arguments&&typeof params.arguments==='object')
|
|
57
|
+
toolInput=params.arguments;
|
|
58
|
+
};
|
|
59
|
+
app.ontoolresult=result=>{
|
|
60
|
+
try{
|
|
61
|
+
const value=decode(result);
|
|
62
|
+
if(['TEST_ONLY_PREVIEW','FORM_PREPARED_SOFT','WAITING_APPROVAL'].includes(value.status))
|
|
63
|
+
render(value);
|
|
64
|
+
else status('工具返回的不是 prepare 回执。','error');
|
|
65
|
+
}catch{status('Form prepare 回执无效,禁止提交。','error')}
|
|
66
|
+
};
|
|
67
|
+
async function submit(){
|
|
68
|
+
if(locked||!prepared||!['GENERAL','TEST_ONLY'].includes(prepared.mode))return;
|
|
69
|
+
const choice=selected();
|
|
70
|
+
const comment=$('comment').value.trim();
|
|
71
|
+
if(!['A','B'].includes(choice)||choice==='B'&&!comment)return;
|
|
72
|
+
// Freeze the unique request before any asynchronous host call.
|
|
73
|
+
locked=true;update();
|
|
74
|
+
const formId=prepared.formId,mode=prepared.mode;
|
|
75
|
+
const requestId=crypto.randomUUID();
|
|
76
|
+
const scope={mode,formId,choice,kind:prepared.kind,
|
|
77
|
+
...(choice==='B'?{comment}:{}),
|
|
78
|
+
userTurn:'unverified-app-'+requestId,
|
|
79
|
+
presentedAssistantRef:'app-form-'+formId,
|
|
80
|
+
writeRequestId:requestId,
|
|
81
|
+
...(mode==='TEST_ONLY'?{
|
|
82
|
+
projectId:prepared.projectId,
|
|
83
|
+
chatRef:prepared.chatRef,
|
|
84
|
+
kind:prepared.kind,
|
|
85
|
+
documentId:prepared.documentId,
|
|
86
|
+
version:prepared.version
|
|
87
|
+
}:{})};
|
|
88
|
+
status('正在向 Form submit 发送唯一请求…');
|
|
89
|
+
let receipt;
|
|
90
|
+
try{
|
|
91
|
+
receipt=decode(await app.callServerTool({
|
|
92
|
+
name:'chat_loop_form__submit',arguments:scope
|
|
93
|
+
}));
|
|
94
|
+
}catch{
|
|
95
|
+
status('Form submit 结果未知。为防止重复提交,表单已锁定;请查原请求回执。','error');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if(receipt.status!=='FORM_SUBMISSION_OBSERVED_SOFT'
|
|
99
|
+
||receipt.formId!==formId||receipt.choice!==choice
|
|
100
|
+
||receipt.preparedFormIdVerified!==true){
|
|
101
|
+
status('Form submit 未验证准备记录;未发送用户消息。','error');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const version=prepared.documentId
|
|
105
|
+
?prepared.documentId+' v'+prepared.version
|
|
106
|
+
:'自定义表单';
|
|
107
|
+
const message='【Chat Loop Form|'+mode+'】formId='+formId+'|'
|
|
108
|
+
+version+'|'+(choice==='A'?'A 确认':'B 修改:'+comment)
|
|
109
|
+
+'。此消息来自组件请求;请独立核对真实用户 Turn 身份。'
|
|
110
|
+
+(mode==='TEST_ONLY'?'不批准正式业务,不 Start/Continue/Handoff。':'');
|
|
111
|
+
status('Form submit 软回执已收到,正在请求宿主发送一次用户消息…');
|
|
112
|
+
try{
|
|
113
|
+
const sent=await app.sendMessage({
|
|
114
|
+
role:'user',content:[{type:'text',text:message}]
|
|
115
|
+
});
|
|
116
|
+
if(sent?.isError){
|
|
117
|
+
status('宿主拒绝用户消息;Form 仅有软提交记录,未批准。','error');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
status('宿主已接受一次消息请求;实际 userMessageId 与日志关联仍需独立核验。','ok');
|
|
121
|
+
}catch{
|
|
122
|
+
status('宿主消息回执未知,禁止重复发送。Form 仅有软提交记录。','error');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
radios.forEach(x=>x.addEventListener('change',update));
|
|
126
|
+
$('comment').addEventListener('input',update);
|
|
127
|
+
$('submit').addEventListener('click',submit);
|
|
128
|
+
app.connect().catch(()=>status('MCP Apps 宿主连接失败,不能提交。','error'));
|