@cortex-agent/server 2026.9.14 → 2026.9.15
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/defaults/plugins/cortex-commission/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-commission/plugin.json +2 -2
- package/defaults/plugins/cortex-commission/skills/commission/SKILL.md +3 -3
- package/dist/agent-adapter/claude/adapter.d.ts +0 -6
- package/dist/agent-adapter/claude/adapter.js +0 -8
- package/dist/agent-adapter/claude/defaults.d.ts +10 -7
- package/dist/agent-adapter/claude/defaults.js +18 -16
- package/dist/agent-adapter/claude/spawn-args.d.ts +0 -3
- package/dist/agent-adapter/claude/spawn-args.js +16 -16
- package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +11 -2
- package/dist/agent-adapter/pi/mcp-bridge-logic.js +32 -1
- package/dist/agent-adapter/pi/mcp-bridge.js +16 -15
- package/dist/agent-adapter/pi/session-options.d.ts +0 -6
- package/dist/agent-adapter/pi/session-options.js +1 -8
- package/dist/agent-adapter/types.d.ts +0 -1
- package/dist/core/mcp-tool-gate.d.ts +3 -17
- package/dist/core/mcp-tool-gate.js +3 -19
- package/dist/core/settings-spec.d.ts +1 -1
- package/dist/core/settings-spec.js +5 -1
- package/dist/domain/agents/config.d.ts +1 -1
- package/dist/domain/agents/config.js +1 -1
- package/dist/domain/agents/profile-switch.d.ts +1 -1
- package/dist/domain/agents/profile-switch.js +3 -5
- package/dist/domain/agents/subagent/runner.js +0 -1
- package/dist/domain/commissions/commission-draft.d.ts +58 -0
- package/dist/domain/commissions/commission-draft.js +87 -4
- package/dist/domain/commissions/commission-finalize.d.ts +8 -3
- package/dist/domain/commissions/commission-finalize.js +14 -0
- package/dist/domain/mcp/tools/commission-tools.d.ts +12 -1
- package/dist/domain/mcp/tools/commission-tools.js +68 -14
- package/dist/domain/remote/client-manager.js +66 -7
- package/dist/domain/remote/client-ssh-tunnel.d.ts +16 -5
- package/dist/domain/remote/client-ssh-tunnel.js +12 -5
- package/dist/domain/runs/builders.js +0 -1
- package/dist/domain/runs/compact.js +0 -1
- package/dist/domain/runs/engine-spec.d.ts +11 -4
- package/dist/domain/runs/engine-spec.js +7 -4
- package/dist/domain/runs/prompt.js +16 -10
- package/dist/domain/runs/request.d.ts +0 -1
- package/dist/domain/sessions/session-hooks.d.ts +5 -12
- package/dist/domain/sessions/session-hooks.js +6 -13
- package/dist/domain/sessions/session-lifecycle.d.ts +4 -4
- package/dist/domain/sessions/session-lifecycle.js +5 -6
- package/dist/domain/sessions/session-retention.d.ts +1 -3
- package/dist/domain/sessions/session-retention.js +9 -26
- package/dist/domain/sessions/session-use.d.ts +32 -0
- package/dist/domain/sessions/session-use.js +63 -0
- package/dist/domain/sessions/session.js +6 -5
- package/dist/domain/system/server-update-check.js +29 -1
- package/dist/domain/system/update-ui-state.d.ts +32 -0
- package/dist/domain/system/update-ui-state.js +63 -0
- package/dist/domain/threads/runner.js +0 -1
- package/dist/domain/ui-service/app-router.d.ts +30 -0
- package/dist/domain/ui-service/app-router.js +5 -1
- package/dist/domain/ui-service/input-schemas.d.ts +32 -0
- package/dist/domain/ui-service/input-schemas.js +22 -0
- package/dist/domain/ui-service/mutate/sessions.d.ts +13 -1
- package/dist/domain/ui-service/mutate/sessions.js +69 -3
- package/dist/domain/ui-service/mutate/system.d.ts +3 -1
- package/dist/domain/ui-service/mutate/system.js +13 -0
- package/dist/domain/ui-service/query/system.d.ts +2 -1
- package/dist/domain/ui-service/query/system.js +4 -0
- package/dist/domain/ui-service/types.d.ts +44 -3
- package/dist/domain/ui-service/ui-service.js +7 -3
- package/dist/entry/app.js +11 -23
- package/dist/entry/start-ui-http.js +3 -1
- package/dist/events/event-types.d.ts +5 -0
- package/dist/orchestration/agent-runner.d.ts +1 -1
- package/dist/orchestration/agent-runner.js +8 -11
- package/dist/orchestration/conversation-request.d.ts +26 -8
- package/dist/orchestration/conversation-request.js +49 -20
- package/dist/orchestration/edit-retry.js +2 -1
- package/dist/orchestration/interactions/ask-user-resume.js +2 -1
- package/dist/orchestration/interactions/ui-update-prompt.d.ts +8 -0
- package/dist/orchestration/interactions/ui-update-prompt.js +47 -0
- package/dist/orchestration/resume-dispatcher.js +2 -2
- package/dist/orchestration/routing/webhook.js +47 -0
- package/dist/orchestration/session-compact.d.ts +3 -0
- package/dist/orchestration/session-compact.js +3 -2
- package/dist/orchestration/session-events.d.ts +6 -0
- package/dist/orchestration/session-events.js +5 -0
- package/dist/orchestration/turn/turn-prep.js +2 -1
- package/dist/platform/ui-http/app-update.d.ts +11 -0
- package/dist/platform/ui-http/app-update.js +3 -0
- package/dist/store/conversation-ledger-repo.d.ts +10 -19
- package/dist/store/conversation-ledger-repo.js +143 -152
- package/dist/store/session-registry-import.d.ts +34 -0
- package/dist/store/session-registry-import.js +182 -0
- package/dist/store/session-registry-journal.d.ts +107 -0
- package/dist/store/session-registry-journal.js +307 -18
- package/dist/store/session-registry-repo.d.ts +113 -28
- package/dist/store/session-registry-repo.js +287 -104
- package/dist/store/version-migrations.d.ts +16 -0
- package/dist/store/version-migrations.js +34 -0
- package/package.json +1 -1
- package/web/dist/assets/{index-aHbOZSP6.js → index-CEZ0DSei.js} +1 -1
- package/web/dist/assets/{index-CCPxQ94C.css → index-CRDJo39X.css} +1 -1
- package/web/dist/assets/index-DjuPJVZE.js +444 -0
- package/web/dist/index.html +2 -2
- package/dist/store/session-repo.d.ts +0 -65
- package/dist/store/session-repo.js +0 -184
- package/web/dist/assets/index-BuXbCsuz.js +0 -444
|
@@ -6,7 +6,7 @@ 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, 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, executionsLogInput, 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, } from './input-schemas.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, executionsLogInput, 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()),
|
|
@@ -84,6 +84,7 @@ function sessionsRouter(service) {
|
|
|
84
84
|
compact: makeMutation(service, 'sessions.compact', sessionsCompactInput),
|
|
85
85
|
setProfile: makeMutation(service, 'sessions.setProfile', sessionsSetProfileInput),
|
|
86
86
|
setSelection: makeMutation(service, 'sessions.setSelection', sessionsSetSelectionInput),
|
|
87
|
+
setCommission: makeMutation(service, 'sessions.setCommission', sessionsSetCommissionInput),
|
|
87
88
|
createAndSend: makeMutation(service, 'sessions.createAndSend', sessionsCreateAndSendInput),
|
|
88
89
|
markRead: makeMutation(service, 'sessions.markRead', sessionsMarkReadInput),
|
|
89
90
|
answerQuestion: makeMutation(service, 'sessions.answerQuestion', sessionsAnswerQuestionInput),
|
|
@@ -231,6 +232,9 @@ function systemRouter(service) {
|
|
|
231
232
|
restart: makeMutation(service, 'system.restart', systemRestartInput),
|
|
232
233
|
clearRateLimit: makeMutation(service, 'system.clearRateLimit', systemClearRateLimitInput),
|
|
233
234
|
refreshUsage: makeMutation(service, 'system.refreshUsage', systemRefreshUsageInput),
|
|
235
|
+
updateStatus: makeQuery(service, 'system.updateStatus', systemUpdateStatusInput),
|
|
236
|
+
applyUpdate: makeMutation(service, 'system.applyUpdate', systemApplyUpdateInput),
|
|
237
|
+
skipUpdate: makeMutation(service, 'system.skipUpdate', systemSkipUpdateInput),
|
|
234
238
|
});
|
|
235
239
|
}
|
|
236
240
|
function costRouter(service) {
|
|
@@ -26,6 +26,7 @@ export declare const systemUsageStatusInput: z.ZodObject<{}, z.core.$strip>;
|
|
|
26
26
|
export declare const systemNoticesInput: z.ZodObject<{
|
|
27
27
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
|
+
export declare const systemUpdateStatusInput: z.ZodObject<{}, z.core.$strip>;
|
|
29
30
|
export declare const executionsLogInput: z.ZodObject<{
|
|
30
31
|
executionId: z.ZodString;
|
|
31
32
|
}, z.core.$strip>;
|
|
@@ -103,6 +104,21 @@ export declare const sessionCommissionInput: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
103
104
|
mode: z.ZodLiteral<"join">;
|
|
104
105
|
commissionId: z.ZodString;
|
|
105
106
|
}, z.core.$strip>], "mode">;
|
|
107
|
+
/** Switching a LIVE session's commission mode (DR-0037 v4). The create-time choices plus `off`,
|
|
108
|
+
* which creation had no need for. Spelled as a third union member rather than a nullable field so
|
|
109
|
+
* the emitted client type keeps it: this package compiles with `strict: false`, where `X | null`
|
|
110
|
+
* erases to `X` and a null the server accepts becomes unspellable in the strict-mode web client. */
|
|
111
|
+
export declare const sessionsSetCommissionInput: z.ZodObject<{
|
|
112
|
+
sessionId: z.ZodString;
|
|
113
|
+
commission: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
114
|
+
mode: z.ZodLiteral<"off">;
|
|
115
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
116
|
+
mode: z.ZodLiteral<"new">;
|
|
117
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
118
|
+
mode: z.ZodLiteral<"join">;
|
|
119
|
+
commissionId: z.ZodString;
|
|
120
|
+
}, z.core.$strip>], "mode">;
|
|
121
|
+
}, z.core.$strip>;
|
|
106
122
|
export declare const sessionsCreateInput: z.ZodObject<{
|
|
107
123
|
projectId: z.ZodOptional<z.ZodString>;
|
|
108
124
|
browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -564,6 +580,8 @@ export declare const systemClearRateLimitInput: z.ZodObject<{
|
|
|
564
580
|
provider: z.ZodOptional<z.ZodString>;
|
|
565
581
|
}, z.core.$strip>;
|
|
566
582
|
export declare const systemRefreshUsageInput: z.ZodObject<{}, z.core.$strip>;
|
|
583
|
+
export declare const systemApplyUpdateInput: z.ZodObject<{}, z.core.$strip>;
|
|
584
|
+
export declare const systemSkipUpdateInput: z.ZodObject<{}, z.core.$strip>;
|
|
567
585
|
export declare const approvalsRequestInput: z.ZodObject<{
|
|
568
586
|
kind: z.ZodEnum<{
|
|
569
587
|
"reconnect-platform": "reconnect-platform";
|
|
@@ -707,6 +725,7 @@ export declare const queryInputSchemas: {
|
|
|
707
725
|
'system.notices': z.ZodObject<{
|
|
708
726
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
709
727
|
}, z.core.$strip>;
|
|
728
|
+
'system.updateStatus': z.ZodObject<{}, z.core.$strip>;
|
|
710
729
|
};
|
|
711
730
|
export declare const mutateInputSchemas: {
|
|
712
731
|
'projects.create': z.ZodObject<{
|
|
@@ -760,6 +779,17 @@ export declare const mutateInputSchemas: {
|
|
|
760
779
|
mode: z.ZodOptional<z.ZodString>;
|
|
761
780
|
}, z.core.$strip>>;
|
|
762
781
|
}, z.core.$strip>;
|
|
782
|
+
'sessions.setCommission': z.ZodObject<{
|
|
783
|
+
sessionId: z.ZodString;
|
|
784
|
+
commission: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
785
|
+
mode: z.ZodLiteral<"off">;
|
|
786
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
787
|
+
mode: z.ZodLiteral<"new">;
|
|
788
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
789
|
+
mode: z.ZodLiteral<"join">;
|
|
790
|
+
commissionId: z.ZodString;
|
|
791
|
+
}, z.core.$strip>], "mode">;
|
|
792
|
+
}, z.core.$strip>;
|
|
763
793
|
'sessions.createAndSend': z.ZodObject<{
|
|
764
794
|
projectId: z.ZodString;
|
|
765
795
|
profileName: z.ZodOptional<z.ZodString>;
|
|
@@ -1264,4 +1294,6 @@ export declare const mutateInputSchemas: {
|
|
|
1264
1294
|
provider: z.ZodOptional<z.ZodString>;
|
|
1265
1295
|
}, z.core.$strip>;
|
|
1266
1296
|
'system.refreshUsage': z.ZodObject<{}, z.core.$strip>;
|
|
1297
|
+
'system.applyUpdate': z.ZodObject<{}, z.core.$strip>;
|
|
1298
|
+
'system.skipUpdate': z.ZodObject<{}, z.core.$strip>;
|
|
1267
1299
|
};
|
|
@@ -34,6 +34,7 @@ export const systemDaemonStatusInput = z.object({});
|
|
|
34
34
|
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
|
+
export const systemUpdateStatusInput = z.object({});
|
|
37
38
|
// ── Subscription input schemas ────────────────────────────────────
|
|
38
39
|
// Subscriptions are not part of the query/mutate keyed maps; their input schemas live here too so
|
|
39
40
|
// the AppRouter and the browser (@cortex-agent/ui-contract) share one source of truth (B2-C).
|
|
@@ -101,6 +102,18 @@ export const sessionCommissionInput = z.discriminatedUnion('mode', [
|
|
|
101
102
|
z.object({ mode: z.literal('new') }),
|
|
102
103
|
z.object({ mode: z.literal('join'), commissionId: z.string() }),
|
|
103
104
|
]);
|
|
105
|
+
/** Switching a LIVE session's commission mode (DR-0037 v4). The create-time choices plus `off`,
|
|
106
|
+
* which creation had no need for. Spelled as a third union member rather than a nullable field so
|
|
107
|
+
* the emitted client type keeps it: this package compiles with `strict: false`, where `X | null`
|
|
108
|
+
* erases to `X` and a null the server accepts becomes unspellable in the strict-mode web client. */
|
|
109
|
+
export const sessionsSetCommissionInput = z.object({
|
|
110
|
+
sessionId: z.string(),
|
|
111
|
+
commission: z.discriminatedUnion('mode', [
|
|
112
|
+
z.object({ mode: z.literal('off') }),
|
|
113
|
+
z.object({ mode: z.literal('new') }),
|
|
114
|
+
z.object({ mode: z.literal('join'), commissionId: z.string() }),
|
|
115
|
+
]),
|
|
116
|
+
});
|
|
104
117
|
export const sessionsCreateInput = z.object({
|
|
105
118
|
projectId: z.string().optional(),
|
|
106
119
|
browser: sessionBrowserInput.nullish(),
|
|
@@ -635,6 +648,11 @@ export const systemClearRateLimitInput = z.object({
|
|
|
635
648
|
provider: z.string().optional(),
|
|
636
649
|
});
|
|
637
650
|
export const systemRefreshUsageInput = z.object({});
|
|
651
|
+
// The pending prompt is process-global (one server, one npm self-update), so neither decision
|
|
652
|
+
// carries a version: answering a prompt that is no longer pending returns accepted:false rather
|
|
653
|
+
// than applying a stale choice.
|
|
654
|
+
export const systemApplyUpdateInput = z.object({});
|
|
655
|
+
export const systemSkipUpdateInput = z.object({});
|
|
638
656
|
export const approvalsRequestInput = z
|
|
639
657
|
.object({
|
|
640
658
|
kind: z.enum(['reconnect-platform', 'add-machine']),
|
|
@@ -691,6 +709,7 @@ export const queryInputSchemas = {
|
|
|
691
709
|
'system.rateLimitStatus': systemRateLimitStatusInput,
|
|
692
710
|
'system.usageStatus': systemUsageStatusInput,
|
|
693
711
|
'system.notices': systemNoticesInput,
|
|
712
|
+
'system.updateStatus': systemUpdateStatusInput,
|
|
694
713
|
};
|
|
695
714
|
export const mutateInputSchemas = {
|
|
696
715
|
'projects.create': projectsCreateInput,
|
|
@@ -700,6 +719,7 @@ export const mutateInputSchemas = {
|
|
|
700
719
|
'sessions.compact': sessionsCompactInput,
|
|
701
720
|
'sessions.setProfile': sessionsSetProfileInput,
|
|
702
721
|
'sessions.setSelection': sessionsSetSelectionInput,
|
|
722
|
+
'sessions.setCommission': sessionsSetCommissionInput,
|
|
703
723
|
'sessions.createAndSend': sessionsCreateAndSendInput,
|
|
704
724
|
'sessions.markRead': sessionsMarkReadInput,
|
|
705
725
|
'sessions.answerQuestion': sessionsAnswerQuestionInput,
|
|
@@ -763,4 +783,6 @@ export const mutateInputSchemas = {
|
|
|
763
783
|
'system.restart': systemRestartInput,
|
|
764
784
|
'system.clearRateLimit': systemClearRateLimitInput,
|
|
765
785
|
'system.refreshUsage': systemRefreshUsageInput,
|
|
786
|
+
'system.applyUpdate': systemApplyUpdateInput,
|
|
787
|
+
'system.skipUpdate': systemSkipUpdateInput,
|
|
766
788
|
};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { UiServiceDeps, Result, SessionsCreateArgs, SessionsCreateReturn, SessionsSendArgs, SessionsSendReturn, SessionsCancelArgs, SessionsCompactArgs, SessionsCompactReturn, SessionsMarkReadArgs, SessionsCancelReturn, SessionsSetProfileArgs, SessionsSetProfileReturn, SessionsSetSelectionArgs, SessionsSetSelectionReturn, 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, 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
|
+
/**
|
|
4
|
+
* Switch a LIVE session in or out of commission mode (DR-0037 v4).
|
|
5
|
+
*
|
|
6
|
+
* The user's half of "either side may start a commission": the agent calls
|
|
7
|
+
* `cortex_commission_start`, the user flips the composer's capsule, and both land in the same
|
|
8
|
+
* `enterCommissionDraft`. It exists for a session already in flight — creation could only ever say
|
|
9
|
+
* yes at birth, which meant a conversation that turned into a long task had no way in.
|
|
10
|
+
*
|
|
11
|
+
* `bound` is terminal: a second contract would orphan the first, so a bound session refuses every
|
|
12
|
+
* transition (open a new session and join instead).
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleSetCommission(deps: UiServiceDeps, args: SessionsSetCommissionArgs): Promise<Result<SessionsSetCommissionReturn>>;
|
|
3
15
|
export declare function handleSendSession(deps: UiServiceDeps, args: SessionsSendArgs): Promise<Result<SessionsSendReturn>>;
|
|
4
16
|
export declare function handleCancelSession(deps: UiServiceDeps, args: SessionsCancelArgs): Promise<Result<SessionsCancelReturn>>;
|
|
5
17
|
export declare function handleCompactSession(deps: UiServiceDeps, args: SessionsCompactArgs): Promise<Result<SessionsCompactReturn>>;
|
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
// assistant reply returns over the `session.message` stream event, NOT this return.
|
|
5
5
|
import { removeDirectResume } from '../../costs/resume-registry.js';
|
|
6
6
|
import { projectCommissionDecisionAction } from '../../commissions/decision-projection.js';
|
|
7
|
+
import { enterCommissionDraft, leaveCommissionDraft } from '../../commissions/commission-draft.js';
|
|
8
|
+
import { commissionRepo } from '../../../store/commission-repo.js';
|
|
9
|
+
import { sessionStore } from '../../../store/session-registry-repo.js';
|
|
7
10
|
import { getSettings } from '../../../core/settings.js';
|
|
8
11
|
// Create a fresh, live direct session for the workbench "+ New session" control. Resolves the target
|
|
9
12
|
// project (falling back to the default project when omitted), delegates the real creation to the
|
|
10
13
|
// injected `createDirectSession` dep (domain primitive wired in entry/app.ts), and returns the new
|
|
11
14
|
// session's id.
|
|
12
|
-
/** Commission mode ships behind `settings.commissionEnabled
|
|
13
|
-
*
|
|
15
|
+
/** Commission mode ships behind `settings.commissionEnabled`, its kill switch (on by default since
|
|
16
|
+
* DR-0037 v4). The composer hides the opt-in when it is off, so reaching this is either a stale
|
|
14
17
|
* client or a direct API call; answer with a 400 rather than letting createDirectSession throw. */
|
|
15
18
|
function commissionDisabled(commission) {
|
|
16
19
|
if (!commission || getSettings().commissionEnabled)
|
|
@@ -31,11 +34,74 @@ export async function handleCreateSession(deps, args) {
|
|
|
31
34
|
});
|
|
32
35
|
return { ok: true, data: { sessionId } };
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Switch a LIVE session in or out of commission mode (DR-0037 v4).
|
|
39
|
+
*
|
|
40
|
+
* The user's half of "either side may start a commission": the agent calls
|
|
41
|
+
* `cortex_commission_start`, the user flips the composer's capsule, and both land in the same
|
|
42
|
+
* `enterCommissionDraft`. It exists for a session already in flight — creation could only ever say
|
|
43
|
+
* yes at birth, which meant a conversation that turned into a long task had no way in.
|
|
44
|
+
*
|
|
45
|
+
* `bound` is terminal: a second contract would orphan the first, so a bound session refuses every
|
|
46
|
+
* transition (open a new session and join instead).
|
|
47
|
+
*/
|
|
48
|
+
export async function handleSetCommission(deps, args) {
|
|
49
|
+
// `off` stays allowed with the feature switched off: a session left drafting when the switch
|
|
50
|
+
// flipped must still be able to get out.
|
|
51
|
+
const disabled = commissionDisabled(args.commission.mode === 'off' ? null : args.commission);
|
|
52
|
+
if (disabled)
|
|
53
|
+
return disabled;
|
|
54
|
+
const session = await deps.sessionStore.getById(args.sessionId);
|
|
55
|
+
if (!session)
|
|
56
|
+
return { ok: false, code: 'not-found', message: `Session not found: ${args.sessionId}` };
|
|
57
|
+
if (session.commissionId) {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
code: 'invalid-args',
|
|
61
|
+
message: 'This session is already bound to a commission — open a new session to work on another one',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const settled = (removedDraftDir) => ({
|
|
65
|
+
ok: true,
|
|
66
|
+
data: {
|
|
67
|
+
phase: 'none', commissionId: null, commissionDraft: null,
|
|
68
|
+
...(removedDraftDir === undefined ? {} : { removedDraftDir }),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (args.commission.mode === 'off') {
|
|
72
|
+
const left = await leaveCommissionDraft(args.sessionId);
|
|
73
|
+
if (left.ok === false)
|
|
74
|
+
return { ok: false, code: 'invalid-args', message: left.error };
|
|
75
|
+
deps.bus.publish({ type: 'session.commission', sessionId: args.sessionId, channel: session.channel });
|
|
76
|
+
return settled(left.removed);
|
|
77
|
+
}
|
|
78
|
+
if (args.commission.mode === 'join') {
|
|
79
|
+
const commission = await (deps.commissionStore ?? commissionRepo).find(args.commission.commissionId);
|
|
80
|
+
if (!commission) {
|
|
81
|
+
return { ok: false, code: 'not-found', message: `Commission not found: ${args.commission.commissionId}` };
|
|
82
|
+
}
|
|
83
|
+
if (commission.status !== 'active') {
|
|
84
|
+
return { ok: false, code: 'invalid-args', message: `Commission is ${commission.status}; only an active one accepts new sessions` };
|
|
85
|
+
}
|
|
86
|
+
// Joining mid-conversation is safe because the [Commission] block follows the binding rather
|
|
87
|
+
// than the session's first turn: the next turn carries the contract index (DR-0037 v4).
|
|
88
|
+
await sessionStore.bindCommission(args.sessionId, commission.id);
|
|
89
|
+
deps.bus.publish({ type: 'commission.updated', commissionId: commission.id, projectId: commission.projectId });
|
|
90
|
+
return { ok: true, data: { phase: 'active', commissionId: commission.id, commissionDraft: null } };
|
|
91
|
+
}
|
|
92
|
+
const entered = await enterCommissionDraft(args.sessionId);
|
|
93
|
+
if (entered.ok === false)
|
|
94
|
+
return { ok: false, code: 'invalid-args', message: entered.error };
|
|
95
|
+
if (!entered.alreadyDrafting) {
|
|
96
|
+
deps.bus.publish({ type: 'session.commission', sessionId: args.sessionId, channel: session.channel });
|
|
97
|
+
}
|
|
98
|
+
return { ok: true, data: { phase: 'draft', commissionId: null, commissionDraft: entered.draftDir } };
|
|
99
|
+
}
|
|
34
100
|
export async function handleSendSession(deps, args) {
|
|
35
101
|
if (!args.text.trim() && (!args.attachments || args.attachments.length === 0)) {
|
|
36
102
|
return { ok: false, code: 'invalid-args', message: 'Either text or attachments required' };
|
|
37
103
|
}
|
|
38
|
-
if (deps.sessionStore.
|
|
104
|
+
if (deps.sessionStore.touchSessionUse && !(await deps.sessionStore.touchSessionUse(args.sessionId))) {
|
|
39
105
|
return { ok: false, code: 'not-found', message: `Session not found: ${args.sessionId}` };
|
|
40
106
|
}
|
|
41
107
|
const session = await deps.sessionStore.getById(args.sessionId);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Result, SystemClearRateLimitArgs, SystemClearRateLimitReturn, SystemRefreshUsageArgs, SystemRefreshUsageReturn, SystemRestartArgs, SystemRestartReturn } from '../types.js';
|
|
1
|
+
import type { Result, SystemClearRateLimitArgs, SystemClearRateLimitReturn, SystemRefreshUsageArgs, SystemRefreshUsageReturn, SystemRestartArgs, SystemRestartReturn, SystemApplyUpdateArgs, SystemSkipUpdateArgs, SystemUpdateDecisionReturn } from '../types.js';
|
|
2
2
|
export declare function handleSystemClearRateLimit(args: SystemClearRateLimitArgs): Promise<Result<SystemClearRateLimitReturn>>;
|
|
3
3
|
export declare function handleSystemRefreshUsage(_args: SystemRefreshUsageArgs): Promise<Result<SystemRefreshUsageReturn>>;
|
|
4
4
|
export declare function handleSystemRestart(args: SystemRestartArgs): Promise<Result<SystemRestartReturn>>;
|
|
5
|
+
export declare function handleSystemApplyUpdate(_args: SystemApplyUpdateArgs): Promise<Result<SystemUpdateDecisionReturn>>;
|
|
6
|
+
export declare function handleSystemSkipUpdate(_args: SystemSkipUpdateArgs): Promise<Result<SystemUpdateDecisionReturn>>;
|
|
@@ -4,6 +4,7 @@ import * as path from 'node:path';
|
|
|
4
4
|
import { STORE_DIR } from '../../../core/paths.js';
|
|
5
5
|
import { clearThrottle } from '../../costs/rate-limit-throttle.js';
|
|
6
6
|
import { usageService } from '../../costs/usage-service.js';
|
|
7
|
+
import { answerServerUpdatePrompt, getServerUpdateStatus, } from '../../system/update-ui-state.js';
|
|
7
8
|
function readChildPid() {
|
|
8
9
|
const childPidFile = path.join(STORE_DIR, 'daemon-child.pid');
|
|
9
10
|
try {
|
|
@@ -115,3 +116,15 @@ export async function handleSystemRestart(args) {
|
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
}
|
|
119
|
+
// ── server self-update decisions ────────────────────────────────
|
|
120
|
+
// Both resolve the `ask()` the dialog is waiting on (domain/system/update-ui-state.ts). The
|
|
121
|
+
// install itself, and the skipped-version bookkeeping, stay in checkServerUpdate — these
|
|
122
|
+
// handlers only deliver the answer.
|
|
123
|
+
export async function handleSystemApplyUpdate(_args) {
|
|
124
|
+
const accepted = answerServerUpdatePrompt('apply');
|
|
125
|
+
return { ok: true, data: { accepted, status: getServerUpdateStatus() } };
|
|
126
|
+
}
|
|
127
|
+
export async function handleSystemSkipUpdate(_args) {
|
|
128
|
+
const accepted = answerServerUpdatePrompt('skip');
|
|
129
|
+
return { ok: true, data: { accepted, status: getServerUpdateStatus() } };
|
|
130
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SystemDaemonStatus, SystemDaemonStatusParams, SystemRateLimitStatus, SystemRateLimitStatusParams, SystemUsageStatus, SystemUsageStatusParams, SystemNotices, SystemNoticesParams } from '../types.js';
|
|
1
|
+
import type { SystemDaemonStatus, SystemDaemonStatusParams, SystemRateLimitStatus, SystemRateLimitStatusParams, SystemUsageStatus, SystemUsageStatusParams, SystemNotices, SystemNoticesParams, SystemUpdateStatus, SystemUpdateStatusParams } from '../types.js';
|
|
2
2
|
export declare function handleSystemDaemonStatus(_params: SystemDaemonStatusParams): Promise<SystemDaemonStatus>;
|
|
3
3
|
export declare function handleSystemRateLimitStatus(_params: SystemRateLimitStatusParams): Promise<SystemRateLimitStatus>;
|
|
4
4
|
export declare function handleSystemUsageStatus(_params: SystemUsageStatusParams): Promise<SystemUsageStatus>;
|
|
5
5
|
export declare function handleSystemNotices(params: SystemNoticesParams): Promise<SystemNotices>;
|
|
6
|
+
export declare function handleSystemUpdateStatus(_params: SystemUpdateStatusParams): Promise<SystemUpdateStatus>;
|
|
@@ -5,6 +5,7 @@ import { getThrottleState } from '../../costs/rate-limit-throttle.js';
|
|
|
5
5
|
import { getResumeCountsByProvider } from '../../costs/resume-registry.js';
|
|
6
6
|
import { usageService } from '../../costs/usage-service.js';
|
|
7
7
|
import { listSystemNotices, NOTICE_HISTORY_CAP } from '../../system/notice-history.js';
|
|
8
|
+
import { getServerUpdateStatus } from '../../system/update-ui-state.js';
|
|
8
9
|
// ── Helpers ───────────────────────────────────────────────────────
|
|
9
10
|
function formatDuration(ms) {
|
|
10
11
|
const seconds = Math.floor(ms / 1000);
|
|
@@ -134,3 +135,6 @@ export async function handleSystemUsageStatus(_params) {
|
|
|
134
135
|
export async function handleSystemNotices(params) {
|
|
135
136
|
return { entries: listSystemNotices(params.limit), cap: NOTICE_HISTORY_CAP };
|
|
136
137
|
}
|
|
138
|
+
export async function handleSystemUpdateStatus(_params) {
|
|
139
|
+
return getServerUpdateStatus();
|
|
140
|
+
}
|
|
@@ -4,6 +4,8 @@ import type { Project, CreateProjectResult } from '../projects/index.js';
|
|
|
4
4
|
import type { CostSummary } from '../costs/cost-tracker.js';
|
|
5
5
|
import type { ProviderUsage } from '../costs/usage-store.js';
|
|
6
6
|
export type { ProviderUsage, UsageBilling, UsageFreshness, UsageWindow } from '../costs/usage-store.js';
|
|
7
|
+
import type { ServerUpdateStatus } from '../system/update-ui-state.js';
|
|
8
|
+
export type { ServerUpdateState, ServerUpdateStatus } from '../system/update-ui-state.js';
|
|
7
9
|
import type { EventBus } from '../../events/index.js';
|
|
8
10
|
import type { SessionStateReader } from '../../core/session-state.js';
|
|
9
11
|
import type { Settings, SettingSnapshotEntry } from '../../core/settings-spec.js';
|
|
@@ -38,8 +40,8 @@ export type Err = {
|
|
|
38
40
|
message: string;
|
|
39
41
|
};
|
|
40
42
|
export type Result<T> = Ok<T> | Err;
|
|
41
|
-
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';
|
|
42
|
-
export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.setSelection' | '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';
|
|
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
45
|
export interface SubscribeFilter {
|
|
44
46
|
events: string[];
|
|
45
47
|
projectId?: string | null;
|
|
@@ -297,6 +299,28 @@ export interface SessionSelectionOverride {
|
|
|
297
299
|
* Naming a profile without naming anything else means "run this profile as declared", which drops
|
|
298
300
|
* the session's earlier model/thinking choices.
|
|
299
301
|
*/
|
|
302
|
+
/** Move a live session in or out of commission mode. `new` starts a contract draft, `join` attaches
|
|
303
|
+
* to a landed commission, `off` leaves the drafting phase. A session already bound to a commission
|
|
304
|
+
* is terminal and refuses every transition. */
|
|
305
|
+
export interface SessionsSetCommissionArgs {
|
|
306
|
+
sessionId: string;
|
|
307
|
+
commission: {
|
|
308
|
+
mode: 'off';
|
|
309
|
+
} | {
|
|
310
|
+
mode: 'new';
|
|
311
|
+
} | {
|
|
312
|
+
mode: 'join';
|
|
313
|
+
commissionId: string;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export interface SessionsSetCommissionReturn {
|
|
317
|
+
/** The session's state after the call: which half of the mode it is in, if any. */
|
|
318
|
+
phase: 'none' | 'draft' | 'active';
|
|
319
|
+
commissionId: string | null;
|
|
320
|
+
commissionDraft: string | null;
|
|
321
|
+
/** True when leaving also deleted an untouched draft directory. */
|
|
322
|
+
removedDraftDir?: boolean;
|
|
323
|
+
}
|
|
300
324
|
export interface SessionsSetSelectionArgs {
|
|
301
325
|
sessionId: string;
|
|
302
326
|
profileName?: string;
|
|
@@ -1834,6 +1858,15 @@ export interface SystemRestartReturn {
|
|
|
1834
1858
|
ok: boolean;
|
|
1835
1859
|
message: string;
|
|
1836
1860
|
}
|
|
1861
|
+
export type SystemUpdateStatusParams = Record<string, never>;
|
|
1862
|
+
export type SystemUpdateStatus = ServerUpdateStatus;
|
|
1863
|
+
export type SystemApplyUpdateArgs = Record<string, never>;
|
|
1864
|
+
export type SystemSkipUpdateArgs = Record<string, never>;
|
|
1865
|
+
export interface SystemUpdateDecisionReturn {
|
|
1866
|
+
/** false when no prompt was pending — a stale dialog whose answer arrived too late. */
|
|
1867
|
+
accepted: boolean;
|
|
1868
|
+
status: SystemUpdateStatus;
|
|
1869
|
+
}
|
|
1837
1870
|
export interface SystemClearRateLimitArgs {
|
|
1838
1871
|
/** Provider key to clear; omit to clear every throttled provider. */
|
|
1839
1872
|
provider?: string;
|
|
@@ -1983,6 +2016,7 @@ export interface QueryParamMap {
|
|
|
1983
2016
|
'system.rateLimitStatus': SystemRateLimitStatusParams;
|
|
1984
2017
|
'system.usageStatus': SystemUsageStatusParams;
|
|
1985
2018
|
'system.notices': SystemNoticesParams;
|
|
2019
|
+
'system.updateStatus': SystemUpdateStatusParams;
|
|
1986
2020
|
}
|
|
1987
2021
|
export interface QueryReturnMap {
|
|
1988
2022
|
'projects.list': ProjectConduitInfo[];
|
|
@@ -2025,6 +2059,7 @@ export interface QueryReturnMap {
|
|
|
2025
2059
|
'system.rateLimitStatus': SystemRateLimitStatus;
|
|
2026
2060
|
'system.usageStatus': SystemUsageStatus;
|
|
2027
2061
|
'system.notices': SystemNotices;
|
|
2062
|
+
'system.updateStatus': SystemUpdateStatus;
|
|
2028
2063
|
}
|
|
2029
2064
|
export interface MutateArgsMap {
|
|
2030
2065
|
'projects.create': ProjectCreateArgs;
|
|
@@ -2034,6 +2069,7 @@ export interface MutateArgsMap {
|
|
|
2034
2069
|
'sessions.compact': SessionsCompactArgs;
|
|
2035
2070
|
'sessions.setProfile': SessionsSetProfileArgs;
|
|
2036
2071
|
'sessions.setSelection': SessionsSetSelectionArgs;
|
|
2072
|
+
'sessions.setCommission': SessionsSetCommissionArgs;
|
|
2037
2073
|
'sessions.createAndSend': SessionsCreateAndSendArgs;
|
|
2038
2074
|
'sessions.markRead': SessionsMarkReadArgs;
|
|
2039
2075
|
'sessions.answerQuestion': SessionsAnswerQuestionArgs;
|
|
@@ -2097,6 +2133,8 @@ export interface MutateArgsMap {
|
|
|
2097
2133
|
'system.restart': SystemRestartArgs;
|
|
2098
2134
|
'system.clearRateLimit': SystemClearRateLimitArgs;
|
|
2099
2135
|
'system.refreshUsage': SystemRefreshUsageArgs;
|
|
2136
|
+
'system.applyUpdate': SystemApplyUpdateArgs;
|
|
2137
|
+
'system.skipUpdate': SystemSkipUpdateArgs;
|
|
2100
2138
|
}
|
|
2101
2139
|
export interface MutateReturnMap {
|
|
2102
2140
|
'projects.create': ProjectCreateReturn;
|
|
@@ -2106,6 +2144,7 @@ export interface MutateReturnMap {
|
|
|
2106
2144
|
'sessions.compact': SessionsCompactReturn;
|
|
2107
2145
|
'sessions.setProfile': SessionsSetProfileReturn;
|
|
2108
2146
|
'sessions.setSelection': SessionsSetSelectionReturn;
|
|
2147
|
+
'sessions.setCommission': SessionsSetCommissionReturn;
|
|
2109
2148
|
'sessions.createAndSend': SessionsCreateAndSendReturn;
|
|
2110
2149
|
'sessions.markRead': void;
|
|
2111
2150
|
'sessions.answerQuestion': SessionsInteractionMutateReturn;
|
|
@@ -2172,6 +2211,8 @@ export interface MutateReturnMap {
|
|
|
2172
2211
|
'system.restart': SystemRestartReturn;
|
|
2173
2212
|
'system.clearRateLimit': SystemClearRateLimitReturn;
|
|
2174
2213
|
'system.refreshUsage': SystemRefreshUsageReturn;
|
|
2214
|
+
'system.applyUpdate': SystemUpdateDecisionReturn;
|
|
2215
|
+
'system.skipUpdate': SystemUpdateDecisionReturn;
|
|
2175
2216
|
}
|
|
2176
2217
|
export type QueryParams<S extends QueryScope> = S extends keyof QueryParamMap ? QueryParamMap[S] : never;
|
|
2177
2218
|
export type QueryReturn<S extends QueryScope> = S extends keyof QueryReturnMap ? QueryReturnMap[S] : never;
|
|
@@ -2217,7 +2258,7 @@ export interface UiServiceDeps {
|
|
|
2217
2258
|
getById(sessionId: string): Promise<Session | null>;
|
|
2218
2259
|
/** Admission-only liveness touch for fire-and-forget send. Updates lastUsedAt and returns false
|
|
2219
2260
|
* when the session is already pending deletion or missing. Optional for legacy fixtures. */
|
|
2220
|
-
|
|
2261
|
+
touchSessionUse?(sessionId: string): Promise<boolean>;
|
|
2221
2262
|
/** Stamp lastReadAt=now (unread tracking; backs `sessions.markRead`). Optional so existing
|
|
2222
2263
|
* facade/test fixtures need not provide it (the handler no-ops when absent). */
|
|
2223
2264
|
markRead?(sessionId: string): Promise<void>;
|
|
@@ -28,7 +28,7 @@ import { handlePluginsList } from './query/plugins.js';
|
|
|
28
28
|
import { handlePluginsSkillFile, handlePluginsMcpRead } from './query/plugin-source.js';
|
|
29
29
|
import { handleThreadTemplatesGet } from './query/thread-templates.js';
|
|
30
30
|
import { handleThreadTemplatesDetail } from './query/thread-template-detail.js';
|
|
31
|
-
import { handleSystemDaemonStatus, handleSystemRateLimitStatus, handleSystemUsageStatus, handleSystemNotices, } from './query/system.js';
|
|
31
|
+
import { handleSystemDaemonStatus, handleSystemRateLimitStatus, handleSystemUsageStatus, handleSystemNotices, handleSystemUpdateStatus, } from './query/system.js';
|
|
32
32
|
import { handleConfigSet, handleConfigSetProviderRateLimitPolicy, } from './mutate/config.js';
|
|
33
33
|
import { handleHooksCreate, handleHooksUpdate, handleHooksSetEnabled, handleHooksRemove, handleHooksTest, } from './mutate/hooks.js';
|
|
34
34
|
import { handleProfilesCreate, handleProfilesUpdate, handleProfilesRemove, } from './mutate/profiles.js';
|
|
@@ -36,7 +36,7 @@ import { handleThreadTemplatesValidate, handleThreadTemplatesSave, handleThreadT
|
|
|
36
36
|
import { handlePluginsAssign } from './mutate/plugins.js';
|
|
37
37
|
import { handlePluginsSkillWrite, handlePluginsSkillCreate, handlePluginsSkillMove, handlePluginsSkillRemove, handlePluginsCreate, handlePluginsRemove, handlePluginsConvertToPortable, handlePluginsMcpWrite, } from './mutate/plugin-packages.js';
|
|
38
38
|
import { handleCreateProject } from './mutate/projects.js';
|
|
39
|
-
import { handleCreateSession, handleSendSession, handleCancelSession, handleCompactSession, handleSetProfile, handleSetSelection, handleCreateAndSend, handleMarkReadSession, handleAnswerQuestion, handleRespondPlan, handleRespondDecision, handleCancelResume, handleRewindSession } from './mutate/sessions.js';
|
|
39
|
+
import { handleCreateSession, handleSendSession, handleCancelSession, handleCompactSession, handleSetProfile, handleSetSelection, handleSetCommission, handleCreateAndSend, handleMarkReadSession, handleAnswerQuestion, handleRespondPlan, handleRespondDecision, handleCancelResume, handleRewindSession } from './mutate/sessions.js';
|
|
40
40
|
import { handleCancelThread } from './mutate/threads.js';
|
|
41
41
|
import { handleCancelExecution } from './mutate/executions.js';
|
|
42
42
|
import { handlePauseSchedule, handleResumeSchedule, handleRemoveSchedule, handleAddSchedule, handleUpdateSchedule, } from './mutate/schedules.js';
|
|
@@ -45,7 +45,7 @@ import { handleClaimTask, handleUnclaimTask, handleCompleteTask, handleBlockTask
|
|
|
45
45
|
import { handleApproveApproval, handleRejectApproval, handleRequestApproval } from './mutate/approvals.js';
|
|
46
46
|
import { handleIssuesDelete, handleIssuesHandle } from './mutate/issues.js';
|
|
47
47
|
import { handleNotesAdd, handleNotesClearCompleted, handleNotesDelete, handleNotesSetCompleted, handleNotesUpdate, } from './mutate/notes.js';
|
|
48
|
-
import { handleSystemRestart, handleSystemClearRateLimit, handleSystemRefreshUsage, } from './mutate/system.js';
|
|
48
|
+
import { handleSystemRestart, handleSystemClearRateLimit, handleSystemRefreshUsage, handleSystemApplyUpdate, handleSystemSkipUpdate, } from './mutate/system.js';
|
|
49
49
|
import { handleAuthCancelFlow, handleAuthLogout, handleAuthSyncGateway, handleAuthRespondPrompt, handleAuthStartLogin, } from './mutate/auth.js';
|
|
50
50
|
import { handleCustomProviderRemove, handleCustomProviderUpsert, } from './mutate/custom-providers.js';
|
|
51
51
|
import { createSubscription } from './subscribe.js';
|
|
@@ -91,6 +91,7 @@ const queryHandlers = {
|
|
|
91
91
|
'system.rateLimitStatus': (_deps, params) => handleSystemRateLimitStatus(params),
|
|
92
92
|
'system.usageStatus': (_deps, params) => handleSystemUsageStatus(params),
|
|
93
93
|
'system.notices': (_deps, params) => handleSystemNotices(params),
|
|
94
|
+
'system.updateStatus': (_deps, params) => handleSystemUpdateStatus(params),
|
|
94
95
|
};
|
|
95
96
|
const mutateHandlers = {
|
|
96
97
|
'projects.create': (deps, args) => handleCreateProject(deps, args),
|
|
@@ -100,6 +101,7 @@ const mutateHandlers = {
|
|
|
100
101
|
'sessions.compact': (deps, args) => handleCompactSession(deps, args),
|
|
101
102
|
'sessions.setProfile': (deps, args) => handleSetProfile(deps, args),
|
|
102
103
|
'sessions.setSelection': (deps, args) => handleSetSelection(deps, args),
|
|
104
|
+
'sessions.setCommission': (deps, args) => handleSetCommission(deps, args),
|
|
103
105
|
'sessions.createAndSend': (deps, args) => handleCreateAndSend(deps, args),
|
|
104
106
|
'sessions.markRead': (deps, args) => handleMarkReadSession(deps, args),
|
|
105
107
|
'sessions.answerQuestion': (deps, args) => handleAnswerQuestion(deps, args),
|
|
@@ -163,6 +165,8 @@ const mutateHandlers = {
|
|
|
163
165
|
'system.restart': (_deps, args) => handleSystemRestart(args),
|
|
164
166
|
'system.clearRateLimit': (_deps, args) => handleSystemClearRateLimit(args),
|
|
165
167
|
'system.refreshUsage': (_deps, args) => handleSystemRefreshUsage(args),
|
|
168
|
+
'system.applyUpdate': (_deps, args) => handleSystemApplyUpdate(args),
|
|
169
|
+
'system.skipUpdate': (_deps, args) => handleSystemSkipUpdate(args),
|
|
166
170
|
};
|
|
167
171
|
export function redactMutationAuditArgs(op, args) {
|
|
168
172
|
if (op === 'config.setPlatform')
|
package/dist/entry/app.js
CHANGED
|
@@ -42,7 +42,6 @@ import { initClientHotReload } from '../domain/remote/client-hot-reload.js';
|
|
|
42
42
|
import { checkServerUpdate } from '../domain/system/server-update-check.js';
|
|
43
43
|
import { emitSystemNotice } from '../domain/system/system-notice.js';
|
|
44
44
|
import { threadStore } from '../store/thread-repo.js';
|
|
45
|
-
import { sessionRepo, registerConduitProvider } from '../store/session-repo.js';
|
|
46
45
|
import { conversationLedger } from '../store/conversation-ledger-repo.js';
|
|
47
46
|
import { conversationHistory } from '../store/conversation-history-repo.js';
|
|
48
47
|
import { pendingInjectionRepo } from '../store/pending-injection-repo.js';
|
|
@@ -77,6 +76,7 @@ import { registerInteractionHandlers, initInteractionHandlers } from '../orchest
|
|
|
77
76
|
import { respondToPlan } from '../orchestration/interactions/plan-response.js';
|
|
78
77
|
import { CommandActionRouter } from '../orchestration/interactions/command-action-router.js';
|
|
79
78
|
import { createUpdatePrompt } from '../orchestration/interactions/update-prompt.js';
|
|
79
|
+
import { createUiUpdatePrompt } from '../orchestration/interactions/ui-update-prompt.js';
|
|
80
80
|
import { registerMessageHandler } from '../orchestration/routing/message-router.js';
|
|
81
81
|
import { initRateLimitThrottle, clearThrottle, RATE_LIMIT_CLEAR_ACTION_ID } from '../domain/costs/rate-limit-throttle.js';
|
|
82
82
|
import { initResumeRegistry, getResumeCount, pendingDirectTrackSessionIds } from '../domain/costs/resume-registry.js';
|
|
@@ -98,7 +98,7 @@ import { retentionCandidateRepo } from '../store/retention-candidate-repo.js';
|
|
|
98
98
|
import { createDirectSession, adoptScheduledSession } from '../domain/sessions/session-lifecycle.js';
|
|
99
99
|
import { runSessionRetentionSweep } from '../domain/sessions/session-retention.js';
|
|
100
100
|
import { syncClaudeUserCleanupPeriodDays } from '../domain/auth/claude-user-settings.js';
|
|
101
|
-
import { setSessionAsync } from '../domain/sessions/session.js';
|
|
101
|
+
import { setSessionAsync, getSessionAsync } from '../domain/sessions/session.js';
|
|
102
102
|
import { applyChannelSelection, getChannelOverride, getSelectionDefault, resolveBackendForChannel, switchChannelProfile, } from '../domain/agents/index.js';
|
|
103
103
|
import { isSessionCompactionSupported } from '../domain/runs/compact.js';
|
|
104
104
|
import { initDiskMonitor, stopDiskMonitor } from '../domain/monitor/disk-monitor.js';
|
|
@@ -162,7 +162,6 @@ async function runRetentionSweep(retentionDays) {
|
|
|
162
162
|
const result = await runSessionRetentionSweep({
|
|
163
163
|
retentionDays,
|
|
164
164
|
registry: sessionStore,
|
|
165
|
-
sessionRepo,
|
|
166
165
|
ledgerRepo: conversationLedger,
|
|
167
166
|
historyRepo: conversationHistory,
|
|
168
167
|
candidateRepo: retentionCandidateRepo,
|
|
@@ -327,9 +326,9 @@ if (tuiGateway) {
|
|
|
327
326
|
// Conduit-queue port — MUST wrap the shared @orch/conduit-queue singletons so TUI message
|
|
328
327
|
// work serializes with the rest of the pipeline on the same conduit key.
|
|
329
328
|
tuiGateway.setConduitQueue({ enqueue, remove: (id) => conduitQueues.delete(id) });
|
|
330
|
-
// Conduit
|
|
329
|
+
// Conduit resolver inversion: the registry's channel lookup resolves ephemeral TUI conduits
|
|
331
330
|
// via the gateway's in-memory state (previously the gateway imported the store directly).
|
|
332
|
-
|
|
331
|
+
sessionStore.registerConduitResolver((conduitId) => tuiGateway.lookupConduit(conduitId)?.sessionId ?? null);
|
|
333
332
|
}
|
|
334
333
|
// --- Wire hot-reload admin notifiers ---
|
|
335
334
|
const notifyAdmin = (text) => {
|
|
@@ -382,7 +381,11 @@ const dispatchCommand = registerCommands({
|
|
|
382
381
|
onLangChanged: () => bus.publish({ type: 'config.changed', section: 'preferences' }),
|
|
383
382
|
});
|
|
384
383
|
// DR-0013: wire Slack update prompt BEFORE bindToAdapter (router has no unregister API)
|
|
385
|
-
|
|
384
|
+
// The SPA dialog is the prompt users actually see; the chat-message prompt stays wired as the
|
|
385
|
+
// fallback createUiUpdatePrompt hands the question to when nobody answers the dialog in time
|
|
386
|
+
// (Slack/Feishu/headless installs have no SPA open).
|
|
387
|
+
const chatUpdatePrompt = createUpdatePrompt(adapter, commandRouter);
|
|
388
|
+
const updatePrompt = createUiUpdatePrompt(chatUpdatePrompt);
|
|
386
389
|
// Bind command action handlers (buttons, modals) to the platform adapter
|
|
387
390
|
commandRouter.bindToAdapter(adapter);
|
|
388
391
|
const handleMessageEdit = createEditHandler({
|
|
@@ -437,7 +440,7 @@ process.on('SIGTERM', async () => {
|
|
|
437
440
|
// `writeFile(tmp)` and `rename(tmp, target)` in atomic-write.ts leaves orphan .tmp.* siblings.
|
|
438
441
|
// Daemon gives 5s before SIGKILL — well over the time needed to flush a few MB of JSON.
|
|
439
442
|
try {
|
|
440
|
-
await Promise.allSettled([bus.close(), oq.flush(), threadStore.flush(),
|
|
443
|
+
await Promise.allSettled([bus.close(), oq.flush(), threadStore.flush(), conversationLedger.flush(), conversationHistory.flush(), pendingInjectionRepo.flush(), taskStore.flush(), executionRepo.flush(), projectDirRepo.flush(), scheduleRepo.flush(), providerStateRepo.flush(), costRepo.flush(), profileRepo.flush(), sessionStore.flush()]);
|
|
441
444
|
}
|
|
442
445
|
catch { }
|
|
443
446
|
await stopGateway();
|
|
@@ -673,21 +676,6 @@ process.on('SIGTERM', async () => {
|
|
|
673
676
|
oq.startDrainLoop();
|
|
674
677
|
pendingTaskTracker.init(adapter);
|
|
675
678
|
taskStore.load();
|
|
676
|
-
// Collapse sessions.json `backend:channel` keys onto `channel`. Idempotent — a migrated
|
|
677
|
-
// file has no legacy keys left, so this is a no-op on every boot after the first.
|
|
678
|
-
try {
|
|
679
|
-
const keys = await sessionRepo.migrateSessionKeys({
|
|
680
|
-
lastUsedAt: async (sessionId) => (await sessionStore.getById(sessionId))?.lastUsedAt ?? null,
|
|
681
|
-
log: (message) => log.warn(message),
|
|
682
|
-
});
|
|
683
|
-
if (keys.migrated > 0) {
|
|
684
|
-
log.info(`sessions.json: migrated ${keys.migrated} backend-prefixed key(s) to channel keys`
|
|
685
|
-
+ (keys.conflicts > 0 ? ` (${keys.conflicts} channel(s) had two bindings)` : ''));
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
catch (e) {
|
|
689
|
-
log.warn(`sessions.json key migration failed: ${e.message}`);
|
|
690
|
-
}
|
|
691
679
|
// DR-0017 D6 Phase 2.5: migrate a legacy single thread-templates.json to the directory form,
|
|
692
680
|
// then per-file copy-if-missing the shipped defaults dir (so new agents/templates/shells — e.g.
|
|
693
681
|
// a new shell definition — reach existing installs). Sealed trial homes supply their complete
|
|
@@ -728,7 +716,7 @@ process.on('SIGTERM', async () => {
|
|
|
728
716
|
save: (entries) => providerStateRepo.setResumeQueue(entries),
|
|
729
717
|
load: () => providerStateRepo.getResumeQueue(),
|
|
730
718
|
}, () => { bus.publish({ type: 'rate-limit.changed' }); }, async (entry) => {
|
|
731
|
-
const bound = await
|
|
719
|
+
const bound = await getSessionAsync(entry.channel);
|
|
732
720
|
return bound && await sessionStore.getById(bound) ? bound : null;
|
|
733
721
|
});
|
|
734
722
|
let reQueuedRateLimited = 0;
|