synabun 2.4.3 → 2.4.5
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 +36 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +66 -36
- package/docs/whatsapp.md +3 -3
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +8 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +2 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +4 -0
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/memory-client.d.ts +5 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-client.js +21 -2
- package/mcp-server/dist/services/memory-client.js.map +1 -1
- package/mcp-server/dist/services/memory-writer.d.ts +3 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-writer.js +7 -1
- package/mcp-server/dist/services/memory-writer.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +12 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +68 -17
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +260 -8
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +19 -4
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +85 -17
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +113 -27
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
- package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-readers.js +17 -0
- package/mcp-server/dist/tools/browser-readers.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -1
- package/mcp-server/dist/tools/remember.js +6 -2
- package/mcp-server/dist/tools/remember.js.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.js +25 -20
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +7 -3
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.js +5 -3
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
- package/mcp-server/dist/tools/youtube/playlist.js +2 -2
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
- package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/readers.js +15 -0
- package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +8 -1
- package/mcp-server/src/services/identity.ts +5 -0
- package/mcp-server/src/services/memory-client.ts +32 -12
- package/mcp-server/src/services/memory-writer.ts +5 -2
- package/mcp-server/src/services/neural-interface.ts +67 -19
- package/mcp-server/src/services/typesafe-config.ts +268 -7
- package/mcp-server/src/tools/agents.ts +79 -17
- package/mcp-server/src/tools/browser-observe.ts +117 -28
- package/mcp-server/src/tools/browser-readers.ts +19 -0
- package/mcp-server/src/tools/remember.ts +6 -1
- package/mcp-server/src/tools/youtube/analytics.ts +26 -28
- package/mcp-server/src/tools/youtube/helpers.ts +8 -2
- package/mcp-server/src/tools/youtube/navigate.ts +6 -7
- package/mcp-server/src/tools/youtube/playlist.ts +2 -2
- package/mcp-server/src/tools/youtube/readers.ts +15 -0
- package/neural-interface/i18n/en.json +487 -8
- package/neural-interface/i18n/pt-BR.json +487 -8
- package/neural-interface/lib/agents-studio-api.js +7 -2
- package/neural-interface/lib/antigravity/home.js +43 -8
- package/neural-interface/lib/antigravity/tool-call.js +14 -0
- package/neural-interface/lib/assistant-api.js +90 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +4 -2
- package/neural-interface/lib/assistant-brains/claude.js +10 -0
- package/neural-interface/lib/assistant-dispatch.js +276 -42
- package/neural-interface/lib/assistant-memory.js +3 -1
- package/neural-interface/lib/assistant-persona.js +14 -3
- package/neural-interface/lib/assistant-route-gate.js +11 -2
- package/neural-interface/lib/assistant-router.js +18 -8
- package/neural-interface/lib/assistant-runtime.js +103 -6
- package/neural-interface/lib/assistant-spilled-output.js +53 -0
- package/neural-interface/lib/assistant-task-prompt.js +15 -2
- package/neural-interface/lib/browser-connection-state.js +20 -0
- package/neural-interface/lib/browser-default.js +22 -2
- package/neural-interface/lib/browser-extension-adapter.js +221 -15
- package/neural-interface/lib/browser-extension-bridge.js +89 -9
- package/neural-interface/lib/browser-extension-folder.js +50 -11
- package/neural-interface/lib/browser-extension-package.js +6 -5
- package/neural-interface/lib/browser-extension-pin.json +15 -13
- package/neural-interface/lib/browser-extension-protocol.js +141 -14
- package/neural-interface/lib/browser-extension-setup.js +210 -40
- package/neural-interface/lib/browser-extension-update.js +104 -0
- package/neural-interface/lib/browser-extraction.js +38 -14
- package/neural-interface/lib/claude-bg-tasks.js +183 -0
- package/neural-interface/lib/claude-history.js +12 -1
- package/neural-interface/lib/confined-fs.js +25 -0
- package/neural-interface/lib/coordination/operations.js +2 -0
- package/neural-interface/lib/db.js +39 -16
- package/neural-interface/lib/editor-completion-opencode.js +2 -2
- package/neural-interface/lib/git-bash/manager.js +28 -3
- package/neural-interface/lib/git-status-runner.js +31 -3
- package/neural-interface/lib/loop-inventory.js +162 -0
- package/neural-interface/lib/loop-stall.js +74 -4
- package/neural-interface/lib/memory-session-capture.js +157 -66
- package/neural-interface/lib/native-loop-providers.js +73 -13
- package/neural-interface/lib/native-loop-runtime.js +3 -0
- package/neural-interface/lib/opencode-protocol.js +4 -2
- package/neural-interface/lib/peer-identity.js +62 -16
- package/neural-interface/lib/remote-policy.js +24 -7
- package/neural-interface/lib/session-cache-builder.js +66 -18
- package/neural-interface/lib/session-capture-gate.js +42 -0
- package/neural-interface/lib/session-indexer.js +28 -20
- package/neural-interface/lib/teams/README.md +22 -1
- package/neural-interface/lib/teams/api.js +79 -6
- package/neural-interface/lib/teams/index.js +2 -0
- package/neural-interface/lib/teams/recovery.js +68 -0
- package/neural-interface/lib/teams/scheduler.js +352 -31
- package/neural-interface/lib/teams/worktrees.js +123 -30
- package/neural-interface/lib/ui-blob-api.js +14 -5
- package/neural-interface/lib/ui-blob-store.js +302 -39
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +7 -2
- package/neural-interface/public/shared/agents/studio/ax-api.js +16 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +318 -13
- package/neural-interface/public/shared/agents/studio/ax-teams.js +141 -9
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
- package/neural-interface/public/shared/assistant/asst-api.js +42 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
- package/neural-interface/public/shared/assistant/asst-panel.js +285 -10
- package/neural-interface/public/shared/assistant/asst-render.js +205 -4
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
- package/neural-interface/public/shared/assistant/asst-state.js +241 -2
- package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +20 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
- package/neural-interface/public/shared/browser-extension-updates.js +90 -0
- package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +41 -15
- package/neural-interface/public/shared/extension-setup/es-view.js +51 -11
- package/neural-interface/public/shared/extension-update-view.js +34 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +8 -4
- package/neural-interface/public/shared/settings/settings-ai-browser.js +23 -3
- package/neural-interface/public/shared/settings/settings-browser-extension.js +581 -197
- package/neural-interface/public/shared/settings/settings-extension-diagrams.js +116 -0
- package/neural-interface/public/shared/settings/settings-extension-guide.js +222 -0
- package/neural-interface/public/shared/settings/settings-extension-update.js +114 -0
- package/neural-interface/public/shared/settings/settings-ia.js +2 -2
- package/neural-interface/public/shared/settings/settings-shell.js +5 -0
- package/neural-interface/public/shared/styles.css +200 -13
- package/neural-interface/public/shared/ui-claude-panel.js +110 -1
- package/neural-interface/public/shared/ui-notifications.js +23 -4
- package/neural-interface/public/shared/ui-settings-entry.js +6 -0
- package/neural-interface/public/shared/ui-settings.js +48 -11
- package/neural-interface/public/shared/ui-tray-columns.js +9 -2
- package/neural-interface/public/shared/worker-end.js +18 -0
- package/neural-interface/scripts/patch-node-pty.mjs +151 -0
- package/neural-interface/scripts/rebuild-pty.js +10 -0
- package/neural-interface/server.js +503 -281
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -30,6 +30,8 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, st
|
|
|
30
30
|
import { homedir } from 'node:os';
|
|
31
31
|
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
32
32
|
import { createHash } from 'node:crypto';
|
|
33
|
+
import { fileURLToPath } from 'node:url';
|
|
34
|
+
import { ownSpilledFile } from '../assistant-spilled-output.js';
|
|
33
35
|
|
|
34
36
|
/** The settings keys of the user's own Antigravity settings a SynaBun home keeps: how they sign in and which models they get. */
|
|
35
37
|
export const KEPT_USER_SETTINGS = Object.freeze(['modelProvider', 'customModelsConfig', 'gcp', 'useG1Credits']);
|
|
@@ -242,19 +244,52 @@ export function assertSafeAntigravityProject(cwd) {
|
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
// A tool output Antigravity cuts short in the model's context is written whole to
|
|
248
|
+
// <App Data Dir>/brain/<conversation>/.system_generated/steps/<n>/output.txt, and the model is told to read it there
|
|
249
|
+
// ("The tool's output was truncated due to being too long. You can find the full output in a file at file://…").
|
|
250
|
+
// Measured on agy 1.4.12: outputs above about 10 KB (a SynaBun recall, agent_list or agent_dispatch among them).
|
|
251
|
+
const SPILLED_OUTPUT_RE = /^antigravity-cli[\\/]brain[\\/][A-Za-z0-9_-]{1,128}[\\/]\.system_generated[\\/]steps[\\/]\d{1,9}[\\/]output\.txt$/;
|
|
252
|
+
const SCHEMA_RE = /^antigravity-cli[\\/]mcp[\\/][^\\/]+[\\/][^\\/]+\.json$/;
|
|
253
|
+
|
|
254
|
+
/** Every path a call names, absolute: `~`, `$HOME` and `file://` URLs read as the model meant them, the rest from cwd. */
|
|
255
|
+
function homeCallPaths(call, cwd) {
|
|
256
|
+
return acpToolPaths(call).map((raw) => {
|
|
251
257
|
const path = raw.trim();
|
|
252
258
|
if (path === '~' || path.startsWith('~/')) return resolve(homedir(), path.slice(2));
|
|
253
259
|
if (/^\$\{?HOME\}?(\/|$)/.test(path)) return resolve(homedir(), path.replace(/^\$\{?HOME\}?\/?/, ''));
|
|
260
|
+
if (/^file:\/\//i.test(path)) { try { return resolve(fileURLToPath(path)); } catch { /* not a local file URL: read as written */ } }
|
|
254
261
|
return resolve(cwd || process.cwd(), path);
|
|
255
262
|
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Whether `path` is one of the home's own spilled tool outputs: exactly the shape above, a regular file with one name
|
|
267
|
+
* (no hard link), and no symbolic link between the home and the file (its real path is that path under the home's
|
|
268
|
+
* real path). Anything else, a missing file included, is not.
|
|
269
|
+
*/
|
|
270
|
+
export function isAntigravitySpilledOutput(path, homeDir) {
|
|
271
|
+
return ownSpilledFile(path, homeDir, SPILLED_OUTPUT_RE);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Whether a call only reads the home's own spilled tool outputs (every path it names is one). The route gate lets
|
|
276
|
+
* it through: the file holds the output of a tool the model already ran, and an unrouted turn runs only the
|
|
277
|
+
* always-allowed ones.
|
|
278
|
+
*/
|
|
279
|
+
export function antigravitySpilledOutputRead(call, { homeDir, cwd } = {}) {
|
|
280
|
+
if (!homeDir || !call || call.mcp || (call.kind !== 'read' && call.kind !== 'search')) return false;
|
|
281
|
+
const paths = homeCallPaths(call, cwd);
|
|
282
|
+
return paths.length > 0 && paths.every((path) => isAntigravitySpilledOutput(path, homeDir));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** The only automatic reads in a managed home are MCP tool schemas and the tool outputs Antigravity spilled there.
|
|
286
|
+
* Config/settings copy credentials. null for a call outside the home; deny mixed reads so a safe file cannot mask another.
|
|
287
|
+
*/
|
|
288
|
+
export function antigravityHomeReadPolicy(call, { homeDir, cwd } = {}) {
|
|
289
|
+
if (!homeDir || !acpReadOnlyKind(call.kind)) return null;
|
|
290
|
+
const paths = homeCallPaths(call, cwd);
|
|
256
291
|
const inside = (path) => { const rel = relative(resolve(homeDir), path); return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel)); };
|
|
257
292
|
if (!paths.some(inside)) return null;
|
|
258
|
-
if (paths.every((path) => inside(path) &&
|
|
259
|
-
return { decision: 'deny', reason: 'SynaBun refuses reads of its Antigravity home configuration: it can contain MCP credentials and sign-in settings. Only tool schemas may be read here.' };
|
|
293
|
+
if (paths.every((path) => inside(path) && (SCHEMA_RE.test(relative(resolve(homeDir), path)) || isAntigravitySpilledOutput(path, homeDir)))) return { decision: 'allow' };
|
|
294
|
+
return { decision: 'deny', reason: 'SynaBun refuses reads of its Antigravity home configuration: it can contain MCP credentials and sign-in settings. Only tool schemas and the tool outputs Antigravity saved under brain/<conversation>/.system_generated/steps/ may be read here.' };
|
|
260
295
|
}
|
|
@@ -129,9 +129,23 @@ export function acpWebTool(value) {
|
|
|
129
129
|
return WEB_TOOLS.has(named) || /^browser_/.test(named) || (!named && call.kind === 'fetch');
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* A path as agy may write it: its transcript keeps arguments JSON-encoded ("\"/Users/…/output.txt\""), so a value
|
|
134
|
+
* that is a JSON string literal is read as the string it encodes; anything else as written.
|
|
135
|
+
*/
|
|
136
|
+
function unquotedPath(value) {
|
|
137
|
+
const path = String(value).trim();
|
|
138
|
+
if (path.length < 2 || path[0] !== '"' || path[path.length - 1] !== '"') return path;
|
|
139
|
+
try { const inner = JSON.parse(path); return typeof inner === 'string' ? inner.trim() : path; } catch { return path; }
|
|
140
|
+
}
|
|
141
|
+
|
|
132
142
|
/** Every path the call names, including nested path-like values in an MCP call's arguments. */
|
|
133
143
|
export function acpToolPaths(value) {
|
|
134
144
|
const call = value?.args && 'mcp' in value ? value : acpCall(value);
|
|
145
|
+
return [...new Set(rawToolPaths(call).map(unquotedPath).filter(Boolean))];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function rawToolPaths(call) {
|
|
135
149
|
const out = [];
|
|
136
150
|
for (const location of call.locations) if (typeof location?.path === 'string' && location.path) out.push(location.path);
|
|
137
151
|
if (call.mcp) {
|
|
@@ -171,6 +171,9 @@ export function createAssistantApi({
|
|
|
171
171
|
// The page secret (lib/page-session.js): a request without an agent pin is the owner's page only when it carries
|
|
172
172
|
// this boot's cookie; a local process that merely sends no headers is nobody (never 'ui').
|
|
173
173
|
pageSession = null,
|
|
174
|
+
// The Background tasks view of a Claude brain: lib/claude-bg-tasks.js over the brain's own transcript
|
|
175
|
+
// ({ list(identity), output(identity, q) } built in server.js). None: those routes answer 404.
|
|
176
|
+
backgroundTasks = null,
|
|
174
177
|
// Whether a pin counts (lib/terminal-tokens.js verdict, server.js): (pin, req) → { accepted, code, error, httpStatus }.
|
|
175
178
|
// A pin SynaBun gave a proof to (a run's terminal token, a brain's launch credential) counts only with it: a request
|
|
176
179
|
// that names a worker's run, or a brain's id, without it is refused (403 TERMINAL_TOKEN_REQUIRED / _INVALID) instead
|
|
@@ -1046,6 +1049,43 @@ export function createAssistantApi({
|
|
|
1046
1049
|
res.json(await dispatcher.sendTurn(req.params.runId, body.text ?? body.message, { origin, queue: body.queue !== false }));
|
|
1047
1050
|
} catch (error) { sendError(res, error); }
|
|
1048
1051
|
});
|
|
1052
|
+
// Steer: the user changed work in flight. With runId, that run's current turn is interrupted and the steer follows
|
|
1053
|
+
// (dispatcher.steerRun; the run must be this session's); without, the session's own brain is steered (the page only:
|
|
1054
|
+
// a brain never steers itself). → { ok, target: { kind, runId? }, interruptedTurn }.
|
|
1055
|
+
router.post('/steer', orchestrationGuard, async (req, res) => {
|
|
1056
|
+
try {
|
|
1057
|
+
const body = req.body || {};
|
|
1058
|
+
const caller = req.assistantCaller;
|
|
1059
|
+
const text = typeof body.text === 'string' ? body.text.trim() : '';
|
|
1060
|
+
if (!text) return res.status(400).json({ ok: false, code: 'MESSAGE_REQUIRED', error: 'text is required' });
|
|
1061
|
+
const runId = typeof (body.runId ?? body.run_id) === 'string' ? String(body.runId ?? body.run_id).trim() : '';
|
|
1062
|
+
// A brain's session is the one its credential proves, whatever the body says.
|
|
1063
|
+
const sessionId = caller.credentialed ? (caller.assistantSessionId || null) : (body.assistantSessionId || body.assistant_session_id || null);
|
|
1064
|
+
if (runId) {
|
|
1065
|
+
const run = dispatcher.get(runId);
|
|
1066
|
+
if (!run) return res.status(404).json({ ok: false, code: 'RUN_NOT_FOUND', error: `Unknown run ${runId}` });
|
|
1067
|
+
if (!sessionId && caller.kind !== 'ui') return res.status(404).json({ ok: false, code: 'SESSION_NOT_FOUND', error: 'The caller has no assistant session.' });
|
|
1068
|
+
if (sessionId && String(run.assistantSessionId || '') !== String(sessionId)) {
|
|
1069
|
+
return res.status(404).json({ ok: false, code: 'RUN_NOT_FOUND', error: `Run ${runId} does not belong to assistant session ${sessionId}` });
|
|
1070
|
+
}
|
|
1071
|
+
if (planRefusal(req, res, sessionId, 'steer a worker')) return;
|
|
1072
|
+
if (planState(req, sessionId) === 'plan' && planSendRefusal(res, run)) return;
|
|
1073
|
+
const from = caller.kind === 'ui' ? 'user' : 'assistant';
|
|
1074
|
+
try { await dispatcher.coverFollowUp?.(runId); } catch { /* steerRun decides */ }
|
|
1075
|
+
const steered = await dispatcher.steerRun(runId, text, { from, assistantSessionId: sessionId });
|
|
1076
|
+
return res.json({ ok: true, target: steered.target, interruptedTurn: steered.interruptedTurn, followUpId: steered.followUpId, run: steered.run });
|
|
1077
|
+
}
|
|
1078
|
+
if (caller.kind !== 'ui') return res.status(403).json({ ok: false, code: 'UI_ONLY', error: 'Only the user\'s page steers the Assistant itself; a brain steers a worker with runId.' });
|
|
1079
|
+
if (!sessionId) return res.status(400).json({ ok: false, code: 'SESSION_REQUIRED', error: 'assistantSessionId is required' });
|
|
1080
|
+
if (typeof runtime?.steerBrain !== 'function') return res.status(503).json({ ok: false, code: 'STEER_UNAVAILABLE', error: 'This server cannot steer the Assistant yet; restart it.' });
|
|
1081
|
+
const out = await runtime.steerBrain(String(sessionId), { text, origin: 'ui' });
|
|
1082
|
+
if (!out?.ok) {
|
|
1083
|
+
const status = out?.code === 'SESSION_NOT_FOUND' ? 404 : out?.code === 'MESSAGE_REQUIRED' ? 400 : 409;
|
|
1084
|
+
return res.status(status).json({ ok: false, code: out?.code || 'STEER_FAILED', error: out?.message || 'The steer did not reach the Assistant.', interruptedTurn: !!out?.interruptedTurn });
|
|
1085
|
+
}
|
|
1086
|
+
res.json({ ok: true, target: { kind: 'brain' }, interruptedTurn: !!out.interruptedTurn });
|
|
1087
|
+
} catch (error) { sendError(res, error); }
|
|
1088
|
+
});
|
|
1049
1089
|
router.post('/runs/:runId/permission', orchestrationGuard, (req, res) => {
|
|
1050
1090
|
try {
|
|
1051
1091
|
const body = req.body || {};
|
|
@@ -1202,6 +1242,56 @@ export function createAssistantApi({
|
|
|
1202
1242
|
res.json({ ok: true, ...page.data });
|
|
1203
1243
|
} catch (error) { sendError(res, error); }
|
|
1204
1244
|
});
|
|
1245
|
+
// The background shells and watches of a session's Claude brain (the panel's Background tasks view), a page of
|
|
1246
|
+
// what one printed, and the owner's Stop. The same reader as a command's output (shellReader): the owner's page
|
|
1247
|
+
// alone, never a brain, a worker or the automation browser. The brain named in the path is the one asked, and its
|
|
1248
|
+
// transcript is the only one read (lib/claude-bg-tasks.js: only the file it reported for a task it ran).
|
|
1249
|
+
const bgTaskId = (value) => (/^[A-Za-z0-9_-]{1,128}$/.test(String(value || '')) ? String(value) : '');
|
|
1250
|
+
function bgSource(req, res) {
|
|
1251
|
+
if (!requireRuntime(res) || !shellReader(req, res)) return null;
|
|
1252
|
+
const source = typeof runtime.backgroundTaskSource === 'function' ? runtime.backgroundTaskSource(req.params.id) : null;
|
|
1253
|
+
if (source === null && typeof runtime.getSession === 'function' && !runtime.getSession(req.params.id, { transcript: false })) {
|
|
1254
|
+
res.status(404).json({ ok: false, code: 'SESSION_NOT_FOUND', error: `Unknown assistant session ${req.params.id}` });
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
if (!source || !backgroundTasks) { res.json({ ok: true, tasks: [], live: null, supported: false }); return null; }
|
|
1258
|
+
return source;
|
|
1259
|
+
}
|
|
1260
|
+
router.get('/sessions/:id/background-tasks', noStore, (req, res) => {
|
|
1261
|
+
const source = bgSource(req, res);
|
|
1262
|
+
if (!source) return;
|
|
1263
|
+
try {
|
|
1264
|
+
const listed = backgroundTasks.list(source);
|
|
1265
|
+
res.json({ ok: true, supported: true, tasks: listed?.tasks || [], live: Array.isArray(source.live) ? source.live : null });
|
|
1266
|
+
} catch (error) {
|
|
1267
|
+
if (Number(error?.status) === 404) return res.json({ ok: true, supported: true, tasks: [], live: Array.isArray(source.live) ? source.live : null });
|
|
1268
|
+
sendError(res, error);
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
router.get('/sessions/:id/background-tasks/:taskId/output', noStore, async (req, res) => {
|
|
1272
|
+
const taskId = bgTaskId(req.params.taskId);
|
|
1273
|
+
if (!taskId) { if (requireRuntime(res) && shellReader(req, res)) res.status(400).json({ ok: false, code: 'TASK_ID_INVALID', error: 'That is not a background task of this conversation.' }); return; }
|
|
1274
|
+
const source = bgSource(req, res);
|
|
1275
|
+
if (!source) return;
|
|
1276
|
+
const number = (value) => (typeof value === 'string' && /^\d{1,15}$/.test(value) ? Number(value) : undefined);
|
|
1277
|
+
try {
|
|
1278
|
+
const running = Array.isArray(source.live) ? source.live.some((t) => t.task_id === taskId) : null;
|
|
1279
|
+
const page = await backgroundTasks.output(source, { taskId, cursor: number(req.query.cursor), tail: number(req.query.tail), limit: number(req.query.limit), running });
|
|
1280
|
+
if (!page || page.ok === false) return res.status(Number(page?.status) >= 400 ? Number(page.status) : 502).json({ ok: false, code: page?.code || 'OUTPUT_FAILED', error: page?.error || 'The output could not be read.' });
|
|
1281
|
+
res.json({ ok: true, ...page.data });
|
|
1282
|
+
} catch (error) { sendError(res, error); }
|
|
1283
|
+
});
|
|
1284
|
+
router.post('/sessions/:id/background-tasks/:taskId/stop', noStore, async (req, res) => {
|
|
1285
|
+
if (!requireRuntime(res) || !shellReader(req, res)) return;
|
|
1286
|
+
const taskId = bgTaskId(req.params.taskId);
|
|
1287
|
+
if (!taskId) return res.status(400).json({ ok: false, code: 'TASK_ID_INVALID', error: 'That is not a background task of this conversation.' });
|
|
1288
|
+
if (typeof runtime.stopBackgroundTask !== 'function') return res.status(404).json({ ok: false, code: 'NOT_SUPPORTED', error: 'Stopping a background task needs the SynaBun server restart.' });
|
|
1289
|
+
try {
|
|
1290
|
+
const out = await runtime.stopBackgroundTask(req.params.id, taskId);
|
|
1291
|
+
if (!out || out.ok === false) return res.status(Number(out?.status) >= 400 ? Number(out.status) : 409).json({ ok: false, code: out?.code || 'STOP_FAILED', error: out?.error || 'The task could not be stopped.' });
|
|
1292
|
+
res.json({ ok: true, taskId });
|
|
1293
|
+
} catch (error) { sendError(res, error); }
|
|
1294
|
+
});
|
|
1205
1295
|
router.get('/sessions/:id', (req, res) => {
|
|
1206
1296
|
if (!requireRuntime(res)) return;
|
|
1207
1297
|
const session = runtime.getSession(req.params.id, { transcript: req.query.transcript !== '0', limit: clampInt(req.query.limit, 1, 2000, 400) });
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { randomUUID } from 'node:crypto';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
20
|
import { acpErrorInfo, createAcpConnection, isAuthRequired } from '../antigravity/acp-connection.js';
|
|
21
|
-
import { assertSafeAntigravityProject, antigravityHomeReadPolicy, antigravityHomeSettings, homeMcpTools, policyHookCommand, prepareAntigravityHome, toAntigravityMcpEntry, userAntigravityMcpServers, userAntigravitySettings, userGeminiDir } from '../antigravity/home.js';
|
|
21
|
+
import { assertSafeAntigravityProject, antigravityHomeReadPolicy, antigravityHomeSettings, antigravitySpilledOutputRead, homeMcpTools, policyHookCommand, prepareAntigravityHome, toAntigravityMcpEntry, userAntigravityMcpServers, userAntigravitySettings, userGeminiDir } from '../antigravity/home.js';
|
|
22
22
|
import { acpCall, acpReadOnlyKind, acpToolPaths, acpUiToolName } from '../antigravity/tool-call.js';
|
|
23
23
|
import { splitAntigravityModel } from '../antigravity/catalog.js';
|
|
24
24
|
import { acpTurnUsage } from '../antigravity/usage.js';
|
|
@@ -130,7 +130,9 @@ export function createAntigravityBrain({ session, sink, deps = {}, persona = ''
|
|
|
130
130
|
*/
|
|
131
131
|
function policyCheck(call) {
|
|
132
132
|
let verdict = null;
|
|
133
|
-
|
|
133
|
+
// A read of a tool output Antigravity spilled into this brain's home: the route gate lets it through (the runtime's other checks still apply).
|
|
134
|
+
const spilledOutput = antigravitySpilledOutputRead(call, { homeDir, cwd });
|
|
135
|
+
try { verdict = typeof deps.policyCheck === 'function' ? deps.policyCheck(call, { spilledOutput }) : null; } catch (error) { return { decision: 'deny', reason: `SynaBun could not check this call (${error?.message || error}).` }; }
|
|
134
136
|
if (verdict?.decision === 'deny') return verdict;
|
|
135
137
|
const homeRead = antigravityHomeReadPolicy(call, { homeDir, cwd });
|
|
136
138
|
if (homeRead) return homeRead;
|
|
@@ -215,6 +215,16 @@ export function createClaudeBrain({ session, sink, deps = {}, persona = '', hook
|
|
|
215
215
|
// Background agents or scheduled wakeups still running after their turn
|
|
216
216
|
// ended. Not "busy" (the mailbox may deliver), but disposing would kill them.
|
|
217
217
|
hasPendingWork() { return !!inner._hasPendingWork?.(); },
|
|
218
|
+
// The live background set the CLI reports (background_tasks_changed), for the panel's Background tasks view;
|
|
219
|
+
// null while no process runs (the set is per process).
|
|
220
|
+
backgroundTasks() { return inner.q && inner._bgTasks instanceof Map ? [...inner._bgTasks.values()].map(t => ({ ...t })) : null; },
|
|
221
|
+
// The owner's Stop of one of them, through the SDK's own stop (never a kill of a process by hand).
|
|
222
|
+
async stopTask(taskId) {
|
|
223
|
+
const q = inner.q;
|
|
224
|
+
if (!q || typeof q.stopTask !== 'function') return { ok: false, error: q ? 'Not supported by this Claude Code version' : 'Nothing of this conversation runs now: the task has already ended.' };
|
|
225
|
+
await q.stopTask(String(taskId));
|
|
226
|
+
return { ok: true };
|
|
227
|
+
},
|
|
218
228
|
identity() {
|
|
219
229
|
return {
|
|
220
230
|
providerSessionId: inner.sessionId || providerSessionId, providerThreadId: null, accountId: brain.accountId || 'default',
|