@1agh/maude 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +5 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -1
- package/apps/studio/api.ts +31 -24
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/home-api.js +30 -19
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +22 -37
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +9 -0
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
- package/apps/studio/client/v2/ds/make-host.jsx +5 -2
- package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
- package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- package/apps/studio/client/v2/history/git-model.js +18 -4
- package/apps/studio/client/v2/history/git-parts.jsx +60 -42
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/menu-runner.js +1 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/dist/client.bundle.js +977 -981
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/routes.ts +47 -8
- package/apps/studio/http.ts +117 -66
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +3 -0
- package/apps/studio/server.ts +11 -0
- package/apps/studio/sync/accepted-cold-start.ts +26 -3
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-plane.ts +443 -77
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +73 -11
- package/apps/studio/sync/projection.ts +44 -2
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +47 -3
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +54 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A personal marketplace of Claude Code and Codex plugins. Two plugins today, plus a `maude` CLI for scaffolding and running the bundled dev tooling.
|
|
4
4
|
|
|
5
|
-
<!--
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<!-- The 1-minute intro film is a release asset of the `intro-v2` release (not a v* tag, so no
|
|
6
|
+
release workflow fires). Upload: cp scripts/video/final/out/intro2/Intro2-audio.mp4 /tmp/intro.mp4 &&
|
|
7
|
+
gh release create intro-v2 /tmp/intro.mp4 --title "Intro film" --notes "Maude 2 intro film" -->
|
|
8
|
+
<video src="https://github.com/1aGh/maude/releases/download/intro-v2/intro.mp4" controls muted playsinline poster="https://maude.sh/intro-poster.jpg" width="800"></video>
|
|
8
9
|
|
|
9
10
|
> **📚 Full docs: https://maude.sh** (or browse the source under [`site/content/docs/`](./site/content/docs/) until the public URL lands).
|
|
10
11
|
> Contributing? See [CONTRIBUTING.md](./CONTRIBUTING.md). Security? See [SECURITY.md](./SECURITY.md).
|
|
@@ -120,7 +121,7 @@ Solo mode (the default) is fully local — no accounts, no telemetry, no network
|
|
|
120
121
|
|
|
121
122
|
User-facing docs live in two places — the README points you the right way:
|
|
122
123
|
|
|
123
|
-
- **Reference** (every command, every config key, recipes for Next.js / Expo / monorepo) → [`site/content/docs/`](./site/content/docs/) (served at https://maude.sh
|
|
124
|
+
- **Reference** (every command, every config key, recipes for Next.js / Expo / monorepo) → [`site/content/docs/`](./site/content/docs/) (served at https://maude.sh — see [DDR-005](.ai/archive/decisions/DDR-005-docs-site-stack-and-hosting.md)).
|
|
124
125
|
- **kgai knowledge-graph backend** (opt-in shared decision memory across repos) → [`docs/kgai-onboarding.md`](./docs/kgai-onboarding.md) (per user) + [`docs/kgai-company-setup.md`](./docs/kgai-company-setup.md) (one-time admin). Off by default — absent `kg`, every command runs its classic `.ai/` path.
|
|
125
126
|
- **Quickstart** + **contributor info** → this README.
|
|
126
127
|
|
|
@@ -133,7 +134,7 @@ The repo is a **pnpm workspace monorepo** with one published npm package (`@1agh
|
|
|
133
134
|
| Workspace | Purpose |
|
|
134
135
|
| --------- | ------- |
|
|
135
136
|
| `.` (root) | The single npm publisher — CLI, dev-server entry, plugin templates that ship to npm. |
|
|
136
|
-
| `site/` | Docs site — Fumadocs + Next.js,
|
|
137
|
+
| `site/` | Docs site — Fumadocs + Next.js, served by Cloudflare Workers ([DDR-005](.ai/archive/decisions/DDR-005-docs-site-stack-and-hosting.md)). |
|
|
137
138
|
| `apps/studio/` | Zero-dep Node dev server + browser client. Bundled output (`dist/`) is the only thing in the npm tarball. |
|
|
138
139
|
| `apps/hub/` | Reserved for the v1.1 federated hub (Phase 9). |
|
|
139
140
|
|
|
@@ -55,7 +55,6 @@ export const SESSION_WRITES: ReadonlySet<string> = new Set([
|
|
|
55
55
|
'/_api/report-fallback',
|
|
56
56
|
'/_api/hub/link', // link/unlink ≈ session management (cell allows /auth/logout)
|
|
57
57
|
'/_api/cloud/detach', // unlink — the same session-management class as hub/link
|
|
58
|
-
'/_api/workspace/sign-in', // signing in is how the role is (re)learned
|
|
59
58
|
'/_api/workspace/disclosure',
|
|
60
59
|
'/_api/cloud/signin/start', // account session, not project state
|
|
61
60
|
'/_api/cloud/signin/poll',
|
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
// What the studio relays from the ACP adapter's stderr into its own log (the
|
|
2
2
|
// person's Diagnostics view). The adapter (@agentclientprotocol/claude-agent-acp)
|
|
3
|
-
// calls `unreachable()` for an SDK
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
3
|
+
// calls `unreachable()` for an SDK message it has no case for and logs
|
|
4
|
+
// `Unexpected case: <json>`. Two of those are known and not surprises:
|
|
5
|
+
//
|
|
6
|
+
// · `subtype: "background_tasks_changed"` — the live set of background tasks
|
|
7
|
+
// (subagents, background commands). Not noise any more (issue #177): it is
|
|
8
|
+
// the one place that snapshot reaches us, so it goes to `onBackground` (see
|
|
9
|
+
// background-tasks.ts) instead of the log.
|
|
10
|
+
// · `type: "command_lifecycle"` — queued / started / completed of the host's
|
|
11
|
+
// own prompts in Claude Code's input queue. Dropped quietly.
|
|
12
|
+
//
|
|
13
|
+
// We handle these here and not by bumping the adapter (the lockfiles are
|
|
14
|
+
// release-sensitive); every OTHER `Unexpected case` still shows, so a real
|
|
15
|
+
// protocol surprise is not hidden.
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
import {
|
|
18
|
+
type BackgroundSnapshot,
|
|
19
|
+
isCommandLifecycleLine,
|
|
20
|
+
parseBackgroundLine,
|
|
21
|
+
} from './background-tasks.ts';
|
|
22
|
+
|
|
23
|
+
const BACKGROUND_LINE = /Unexpected case:.*"subtype"\s*:\s*"background_tasks_changed"/;
|
|
11
24
|
|
|
12
25
|
export function isKnownAdapterNoise(line: string): boolean {
|
|
13
|
-
return
|
|
26
|
+
return BACKGROUND_LINE.test(line) || isCommandLifecycleLine(line);
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
/**
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
/** One whole stderr line: a background snapshot goes to `onBackground`, noise is dropped, the rest to `sink`. */
|
|
30
|
+
export function relayAdapterLine(
|
|
31
|
+
raw: string,
|
|
32
|
+
sink: (line: string) => void,
|
|
33
|
+
onBackground?: (snap: BackgroundSnapshot) => void
|
|
34
|
+
): void {
|
|
35
|
+
const line = raw.trimEnd();
|
|
36
|
+
if (!line) return;
|
|
37
|
+
const snap = parseBackgroundLine(line);
|
|
38
|
+
if (snap) {
|
|
39
|
+
onBackground?.(snap);
|
|
40
|
+
return;
|
|
21
41
|
}
|
|
42
|
+
if (!isKnownAdapterNoise(line)) sink(line);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Split one stderr chunk into lines and hand each non-empty, non-noise line to `sink`. */
|
|
46
|
+
export function relayAdapterStderr(
|
|
47
|
+
chunk: string,
|
|
48
|
+
sink: (line: string) => void,
|
|
49
|
+
onBackground?: (snap: BackgroundSnapshot) => void
|
|
50
|
+
): void {
|
|
51
|
+
for (const raw of chunk.split('\n')) relayAdapterLine(raw, sink, onBackground);
|
|
22
52
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// acp/background-tasks.ts — issue #177: what the AI chat knows about work running in the background.
|
|
2
|
+
//
|
|
3
|
+
// Claude Code reports its live background work (subagents launched with the Agent tool, a Bash call
|
|
4
|
+
// with `run_in_background`, a Monitor) as one LEVEL signal: the SDK system message
|
|
5
|
+
// `background_tasks_changed`, whose `tasks` array is "every live background task after the change"
|
|
6
|
+
// (replace semantics; emitted on start, completion, kill, a foreground agent being backgrounded).
|
|
7
|
+
// The edge events (`task_started` / `task_progress` / `task_updated` / `task_notification`) never reach
|
|
8
|
+
// us: the pinned adapter (claude-agent-acp 0.57.0) swallows them. It has no case for
|
|
9
|
+
// `background_tasks_changed` either, so it calls `unreachable()`, which logs the WHOLE message to its
|
|
10
|
+
// stderr as `Unexpected case: <json>` — that stderr line is the one place the snapshot survives, so the
|
|
11
|
+
// bridge reads it there (decision maude/v2-204-background-from-adapter-stderr).
|
|
12
|
+
//
|
|
13
|
+
// `command_lifecycle` (queued / started / completed) is the lifecycle of the host's OWN prompts in
|
|
14
|
+
// Claude Code's input queue, not background work: it is dropped quietly.
|
|
15
|
+
//
|
|
16
|
+
// What leaves this module is a short, render-ready list: an id, a kind (agent / command / other), a
|
|
17
|
+
// one-line label and the time this bridge first saw the task. The label is model-authored text — it is
|
|
18
|
+
// cut to one line and capped here, and rendered as text by the client, never as markup.
|
|
19
|
+
|
|
20
|
+
/** One live background task, as the chat shows it. */
|
|
21
|
+
export interface BackgroundTask {
|
|
22
|
+
id: string;
|
|
23
|
+
kind: 'agent' | 'command' | 'other';
|
|
24
|
+
label: string;
|
|
25
|
+
/** Epoch ms this bridge first saw the task in a snapshot (drives the elapsed time). */
|
|
26
|
+
since: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A parsed `background_tasks_changed` message: the session it is for and its raw tasks. */
|
|
30
|
+
export interface BackgroundSnapshot {
|
|
31
|
+
sessionId: string | null;
|
|
32
|
+
tasks: RawTask[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface RawTask {
|
|
36
|
+
task_id?: unknown;
|
|
37
|
+
task_type?: unknown;
|
|
38
|
+
description?: unknown;
|
|
39
|
+
subagent_type?: unknown;
|
|
40
|
+
ambient?: unknown;
|
|
41
|
+
awaited?: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** At most this many rows reach the client (a runaway list must not flood the chat). */
|
|
45
|
+
export const MAX_TASKS = 50;
|
|
46
|
+
const LABEL_MAX = 80;
|
|
47
|
+
const ID_RE = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
48
|
+
const PREFIX = 'Unexpected case: ';
|
|
49
|
+
|
|
50
|
+
/** The JSON body of an adapter `Unexpected case:` line (any leading timestamp tolerated), or null. */
|
|
51
|
+
function unexpectedBody(line: string): unknown {
|
|
52
|
+
const at = line.indexOf(PREFIX);
|
|
53
|
+
if (at < 0) return null;
|
|
54
|
+
const body = line.slice(at + PREFIX.length).trim();
|
|
55
|
+
if (!body.startsWith('{')) return null;
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(body);
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The background snapshot an adapter stderr line carries, or null when it carries none. */
|
|
64
|
+
export function parseBackgroundLine(line: string): BackgroundSnapshot | null {
|
|
65
|
+
if (!line.includes('background_tasks_changed')) return null;
|
|
66
|
+
const msg = unexpectedBody(line) as Record<string, unknown> | null;
|
|
67
|
+
if (msg?.type !== 'system' || msg.subtype !== 'background_tasks_changed') return null;
|
|
68
|
+
if (!Array.isArray(msg.tasks)) return null;
|
|
69
|
+
return {
|
|
70
|
+
sessionId: typeof msg.session_id === 'string' ? msg.session_id : null,
|
|
71
|
+
tasks: msg.tasks.filter((t): t is RawTask => !!t && typeof t === 'object'),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** True for the adapter's `command_lifecycle` line — the host's own prompt queue, not background work. */
|
|
76
|
+
export function isCommandLifecycleLine(line: string): boolean {
|
|
77
|
+
if (!line.includes('command_lifecycle')) return false;
|
|
78
|
+
const msg = unexpectedBody(line) as Record<string, unknown> | null;
|
|
79
|
+
return !!msg && msg.type === 'command_lifecycle';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** One line of model text: control and bidi characters out, whitespace collapsed, capped. */
|
|
83
|
+
export function oneLine(s: unknown, max = LABEL_MAX): string {
|
|
84
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: stripping control characters is the point
|
|
85
|
+
const t = String(s ?? '').replace(/[\u0000-\u001f\u007f-\u009f---]/g, ' ');
|
|
86
|
+
const one = t.replace(/\s+/g, ' ').trim();
|
|
87
|
+
return one.length <= max ? one : `${one.slice(0, max - 1).trimEnd()}…`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function kindOf(taskType: unknown): BackgroundTask['kind'] {
|
|
91
|
+
if (taskType === 'local_agent' || taskType === 'remote_agent') return 'agent';
|
|
92
|
+
if (taskType === 'local_bash') return 'command';
|
|
93
|
+
return 'other';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Fold a snapshot into the live list. Replace semantics: a task missing from the snapshot has
|
|
98
|
+
* ended. `prev` keeps a task's `since` across snapshots. Ambient tasks (housekeeping, live-update
|
|
99
|
+
* watchers — "hosts should exclude them from activity indicators") and awaited runs (a foreground
|
|
100
|
+
* call is waiting on them, so they are not background) are left out.
|
|
101
|
+
*/
|
|
102
|
+
export function foldSnapshot(
|
|
103
|
+
prev: readonly BackgroundTask[],
|
|
104
|
+
snap: BackgroundSnapshot,
|
|
105
|
+
now: number = Date.now()
|
|
106
|
+
): BackgroundTask[] {
|
|
107
|
+
const before = new Map(prev.map((t) => [t.id, t]));
|
|
108
|
+
const out: BackgroundTask[] = [];
|
|
109
|
+
const seen = new Set<string>();
|
|
110
|
+
for (const raw of snap.tasks) {
|
|
111
|
+
if (out.length >= MAX_TASKS) break;
|
|
112
|
+
if (raw.ambient === true || raw.awaited === true) continue;
|
|
113
|
+
const id = typeof raw.task_id === 'string' && ID_RE.test(raw.task_id) ? raw.task_id : null;
|
|
114
|
+
if (!id || seen.has(id)) continue;
|
|
115
|
+
seen.add(id);
|
|
116
|
+
const kind = kindOf(raw.task_type);
|
|
117
|
+
const label =
|
|
118
|
+
oneLine(raw.description) ||
|
|
119
|
+
(kind === 'agent' ? oneLine(raw.subagent_type) : '') ||
|
|
120
|
+
(kind === 'agent' ? 'Agent' : kind === 'command' ? 'Command' : 'Task');
|
|
121
|
+
out.push({ id, kind, label, since: before.get(id)?.since ?? now });
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Same list, same order, same fields — so an unchanged snapshot sends no frame. */
|
|
127
|
+
export function sameTasks(a: readonly BackgroundTask[], b: readonly BackgroundTask[]): boolean {
|
|
128
|
+
if (a.length !== b.length) return false;
|
|
129
|
+
return a.every((t, i) => {
|
|
130
|
+
const o = b[i];
|
|
131
|
+
return o && o.id === t.id && o.kind === t.kind && o.label === t.label && o.since === t.since;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Split a stderr stream into whole lines. A chunk can end mid-line (a long snapshot is one long
|
|
137
|
+
* line), so the tail is carried into the next chunk; `flush()` hands back what is left at the end.
|
|
138
|
+
*/
|
|
139
|
+
export function createLineSplitter(onLine: (line: string) => void) {
|
|
140
|
+
let carry = '';
|
|
141
|
+
return {
|
|
142
|
+
push(chunk: string): void {
|
|
143
|
+
const text = carry + chunk;
|
|
144
|
+
const parts = text.split('\n');
|
|
145
|
+
carry = parts.pop() ?? '';
|
|
146
|
+
// A line longer than 1 MB is never a snapshot we want; do not hold it forever.
|
|
147
|
+
if (carry.length > 1_000_000) carry = '';
|
|
148
|
+
for (const p of parts) onLine(p);
|
|
149
|
+
},
|
|
150
|
+
flush(): void {
|
|
151
|
+
if (carry) onLine(carry);
|
|
152
|
+
carry = '';
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -34,7 +34,7 @@ import { autoAllowRules } from '../actions/verbs.ts';
|
|
|
34
34
|
import { HANDOFF_RUN_VERBS } from '../handoff/write-scopes.ts';
|
|
35
35
|
import { DEV_SERVER_ROOT } from '../paths.ts';
|
|
36
36
|
import { readUiPrefs } from '../ui-prefs.ts';
|
|
37
|
-
import {
|
|
37
|
+
import { relayAdapterLine } from './adapter-stderr.ts';
|
|
38
38
|
import {
|
|
39
39
|
type AudienceLeak,
|
|
40
40
|
audienceLeak,
|
|
@@ -48,6 +48,12 @@ import {
|
|
|
48
48
|
withoutWriterRules,
|
|
49
49
|
writerVerbCall,
|
|
50
50
|
} from './audience.ts';
|
|
51
|
+
import {
|
|
52
|
+
type BackgroundTask,
|
|
53
|
+
createLineSplitter,
|
|
54
|
+
foldSnapshot,
|
|
55
|
+
sameTasks,
|
|
56
|
+
} from './background-tasks.ts';
|
|
51
57
|
import { chatSpawnEnv, scrubAgentEnv, teamsSpawnEnv } from './env.ts';
|
|
52
58
|
import {
|
|
53
59
|
type AiMay,
|
|
@@ -247,6 +253,12 @@ export interface AcpBridgeOptions {
|
|
|
247
253
|
* a message part.
|
|
248
254
|
*/
|
|
249
255
|
onUsage?: (usage: BridgeUsage) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Issue #177 — the live set of background tasks (subagents, background commands), replaced
|
|
258
|
+
* whenever it changes; `[]` once the last one ends or the adapter goes away. Read from the
|
|
259
|
+
* adapter's stderr (background-tasks.ts). Chrome, not turn content: never transcripted.
|
|
260
|
+
*/
|
|
261
|
+
onBackground?: (tasks: BackgroundTask[]) => void;
|
|
250
262
|
/** Override for `PERMISSION_TIMEOUT_MS` (tests only — production always gets the real default). */
|
|
251
263
|
permissionTimeoutMs?: number;
|
|
252
264
|
/**
|
|
@@ -856,6 +868,10 @@ export class AcpBridge {
|
|
|
856
868
|
// running establishSession() and stomping the single shared `replaying` flag.
|
|
857
869
|
private sessionPromises = new Map<string, Promise<string>>();
|
|
858
870
|
private currentSession: string | null = null; // the in-flight prompt's session
|
|
871
|
+
// Issue #177 — the live background tasks, and which adapter process reported them (a respawned
|
|
872
|
+
// adapter's old stderr ending must not wipe the new one's list).
|
|
873
|
+
private background: BackgroundTask[] = [];
|
|
874
|
+
private backgroundProc: Spawned | null = null;
|
|
859
875
|
// issue-82 — every prompt() call currently racing a forced-cancellation
|
|
860
876
|
// (see `prompt()`), so cancel()/stop() can force ANY of them to settle
|
|
861
877
|
// when the adapter doesn't cooperate, instead of leaving one hanging
|
|
@@ -1089,6 +1105,11 @@ export class AcpBridge {
|
|
|
1089
1105
|
return this.pendingPermissions.size + this.pendingElicitations.size;
|
|
1090
1106
|
}
|
|
1091
1107
|
|
|
1108
|
+
/** Issue #177 — the background tasks running now (subagents, background commands). */
|
|
1109
|
+
get backgroundTasks(): BackgroundTask[] {
|
|
1110
|
+
return this.background;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1092
1113
|
/** The session id of the most recent prompt (for the `connected` frame). */
|
|
1093
1114
|
get sessionId(): string | null {
|
|
1094
1115
|
return this.currentSession;
|
|
@@ -1503,7 +1524,7 @@ export class AcpBridge {
|
|
|
1503
1524
|
stderr: 'pipe',
|
|
1504
1525
|
});
|
|
1505
1526
|
this.proc = proc;
|
|
1506
|
-
void this.drainStderr(proc
|
|
1527
|
+
void this.drainStderr(proc);
|
|
1507
1528
|
|
|
1508
1529
|
// Bun's `proc.stdin` is a FileSink, not a WritableStream — wrap it so
|
|
1509
1530
|
// ndJsonStream can pipe encoded ACP frames into the child's stdin.
|
|
@@ -2524,15 +2545,33 @@ export class AcpBridge {
|
|
|
2524
2545
|
}
|
|
2525
2546
|
}
|
|
2526
2547
|
|
|
2527
|
-
private async drainStderr(
|
|
2548
|
+
private async drainStderr(proc: Spawned): Promise<void> {
|
|
2549
|
+
const log = (line: string) => console.error('[acp-adapter]', line);
|
|
2550
|
+
const lines = createLineSplitter((line) =>
|
|
2551
|
+
relayAdapterLine(line, log, (snap) => this.setBackground(proc, snap))
|
|
2552
|
+
);
|
|
2528
2553
|
try {
|
|
2529
2554
|
const decoder = new TextDecoder();
|
|
2530
|
-
for await (const chunk of stderr) {
|
|
2531
|
-
|
|
2555
|
+
for await (const chunk of proc.stderr as ReadableStream<Uint8Array>) {
|
|
2556
|
+
lines.push(decoder.decode(chunk, { stream: true }));
|
|
2532
2557
|
}
|
|
2533
2558
|
} catch {
|
|
2534
2559
|
/* stream closed on teardown */
|
|
2535
2560
|
}
|
|
2561
|
+
lines.flush();
|
|
2562
|
+
// The adapter is gone (stopped, crashed, respawned): nothing it ran is still running for us.
|
|
2563
|
+
if (this.backgroundProc === proc) this.setBackground(proc, null);
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
/** Issue #177 — fold one adapter snapshot (null: that adapter ended) into the live list. */
|
|
2567
|
+
private setBackground(proc: Spawned, snap: Parameters<typeof foldSnapshot>[1] | null): void {
|
|
2568
|
+
const next = snap
|
|
2569
|
+
? foldSnapshot(this.backgroundProc === proc ? this.background : [], snap)
|
|
2570
|
+
: [];
|
|
2571
|
+
this.backgroundProc = next.length ? proc : null;
|
|
2572
|
+
if (sameTasks(next, this.background)) return;
|
|
2573
|
+
this.background = next;
|
|
2574
|
+
this.opts.onBackground?.(next);
|
|
2536
2575
|
}
|
|
2537
2576
|
|
|
2538
2577
|
/** Append one transcript line. `claimedSeq` is passed by the update path,
|
|
@@ -54,9 +54,14 @@ export function createConnectedFact(deps: ConnectedFactDeps) {
|
|
|
54
54
|
function ensure(): Promise<boolean> {
|
|
55
55
|
if (fresh()) return Promise.resolve(value === true);
|
|
56
56
|
if (inflight) return inflight;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// 2.0.4 (J): never chain on the probe's own return. In the cloud build (cell, self-hosted hub image)
|
|
58
|
+
// `acp/probe.ts` is the inert, deliberately NON-thenable stub (`cloud-build.ts`), so `probe().then` threw
|
|
59
|
+
// synchronously — out of `read()`, out of the outbox gates, and every drain pass failed. The executor
|
|
60
|
+
// adopts a promise, wraps a plain value and turns a synchronous throw into a rejection.
|
|
61
|
+
inflight = new Promise<{ available?: unknown } | null | undefined>((resolve) =>
|
|
62
|
+
resolve(deps.probe())
|
|
63
|
+
)
|
|
64
|
+
.then((r) => set(r?.available === true))
|
|
60
65
|
.catch(() => set(false))
|
|
61
66
|
.finally(() => {
|
|
62
67
|
inflight = null;
|
|
@@ -71,7 +76,13 @@ export function createConnectedFact(deps: ConnectedFactDeps) {
|
|
|
71
76
|
/** The last answer (the sync fallback before the first one); a stale answer starts a refresh. */
|
|
72
77
|
read(): boolean {
|
|
73
78
|
if (!fresh()) void ensure();
|
|
74
|
-
|
|
79
|
+
if (value !== null) return value;
|
|
80
|
+
// strictly `true`: the cloud stub's `.available` is a truthy proxy, and a gate fact is a boolean
|
|
81
|
+
try {
|
|
82
|
+
return deps.sync() === true;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
75
86
|
},
|
|
76
87
|
/** An answer somebody else already got (the status route, the preflight). */
|
|
77
88
|
note(available: boolean): void {
|
package/apps/studio/acp/index.ts
CHANGED
|
@@ -766,13 +766,19 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
766
766
|
* must not kill a running turn — but a genuinely abandoned one is torn down
|
|
767
767
|
* on the first TTL. Re-attaching cancels the timer (see `attach`).
|
|
768
768
|
*/
|
|
769
|
+
/** A turn in flight, or background work the turn left running (issue #177). */
|
|
770
|
+
function isBusy(entry: BridgeEntry): boolean {
|
|
771
|
+
return entry.turnActive || entry.bridge.backgroundTasks.length > 0;
|
|
772
|
+
}
|
|
773
|
+
|
|
769
774
|
function armReap(entry: BridgeEntry): void {
|
|
770
775
|
if (entry.reapTimer) clearTimeout(entry.reapTimer);
|
|
771
776
|
entry.reapTimer = setTimeout(() => {
|
|
772
777
|
entry.reapTimer = null;
|
|
773
778
|
if (entry.sinks.size > 0) return; // re-attached in the meantime
|
|
774
779
|
const detachedFor = Date.now() - entry.detachedSince;
|
|
775
|
-
|
|
780
|
+
// Issue #177 — background work (a subagent, a background command) outlives the turn: keep it too.
|
|
781
|
+
if (isBusy(entry) && detachedFor < MAX_DETACHED_LIFETIME_MS) {
|
|
776
782
|
armReap(entry);
|
|
777
783
|
return;
|
|
778
784
|
}
|
|
@@ -788,9 +794,7 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
788
794
|
for (;;) {
|
|
789
795
|
const detached = [...bridges.values()].filter((e) => e.sinks.size === 0);
|
|
790
796
|
if (detached.length <= max) return;
|
|
791
|
-
detached.sort(
|
|
792
|
-
(a, b) => Number(a.turnActive) - Number(b.turnActive) || a.lastActive - b.lastActive
|
|
793
|
-
);
|
|
797
|
+
detached.sort((a, b) => Number(isBusy(a)) - Number(isBusy(b)) || a.lastActive - b.lastActive);
|
|
794
798
|
reap(detached[0]);
|
|
795
799
|
}
|
|
796
800
|
}
|
|
@@ -963,6 +967,8 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
963
967
|
},
|
|
964
968
|
onCaps: (modes, configOptions) => broadcast(entry, { t: 'caps', modes, configOptions }),
|
|
965
969
|
onSessionInfo: (info) => broadcast(entry, { t: 'session-info', ...info }),
|
|
970
|
+
// Issue #177 — the live background tasks (chrome, like caps: replayed on attach, never transcripted).
|
|
971
|
+
onBackground: (tasks) => broadcast(entry, { t: 'background', tasks }),
|
|
966
972
|
onUsage: (usage) => {
|
|
967
973
|
latestUsage = usage;
|
|
968
974
|
noteRateLimit(usage.rateLimit); // S5.6 — the outbox's `ai-allowance` gate fact
|
|
@@ -1405,7 +1411,8 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1405
1411
|
registerActivityProbe(() =>
|
|
1406
1412
|
[...bridges.values()].map((e) => ({
|
|
1407
1413
|
chatId: e.chatId,
|
|
1408
|
-
|
|
1414
|
+
// Issue #177 — background work counts as running: the tab must not rest mid-run.
|
|
1415
|
+
state: e.bridge.awaitingInputCount > 0 ? 'awaiting-input' : isBusy(e) ? 'running' : 'idle',
|
|
1409
1416
|
}))
|
|
1410
1417
|
);
|
|
1411
1418
|
|
|
@@ -1504,6 +1511,8 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1504
1511
|
// the busy state) rather than a finished one. Without this a reload
|
|
1505
1512
|
// mid-turn would look idle while the agent kept working.
|
|
1506
1513
|
send(ws, { t: 'attached', chat: safeChat, running: entry.turnActive });
|
|
1514
|
+
// Issue #177 — what is still running in the background (a reload must not hide it).
|
|
1515
|
+
send(ws, { t: 'background', tasks: entry.bridge.backgroundTasks });
|
|
1507
1516
|
entry.sentRuns.clear(); // a re-attached client gets the chat's live runs again
|
|
1508
1517
|
pushRunFrames(entry);
|
|
1509
1518
|
} else if (frame.t === 'prompt' && typeof frame.text === 'string') {
|
|
@@ -890,6 +890,11 @@ export const AGENT_PATHS: Readonly<Record<ActionId, ActionDefAI>> = {
|
|
|
890
890
|
// a read for every role (GET /_api/asset-details): no per-role refusal row, so no `server` key (as S10.9's ds.show-reach)
|
|
891
891
|
agent: cli('maude design assets --usage <asset> --details'),
|
|
892
892
|
},
|
|
893
|
+
// 2.0.4 (#191) — View larger: a picture, clip or sound in a window over the person's screen. A read of a file the agent
|
|
894
|
+
// already has (`maude design assets`), so there is nothing for it to run.
|
|
895
|
+
'assets.spotlight': PREF(
|
|
896
|
+
"opens a large view on the person's screen; an agent reads the file itself"
|
|
897
|
+
),
|
|
893
898
|
// S8.20 — search in pictures: the person's own yes (or Stop) to describing their pictures with THEIR Claude account on
|
|
894
899
|
// THEIR Mac (V2-1.17 §5.9, Q9). An agent cannot say yes for the person whose account it spends.
|
|
895
900
|
'assets.describe': {
|
|
@@ -181,6 +181,18 @@ export const VIEW_ACTIONS: ActionDef[] = [
|
|
|
181
181
|
],
|
|
182
182
|
search: { hidden: true },
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
// 2.0.4 (#191) — View larger: the picked tile's picture, clip or sound in a window (a double-click opens the same one).
|
|
186
|
+
// ← → walk the tiles the tab shows, esc or a click outside closes. A read, so every role has it. Only while a tile is
|
|
187
|
+
// picked and focus is in the tab (`assetTileSelected`) — Space is the Hand tool's key in the canvas, which this never is.
|
|
188
|
+
id: 'assets.spotlight',
|
|
189
|
+
label: 'View larger',
|
|
190
|
+
kind: 'command',
|
|
191
|
+
icon: 'image',
|
|
192
|
+
exec: 'shell',
|
|
193
|
+
keys: [kb('Space', 'selection', { when: { focus: ['chrome'], facts: ['assetTileSelected'] } })],
|
|
194
|
+
search: { hidden: true },
|
|
195
|
+
},
|
|
184
196
|
{
|
|
185
197
|
// S8.13 — Move to trash on the picked tile (its menu row; the tidy view's "Move 31 to the trash…" is the same route).
|
|
186
198
|
// A write: Can edit and up, refused by the server as well. The server also refuses a picture a canvas uses or an
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"generated": "scripts/gen-actions.mjs — do not edit by hand",
|
|
3
3
|
"format": "maude.actions-manifest",
|
|
4
4
|
"v": 1,
|
|
5
|
-
"manifestVersion": "
|
|
5
|
+
"manifestVersion": "4ae7b6bdb900",
|
|
6
6
|
"actions": [
|
|
7
7
|
{
|
|
8
8
|
"id": "search.open",
|
|
@@ -2048,6 +2048,18 @@
|
|
|
2048
2048
|
"verb": "maude design assets --usage <asset> --details"
|
|
2049
2049
|
}
|
|
2050
2050
|
},
|
|
2051
|
+
{
|
|
2052
|
+
"id": "assets.spotlight",
|
|
2053
|
+
"label": "View larger",
|
|
2054
|
+
"kind": "command",
|
|
2055
|
+
"exec": "shell",
|
|
2056
|
+
"effect": "none",
|
|
2057
|
+
"agent": {
|
|
2058
|
+
"path": "human",
|
|
2059
|
+
"because": "view-pref",
|
|
2060
|
+
"note": "opens a large view on the person's screen; an agent reads the file itself"
|
|
2061
|
+
}
|
|
2062
|
+
},
|
|
2051
2063
|
{
|
|
2052
2064
|
"id": "assets.trash",
|
|
2053
2065
|
"label": "Move to trash",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Lead-owned (contract V2-1.11 §5.7). humanMax/pendingMax may only be lowered; raising either, or adding a humanDecisions reason, is a lead change citing a decision id.",
|
|
3
|
-
"humanMax":
|
|
3
|
+
"humanMax": 176,
|
|
4
4
|
"pendingMax": 0,
|
|
5
5
|
"pending": [],
|
|
6
6
|
"humanDecisions": {
|
|
@@ -262,6 +262,12 @@
|
|
|
262
262
|
"from": 173,
|
|
263
263
|
"by": "decision:maude/v2-gate-b-sec3b-home-invite-actions-human",
|
|
264
264
|
"why": "gate-b-sec3b registers invite.join and invite.leave (Home › Shared with you: accept or turn down an invitation addressed to the person's own cloud account). Both human 'accounts': an agent invites others with share.invite but never answers for the person; the Home server holds the device token. Two human rows (raised from the current feat 172)."
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"to": 176,
|
|
268
|
+
"from": 175,
|
|
269
|
+
"by": "decision:maude/v2-204-asset-spotlight-registry-action",
|
|
270
|
+
"why": "2.0.4 (#191) registers assets.spotlight (View larger: the large preview of an Assets tile, dblclick / Space / tile menu). Human 'view-pref': it only changes what the person is looking at; an agent reads the file itself. One human row."
|
|
265
271
|
}
|
|
266
272
|
],
|
|
267
273
|
"humanMaxRaisedNote": "V2-5 A1 integration: the three slice raises stack on 86 (84 -> 86 by decision:maude/v2-4-gate-github-doors, human 'accounts'). S4.1/S4.3/S4.4 and S2.2-S2.4 add no human row. 86 + 4 + 6 + 4 = 100 human actions in the merged registry. V2-5 A2 integration: S5.4 builds `maude design runs list|stop`, so ai.runs.list and ai.stop turn cli (decision:maude/v2-S5.3-run-actions-human-until-s5.4 resolved by decision:maude/v2-S5.4-runs-fallback-prompts) and the cap lowers 100 -> 98; S3.1, S4.2, S4.5, S9.4, S2.5 and S1.4 add no human row. V2-5 A4 integration: measured 107 human actions in the merged registry (98 on feat + tool.pointer from S3.2b + 7 chat.advanced.* from S5.12 + object.select-matching from S2.6); every other A4 slice adds no human row. V2-5 A5 integration: measured 113 human actions in the merged registry (107 on feat + trash.clear from S1.7b + four ai.attach-* from S5.10 + present.presenter-view from S3.6b); every other A5 slice adds no human row. V2-5 A6a integration: measured 118 human actions in the merged registry (113 on feat + artboard.ask-ai S2.10 + element.set-id S2.2b/lead + edit.undo-history S2.20 + history.filter S1.12b − view.trash S1.17 (cli) + tab.overview + tab.rename S1.22b); every other A6a slice adds no human row."
|