@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.
Files changed (102) hide show
  1. package/defaults/plugins/cortex-commission/.claude-plugin/plugin.json +2 -2
  2. package/defaults/plugins/cortex-commission/plugin.json +2 -2
  3. package/defaults/plugins/cortex-commission/skills/commission/SKILL.md +3 -3
  4. package/dist/agent-adapter/claude/adapter.d.ts +0 -6
  5. package/dist/agent-adapter/claude/adapter.js +0 -8
  6. package/dist/agent-adapter/claude/defaults.d.ts +10 -7
  7. package/dist/agent-adapter/claude/defaults.js +18 -16
  8. package/dist/agent-adapter/claude/spawn-args.d.ts +0 -3
  9. package/dist/agent-adapter/claude/spawn-args.js +16 -16
  10. package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +11 -2
  11. package/dist/agent-adapter/pi/mcp-bridge-logic.js +32 -1
  12. package/dist/agent-adapter/pi/mcp-bridge.js +16 -15
  13. package/dist/agent-adapter/pi/session-options.d.ts +0 -6
  14. package/dist/agent-adapter/pi/session-options.js +1 -8
  15. package/dist/agent-adapter/types.d.ts +0 -1
  16. package/dist/core/mcp-tool-gate.d.ts +3 -17
  17. package/dist/core/mcp-tool-gate.js +3 -19
  18. package/dist/core/settings-spec.d.ts +1 -1
  19. package/dist/core/settings-spec.js +5 -1
  20. package/dist/domain/agents/config.d.ts +1 -1
  21. package/dist/domain/agents/config.js +1 -1
  22. package/dist/domain/agents/profile-switch.d.ts +1 -1
  23. package/dist/domain/agents/profile-switch.js +3 -5
  24. package/dist/domain/agents/subagent/runner.js +0 -1
  25. package/dist/domain/commissions/commission-draft.d.ts +58 -0
  26. package/dist/domain/commissions/commission-draft.js +87 -4
  27. package/dist/domain/commissions/commission-finalize.d.ts +8 -3
  28. package/dist/domain/commissions/commission-finalize.js +14 -0
  29. package/dist/domain/mcp/tools/commission-tools.d.ts +12 -1
  30. package/dist/domain/mcp/tools/commission-tools.js +68 -14
  31. package/dist/domain/remote/client-manager.js +66 -7
  32. package/dist/domain/remote/client-ssh-tunnel.d.ts +16 -5
  33. package/dist/domain/remote/client-ssh-tunnel.js +12 -5
  34. package/dist/domain/runs/builders.js +0 -1
  35. package/dist/domain/runs/compact.js +0 -1
  36. package/dist/domain/runs/engine-spec.d.ts +11 -4
  37. package/dist/domain/runs/engine-spec.js +7 -4
  38. package/dist/domain/runs/prompt.js +16 -10
  39. package/dist/domain/runs/request.d.ts +0 -1
  40. package/dist/domain/sessions/session-hooks.d.ts +5 -12
  41. package/dist/domain/sessions/session-hooks.js +6 -13
  42. package/dist/domain/sessions/session-lifecycle.d.ts +4 -4
  43. package/dist/domain/sessions/session-lifecycle.js +5 -6
  44. package/dist/domain/sessions/session-retention.d.ts +1 -3
  45. package/dist/domain/sessions/session-retention.js +9 -26
  46. package/dist/domain/sessions/session-use.d.ts +32 -0
  47. package/dist/domain/sessions/session-use.js +63 -0
  48. package/dist/domain/sessions/session.js +6 -5
  49. package/dist/domain/system/server-update-check.js +29 -1
  50. package/dist/domain/system/update-ui-state.d.ts +32 -0
  51. package/dist/domain/system/update-ui-state.js +63 -0
  52. package/dist/domain/threads/runner.js +0 -1
  53. package/dist/domain/ui-service/app-router.d.ts +30 -0
  54. package/dist/domain/ui-service/app-router.js +5 -1
  55. package/dist/domain/ui-service/input-schemas.d.ts +32 -0
  56. package/dist/domain/ui-service/input-schemas.js +22 -0
  57. package/dist/domain/ui-service/mutate/sessions.d.ts +13 -1
  58. package/dist/domain/ui-service/mutate/sessions.js +69 -3
  59. package/dist/domain/ui-service/mutate/system.d.ts +3 -1
  60. package/dist/domain/ui-service/mutate/system.js +13 -0
  61. package/dist/domain/ui-service/query/system.d.ts +2 -1
  62. package/dist/domain/ui-service/query/system.js +4 -0
  63. package/dist/domain/ui-service/types.d.ts +44 -3
  64. package/dist/domain/ui-service/ui-service.js +7 -3
  65. package/dist/entry/app.js +11 -23
  66. package/dist/entry/start-ui-http.js +3 -1
  67. package/dist/events/event-types.d.ts +5 -0
  68. package/dist/orchestration/agent-runner.d.ts +1 -1
  69. package/dist/orchestration/agent-runner.js +8 -11
  70. package/dist/orchestration/conversation-request.d.ts +26 -8
  71. package/dist/orchestration/conversation-request.js +49 -20
  72. package/dist/orchestration/edit-retry.js +2 -1
  73. package/dist/orchestration/interactions/ask-user-resume.js +2 -1
  74. package/dist/orchestration/interactions/ui-update-prompt.d.ts +8 -0
  75. package/dist/orchestration/interactions/ui-update-prompt.js +47 -0
  76. package/dist/orchestration/resume-dispatcher.js +2 -2
  77. package/dist/orchestration/routing/webhook.js +47 -0
  78. package/dist/orchestration/session-compact.d.ts +3 -0
  79. package/dist/orchestration/session-compact.js +3 -2
  80. package/dist/orchestration/session-events.d.ts +6 -0
  81. package/dist/orchestration/session-events.js +5 -0
  82. package/dist/orchestration/turn/turn-prep.js +2 -1
  83. package/dist/platform/ui-http/app-update.d.ts +11 -0
  84. package/dist/platform/ui-http/app-update.js +3 -0
  85. package/dist/store/conversation-ledger-repo.d.ts +10 -19
  86. package/dist/store/conversation-ledger-repo.js +143 -152
  87. package/dist/store/session-registry-import.d.ts +34 -0
  88. package/dist/store/session-registry-import.js +182 -0
  89. package/dist/store/session-registry-journal.d.ts +107 -0
  90. package/dist/store/session-registry-journal.js +307 -18
  91. package/dist/store/session-registry-repo.d.ts +113 -28
  92. package/dist/store/session-registry-repo.js +287 -104
  93. package/dist/store/version-migrations.d.ts +16 -0
  94. package/dist/store/version-migrations.js +34 -0
  95. package/package.json +1 -1
  96. package/web/dist/assets/{index-aHbOZSP6.js → index-CEZ0DSei.js} +1 -1
  97. package/web/dist/assets/{index-CCPxQ94C.css → index-CRDJo39X.css} +1 -1
  98. package/web/dist/assets/index-DjuPJVZE.js +444 -0
  99. package/web/dist/index.html +2 -2
  100. package/dist/store/session-repo.d.ts +0 -65
  101. package/dist/store/session-repo.js +0 -184
  102. package/web/dist/assets/index-BuXbCsuz.js +0 -444
@@ -19,8 +19,8 @@
19
19
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
20
20
  rel="stylesheet"
21
21
  />
22
- <script type="module" crossorigin src="/assets/index-BuXbCsuz.js"></script>
23
- <link rel="stylesheet" crossorigin href="/assets/index-CCPxQ94C.css">
22
+ <script type="module" crossorigin src="/assets/index-DjuPJVZE.js"></script>
23
+ <link rel="stylesheet" crossorigin href="/assets/index-CRDJo39X.css">
24
24
  </head>
25
25
  <body>
26
26
  <div id="root"></div>
@@ -1,65 +0,0 @@
1
- /**
2
- * A conduit provider resolves session+project info for non-file-based conduits
3
- * (e.g., TUI in-memory conduit state). Returns null for unrecognized conduitIds
4
- * so the file-based lookup is used as fallback.
5
- */
6
- export type ConduitProvider = (conduitId: string) => {
7
- sessionId: string;
8
- projectId: string;
9
- } | null;
10
- /**
11
- * Register a conduit provider callback. Called by adapters (e.g., TuiGatewayAdapter)
12
- * during start() so session lookup can resolve in-memory conduit state.
13
- */
14
- export declare function registerConduitProvider(provider: ConduitProvider): void;
15
- /** Shape of sessions.json: `{"<channel>": sessionId, ...}`. Legacy files key on
16
- * `"<backend>:<channel>"`; both are read, and `migrateSessionKeys` collapses the old form. */
17
- export type SessionsData = Record<string, string>;
18
- export interface SessionKeyMigrationDeps {
19
- /** When two backends bound the same channel, the more recently used binding wins. Returns null
20
- * for a session the registry has forgotten, which then loses to any dated candidate. */
21
- lastUsedAt?: (sessionId: string) => Promise<string | null>;
22
- log?: (message: string) => void;
23
- }
24
- export interface SessionKeyMigrationResult {
25
- /** Keys rewritten from `backend:channel` to `channel`. */
26
- migrated: number;
27
- /** Channels that held two different sessions, one of which was dropped. */
28
- conflicts: number;
29
- }
30
- export declare class SessionRepo {
31
- private _repo;
32
- constructor(filePath?: string);
33
- /**
34
- * The session bound to a channel.
35
- *
36
- * `backend` is accepted and ignored: a channel has one session. The parameter stays so the
37
- * many call sites that pass one keep compiling while they are cleaned up; it is deprecated.
38
- *
39
- * Legacy `backend:channel` keys are still read, so a file written by an older build resolves
40
- * correctly before `migrateSessionKeys` has run (and in any process that never runs it).
41
- */
42
- getSessionAsync(channel: string, _backend?: string): Promise<string | undefined>;
43
- /** Bind a channel to a session. Any legacy backend-prefixed key for the same channel is dropped,
44
- * so a write is also a migration of the one channel it touches. */
45
- setSessionAsync(channel: string, sessionId: string, _backend?: string): Promise<void>;
46
- /** Unbind a channel. Deletes every form of the key, so one call really does clear the channel —
47
- * where the old signature needed one call per backend and silently left the other behind. */
48
- deleteSessionAsync(channel: string, _backend?: string): Promise<void>;
49
- /**
50
- * Collapse `backend:channel` keys onto `channel`, once, at startup.
51
- *
52
- * A channel bound under both backends keeps the more recently used session and drops the other:
53
- * the two were never usable at the same time — only the channel's current backend was ever
54
- * consulted — so the newer one is the conversation the user actually has. Every drop is logged
55
- * with both ids, because that is the only record that the other binding existed.
56
- */
57
- migrateSessionKeys(deps?: SessionKeyMigrationDeps): Promise<SessionKeyMigrationResult>;
58
- deleteManyBySessionIds(sessionIds: Iterable<string>): Promise<number>;
59
- deleteExceptSessionIds(sessionIds: Iterable<string>): Promise<number>;
60
- /** Drop the in-memory cache so the next read() fetches from disk. Test hook. */
61
- invalidate(): void;
62
- /** Wait for any in-flight mutate() to complete. For graceful SIGTERM drain. */
63
- flush(): Promise<void>;
64
- }
65
- export declare const sessionRepo: SessionRepo;
@@ -1,184 +0,0 @@
1
- import * as path from 'path';
2
- import { JsonRepository } from '../core/json-repository.js';
3
- import { STORE_DIR } from '../core/paths.js';
4
- const SESSIONS_FILE = path.join(STORE_DIR, 'sessions.json');
5
- /** Registered conduit providers, tried in registration order before file lookup. */
6
- const conduitProviders = [];
7
- /**
8
- * Register a conduit provider callback. Called by adapters (e.g., TuiGatewayAdapter)
9
- * during start() so session lookup can resolve in-memory conduit state.
10
- */
11
- export function registerConduitProvider(provider) {
12
- conduitProviders.push(provider);
13
- }
14
- /** Try conduit providers in registration order; returns null if none match. */
15
- async function lookupViaProviders(channel) {
16
- for (const provider of conduitProviders) {
17
- const result = provider(channel);
18
- if (result)
19
- return result.sessionId;
20
- }
21
- return undefined;
22
- }
23
- /**
24
- * D5: a channel has ONE session, and which backend it runs is a property of that session's record,
25
- * not of the key it is filed under. Keying on `backend:channel` let the same channel hold two
26
- * bindings at once, so a caller that asked with the wrong backend — cancel, `!session`, the
27
- * scheduler — silently missed a session that was right there.
28
- */
29
- const LEGACY_PREFIXES = ['claude', 'pi'];
30
- function legacyKeys(channel) {
31
- return LEGACY_PREFIXES.map(prefix => `${prefix}:${channel}`);
32
- }
33
- /** Split a stored key into the channel it refers to. `web:`/`slack:`/`feishu:`/`tui:` channels
34
- * carry their own colons, so only a leading backend name is stripped, and only those two. */
35
- function channelFromKey(key) {
36
- for (const prefix of LEGACY_PREFIXES) {
37
- if (key.startsWith(`${prefix}:`))
38
- return key.slice(prefix.length + 1);
39
- }
40
- return key;
41
- }
42
- export class SessionRepo {
43
- _repo;
44
- constructor(filePath = SESSIONS_FILE) {
45
- this._repo = new JsonRepository({
46
- filePath,
47
- defaultValue: () => ({}),
48
- migrate: (raw) => (typeof raw === 'object' && raw !== null ? raw : ({})),
49
- });
50
- }
51
- /**
52
- * The session bound to a channel.
53
- *
54
- * `backend` is accepted and ignored: a channel has one session. The parameter stays so the
55
- * many call sites that pass one keep compiling while they are cleaned up; it is deprecated.
56
- *
57
- * Legacy `backend:channel` keys are still read, so a file written by an older build resolves
58
- * correctly before `migrateSessionKeys` has run (and in any process that never runs it).
59
- */
60
- async getSessionAsync(channel, _backend) {
61
- // Try conduit providers first (TUI in-memory state, etc.)
62
- const providerResult = await lookupViaProviders(channel);
63
- if (providerResult !== undefined)
64
- return providerResult;
65
- // Fall back to file storage
66
- const sessions = await this._repo.read();
67
- if (sessions[channel] !== undefined)
68
- return sessions[channel];
69
- for (const key of legacyKeys(channel)) {
70
- if (sessions[key] !== undefined)
71
- return sessions[key];
72
- }
73
- return undefined;
74
- }
75
- /** Bind a channel to a session. Any legacy backend-prefixed key for the same channel is dropped,
76
- * so a write is also a migration of the one channel it touches. */
77
- async setSessionAsync(channel, sessionId, _backend) {
78
- await this._repo.mutate((sessions) => {
79
- sessions[channel] = sessionId;
80
- for (const key of legacyKeys(channel))
81
- delete sessions[key];
82
- return { next: sessions, result: undefined };
83
- });
84
- }
85
- /** Unbind a channel. Deletes every form of the key, so one call really does clear the channel —
86
- * where the old signature needed one call per backend and silently left the other behind. */
87
- async deleteSessionAsync(channel, _backend) {
88
- await this._repo.mutate((sessions) => {
89
- delete sessions[channel];
90
- for (const key of legacyKeys(channel))
91
- delete sessions[key];
92
- return { next: sessions, result: undefined };
93
- });
94
- }
95
- /**
96
- * Collapse `backend:channel` keys onto `channel`, once, at startup.
97
- *
98
- * A channel bound under both backends keeps the more recently used session and drops the other:
99
- * the two were never usable at the same time — only the channel's current backend was ever
100
- * consulted — so the newer one is the conversation the user actually has. Every drop is logged
101
- * with both ids, because that is the only record that the other binding existed.
102
- */
103
- async migrateSessionKeys(deps = {}) {
104
- const lastUsedAt = deps.lastUsedAt ?? (async () => null);
105
- const sessions = await this._repo.read();
106
- const legacy = Object.keys(sessions).filter(key => key !== channelFromKey(key));
107
- if (legacy.length === 0)
108
- return { migrated: 0, conflicts: 0 };
109
- // Resolve timestamps before the mutate: the mutator must stay synchronous.
110
- const dated = new Map();
111
- for (const key of legacy) {
112
- const id = sessions[key];
113
- if (!dated.has(id))
114
- dated.set(id, await lastUsedAt(id).catch(() => null));
115
- }
116
- for (const key of legacy) {
117
- const bare = sessions[channelFromKey(key)];
118
- if (bare !== undefined && !dated.has(bare))
119
- dated.set(bare, await lastUsedAt(bare).catch(() => null));
120
- }
121
- return this._repo.mutate((data) => {
122
- let migrated = 0;
123
- let conflicts = 0;
124
- for (const key of legacy) {
125
- const value = data[key];
126
- if (value === undefined)
127
- continue;
128
- delete data[key];
129
- const channel = channelFromKey(key);
130
- const incumbent = data[channel];
131
- if (incumbent === undefined || incumbent === value) {
132
- data[channel] = value;
133
- migrated += 1;
134
- continue;
135
- }
136
- conflicts += 1;
137
- // An undated candidate is one the registry has forgotten; it loses to any dated one, and
138
- // to the incumbent when neither is dated (first key wins, so the result is deterministic).
139
- const keep = (dated.get(value) ?? '') > (dated.get(incumbent) ?? '') ? value : incumbent;
140
- data[channel] = keep;
141
- deps.log?.(`sessions.json: channel ${channel} was bound under two backends `
142
- + `(${incumbent}, ${value}); keeping the more recently used session ${keep}`);
143
- }
144
- return { next: data, result: { migrated, conflicts } };
145
- });
146
- }
147
- async deleteManyBySessionIds(sessionIds) {
148
- const targets = new Set(sessionIds);
149
- if (targets.size === 0)
150
- return 0;
151
- return this._repo.mutate((sessions) => {
152
- let removed = 0;
153
- for (const [key, value] of Object.entries(sessions)) {
154
- if (!targets.has(value))
155
- continue;
156
- delete sessions[key];
157
- removed += 1;
158
- }
159
- return { next: sessions, result: removed };
160
- });
161
- }
162
- async deleteExceptSessionIds(sessionIds) {
163
- const live = new Set(sessionIds);
164
- return this._repo.mutate((sessions) => {
165
- let removed = 0;
166
- for (const [key, value] of Object.entries(sessions)) {
167
- if (live.has(value))
168
- continue;
169
- delete sessions[key];
170
- removed += 1;
171
- }
172
- return { next: sessions, result: removed };
173
- });
174
- }
175
- /** Drop the in-memory cache so the next read() fetches from disk. Test hook. */
176
- invalidate() {
177
- this._repo.invalidate();
178
- }
179
- /** Wait for any in-flight mutate() to complete. For graceful SIGTERM drain. */
180
- flush() {
181
- return this._repo.flush();
182
- }
183
- }
184
- export const sessionRepo = new SessionRepo();