@tomflow/chatloop-tools 0.9.63 → 0.9.64
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/README.md +13 -1
- package/index.mjs +7 -7
- package/lib/context-control-run.mjs +23 -5
- package/lib/extension-proxy.mjs +16 -7
- package/lib/native-owner-v2.mjs +128 -0
- package/lib/release-health-checks.mjs +29 -5
- package/lib/trace-gateway.mjs +3 -1
- package/package.json +2 -12
- package/providers/extension.mjs +59 -16
- package/node_modules/@tomflow/chatloop-context/README.md +0 -240
- package/node_modules/@tomflow/chatloop-context/bin/cli.mjs +0 -48
- package/node_modules/@tomflow/chatloop-context/capabilities/approval.mjs +0 -151
- package/node_modules/@tomflow/chatloop-context/capabilities/context.mjs +0 -376
- package/node_modules/@tomflow/chatloop-context/capabilities/document.mjs +0 -266
- package/node_modules/@tomflow/chatloop-context/capabilities/evidence.mjs +0 -134
- package/node_modules/@tomflow/chatloop-context/capabilities/presentation.mjs +0 -82
- package/node_modules/@tomflow/chatloop-context/capabilities/project.mjs +0 -349
- package/node_modules/@tomflow/chatloop-context/capabilities/sdk.mjs +0 -72
- package/node_modules/@tomflow/chatloop-context/capabilities/start.mjs +0 -73
- package/node_modules/@tomflow/chatloop-context/capabilities/task.mjs +0 -507
- package/node_modules/@tomflow/chatloop-context/capabilities.generated.mjs +0 -11
- package/node_modules/@tomflow/chatloop-context/docs/interfaces.md +0 -192
- package/node_modules/@tomflow/chatloop-context/docs/operator-and-migration.md +0 -277
- package/node_modules/@tomflow/chatloop-context/index.mjs +0 -236
- package/node_modules/@tomflow/chatloop-context/lib/api-log.mjs +0 -86
- package/node_modules/@tomflow/chatloop-context/lib/approval-policy.mjs +0 -77
- package/node_modules/@tomflow/chatloop-context/lib/capability-catalog.generated.json +0 -1989
- package/node_modules/@tomflow/chatloop-context/lib/capability-router.mjs +0 -69
- package/node_modules/@tomflow/chatloop-context/lib/cli-commands.mjs +0 -285
- package/node_modules/@tomflow/chatloop-context/lib/context-cli.mjs +0 -298
- package/node_modules/@tomflow/chatloop-context/lib/context-migration.mjs +0 -286
- package/node_modules/@tomflow/chatloop-context/lib/core/context.mjs +0 -115
- package/node_modules/@tomflow/chatloop-context/lib/core/evidence.mjs +0 -51
- package/node_modules/@tomflow/chatloop-context/lib/core/health.mjs +0 -75
- package/node_modules/@tomflow/chatloop-context/lib/core/migration.mjs +0 -262
- package/node_modules/@tomflow/chatloop-context/lib/core/project.mjs +0 -246
- package/node_modules/@tomflow/chatloop-context/lib/core/review.mjs +0 -147
- package/node_modules/@tomflow/chatloop-context/lib/core/run-cancel.mjs +0 -54
- package/node_modules/@tomflow/chatloop-context/lib/core/run.mjs +0 -375
- package/node_modules/@tomflow/chatloop-context/lib/core/store.mjs +0 -397
- package/node_modules/@tomflow/chatloop-context/lib/core/task.mjs +0 -183
- package/node_modules/@tomflow/chatloop-context/lib/line-review.mjs +0 -13
- package/node_modules/@tomflow/chatloop-context/lib/methods.mjs +0 -111
- package/node_modules/@tomflow/chatloop-context/lib/operations.mjs +0 -107
- package/node_modules/@tomflow/chatloop-context/lib/orphan-operator.mjs +0 -118
- package/node_modules/@tomflow/chatloop-context/lib/process-inventory.mjs +0 -20
- package/node_modules/@tomflow/chatloop-context/lib/project-branch.mjs +0 -316
- package/node_modules/@tomflow/chatloop-context/lib/project-diagnostic.mjs +0 -153
- package/node_modules/@tomflow/chatloop-context/lib/project-guards.mjs +0 -19
- package/node_modules/@tomflow/chatloop-context/lib/project-store.mjs +0 -117
- package/node_modules/@tomflow/chatloop-context/lib/trusted-run.mjs +0 -97
- package/node_modules/@tomflow/chatloop-context/lib/workspace-operator.mjs +0 -169
- package/node_modules/@tomflow/chatloop-context/package.json +0 -40
- package/node_modules/@tomflow/chatloop-context/scripts/build-capabilities.mjs +0 -114
- package/node_modules/@tomflow/chatloop-extension/README.md +0 -124
- package/node_modules/@tomflow/chatloop-extension/actions.generated.mjs +0 -13
- package/node_modules/@tomflow/chatloop-extension/bin/cli.mjs +0 -153
- package/node_modules/@tomflow/chatloop-extension/bin/native-host.mjs +0 -207
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_dom.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_screenshot.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_text.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/clean.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/continue.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/entry_test.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/handoff.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/reload.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/session.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/start.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/capabilities/status.mjs +0 -1
- package/node_modules/@tomflow/chatloop-extension/extension/actions/clean.js +0 -123
- package/node_modules/@tomflow/chatloop-extension/extension/actions/common.js +0 -183
- package/node_modules/@tomflow/chatloop-extension/extension/actions/continue.js +0 -340
- package/node_modules/@tomflow/chatloop-extension/extension/actions/dom.js +0 -2
- package/node_modules/@tomflow/chatloop-extension/extension/actions/entry_test.js +0 -241
- package/node_modules/@tomflow/chatloop-extension/extension/actions/handoff.js +0 -393
- package/node_modules/@tomflow/chatloop-extension/extension/actions/index.js +0 -2
- package/node_modules/@tomflow/chatloop-extension/extension/actions/model-intent.js +0 -56
- package/node_modules/@tomflow/chatloop-extension/extension/actions/read-mode.js +0 -9
- package/node_modules/@tomflow/chatloop-extension/extension/actions/reload.js +0 -20
- package/node_modules/@tomflow/chatloop-extension/extension/actions/screenshot.js +0 -77
- package/node_modules/@tomflow/chatloop-extension/extension/actions/session.js +0 -52
- package/node_modules/@tomflow/chatloop-extension/extension/actions/start.js +0 -295
- package/node_modules/@tomflow/chatloop-extension/extension/actions/status.js +0 -24
- package/node_modules/@tomflow/chatloop-extension/extension/actions/text.js +0 -2
- package/node_modules/@tomflow/chatloop-extension/extension/background.js +0 -17
- package/node_modules/@tomflow/chatloop-extension/extension/clean.html +0 -5
- package/node_modules/@tomflow/chatloop-extension/extension/content.js +0 -40
- package/node_modules/@tomflow/chatloop-extension/extension/continue.html +0 -9
- package/node_modules/@tomflow/chatloop-extension/extension/dom.html +0 -17
- package/node_modules/@tomflow/chatloop-extension/extension/entry_test.html +0 -6
- package/node_modules/@tomflow/chatloop-extension/extension/handoff.html +0 -9
- package/node_modules/@tomflow/chatloop-extension/extension/loop/action-catalog.generated.js +0 -2
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-aspect.generated.js +0 -275
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-observation-queue.generated.js +0 -84
- package/node_modules/@tomflow/chatloop-extension/extension/loop/core.js +0 -107
- package/node_modules/@tomflow/chatloop-extension/extension/loop/index.js +0 -36
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-approval.js +0 -299
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-inspect.js +0 -144
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-poll.js +0 -171
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-recovery.js +0 -109
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer.js +0 -154
- package/node_modules/@tomflow/chatloop-extension/extension/loop/resources.js +0 -259
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +0 -42
- package/node_modules/@tomflow/chatloop-extension/extension/popup.html +0 -25
- package/node_modules/@tomflow/chatloop-extension/extension/popup.js +0 -99
- package/node_modules/@tomflow/chatloop-extension/extension/reload.html +0 -17
- package/node_modules/@tomflow/chatloop-extension/extension/screenshot.html +0 -17
- package/node_modules/@tomflow/chatloop-extension/extension/session.html +0 -6
- package/node_modules/@tomflow/chatloop-extension/extension/start.html +0 -6
- package/node_modules/@tomflow/chatloop-extension/extension/status.html +0 -6
- package/node_modules/@tomflow/chatloop-extension/extension/text.html +0 -17
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-result.js +0 -136
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-take.js +0 -218
- package/node_modules/@tomflow/chatloop-extension/extension/worker/admission.js +0 -124
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +0 -296
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-recovery.js +0 -186
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-result.js +0 -126
- package/node_modules/@tomflow/chatloop-extension/extension/worker/bootstrap.js +0 -230
- package/node_modules/@tomflow/chatloop-extension/extension/worker/manual.js +0 -163
- package/node_modules/@tomflow/chatloop-extension/extension/worker/readiness.js +0 -345
- package/node_modules/@tomflow/chatloop-extension/extension/worker/router.js +0 -192
- package/node_modules/@tomflow/chatloop-extension/extension/worker/scheduler.js +0 -161
- package/node_modules/@tomflow/chatloop-extension/extension/worker/session-control.js +0 -75
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-failure.js +0 -197
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-finished.js +0 -205
- package/node_modules/@tomflow/chatloop-extension/index.mjs +0 -71
- package/node_modules/@tomflow/chatloop-extension/lib/action-routing.mjs +0 -19
- package/node_modules/@tomflow/chatloop-extension/lib/api-observation-queue.mjs +0 -82
- package/node_modules/@tomflow/chatloop-extension/lib/bridge.mjs +0 -303
- package/node_modules/@tomflow/chatloop-extension/lib/browser-launch.mjs +0 -89
- package/node_modules/@tomflow/chatloop-extension/lib/context-binding.mjs +0 -45
- package/node_modules/@tomflow/chatloop-extension/lib/context-ipc.mjs +0 -115
- package/node_modules/@tomflow/chatloop-extension/lib/owner-evidence.mjs +0 -75
- package/node_modules/@tomflow/chatloop-extension/lib/session-file.mjs +0 -185
- package/node_modules/@tomflow/chatloop-extension/package.json +0 -38
- package/node_modules/@tomflow/chatloop-extension/scripts/build-actions.mjs +0 -138
- package/node_modules/@tomflow/chatloop-trace/README.md +0 -118
- package/node_modules/@tomflow/chatloop-trace/events/context.api.mjs +0 -23
- package/node_modules/@tomflow/chatloop-trace/events/typed.api.call.mjs +0 -22
- package/node_modules/@tomflow/chatloop-trace/events.generated.mjs +0 -4
- package/node_modules/@tomflow/chatloop-trace/index.mjs +0 -59
- package/node_modules/@tomflow/chatloop-trace/lib/api-aspect.mjs +0 -273
- package/node_modules/@tomflow/chatloop-trace/lib/trace-reader.mjs +0 -308
- package/node_modules/@tomflow/chatloop-trace/lib/trace-retention.mjs +0 -140
- package/node_modules/@tomflow/chatloop-trace/lib/trace.mjs +0 -236
- package/node_modules/@tomflow/chatloop-trace/package.json +0 -30
- package/node_modules/@tomflow/chatloop-trace/scripts/build-events.mjs +0 -68
- package/node_modules/ps-list/index.d.ts +0 -76
- package/node_modules/ps-list/index.js +0 -366
- package/node_modules/ps-list/license +0 -9
- package/node_modules/ps-list/package.json +0 -44
- package/node_modules/ps-list/readme.md +0 -56
- 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
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
// The ONLY JavaScript package entry. Roles are explicit; importing it does
|
|
2
|
-
// not open a Store, authorize a Principal, or grant an execution capability.
|
|
3
|
-
import {fileURLToPath} from 'node:url';
|
|
4
|
-
import {capabilities} from './capabilities.generated.mjs';
|
|
5
|
-
import {createCapabilityRouter} from './lib/capability-router.mjs';
|
|
6
|
-
import {auditFunction,auditMethods,subscribeContextApiLog} from './lib/api-log.mjs';
|
|
7
|
-
export {subscribeContextApiLog};
|
|
8
|
-
import {CONTEXT_CONTRACT,CONTEXT_PACKAGE_VERSION,methodById,methodDefinitions,
|
|
9
|
-
contextGatewayTools,validateContextCall,parseContextAllowedProjects,
|
|
10
|
-
listMethods,describeMethod} from './lib/methods.mjs';
|
|
11
|
-
|
|
12
|
-
export {CONTEXT_CONTRACT,CONTEXT_PACKAGE_VERSION};
|
|
13
|
-
|
|
14
|
-
// Public MCP adapter contract: metadata, validation, and the npm-installed
|
|
15
|
-
// CLI command. The adapter cannot select a private module path itself.
|
|
16
|
-
export const contextGateway=auditMethods(Object.freeze({
|
|
17
|
-
tools:contextGatewayTools,
|
|
18
|
-
validate:validateContextCall,
|
|
19
|
-
allowedProjects:parseContextAllowedProjects,
|
|
20
|
-
cliPath:fileURLToPath(new URL('./bin/cli.mjs',import.meta.url))
|
|
21
|
-
}),{
|
|
22
|
-
validate:([name,args])=>({api:'gateway.validate',surface:'gateway',mode:'read',
|
|
23
|
-
projectRef:args?.projectId,taskRef:args?.taskId}),
|
|
24
|
-
allowedProjects:()=>({api:'gateway.allowed_projects',surface:'gateway',mode:'read'})
|
|
25
|
-
});
|
|
26
|
-
const fail=code=>Object.assign(new Error(code),{code});
|
|
27
|
-
const runtimeRequired=()=>{
|
|
28
|
-
if(Number(process.versions.node.split('.')[0])<24)
|
|
29
|
-
throw fail('CONTEXT_RUNTIME_UNSUPPORTED');
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Two public package entrypoints, one SDK composition root here.
|
|
33
|
-
// Private modules only declare typed named capabilities; they never import one
|
|
34
|
-
// another, nor reverse-import this facade (which would create ESM cycles).
|
|
35
|
-
// Lazy tiers keep privileged operator code out of ordinary business requests.
|
|
36
|
-
let sdkPromise,operatorPromise,trustedPromise;
|
|
37
|
-
function sdkRuntime(){
|
|
38
|
-
if(!sdkPromise)sdkPromise=(async()=>{
|
|
39
|
-
const [
|
|
40
|
-
core,health,migrationCore,projectCore,taskCore,reviewCore,
|
|
41
|
-
evidenceCore,contextCore,runCore,cancelCore,migration,policy,methods,
|
|
42
|
-
projectStore,operations,lineReview
|
|
43
|
-
]=await Promise.all([
|
|
44
|
-
import('./lib/core/store.mjs'),import('./lib/core/health.mjs'),
|
|
45
|
-
import('./lib/core/migration.mjs'),import('./lib/core/project.mjs'),
|
|
46
|
-
import('./lib/core/task.mjs'),import('./lib/core/review.mjs'),
|
|
47
|
-
import('./lib/core/evidence.mjs'),import('./lib/core/context.mjs'),
|
|
48
|
-
import('./lib/core/run.mjs'),import('./lib/core/run-cancel.mjs'),
|
|
49
|
-
import('./lib/context-migration.mjs'),
|
|
50
|
-
import('./lib/approval-policy.mjs'),import('./lib/methods.mjs'),
|
|
51
|
-
import('./lib/project-store.mjs'),import('./lib/operations.mjs'),
|
|
52
|
-
import('./lib/line-review.mjs')
|
|
53
|
-
]);
|
|
54
|
-
migration.configureMigrationSource({
|
|
55
|
-
reviewPreservedLines:lineReview.reviewPreservedLines
|
|
56
|
-
});
|
|
57
|
-
core.configureCore({
|
|
58
|
-
createHealthMethods:health.createHealthMethods,
|
|
59
|
-
createMigrationMethods:migrationCore.createMigrationMethods,
|
|
60
|
-
createProjectMethods:projectCore.createProjectMethods,
|
|
61
|
-
createTaskMethods:taskCore.createTaskMethods,
|
|
62
|
-
createReviewMethods:reviewCore.createReviewMethods,
|
|
63
|
-
createEvidenceMethods:evidenceCore.createEvidenceMethods,
|
|
64
|
-
createContextMethods:contextCore.createContextMethods,
|
|
65
|
-
createRunMethods:runCore.createRunMethods,
|
|
66
|
-
createCancelMethods:cancelCore.createCancelMethods,
|
|
67
|
-
verifySourceUnit:migration.verifySourceUnit,
|
|
68
|
-
inspectRegistryReferenceForReview:migration.inspectRegistryReferenceForReview,
|
|
69
|
-
hasApprovedPlan:policy.hasApprovedPlan,
|
|
70
|
-
hasRequirementApproval:policy.hasRequirementApproval,
|
|
71
|
-
approvedTurnSourceMatches:policy.approvedTurnSourceMatches
|
|
72
|
-
});
|
|
73
|
-
projectStore.configureProjectStore({
|
|
74
|
-
parseContextAllowedProjects:methods.parseContextAllowedProjects
|
|
75
|
-
});
|
|
76
|
-
operations.configureOperations({
|
|
77
|
-
capabilityRouter:createCapabilityRouter(methodDefinitions,capabilities),
|
|
78
|
-
openContextProtocol:core.openContextProtocol,
|
|
79
|
-
CONTEXT_CONTRACT:methods.CONTEXT_CONTRACT,
|
|
80
|
-
validateContextCall:methods.validateContextCall,
|
|
81
|
-
listMethods:methods.listMethods,describeMethod:methods.describeMethod,
|
|
82
|
-
projectDatabase:projectStore.projectDatabase,
|
|
83
|
-
projectMeta:projectStore.projectMeta,
|
|
84
|
-
verifiedStoreFile:projectStore.verifiedStoreFile,
|
|
85
|
-
resolveProjects:projectStore.resolveProjects,
|
|
86
|
-
allowedProjects:projectStore.allowedProjects
|
|
87
|
-
});
|
|
88
|
-
return Object.freeze({core,migration,methods,operations,projectStore,lineReview});
|
|
89
|
-
})();
|
|
90
|
-
return sdkPromise;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function operatorRuntime(){
|
|
94
|
-
if(!operatorPromise)operatorPromise=(async()=>{
|
|
95
|
-
const sdk=await sdkRuntime();
|
|
96
|
-
const {core,migration,methods,operations,projectStore,lineReview}=sdk;
|
|
97
|
-
const [inventory,workspace,branch,diagnostic,orphan,admin,guards,commands]=
|
|
98
|
-
await Promise.all([
|
|
99
|
-
import('./lib/process-inventory.mjs'),
|
|
100
|
-
import('./lib/workspace-operator.mjs'),
|
|
101
|
-
import('./lib/project-branch.mjs'),
|
|
102
|
-
import('./lib/project-diagnostic.mjs'),
|
|
103
|
-
import('./lib/orphan-operator.mjs'),
|
|
104
|
-
import('./lib/context-cli.mjs'),
|
|
105
|
-
import('./lib/project-guards.mjs'),
|
|
106
|
-
import('./lib/cli-commands.mjs')
|
|
107
|
-
]);
|
|
108
|
-
admin.configureContextAdmin({
|
|
109
|
-
activeLegacyWriters:inventory.activeLegacyWriters,
|
|
110
|
-
openContextProtocol:core.openContextProtocol,
|
|
111
|
-
parseContextAllowedProjects:methods.parseContextAllowedProjects,
|
|
112
|
-
scanSourceUnit:migration.scanSourceUnit,
|
|
113
|
-
saveShadowManifest:migration.saveShadowManifest,
|
|
114
|
-
readShadowManifest:migration.readShadowManifest,
|
|
115
|
-
verifyShadowManifest:migration.verifyShadowManifest,
|
|
116
|
-
backupContextDb:migration.backupContextDb,
|
|
117
|
-
createRecoveryManifest:migration.createRecoveryManifest,
|
|
118
|
-
restoreBackupToDiagnosticBranch:migration.restoreBackupToDiagnosticBranch
|
|
119
|
-
});
|
|
120
|
-
workspace.configureWorkspaceOperator({
|
|
121
|
-
openContextProtocol:core.openContextProtocol,
|
|
122
|
-
contextRoot:projectStore.contextRoot,
|
|
123
|
-
allowedProjects:projectStore.allowedProjects,
|
|
124
|
-
dispatchContextCall:operations.dispatchContextCall
|
|
125
|
-
});
|
|
126
|
-
branch.configureProjectBranch({
|
|
127
|
-
knownWriterInventory:inventory.knownWriterInventory,
|
|
128
|
-
openContextProtocol:core.openContextProtocol,
|
|
129
|
-
backupContextDb:migration.backupContextDb,
|
|
130
|
-
verifySourceUnit:migration.verifySourceUnit,
|
|
131
|
-
scanSourceUnit:migration.scanSourceUnit,
|
|
132
|
-
ID:guards.ID,ensure:guards.ensure,
|
|
133
|
-
privateFile:guards.privateFile,privateRoot:guards.privateRoot
|
|
134
|
-
});
|
|
135
|
-
diagnostic.configureProjectDiagnostic({
|
|
136
|
-
projectBranch:branch,
|
|
137
|
-
openContextProtocol:core.openContextProtocol,
|
|
138
|
-
verifySourceUnit:migration.verifySourceUnit,
|
|
139
|
-
scanSourceUnit:migration.scanSourceUnit,
|
|
140
|
-
reviewPreservedLines:lineReview.reviewPreservedLines,
|
|
141
|
-
ID:guards.ID,ensure:guards.ensure,privateFile:guards.privateFile
|
|
142
|
-
});
|
|
143
|
-
orphan.configureOrphanOperator({
|
|
144
|
-
openContextProtocol:core.openContextProtocol,
|
|
145
|
-
contextRoot:projectStore.contextRoot,
|
|
146
|
-
allowedProjects:projectStore.allowedProjects,
|
|
147
|
-
confirmWorkspaceOperator:workspace.confirmWorkspaceOperator
|
|
148
|
-
});
|
|
149
|
-
commands.configureCliCommands({
|
|
150
|
-
openContextProtocol:core.openContextProtocol,
|
|
151
|
-
contextRoot:projectStore.contextRoot,
|
|
152
|
-
allowedProjects:projectStore.allowedProjects,
|
|
153
|
-
verifySourceUnit:migration.verifySourceUnit,
|
|
154
|
-
createProjectDiagnosticBranch:diagnostic.createProjectDiagnosticBranch,
|
|
155
|
-
createManagedProjectBranch:diagnostic.createManagedProjectBranch,
|
|
156
|
-
fenceLegacyProjectStore:diagnostic.fenceLegacyProjectStore,
|
|
157
|
-
auditLegacyProjectSources:diagnostic.auditLegacyProjectSources,
|
|
158
|
-
inspectLegacyRegistryReference:diagnostic.inspectLegacyRegistryReference,
|
|
159
|
-
activeLegacyWriters:inventory.activeLegacyWriters,
|
|
160
|
-
fenceOrphanRunOperator:orphan.fenceOrphanRunOperator,
|
|
161
|
-
canonicalWorkspaceRefs:workspace.canonicalWorkspaceRefs,
|
|
162
|
-
confirmWorkspaceOperator:workspace.confirmWorkspaceOperator,
|
|
163
|
-
assertWorkspaceUnclaimed:workspace.assertWorkspaceUnclaimed,
|
|
164
|
-
withWorkspaceRegistryLock:workspace.withWorkspaceRegistryLock,
|
|
165
|
-
rebindProjectWorkspaces:workspace.rebindProjectWorkspaces,
|
|
166
|
-
readOperatorWorkspaceReceipt:workspace.readOperatorWorkspaceReceipt,
|
|
167
|
-
runContextCli:admin.runContextCli,
|
|
168
|
-
requestContext,listMethods,describeMethod,CONTEXT_PACKAGE_VERSION
|
|
169
|
-
});
|
|
170
|
-
return Object.freeze({...sdk,inventory,workspace,branch,diagnostic,
|
|
171
|
-
orphan,admin,guards,commands});
|
|
172
|
-
})();
|
|
173
|
-
return operatorPromise;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function trustedRuntime(){
|
|
177
|
-
if(!trustedPromise)trustedPromise=(async()=>{
|
|
178
|
-
const {core,projectStore}=await sdkRuntime();
|
|
179
|
-
const trusted=await import('./lib/trusted-run.mjs');
|
|
180
|
-
trusted.configureTrustedRun({
|
|
181
|
-
openContextProtocol:core.openContextProtocol,
|
|
182
|
-
allowedProjects:projectStore.allowedProjects,
|
|
183
|
-
resolveVerifiedProjectDatabase:projectStore.resolveVerifiedProjectDatabase
|
|
184
|
-
});
|
|
185
|
-
return Object.freeze({execute:trusted.executeTrustedRun});
|
|
186
|
-
})();
|
|
187
|
-
return trustedPromise;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Implementation stays free of observability; the exported callable is a Proxy.
|
|
191
|
-
async function requestContextCore(args){
|
|
192
|
-
const method=methodById.get(args?.operation);
|
|
193
|
-
const tool=method?.mode==='write'?'chat_loop_context_mutate':'chat_loop_context_get';
|
|
194
|
-
validateContextCall(tool,args);
|
|
195
|
-
if(method.id==='sdk.methods.list')return listMethods(args.group,args.view);
|
|
196
|
-
if(method.id==='sdk.methods.describe')return describeMethod(args.methodId);
|
|
197
|
-
runtimeRequired();
|
|
198
|
-
const {operations}=await sdkRuntime();
|
|
199
|
-
return operations.dispatchContextCall(tool,args);
|
|
200
|
-
}
|
|
201
|
-
export const requestContext=auditFunction(requestContextCore,([args])=>{
|
|
202
|
-
const method=methodById.get(args?.operation);
|
|
203
|
-
return {api:method?.id??'request.invalid',surface:'sdk',
|
|
204
|
-
mode:method?.mode??'unknown',projectRef:args?.projectId,taskRef:args?.taskId};
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// Each nested operation is intercepted without modifying the trusted runtime.
|
|
208
|
-
async function loadTrustedRuntimeCore(){
|
|
209
|
-
runtimeRequired();
|
|
210
|
-
const instance=await trustedRuntime();
|
|
211
|
-
return auditMethods(instance,{
|
|
212
|
-
execute:([command,args])=>({
|
|
213
|
-
api:typeof command==='string'&&/^[a-z][a-z0-9.-]{1,69}$/.test(command)
|
|
214
|
-
?'trusted.'+command:'trusted.invalid',
|
|
215
|
-
surface:'trusted',mode:'internal',projectRef:args?.projectId,taskRef:args?.taskId
|
|
216
|
-
})
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
export const loadTrustedRuntime=auditFunction(loadTrustedRuntimeCore,
|
|
220
|
-
()=>({api:'sdk.load_trusted',surface:'sdk',mode:'internal'}));
|
|
221
|
-
|
|
222
|
-
// Only the single public CLI callable is exposed; the internals stay private.
|
|
223
|
-
async function loadLocalOperatorCore(){
|
|
224
|
-
runtimeRequired();
|
|
225
|
-
const {commands}=await operatorRuntime();
|
|
226
|
-
return auditMethods(Object.freeze({
|
|
227
|
-
runLocalCliCommand:commands.runLocalCliCommand
|
|
228
|
-
}),{
|
|
229
|
-
runLocalCliCommand:()=>({
|
|
230
|
-
// Only the public callable name, not CLI tokens, may enter logs.
|
|
231
|
-
api:'operator.runLocalCliCommand',surface:'operator',mode:'operator'
|
|
232
|
-
})
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
export const loadLocalOperator=auditFunction(loadLocalOperatorCore,
|
|
236
|
-
()=>({api:'sdk.load_operator',surface:'sdk',mode:'operator'}));
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// Context-specific evidence adapter for the one canonical API AOP runtime.
|
|
2
|
-
// Public functions, promise/throw semantics, correlation and queue handling
|
|
3
|
-
// belong to the public @tomflow/chatloop-trace API, not a copied runtime.
|
|
4
|
-
import {createApiAspect} from '@tomflow/chatloop-trace';
|
|
5
|
-
|
|
6
|
-
const API_LOG_CONTRACT='chat-loop.context-api-log.v1';
|
|
7
|
-
const API=/^[a-z][A-Za-z0-9._-]{1,89}$/;
|
|
8
|
-
const REF=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
9
|
-
const CODE=/^[A-Z][A-Z0-9_]{1,95}$/;
|
|
10
|
-
const listeners=new Set(),metadata=new Map();
|
|
11
|
-
const safe=(value,re)=>typeof value==='string'&&re.test(value)?value:null;
|
|
12
|
-
const adapter=createApiAspect('@tomflow/chatloop-context',{sink:deliver});
|
|
13
|
-
|
|
14
|
-
// At the public boundary capture only safe, bounded identifiers. Never log
|
|
15
|
-
// method arguments, bodies, workspace paths or tool return values.
|
|
16
|
-
function capture(detail,ids){
|
|
17
|
-
// If a Promise never settles, evict its oldest soft span rather than
|
|
18
|
-
// permanently disabling observation of all future business calls.
|
|
19
|
-
// Evicted spans report a transport failure if/when delivery is attempted.
|
|
20
|
-
if(metadata.size>=4096)metadata.delete(metadata.keys().next().value);
|
|
21
|
-
metadata.set(ids.spanId,{
|
|
22
|
-
api:safe(detail.api,API)||'api.invalid',
|
|
23
|
-
surface:safe(detail.surface,API)||'sdk',
|
|
24
|
-
mode:safe(detail.mode,API)||'read',
|
|
25
|
-
projectRef:safe(detail.projectRef,REF),
|
|
26
|
-
taskRef:safe(detail.taskRef,REF),
|
|
27
|
-
targets:[...listeners]
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function deliver(raw){
|
|
31
|
-
const meta=metadata.get(raw.callId);
|
|
32
|
-
if(!meta)return false;
|
|
33
|
-
if(raw.phase!=='BEGIN')metadata.delete(raw.callId);
|
|
34
|
-
const event=Object.freeze({
|
|
35
|
-
contract:API_LOG_CONTRACT,callId:raw.callId,traceId:raw.traceId,
|
|
36
|
-
spanId:raw.spanId,parentSpanId:raw.parentSpanId,
|
|
37
|
-
api:meta.api,surface:meta.surface,mode:meta.mode,
|
|
38
|
-
projectRef:meta.projectRef,taskRef:meta.taskRef,phase:raw.phase,
|
|
39
|
-
time:raw.time,durationMs:raw.durationMs,
|
|
40
|
-
errorCode:raw.phase==='FAILED'
|
|
41
|
-
?safe(raw.errorCode,CODE)==='API_FAILED'?'CONTEXT_FAILED':
|
|
42
|
-
safe(raw.errorCode,CODE)||'CONTEXT_FAILED'
|
|
43
|
-
:null
|
|
44
|
-
});
|
|
45
|
-
let attempted=false,failed=false;
|
|
46
|
-
if(process.env.CHAT_LOOP_CONTEXT_API_LOG_STDERR==='1'){
|
|
47
|
-
attempted=true;
|
|
48
|
-
try{process.stderr.write('CHAT_LOOP_CONTEXT_API_LOG '+JSON.stringify(event)+'\n')}
|
|
49
|
-
catch{failed=true}
|
|
50
|
-
}
|
|
51
|
-
const pending=[];
|
|
52
|
-
for(const listener of meta.targets){
|
|
53
|
-
attempted=true;
|
|
54
|
-
try{
|
|
55
|
-
const result=listener(event);
|
|
56
|
-
if(result&&typeof result.then==='function')
|
|
57
|
-
pending.push(Promise.resolve(result).then(value=>value!==false,()=>false));
|
|
58
|
-
else if(result===false)failed=true;
|
|
59
|
-
}catch{failed=true}
|
|
60
|
-
}
|
|
61
|
-
// A different successful observer cannot conceal a failed writer.
|
|
62
|
-
// All registered sinks must acknowledge; none may affect the API result.
|
|
63
|
-
return pending.length?Promise.all(pending).then(values=>
|
|
64
|
-
attempted&&!failed&&values.every(Boolean)):attempted&&!failed;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Context's public SDK retains the established descriptor contracts, but
|
|
68
|
-
// uses the shared AOP for every intercepted callable and its child spans.
|
|
69
|
-
export const auditFunction=(target,describe)=>adapter.described(target,describe,capture);
|
|
70
|
-
export const auditMethods=(target,descriptors)=>
|
|
71
|
-
adapter.describedMethods(target,descriptors,capture);
|
|
72
|
-
|
|
73
|
-
function subscribe(listener){
|
|
74
|
-
if(typeof listener!=='function')throw TypeError('API_LOG_LISTENER_REQUIRED');
|
|
75
|
-
listeners.add(listener);
|
|
76
|
-
// Own subscription begins before registration; attach this subscriber to
|
|
77
|
-
// exactly its own span without inventing a second bootstrap event.
|
|
78
|
-
const spanId=adapter.current()?.spanId;
|
|
79
|
-
const current=spanId?metadata.get(spanId):null;
|
|
80
|
-
if(current&¤t.api==='sdk.subscribe_log'&&!current.targets.includes(listener))
|
|
81
|
-
current.targets.push(listener);
|
|
82
|
-
return auditFunction(()=>listeners.delete(listener),
|
|
83
|
-
()=>({api:'sdk.unsubscribe_log',mode:'internal'}));
|
|
84
|
-
}
|
|
85
|
-
export const subscribeContextApiLog=auditFunction(subscribe,
|
|
86
|
-
()=>({api:'sdk.subscribe_log',mode:'internal'}));
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Context owns business approval policy. No SQLite, browser, MCP or Session state.
|
|
2
|
-
// Only these enforced predicates (not an unused second policy descriptor)
|
|
3
|
-
// decide whether R and P have distinct genuine user Turns.
|
|
4
|
-
|
|
5
|
-
const fromUser=a=>Boolean(a&&typeof a==='object'
|
|
6
|
-
&&(a.sourceRole===undefined||a.sourceRole==='user')
|
|
7
|
-
&&typeof a.userTurn==='string'&&a.userTurn.length>0);
|
|
8
|
-
|
|
9
|
-
export function hasRequirementApproval(records){
|
|
10
|
-
return Array.isArray(records)&&records.length===1
|
|
11
|
-
&&records[0]?.kind==='R'&&fromUser(records[0]);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function hasApprovedPlan(records){
|
|
15
|
-
return Array.isArray(records)&&records.length===2
|
|
16
|
-
&&records[0]?.kind==='R'&&records[1]?.kind==='P'
|
|
17
|
-
&&fromUser(records[0])&&fromUser(records[1])
|
|
18
|
-
&&records[0].userTurn!==records[1].userTurn;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const FORM_UUID='[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}';
|
|
22
|
-
const FORM_HEADER='Chat Loop Form 提交结果(由用户点击表单提交)';
|
|
23
|
-
const FORM_NOTE='请核对当前业务任务、文档与 Issue 版本及原生消息身份后处理本次选择;表单回执本身不构成审批或写权。';
|
|
24
|
-
const versionedLabel=(version,label,kind)=>version[0]===kind
|
|
25
|
-
&&(kind==='R'?label==='需求'
|
|
26
|
-
:['技术与验证方案','技术方案','方案'].includes(label));
|
|
27
|
-
const formReceipt=(text,kind,stored)=>{
|
|
28
|
-
if(typeof text!=='string'||text.length>1000)return null;
|
|
29
|
-
let formId,traceRef,version,label;
|
|
30
|
-
if(stored){
|
|
31
|
-
// Existing Context approval.observe callers persisted this exact bounded
|
|
32
|
-
// Form summary, NOT the multiline ChatGPT user Turn visible to Observer.
|
|
33
|
-
const m=text.match(new RegExp('^Chat Loop Form 提交结果(由用户点击表单提交);formId=('+
|
|
34
|
-
FORM_UUID+');traceRef=('+FORM_UUID+');A[||]确认当前 ([RP][1-9][0-9]*) (需求|技术与验证方案|技术方案|方案)$','i'));
|
|
35
|
-
if(!m)return null;
|
|
36
|
-
[,formId,traceRef,version,label]=m;
|
|
37
|
-
}else{
|
|
38
|
-
const lines=text.split(/\r?\n/).map(x=>x.trim()).filter(Boolean);
|
|
39
|
-
if(lines.length!==6||lines[0]!=='Chat Loop Form 提交结果(由用户点击表单提交)'
|
|
40
|
-
||lines[3]!=='选项值: A'||lines[5]!==FORM_NOTE)return null;
|
|
41
|
-
const id=lines[1].match(new RegExp('^formId:\\s*('+FORM_UUID+')$','i'));
|
|
42
|
-
const trace=lines[2].match(new RegExp('^traceRef:\\s*('+FORM_UUID+')$','i'));
|
|
43
|
-
const choice=lines[4].match(/^选项标签:\s*A[||]\s*确认当前\s*([RP][1-9][0-9]*)\s*(需求|技术与验证方案|技术方案|方案)$/i);
|
|
44
|
-
if(!id||!trace||!choice)return null;
|
|
45
|
-
formId=id[1];traceRef=trace[1];version=choice[1];label=choice[2];
|
|
46
|
-
}
|
|
47
|
-
version=version.toUpperCase();
|
|
48
|
-
if(!versionedLabel(version,label,kind)
|
|
49
|
-
||formId.toLowerCase()===traceRef.toLowerCase())return null;
|
|
50
|
-
return {formId:formId.toLowerCase(),traceRef:traceRef.toLowerCase(),version,label};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// The single Context policy for matching an immutable approval source to
|
|
54
|
-
// soft, ephemeral browser evidence. A summary is accepted ONLY through an
|
|
55
|
-
// exact Form A schema; task identity remains the Context row + live lease.
|
|
56
|
-
export function approvedTurnSourceMatches(record,observed,kind){
|
|
57
|
-
if(!record||record.kind!==kind||!observed
|
|
58
|
-
||typeof observed.userText!=='string'||observed.userText.length>1000
|
|
59
|
-
||typeof observed.userKey!=='string'||!/^user:[^\s]{8,}$/.test(observed.userKey)
|
|
60
|
-
||!/^([RP])[1-9][0-9]*$/.test(observed.version)
|
|
61
|
-
||observed.version[0]!==kind
|
|
62
|
-
||observed.version!==kind+String(record.version).replace(/^[RP]/,'')
|
|
63
|
-
||(record.sourceRole!==undefined&&record.sourceRole!=='user'))return false;
|
|
64
|
-
// A stored Form summary cannot authenticate a browser message that merely
|
|
65
|
-
// copies the summary. Require the six-line original user-turn template.
|
|
66
|
-
if(typeof record.userTurn==='string'
|
|
67
|
-
&&record.userTurn.startsWith(FORM_HEADER)){
|
|
68
|
-
const stored=formReceipt(record.userTurn,kind,true)
|
|
69
|
-
||formReceipt(record.userTurn,kind,false);
|
|
70
|
-
const actual=formReceipt(observed.userText,kind,false);
|
|
71
|
-
return Boolean(stored&&actual
|
|
72
|
-
&&stored.formId===actual.formId&&stored.traceRef===actual.traceRef
|
|
73
|
-
&&stored.version===actual.version&&stored.label===actual.label
|
|
74
|
-
&&stored.version===observed.version);
|
|
75
|
-
}
|
|
76
|
-
return record.userTurn===observed.userText||record.userTurn===observed.userKey;
|
|
77
|
-
}
|