@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
|
@@ -244,13 +244,12 @@ function buildDispatchPrompt(task) {
|
|
|
244
244
|
'',
|
|
245
245
|
'**CRITICAL: Before marking any task complete, verify ALL done_when conditions are actually satisfied.**',
|
|
246
246
|
'',
|
|
247
|
-
`
|
|
248
|
-
` cortex-run --name NAME --task-project ${task.project} --task-id ${task.id} -- COMMAND`,
|
|
249
|
-
`cortex-run will auto-mark the task pending on start, then complete on success / block on failure.`,
|
|
250
|
-
'',
|
|
251
|
-
`If NOT using cortex-run, verify done_when conditions, then run:`,
|
|
247
|
+
`Verify done_when conditions, then run:`,
|
|
252
248
|
` cortex-task complete --project ${task.project} --task-id ${task.id} --note "your completion note"`,
|
|
253
249
|
'',
|
|
250
|
+
`If something outside this turn has to finish first (a long run, a build), arm a waitpoint with`,
|
|
251
|
+
`wait_create, mark the task pending, and complete it when the signal wakes you.`,
|
|
252
|
+
'',
|
|
254
253
|
'- Update the project STATUS.md if the work changed project state',
|
|
255
254
|
];
|
|
256
255
|
sections.push(completion.join('\n'));
|
|
@@ -26,8 +26,8 @@ export declare class TaskMutator {
|
|
|
26
26
|
constructor(store?: TaskRepo, bus?: EventBus);
|
|
27
27
|
setBus(bus: EventBus): void;
|
|
28
28
|
/** getById with a one-shot refresh on miss: tasks created out-of-process (CLI, manager
|
|
29
|
-
* threads) reach the in-memory cache only on refresh —
|
|
30
|
-
*
|
|
29
|
+
* threads) reach the in-memory cache only on refresh — a caller may fire before any
|
|
30
|
+
* dispatch cycle has reloaded TASKS.yaml. */
|
|
31
31
|
private getByIdFresh;
|
|
32
32
|
claim(taskId: string, agent: string, options?: ClaimTaskOptions): Promise<any>;
|
|
33
33
|
unclaim(taskId: string, options?: OwnedMutationOptions): Promise<any>;
|
|
@@ -39,8 +39,8 @@ export class TaskMutator {
|
|
|
39
39
|
this.bus = bus;
|
|
40
40
|
}
|
|
41
41
|
/** getById with a one-shot refresh on miss: tasks created out-of-process (CLI, manager
|
|
42
|
-
* threads) reach the in-memory cache only on refresh —
|
|
43
|
-
*
|
|
42
|
+
* threads) reach the in-memory cache only on refresh — a caller may fire before any
|
|
43
|
+
* dispatch cycle has reloaded TASKS.yaml. */
|
|
44
44
|
getByIdFresh(taskId) {
|
|
45
45
|
let task = this.store.getById(taskId);
|
|
46
46
|
if (!task) {
|
|
@@ -108,8 +108,8 @@ const HELP_CONFIG = {
|
|
|
108
108
|
{ name: 'unclaim', description: 'Remove in-progress status' },
|
|
109
109
|
{ name: 'pause', description: 'Pause' },
|
|
110
110
|
{ name: 'resume', description: 'Resume a paused task' },
|
|
111
|
-
{ name: 'pending', description: 'Mark pending (waiting
|
|
112
|
-
{ name: 'reopen', description: 'Restore a stuck pending task back to open (e.g.
|
|
111
|
+
{ name: 'pending', description: 'Mark pending (waiting on work outside this turn)' },
|
|
112
|
+
{ name: 'reopen', description: 'Restore a stuck pending task back to open (e.g. the awaited work never reported)' },
|
|
113
113
|
{ name: 'complete', description: 'Mark complete (--note)' },
|
|
114
114
|
{ name: 'uncomplete', description: 'Reverse a completed task' },
|
|
115
115
|
],
|
|
@@ -173,7 +173,7 @@ function blockTaskUnlocked(taskText, project, reason, taskId = null, ownership)
|
|
|
173
173
|
task.dispatch_generation = ownership?.generation ?? null;
|
|
174
174
|
task.pending_at = null;
|
|
175
175
|
task.blocked_by = reason;
|
|
176
|
-
// Normalize a 'pending' (
|
|
176
|
+
// Normalize a 'pending' (waiting on outside work) task back to 'open'. `status === 'pending'`
|
|
177
177
|
// is an independent dispatch-exclusion gate (task-parser isActionable), so leaving it
|
|
178
178
|
// here would make the task invisible to the dispatcher even after it is unblocked.
|
|
179
179
|
// blocked_by still gates dispatch, so this is safe. Never resurrect a done task.
|
|
@@ -285,7 +285,9 @@ export function buildThreadRunRequest(threadId, stepCtx, ctx, opts) {
|
|
|
285
285
|
text: stepCtx.prompt,
|
|
286
286
|
// First-step files only (never re-attached on an interrupted-session resume).
|
|
287
287
|
attachments: stepCtx.isFirstStep && !stepCtx.interruptedResume
|
|
288
|
-
? (opts.files || []).map((file) => ({
|
|
288
|
+
? (opts.files || []).map((file) => ({
|
|
289
|
+
mimeType: file.mimetype, path: file.localPath, name: file.name,
|
|
290
|
+
}))
|
|
289
291
|
: [],
|
|
290
292
|
},
|
|
291
293
|
context: {
|
|
@@ -191,6 +191,13 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
191
191
|
output: void;
|
|
192
192
|
meta: object;
|
|
193
193
|
}>;
|
|
194
|
+
markManyRead: import("@trpc/server").TRPCMutationProcedure<{
|
|
195
|
+
input: {
|
|
196
|
+
sessionIds: string[];
|
|
197
|
+
};
|
|
198
|
+
output: import("./types.js").SessionsMarkManyReadReturn;
|
|
199
|
+
meta: object;
|
|
200
|
+
}>;
|
|
194
201
|
answerQuestion: import("@trpc/server").TRPCMutationProcedure<{
|
|
195
202
|
input: {
|
|
196
203
|
requestId: string;
|
|
@@ -472,11 +479,25 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
472
479
|
output: import("./types.js").ExecutionsCancelReturn;
|
|
473
480
|
meta: object;
|
|
474
481
|
}>;
|
|
475
|
-
|
|
482
|
+
}>>;
|
|
483
|
+
waitpoints: import("@trpc/server").TRPCBuiltRouter<{
|
|
484
|
+
ctx: object;
|
|
485
|
+
meta: object;
|
|
486
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
487
|
+
transformer: false;
|
|
488
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
489
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
490
|
+
input: {
|
|
491
|
+
sessionId: string;
|
|
492
|
+
};
|
|
493
|
+
output: import("./types.js").WaitpointInfo[];
|
|
494
|
+
meta: object;
|
|
495
|
+
}>;
|
|
496
|
+
cancel: import("@trpc/server").TRPCMutationProcedure<{
|
|
476
497
|
input: {
|
|
477
|
-
|
|
498
|
+
waitpointId: string;
|
|
478
499
|
};
|
|
479
|
-
output:
|
|
500
|
+
output: import("./types.js").WaitpointsCancelReturn;
|
|
480
501
|
meta: object;
|
|
481
502
|
}>;
|
|
482
503
|
}>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// input: UI service, operation schemas and tRPC
|
|
2
2
|
// output: typed UI router including platform configuration
|
|
3
3
|
// pos: Typed tRPC mirror of UI operations
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import { platformSettingsInput } from '../../core/platform-settings-spec.js';
|
|
6
6
|
import { TRPCError } from '@trpc/server';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { router, publicProcedure } from './trpc.js';
|
|
9
|
-
import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput, sessionsSetProfileInput, sessionsSetSelectionInput, sessionsSetCommissionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, commissionCloseInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, approvalsApproveInput, approvalsRejectInput, approvalsRequestInput, issuesListInput, issueActionInput, notesListInput, noteAddInput, noteUpdateInput, noteSetCompletedInput, noteActionInput, notesClearCompletedInput, costSummaryInput, threadsCancelInput, executionsCancelInput, scheduleActionInput, scheduleAddInput, scheduleUpdateInput, taskActionInput, taskCompleteInput, taskBlockInput,
|
|
9
|
+
import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput, sessionsSetProfileInput, sessionsSetSelectionInput, sessionsSetCommissionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsMarkManyReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, commissionCloseInput, executionsListInput, waitpointsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, approvalsApproveInput, approvalsRejectInput, approvalsRequestInput, issuesListInput, issueActionInput, notesListInput, noteAddInput, noteUpdateInput, noteSetCompletedInput, noteActionInput, notesClearCompletedInput, costSummaryInput, threadsCancelInput, executionsCancelInput, waitpointsCancelInput, scheduleActionInput, scheduleAddInput, scheduleUpdateInput, taskActionInput, taskCompleteInput, taskBlockInput, configGetInput, configSetInput, configSetProviderRateLimitPolicyInput, authStatusInput, authFlowStateInput, authStartLoginInput, authRespondPromptInput, authCancelFlowInput, authLogoutInput, authSyncGatewayInput, authCustomProvidersInput, authUpsertCustomProviderInput, authRemoveCustomProviderInput, hooksListInput, hooksCreateInput, hooksUpdateInput, hooksSetEnabledInput, hooksRemoveInput, hooksTestInput, profilesCreateInput, profilesUpdateInput, profilesRemoveInput, modelsCatalogInput, machinesListInput, machineDetailInput, skillsListInput, pluginsListInput, pluginsAssignInput, pluginsSkillFileInput, pluginsSkillWriteInput, pluginsSkillCreateInput, pluginsSkillMoveInput, pluginsSkillRemoveInput, pluginsCreateInput, pluginsRemoveInput, pluginsConvertInput, pluginsMcpReadInput, pluginsMcpWriteInput, threadTemplatesGetInput, threadTemplatesDetailInput, threadTemplatesValidateInput, threadTemplatesSaveInput, threadTemplatesRemoveInput, systemDaemonStatusInput, systemRateLimitStatusInput, systemUsageStatusInput, systemNoticesInput, systemRestartInput, systemClearRateLimitInput, systemRefreshUsageInput, systemUpdateStatusInput, systemApplyUpdateInput, systemSkipUpdateInput, } from './input-schemas.js';
|
|
10
10
|
// ── Subscribe filter input (no keyed schema for subscribe; router-local) ──
|
|
11
11
|
const subscribeFilterInput = z.object({
|
|
12
12
|
events: z.array(z.string()),
|
|
@@ -87,6 +87,7 @@ function sessionsRouter(service) {
|
|
|
87
87
|
setCommission: makeMutation(service, 'sessions.setCommission', sessionsSetCommissionInput),
|
|
88
88
|
createAndSend: makeMutation(service, 'sessions.createAndSend', sessionsCreateAndSendInput),
|
|
89
89
|
markRead: makeMutation(service, 'sessions.markRead', sessionsMarkReadInput),
|
|
90
|
+
markManyRead: makeMutation(service, 'sessions.markManyRead', sessionsMarkManyReadInput),
|
|
90
91
|
answerQuestion: makeMutation(service, 'sessions.answerQuestion', sessionsAnswerQuestionInput),
|
|
91
92
|
respondPlan: makeMutation(service, 'sessions.respondPlan', sessionsRespondPlanInput),
|
|
92
93
|
respondDecision: makeMutation(service, 'sessions.respondDecision', sessionsRespondDecisionInput),
|
|
@@ -130,17 +131,10 @@ function commissionsRouter(service) {
|
|
|
130
131
|
close: makeMutation(service, 'commissions.close', commissionCloseInput),
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
for await (const event of sub)
|
|
139
|
-
yield event;
|
|
140
|
-
}
|
|
141
|
-
finally {
|
|
142
|
-
sub.close();
|
|
143
|
-
}
|
|
134
|
+
function waitpointsRouter(service) {
|
|
135
|
+
return router({
|
|
136
|
+
list: makeQuery(service, 'waitpoints.list', waitpointsListInput),
|
|
137
|
+
cancel: makeMutation(service, 'waitpoints.cancel', waitpointsCancelInput),
|
|
144
138
|
});
|
|
145
139
|
}
|
|
146
140
|
function executionsRouter(service) {
|
|
@@ -148,7 +142,6 @@ function executionsRouter(service) {
|
|
|
148
142
|
list: makeQuery(service, 'executions.list', executionsListInput),
|
|
149
143
|
get: makeQuery(service, 'executions.get', executionsGetInput),
|
|
150
144
|
cancel: makeMutation(service, 'executions.cancel', executionsCancelInput),
|
|
151
|
-
log: executionLogProcedure(service),
|
|
152
145
|
});
|
|
153
146
|
}
|
|
154
147
|
function memoryRouter(service) {
|
|
@@ -304,6 +297,7 @@ export function createAppRouter(service) {
|
|
|
304
297
|
schedules: schedulesRouter(service),
|
|
305
298
|
commissions: commissionsRouter(service),
|
|
306
299
|
executions: executionsRouter(service),
|
|
300
|
+
waitpoints: waitpointsRouter(service),
|
|
307
301
|
memory: memoryRouter(service),
|
|
308
302
|
approvals: approvalsRouter(service),
|
|
309
303
|
issues: issuesRouter(service),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { platformSettingsInput } from '../../core/platform-settings-spec.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput } from './query-input-schemas.js';
|
|
4
|
-
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
|
|
3
|
+
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput } from './query-input-schemas.js';
|
|
4
|
+
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
|
|
5
5
|
export declare const projectsListInput: z.ZodObject<{}, z.core.$strip>;
|
|
6
6
|
export declare const costSummaryInput: z.ZodObject<{
|
|
7
7
|
projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -27,9 +27,6 @@ export declare const systemNoticesInput: z.ZodObject<{
|
|
|
27
27
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
export declare const systemUpdateStatusInput: z.ZodObject<{}, z.core.$strip>;
|
|
30
|
-
export declare const executionsLogInput: z.ZodObject<{
|
|
31
|
-
executionId: z.ZodString;
|
|
32
|
-
}, z.core.$strip>;
|
|
33
30
|
export declare const authStartLoginInput: z.ZodObject<{
|
|
34
31
|
backend: z.ZodEnum<{
|
|
35
32
|
claude: "claude";
|
|
@@ -156,6 +153,9 @@ export declare const sessionsCompactInput: z.ZodObject<{
|
|
|
156
153
|
export declare const sessionsMarkReadInput: z.ZodObject<{
|
|
157
154
|
sessionId: z.ZodString;
|
|
158
155
|
}, z.core.$strip>;
|
|
156
|
+
export declare const sessionsMarkManyReadInput: z.ZodObject<{
|
|
157
|
+
sessionIds: z.ZodArray<z.ZodString>;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
159
|
export declare const sessionsSetProfileInput: z.ZodObject<{
|
|
160
160
|
sessionId: z.ZodString;
|
|
161
161
|
profileName: z.ZodString;
|
|
@@ -232,6 +232,9 @@ export declare const sessionsCreateAndSendInput: z.ZodObject<{
|
|
|
232
232
|
export declare const threadsCancelInput: z.ZodObject<{
|
|
233
233
|
threadId: z.ZodString;
|
|
234
234
|
}, z.core.$strip>;
|
|
235
|
+
export declare const waitpointsCancelInput: z.ZodObject<{
|
|
236
|
+
waitpointId: z.ZodString;
|
|
237
|
+
}, z.core.$strip>;
|
|
235
238
|
export declare const executionsCancelInput: z.ZodObject<{
|
|
236
239
|
executionId: z.ZodString;
|
|
237
240
|
}, z.core.$strip>;
|
|
@@ -662,6 +665,9 @@ export declare const queryInputSchemas: {
|
|
|
662
665
|
status: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
663
666
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
664
667
|
}, z.core.$strip>;
|
|
668
|
+
'waitpoints.list': z.ZodObject<{
|
|
669
|
+
sessionId: z.ZodString;
|
|
670
|
+
}, z.core.$strip>;
|
|
665
671
|
'executions.get': z.ZodObject<{
|
|
666
672
|
executionId: z.ZodString;
|
|
667
673
|
}, z.core.$strip>;
|
|
@@ -825,6 +831,9 @@ export declare const mutateInputSchemas: {
|
|
|
825
831
|
'sessions.markRead': z.ZodObject<{
|
|
826
832
|
sessionId: z.ZodString;
|
|
827
833
|
}, z.core.$strip>;
|
|
834
|
+
'sessions.markManyRead': z.ZodObject<{
|
|
835
|
+
sessionIds: z.ZodArray<z.ZodString>;
|
|
836
|
+
}, z.core.$strip>;
|
|
828
837
|
'sessions.answerQuestion': z.ZodObject<{
|
|
829
838
|
requestId: z.ZodString;
|
|
830
839
|
answers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -858,6 +867,9 @@ export declare const mutateInputSchemas: {
|
|
|
858
867
|
'executions.cancel': z.ZodObject<{
|
|
859
868
|
executionId: z.ZodString;
|
|
860
869
|
}, z.core.$strip>;
|
|
870
|
+
'waitpoints.cancel': z.ZodObject<{
|
|
871
|
+
waitpointId: z.ZodString;
|
|
872
|
+
}, z.core.$strip>;
|
|
861
873
|
'schedules.pause': z.ZodObject<{
|
|
862
874
|
scheduleId: z.ZodString;
|
|
863
875
|
}, z.core.$strip>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: Zod, settings specs and UI operation unions
|
|
2
2
|
// output: UI input validation schemas and operation maps
|
|
3
3
|
// pos: Runtime validation source for UI contract
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import { platformSettingsInput } from '../../core/platform-settings-spec.js';
|
|
6
6
|
export { platformSettingsInput } from '../../core/platform-settings-spec.js';
|
|
7
7
|
import { z } from 'zod';
|
|
@@ -9,8 +9,8 @@ import { SETTINGS_SPEC } from '../../core/settings-spec.js';
|
|
|
9
9
|
// Import the leaf model module, not the pi-providers barrel: this file is bundled for the browser
|
|
10
10
|
// through @cortex-agent/ui-contract, and that module is pure data with no imports of its own.
|
|
11
11
|
import { CUSTOM_PROVIDER_APIS, CUSTOM_PROVIDER_NAME_RE, } from '../pi-providers/custom-provider-model.js';
|
|
12
|
-
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, } from './query-input-schemas.js';
|
|
13
|
-
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
|
|
12
|
+
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, } from './query-input-schemas.js';
|
|
13
|
+
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
|
|
14
14
|
// ── Query input schemas ───────────────────────────────────────────
|
|
15
15
|
export const projectsListInput = z.object({});
|
|
16
16
|
export const costSummaryInput = z.object({
|
|
@@ -35,12 +35,6 @@ export const systemRateLimitStatusInput = z.object({});
|
|
|
35
35
|
export const systemUsageStatusInput = z.object({});
|
|
36
36
|
export const systemNoticesInput = z.object({ limit: z.number().int().positive().max(50).optional() });
|
|
37
37
|
export const systemUpdateStatusInput = z.object({});
|
|
38
|
-
// ── Subscription input schemas ────────────────────────────────────
|
|
39
|
-
// Subscriptions are not part of the query/mutate keyed maps; their input schemas live here too so
|
|
40
|
-
// the AppRouter and the browser (@cortex-agent/ui-contract) share one source of truth (B2-C).
|
|
41
|
-
export const executionsLogInput = z.object({
|
|
42
|
-
executionId: z.string(),
|
|
43
|
-
});
|
|
44
38
|
// ── Mutate input schemas ──────────────────────────────────────────
|
|
45
39
|
export const authStartLoginInput = z.object({
|
|
46
40
|
backend: z.enum(['claude', 'pi']),
|
|
@@ -139,6 +133,10 @@ export const sessionsCompactInput = z.object({
|
|
|
139
133
|
export const sessionsMarkReadInput = z.object({
|
|
140
134
|
sessionId: z.string(),
|
|
141
135
|
});
|
|
136
|
+
// Bounded batch: the run list of one schedule, never "every session on the box".
|
|
137
|
+
export const sessionsMarkManyReadInput = z.object({
|
|
138
|
+
sessionIds: z.array(z.string()).min(1).max(500),
|
|
139
|
+
});
|
|
142
140
|
export const sessionsSetProfileInput = z.object({
|
|
143
141
|
sessionId: z.string(),
|
|
144
142
|
profileName: z.string().min(1),
|
|
@@ -206,6 +204,9 @@ export const sessionsCreateAndSendInput = z.object({
|
|
|
206
204
|
export const threadsCancelInput = z.object({
|
|
207
205
|
threadId: z.string(),
|
|
208
206
|
});
|
|
207
|
+
export const waitpointsCancelInput = z.object({
|
|
208
|
+
waitpointId: z.string().min(1),
|
|
209
|
+
});
|
|
209
210
|
export const executionsCancelInput = z.object({
|
|
210
211
|
executionId: z.string(),
|
|
211
212
|
});
|
|
@@ -684,6 +685,7 @@ export const queryInputSchemas = {
|
|
|
684
685
|
'commissions.get': commissionsGetInput,
|
|
685
686
|
'commissions.decisions': commissionsDecisionsInput,
|
|
686
687
|
'executions.list': executionsListInput,
|
|
688
|
+
'waitpoints.list': waitpointsListInput,
|
|
687
689
|
'executions.get': executionsGetInput,
|
|
688
690
|
'memory.tree': memoryTreeInput,
|
|
689
691
|
'memory.file': memoryFileInput,
|
|
@@ -722,6 +724,7 @@ export const mutateInputSchemas = {
|
|
|
722
724
|
'sessions.setCommission': sessionsSetCommissionInput,
|
|
723
725
|
'sessions.createAndSend': sessionsCreateAndSendInput,
|
|
724
726
|
'sessions.markRead': sessionsMarkReadInput,
|
|
727
|
+
'sessions.markManyRead': sessionsMarkManyReadInput,
|
|
725
728
|
'sessions.answerQuestion': sessionsAnswerQuestionInput,
|
|
726
729
|
'sessions.respondPlan': sessionsRespondPlanInput,
|
|
727
730
|
'sessions.respondDecision': sessionsRespondDecisionInput,
|
|
@@ -729,6 +732,7 @@ export const mutateInputSchemas = {
|
|
|
729
732
|
'sessions.rewind': sessionsRewindInput,
|
|
730
733
|
'threads.cancel': threadsCancelInput,
|
|
731
734
|
'executions.cancel': executionsCancelInput,
|
|
735
|
+
'waitpoints.cancel': waitpointsCancelInput,
|
|
732
736
|
'schedules.pause': scheduleActionInput,
|
|
733
737
|
'schedules.resume': scheduleActionInput,
|
|
734
738
|
'schedules.remove': scheduleActionInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: platform patch schema, config path and credential writer
|
|
2
2
|
// output: validated platform writes with secret-free errors
|
|
3
3
|
// pos: Platform settings mutation boundary
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { CONFIG_DIR } from '../../../core/paths.js';
|
|
7
7
|
import { platformSettingsInput } from '../../../core/platform-settings-spec.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UiServiceDeps, Result, SessionsCreateArgs, SessionsCreateReturn, SessionsSendArgs, SessionsSendReturn, SessionsCancelArgs, SessionsCompactArgs, SessionsCompactReturn, SessionsMarkReadArgs, SessionsCancelReturn, SessionsSetProfileArgs, SessionsSetProfileReturn, SessionsSetSelectionArgs, SessionsSetSelectionReturn, SessionsSetCommissionArgs, SessionsSetCommissionReturn, SessionsCreateAndSendArgs, SessionsCreateAndSendReturn, SessionsAnswerQuestionArgs, SessionsRespondPlanArgs, SessionsRespondDecisionArgs, SessionsRespondDecisionReturn, SessionsInteractionMutateReturn, SessionsRewindArgs, SessionsRewindReturn, SessionsCancelResumeArgs, SessionsCancelResumeReturn } from '../types.js';
|
|
1
|
+
import type { UiServiceDeps, Result, SessionsCreateArgs, SessionsCreateReturn, SessionsSendArgs, SessionsSendReturn, SessionsCancelArgs, SessionsCompactArgs, SessionsCompactReturn, SessionsMarkReadArgs, SessionsMarkManyReadArgs, SessionsMarkManyReadReturn, SessionsCancelReturn, SessionsSetProfileArgs, SessionsSetProfileReturn, SessionsSetSelectionArgs, SessionsSetSelectionReturn, SessionsSetCommissionArgs, SessionsSetCommissionReturn, SessionsCreateAndSendArgs, SessionsCreateAndSendReturn, SessionsAnswerQuestionArgs, SessionsRespondPlanArgs, SessionsRespondDecisionArgs, SessionsRespondDecisionReturn, SessionsInteractionMutateReturn, SessionsRewindArgs, SessionsRewindReturn, SessionsCancelResumeArgs, SessionsCancelResumeReturn } from '../types.js';
|
|
2
2
|
export declare function handleCreateSession(deps: UiServiceDeps, args: SessionsCreateArgs): Promise<Result<SessionsCreateReturn>>;
|
|
3
3
|
/**
|
|
4
4
|
* Switch a LIVE session in or out of commission mode (DR-0037 v4).
|
|
@@ -16,6 +16,10 @@ export declare function handleSendSession(deps: UiServiceDeps, args: SessionsSen
|
|
|
16
16
|
export declare function handleCancelSession(deps: UiServiceDeps, args: SessionsCancelArgs): Promise<Result<SessionsCancelReturn>>;
|
|
17
17
|
export declare function handleCompactSession(deps: UiServiceDeps, args: SessionsCompactArgs): Promise<Result<SessionsCompactReturn>>;
|
|
18
18
|
export declare function handleMarkReadSession(deps: UiServiceDeps, args: SessionsMarkReadArgs): Promise<Result<void>>;
|
|
19
|
+
/** Batch mark-read behind the run list's「mark all read」. Deliberately forgiving: a session that
|
|
20
|
+
* no longer resolves (purged run, stale client list) is skipped instead of failing the batch —
|
|
21
|
+
* the user asked to clear what they see, and a half-stale list must still clear. */
|
|
22
|
+
export declare function handleMarkManyReadSessions(deps: UiServiceDeps, args: SessionsMarkManyReadArgs): Promise<Result<SessionsMarkManyReadReturn>>;
|
|
19
23
|
export declare function handleCreateAndSend(deps: UiServiceDeps, args: SessionsCreateAndSendArgs): Promise<Result<SessionsCreateAndSendReturn>>;
|
|
20
24
|
export declare function handleSetProfile(deps: UiServiceDeps, args: SessionsSetProfileArgs): Promise<Result<SessionsSetProfileReturn>>;
|
|
21
25
|
export declare function handleSetSelection(deps: UiServiceDeps, args: SessionsSetSelectionArgs): Promise<Result<SessionsSetSelectionReturn>>;
|
|
@@ -177,6 +177,20 @@ export async function handleMarkReadSession(deps, args) {
|
|
|
177
177
|
await deps.sessionStore.markRead?.(args.sessionId);
|
|
178
178
|
return { ok: true, data: undefined };
|
|
179
179
|
}
|
|
180
|
+
/** Batch mark-read behind the run list's「mark all read」. Deliberately forgiving: a session that
|
|
181
|
+
* no longer resolves (purged run, stale client list) is skipped instead of failing the batch —
|
|
182
|
+
* the user asked to clear what they see, and a half-stale list must still clear. */
|
|
183
|
+
export async function handleMarkManyReadSessions(deps, args) {
|
|
184
|
+
let marked = 0;
|
|
185
|
+
for (const sessionId of new Set(args.sessionIds)) {
|
|
186
|
+
const session = await deps.sessionStore.getById(sessionId);
|
|
187
|
+
if (!session)
|
|
188
|
+
continue;
|
|
189
|
+
await deps.sessionStore.markRead?.(sessionId);
|
|
190
|
+
marked += 1;
|
|
191
|
+
}
|
|
192
|
+
return { ok: true, data: { marked } };
|
|
193
|
+
}
|
|
180
194
|
// Create a fresh session AND send the first message in one atomic operation. Used by the workbench
|
|
181
195
|
// "New Conversation" draft flow (task 15b): the session is created only when the user sends their
|
|
182
196
|
// first message, at which point the profile is already known and the backend is resolved correctly.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// input: UiServiceDeps + WaitpointsCancelArgs
|
|
2
|
+
// output: handleCancelWaitpoint → Result<WaitpointsCancelReturn>
|
|
3
|
+
// pos: mutate handler for 'waitpoints.cancel' — the human escape hatch for a waitpoint whose
|
|
4
|
+
// signal is never coming. The state guard lives in the waitpoint service (a non-armed
|
|
5
|
+
// waitpoint refuses), so this handler only translates the outcome.
|
|
6
|
+
export async function handleCancelWaitpoint(deps, args) {
|
|
7
|
+
if (!deps.waitpointRegistry) {
|
|
8
|
+
return { ok: false, code: 'not-available', message: 'Waitpoints are not available on this server' };
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const outcome = await deps.waitpointRegistry.cancel(args.waitpointId);
|
|
12
|
+
if (!outcome.cancelled && !outcome.state) {
|
|
13
|
+
return { ok: false, code: 'not-found', message: `Waitpoint not found: ${args.waitpointId}` };
|
|
14
|
+
}
|
|
15
|
+
return { ok: true, data: { cancelled: outcome.cancelled, state: outcome.state ?? null } };
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
return { ok: false, code: 'internal', message: err?.message || String(err) };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: dotenv files, live environment, atomic mutation and schema
|
|
2
2
|
// output: redacted platform snapshots and serialized credential patches
|
|
3
3
|
// pos: Platform configuration persistence and pending-state reader
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
6
|
import { parse } from 'dotenv';
|
|
7
7
|
import { mutateFileAtomically } from '../../core/atomic-write.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: plugin catalog, settings and plugin directories
|
|
2
2
|
// output: normalized plugin entries and effective scopes
|
|
3
3
|
// pos: Shared plugin helpers for UI service
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import { getSettings } from '../../core/settings.js';
|
|
7
7
|
import path from 'node:path';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input: config root, platform settings, hook registry, live locale and its source
|
|
2
2
|
// output: config snapshot with redacted platform fields and the active UI/server language
|
|
3
3
|
// pos: Config snapshot reader
|
|
4
|
-
// >>> Once updated, update this header and parent
|
|
4
|
+
// >>> Once updated, update this header and parent AGENTS.md <<<
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
6
|
import { readPlatformSettings } from '../platform-settings.js';
|
|
7
7
|
import path from 'node:path';
|
|
@@ -61,7 +61,6 @@ export async function handleExecutionsGet(deps, params) {
|
|
|
61
61
|
tmuxName: e.dispatch.tmuxName ?? null,
|
|
62
62
|
sessionName: e.dispatch.sessionName ?? null,
|
|
63
63
|
scheduleTaskId: e.dispatch.scheduleTaskId ?? null,
|
|
64
|
-
runName: e.dispatch.runName ?? null,
|
|
65
64
|
}
|
|
66
65
|
: null,
|
|
67
66
|
metrics: {
|
|
@@ -69,7 +68,6 @@ export async function handleExecutionsGet(deps, params) {
|
|
|
69
68
|
numTurns: e.metrics?.numTurns ?? null,
|
|
70
69
|
durationS: e.metrics?.durationS ?? null,
|
|
71
70
|
},
|
|
72
|
-
gpu: e.gpu ?? null,
|
|
73
71
|
text: {
|
|
74
72
|
label: e.text?.label ?? null,
|
|
75
73
|
finalOutput: e.text?.finalOutput ?? null,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { buildProbeCommand, parseMachineProbe, PROBE_TIMEOUT_MS } from './machine-probe.js';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* GPU row with its owning run. Process pids are deliberately NOT matched: dispatch.pid is the
|
|
6
|
-
* cortex-run launcher, not the CUDA process, so any such join would be fabricated.
|
|
7
|
-
*/
|
|
2
|
+
/** Running dispatch executions on this machine. Process pids are deliberately NOT matched against
|
|
3
|
+
* the GPU probe: dispatch.pid is the launcher, not the CUDA process, so any such join would be
|
|
4
|
+
* fabricated. */
|
|
8
5
|
function collectLiveRuns(deps, machine) {
|
|
9
6
|
return deps.executionRegistry
|
|
10
7
|
.getAll()
|
|
@@ -12,9 +9,7 @@ function collectLiveRuns(deps, machine) {
|
|
|
12
9
|
.map((exec) => ({
|
|
13
10
|
executionId: String(exec.id),
|
|
14
11
|
taskId: exec.dispatch?.taskId ?? null,
|
|
15
|
-
runName: exec.dispatch?.runName ?? null,
|
|
16
12
|
project: exec.project ?? null,
|
|
17
|
-
gpuIndices: Array.isArray(exec.gpu?.indices) ? exec.gpu.indices : [],
|
|
18
13
|
startedAt: exec.runtime?.startedAt ?? null,
|
|
19
14
|
}));
|
|
20
15
|
}
|
|
@@ -81,7 +81,7 @@ export async function handleMemoryTree(deps, params) {
|
|
|
81
81
|
return [];
|
|
82
82
|
}
|
|
83
83
|
const entries = dirents
|
|
84
|
-
.filter((e) => e.isFile() && e.name.endsWith('.md') && e.name !== 'index.md' && e.name !== '
|
|
84
|
+
.filter((e) => e.isFile() && e.name.endsWith('.md') && e.name !== 'index.md' && e.name !== 'AGENTS.md')
|
|
85
85
|
.map((e) => {
|
|
86
86
|
const st = fs.statSync(path.join(abs, e.name));
|
|
87
87
|
return { name: e.name, sizeBytes: st.size, modifiedAt: st.mtime.toISOString() };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { effectiveBackendSessionId } from '../../../store/session-registry-repo.js';
|
|
2
|
+
import { countWaitingOn } from './waitpoints.js';
|
|
2
3
|
import { sessionTotalsCarry } from '../../../store/session-totals-repo.js';
|
|
3
4
|
import { addTotalsAcc, emptyTotalsAcc, foldExecution, toSessionTotals, } from '../../../store/session-totals.js';
|
|
4
5
|
import { projectCompactHistory, projectSubagentHistory } from '../../../store/conversation-display-projection.js';
|
|
@@ -79,6 +80,11 @@ export async function handleSessionsList(deps, params) {
|
|
|
79
80
|
return null;
|
|
80
81
|
return sessionId ? (lastRunBySession.get(sessionId)?.costUsd ?? null) : null;
|
|
81
82
|
};
|
|
83
|
+
// Armed waitpoints, fetched once for the whole page (the repo read is an in-memory cache hit).
|
|
84
|
+
// Counted per session by the shared ownership rule so `waitingOn` and `waitpoints.list` can never
|
|
85
|
+
// disagree. Absent dep (fixtures / TUI) ⇒ every session reports 0.
|
|
86
|
+
const armedWaitpoints = deps.waitpointRegistry ? await deps.waitpointRegistry.listArmed() : [];
|
|
87
|
+
const waitingOnBySession = countWaitingOn(armedWaitpoints, sessions.map((s) => ({ sessionId: s.sessionId, channel: s.channel ?? null })));
|
|
82
88
|
const infos = sessions.map((s) => {
|
|
83
89
|
// Busy snapshot: the registry's single answer for this session. Snapshot + delta — this field
|
|
84
90
|
// is the queryable snapshot, the `session.status` event stream is the delta.
|
|
@@ -128,6 +134,7 @@ export async function handleSessionsList(deps, params) {
|
|
|
128
134
|
running,
|
|
129
135
|
backgroundRunning: bgHeld,
|
|
130
136
|
awaitingInput,
|
|
137
|
+
waitingOn: waitingOnBySession.get(s.sessionId) ?? 0,
|
|
131
138
|
numTurns: resolveNumTurns(s.sessionId, inTurn, state.numTurns),
|
|
132
139
|
costUsd: resolveCost(s.sessionId, inTurn),
|
|
133
140
|
// Cumulative over every finished run this session has had (plus its Agent-tool children's
|
|
@@ -80,7 +80,7 @@ export async function handleThreadsGet(deps, params) {
|
|
|
80
80
|
error: t.error ?? null, abortReason: t.abortReason ?? null,
|
|
81
81
|
activeAgent: t.activeAgent ?? null, activeStage: t.activeStage ?? null,
|
|
82
82
|
totalCostUsd: t.totalCostUsd ?? 0, steps, agentFlow: buildAgentFlow(t),
|
|
83
|
-
|
|
83
|
+
subtasks: buildSubtasks(deps, t),
|
|
84
84
|
children: buildChildTree(deps, t.metadata?.childThreadIds ?? [], 0, new Set([t.id])),
|
|
85
85
|
artifacts: buildArtifactRefs(t, content),
|
|
86
86
|
};
|
|
@@ -140,59 +140,6 @@ function buildAgentFlow(t) {
|
|
|
140
140
|
lastOutput: slot.lastOutput ?? null,
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
function findLaunchStep(steps, thread, startedAt) {
|
|
144
|
-
const launchedAt = Date.parse(startedAt);
|
|
145
|
-
if (!Number.isFinite(launchedAt))
|
|
146
|
-
return null;
|
|
147
|
-
const completed = steps.find((step) => {
|
|
148
|
-
const start = step.startedAt ? Date.parse(step.startedAt) : NaN;
|
|
149
|
-
const end = step.endedAt ? Date.parse(step.endedAt) : NaN;
|
|
150
|
-
return Number.isFinite(start) && Number.isFinite(end) && launchedAt >= start && launchedAt < end;
|
|
151
|
-
});
|
|
152
|
-
if (completed)
|
|
153
|
-
return completed;
|
|
154
|
-
const active = steps.find((step) => step.status === 'running');
|
|
155
|
-
if (!active)
|
|
156
|
-
return null;
|
|
157
|
-
const priorEnd = steps.reduce((latest, step) => {
|
|
158
|
-
const end = step.endedAt ? Date.parse(step.endedAt) : NaN;
|
|
159
|
-
return Number.isFinite(end) ? Math.max(latest, end) : latest;
|
|
160
|
-
}, Date.parse(thread.createdAt));
|
|
161
|
-
return launchedAt >= priorEnd ? active : null;
|
|
162
|
-
}
|
|
163
|
-
function toThreadDispatch(e, step) {
|
|
164
|
-
const startedAt = e.runtime?.startedAt || '';
|
|
165
|
-
const finishedAt = e.runtime?.endedAt || null;
|
|
166
|
-
const endMs = finishedAt ? Date.parse(finishedAt) : null;
|
|
167
|
-
return {
|
|
168
|
-
executionId: e.id,
|
|
169
|
-
status: e.status,
|
|
170
|
-
machine: e.dispatch.machine ?? null,
|
|
171
|
-
type: 'dispatch',
|
|
172
|
-
agentSlotId: step.agentSlotId,
|
|
173
|
-
stepIndex: step.stepIndex,
|
|
174
|
-
taskId: e.dispatch.taskId,
|
|
175
|
-
runName: e.dispatch.runName,
|
|
176
|
-
startedAt,
|
|
177
|
-
finishedAt,
|
|
178
|
-
durationMs: endMs ? endMs - Date.parse(startedAt) : null,
|
|
179
|
-
cost: e.metrics?.costUsd ?? null,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
// Real cortex-runs have a runName and owning task but no caller-thread field. Launch time is the
|
|
183
|
-
// remaining provenance seam: attribute only runs launched inside one of this thread's step windows.
|
|
184
|
-
function buildDispatches(deps, thread, steps) {
|
|
185
|
-
const taskId = thread.metadata?.taskId;
|
|
186
|
-
if (!taskId)
|
|
187
|
-
return [];
|
|
188
|
-
return deps.executionRegistry.getAll()
|
|
189
|
-
.filter((e) => e.dispatch?.taskId === taskId && e.dispatch?.runName)
|
|
190
|
-
.sort((a, b) => (a.runtime?.startedAt || '').localeCompare(b.runtime?.startedAt || ''))
|
|
191
|
-
.flatMap((e) => {
|
|
192
|
-
const step = findLaunchStep(steps, thread, e.runtime?.startedAt || '');
|
|
193
|
-
return step ? [toThreadDispatch(e, step)] : [];
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
143
|
function buildSubtasks(deps, thread) {
|
|
197
144
|
const taskId = thread.metadata?.taskId;
|
|
198
145
|
if (!taskId)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Waitpoint } from '../../../store/waitpoint-repo.js';
|
|
2
|
+
import type { UiServiceDeps, WaitpointInfo, WaitpointsListParams } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Does `wp` belong to the session identified by (`sessionId`, `channel`)?
|
|
5
|
+
*
|
|
6
|
+
* The union of two clauses, each covering the other's blind spot:
|
|
7
|
+
* - `owner.sessionId` — this session's own process armed it. Survives a channel rebind, since
|
|
8
|
+
* `bindChannel` never rewrites the session record's channel.
|
|
9
|
+
* - `owner.channel` — the wake will be DELIVERED here. Survives the session being recreated
|
|
10
|
+
* (`!new`, a scheduled re-run), because delivery is channel-addressed and find-or-creates a
|
|
11
|
+
* session. This clause can surface a waitpoint armed by an earlier session on the same channel;
|
|
12
|
+
* that is honest rather than wrong — its wake really will land on the current one.
|
|
13
|
+
*
|
|
14
|
+
* Kept as one exported function so `SessionInfo.waitingOn` and `waitpoints.list` can never drift.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ownsWaitpoint(wp: Waitpoint, sessionId: string, channel: string | null): boolean;
|
|
17
|
+
/** Count the armed waitpoints each of `sessions` is waiting on. One pass over a handful of records
|
|
18
|
+
* (the repo read is an in-memory cache hit and settled records are purged after 3 days), so the
|
|
19
|
+
* nested loop is cheaper than building and reconciling two indexes. */
|
|
20
|
+
export declare function countWaitingOn(armed: Waitpoint[], sessions: Array<{
|
|
21
|
+
sessionId: string;
|
|
22
|
+
channel: string | null;
|
|
23
|
+
}>): Map<string, number>;
|
|
24
|
+
/**
|
|
25
|
+
* Redacting serialiser. Built field by field, never by spreading the record: `secretHash` must not
|
|
26
|
+
* be able to leak through a field added upstream later. `signals[].data` is dropped on purpose —
|
|
27
|
+
* it is externally written and capped at 16 KB per signal, which would bloat every list response.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toWaitpointInfo(wp: Waitpoint, now: number, wakeLimit: number): WaitpointInfo;
|
|
30
|
+
export declare function handleWaitpointsList(deps: UiServiceDeps, params: WaitpointsListParams): Promise<WaitpointInfo[]>;
|