@cortex-agent/server 2026.9.15 → 2026.9.21
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 +3 -2
- package/defaults/config/hooks/08-agents-md-injector-post-tool.json +10 -0
- package/defaults/config/hooks/{10-cortex-md-injector-session-start.json → 10-agents-md-injector-session-start.json} +3 -3
- package/defaults/config/hooks/{CORTEX.md → AGENTS.md} +2 -2
- package/defaults/hooks/{CORTEX.md → AGENTS.md} +1 -1
- package/defaults/hooks/{cortex-md-injector.mjs → agents-md-injector.mjs} +117 -26
- package/defaults/hooks/cortex-hook-api.mjs +2 -2
- package/defaults/hooks/new-session-hook.mjs +2 -2
- package/defaults/hooks/rules-loader.mjs +2 -2
- package/defaults/hooks/status-md-guard.mjs +8 -8
- package/defaults/hooks/task-status-check.mjs +18 -76
- package/defaults/hooks/tasks-yaml-guard.mjs +2 -2
- package/defaults/plugins/cortex-feishu/skills/feishu-doc/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +2 -2
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +4 -4
- package/defaults/plugins/cortex-system/skills/task/SKILL.md +1 -1
- package/defaults/rules/{cortex-md.md → agents-md.md} +4 -4
- package/defaults/rules/decision-records.md +1 -1
- package/defaults/rules/meta-conventions.md +4 -4
- package/defaults/rules/mission-md.md +1 -1
- package/dist/agent-adapter/claude/hooks-builder.js +2 -2
- package/dist/agent-adapter/claude/spawn-args.js +4 -0
- package/dist/agent-adapter/claude/turn-machine.d.ts +11 -0
- package/dist/agent-adapter/claude/turn-machine.js +46 -5
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +16 -1
- package/dist/agent-adapter/normalize/prompt-builder.js +24 -6
- package/dist/agent-adapter/types.d.ts +1 -0
- package/dist/core/mcp-tool-gate.js +1 -0
- package/dist/core/media-types.d.ts +10 -0
- package/dist/core/media-types.js +34 -0
- package/dist/core/platform-settings-spec.js +1 -1
- package/dist/core/settings-spec.d.ts +21 -0
- package/dist/core/settings-spec.js +28 -1
- package/dist/core/types/agent-types.d.ts +3 -1
- package/dist/core/utils.d.ts +1 -1
- package/dist/core/utils.js +1 -1
- package/dist/domain/executions/registry.d.ts +1 -2
- package/dist/domain/executions/registry.js +0 -3
- package/dist/domain/mcp/bundled-server.js +4 -3
- package/dist/domain/mcp/feishu/file.js +37 -18
- package/dist/domain/mcp/feishu/types.d.ts +3 -0
- package/dist/domain/mcp/feishu-server.js +1 -1
- package/dist/domain/mcp/tools/{cortex-md.d.ts → agents-md.d.ts} +6 -6
- package/dist/domain/mcp/tools/{cortex-md.js → agents-md.js} +6 -6
- package/dist/domain/mcp/tools/remote-file.d.ts +20 -0
- package/dist/domain/mcp/tools/remote-file.js +44 -0
- package/dist/domain/mcp/tools/slack.d.ts +2 -0
- package/dist/domain/mcp/tools/slack.js +22 -7
- package/dist/domain/mcp/tools/task-ops.js +5 -13
- package/dist/domain/mcp/tools/ui-file.js +23 -10
- package/dist/domain/mcp/tools/waitpoint.d.ts +3 -0
- package/dist/domain/mcp/tools/waitpoint.js +122 -0
- package/dist/domain/memory/agents-md-injector.d.ts +24 -0
- package/dist/domain/memory/{cortex-md-injector.js → agents-md-injector.js} +10 -7
- package/dist/domain/projects/project-store.d.ts +1 -1
- package/dist/domain/projects/project-store.js +3 -3
- package/dist/domain/remote/client-hot-reload.js +3 -1
- package/dist/domain/remote/client-manager.js +39 -119
- package/dist/domain/remote/cortex-client-config.d.ts +1 -1
- package/dist/domain/remote/cortex-client-config.js +1 -1
- package/dist/domain/remote/device-file.d.ts +51 -0
- package/dist/domain/remote/device-file.js +193 -0
- package/dist/domain/remote/device-port.js +3 -0
- package/dist/domain/remote/reverse-stream.d.ts +18 -7
- package/dist/domain/remote/reverse-stream.js +19 -6
- package/dist/domain/tasks/claim-recovery.js +2 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +10 -1
- package/dist/domain/tasks/dispatch-utils.js +46 -1
- package/dist/domain/tasks/dispatcher.js +4 -5
- package/dist/domain/tasks/mutator.d.ts +2 -2
- package/dist/domain/tasks/mutator.js +2 -2
- package/dist/domain/tasks/system/task-cli.js +2 -2
- package/dist/domain/tasks/system/task-state.js +1 -1
- package/dist/domain/threads/runner.js +3 -1
- package/dist/domain/ui-service/app-router.d.ts +24 -3
- package/dist/domain/ui-service/app-router.js +8 -14
- package/dist/domain/ui-service/input-schemas.d.ts +17 -5
- package/dist/domain/ui-service/input-schemas.js +13 -9
- package/dist/domain/ui-service/mutate/platform-settings.js +1 -1
- package/dist/domain/ui-service/mutate/sessions.d.ts +5 -1
- package/dist/domain/ui-service/mutate/sessions.js +14 -0
- package/dist/domain/ui-service/mutate/waitpoints.d.ts +2 -0
- package/dist/domain/ui-service/mutate/waitpoints.js +20 -0
- package/dist/domain/ui-service/platform-settings.js +1 -1
- package/dist/domain/ui-service/plugins-shared.js +1 -1
- package/dist/domain/ui-service/query/config.js +1 -1
- package/dist/domain/ui-service/query/executions.js +0 -2
- package/dist/domain/ui-service/query/machine-detail.js +3 -8
- package/dist/domain/ui-service/query/memory.js +1 -1
- package/dist/domain/ui-service/query/sessions.js +7 -0
- package/dist/domain/ui-service/query/threads.js +1 -54
- package/dist/domain/ui-service/query/waitpoints.d.ts +30 -0
- package/dist/domain/ui-service/query/waitpoints.js +117 -0
- package/dist/domain/ui-service/query-input-schemas.d.ts +3 -0
- package/dist/domain/ui-service/query-input-schemas.js +3 -0
- package/dist/domain/ui-service/trpc.js +1 -1
- package/dist/domain/ui-service/types.d.ts +133 -49
- package/dist/domain/ui-service/types.js +1 -1
- package/dist/domain/ui-service/ui-service.js +7 -31
- package/dist/domain/waitpoints/notices.d.ts +21 -0
- package/dist/domain/waitpoints/notices.js +115 -0
- package/dist/domain/waitpoints/service.d.ts +91 -0
- package/dist/domain/waitpoints/service.js +243 -0
- package/dist/entry/app.js +29 -7
- package/dist/entry/auth-login-cli.js +1 -1
- package/dist/entry/auth-login-terminal.js +1 -1
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init.js +6 -6
- package/dist/entry/signal-cli.d.ts +30 -0
- package/dist/entry/signal-cli.js +207 -0
- package/dist/entry/start-ui-http.d.ts +1 -1
- package/dist/entry/start-ui-http.js +2 -2
- package/dist/events/event-types.d.ts +0 -7
- package/dist/hooks/{cortex-md-injector.mjs → agents-md-injector.mjs} +117 -26
- package/dist/hooks/cortex-hook-api.mjs +2 -2
- package/dist/hooks/new-session-hook.mjs +2 -2
- package/dist/hooks/rules-loader.mjs +2 -2
- package/dist/hooks/status-md-guard.mjs +8 -8
- package/dist/hooks/task-status-check.mjs +18 -76
- package/dist/hooks/tasks-yaml-guard.mjs +2 -2
- package/dist/orchestration/agent-file-send.d.ts +9 -0
- package/dist/orchestration/agent-file-send.js +21 -2
- package/dist/orchestration/agent-runner.d.ts +3 -2
- package/dist/orchestration/agent-runner.js +17 -12
- package/dist/orchestration/attachments-store.d.ts +31 -0
- package/dist/orchestration/attachments-store.js +184 -0
- package/dist/orchestration/conversation-request.d.ts +4 -0
- package/dist/orchestration/conversation-request.js +13 -6
- package/dist/orchestration/interactions/plan-approvals.js +1 -1
- package/dist/orchestration/outputs-store.d.ts +11 -0
- package/dist/orchestration/outputs-store.js +32 -6
- package/dist/orchestration/routing/file-handler.d.ts +23 -2
- package/dist/orchestration/routing/file-handler.js +22 -5
- package/dist/orchestration/routing/webhook.js +193 -39
- package/dist/orchestration/session-gateway.d.ts +1 -1
- package/dist/orchestration/session-gateway.js +1 -0
- package/dist/orchestration/thread-executor.d.ts +2 -0
- package/dist/orchestration/thread-executor.js +11 -1
- package/dist/orchestration/thread-input.d.ts +3 -2
- package/dist/orchestration/thread-input.js +8 -9
- package/dist/orchestration/turn/turn-prep.d.ts +15 -1
- package/dist/orchestration/turn/turn-prep.js +19 -8
- package/dist/orchestration/waitpoint-ingress.d.ts +41 -0
- package/dist/orchestration/waitpoint-ingress.js +172 -0
- package/dist/orchestration/waitpoint-notifier.d.ts +21 -0
- package/dist/orchestration/waitpoint-notifier.js +119 -0
- package/dist/orchestration/waitpoint-remote-drain.d.ts +20 -0
- package/dist/orchestration/waitpoint-remote-drain.js +147 -0
- package/dist/orchestration/waitpoint-sweep.d.ts +42 -0
- package/dist/orchestration/waitpoint-sweep.js +87 -0
- package/dist/platform/adapters/feishu-image.d.ts +19 -0
- package/dist/platform/adapters/feishu-image.js +71 -0
- package/dist/platform/adapters/feishu.d.ts +2 -0
- package/dist/platform/adapters/feishu.js +26 -16
- package/dist/platform/ui-http/listening-ports.d.ts +1 -1
- package/dist/platform/ui-http/listening-ports.js +1 -1
- package/dist/platform/ui-http/ui-session.js +1 -1
- package/dist/store/conversation-ledger-repo.js +1 -1
- package/dist/store/execution-repo.d.ts +1 -19
- package/dist/store/execution-repo.js +1 -18
- package/dist/store/project-notes-repo.js +11 -2
- package/dist/store/prompt-migration-replacements.js +1 -1
- package/dist/store/session-registry-import.js +1 -1
- package/dist/store/session-registry-journal.js +1 -1
- package/dist/store/session-registry-repo.js +1 -1
- package/dist/store/version-migrations.d.ts +13 -3
- package/dist/store/version-migrations.js +254 -24
- package/dist/store/waitpoint-repo.d.ts +108 -0
- package/dist/store/waitpoint-repo.js +94 -0
- package/package.json +2 -2
- package/web/dist/assets/{index-CRDJo39X.css → index-CwwQNMpP.css} +1 -1
- package/web/dist/assets/index-DLSfgq3o.js +444 -0
- package/web/dist/assets/{index-CEZ0DSei.js → index-DZTuqUO4.js} +1 -1
- package/web/dist/index.html +2 -2
- package/defaults/config/hooks/08-cortex-md-injector-post-tool.json +0 -10
- package/dist/domain/executions/log-tailer.d.ts +0 -71
- package/dist/domain/executions/log-tailer.js +0 -194
- package/dist/domain/memory/cortex-md-injector.d.ts +0 -24
- package/dist/domain/memory/cortex-md-scanner.d.ts +0 -10
- package/dist/domain/memory/cortex-md-scanner.js +0 -66
- package/dist/domain/remote/cortex-client.d.ts +0 -1
- package/dist/domain/remote/cortex-client.js +0 -662
- package/dist/domain/tasks/system/cortex-run.d.ts +0 -25
- package/dist/domain/tasks/system/cortex-run.js +0 -360
- package/web/dist/assets/index-DjuPJVZE.js +0 -444
- /package/defaults/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/config/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/context/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/context/ideas/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/context/projects/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/context/scans/{CORTEX.md → AGENTS.md} +0 -0
- /package/defaults/context/user/{CORTEX.md → AGENTS.md} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// input: UiServiceDeps + WaitpointsListParams
|
|
2
|
+
// output: handleWaitpointsList → WaitpointInfo[]; ownsWaitpoint (the ownership rule, shared with
|
|
3
|
+
// query/sessions.ts); toWaitpointInfo (the redacting serialiser)
|
|
4
|
+
// pos: query handler for 'waitpoints.list' — the operator-facing view of the waitpoints a
|
|
5
|
+
// session is still waiting on. Deliberately NOT domain/waitpoints' `publicView`: that one
|
|
6
|
+
// is written for the agent and hides exactly the fields a human needs (delivery state, wake
|
|
7
|
+
// budget, rate-limit latch). Records reach this file only through UiServiceDeps.
|
|
8
|
+
import { getSettings } from '../../../core/settings.js';
|
|
9
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
10
|
+
/**
|
|
11
|
+
* Does `wp` belong to the session identified by (`sessionId`, `channel`)?
|
|
12
|
+
*
|
|
13
|
+
* The union of two clauses, each covering the other's blind spot:
|
|
14
|
+
* - `owner.sessionId` — this session's own process armed it. Survives a channel rebind, since
|
|
15
|
+
* `bindChannel` never rewrites the session record's channel.
|
|
16
|
+
* - `owner.channel` — the wake will be DELIVERED here. Survives the session being recreated
|
|
17
|
+
* (`!new`, a scheduled re-run), because delivery is channel-addressed and find-or-creates a
|
|
18
|
+
* session. This clause can surface a waitpoint armed by an earlier session on the same channel;
|
|
19
|
+
* that is honest rather than wrong — its wake really will land on the current one.
|
|
20
|
+
*
|
|
21
|
+
* Kept as one exported function so `SessionInfo.waitingOn` and `waitpoints.list` can never drift.
|
|
22
|
+
*/
|
|
23
|
+
export function ownsWaitpoint(wp, sessionId, channel) {
|
|
24
|
+
if (sessionId && wp.owner.sessionId === sessionId)
|
|
25
|
+
return true;
|
|
26
|
+
if (channel && wp.owner.channel === channel)
|
|
27
|
+
return true;
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
/** Count the armed waitpoints each of `sessions` is waiting on. One pass over a handful of records
|
|
31
|
+
* (the repo read is an in-memory cache hit and settled records are purged after 3 days), so the
|
|
32
|
+
* nested loop is cheaper than building and reconciling two indexes. */
|
|
33
|
+
export function countWaitingOn(armed, sessions) {
|
|
34
|
+
const out = new Map();
|
|
35
|
+
for (const s of sessions) {
|
|
36
|
+
if (armed.length === 0) {
|
|
37
|
+
out.set(s.sessionId, 0);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
let n = 0;
|
|
41
|
+
for (const wp of armed)
|
|
42
|
+
if (ownsWaitpoint(wp, s.sessionId, s.channel))
|
|
43
|
+
n += 1;
|
|
44
|
+
out.set(s.sessionId, n);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** `quorum.need` is collapsed to a number at creation, but the stored type still permits `'all'`
|
|
49
|
+
* (a hand-edited or pre-existing waitpoints.json). Same fallback every other reader uses. */
|
|
50
|
+
function needCount(wp) {
|
|
51
|
+
return typeof wp.quorum.need === 'number' ? wp.quorum.need : wp.quorum.members.length || 1;
|
|
52
|
+
}
|
|
53
|
+
function toSignalInfo(s) {
|
|
54
|
+
return {
|
|
55
|
+
at: s.at,
|
|
56
|
+
status: s.status,
|
|
57
|
+
member: s.member ?? null,
|
|
58
|
+
message: s.message ?? null,
|
|
59
|
+
source: s.source,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Redacting serialiser. Built field by field, never by spreading the record: `secretHash` must not
|
|
64
|
+
* be able to leak through a field added upstream later. `signals[].data` is dropped on purpose —
|
|
65
|
+
* it is externally written and capped at 16 KB per signal, which would bloat every list response.
|
|
66
|
+
*/
|
|
67
|
+
export function toWaitpointInfo(wp, now, wakeLimit) {
|
|
68
|
+
const windowStart = now - HOUR_MS;
|
|
69
|
+
return {
|
|
70
|
+
id: wp.id,
|
|
71
|
+
label: wp.label,
|
|
72
|
+
intent: wp.intent,
|
|
73
|
+
state: wp.state,
|
|
74
|
+
emitFrom: wp.emitFrom.kind === 'device'
|
|
75
|
+
? { kind: 'device', device: wp.emitFrom.device }
|
|
76
|
+
: { kind: 'local' },
|
|
77
|
+
quorum: {
|
|
78
|
+
need: needCount(wp),
|
|
79
|
+
got: wp.quorum.got.length,
|
|
80
|
+
members: [...wp.quorum.members],
|
|
81
|
+
},
|
|
82
|
+
failFast: wp.failFast,
|
|
83
|
+
fires: wp.fires,
|
|
84
|
+
maxSignals: wp.maxSignals,
|
|
85
|
+
createdAt: wp.createdAt,
|
|
86
|
+
expiresAt: wp.expiresAt,
|
|
87
|
+
signals: wp.signals.map(toSignalInfo),
|
|
88
|
+
delivery: {
|
|
89
|
+
pending: wp.delivery.pending,
|
|
90
|
+
attempts: wp.delivery.attempts,
|
|
91
|
+
lastError: wp.delivery.lastError ?? null,
|
|
92
|
+
lastAt: wp.delivery.lastAt ?? null,
|
|
93
|
+
},
|
|
94
|
+
wakesLastHour: wp.wakes.filter((t) => t > windowStart).length,
|
|
95
|
+
wakeLimit,
|
|
96
|
+
rateLimited: wp.rateLimitNotified === true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export async function handleWaitpointsList(deps, params) {
|
|
100
|
+
if (!deps.waitpointRegistry)
|
|
101
|
+
return [];
|
|
102
|
+
const sessionId = String(params.sessionId || '');
|
|
103
|
+
if (!sessionId)
|
|
104
|
+
return [];
|
|
105
|
+
// The channel half of the ownership rule has to be resolved here: SessionInfo carries no channel,
|
|
106
|
+
// so the client cannot compute this match and must not try to guess it (`web:<id>` only holds for
|
|
107
|
+
// sessions created directly — a Slack, Feishu or scheduled session has a different conduit).
|
|
108
|
+
const record = await deps.sessionStore.getById(sessionId);
|
|
109
|
+
const channel = record?.channel ?? null;
|
|
110
|
+
const armed = await deps.waitpointRegistry.listArmed();
|
|
111
|
+
const mine = armed.filter((wp) => ownsWaitpoint(wp, sessionId, channel));
|
|
112
|
+
const now = Date.now();
|
|
113
|
+
const wakeLimit = getSettings().waitpointMaxWakesPerHour;
|
|
114
|
+
// Soonest to expire first: what is about to time out is what a human needs to see.
|
|
115
|
+
mine.sort((a, b) => a.expiresAt - b.expiresAt);
|
|
116
|
+
return mine.map((wp) => toWaitpointInfo(wp, now, wakeLimit));
|
|
117
|
+
}
|
|
@@ -62,6 +62,9 @@ export declare const commissionsGetInput: z.ZodObject<{
|
|
|
62
62
|
export declare const commissionsDecisionsInput: z.ZodObject<{
|
|
63
63
|
commissionId: z.ZodString;
|
|
64
64
|
}, z.core.$strip>;
|
|
65
|
+
export declare const waitpointsListInput: z.ZodObject<{
|
|
66
|
+
sessionId: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
65
68
|
export declare const executionsListInput: z.ZodObject<{
|
|
66
69
|
status: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
70
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
@@ -51,6 +51,9 @@ export const commissionsGetInput = z.object({
|
|
|
51
51
|
export const commissionsDecisionsInput = z.object({
|
|
52
52
|
commissionId: z.string(),
|
|
53
53
|
});
|
|
54
|
+
export const waitpointsListInput = z.object({
|
|
55
|
+
sessionId: z.string().min(1),
|
|
56
|
+
});
|
|
54
57
|
export const executionsListInput = z.object({
|
|
55
58
|
status: z.array(z.string()).optional(),
|
|
56
59
|
limit: z.number().optional(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: tRPC core and procedure error shapes
|
|
2
2
|
// output: router, publicProcedure and createCallerFactory
|
|
3
3
|
// pos: UI router foundation with credential-error redaction
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import { initTRPC } from '@trpc/server';
|
|
6
6
|
/**
|
|
7
7
|
* Keepalive for the SSE subscription that carries the whole UI's live state.
|
|
@@ -17,11 +17,11 @@ import type { HookBackend, HookEvent, HookFilterValue, HookPhase, HookResultMode
|
|
|
17
17
|
import type { HookApplyTime, HookMountTarget } from '../hooks/hook-view.js';
|
|
18
18
|
export type { HookApplyTime, HookMountTarget } from '../hooks/hook-view.js';
|
|
19
19
|
import type { Session } from '../../store/session-registry-repo.js';
|
|
20
|
+
import type { Waitpoint } from '../../store/waitpoint-repo.js';
|
|
20
21
|
import type { SessionTotals } from '../../store/session-totals.js';
|
|
21
22
|
export type { SessionTotals } from '../../store/session-totals.js';
|
|
22
23
|
import type { ScheduleTask, ScheduleTarget } from '../../store/schedule-repo.js';
|
|
23
24
|
import type { CommissionRecord } from '../../store/commission-repo.js';
|
|
24
|
-
import type { LogLocation } from '../executions/log-tailer.js';
|
|
25
25
|
import type { SessionHistory } from '../../store/conversation-history-repo.js';
|
|
26
26
|
import type { Backend } from '../../agent-adapter/types.js';
|
|
27
27
|
import type { ProjectNote } from '../../store/project-notes-repo.js';
|
|
@@ -40,12 +40,12 @@ export type Err = {
|
|
|
40
40
|
message: string;
|
|
41
41
|
};
|
|
42
42
|
export type Result<T> = Ok<T> | Err;
|
|
43
|
-
export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.subagentTranscript' | 'sessions.debugDetails' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'commissions.list' | 'commissions.get' | 'commissions.decisions' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'auth.status' | 'auth.flowState' | 'auth.customProviders' | 'models.catalog' | 'hooks.list' | 'machines.list' | 'machines.detail' | 'skills.list' | 'plugins.list' | 'plugins.skillFile' | 'plugins.mcpRead' | 'threadTemplates.get' | 'threadTemplates.detail' | 'system.daemonStatus' | 'system.rateLimitStatus' | 'system.usageStatus' | 'system.notices' | 'system.updateStatus';
|
|
44
|
-
export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.setSelection' | 'sessions.setCommission' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.respondDecision' | 'sessions.cancelResume' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'schedules.update' | 'commissions.close' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'config.setPlatform' | 'config.setProviderRateLimitPolicy' | 'auth.startLogin' | 'auth.respondPrompt' | 'auth.cancelFlow' | 'auth.logout' | 'auth.syncGateway' | 'auth.upsertCustomProvider' | 'auth.removeCustomProvider' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'profiles.create' | 'profiles.update' | 'profiles.remove' | 'plugins.assign' | 'plugins.skillWrite' | 'plugins.skillCreate' | 'plugins.skillMove' | 'plugins.skillRemove' | 'plugins.create' | 'plugins.remove' | 'plugins.convertToPortable' | 'plugins.mcpWrite' | 'threadTemplates.validate' | 'threadTemplates.save' | 'threadTemplates.remove' | 'system.restart' | 'system.clearRateLimit' | 'system.refreshUsage' | 'system.applyUpdate' | 'system.skipUpdate';
|
|
43
|
+
export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.subagentTranscript' | 'sessions.debugDetails' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'commissions.list' | 'commissions.get' | 'commissions.decisions' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'auth.status' | 'auth.flowState' | 'auth.customProviders' | 'models.catalog' | 'hooks.list' | 'machines.list' | 'machines.detail' | 'skills.list' | 'plugins.list' | 'plugins.skillFile' | 'plugins.mcpRead' | 'threadTemplates.get' | 'threadTemplates.detail' | 'system.daemonStatus' | 'system.rateLimitStatus' | 'system.usageStatus' | 'system.notices' | 'system.updateStatus' | 'waitpoints.list';
|
|
44
|
+
export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.setSelection' | 'sessions.setCommission' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.markManyRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.respondDecision' | 'sessions.cancelResume' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'waitpoints.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'schedules.update' | 'commissions.close' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'config.setPlatform' | 'config.setProviderRateLimitPolicy' | 'auth.startLogin' | 'auth.respondPrompt' | 'auth.cancelFlow' | 'auth.logout' | 'auth.syncGateway' | 'auth.upsertCustomProvider' | 'auth.removeCustomProvider' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'profiles.create' | 'profiles.update' | 'profiles.remove' | 'plugins.assign' | 'plugins.skillWrite' | 'plugins.skillCreate' | 'plugins.skillMove' | 'plugins.skillRemove' | 'plugins.create' | 'plugins.remove' | 'plugins.convertToPortable' | 'plugins.mcpWrite' | 'threadTemplates.validate' | 'threadTemplates.save' | 'threadTemplates.remove' | 'system.restart' | 'system.clearRateLimit' | 'system.refreshUsage' | 'system.applyUpdate' | 'system.skipUpdate';
|
|
45
45
|
export interface SubscribeFilter {
|
|
46
46
|
events: string[];
|
|
47
47
|
projectId?: string | null;
|
|
48
|
-
/** Scope
|
|
48
|
+
/** Scope execution-carrying events (agent.*) to a single execution. */
|
|
49
49
|
executionId?: string | null;
|
|
50
50
|
/** Scope `session.message` events to a single session (S4 chat live stream). REQUIRED for
|
|
51
51
|
* `session.message.delta`: token-level previews are delivered to session-scoped subscriptions
|
|
@@ -57,10 +57,6 @@ export interface UiEvent {
|
|
|
57
57
|
ts: string;
|
|
58
58
|
payload: unknown;
|
|
59
59
|
}
|
|
60
|
-
/** Input for the `executions.log` subscription (B2-C). Parity-guarded in @cortex-agent/ui-contract. */
|
|
61
|
-
export interface ExecutionsLogParams {
|
|
62
|
-
executionId: string;
|
|
63
|
-
}
|
|
64
60
|
export interface SessionsListParams {
|
|
65
61
|
projectId?: string;
|
|
66
62
|
resumable?: boolean;
|
|
@@ -147,6 +143,11 @@ export interface ExecutionsListParams {
|
|
|
147
143
|
export interface ExecutionsGetParams {
|
|
148
144
|
executionId: string;
|
|
149
145
|
}
|
|
146
|
+
/** Waitpoints belonging to ONE session. Scoped server-side: the client cannot compute the match
|
|
147
|
+
* because SessionInfo carries no `channel` (see WaitpointInfo for the ownership rule). */
|
|
148
|
+
export interface WaitpointsListParams {
|
|
149
|
+
sessionId: string;
|
|
150
|
+
}
|
|
150
151
|
export interface MemoryTreeParams {
|
|
151
152
|
projectId: string;
|
|
152
153
|
}
|
|
@@ -276,6 +277,16 @@ export interface SessionsCompactArgs {
|
|
|
276
277
|
export interface SessionsMarkReadArgs {
|
|
277
278
|
sessionId: string;
|
|
278
279
|
}
|
|
280
|
+
/** Batch form of markRead: the client hands over the exact sessions it is showing as unread (the
|
|
281
|
+
* run list's「mark all read」), so the server never has to re-derive the set. */
|
|
282
|
+
export interface SessionsMarkManyReadArgs {
|
|
283
|
+
sessionIds: string[];
|
|
284
|
+
}
|
|
285
|
+
export interface SessionsMarkManyReadReturn {
|
|
286
|
+
/** How many of the requested sessions were stamped — ids that no longer resolve (purged runs)
|
|
287
|
+
* are skipped rather than failing the batch. */
|
|
288
|
+
marked: number;
|
|
289
|
+
}
|
|
279
290
|
export interface SessionsSetProfileArgs {
|
|
280
291
|
sessionId: string;
|
|
281
292
|
/** The profile to switch the session to. Must exist in profiles.json. */
|
|
@@ -423,6 +434,9 @@ export interface ThreadsCancelArgs {
|
|
|
423
434
|
export interface ExecutionsCancelArgs {
|
|
424
435
|
executionId: string;
|
|
425
436
|
}
|
|
437
|
+
export interface WaitpointsCancelArgs {
|
|
438
|
+
waitpointId: string;
|
|
439
|
+
}
|
|
426
440
|
export interface ScheduleActionArgs {
|
|
427
441
|
scheduleId: string;
|
|
428
442
|
}
|
|
@@ -649,6 +663,14 @@ export interface SessionInfo {
|
|
|
649
663
|
* blue. False when nothing is pending, and false when the pending-interaction deps are absent
|
|
650
664
|
* (fixtures / TUI). Snapshot-only, mirrored live via the `session.interaction` event stream. */
|
|
651
665
|
awaitingInput: boolean;
|
|
666
|
+
/** How many waitpoints this session is still waiting on — external "wake me when X finishes"
|
|
667
|
+
* objects that are still `armed` (docs/waitpoints.md). Distinct from `awaitingInput`: that one
|
|
668
|
+
* means "blocked on YOU", this one means "blocked on a machine, nothing for you to do", which is
|
|
669
|
+
* why it must never drive the amber dot. Counted with the ownership union documented on
|
|
670
|
+
* WaitpointInfo (own sessionId OR own channel), deduped per waitpoint. 0 when nothing is pending
|
|
671
|
+
* and 0 when the waitpoint dep is absent (fixtures / TUI). Optional for rolling compatibility
|
|
672
|
+
* with older servers, like `totals` below — consumers read it as `?? 0`. */
|
|
673
|
+
waitingOn?: number;
|
|
652
674
|
/** Real agent-turn count for the composer (NOT the number of user-message rounds). While running,
|
|
653
675
|
* the live count of the in-flight turn (from the running execution); while idle, the last run's
|
|
654
676
|
* final turn count (from the most recent non-thread execution on the session's channel). Null when
|
|
@@ -871,20 +893,6 @@ export interface ThreadAgentFlow {
|
|
|
871
893
|
sessionName: string | null;
|
|
872
894
|
lastOutput: string | null;
|
|
873
895
|
}
|
|
874
|
-
export interface ThreadDispatchInfo {
|
|
875
|
-
executionId: string;
|
|
876
|
-
status: string;
|
|
877
|
-
machine: string | null;
|
|
878
|
-
type: 'local' | 'dispatch';
|
|
879
|
-
agentSlotId: string | null;
|
|
880
|
-
stepIndex: number | null;
|
|
881
|
-
taskId: string | null;
|
|
882
|
-
runName: string | null;
|
|
883
|
-
startedAt: string;
|
|
884
|
-
finishedAt: string | null;
|
|
885
|
-
durationMs: number | null;
|
|
886
|
-
cost: number | null;
|
|
887
|
-
}
|
|
888
896
|
export interface ThreadChildNode {
|
|
889
897
|
id: string;
|
|
890
898
|
templateName: string | null;
|
|
@@ -934,7 +942,6 @@ export interface ThreadDetail {
|
|
|
934
942
|
totalCostUsd: number;
|
|
935
943
|
steps: ThreadStepDetail[];
|
|
936
944
|
agentFlow: ThreadAgentFlow | null;
|
|
937
|
-
dispatches: ThreadDispatchInfo[];
|
|
938
945
|
subtasks: ThreadSubtaskInfo[];
|
|
939
946
|
children: ThreadChildNode[];
|
|
940
947
|
artifacts: ThreadArtifactRefs;
|
|
@@ -1042,6 +1049,83 @@ export interface CommissionDecisionEntry {
|
|
|
1042
1049
|
sessionId: string;
|
|
1043
1050
|
item: DecisionItem;
|
|
1044
1051
|
}
|
|
1052
|
+
/** One signal that has landed on a waitpoint. `message`/`member`/`source` are written by the
|
|
1053
|
+
* external process — plain text only, never interpreted. */
|
|
1054
|
+
export interface WaitpointSignalInfo {
|
|
1055
|
+
at: number;
|
|
1056
|
+
status: 'ok' | 'fail' | 'progress';
|
|
1057
|
+
member: string | null;
|
|
1058
|
+
message: string | null;
|
|
1059
|
+
source: string;
|
|
1060
|
+
}
|
|
1061
|
+
/** One waitpoint a session is still waiting on (docs/waitpoints.md). Only `armed` ones are returned:
|
|
1062
|
+
* a fired or expired waitpoint has already posted its own notice into the transcript, so repeating
|
|
1063
|
+
* it in a panel would tell the same story twice.
|
|
1064
|
+
*
|
|
1065
|
+
* OWNERSHIP — a waitpoint belongs to a session when EITHER holds:
|
|
1066
|
+
* `owner.sessionId === session.sessionId` the session armed it, or
|
|
1067
|
+
* `owner.channel === session's channel` the wake will be delivered HERE.
|
|
1068
|
+
* Both clauses are needed. The first survives a channel rebind (`bindChannel` does not rewrite
|
|
1069
|
+
* `record.channel`); the second survives the session being recreated (`!new`, a scheduled re-run),
|
|
1070
|
+
* because delivery is channel-addressed and find-or-creates a session. A consequence worth knowing:
|
|
1071
|
+
* the second clause can legitimately surface a waitpoint armed by an EARLIER session on the same
|
|
1072
|
+
* channel — that is honest, since its wake really will land on the current one.
|
|
1073
|
+
*
|
|
1074
|
+
* SECURITY: built field-by-field from the stored record, never by spreading it, so the capability
|
|
1075
|
+
* secret hash cannot leak by omission. `signals[].data` is deliberately absent — externally written
|
|
1076
|
+
* and capped at 16 KB per signal, it would bloat every list response. */
|
|
1077
|
+
export interface WaitpointInfo {
|
|
1078
|
+
/** `wp_<12 hex>` — public, appears in notices and in the signal command line. */
|
|
1079
|
+
id: string;
|
|
1080
|
+
/** Agent-written short name. */
|
|
1081
|
+
label: string;
|
|
1082
|
+
/** What the agent said it was waiting for, in its own words. */
|
|
1083
|
+
intent: string;
|
|
1084
|
+
/** Always `armed` today; the wider union is carried so the shape survives if settled waitpoints
|
|
1085
|
+
* are ever surfaced. */
|
|
1086
|
+
state: 'armed' | 'fired' | 'expired' | 'cancelled';
|
|
1087
|
+
/** Where the signal is expected from. `device` names the machine whose spool dir the sweep drains. */
|
|
1088
|
+
emitFrom: {
|
|
1089
|
+
kind: 'local';
|
|
1090
|
+
} | {
|
|
1091
|
+
kind: 'device';
|
|
1092
|
+
device: string;
|
|
1093
|
+
};
|
|
1094
|
+
/** Quorum progress. `got` counts distinct REPORTER KEYS, not signals: named members are deduped,
|
|
1095
|
+
* anonymous signals take synthetic slots. So `got` can exceed `members.length`, and a per-member
|
|
1096
|
+
* checklist must never be rendered from `members` alone. */
|
|
1097
|
+
quorum: {
|
|
1098
|
+
need: number;
|
|
1099
|
+
got: number;
|
|
1100
|
+
members: string[];
|
|
1101
|
+
};
|
|
1102
|
+
/** A single `fail` resolves it with the quorum unmet — which is why a resolved waitpoint can
|
|
1103
|
+
* legitimately read "1 of 3". */
|
|
1104
|
+
failFast: boolean;
|
|
1105
|
+
/** Mailbox mode. After each fire below `maxSignals` the quorum counter resets, so progress
|
|
1106
|
+
* appearing to go backwards is not a bug — `fires`/`maxSignals` is what disambiguates it. */
|
|
1107
|
+
fires: number;
|
|
1108
|
+
maxSignals: number;
|
|
1109
|
+
createdAt: number;
|
|
1110
|
+
expiresAt: number;
|
|
1111
|
+
/** Signals received so far, oldest first. Includes `progress` reports, which never resolve. */
|
|
1112
|
+
signals: WaitpointSignalInfo[];
|
|
1113
|
+
/** Delivery write-ahead bit. `pending && attempts > 1 && lastError` is the silent failure
|
|
1114
|
+
* "the signal landed but the wake did not, and it is being retried" — invisible everywhere else.
|
|
1115
|
+
* `lastError` is a locally generated message, not attacker input. */
|
|
1116
|
+
delivery: {
|
|
1117
|
+
pending: boolean;
|
|
1118
|
+
attempts: number;
|
|
1119
|
+
lastError: string | null;
|
|
1120
|
+
lastAt: number | null;
|
|
1121
|
+
};
|
|
1122
|
+
/** Wakes spent in the trailing hour, and the cap they are counted against. */
|
|
1123
|
+
wakesLastHour: number;
|
|
1124
|
+
wakeLimit: number;
|
|
1125
|
+
/** True once the rate limit has bitten: further signals are RECORDED BUT NEVER WAKE the session,
|
|
1126
|
+
* and the flag is never reset. The loudest thing this DTO carries. */
|
|
1127
|
+
rateLimited: boolean;
|
|
1128
|
+
}
|
|
1045
1129
|
export interface ExecutionInfo {
|
|
1046
1130
|
id: string;
|
|
1047
1131
|
type: 'local' | 'dispatch';
|
|
@@ -1075,18 +1159,12 @@ export interface ExecutionDetailInfo {
|
|
|
1075
1159
|
tmuxName: string | null;
|
|
1076
1160
|
sessionName: string | null;
|
|
1077
1161
|
scheduleTaskId: string | null;
|
|
1078
|
-
/** cortex-run `--name`; non-null ⇒ a live `execution.log` stream is subscribable (B2-C 8b). */
|
|
1079
|
-
runName: string | null;
|
|
1080
1162
|
} | null;
|
|
1081
1163
|
metrics: {
|
|
1082
1164
|
costUsd: number | null;
|
|
1083
1165
|
numTurns: number | null;
|
|
1084
1166
|
durationS: number | null;
|
|
1085
1167
|
};
|
|
1086
|
-
gpu: {
|
|
1087
|
-
indices: number[];
|
|
1088
|
-
memoryMb: number | null;
|
|
1089
|
-
} | null;
|
|
1090
1168
|
text: {
|
|
1091
1169
|
label: string | null;
|
|
1092
1170
|
finalOutput: string | null;
|
|
@@ -1352,7 +1430,7 @@ export interface MachineGpuProcess {
|
|
|
1352
1430
|
memoryMb: number;
|
|
1353
1431
|
}
|
|
1354
1432
|
export interface MachineGpu {
|
|
1355
|
-
/** CUDA device ordinal
|
|
1433
|
+
/** CUDA device ordinal. */
|
|
1356
1434
|
index: number;
|
|
1357
1435
|
name: string;
|
|
1358
1436
|
utilPercent: number;
|
|
@@ -1377,10 +1455,7 @@ export interface MachineVitals {
|
|
|
1377
1455
|
export interface MachineLiveRun {
|
|
1378
1456
|
executionId: string;
|
|
1379
1457
|
taskId: string | null;
|
|
1380
|
-
runName: string | null;
|
|
1381
1458
|
project: string | null;
|
|
1382
|
-
/** GPU ordinals the run actually acquired (recorded by the client watcher); [] when unknown. */
|
|
1383
|
-
gpuIndices: number[];
|
|
1384
1459
|
startedAt: string | null;
|
|
1385
1460
|
}
|
|
1386
1461
|
export interface MachineDetail {
|
|
@@ -1699,10 +1774,10 @@ export interface MemoryFileEntry {
|
|
|
1699
1774
|
}
|
|
1700
1775
|
export interface MemoryDirEntry {
|
|
1701
1776
|
name: string;
|
|
1702
|
-
/** Number of `*.md` entry files, excluding the auto-generated `index.md` and `
|
|
1777
|
+
/** Number of `*.md` entry files, excluding the auto-generated `index.md` and `AGENTS.md`. */
|
|
1703
1778
|
entryCount: number;
|
|
1704
1779
|
/**
|
|
1705
|
-
* The dir's `*.md` entry files (same filter as `entryCount` — excludes `index.md` / `
|
|
1780
|
+
* The dir's `*.md` entry files (same filter as `entryCount` — excludes `index.md` / `AGENTS.md`),
|
|
1706
1781
|
* sorted by name. Lets a client enumerate + open the files under each memory dir (mobile 1j
|
|
1707
1782
|
* accordion) without a second round-trip. `entryCount === entries.length`.
|
|
1708
1783
|
*/
|
|
@@ -1943,6 +2018,11 @@ export interface ThreadsCancelReturn {
|
|
|
1943
2018
|
export interface ExecutionsCancelReturn {
|
|
1944
2019
|
cancelled: boolean;
|
|
1945
2020
|
}
|
|
2021
|
+
export interface WaitpointsCancelReturn {
|
|
2022
|
+
cancelled: boolean;
|
|
2023
|
+
/** The state that blocked the cancel when `cancelled` is false (already fired/expired/cancelled). */
|
|
2024
|
+
state: string | null;
|
|
2025
|
+
}
|
|
1946
2026
|
export interface ConfigSetReturn {
|
|
1947
2027
|
written: true;
|
|
1948
2028
|
section: 'budget' | 'profiles' | 'settings' | 'preferences';
|
|
@@ -1991,6 +2071,7 @@ export interface QueryParamMap {
|
|
|
1991
2071
|
'commissions.get': CommissionsGetParams;
|
|
1992
2072
|
'commissions.decisions': CommissionsDecisionsParams;
|
|
1993
2073
|
'executions.list': ExecutionsListParams;
|
|
2074
|
+
'waitpoints.list': WaitpointsListParams;
|
|
1994
2075
|
'executions.get': ExecutionsGetParams;
|
|
1995
2076
|
'memory.tree': MemoryTreeParams;
|
|
1996
2077
|
'memory.file': MemoryFileParams;
|
|
@@ -2034,6 +2115,7 @@ export interface QueryReturnMap {
|
|
|
2034
2115
|
'commissions.get': CommissionInfo;
|
|
2035
2116
|
'commissions.decisions': CommissionDecisionEntry[];
|
|
2036
2117
|
'executions.list': ExecutionInfo[];
|
|
2118
|
+
'waitpoints.list': WaitpointInfo[];
|
|
2037
2119
|
'executions.get': ExecutionDetailInfo;
|
|
2038
2120
|
'memory.tree': MemoryTree;
|
|
2039
2121
|
'memory.file': MemoryFile;
|
|
@@ -2072,6 +2154,7 @@ export interface MutateArgsMap {
|
|
|
2072
2154
|
'sessions.setCommission': SessionsSetCommissionArgs;
|
|
2073
2155
|
'sessions.createAndSend': SessionsCreateAndSendArgs;
|
|
2074
2156
|
'sessions.markRead': SessionsMarkReadArgs;
|
|
2157
|
+
'sessions.markManyRead': SessionsMarkManyReadArgs;
|
|
2075
2158
|
'sessions.answerQuestion': SessionsAnswerQuestionArgs;
|
|
2076
2159
|
'sessions.respondPlan': SessionsRespondPlanArgs;
|
|
2077
2160
|
'sessions.respondDecision': SessionsRespondDecisionArgs;
|
|
@@ -2079,6 +2162,7 @@ export interface MutateArgsMap {
|
|
|
2079
2162
|
'sessions.rewind': SessionsRewindArgs;
|
|
2080
2163
|
'threads.cancel': ThreadsCancelArgs;
|
|
2081
2164
|
'executions.cancel': ExecutionsCancelArgs;
|
|
2165
|
+
'waitpoints.cancel': WaitpointsCancelArgs;
|
|
2082
2166
|
'schedules.pause': ScheduleActionArgs;
|
|
2083
2167
|
'schedules.resume': ScheduleActionArgs;
|
|
2084
2168
|
'schedules.remove': ScheduleActionArgs;
|
|
@@ -2147,6 +2231,7 @@ export interface MutateReturnMap {
|
|
|
2147
2231
|
'sessions.setCommission': SessionsSetCommissionReturn;
|
|
2148
2232
|
'sessions.createAndSend': SessionsCreateAndSendReturn;
|
|
2149
2233
|
'sessions.markRead': void;
|
|
2234
|
+
'sessions.markManyRead': SessionsMarkManyReadReturn;
|
|
2150
2235
|
'sessions.answerQuestion': SessionsInteractionMutateReturn;
|
|
2151
2236
|
'sessions.respondPlan': SessionsInteractionMutateReturn;
|
|
2152
2237
|
'sessions.respondDecision': SessionsRespondDecisionReturn;
|
|
@@ -2154,6 +2239,7 @@ export interface MutateReturnMap {
|
|
|
2154
2239
|
'sessions.rewind': SessionsRewindReturn;
|
|
2155
2240
|
'threads.cancel': ThreadsCancelReturn;
|
|
2156
2241
|
'executions.cancel': ExecutionsCancelReturn;
|
|
2242
|
+
'waitpoints.cancel': WaitpointsCancelReturn;
|
|
2157
2243
|
'schedules.pause': void;
|
|
2158
2244
|
'schedules.resume': void;
|
|
2159
2245
|
'schedules.remove': void;
|
|
@@ -2224,14 +2310,6 @@ export interface UiService {
|
|
|
2224
2310
|
subscribe(filter: SubscribeFilter): AsyncIterable<UiEvent> & {
|
|
2225
2311
|
close(): void;
|
|
2226
2312
|
};
|
|
2227
|
-
/**
|
|
2228
|
-
* Live `execution.log` stream for one running execution (B2-C). Resolves the log location from
|
|
2229
|
-
* the executionId, ref-counts the shared tailer (first subscriber starts it, last stops it), and
|
|
2230
|
-
* delivers lines over the same bounded queue as `subscribe`. A closed stream when unresolvable.
|
|
2231
|
-
*/
|
|
2232
|
-
subscribeExecutionLog(executionId: string): AsyncIterable<UiEvent> & {
|
|
2233
|
-
close(): void;
|
|
2234
|
-
};
|
|
2235
2313
|
}
|
|
2236
2314
|
export interface UiServiceDeps {
|
|
2237
2315
|
/** Optional seams for deterministic authentication dispatch tests. */
|
|
@@ -2487,6 +2565,18 @@ export interface UiServiceDeps {
|
|
|
2487
2565
|
getAll(): any[];
|
|
2488
2566
|
cancelExecution(id: string, metrics?: any): any | null;
|
|
2489
2567
|
};
|
|
2568
|
+
/** Waitpoint seam (`waitpoints.*` ops and SessionInfo.waitingOn). Injected at the entry layer so
|
|
2569
|
+
* the ui-service domain never reaches into the waitpoint store itself. Optional on purpose:
|
|
2570
|
+
* absent ⇒ no waitpoints and `waitingOn: 0`, so every existing fixture keeps working unchanged.
|
|
2571
|
+
* Only `armed` records are ever listed — settled ones have already announced themselves in the
|
|
2572
|
+
* session transcript. */
|
|
2573
|
+
waitpointRegistry?: {
|
|
2574
|
+
listArmed(): Promise<Waitpoint[]>;
|
|
2575
|
+
cancel(id: string): Promise<{
|
|
2576
|
+
cancelled: boolean;
|
|
2577
|
+
state?: string;
|
|
2578
|
+
}>;
|
|
2579
|
+
};
|
|
2490
2580
|
/** Commission registry seam (commissions.* ops). Optional — handlers fall back to the
|
|
2491
2581
|
* commissionRepo singleton when absent, so existing fixtures/entry wiring need no change;
|
|
2492
2582
|
* tests inject it for determinism. */
|
|
@@ -2497,12 +2587,6 @@ export interface UiServiceDeps {
|
|
|
2497
2587
|
};
|
|
2498
2588
|
/** Absolute path to PENDING_APPROVALS.md (the approval-center 7a markdown queue). */
|
|
2499
2589
|
approvalsPath: string;
|
|
2500
|
-
/** Ref-counted live log tailer (B2-C). Started/stopped around each execution.log subscription. */
|
|
2501
|
-
executionLogTailer: {
|
|
2502
|
-
startTail(executionId: string, location: LogLocation): void;
|
|
2503
|
-
stopTail(executionId: string): void;
|
|
2504
|
-
refCount(executionId: string): number;
|
|
2505
|
-
};
|
|
2506
2590
|
/** The one busy answer (core/session-state.ts): sessions.list joins on it rather than
|
|
2507
2591
|
* re-deriving "running" from the executions index and the hold registry separately. */
|
|
2508
2592
|
runningExecutions: SessionStateReader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// input: domain, platform, auth and runtime setting types
|
|
2
2
|
// output: canonical UI DTOs and operation signatures
|
|
3
3
|
// pos: Transport-neutral UI service contract
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: UI dependencies and operation handlers
|
|
2
2
|
// output: UI dispatcher with credential-safe mutation audit
|
|
3
3
|
// pos: Transport-neutral UI-service dispatcher
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import { handleProjectsList } from './query/projects.js';
|
|
6
6
|
import { handleSessionsList, handleSessionsTranscript, handleSessionsSubagentTranscript, handleSessionsDebugDetails, handleSessionsPendingInteraction, } from './query/sessions.js';
|
|
7
7
|
import { handleThreadsList, handleThreadsGet } from './query/threads.js';
|
|
@@ -10,6 +10,7 @@ import { handleTaskVerification } from './query/task-verification.js';
|
|
|
10
10
|
import { handleSchedulesList } from './query/schedules.js';
|
|
11
11
|
import { handleCommissionsList, handleCommissionsGet, handleCommissionsDecisions, } from './query/commissions.js';
|
|
12
12
|
import { handleExecutionsList, handleExecutionsGet } from './query/executions.js';
|
|
13
|
+
import { handleWaitpointsList } from './query/waitpoints.js';
|
|
13
14
|
import { handleMemoryTree, handleMemoryFile } from './query/memory.js';
|
|
14
15
|
import { handleApprovalsList } from './query/approvals.js';
|
|
15
16
|
import { handleIssuesList } from './query/issues.js';
|
|
@@ -36,9 +37,10 @@ import { handleThreadTemplatesValidate, handleThreadTemplatesSave, handleThreadT
|
|
|
36
37
|
import { handlePluginsAssign } from './mutate/plugins.js';
|
|
37
38
|
import { handlePluginsSkillWrite, handlePluginsSkillCreate, handlePluginsSkillMove, handlePluginsSkillRemove, handlePluginsCreate, handlePluginsRemove, handlePluginsConvertToPortable, handlePluginsMcpWrite, } from './mutate/plugin-packages.js';
|
|
38
39
|
import { handleCreateProject } from './mutate/projects.js';
|
|
39
|
-
import { handleCreateSession, handleSendSession, handleCancelSession, handleCompactSession, handleSetProfile, handleSetSelection, handleSetCommission, handleCreateAndSend, handleMarkReadSession, handleAnswerQuestion, handleRespondPlan, handleRespondDecision, handleCancelResume, handleRewindSession } from './mutate/sessions.js';
|
|
40
|
+
import { handleCreateSession, handleSendSession, handleCancelSession, handleCompactSession, handleSetProfile, handleSetSelection, handleSetCommission, handleCreateAndSend, handleMarkReadSession, handleMarkManyReadSessions, handleAnswerQuestion, handleRespondPlan, handleRespondDecision, handleCancelResume, handleRewindSession } from './mutate/sessions.js';
|
|
40
41
|
import { handleCancelThread } from './mutate/threads.js';
|
|
41
42
|
import { handleCancelExecution } from './mutate/executions.js';
|
|
43
|
+
import { handleCancelWaitpoint } from './mutate/waitpoints.js';
|
|
42
44
|
import { handlePauseSchedule, handleResumeSchedule, handleRemoveSchedule, handleAddSchedule, handleUpdateSchedule, } from './mutate/schedules.js';
|
|
43
45
|
import { handleCommissionClose } from './mutate/commissions.js';
|
|
44
46
|
import { handleClaimTask, handleUnclaimTask, handleCompleteTask, handleBlockTask, handleUnblockTask, } from './mutate/tasks.js';
|
|
@@ -49,7 +51,6 @@ import { handleSystemRestart, handleSystemClearRateLimit, handleSystemRefreshUsa
|
|
|
49
51
|
import { handleAuthCancelFlow, handleAuthLogout, handleAuthSyncGateway, handleAuthRespondPrompt, handleAuthStartLogin, } from './mutate/auth.js';
|
|
50
52
|
import { handleCustomProviderRemove, handleCustomProviderUpsert, } from './mutate/custom-providers.js';
|
|
51
53
|
import { createSubscription } from './subscribe.js';
|
|
52
|
-
import { resolveExecutionLogLocation } from '../executions/log-tailer.js';
|
|
53
54
|
const queryHandlers = {
|
|
54
55
|
'projects.list': (deps) => handleProjectsList(deps),
|
|
55
56
|
'sessions.list': (deps, params) => handleSessionsList(deps, params),
|
|
@@ -66,6 +67,7 @@ const queryHandlers = {
|
|
|
66
67
|
'commissions.get': (deps, params) => handleCommissionsGet(deps, params),
|
|
67
68
|
'commissions.decisions': (deps, params) => handleCommissionsDecisions(deps, params),
|
|
68
69
|
'executions.list': (deps, params) => handleExecutionsList(deps, params),
|
|
70
|
+
'waitpoints.list': (deps, params) => handleWaitpointsList(deps, params),
|
|
69
71
|
'executions.get': (deps, params) => handleExecutionsGet(deps, params),
|
|
70
72
|
'memory.tree': (deps, params) => handleMemoryTree(deps, params),
|
|
71
73
|
'memory.file': (deps, params) => handleMemoryFile(deps, params),
|
|
@@ -104,6 +106,7 @@ const mutateHandlers = {
|
|
|
104
106
|
'sessions.setCommission': (deps, args) => handleSetCommission(deps, args),
|
|
105
107
|
'sessions.createAndSend': (deps, args) => handleCreateAndSend(deps, args),
|
|
106
108
|
'sessions.markRead': (deps, args) => handleMarkReadSession(deps, args),
|
|
109
|
+
'sessions.markManyRead': (deps, args) => handleMarkManyReadSessions(deps, args),
|
|
107
110
|
'sessions.answerQuestion': (deps, args) => handleAnswerQuestion(deps, args),
|
|
108
111
|
'sessions.respondPlan': (deps, args) => handleRespondPlan(deps, args),
|
|
109
112
|
'sessions.respondDecision': (deps, args) => handleRespondDecision(deps, args),
|
|
@@ -111,6 +114,7 @@ const mutateHandlers = {
|
|
|
111
114
|
'sessions.rewind': (deps, args) => handleRewindSession(deps, args),
|
|
112
115
|
'threads.cancel': (deps, args) => handleCancelThread(deps, args),
|
|
113
116
|
'executions.cancel': (deps, args) => handleCancelExecution(deps, args),
|
|
117
|
+
'waitpoints.cancel': (deps, args) => handleCancelWaitpoint(deps, args),
|
|
114
118
|
'schedules.pause': (deps, args) => handlePauseSchedule(deps, args),
|
|
115
119
|
'schedules.resume': (deps, args) => handleResumeSchedule(deps, args),
|
|
116
120
|
'schedules.remove': (deps, args) => handleRemoveSchedule(deps, args),
|
|
@@ -232,33 +236,5 @@ export function createUiService(deps) {
|
|
|
232
236
|
subscribe(filter) {
|
|
233
237
|
return createSubscription(deps.bus, filter);
|
|
234
238
|
},
|
|
235
|
-
subscribeExecutionLog(executionId) {
|
|
236
|
-
// Resolve the run's log location from the persisted dispatch.runName (B2-C). When it cannot
|
|
237
|
-
// be resolved (unknown id / no runName / not a cortex-run), hand back an already-closed
|
|
238
|
-
// stream so the client ends cleanly rather than hanging on a tail that will never emit.
|
|
239
|
-
const location = resolveExecutionLogLocation(executionId, {
|
|
240
|
-
getExecution: (id) => deps.executionRegistry.getExecution(id),
|
|
241
|
-
});
|
|
242
|
-
if (!location) {
|
|
243
|
-
const empty = createSubscription(deps.bus, { events: [] });
|
|
244
|
-
empty.close();
|
|
245
|
-
return empty;
|
|
246
|
-
}
|
|
247
|
-
// First subscriber starts the shared tailer (ref-count +1); the last close stops it (-1).
|
|
248
|
-
deps.executionLogTailer.startTail(executionId, location);
|
|
249
|
-
const sub = createSubscription(deps.bus, { events: ['execution.log'], executionId });
|
|
250
|
-
let stopped = false;
|
|
251
|
-
const close = () => {
|
|
252
|
-
sub.close();
|
|
253
|
-
if (stopped)
|
|
254
|
-
return;
|
|
255
|
-
stopped = true;
|
|
256
|
-
deps.executionLogTailer.stopTail(executionId);
|
|
257
|
-
};
|
|
258
|
-
return {
|
|
259
|
-
[Symbol.asyncIterator]: () => sub[Symbol.asyncIterator](),
|
|
260
|
-
close,
|
|
261
|
-
};
|
|
262
|
-
},
|
|
263
239
|
};
|
|
264
240
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Waitpoint, WaitpointSignal } from '../../store/waitpoint-repo.js';
|
|
2
|
+
export declare function formatDuration(ms: number): string;
|
|
3
|
+
/** One-line reminder of what the agent said it was waiting for. */
|
|
4
|
+
export declare function describeWaitFor(wp: Waitpoint): string;
|
|
5
|
+
export interface SignalNoticeOptions {
|
|
6
|
+
/** Signals folded into this wake (a coalesce window may hold several). */
|
|
7
|
+
signals: WaitpointSignal[];
|
|
8
|
+
now: number;
|
|
9
|
+
/** Set when this wake is the last one before the per-hour cap starts withholding. */
|
|
10
|
+
rateLimited?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The turn text delivered when a waitpoint fires.
|
|
14
|
+
*
|
|
15
|
+
* Wrapped in `<system-reminder>` like the task-callback notice, and the external payload is
|
|
16
|
+
* explicitly framed as data: it is attacker-controlled in the general case (anything holding the
|
|
17
|
+
* capability can write it) and it arrives in the transcript as a *user* turn.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildSignalNotice(wp: Waitpoint, opts: SignalNoticeOptions): string;
|
|
20
|
+
/** Delivered when a waitpoint's deadline passes with nobody ever signalling it. */
|
|
21
|
+
export declare function buildExpiryNotice(wp: Waitpoint, now: number): string;
|