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
|
@@ -24,6 +24,19 @@ export const SLICE_STATES = Object.freeze(['planned', 'pending', 'blocked', 'run
|
|
|
24
24
|
const TEAM_TONES = { creating: 'idle', planned: 'idle', running: 'active', integrating: 'active', ready: 'ok', landing: 'active', merged: 'done', completed: 'done', failed: 'err', cancelled: 'off', needs_attention: 'warn', landed: 'done', discarded: 'off' };
|
|
25
25
|
/** A team that reached the owner's branch, is on its way there, or was thrown away: nothing more to land or discard. */
|
|
26
26
|
const SETTLED_TEAM = new Set(['merged', 'landing', 'landed', 'discarded', 'completed']);
|
|
27
|
+
/**
|
|
28
|
+
* A team that is over (the scheduler's closed statuses, lib/teams/scheduler.js CLOSED_TEAM_STATUSES, and the
|
|
29
|
+
* journal's words for the same ends): the Finished list. Every other team, a state this page does not know
|
|
30
|
+
* included, is Open (never offered for removal), and the Open list is the rail's count.
|
|
31
|
+
*/
|
|
32
|
+
export const FINISHED_TEAM_STATUSES = Object.freeze(['landed', 'completed', 'discarded', 'failed', 'merged', 'cancelled']);
|
|
33
|
+
const FINISHED_TEAM = new Set(FINISHED_TEAM_STATUSES);
|
|
34
|
+
/** What the server says to do about a closed team that still has something on disk (lib/teams/scheduler.js removalOf). */
|
|
35
|
+
export const REMOVAL_NEXT = Object.freeze(['cleanup', 'force_discard', 'by_hand']);
|
|
36
|
+
/** Why a closed team's record cannot go yet, when it is not what is left on disk (`agentsStudio.teams.removalBlocked.*`). */
|
|
37
|
+
export const REMOVAL_BLOCKED = Object.freeze(['TEAM_RUNS_ACTIVE', 'DISPATCH_UNAVAILABLE', 'PROJECT_NOT_FOUND', 'NOT_A_REPOSITORY', 'GIT_UNAVAILABLE', 'TEAM_NEEDS_RECOVERY', 'TEAM_OPEN']);
|
|
38
|
+
/** Why a discard kept a worktree or a branch (lib/teams/worktrees.js `kept[].reason`; `agentsStudio.teams.keptReason.*`). */
|
|
39
|
+
export const KEPT_REASONS = Object.freeze(['uncommitted_changes', 'unintegrated_commits', 'folder_is_not_a_worktree', 'worktree_not_removed', 'branch_not_removed', 'worktree_not_verified', 'worker_commits']);
|
|
27
40
|
const SLICE_TONES = { planned: 'idle', pending: 'idle', blocked: 'warn', running: 'active', done: 'ok', rejected: 'err', integrating: 'active', integrated: 'done', completed: 'done', conflict: 'err', 'tests-failed': 'err', failed: 'err', cancelled: 'off' };
|
|
28
41
|
|
|
29
42
|
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -35,34 +48,137 @@ const stateOf = (value) => text(first(value?.status, value?.state), 40).toLowerC
|
|
|
35
48
|
/** The tone of a team's or a slice's state: idle / active / ok / done / warn / err / off. */
|
|
36
49
|
export const teamTone = (state) => TEAM_TONES[state] || 'idle';
|
|
37
50
|
export const sliceTone = (state) => SLICE_TONES[state] || 'idle';
|
|
51
|
+
/** Is a team over (Finished)? */
|
|
52
|
+
export const isFinishedTeam = (status) => FINISHED_TEAM.has(String(status || '').toLowerCase());
|
|
53
|
+
|
|
54
|
+
/** The open statuses a card offers a quick action on: a team that waits on the owner. Never a running team. */
|
|
55
|
+
export const QUICK_TEAM_STATUSES = Object.freeze(['needs_attention', 'ready']);
|
|
56
|
+
/** The quick actions of a card: Clean up & remove, Discard & remove, Discard. */
|
|
57
|
+
export const QUICK_ACTIONS = Object.freeze(['cleanup-merged', 'discard-remove', 'discard']);
|
|
58
|
+
const count = (value) => (Number.isInteger(value) && value >= 0 ? value : null);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A ready team whose work is on its base branch already (lib/teams/scheduler.js `onTargetOf`), or null: where
|
|
62
|
+
* (`branch`), whether its worktrees and branches could go now (`clean`), and, in a team's detail, what keeps it from
|
|
63
|
+
* being clean (uncommitted files per worktree, branches with commits the base branch lacks, a live worker, other).
|
|
64
|
+
* Only for a ready team: any other status, or an answer without a branch, is null.
|
|
65
|
+
*/
|
|
66
|
+
export function onTargetOf(team) {
|
|
67
|
+
const o = isObject(team?.alreadyOnTarget) ? team.alreadyOnTarget : null;
|
|
68
|
+
if (!o || stateOf(team) !== 'ready' || team?.plan?.readOnly === true) return null;
|
|
69
|
+
const branch = text(o.branch, 300);
|
|
70
|
+
if (!branch) return null;
|
|
71
|
+
const list = (value) => (Array.isArray(value) ? value.filter(isObject) : []);
|
|
72
|
+
return {
|
|
73
|
+
branch,
|
|
74
|
+
head: text(o.head, 80),
|
|
75
|
+
clean: o.clean === true,
|
|
76
|
+
runs: count(o.runs),
|
|
77
|
+
dirty: list(o.dirty).map((item) => ({ sliceId: text(item.sliceId, 128) || null, path: text(item.path, 1024), files: (Array.isArray(item.files) ? item.files : []).filter((f) => typeof f === 'string').slice(0, 50) })).filter((item) => item.path).slice(0, 20),
|
|
78
|
+
unmerged: list(o.unmerged).map((item) => ({ sliceId: text(item.sliceId, 128) || null, branch: text(item.branch, 300), commits: (Array.isArray(item.commits) ? item.commits : []).filter((c) => typeof c === 'string').length })).filter((item) => item.branch).slice(0, 20),
|
|
79
|
+
other: (Array.isArray(o.other) ? o.other : []).filter((line) => typeof line === 'string' && line).map((line) => line.slice(0, 600)).slice(0, 10),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
38
82
|
|
|
39
83
|
/** A row of the teams list. */
|
|
40
84
|
export function teamRow(team) {
|
|
41
85
|
const t = isObject(team) ? team : {};
|
|
42
86
|
const slices = Array.isArray(t.slices) ? t.slices.length : isObject(t.slices) ? Object.keys(t.slices).length : number(first(t.slices, t.sliceCount, t.slicesCount));
|
|
43
87
|
const status = stateOf(t);
|
|
88
|
+
const onTarget = onTargetOf(t);
|
|
44
89
|
return {
|
|
45
90
|
id: text(first(t.id, t.teamId), 128),
|
|
46
91
|
title: text(first(t.title, t.plan?.title, t.name), 200),
|
|
47
92
|
project: text(first(t.project, t.projectPath, t.plan?.projectPath), 1024),
|
|
48
|
-
|
|
93
|
+
// A ready team whose work is on its base branch already says so instead of "Ready to land".
|
|
94
|
+
status, tone: onTarget ? (onTarget.clean ? 'done' : 'warn') : teamTone(status),
|
|
49
95
|
density: text(first(t.density, t.plan?.density), 40),
|
|
50
96
|
slices: slices ?? null,
|
|
51
97
|
createdAt: text(first(t.createdAt, t.created_at), 40),
|
|
52
98
|
updatedAt: text(first(t.updatedAt, t.updated_at), 40),
|
|
99
|
+
finished: isFinishedTeam(status),
|
|
100
|
+
// Only a finished team the server said can go now (nothing of it on disk or in git, no live worker).
|
|
101
|
+
removable: isFinishedTeam(status) && t.removable === true,
|
|
102
|
+
onTarget,
|
|
103
|
+
// An open team that waits on the owner: its live workers and what of it is on disk (null: not said).
|
|
104
|
+
liveRuns: count(t.liveRuns),
|
|
105
|
+
left: count(t.left),
|
|
53
106
|
};
|
|
54
107
|
}
|
|
55
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The one quick action a card of the Open list offers, or null. Never on a running team, on a team with a live
|
|
111
|
+
* worker or on one whose workers the server did not count; never without the capability its route needs.
|
|
112
|
+
* cleanup-merged a ready team whose work is on its base branch already, clean (`teams-on-target`)
|
|
113
|
+
* discard-remove needs attention or ready, nothing of it on disk or in git (`teams-quick-discard`)
|
|
114
|
+
* discard needs attention or ready, with worktrees or branches (`teams-quick-discard`)
|
|
115
|
+
* A ready team on its base branch that is not clean gets none: discarding it would say its landed work was given up.
|
|
116
|
+
* @param {object} row a teamRow
|
|
117
|
+
* @param {{ has: (cap: string) => boolean }} caps
|
|
118
|
+
*/
|
|
119
|
+
export function quickActionOf(row, caps) {
|
|
120
|
+
const has = (cap) => typeof caps?.has === 'function' && caps.has(cap);
|
|
121
|
+
if (!row?.id || row.finished || !QUICK_TEAM_STATUSES.includes(row.status)) return null;
|
|
122
|
+
if (row.onTarget) return row.onTarget.clean && has('teams-on-target') ? 'cleanup-merged' : null;
|
|
123
|
+
if (!has('teams-quick-discard') || row.liveRuns !== 0 || row.left === null) return null;
|
|
124
|
+
return row.left === 0 ? 'discard-remove' : 'discard';
|
|
125
|
+
}
|
|
126
|
+
|
|
56
127
|
/** The list, newest first, a team without an id left out. */
|
|
57
128
|
export function teamRows(teams) {
|
|
58
129
|
return (Array.isArray(teams) ? teams : []).map(teamRow).filter((row) => row.id)
|
|
59
130
|
.sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
60
131
|
}
|
|
61
132
|
|
|
62
|
-
/**
|
|
133
|
+
/** The list in two: the teams under way (Open) and the teams that are over (Finished), each newest first. */
|
|
134
|
+
export function splitTeams(rows) {
|
|
135
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
136
|
+
return { open: list.filter((row) => !row.finished), finished: list.filter((row) => row.finished) };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** How many teams are under way (the rail's count): the Open list. A team that waits on the owner is under way. */
|
|
63
140
|
export function activeTeams(rows) {
|
|
64
|
-
|
|
65
|
-
|
|
141
|
+
return splitTeams(rows).open.length;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The finished teams Clear finished removes (the server checks each again) and how many it leaves. */
|
|
145
|
+
export function clearableTeams(rows) {
|
|
146
|
+
const { finished } = splitTeams(rows);
|
|
147
|
+
const removable = finished.filter((row) => row.removable);
|
|
148
|
+
return { removable, kept: finished.length - removable.length };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** A closed team's removal view (lib/teams/scheduler.js `removalView`), or null when the answer has none. */
|
|
152
|
+
export function removalOf(team) {
|
|
153
|
+
const r = isObject(team?.removal) ? team.removal : null;
|
|
154
|
+
if (!r) return null;
|
|
155
|
+
const left = (Array.isArray(r.left) ? r.left : []).filter(isObject).map((item) => ({
|
|
156
|
+
sliceId: text(item.sliceId, 128) || null,
|
|
157
|
+
path: text(item.path, 1024),
|
|
158
|
+
branch: text(item.branch, 300),
|
|
159
|
+
worktree: item.worktree === true,
|
|
160
|
+
branchExists: item.branchExists === true,
|
|
161
|
+
})).filter((item) => item.path || item.branch).slice(0, 200);
|
|
162
|
+
return {
|
|
163
|
+
removable: r.removable === true,
|
|
164
|
+
code: text(r.code, 80) || null,
|
|
165
|
+
next: REMOVAL_NEXT.includes(r.next) ? r.next : null,
|
|
166
|
+
message: text(r.message, 1200),
|
|
167
|
+
left,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** What a discard kept, and why (the scheduler's `cleanup.kept`, in the landing part of the answer). */
|
|
172
|
+
export function keptWork(team) {
|
|
173
|
+
const cleanup = isObject(team?.landing?.cleanup) ? team.landing.cleanup : isObject(team?.cleanup) ? team.cleanup : {};
|
|
174
|
+
return (Array.isArray(cleanup.kept) ? cleanup.kept : []).filter(isObject).map((item) => ({
|
|
175
|
+
sliceId: text(item.sliceId, 128) || null,
|
|
176
|
+
path: text(item.path, 1024),
|
|
177
|
+
branch: text(item.branch, 300),
|
|
178
|
+
reason: text(item.reason, 60),
|
|
179
|
+
files: (Array.isArray(item.files) ? item.files : []).filter((f) => typeof f === 'string').slice(0, 20),
|
|
180
|
+
commits: number(item.commits),
|
|
181
|
+
})).slice(0, 100);
|
|
66
182
|
}
|
|
67
183
|
|
|
68
184
|
function sliceOf(raw, plan) {
|
|
@@ -182,19 +298,35 @@ export function teamView(team) {
|
|
|
182
298
|
const row = teamRow(team);
|
|
183
299
|
const slices = sliceRows(team);
|
|
184
300
|
const integration = integrationOf(team);
|
|
301
|
+
const readOnly = team?.plan?.readOnly === true;
|
|
302
|
+
// A finished team: the server's look at git and the disk (null from a server without it: nothing is offered).
|
|
303
|
+
const removal = row.finished ? removalOf(team) : null;
|
|
304
|
+
const leftWith = (next) => !!removal && !removal.removable && removal.next === next && removal.left.length > 0;
|
|
185
305
|
return {
|
|
186
306
|
...row,
|
|
187
307
|
slices,
|
|
188
|
-
readOnly
|
|
308
|
+
readOnly,
|
|
309
|
+
removal,
|
|
310
|
+
kept: keptWork(team),
|
|
311
|
+
// Landed, its worktrees and branches still there: the owner cleans them up (merged and clean, or nothing goes).
|
|
312
|
+
canCleanup: !readOnly && (row.status === 'landed' || row.status === 'merged') && leftWith('cleanup'),
|
|
313
|
+
// Discarded (or failed) with work kept: the owner deletes it with a forced discard.
|
|
314
|
+
canForceDiscard: !readOnly && ['discarded', 'cancelled', 'failed'].includes(row.status) && leftWith('force_discard'),
|
|
315
|
+
// Nothing of it is left and no worker lives: its record can go.
|
|
316
|
+
canRemove: row.finished && removal?.removable === true,
|
|
189
317
|
baseBranch: text(first(team?.baseBranch, team?.plan?.baseBranch), 300),
|
|
190
318
|
baseCommit: text(first(team?.baseCommit, team?.plan?.baseCommit), 80),
|
|
191
319
|
integration, landing: landingOf(team), claims: claimRows(team), feed: feedItems(team),
|
|
192
320
|
// What the scheduler waits on the owner for (status `needs_attention`): its sentence, shown as text.
|
|
193
321
|
attention: text(isObject(team?.attention) ? first(team.attention.message, team.attention.code) : team?.attention, 600),
|
|
194
|
-
// Landing is offered once the integration branch is ready (the server refuses anything else and says why)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
322
|
+
// Landing is offered once the integration branch is ready (the server refuses anything else and says why), and
|
|
323
|
+
// never for a team whose work is on its base branch already: there is nothing left to land.
|
|
324
|
+
canLand: team?.plan?.readOnly !== true && row.status === 'ready' && !row.onTarget,
|
|
325
|
+
// A team that reached the owner's branch, or is on its way there, is not thrown away from here; neither is one
|
|
326
|
+
// whose work is on its base branch already (a discard would record its landed work as given up).
|
|
327
|
+
canDiscard: !!row.id && !SETTLED_TEAM.has(row.status) && team?.removed !== true && !row.onTarget,
|
|
328
|
+
// Its work is on its base branch already and nothing would be lost: Clean up & remove.
|
|
329
|
+
canCleanupMerged: !!row.onTarget && row.onTarget.clean,
|
|
198
330
|
sliceCounts: slices.reduce((acc, slice) => { acc[slice.tone] = (acc[slice.tone] || 0) + 1; return acc; }, {}),
|
|
199
331
|
};
|
|
200
332
|
}
|
|
@@ -53,6 +53,7 @@ function esc(value) {
|
|
|
53
53
|
* createAgentsDock(hostEl, hooks)
|
|
54
54
|
* hooks: { t, sessionId, onFocus(runId), onStop(runId), onRead(runId), onEscalate(runId, target),
|
|
55
55
|
* onStopAll() (the second press of "Stop all"; stopAllConfirmMs / stopAllMinGapMs time it),
|
|
56
|
+
* onSteer(runId, text) → truthy when sent, onSteerInComposer(runId, text), locale() (asst-steer.js),
|
|
56
57
|
* onRemove(runId), onClearFinished(runIds), onReveal(runId), onRunChange(run),
|
|
57
58
|
* open, showAll, onToggle(open), onShowAllChange(showAll),
|
|
58
59
|
* onCountChange({ total, active, attention, answer, idle, working, waiting, visible }) }
|
|
@@ -172,6 +173,9 @@ export function createAgentsDock(hostEl, hooks = {}) {
|
|
|
172
173
|
onRead: hooks.onRead,
|
|
173
174
|
onEscalate: hooks.onEscalate,
|
|
174
175
|
onRemove: typeof hooks.onRemove === 'function' ? hooks.onRemove : null,
|
|
176
|
+
onSteer: hooks.onSteer,
|
|
177
|
+
onSteerInComposer: hooks.onSteerInComposer,
|
|
178
|
+
locale: hooks.locale,
|
|
175
179
|
};
|
|
176
180
|
}
|
|
177
181
|
|
|
@@ -65,6 +65,48 @@ export async function readAssistantShellOutput(sessionId, { shellId, cursor, tai
|
|
|
65
65
|
return { status: res.status, data };
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// ── Background tasks of a Claude brain (the Background tasks view) ─
|
|
69
|
+
|
|
70
|
+
/** The brain's background shells and watches, rebuilt from its transcript, and its live set. Never throws: null. */
|
|
71
|
+
export async function listAssistantBackgroundTasks(sessionId) {
|
|
72
|
+
try {
|
|
73
|
+
const res = await fetch(`/api/assistant/sessions/${enc(sessionId)}/background-tasks`, { credentials: 'same-origin' });
|
|
74
|
+
const body = await res.json().catch(() => null);
|
|
75
|
+
// A server from before this view has no such route (its 404 names no code): its output waits for a restart.
|
|
76
|
+
if (res.status === 404 && !body?.code) return { unsupported: true };
|
|
77
|
+
return res.ok && body?.ok ? body : null;
|
|
78
|
+
} catch { return null; }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One page of what a background task printed. → { status, data } or { ok: false, status, error }; never throws. */
|
|
82
|
+
export async function readAssistantBackgroundOutput(sessionId, { taskId, cursor, tail, limit } = {}) {
|
|
83
|
+
const query = new URLSearchParams();
|
|
84
|
+
if (Number.isSafeInteger(cursor) && cursor >= 0) query.set('cursor', String(cursor));
|
|
85
|
+
if (Number.isSafeInteger(tail) && tail > 0) query.set('tail', String(tail));
|
|
86
|
+
if (Number.isSafeInteger(limit) && limit > 0) query.set('limit', String(limit));
|
|
87
|
+
const search = query.toString();
|
|
88
|
+
let res;
|
|
89
|
+
try {
|
|
90
|
+
res = await fetch(`/api/assistant/sessions/${enc(sessionId)}/background-tasks/${enc(taskId)}/output${search ? `?${search}` : ''}`, { credentials: 'same-origin' });
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return { ok: false, error: error?.message || 'The output could not be read.' };
|
|
93
|
+
}
|
|
94
|
+
let body = null;
|
|
95
|
+
try { body = await res.json(); } catch { /* not JSON */ }
|
|
96
|
+
if (!res.ok || !body?.ok) return { ok: false, status: res.status, error: body?.error || `HTTP ${res.status}` };
|
|
97
|
+
const { ok: _ok, ...data } = body;
|
|
98
|
+
return { status: res.status, data };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The owner's Stop of one background task (the SDK's stopTask). → { ok, error }; never throws. */
|
|
102
|
+
export async function stopAssistantBackgroundTask(sessionId, taskId) {
|
|
103
|
+
try {
|
|
104
|
+
const res = await fetch(`/api/assistant/sessions/${enc(sessionId)}/background-tasks/${enc(taskId)}/stop`, { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'X-SynaBun-UI': '1' }, body: '{}' });
|
|
105
|
+
const body = await res.json().catch(() => null);
|
|
106
|
+
return res.ok && body?.ok ? { ok: true } : { ok: false, error: body?.error || `HTTP ${res.status}` };
|
|
107
|
+
} catch (error) { return { ok: false, error: error?.message || String(error) }; }
|
|
108
|
+
}
|
|
109
|
+
|
|
68
110
|
// ── Catalog ──────────────────────────────────
|
|
69
111
|
|
|
70
112
|
export function fetchAssistantCatalog({ force = false } = {}) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// ═══════════════════════════════════════════
|
|
2
2
|
// SynaBun Assistant — composer
|
|
3
3
|
// ═══════════════════════════════════════════
|
|
4
|
-
// Enter sends
|
|
4
|
+
// Enter sends (while a turn runs: steers it, Alt+Enter queues instead; a run
|
|
5
|
+
// targeted from its card is steered), Shift+Enter inserts a newline, Esc aborts the running turn (or
|
|
5
6
|
// closes the slash menu). Attachments: images (paste / file picker / drop),
|
|
6
7
|
// text files, memory chips (drag from the graph), and any other file — the
|
|
7
8
|
// picker and drop upload it to the server and the prompt carries its path
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
|
|
14
15
|
import { matchSlashCommands, SLASH_COMMANDS } from './asst-slash.js';
|
|
15
16
|
import { isLongPaste, typedText } from './asst-automation.js';
|
|
17
|
+
import { composerKeyIntent, steerTranslator, targetChipText } from './asst-state.js'; // steer's boot part (asst-steer.js loads on demand)
|
|
16
18
|
|
|
17
19
|
const TEXT_EXTENSIONS = new Set([
|
|
18
20
|
'txt', 'md', 'js', 'ts', 'jsx', 'tsx', 'json', 'html', 'css', 'scss', 'less', 'xml', 'svg',
|
|
@@ -121,15 +123,22 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
121
123
|
return params ? String(fallback).replace(/\{(\w+)\}/g, (_, k) => (params[k] != null ? params[k] : `{${k}}`)) : fallback;
|
|
122
124
|
};
|
|
123
125
|
|
|
126
|
+
// The steer sentences (asst-steer.js): the page's `assistant.steer.*`, else its own English / Portuguese.
|
|
127
|
+
const st8 = steerTranslator(hooks.t, typeof hooks.locale === 'function' ? hooks.locale() : hooks.locale);
|
|
124
128
|
const root = el('div', 'asst-composer');
|
|
125
129
|
root.innerHTML = `
|
|
126
130
|
<div class="asst-slash-menu" role="listbox" id="asst-slash-${Math.random().toString(36).slice(2, 8)}" aria-label="${esc(t('assistant.composer.commands', 'Commands'))}" hidden></div>
|
|
127
131
|
<div class="asst-composer-queue" hidden></div>
|
|
132
|
+
<div class="asst-composer-target" hidden></div>
|
|
128
133
|
<div class="asst-composer-attachments" hidden></div>
|
|
129
134
|
<textarea class="asst-input" rows="1" spellcheck="true" aria-label="${esc(t('assistant.composer.aria', 'Message the assistant'))}" aria-autocomplete="list"></textarea>
|
|
130
135
|
<div class="asst-composer-actions">
|
|
131
136
|
<button type="button" class="asst-tb-btn asst-attach" data-tooltip="${esc(t('assistant.composer.attach', 'Attach files'))}" aria-label="${esc(t('assistant.composer.attach', 'Attach files'))}">${ICON_ATTACH}</button>
|
|
132
137
|
<div class="asst-composer-brain"></div>
|
|
138
|
+
<span class="asst-steer-actions" role="group" aria-label="${esc(st8('steer'))}" hidden>
|
|
139
|
+
<button type="button" class="asst-tb-btn asst-queue-btn" data-tooltip="${esc(st8('queueTip'))}" aria-label="${esc(st8('queueTip'))}">${esc(st8('queue'))}</button>
|
|
140
|
+
<button type="button" class="asst-btn asst-steer-btn" data-tooltip="${esc(st8('steerNow'))}" aria-label="${esc(st8('steerNow'))}">${esc(st8('steer'))}</button>
|
|
141
|
+
</span>
|
|
133
142
|
<button type="button" class="asst-send" data-state="empty" aria-label="${esc(t('assistant.composer.send', 'Send'))}">${ICON_SEND}</button>
|
|
134
143
|
</div>
|
|
135
144
|
<input type="file" class="asst-file-input" multiple hidden tabindex="-1">
|
|
@@ -142,6 +151,10 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
142
151
|
const fileInput = root.querySelector('.asst-file-input');
|
|
143
152
|
const attachmentsEl = root.querySelector('.asst-composer-attachments');
|
|
144
153
|
const queueEl = root.querySelector('.asst-composer-queue');
|
|
154
|
+
const targetEl = root.querySelector('.asst-composer-target');
|
|
155
|
+
const steerActions = root.querySelector('.asst-steer-actions');
|
|
156
|
+
const queueBtn = root.querySelector('.asst-queue-btn');
|
|
157
|
+
const steerBtn = root.querySelector('.asst-steer-btn');
|
|
145
158
|
const slashMenu = root.querySelector('.asst-slash-menu');
|
|
146
159
|
textarea.setAttribute('aria-controls', slashMenu.id);
|
|
147
160
|
|
|
@@ -160,6 +173,10 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
160
173
|
// A composer under 300px says the short form, so the placeholder never wraps to three lines.
|
|
161
174
|
placeholderShort: t('assistant.composer.placeholderShort', 'Ask SynaBun…'),
|
|
162
175
|
narrow: false,
|
|
176
|
+
// The run the next message steers ({ runId, title, index }), set from its card; null: the Assistant.
|
|
177
|
+
target: null,
|
|
178
|
+
// The server can steer (an older one cannot: Enter while busy queues, as before).
|
|
179
|
+
steerable: hooks.steerable !== false,
|
|
163
180
|
};
|
|
164
181
|
const placeholderNow = () => (state.narrow ? state.placeholderShort : state.placeholder);
|
|
165
182
|
textarea.placeholder = placeholderNow();
|
|
@@ -199,6 +216,42 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
199
216
|
sendBtn.setAttribute('aria-label', label);
|
|
200
217
|
sendBtn.setAttribute('data-tooltip', label);
|
|
201
218
|
sendBtn.disabled = mode === 'empty';
|
|
219
|
+
// While a turn runs and there is something to send: Steer (Enter) and Queue (Alt+Enter) beside Stop.
|
|
220
|
+
// A targeted run while busy: Steer only (Queue is for the Assistant's own turn). Not busy with a target:
|
|
221
|
+
// the send button itself steers that run.
|
|
222
|
+
const ready = hasContent() && !state.disabled && !waiting;
|
|
223
|
+
steerActions.hidden = !(ready && state.running && (state.steerable || state.target));
|
|
224
|
+
queueBtn.hidden = !!state.target;
|
|
225
|
+
if (state.target && !state.running) {
|
|
226
|
+
const tip = st8('targetLabel', { title: state.target.title || state.target.runId });
|
|
227
|
+
sendBtn.setAttribute('aria-label', tip);
|
|
228
|
+
sendBtn.setAttribute('data-tooltip', tip);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function renderTarget() {
|
|
233
|
+
const target = state.target;
|
|
234
|
+
if (!target) {
|
|
235
|
+
targetEl.hidden = true;
|
|
236
|
+
targetEl.innerHTML = '';
|
|
237
|
+
if (!state.disabled) textarea.placeholder = placeholderNow();
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const label = st8('targetLabel', { title: target.title || target.runId });
|
|
241
|
+
targetEl.innerHTML = `<span class="asst-chip static asst-steer-target" data-run-id="${esc(target.runId)}" aria-label="${esc(label)}"><span class="asst-chip-text">${esc(targetChipText(target, st8))}</span><button type="button" class="asst-chip-x" aria-label="${esc(st8('targetClear'))}" data-tooltip="${esc(st8('targetClear'))}">${ICON_X}</button></span>`;
|
|
242
|
+
targetEl.hidden = false;
|
|
243
|
+
if (!state.disabled) textarea.placeholder = st8('targetPlaceholder', { title: target.title || target.runId });
|
|
244
|
+
}
|
|
245
|
+
targetEl.addEventListener('click', (e) => {
|
|
246
|
+
if (!e.target.closest('.asst-chip-x')) return;
|
|
247
|
+
setSteerTarget(null);
|
|
248
|
+
textarea.focus();
|
|
249
|
+
});
|
|
250
|
+
function setSteerTarget(target) {
|
|
251
|
+
state.target = target && target.runId ? { runId: String(target.runId), title: String(target.title || ''), index: target.index ?? null } : null;
|
|
252
|
+
renderTarget();
|
|
253
|
+
updateSendButton();
|
|
254
|
+
hooks.onTargetChange?.(state.target ? { ...state.target } : null);
|
|
202
255
|
}
|
|
203
256
|
|
|
204
257
|
function renderAttachments() {
|
|
@@ -316,7 +369,7 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
316
369
|
});
|
|
317
370
|
|
|
318
371
|
// ── Submit ──
|
|
319
|
-
async function submit() {
|
|
372
|
+
async function submit(mode = null) {
|
|
320
373
|
if (state.disabled) return;
|
|
321
374
|
if (uploading()) { hooks.onToast?.(t('assistant.composer.waitUploads', 'Wait for the upload to finish, then send')); return; }
|
|
322
375
|
const text = textarea.value.trim();
|
|
@@ -331,20 +384,30 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
331
384
|
uploads: state.uploads.map(({ name, size, mime, path }) => ({ name, size, mime, path })),
|
|
332
385
|
memories: state.memories.slice(),
|
|
333
386
|
};
|
|
387
|
+
// 'steer' / 'queue' only when the user chose one (Enter or Alt+Enter while busy, the buttons); a target always steers.
|
|
388
|
+
if (state.target) { payload.mode = 'steer'; payload.steerTarget = { ...state.target }; }
|
|
389
|
+
else if (mode === 'steer' || mode === 'queue') payload.mode = mode;
|
|
390
|
+
// What this send took, by reference: the send is awaited, and the user may type or attach the next message meanwhile.
|
|
391
|
+
const took = { images: state.images.slice(), files: state.files.slice(), uploads: state.uploads.slice(), memories: state.memories.slice(), pastes: state.pastes.slice() };
|
|
334
392
|
let outcome;
|
|
335
393
|
try { outcome = await hooks.onSubmit?.(payload); } catch { outcome = false; }
|
|
336
394
|
if (outcome === false) return;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
state.
|
|
342
|
-
state.
|
|
395
|
+
// Clear only what went: words typed and attachments added while the send was on its way stay for the next one.
|
|
396
|
+
const textWent = textarea.value.trim() === text;
|
|
397
|
+
if (textWent) textarea.value = '';
|
|
398
|
+
const keep = (list, sent) => list.filter((item) => !sent.includes(item));
|
|
399
|
+
state.images = keep(state.images, took.images);
|
|
400
|
+
state.files = keep(state.files, took.files);
|
|
401
|
+
state.uploads = keep(state.uploads, took.uploads);
|
|
402
|
+
state.memories = keep(state.memories, took.memories);
|
|
403
|
+
state.pastes = textWent ? [] : keep(state.pastes, took.pastes);
|
|
343
404
|
renderAttachments();
|
|
344
|
-
closeSlash();
|
|
405
|
+
if (textWent) closeSlash();
|
|
345
406
|
autoResize();
|
|
346
407
|
updateSendButton();
|
|
347
|
-
hooks.onDraftChange?.('');
|
|
408
|
+
hooks.onDraftChange?.(textWent ? '' : textarea.value);
|
|
409
|
+
// One steer per target: the next message goes to the Assistant again unless a card sets it once more.
|
|
410
|
+
if (outcome === 'steered' && state.target) setSteerTarget(null);
|
|
348
411
|
if (outcome === 'queued') hooks.onToast?.(t('assistant.composer.queued', 'Queued — will send when the current turn finishes'));
|
|
349
412
|
}
|
|
350
413
|
|
|
@@ -352,6 +415,9 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
352
415
|
if (state.running) { hooks.onAbort?.(); return; }
|
|
353
416
|
submit();
|
|
354
417
|
});
|
|
418
|
+
// Focus stays in (and returns to) the composer after either choice.
|
|
419
|
+
steerBtn.addEventListener('click', () => { Promise.resolve(submit('steer')).finally(() => textarea.focus()); });
|
|
420
|
+
queueBtn.addEventListener('click', () => { Promise.resolve(submit('queue')).finally(() => textarea.focus()); });
|
|
355
421
|
|
|
356
422
|
textarea.addEventListener('keydown', (e) => {
|
|
357
423
|
if (state.slashOpen) {
|
|
@@ -366,9 +432,11 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
366
432
|
}
|
|
367
433
|
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSlash(); return; }
|
|
368
434
|
}
|
|
369
|
-
|
|
435
|
+
// Enter: send, or Steer while a turn runs (or a run is targeted); Alt+Enter while busy: Queue (asst-steer.js).
|
|
436
|
+
const intent = composerKeyIntent(e, { running: state.running, targeted: !!state.target, steerable: state.steerable });
|
|
437
|
+
if (intent) {
|
|
370
438
|
e.preventDefault();
|
|
371
|
-
submit();
|
|
439
|
+
submit(intent === 'send' ? null : intent);
|
|
372
440
|
return;
|
|
373
441
|
}
|
|
374
442
|
if (e.key === 'Escape') {
|
|
@@ -643,6 +711,11 @@ export function createComposer(hostEl, hooks = {}) {
|
|
|
643
711
|
clearAttachments() { abortUploads(); state.images = []; state.files = []; state.uploads = []; state.memories = []; renderAttachments(); },
|
|
644
712
|
setQueue,
|
|
645
713
|
hasContent,
|
|
714
|
+
/** The run the next message steers ({ runId, title, index }), or null for the Assistant. */
|
|
715
|
+
setSteerTarget,
|
|
716
|
+
getSteerTarget: () => (state.target ? { ...state.target } : null),
|
|
717
|
+
/** Whether the server can steer: without it Enter while busy queues, as before. */
|
|
718
|
+
setSteerable(value) { state.steerable = value !== false; updateSendButton(); },
|
|
646
719
|
destroy() { abortUploads(); closeSlash(); resizeObserver?.disconnect(); root.remove(); },
|
|
647
720
|
};
|
|
648
721
|
}
|