@platless/axom-cli 0.5.9 → 0.6.36

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 (163) hide show
  1. package/README.md +18 -5
  2. package/dist/axom-patch/cli/README.md +100 -12
  3. package/dist/axom-patch/cli/account-limits/generate.py +15 -12
  4. package/dist/axom-patch/cli/account-limits/kimi-proxy.mjs +20 -3
  5. package/dist/axom-patch/cli/claude-account-limits.json +9 -9
  6. package/dist/axom-patch/cli/codex-account-limits.json +11 -11
  7. package/dist/axom-patch/cli/codex-terminal-output.json +16 -0
  8. package/dist/axom-patch/cli/commandcode-account-limits.json +9 -9
  9. package/dist/axom-patch/cli/kimi-quota.mjs +12 -0
  10. package/dist/axom-patch/cli/kimi-subagents.mjs +173 -0
  11. package/dist/axom-patch/cli/nightly-task.md +55 -13
  12. package/dist/axom-patch/cli/probes/codex-terminal-output.mjs +33 -0
  13. package/dist/axom-patch/cli/probes/kimi-subagent-subwork.mjs +82 -0
  14. package/dist/axom-patch/cli/qoder/dist/axom-acp-compat.mjs +1591 -0
  15. package/dist/axom-patch/cli/qoder/releases/1.1.75.json +360 -0
  16. package/dist/axom-patch/cli/qoder-background-terminal.md +13 -6
  17. package/dist/axom-patch/cli/qoder-foreground-output.md +14 -8
  18. package/dist/axom-patch/cli/qoder-native-acp.json +227 -0
  19. package/dist/axom-patch/cli/qoder-steering.md +20 -25
  20. package/dist/axom-patch/cli/qoder-subagent-subwork.md +17 -68
  21. package/dist/axom-patch/cli/runtime.json +16 -18
  22. package/dist/axom-patch/cli/zcode-account-limits.json +10 -11
  23. package/dist/axom-patch/cli/zcode-models.json +1 -2
  24. package/dist/axom-patch/cli/zcode-subagent-subwork.json +9 -10
  25. package/dist/cli.js +4 -36
  26. package/dist/commands/knowledge.js +47 -0
  27. package/dist/commands/update.js +65 -3
  28. package/dist/commands/workstation.js +73 -7
  29. package/dist/install/claude/commands.js +13 -13
  30. package/dist/mcp.js +1 -1
  31. package/dist/native/darwin-arm64/axom-quic +0 -0
  32. package/dist/workstation/acp/acpAgents.js +102 -98
  33. package/dist/workstation/acp/acpClient.js +26 -0
  34. package/dist/workstation/acp/builds/install/npm.js +99 -10
  35. package/dist/workstation/acp/initializeResponse.js +6 -1
  36. package/dist/workstation/acp/managedPatches.js +189 -25
  37. package/dist/workstation/acp/managedRuntime.js +314 -0
  38. package/dist/workstation/acp/patchAssets.js +40 -0
  39. package/dist/workstation/acp/processor/checkpoint.js +25 -34
  40. package/dist/workstation/acp/processor/control.js +5 -78
  41. package/dist/workstation/acp/processor/runtime.js +5 -81
  42. package/dist/workstation/acp/processor/session.js +51 -80
  43. package/dist/workstation/acp/processor/state.js +6 -13
  44. package/dist/workstation/acp/processor/step.js +3 -20
  45. package/dist/workstation/acp/processor/test/fixtureLog.js +9 -16
  46. package/dist/workstation/acp/processor/updates.js +131 -105
  47. package/dist/workstation/acp/processorSession.js +8 -172
  48. package/dist/workstation/acp/registry/catalog.js +65 -39
  49. package/dist/workstation/acp/registry/launch.js +16 -1
  50. package/dist/workstation/acp/switching.js +0 -3
  51. package/dist/workstation/acp/test/fakeAgent.js +13 -0
  52. package/dist/workstation/acp/test/keeperWorld.js +28 -0
  53. package/dist/workstation/acp/test/raw/sources.js +16 -130
  54. package/dist/workstation/acp/test/realAdapter.js +1 -47
  55. package/dist/workstation/acp/test/scriptAgent.js +11 -3
  56. package/dist/workstation/agentFlow.js +1 -1
  57. package/dist/workstation/agentSessions.js +38 -143
  58. package/dist/workstation/channels/management.js +95 -11
  59. package/dist/workstation/channels/url.js +1 -1
  60. package/dist/workstation/config.js +16 -4
  61. package/dist/workstation/connection/encryptedChannel.js +4 -1
  62. package/dist/workstation/control/bindingStore.js +200 -0
  63. package/dist/workstation/control/commands.js +124 -0
  64. package/dist/workstation/control/daemonIdentity.js +53 -0
  65. package/dist/workstation/control/enrollment.js +106 -0
  66. package/dist/workstation/control/inspect.js +71 -0
  67. package/dist/workstation/control/locks.js +63 -0
  68. package/dist/workstation/control/protocol.js +40 -0
  69. package/dist/workstation/control/restartGuard.js +46 -0
  70. package/dist/workstation/control/runtimeClient.js +97 -0
  71. package/dist/workstation/control/runtimeHost.js +148 -0
  72. package/dist/workstation/control/serverIdentity.js +35 -0
  73. package/dist/workstation/daemon.js +106 -6
  74. package/dist/workstation/daemonctl.js +77 -14
  75. package/dist/workstation/desktopControl/audio.js +99 -0
  76. package/dist/workstation/desktopControl/capabilities.js +92 -0
  77. package/dist/workstation/desktopControl/captureModes.js +9 -0
  78. package/dist/workstation/desktopControl/captureTargetLabel.js +9 -0
  79. package/dist/workstation/desktopControl/deviceSockets.js +246 -0
  80. package/dist/workstation/desktopControl/helperProcess.js +353 -0
  81. package/dist/workstation/desktopControl/lobby.js +129 -0
  82. package/dist/workstation/desktopControl/macProvider.js +155 -0
  83. package/dist/workstation/desktopControl/media.js +331 -0
  84. package/dist/workstation/desktopControl/nativeProvider.js +1018 -0
  85. package/dist/workstation/desktopControl/networkEvidence.js +43 -0
  86. package/dist/workstation/desktopControl/overview.js +58 -0
  87. package/dist/workstation/desktopControl/protocol.js +302 -0
  88. package/dist/workstation/desktopControl/quicMedia.js +240 -0
  89. package/dist/workstation/desktopControl/rateController.js +226 -0
  90. package/dist/workstation/desktopControl/supervisor.js +1681 -0
  91. package/dist/workstation/desktopControl/transport.js +27 -0
  92. package/dist/workstation/desktopControl/wallpaper.js +78 -0
  93. package/dist/workstation/files/credentials.js +142 -0
  94. package/dist/workstation/files/text.js +42 -8
  95. package/dist/workstation/keepers/kit/bundle.js +21 -17
  96. package/dist/workstation/keepers/kit/launcher.js +47 -7
  97. package/dist/workstation/keepers/kit/paths.js +2 -1
  98. package/dist/workstation/managedInstall.js +57 -0
  99. package/dist/workstation/protocol/agent.js +2 -15
  100. package/dist/workstation/protocol/management.js +93 -4
  101. package/dist/workstation/protocol/runtimeDiagnostics.js +15 -0
  102. package/dist/workstation/rd/artifact.js +119 -0
  103. package/dist/workstation/rd/control.js +119 -0
  104. package/dist/workstation/rd/display.js +29 -0
  105. package/dist/workstation/rd/provider.js +222 -0
  106. package/dist/workstation/rd/sessions.js +391 -0
  107. package/dist/workstation/rd/state.js +45 -0
  108. package/dist/workstation/rd/update.js +171 -0
  109. package/dist/workstation/rd/upkeep.js +38 -0
  110. package/dist/workstation/register.js +27 -37
  111. package/dist/workstation/service/installer.js +104 -13
  112. package/dist/workstation/service/launchd.js +1 -0
  113. package/dist/workstation/storageMetrics.js +118 -0
  114. package/dist/workstation/systemMetrics.js +44 -92
  115. package/dist/workstation/toolchain.js +94 -0
  116. package/dist/workstation/tools/browser.js +28 -4
  117. package/dist/workstation/update/artifact.js +2 -1
  118. package/dist/workstation/update/globalInstall.js +116 -0
  119. package/dist/workstation/update/npmInstaller.js +49 -23
  120. package/dist/workstation/update/rdRollback.js +145 -0
  121. package/dist/workstation/update/runUpdate.js +3 -2
  122. package/dist/workstation/update/watchdog.js +16790 -334
  123. package/package.json +5 -5
  124. package/skills/axom/SKILL.md +11 -11
  125. package/skills/axom-definition/SKILL.md +3 -3
  126. package/skills/axom-platform/SKILL.md +3 -3
  127. package/dist/axom-patch/cli/probes/qoder-steering.mjs +0 -89
  128. package/dist/axom-patch/cli/probes/qoder-subagent-origin.mjs +0 -61
  129. package/dist/axom-patch/cli/qoder-steering.json +0 -52
  130. package/dist/axom-patch/cli/qoder-subagent-origin.json +0 -73
  131. package/dist/commands/guide.js +0 -38
  132. package/dist/runtime-deps/qoder-sdk/package-lock.json +0 -1189
  133. package/dist/runtime-deps/qoder-sdk/package.json +0 -8
  134. package/dist/workstation/acp/delegationMcp.js +0 -24
  135. package/dist/workstation/acp/processor/sideChannel.js +0 -80
  136. package/dist/workstation/acp/qoderStartup.js +0 -45
  137. package/dist/workstation/acp/test/raw/qoderCaptures.js +0 -125
  138. package/dist/workstation/qoderAdapter/backgroundProcess.js +0 -118
  139. package/dist/workstation/qoderAdapter/backgroundTerminal.js +0 -193
  140. package/dist/workstation/qoderAdapter/backgroundTerminalFold.js +0 -372
  141. package/dist/workstation/qoderAdapter/callbackContext.js +0 -76
  142. package/dist/workstation/qoderAdapter/completedContinuation.js +0 -139
  143. package/dist/workstation/qoderAdapter/contract.js +0 -78
  144. package/dist/workstation/qoderAdapter/foregroundOutput.js +0 -36
  145. package/dist/workstation/qoderAdapter/history.js +0 -85
  146. package/dist/workstation/qoderAdapter/identityIndex.js +0 -191
  147. package/dist/workstation/qoderAdapter/inputQueue.js +0 -42
  148. package/dist/workstation/qoderAdapter/main.js +0 -95
  149. package/dist/workstation/qoderAdapter/mapper.js +0 -117
  150. package/dist/workstation/qoderAdapter/observerPlugin.js +0 -245
  151. package/dist/workstation/qoderAdapter/observerReceiver.js +0 -187
  152. package/dist/workstation/qoderAdapter/permissions.js +0 -61
  153. package/dist/workstation/qoderAdapter/profile.js +0 -93
  154. package/dist/workstation/qoderAdapter/sdkDriver.js +0 -48
  155. package/dist/workstation/qoderAdapter/sdkRuntime.js +0 -93
  156. package/dist/workstation/qoderAdapter/sdkRuntimeInstall.js +0 -145
  157. package/dist/workstation/qoderAdapter/session.js +0 -319
  158. package/dist/workstation/qoderAdapter/subagentMeta.js +0 -28
  159. package/dist/workstation/qoderAdapter/subwork.js +0 -85
  160. package/dist/workstation/qoderAdapter/taskControl.js +0 -38
  161. package/dist/workstation/qoderAdapter/taskLedger.js +0 -163
  162. package/dist/workstation/qoderAdapter/usage.js +0 -37
  163. /package/dist/workstation/{qoderAdapter/types.js → desktopControl/provider.js} +0 -0
@@ -1,85 +0,0 @@
1
- const object = (v) => v && typeof v === 'object' && !Array.isArray(v) ? v : {};
2
- const id = (v) => typeof v === 'string' && v.length > 0 && v.length <= 256 && !/[\x00-\x1f\x7f]/.test(v);
3
- export function newSubworkData() {
4
- return { calls: {}, count: 0 };
5
- }
6
- export function supportsSubworkMeta(info) {
7
- return (info?.name === 'qoder-cli' && info.version === '1.1.61') ||
8
- (info?.name === 'axom-qoder-sdk' && info.version === '1.0.50');
9
- }
10
- function resultText(value) {
11
- if (typeof value === 'string')
12
- return value;
13
- if (Array.isArray(value)) {
14
- const texts = value.filter(v => object(v).type === 'text').map(v => object(v).text).filter(v => typeof v === 'string');
15
- return texts.length ? texts.join('\n') : undefined;
16
- }
17
- const v = object(value);
18
- if (v.kind === 'agent-result')
19
- return resultText(v.content ?? v.result);
20
- return undefined;
21
- }
22
- export class SubworkBoundary {
23
- root;
24
- data;
25
- constructor(root, data = newSubworkData()) {
26
- this.root = root;
27
- this.data = data;
28
- }
29
- get(toolId) { return Object.hasOwn(this.data.calls, toolId) ? this.data.calls[toolId] : undefined; }
30
- child(toolId) { return `qoder-agent:${this.root}:${toolId}`; }
31
- map(event) {
32
- if (event.acpSessionId && event.acpSessionId !== this.root)
33
- return [event];
34
- const p = event.payload, q = object(object(p._meta).qoder), input = object(p.rawInput);
35
- const marked = q.version === 1 && ['native-acp-patch', 'sdk', 'correction'].includes(String(q.source));
36
- const toolId = p.toolCallId;
37
- let call = id(toolId) ? this.get(toolId) : undefined;
38
- const parent = marked && q.route !== 'unknown' && id(q.parentToolUseId) ? q.parentToolUseId : undefined;
39
- const events = [];
40
- if (!call && marked && p.kind === 'think' && q.toolName === 'Agent' && id(toolId) &&
41
- typeof input.prompt === 'string' && (input.subagent_type == null || typeof input.subagent_type === 'string') &&
42
- (input.run_in_background === undefined || typeof input.run_in_background === 'boolean') &&
43
- ['tool_call', 'tool_call_update'].includes(event.eventName) && this.data.count < 4096) {
44
- call = { child: this.child(toolId), ...(parent ? { parent: this.child(parent) } : {}),
45
- background: input.run_in_background === true, ended: false, streamedText: '' };
46
- Object.defineProperty(this.data.calls, toolId, { value: call, enumerable: true, writable: true, configurable: true });
47
- this.data.count += 1;
48
- events.push({ eventName: 'subagent_spawned', payload: { subagentSessionId: call.child,
49
- name: typeof input.description === 'string' && input.description.trim() ? input.description : input.subagent_type ?? 'Agent',
50
- task: input.prompt, capabilities: {} }, ...(call.parent ? { acpSessionId: call.parent } : {}) });
51
- events.push({ eventName: 'user_message_chunk', payload: { content: { type: 'text', text: input.prompt } }, acpSessionId: call.child });
52
- }
53
- if (call && ['tool_call', 'tool_call_update'].includes(event.eventName)) {
54
- if (call.ended)
55
- return events;
56
- const output = object(p.rawOutput);
57
- const state = output.kind === 'agent-result' ? output.state : undefined;
58
- const terminal = state === 'completed' ? 'completed' : ['error', 'failed'].includes(String(state)) ? 'failed' :
59
- state === 'cancelled' ? 'cancelled' : ['failed', 'cancelled'].includes(String(p.status)) ? p.status :
60
- !call.background && p.status === 'completed' ? 'completed' : undefined;
61
- if (terminal) {
62
- const text = resultText(p.rawOutput);
63
- if (text !== undefined && !call.streamedText.endsWith(text))
64
- events.push({ eventName: 'agent_message_chunk',
65
- payload: { content: { type: 'text', text } }, acpSessionId: call.child });
66
- events.push({ eventName: 'subagent_state_update', payload: { subagentSessionId: call.child, state: terminal },
67
- ...(call.parent ? { acpSessionId: call.parent } : {}) });
68
- call.ended = true;
69
- // Read only by the check above, once: an ended call keeps no stream (checkpointed state).
70
- call.streamedText = '';
71
- }
72
- // The Agent invocation becomes a dispatch/result in subwork. Keeping the vendor tool here
73
- // would also create the old delegation card for the very same task.
74
- return events;
75
- }
76
- if (parent) {
77
- const owner = this.get(parent), content = object(p.content);
78
- if (owner && !owner.ended && event.eventName === 'agent_message_chunk' && content.type === 'text' && typeof content.text === 'string') {
79
- owner.streamedText += content.text;
80
- }
81
- return [{ ...event, acpSessionId: this.child(parent) }];
82
- }
83
- return [event];
84
- }
85
- }
@@ -1,38 +0,0 @@
1
- import { capabilitiesFor } from './profile.js';
2
- const validId = (value) => value.length > 0 && Buffer.byteLength(value, 'utf8') <= 256 &&
3
- !/[\x00-\x1f\x7f]/.test(value);
4
- export class TaskControl {
5
- ledger;
6
- profile;
7
- query;
8
- certifications;
9
- binding;
10
- requests = new Map();
11
- constructor(ledger, profile, query, certifications, binding) {
12
- this.ledger = ledger;
13
- this.profile = profile;
14
- this.query = query;
15
- this.certifications = certifications;
16
- this.binding = binding;
17
- }
18
- async stop(request) {
19
- if (![request.sessionId, request.taskId, request.requestId].every(validId))
20
- throw new Error('Invalid task stop identity');
21
- const previous = this.requests.get(request.requestId);
22
- if (previous) {
23
- if (previous.sessionId !== request.sessionId || previous.taskId !== request.taskId)
24
- throw new Error('Task stop request identity conflict');
25
- return previous.receipt;
26
- }
27
- const profile = this.profile(), task = this.ledger.get(request.taskId);
28
- if (!profile || !task || request.sessionId !== profile.rootSessionId ||
29
- !task.origin.agentId || !task.origin.launchingToolUseId || task.taskType !== 'local_agent' ||
30
- task.background !== true || !capabilitiesFor(profile, task, this.certifications, this.binding).stopActiveRun)
31
- throw new Error('Task stop unavailable');
32
- if (this.requests.size >= 4096)
33
- throw new Error('Task stop receipt capacity exceeded');
34
- const receipt = this.query.stopTask(request.taskId).then(() => ({ requestId: request.requestId, state: 'accepted' }), () => ({ requestId: request.requestId, state: 'unknown' }));
35
- this.requests.set(request.requestId, { sessionId: request.sessionId, taskId: request.taskId, receipt });
36
- return receipt;
37
- }
38
- }
@@ -1,163 +0,0 @@
1
- const identifier = (value) => typeof value === 'string' && value.length > 0 &&
2
- Buffer.byteLength(value, 'utf8') <= 256 && !/[\x00-\x1f\x7f]/.test(value);
3
- const terminal = (state) => state === 'completed' || state === 'failed' || state === 'stopped';
4
- const defaultMaxTasks = 4096;
5
- const sameTask = (a, b) => a.state === b.state && a.live === b.live && a.stale === b.stale && a.taskType === b.taskType &&
6
- a.background === b.background && JSON.stringify(a.origin) === JSON.stringify(b.origin);
7
- export class TaskLedger {
8
- rootSessionId;
9
- runtimeGeneration;
10
- maxTasks;
11
- tasks = new Map();
12
- seen = new Set();
13
- actors = new Map();
14
- launchTasks = new Map();
15
- conflicts = new Set();
16
- notified = new Set();
17
- failed = false;
18
- constructor(rootSessionId, runtimeGeneration, maxTasks = defaultMaxTasks) {
19
- this.rootSessionId = rootSessionId;
20
- this.runtimeGeneration = runtimeGeneration;
21
- this.maxTasks = maxTasks;
22
- if (!identifier(rootSessionId) || !identifier(runtimeGeneration))
23
- throw new Error('Invalid task ledger binding');
24
- if (!Number.isInteger(maxTasks) || maxTasks < 1 || maxTasks > defaultMaxTasks)
25
- throw new Error('Invalid task ledger capacity');
26
- }
27
- get(taskId) {
28
- const task = this.tasks.get(taskId);
29
- return task && { ...task, origin: { ...task.origin } };
30
- }
31
- all() { return [...this.tasks.keys()].map((id) => this.get(id)); }
32
- get launchObservationCount() { return this.actors.size; }
33
- get degraded() { return this.failed; }
34
- markStale() {
35
- for (const [id, task] of this.tasks)
36
- this.tasks.set(id, { ...task, live: false, stale: true });
37
- return this.all();
38
- }
39
- degrade() {
40
- this.failed = true;
41
- return this.markStale();
42
- }
43
- observeLaunch(toolUseId, agentId) {
44
- if (this.failed || !identifier(toolUseId) || !identifier(agentId))
45
- return [];
46
- const prior = this.actors.get(toolUseId);
47
- if (prior !== undefined && prior !== agentId)
48
- this.actors.set(toolUseId, null);
49
- else if (prior === undefined && this.actors.size < this.maxTasks)
50
- this.actors.set(toolUseId, agentId);
51
- const changed = [];
52
- for (const [id, task] of this.tasks) {
53
- if (task.origin.launchingToolUseId !== toolUseId)
54
- continue;
55
- const actor = this.actors.get(toolUseId);
56
- const next = { ...task, origin: { ...task.origin,
57
- agentId: this.conflicts.has(id) ? undefined : actor ?? undefined },
58
- stale: actor === null || this.conflicts.has(id) || task.stale };
59
- this.tasks.set(id, next);
60
- changed.push(next);
61
- }
62
- return changed;
63
- }
64
- ensure(taskId) {
65
- if (!identifier(taskId))
66
- return undefined;
67
- const existing = this.tasks.get(taskId);
68
- if (existing)
69
- return existing;
70
- if (this.tasks.size >= this.maxTasks) {
71
- this.degrade();
72
- return undefined;
73
- }
74
- const task = { origin: { rootSessionId: this.rootSessionId, runtimeGeneration: this.runtimeGeneration,
75
- taskId }, state: 'unknown', live: false, stale: false };
76
- this.tasks.set(taskId, task);
77
- return task;
78
- }
79
- apply(message) {
80
- if (this.failed || message.type !== 'system' || message.session_id !== this.rootSessionId ||
81
- !identifier(message.uuid) || this.seen.has(message.uuid))
82
- return [];
83
- if (this.seen.size >= this.maxTasks * 4)
84
- return this.degrade();
85
- if (message.subtype === 'background_tasks_changed' && message.tasks.length > this.maxTasks)
86
- return this.degrade();
87
- if (message.subtype === 'background_tasks_changed') {
88
- const added = new Set();
89
- for (const entry of message.tasks) {
90
- if (identifier(entry.task_id) && !this.tasks.has(entry.task_id))
91
- added.add(entry.task_id);
92
- if (this.tasks.size + added.size > this.maxTasks)
93
- return this.degrade();
94
- }
95
- }
96
- const previous = new Map(this.tasks);
97
- this.seen.add(message.uuid);
98
- if (message.subtype === 'background_tasks_changed') {
99
- const current = new Map(message.tasks.filter((entry) => identifier(entry.task_id))
100
- .map((entry) => [entry.task_id, entry]));
101
- for (const [id, task] of this.tasks) {
102
- if (!terminal(task.state) && task.background) {
103
- const next = { ...task, live: current.has(id),
104
- stale: current.has(id) ? this.conflicts.has(id) : task.stale };
105
- if (!sameTask(task, next))
106
- this.tasks.set(id, next);
107
- }
108
- }
109
- for (const [id, entry] of current) {
110
- const task = this.ensure(id);
111
- if (task && !terminal(task.state)) {
112
- const next = { ...task, state: 'running', live: true,
113
- stale: this.conflicts.has(id), taskType: entry.task_type, background: true };
114
- if (!sameTask(task, next))
115
- this.tasks.set(id, next);
116
- }
117
- }
118
- }
119
- else if (message.subtype === 'task_started' || message.subtype === 'task_progress') {
120
- const task = this.ensure(message.task_id);
121
- if (task && !terminal(task.state)) {
122
- const toolId = identifier(message.tool_use_id) ? message.tool_use_id : task.origin.launchingToolUseId;
123
- if (toolId && !this.launchTasks.has(toolId) && this.launchTasks.size < this.maxTasks)
124
- this.launchTasks.set(toolId, message.task_id);
125
- else if (toolId && this.launchTasks.get(toolId) !== message.task_id) {
126
- this.conflicts.add(message.task_id);
127
- const other = this.launchTasks.get(toolId);
128
- if (other) {
129
- this.conflicts.add(other);
130
- const previous = this.tasks.get(other);
131
- if (previous)
132
- this.tasks.set(other, { ...previous, stale: true,
133
- origin: { ...previous.origin, agentId: undefined } });
134
- }
135
- }
136
- const actor = toolId && this.actors.get(toolId);
137
- this.tasks.set(message.task_id, { ...task, state: 'running', stale: this.conflicts.has(message.task_id),
138
- taskType: 'task_type' in message ? message.task_type : task.taskType,
139
- origin: { ...task.origin, launchingToolUseId: toolId,
140
- agentId: this.conflicts.has(message.task_id) ? undefined : actor ?? task.origin.agentId } });
141
- }
142
- }
143
- else if (message.subtype === 'task_updated') {
144
- const task = this.ensure(message.task_id);
145
- if (task && !terminal(task.state)) {
146
- const status = message.patch.status;
147
- const state = status === 'killed' ? 'stopped' : status ?? task.state;
148
- this.tasks.set(message.task_id, { ...task, state, live: terminal(state) ? false : task.live,
149
- stale: this.conflicts.has(message.task_id), background: message.patch.is_backgrounded ?? task.background });
150
- }
151
- }
152
- else if (message.subtype === 'task_notification') {
153
- const task = this.ensure(message.task_id);
154
- if (task && (!this.notified.has(message.task_id) ||
155
- (task.state === 'stopped' && message.status === 'completed'))) {
156
- this.notified.add(message.task_id);
157
- this.tasks.set(message.task_id, { ...task, state: message.status,
158
- live: false, stale: this.conflicts.has(message.task_id) });
159
- }
160
- }
161
- return [...this.tasks].filter(([id, task]) => task !== previous.get(id)).map(([id]) => this.get(id));
162
- }
163
- }
@@ -1,37 +0,0 @@
1
- export const QODER_CREDITS_LABEL = 'Qoder Credits(厂商报告)';
2
- const validCredits = (value) => typeof value === 'number' &&
3
- Number.isFinite(value) && value >= 0;
4
- /** Qoder's report is cumulative. A missing/invalid report never erases a prior valid value. */
5
- export function applyCredits(previous, reported) {
6
- if (validCredits(reported))
7
- return reported;
8
- return validCredits(previous) ? previous : undefined;
9
- }
10
- function reportedCredits(value) {
11
- if (!value || typeof value !== 'object' || Array.isArray(value))
12
- return undefined;
13
- const input = value;
14
- for (const key of ['total_credits', 'totalCredits', 'credits'])
15
- if (validCredits(input[key]))
16
- return input[key];
17
- return undefined;
18
- }
19
- /**
20
- * Keeps vendor credits separate from ACP token/USD counters. Qoder's SDK does not
21
- * provide equivalent token or USD values, so zero placeholders are intentionally omitted.
22
- */
23
- export function normalizeQoderUsage(value, previousCredits) {
24
- const input = value && typeof value === 'object' && !Array.isArray(value)
25
- ? value : {};
26
- const scope = input.cumulativeScope === 'unknown' ? 'unknown' : 'session';
27
- const reported = reportedCredits(value);
28
- if (scope === 'unknown') {
29
- return { credits: undefined, creditsLabel: QODER_CREDITS_LABEL, creditsScope: scope,
30
- inputTokens: undefined, outputTokens: undefined, costUsd: undefined,
31
- ...(validCredits(previousCredits) ? { previousCredits } : {}) };
32
- }
33
- const credits = applyCredits(previousCredits, reported);
34
- return { credits, creditsLabel: QODER_CREDITS_LABEL, creditsScope: scope,
35
- inputTokens: undefined, outputTokens: undefined, costUsd: undefined,
36
- ...(validCredits(previousCredits) ? { previousCredits } : {}) };
37
- }