synabun 2.4.1 → 2.4.2
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/CHANGELOG.md +30 -0
- package/README.md +1 -1
- package/browser-extension/content.js +56 -14
- package/browser-extension/engine.js +158 -8
- package/browser-extension/manifest.json +3 -1
- package/browser-extension/protocol.js +91 -6
- package/browser-extension/service-worker.js +13 -5
- package/browser-extension/tokens.css +1 -1
- package/docs/browser-extension-bridge.md +24 -4
- package/lib/data-home-files.js +4 -2
- package/lib/first-launch-protection.js +8 -2
- package/lib/update-snapshot.js +11 -4
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +25 -2
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +62 -17
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-bench.d.ts +22 -22
- package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-maintenance.js +34 -45
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
- package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
- package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-copy.js +467 -0
- package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.js +60 -0
- package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-retrieval.js +188 -40
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
- package/mcp-server/dist/services/memory-schema.d.ts +58 -2
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-schema.js +190 -13
- package/mcp-server/dist/services/memory-schema.js.map +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +56 -20
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-verification.js +8 -5
- package/mcp-server/dist/services/memory-verification.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +5 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +19 -2
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.js +145 -0
- package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
- package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
- package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite-write.js +94 -0
- package/mcp-server/dist/services/sqlite-write.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +39 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
- package/mcp-server/dist/services/sqlite.js +249 -8
- package/mcp-server/dist/services/sqlite.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +32 -10
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe.js +9 -7
- package/mcp-server/dist/services/typesafe.js.map +1 -1
- package/mcp-server/dist/services/vector-cache.d.ts +32 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
- package/mcp-server/dist/services/vector-cache.js +161 -8
- package/mcp-server/dist/services/vector-cache.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +11 -7
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +27 -9
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +10 -3
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +6 -1
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +20 -2
- package/mcp-server/src/index.ts +59 -17
- package/mcp-server/src/services/memory-maintenance.ts +31 -28
- package/mcp-server/src/services/memory-migration-copy.ts +419 -0
- package/mcp-server/src/services/memory-migration-worker.ts +55 -0
- package/mcp-server/src/services/memory-retrieval.ts +173 -32
- package/mcp-server/src/services/memory-schema.ts +194 -12
- package/mcp-server/src/services/memory-sessions.ts +54 -21
- package/mcp-server/src/services/memory-verification.ts +7 -4
- package/mcp-server/src/services/neural-interface.ts +22 -2
- package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
- package/mcp-server/src/services/retrieval-reader.ts +131 -0
- package/mcp-server/src/services/sqlite-write.ts +60 -0
- package/mcp-server/src/services/sqlite.ts +246 -8
- package/mcp-server/src/services/typesafe-config.ts +25 -6
- package/mcp-server/src/services/typesafe.ts +9 -7
- package/mcp-server/src/services/vector-cache.ts +154 -9
- package/mcp-server/src/tools/agents.ts +26 -9
- package/mcp-server/src/tools/browser-advanced.ts +10 -3
- package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
- package/mcp-server/src/tools/browser-interact.ts +5 -1
- package/neural-interface/i18n/en.json +263 -1
- package/neural-interface/i18n/pt-BR.json +264 -2
- package/neural-interface/lib/agents/split.js +32 -4
- package/neural-interface/lib/assistant-api.js +19 -8
- package/neural-interface/lib/assistant-brains/claude.js +2 -0
- package/neural-interface/lib/assistant-catalog.js +2 -2
- package/neural-interface/lib/assistant-config.js +0 -7
- package/neural-interface/lib/assistant-dispatch.js +257 -95
- package/neural-interface/lib/assistant-persona.js +16 -4
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +131 -47
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +39 -33
- package/neural-interface/lib/backup-contents.js +158 -0
- package/neural-interface/lib/backup-crypto-io.js +330 -0
- package/neural-interface/lib/backup-crypto-worker.js +130 -0
- package/neural-interface/lib/backup-crypto.js +525 -0
- package/neural-interface/lib/backup-download.js +268 -0
- package/neural-interface/lib/backup-encryption.js +318 -0
- package/neural-interface/lib/backup-groups.js +287 -0
- package/neural-interface/lib/backup-restore-session.js +176 -0
- package/neural-interface/lib/backup-restore-stage.js +60 -0
- package/neural-interface/lib/backup-service.js +788 -233
- package/neural-interface/lib/backup-zip-reader.js +30 -18
- package/neural-interface/lib/backup-zip-writer.js +34 -10
- package/neural-interface/lib/browser-extension-adapter.js +89 -13
- package/neural-interface/lib/browser-extension-bridge.js +18 -7
- package/neural-interface/lib/claude-agent-bridge.js +1 -0
- package/neural-interface/lib/claude-session-cleanup.js +5 -1
- package/neural-interface/lib/cli-update-planner.js +105 -6
- package/neural-interface/lib/client-diagnostics.js +42 -0
- package/neural-interface/lib/confined-fs.js +7 -2
- package/neural-interface/lib/coordination/README.md +8 -2
- package/neural-interface/lib/coordination/contract.js +161 -0
- package/neural-interface/lib/coordination/database.js +999 -0
- package/neural-interface/lib/coordination/operations.js +436 -0
- package/neural-interface/lib/coordination/service.js +68 -537
- package/neural-interface/lib/coordination/storage-worker.js +101 -0
- package/neural-interface/lib/coordination/store.js +219 -1111
- package/neural-interface/lib/db.js +70 -32
- package/neural-interface/lib/health-count.js +37 -0
- package/neural-interface/lib/loop-stall.js +139 -0
- package/neural-interface/lib/maritaca/client.js +2 -2
- package/neural-interface/lib/maritaca/models.js +12 -17
- package/neural-interface/lib/maritaca/opencode.js +4 -2
- package/neural-interface/lib/memory-api.js +9 -1
- package/neural-interface/lib/memory-session-capture.js +42 -10
- package/neural-interface/lib/memory-store-gate.js +313 -0
- package/neural-interface/lib/memory-store-migrate.js +65 -0
- package/neural-interface/lib/memory-timers.js +7 -7
- package/neural-interface/lib/native-loop-providers.js +13 -16
- package/neural-interface/lib/native-loop-runtime.js +28 -7
- package/neural-interface/lib/opencode-build-preflight.js +18 -1
- package/neural-interface/lib/opencode-native-boundary.js +69 -8
- package/neural-interface/lib/opencode-provider-view.js +14 -3
- package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
- package/neural-interface/lib/opencode2-client.js +2 -1
- package/neural-interface/lib/recall-impact.js +122 -0
- package/neural-interface/lib/scratch-evidence.js +420 -0
- package/neural-interface/lib/scratch-process-guard.js +139 -0
- package/neural-interface/lib/scratch-references.js +279 -0
- package/neural-interface/lib/scratch-retention-core.js +385 -0
- package/neural-interface/lib/scratch-retention-worker.js +37 -0
- package/neural-interface/lib/scratch-retention.js +151 -0
- package/neural-interface/lib/session-cache-builder.js +31 -43
- package/neural-interface/lib/session-cache-worker.js +157 -0
- package/neural-interface/lib/session-indexer.js +28 -21
- package/neural-interface/lib/session-search-index.js +85 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
- package/neural-interface/lib/style-guide/store.js +43 -3
- package/neural-interface/lib/system-restore.js +50 -0
- package/neural-interface/lib/teams/api.js +15 -6
- package/neural-interface/lib/teams/claims.js +67 -31
- package/neural-interface/lib/teams/index.js +7 -7
- package/neural-interface/lib/teams/integration.js +40 -40
- package/neural-interface/lib/teams/landing.js +6 -6
- package/neural-interface/lib/teams/recovery.js +24 -23
- package/neural-interface/lib/teams/scheduler.js +194 -95
- package/neural-interface/lib/teams/state.js +14 -14
- package/neural-interface/lib/teams/worktrees.js +27 -27
- package/neural-interface/lib/whatsapp/bridge.js +2 -1
- package/neural-interface/lib/worker-confinement.js +47 -2
- package/neural-interface/lib/worker-mcp-channel.js +2 -0
- package/neural-interface/lib/worker-resume.js +5 -0
- package/neural-interface/lib/worker-stop.js +86 -0
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/index.html +233 -24
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
- package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
- package/neural-interface/public/shared/agy/agy-options.js +11 -0
- package/neural-interface/public/shared/agy/agy-panel.js +29 -10
- package/neural-interface/public/shared/agy/agy-styles.js +14 -12
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
- package/neural-interface/public/shared/api.js +1 -1
- package/neural-interface/public/shared/assistant/asst-api.js +3 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
- package/neural-interface/public/shared/assistant/asst-control.js +2 -0
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
- package/neural-interface/public/shared/assistant/asst-render.js +105 -38
- package/neural-interface/public/shared/assistant/asst-route.js +100 -21
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
- package/neural-interface/public/shared/assistant/asst-state.js +11 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
- package/neural-interface/public/shared/assistant/route-identity.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
- package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
- package/neural-interface/public/shared/client-diagnostics.js +94 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-styles.js +1 -1
- package/neural-interface/public/shared/effort-i18n.js +118 -0
- package/neural-interface/public/shared/html-shell.js +4 -52
- package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
- package/neural-interface/public/shared/memory-store-wait.js +52 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
- package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
- package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
- package/neural-interface/public/shared/output-format.js +294 -0
- package/neural-interface/public/shared/provider-icons.js +6 -0
- package/neural-interface/public/shared/schedules-view.js +2 -1
- package/neural-interface/public/shared/server-presence.js +77 -0
- package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
- package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
- package/neural-interface/public/shared/settings/settings-ia.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
- package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +341 -437
- package/neural-interface/public/shared/transcript-rows.js +28 -3
- package/neural-interface/public/shared/tray-auto-close.js +18 -5
- package/neural-interface/public/shared/ui-agents.js +1 -2
- package/neural-interface/public/shared/ui-automation-studio.js +168 -108
- package/neural-interface/public/shared/ui-claude-panel.js +42 -65
- package/neural-interface/public/shared/ui-loading.js +124 -17
- package/neural-interface/public/shared/ui-native-loop-router.js +10 -0
- package/neural-interface/public/shared/ui-navbar.js +2 -1
- package/neural-interface/public/shared/ui-output.js +533 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
- package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
- package/neural-interface/public/shared/ui-sessions.js +2 -2
- package/neural-interface/public/shared/ui-settings-entry.js +18 -0
- package/neural-interface/public/shared/ui-settings.js +224 -65
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-tooltip.js +16 -0
- package/neural-interface/public/shared/ui-tutorial.js +5 -6
- package/neural-interface/public/shared/ui-worker-end.js +27 -8
- package/neural-interface/public/shared/worker-end.js +9 -4
- package/neural-interface/public/variant/2d/main.js +5 -0
- package/neural-interface/public/variant/3d/app.js +10 -0
- package/neural-interface/public/variant/3d/main.js +5 -1
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +477 -139
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
|
@@ -55,20 +55,20 @@ const PAGE = 500;
|
|
|
55
55
|
export function createTeamState({ store, log = () => {} } = {}) {
|
|
56
56
|
if (!store || typeof store.journal?.write !== 'function') throw new TeamError('STORE_REQUIRED', 'The teams modules need a coordination store (lib/coordination/store.js).');
|
|
57
57
|
|
|
58
|
-
function entriesOf(teamId) {
|
|
58
|
+
async function entriesOf(teamId) {
|
|
59
59
|
const out = [];
|
|
60
60
|
let afterId = 0;
|
|
61
61
|
for (;;) {
|
|
62
|
-
const page = store.journal.read({ teamId, afterId, limit: PAGE });
|
|
62
|
+
const page = await store.journal.read({ teamId, afterId, limit: PAGE });
|
|
63
63
|
out.push(...page);
|
|
64
64
|
if (page.length < PAGE) return out;
|
|
65
65
|
afterId = page[page.length - 1].id;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
function announce(entry) {
|
|
69
|
+
async function announce(entry) {
|
|
70
70
|
try {
|
|
71
|
-
store.append({
|
|
71
|
+
await store.append({
|
|
72
72
|
id: `team:${entry.teamId}:journal:${entry.id}`,
|
|
73
73
|
teamId: entry.teamId,
|
|
74
74
|
runId: entry.runId || null,
|
|
@@ -86,8 +86,8 @@ export function createTeamState({ store, log = () => {} } = {}) {
|
|
|
86
86
|
* projectPath: string, baseCommit: string, baseBranch: string|null, testCommand: any, integration: object,
|
|
87
87
|
* removed: boolean, slices: Record<string, object>, [key: string]: any }}
|
|
88
88
|
*/
|
|
89
|
-
function record(teamId) {
|
|
90
|
-
const entries = entriesOf(teamId);
|
|
89
|
+
async function record(teamId) {
|
|
90
|
+
const entries = await entriesOf(teamId);
|
|
91
91
|
if (!entries.length) return null;
|
|
92
92
|
const team = {};
|
|
93
93
|
const slices = {};
|
|
@@ -136,23 +136,23 @@ export function createTeamState({ store, log = () => {} } = {}) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** Record that a team is in a state now, with what this step changes. */
|
|
139
|
-
function writeTeam(teamId, state, data = {}) {
|
|
140
|
-
const entry = store.journal.write({ teamId, state, data });
|
|
141
|
-
announce(entry);
|
|
139
|
+
async function writeTeam(teamId, state, data = {}) {
|
|
140
|
+
const entry = await store.journal.write({ teamId, state, data });
|
|
141
|
+
await announce(entry);
|
|
142
142
|
return entry;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/** Record that a slice is in a state now, with what this step changes. */
|
|
146
|
-
function writeSlice(teamId, sliceId, state, data = {}, runId = null) {
|
|
146
|
+
async function writeSlice(teamId, sliceId, state, data = {}, runId = null, claimGlobs = null) {
|
|
147
147
|
if (sliceId === INTEGRATION_SLICE_ID) throw new TeamError('RESERVED_SLICE', '"integration" is the team\'s integration worktree, not a slice.');
|
|
148
|
-
const entry = store.journal.write({ teamId, sliceId, state, runId, data });
|
|
149
|
-
announce(entry);
|
|
148
|
+
const entry = await store.journal.write({ teamId, sliceId, state, runId, data, ...(claimGlobs?.length ? { claimGlobs } : {}) });
|
|
149
|
+
await announce(entry);
|
|
150
150
|
return entry;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/** Every team the journal knows (its own newest entry), oldest team first; `states` narrows it. */
|
|
154
|
-
function teams({ states = null } = {}) {
|
|
155
|
-
return store.journal.teams(states ? { states } : {});
|
|
154
|
+
async function teams({ states = null } = {}) {
|
|
155
|
+
return await store.journal.teams(states ? { states } : {});
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
return { record, writeTeam, writeSlice, teams, entriesOf };
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
// system can clone. Changing dependencies (lockfiles, and with them the manifests) is the lockfile-owner slice's.
|
|
30
30
|
|
|
31
31
|
import { execFile } from 'node:child_process';
|
|
32
|
-
import { appendFileSync, constants as FS, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync,
|
|
32
|
+
import { appendFileSync, constants as FS, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmdirSync, statfsSync } from 'node:fs';
|
|
33
33
|
import { copyFile, cp, rm } from 'node:fs/promises';
|
|
34
34
|
import { dirname, isAbsolute, join, posix, resolve } from 'node:path';
|
|
35
35
|
import { promisify } from 'node:util';
|
|
@@ -303,7 +303,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
303
303
|
async function unmake(plan, made) {
|
|
304
304
|
for (const piece of made) {
|
|
305
305
|
await git(['worktree', 'remove', '--force', piece.path], { cwd: plan.projectPath });
|
|
306
|
-
if (present(piece.path))
|
|
306
|
+
if (present(piece.path)) await rm(piece.path, { recursive: true, force: true });
|
|
307
307
|
if (piece.madeBranch && await commitOf(git, plan.projectPath, `refs/heads/${piece.branch}`) === plan.baseCommit) await git(['branch', '-D', piece.branch], { cwd: plan.projectPath });
|
|
308
308
|
}
|
|
309
309
|
await git(['worktree', 'prune'], { cwd: plan.projectPath });
|
|
@@ -356,7 +356,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
356
356
|
if (command === false) return refuse('INVALID_TEST_COMMAND', 'testCommand is a command line (text) or a list of arguments.');
|
|
357
357
|
|
|
358
358
|
return locks.run(repoKey(plan.projectPath), async () => {
|
|
359
|
-
if (state.record(plan.teamId)) return refuse('TEAM_EXISTS', `A team named "${plan.teamId}" is already recorded. Pick another team id, or remove that team first.`, { existing: [{ kind: 'journal', teamId: plan.teamId }] });
|
|
359
|
+
if (await state.record(plan.teamId)) return refuse('TEAM_EXISTS', `A team named "${plan.teamId}" is already recorded. Pick another team id, or remove that team first.`, { existing: [{ kind: 'journal', teamId: plan.teamId }] });
|
|
360
360
|
const existing = await collisions(plan);
|
|
361
361
|
if (existing.length) {
|
|
362
362
|
const what = existing.map((each) => each.path || each.branch).join(', ');
|
|
@@ -364,38 +364,38 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
364
364
|
}
|
|
365
365
|
const excluded = await ensureWorktreesExcluded(git, plan.projectPath);
|
|
366
366
|
const pieces = planPieces(plan);
|
|
367
|
-
state.writeTeam(plan.teamId, 'creating', {
|
|
367
|
+
await state.writeTeam(plan.teamId, 'creating', {
|
|
368
368
|
plan: pieces.team, baseBranch: repo.branch, headAtCreate: repo.head, testCommand: command, createdBy: typeof createdBy === 'string' ? createdBy : null,
|
|
369
369
|
integration: { head: plan.baseCommit, lastGood: plan.baseCommit, tests: null },
|
|
370
370
|
});
|
|
371
371
|
for (const piece of pieces.slices) {
|
|
372
|
-
state.writeSlice(plan.teamId, piece.id, 'planned', { task: piece.task });
|
|
373
|
-
state.writeSlice(plan.teamId, piece.id, 'pending', { ownedPaths: piece.ownedPaths, ...placeOf(plan, piece.id), startCommit: plan.baseCommit });
|
|
372
|
+
await state.writeSlice(plan.teamId, piece.id, 'planned', { task: piece.task });
|
|
373
|
+
await state.writeSlice(plan.teamId, piece.id, 'pending', { ownedPaths: piece.ownedPaths, ...placeOf(plan, piece.id), startCommit: plan.baseCommit });
|
|
374
374
|
}
|
|
375
375
|
const built = await materialize(plan);
|
|
376
376
|
if (!built.ok) {
|
|
377
377
|
await unmake(plan, built.made);
|
|
378
|
-
state.writeTeam(plan.teamId, 'failed', { error: built.failed, failedAt: now() });
|
|
378
|
+
await state.writeTeam(plan.teamId, 'failed', { error: built.failed, failedAt: now() });
|
|
379
379
|
return refuse('WORKTREE_FAILED', `The worktree of "${built.failed.sliceId}" could not be made: ${built.failed.error}. Nothing of the team is left.`, { failed: built.failed });
|
|
380
380
|
}
|
|
381
381
|
const prepared = await runSetup(plan, plan.readOnly ? null : setup === undefined ? defaultSetup : setup);
|
|
382
|
-
state.writeTeam(plan.teamId, 'planned', { worktrees: built.made.map(({ sliceId, path, branch }) => ({ sliceId, path, branch })) });
|
|
383
|
-
return { ok: true, team: state.record(plan.teamId), setup: prepared, excluded };
|
|
382
|
+
await state.writeTeam(plan.teamId, 'planned', { worktrees: built.made.map(({ sliceId, path, branch }) => ({ sliceId, path, branch })) });
|
|
383
|
+
return { ok: true, team: await state.record(plan.teamId), setup: prepared, excluded };
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
/** A team's record (lib/teams/state.js), or null. */
|
|
388
|
-
const get = (teamId) => (isTeamSlug(teamId) ? state.record(teamId) : null);
|
|
388
|
+
const get = async (teamId) => (isTeamSlug(teamId) ? await state.record(teamId) : null);
|
|
389
389
|
|
|
390
390
|
/**
|
|
391
391
|
* The teams the journal knows, oldest first.
|
|
392
392
|
* @param {{ projectPath?: string, states?: string[], includeRemoved?: boolean }} [query]
|
|
393
393
|
*/
|
|
394
|
-
function list({ projectPath = null, states = null, includeRemoved = true } = {}) {
|
|
394
|
+
async function list({ projectPath = null, states = null, includeRemoved = true } = {}) {
|
|
395
395
|
const wanted = projectPath ? realOf(projectPath) : null;
|
|
396
396
|
const out = [];
|
|
397
|
-
for (const entry of state.teams(states ? { states } : {})) {
|
|
398
|
-
const record = state.record(entry.teamId);
|
|
397
|
+
for (const entry of await state.teams(states ? { states } : {})) {
|
|
398
|
+
const record = await state.record(entry.teamId);
|
|
399
399
|
if (!record) continue;
|
|
400
400
|
if (wanted && realOf(record.projectPath) !== wanted) continue;
|
|
401
401
|
if (!includeRemoved && record.removed) continue;
|
|
@@ -436,7 +436,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
436
436
|
* integration branch, uncommitted files, last commit), the integration branch, and the user's branch.
|
|
437
437
|
*/
|
|
438
438
|
async function inspect(teamId) {
|
|
439
|
-
const record = get(teamId);
|
|
439
|
+
const record = await get(teamId);
|
|
440
440
|
if (!record) return refuse('TEAM_NOT_FOUND', `No team named "${teamId}" is recorded.`);
|
|
441
441
|
const registered = isDirectory(record.projectPath) ? await listWorktrees(git, record.projectPath) : [];
|
|
442
442
|
const integration = record.plan.readOnly ? {} : await pieceInfo(record, INTEGRATION_SLICE_ID, registered);
|
|
@@ -477,7 +477,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
477
477
|
* @returns {Promise<{ ok: true, sliceId: string, worktree: string, branch: string, startCommit: string, rework: boolean } | { ok: false, code: string }>}
|
|
478
478
|
*/
|
|
479
479
|
async function startSlice(teamId, sliceId, { runId = null } = {}) {
|
|
480
|
-
const record = get(teamId);
|
|
480
|
+
const record = await get(teamId);
|
|
481
481
|
if (!record) return refuse('TEAM_NOT_FOUND', `No team named "${teamId}" is recorded.`);
|
|
482
482
|
const slice = planSlice(record, sliceId);
|
|
483
483
|
if (!slice) return refuse('SLICE_NOT_FOUND', `Team "${teamId}" has no slice "${sliceId}".`);
|
|
@@ -504,15 +504,15 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
504
504
|
}
|
|
505
505
|
startCommit = await commitOf(git, path, 'HEAD') || head;
|
|
506
506
|
}
|
|
507
|
-
state.writeSlice(teamId, sliceId, 'running', { startCommit, startedAt: now(), ...(rework ? { rework: true } : {}) }, runId);
|
|
508
|
-
if (record.state === 'planned' || record.state === 'ready') state.writeTeam(teamId, 'running', {});
|
|
507
|
+
await state.writeSlice(teamId, sliceId, 'running', { startCommit, startedAt: now(), ...(rework ? { rework: true } : {}) }, runId);
|
|
508
|
+
if (record.state === 'planned' || record.state === 'ready') await state.writeTeam(teamId, 'running', {});
|
|
509
509
|
return { ok: true, sliceId, worktree: path, branch, startCommit, rework };
|
|
510
510
|
});
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
/** A read-only worker has ended. Preserve any changed checkout or commit, including ignored files. */
|
|
514
514
|
async function finishReadOnlySlice(teamId, sliceId, { failed = false } = {}) {
|
|
515
|
-
const record = get(teamId);
|
|
515
|
+
const record = await get(teamId);
|
|
516
516
|
if (!record?.plan.readOnly) return refuse('TEAM_NOT_READ_ONLY', 'This operation is for read-only workers.');
|
|
517
517
|
if (!planSlice(record, sliceId)) return refuse('SLICE_NOT_FOUND', `Unknown slice ${sliceId}.`);
|
|
518
518
|
return locks.run(repoKey(record.projectPath), async () => {
|
|
@@ -536,12 +536,12 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
const cleanup = { removed: !kept, kept, path: info.path, branch: info.branch };
|
|
539
|
-
state.writeSlice(teamId, sliceId, failed ? 'failed' : 'completed', { cleanup, endedAt: now() });
|
|
540
|
-
const fresh = get(teamId);
|
|
539
|
+
await state.writeSlice(teamId, sliceId, failed ? 'failed' : 'completed', { cleanup, endedAt: now() });
|
|
540
|
+
const fresh = await get(teamId);
|
|
541
541
|
const ended = fresh.plan.slices.every(s => fresh.slices[s.id]?.cleanup);
|
|
542
542
|
if (ended) {
|
|
543
543
|
const clean = fresh.plan.slices.every(s => fresh.slices[s.id]?.cleanup.removed);
|
|
544
|
-
state.writeTeam(teamId, 'completed', { removed: clean });
|
|
544
|
+
await state.writeTeam(teamId, 'completed', { removed: clean });
|
|
545
545
|
if (clean) { try { rmdirSync(join(worktreesRoot(record.projectPath), teamId)); } catch {} }
|
|
546
546
|
}
|
|
547
547
|
return { ok: true, ...cleanup };
|
|
@@ -555,7 +555,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
555
555
|
* @returns {Promise<{ ok: true, complete: boolean, removed: object[], kept: object[] } | { ok: false, code: string }>}
|
|
556
556
|
*/
|
|
557
557
|
async function remove(teamId, { discard = false, force = false, guarded = false, checkOnly = false } = {}) {
|
|
558
|
-
const record = get(teamId);
|
|
558
|
+
const record = await get(teamId);
|
|
559
559
|
if (!record) return refuse('TEAM_NOT_FOUND', `No team named "${teamId}" is recorded.`);
|
|
560
560
|
if (guarded && record.plan.readOnly) return refuse('TEAM_NOT_LANDED', 'Read-only teams cannot land.', { checks: [{ name: 'landed', ok: false, detail: 'Read-only team' }] });
|
|
561
561
|
if (record.plan.readOnly) {
|
|
@@ -659,7 +659,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
659
659
|
const pruned = await git(['worktree', 'prune'], { cwd: record.projectPath });
|
|
660
660
|
if (!pruned.ok) throw new Error(`Cleanup prune failed: ${gitSaid(pruned)}`);
|
|
661
661
|
try { rmdirSync(join(worktreesRoot(record.projectPath), teamId)); } catch (error) { if (error.code !== 'ENOENT' && error.code !== 'ENOTEMPTY') throw error; }
|
|
662
|
-
state.writeTeam(teamId, 'merged', { removed: true, removal: { at: now(), force: false, removed, kept: [] } });
|
|
662
|
+
await state.writeTeam(teamId, 'merged', { removed: true, removal: { at: now(), force: false, removed, kept: [] } });
|
|
663
663
|
return { ok: true, complete: true, removed, checks };
|
|
664
664
|
}
|
|
665
665
|
const registered = await listWorktrees(git, record.projectPath);
|
|
@@ -698,7 +698,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
698
698
|
const gone = await git(['worktree', 'remove', '--force', info.path], { cwd: record.projectPath });
|
|
699
699
|
if (!gone.ok && present(info.path)) {
|
|
700
700
|
if (info.registered) { kept.push({ sliceId, path: info.path, branch: info.branch, head: info.head, reason: 'worktree_not_removed', error: gitSaid(gone) }); continue; }
|
|
701
|
-
|
|
701
|
+
await rm(info.path, { recursive: true, force: true });
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
await git(['worktree', 'prune'], { cwd: record.projectPath });
|
|
@@ -712,11 +712,11 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
712
712
|
let folderRemoved = false;
|
|
713
713
|
try { rmdirSync(folder); folderRemoved = true; } catch { folderRemoved = !present(folder); }
|
|
714
714
|
const complete = kept.length === 0;
|
|
715
|
-
state.writeTeam(teamId, landed ? 'merged' : 'cancelled', {
|
|
715
|
+
await state.writeTeam(teamId, landed ? 'merged' : 'cancelled', {
|
|
716
716
|
removed: complete, removal: { at: now(), discard: !landed, force: !!force, removed, kept },
|
|
717
717
|
});
|
|
718
718
|
for (const slice of record.plan.slices) {
|
|
719
|
-
if (!landed && removed.some((each) => each.sliceId === slice.id) && sliceState(record, slice.id) !== 'integrated') state.writeSlice(teamId, slice.id, 'cancelled', { discarded: true });
|
|
719
|
+
if (!landed && removed.some((each) => each.sliceId === slice.id) && sliceState(record, slice.id) !== 'integrated') await state.writeSlice(teamId, slice.id, 'cancelled', { discarded: true });
|
|
720
720
|
}
|
|
721
721
|
return { ok: true, complete, landed, removed, kept, folderRemoved };
|
|
722
722
|
});
|
|
@@ -738,7 +738,7 @@ export function createTeamWorktrees({ state, git, locks, setup: defaultSetup = n
|
|
|
738
738
|
let names = [];
|
|
739
739
|
try { names = readdirSync(root); } catch { names = []; }
|
|
740
740
|
for (const name of names) {
|
|
741
|
-
if (!isTeamSlug(name) || !state.record(name)) continue;
|
|
741
|
+
if (!isTeamSlug(name) || !await state.record(name)) continue;
|
|
742
742
|
try { rmdirSync(join(root, name)); folders.push(join(root, name)); } catch { /* not empty: a team's worktrees are in it */ }
|
|
743
743
|
}
|
|
744
744
|
return { ok: result.ok, pruned: stale, folders, ...(result.ok ? {} : { error: gitSaid(result) }) };
|
|
@@ -1129,7 +1129,8 @@ export function createWhatsAppBridge({
|
|
|
1129
1129
|
if (d?.list && d?.stop && id) {
|
|
1130
1130
|
let runs = [];
|
|
1131
1131
|
try { runs = d.list({ assistantSessionId: id, activeOnly: true }) || []; } catch { runs = []; }
|
|
1132
|
-
|
|
1132
|
+
const stopProvenance = { actor: reason === 'phone' ? 'whatsapp_user' : 'whatsapp_service', action: 'stop' };
|
|
1133
|
+
for (const run of runs) { try { await d.stop(run.runId, reason === 'phone' ? 'user' : 'whatsapp_service', stopProvenance); stoppedRuns += 1; } catch {} }
|
|
1133
1134
|
}
|
|
1134
1135
|
for (const card of [...state.cards.values()]) {
|
|
1135
1136
|
if (card.sessionId !== id) continue;
|
|
@@ -1453,9 +1453,54 @@ export function confinementEvent(decision, { tool, confinement, provider = null
|
|
|
1453
1453
|
};
|
|
1454
1454
|
}
|
|
1455
1455
|
|
|
1456
|
-
|
|
1456
|
+
// A denial in a failed command's output. The bare word "sandbox" is not one (a test file can be named that).
|
|
1457
|
+
const CODEX_DENIAL = /operation not permitted|permission denied|read-only file system|EPERM|EACCES|EROFS|sandbox[^\n]{0,60}\b(?:den(?:y|ied)|refus\w*|block\w*|not allowed)|\b(?:den(?:y|ied)|refus\w*|block\w*|not allowed)\b[^\n]{0,60}sandbox/i;
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* What a guarded Codex run records about a command that already finished (item.completed command_execution), or
|
|
1461
|
+
* null. SynaBun has no check before a Codex command runs, so this never reuses a decision's reason, which is written
|
|
1462
|
+
* for a real pre-execution refusal ("so it did not run"). Actions: `noted` (enforce: it ran, the heuristic objected,
|
|
1463
|
+
* the sandbox is the boundary), `warned` (warn: the same), `refused` (the sandbox denied an operation; the process
|
|
1464
|
+
* did start).
|
|
1465
|
+
*/
|
|
1466
|
+
export function codexCommandEvent(item, confinement) {
|
|
1467
|
+
const command = typeof item?.command === 'string' ? item.command : Array.isArray(item?.command) ? item.command.join(' ') : '';
|
|
1468
|
+
if (!command) return null;
|
|
1469
|
+
const decision = workerShellDecision(command, confinement);
|
|
1470
|
+
const denied = Number(item.exit_code) !== 0 && CODEX_DENIAL.test(String(item.aggregated_output || item.output || ''));
|
|
1471
|
+
if (!decision && !denied) return null;
|
|
1472
|
+
const exit = Number.isInteger(item.exit_code) ? item.exit_code : null;
|
|
1473
|
+
const shown = `Command: ${command.slice(0, 160)}`;
|
|
1474
|
+
let action;
|
|
1475
|
+
let reason;
|
|
1476
|
+
if (denied) {
|
|
1477
|
+
action = 'refused';
|
|
1478
|
+
const scope = !confinement.enforced ? 'Warn mode does not change Codex\'s own sandbox.'
|
|
1479
|
+
: confinement.capability === 'read-only' ? 'This run (capability read-only) writes nothing, the temp folder included.'
|
|
1480
|
+
: `This run (capability ${confinement.capability}) writes inside ${confinement.writable.join(', ')} only.`;
|
|
1481
|
+
reason = `Codex's sandbox refused an operation${exit === null ? '' : `; the command started and exited ${exit}`}. ${scope} ${shown}`;
|
|
1482
|
+
} else {
|
|
1483
|
+
const ran = exit === null ? 'Codex finished the command without an exit code.' : `The command ran (exit ${exit}).`;
|
|
1484
|
+
action = confinement.enforced ? 'noted' : 'warned';
|
|
1485
|
+
reason = confinement.enforced
|
|
1486
|
+
? `${ran} SynaBun's shell check flagged it afterwards and could not stop it: on Codex the sandbox is the boundary. ${shown}`
|
|
1487
|
+
: `${ran} Warn mode: SynaBun's shell check flagged it afterwards and stopped nothing. ${shown}`;
|
|
1488
|
+
}
|
|
1489
|
+
return {
|
|
1490
|
+
type: 'synabun.confinement',
|
|
1491
|
+
action,
|
|
1492
|
+
capability: confinement.capability,
|
|
1493
|
+
tool: 'shell',
|
|
1494
|
+
rule: decision?.rule || 'sandbox',
|
|
1495
|
+
reason,
|
|
1496
|
+
...(decision?.target ? { target: decision.target } : {}),
|
|
1497
|
+
provider: 'codex',
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/** One line for a transcript tail. `noted` is a command that already ran: never "refused". */
|
|
1457
1502
|
export function describeConfinementEvent(event) {
|
|
1458
|
-
const verb = event?.action === 'warned' ? 'guard warning' : 'refused';
|
|
1503
|
+
const verb = event?.action === 'warned' ? 'guard warning' : event?.action === 'noted' ? 'guard note' : 'refused';
|
|
1459
1504
|
return `${verb}: ${event?.tool || 'tool'}${event?.target ? ` → ${event.target}` : ''} (${event?.rule || 'rule'}) ${String(event?.reason || '').slice(0, 200)}`;
|
|
1460
1505
|
}
|
|
1461
1506
|
|
|
@@ -33,6 +33,7 @@ import express from 'express';
|
|
|
33
33
|
import net from 'node:net';
|
|
34
34
|
import { randomUUID } from 'node:crypto';
|
|
35
35
|
import { isAutomationBrowserRoute } from './browser-automation-routes.js';
|
|
36
|
+
import { markActivity } from './loop-stall.js';
|
|
36
37
|
|
|
37
38
|
// The only Neural-Interface API a sandboxed worker's stdio MCP child (OpenCode) may reach through the channel: the
|
|
38
39
|
// browser routes its browser tools call over HTTP to NEURAL_INTERFACE_URL, exactly (lib/browser-automation-routes.js:
|
|
@@ -160,6 +161,7 @@ export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetch
|
|
|
160
161
|
});
|
|
161
162
|
// Everything the channel serves is under /w/:token/mcp; the run is pinned from the token and authority is stripped.
|
|
162
163
|
app.use('/w/:token/mcp', (req, res, next) => {
|
|
164
|
+
markActivity('mcp:worker-request');
|
|
163
165
|
const runId = tokenToRun.get(String(req.params.token || ''));
|
|
164
166
|
if (!runId) return res.status(404).json({ jsonrpc: '2.0', error: { code: -32001, message: 'Unknown worker channel' }, id: null });
|
|
165
167
|
req.headers['x-synabun-terminal'] = runId; // the worker's identity is its own run, never what it claims
|
|
@@ -88,6 +88,11 @@ export function resumeRefusal(entry, { now = Date.now(), workLeftMs = Infinity,
|
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/** The CLI refused to resume because it saved no conversation under that session id (a run cut off very early). */
|
|
92
|
+
export function isMissingConversationError(error) {
|
|
93
|
+
return /No conversation found with session ID/i.test(String(error?.message || error || ''));
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
/** Whether `path` is `root` or inside it (both resolved; a missing path is compared as written). */
|
|
92
97
|
export function isInside(path, root) {
|
|
93
98
|
if (!path || !root) return false;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Who asked a run to stop, and whether that request may end a run a server restart suspended.
|
|
2
|
+
// The request guards identify the caller. The page may describe its control, but neither its JSON nor a legacy reason
|
|
3
|
+
// string identifies a person: `reason: 'user'` is recorded only for a control a person operates (personAskedToStop).
|
|
4
|
+
|
|
5
|
+
const PERSON_PAGE_ACTIONS = new Set(['stop', 'tab_close']);
|
|
6
|
+
|
|
7
|
+
export function pageStopProvenance(action, verified) {
|
|
8
|
+
return {
|
|
9
|
+
actor: verified ? 'page' : 'unknown',
|
|
10
|
+
action: ['stop', 'tab_close', 'tray_auto_close'].includes(action) ? action : 'unknown',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function assistantStopProvenance(caller, action) {
|
|
15
|
+
if (caller.credentialed) {
|
|
16
|
+
return { actor: 'assistant', action: 'agent_stop', assistantSessionId: caller.assistantSessionId };
|
|
17
|
+
}
|
|
18
|
+
return pageStopProvenance(action, caller.verifiedPage);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// What SynaBun itself ends a run for. A reason that is not here names no caller: it is recorded as unknown.
|
|
22
|
+
const SYSTEM_STOPS = Object.freeze({
|
|
23
|
+
server_restart: ['server', 'shutdown'],
|
|
24
|
+
server_shutdown: ['server', 'shutdown'],
|
|
25
|
+
resume_failed: ['server', 'resume_failed'],
|
|
26
|
+
state_removed: ['server', 'state_file'],
|
|
27
|
+
state_inactive: ['server', 'state_file'],
|
|
28
|
+
time_cap: ['limit', 'time_cap'],
|
|
29
|
+
max_turns: ['limit', 'max_turns'],
|
|
30
|
+
idle_timeout: ['limit', 'idle_timeout'],
|
|
31
|
+
budget_cap: ['budget', 'budget_cap'],
|
|
32
|
+
session_budget_cap: ['budget', 'session_budget_cap'],
|
|
33
|
+
budget_share: ['budget', 'budget_share'],
|
|
34
|
+
budget_unpriced: ['budget', 'budget_unpriced'],
|
|
35
|
+
assistant: ['assistant', 'stop'],
|
|
36
|
+
complete: ['assistant', 'agent_complete'],
|
|
37
|
+
remote_policy: ['policy', 'remote_policy'],
|
|
38
|
+
desktop_stop: ['desktop', 'stop_control'],
|
|
39
|
+
team_replaced: ['team', 'replace'],
|
|
40
|
+
team_discarded: ['team', 'discard'],
|
|
41
|
+
cancelled: ['system', 'cancelled'],
|
|
42
|
+
whatsapp_service: ['whatsapp_service', 'stop'],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/** The actor and action of a stop SynaBun made for `reason`, or null when the reason names no caller. */
|
|
46
|
+
export function systemStopProvenance(reason) {
|
|
47
|
+
const known = Object.hasOwn(SYSTEM_STOPS, String(reason)) ? SYSTEM_STOPS[reason] : null;
|
|
48
|
+
return known ? { actor: known[0], action: known[1] } : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What is recorded for a stop: the proven caller, else what `reason` says, else unknown; always with its time. */
|
|
52
|
+
export function stampStopProvenance(reason, provenance, at) {
|
|
53
|
+
const base = provenance || systemStopProvenance(reason) || { actor: 'unknown', action: String(reason || 'unknown').slice(0, 64) };
|
|
54
|
+
return { ...base, at: base.at || at };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A person operated the control: the owner's page (Stop, a tab's X) or the owner's phone. */
|
|
58
|
+
export function personAskedToStop(provenance) {
|
|
59
|
+
if (provenance?.actor === 'whatsapp_user') return provenance.action === 'stop';
|
|
60
|
+
return provenance?.actor === 'page' && PERSON_PAGE_ACTIONS.has(provenance.action);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The reason a stop through a page or by a run itself is recorded under. */
|
|
64
|
+
export function callerStopReason(provenance) {
|
|
65
|
+
if (personAskedToStop(provenance)) return 'user';
|
|
66
|
+
if (provenance?.actor === 'automation' && provenance.action === 'self_stop') return 'self_stop';
|
|
67
|
+
if (provenance?.action === 'tray_auto_close') return 'tray_auto_close';
|
|
68
|
+
return 'unknown';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether this request may end a run suspended for a server restart. That run has no process, so it cannot stop
|
|
73
|
+
* itself: an exit hook of its old CLI, an unidentified caller, a page that names no control, the tray's timer and the
|
|
74
|
+
* shutdown itself never end it. A person, the Assistant and a limit or policy of SynaBun's do.
|
|
75
|
+
*/
|
|
76
|
+
export function mayEndSuspendedRun(provenance) {
|
|
77
|
+
if (!provenance) return false;
|
|
78
|
+
if (['unknown', 'automation', 'server'].includes(provenance.actor)) return false;
|
|
79
|
+
if (provenance.actor === 'page') return PERSON_PAGE_ACTIONS.has(provenance.action);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The reason a run ended by a server shutdown is recorded under, whatever the shutdown was called. */
|
|
84
|
+
export function shutdownStopReason(reason) {
|
|
85
|
+
return reason === 'restart' || reason === 'server_restart' ? 'server_restart' : 'server_shutdown';
|
|
86
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neural-memory-interface",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "neural-memory-interface",
|
|
9
|
-
"version": "2.4.
|
|
9
|
+
"version": "2.4.2",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"dependencies": {
|