@koalaauto/agentchannel 3.30.2 → 3.31.0
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/dist/src/adapters/claude.d.ts +9 -1
- package/dist/src/adapters/claude.js +47 -11
- package/dist/src/adapters/codex.d.ts +1 -1
- package/dist/src/adapters/codex.js +3 -0
- package/dist/src/adapters/fake.d.ts +5 -0
- package/dist/src/adapters/fake.js +7 -3
- package/dist/src/adapters/kiro.d.ts +1 -1
- package/dist/src/adapters/kiro.js +2 -1
- package/dist/src/adapters/types.d.ts +9 -0
- package/dist/src/adapters/types.js +4 -1
- package/dist/src/cli.d.ts +8 -0
- package/dist/src/cli.js +13 -3
- package/dist/src/client.d.ts +8 -2
- package/dist/src/client.js +6 -4
- package/dist/src/runner/runner.js +5 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CanUseTool, HookCallbackMatcher, Options } from '@anthropic-ai/claude-agent-sdk';
|
|
2
2
|
import type { Perm } from '../perm.js';
|
|
3
3
|
import { type PathPolicy } from './paths.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type AdapterResult, type AdapterRunOptions, type RuntimeAdapter } from './types.js';
|
|
5
5
|
/** Best-effort Bash deny list for `workdir` (the SDK sandbox is the real boundary). */
|
|
6
6
|
export declare const BASH_DENY: RegExp[];
|
|
7
7
|
/** S3: the only `ach` subcommands a spawned agent is pre-approved to run. */
|
|
@@ -77,6 +77,14 @@ export declare function thinkingFor(model: string | undefined, env?: Record<stri
|
|
|
77
77
|
display: 'summarized';
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* The model a Claude run used: the one the CLI names in its init message, else the only one its result lists usage for. A run
|
|
82
|
+
* lists more than one when Claude Code does side work on a small model (titles, searches), which says nothing about the one
|
|
83
|
+
* that answered, so several without an init name stay unknown.
|
|
84
|
+
*/
|
|
85
|
+
export declare function modelOf(init: unknown, modelUsage?: unknown): string | undefined;
|
|
86
|
+
/** The effort a hook input says the turn ran at, after the CLI's own downgrades for the model (the init message does not carry it). */
|
|
87
|
+
export declare function effortOf(input: unknown): string | undefined;
|
|
80
88
|
export interface ClaudeAdapterOptions {
|
|
81
89
|
model?: string;
|
|
82
90
|
}
|
|
@@ -2,6 +2,7 @@ import { homedir } from 'node:os';
|
|
|
2
2
|
import { toolDenied } from './paths.js';
|
|
3
3
|
import { macTempPatterns, readable, systemPaths } from './scope.js';
|
|
4
4
|
import { spawnGroup } from './procgroup.js';
|
|
5
|
+
import { modelId } from './types.js';
|
|
5
6
|
/** Best-effort Bash deny list for `workdir` (the SDK sandbox is the real boundary). */
|
|
6
7
|
export const BASH_DENY = [
|
|
7
8
|
/\brm\s+-[a-z]*r[a-z]*f?[a-z]*\s+(\/|~|\$HOME)(\s|$)/i,
|
|
@@ -193,6 +194,24 @@ export function thinkingFor(model, env = {}) {
|
|
|
193
194
|
}
|
|
194
195
|
return { thinking: { type: 'adaptive', display: 'summarized' } };
|
|
195
196
|
}
|
|
197
|
+
const EFFORT_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
198
|
+
/**
|
|
199
|
+
* The model a Claude run used: the one the CLI names in its init message, else the only one its result lists usage for. A run
|
|
200
|
+
* lists more than one when Claude Code does side work on a small model (titles, searches), which says nothing about the one
|
|
201
|
+
* that answered, so several without an init name stay unknown.
|
|
202
|
+
*/
|
|
203
|
+
export function modelOf(init, modelUsage) {
|
|
204
|
+
const named = modelId(init);
|
|
205
|
+
if (named)
|
|
206
|
+
return named;
|
|
207
|
+
const used = modelUsage && typeof modelUsage === 'object' ? Object.keys(modelUsage) : [];
|
|
208
|
+
return used.length === 1 ? modelId(used[0]) : undefined;
|
|
209
|
+
}
|
|
210
|
+
/** The effort a hook input says the turn ran at, after the CLI's own downgrades for the model (the init message does not carry it). */
|
|
211
|
+
export function effortOf(input) {
|
|
212
|
+
const level = input?.effort?.level;
|
|
213
|
+
return typeof level === 'string' && EFFORT_LEVELS.includes(level) ? level : undefined;
|
|
214
|
+
}
|
|
196
215
|
export class ClaudeAdapter {
|
|
197
216
|
o;
|
|
198
217
|
name = 'claude';
|
|
@@ -223,6 +242,27 @@ export class ClaudeAdapter {
|
|
|
223
242
|
abortController.abort();
|
|
224
243
|
else
|
|
225
244
|
opts.signal.addEventListener('abort', onAbort, { once: true });
|
|
245
|
+
// what the run really used: the model comes from the init message below, the effort from a hook that only reads
|
|
246
|
+
let model;
|
|
247
|
+
let effort;
|
|
248
|
+
const effortHook = {
|
|
249
|
+
hooks: [
|
|
250
|
+
async (input) => {
|
|
251
|
+
effort = effortOf(input) ?? effort;
|
|
252
|
+
return {};
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
const permOptions = claudePermOptions(opts.perm, {
|
|
257
|
+
cwd: opts.cwd,
|
|
258
|
+
hub: opts.hub,
|
|
259
|
+
mode: opts.mode,
|
|
260
|
+
readRoots: opts.readRoots,
|
|
261
|
+
denyReadPaths: opts.denyReadPaths,
|
|
262
|
+
home: opts.realHome ?? opts.env.HOME,
|
|
263
|
+
tmpDir: opts.tmpDir,
|
|
264
|
+
netAllow: opts.netAllow,
|
|
265
|
+
});
|
|
226
266
|
const options = {
|
|
227
267
|
cwd: opts.cwd,
|
|
228
268
|
env: opts.env,
|
|
@@ -231,16 +271,9 @@ export class ClaudeAdapter {
|
|
|
231
271
|
...(this.o.model ? { model: this.o.model } : {}),
|
|
232
272
|
...(opts.maxBudgetUsd && opts.maxBudgetUsd > 0 ? { maxBudgetUsd: opts.maxBudgetUsd } : {}),
|
|
233
273
|
...(withThinking ? thinkingFor(this.o.model, opts.env) : {}),
|
|
234
|
-
...
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
mode: opts.mode,
|
|
238
|
-
readRoots: opts.readRoots,
|
|
239
|
-
denyReadPaths: opts.denyReadPaths,
|
|
240
|
-
home: opts.realHome ?? opts.env.HOME,
|
|
241
|
-
tmpDir: opts.tmpDir,
|
|
242
|
-
netAllow: opts.netAllow,
|
|
243
|
-
}),
|
|
274
|
+
...permOptions,
|
|
275
|
+
// after the policy's own hooks, never instead of them: the first tool call or the end of a turn tells what effort applied
|
|
276
|
+
hooks: { ...permOptions.hooks, PreToolUse: [...(permOptions.hooks?.PreToolUse ?? []), effortHook], Stop: [...(permOptions.hooks?.Stop ?? []), effortHook] },
|
|
244
277
|
spawnClaudeCodeProcess: (s) => spawnGroup(s.command, s.args, {
|
|
245
278
|
cwd: s.cwd,
|
|
246
279
|
env: s.env,
|
|
@@ -285,6 +318,7 @@ export class ClaudeAdapter {
|
|
|
285
318
|
}
|
|
286
319
|
else if (m.type === 'result') {
|
|
287
320
|
costUsd = anyM.total_cost_usd;
|
|
321
|
+
model = modelOf(model, anyM.modelUsage);
|
|
288
322
|
opts.onEvent({ type: 'usage', data: { costUsd, usage: anyM.usage } });
|
|
289
323
|
if (anyM.subtype === 'success' && !anyM.is_error) {
|
|
290
324
|
ok = true;
|
|
@@ -296,6 +330,8 @@ export class ClaudeAdapter {
|
|
|
296
330
|
}
|
|
297
331
|
}
|
|
298
332
|
else {
|
|
333
|
+
if (m.type === 'system' && anyM.subtype === 'init')
|
|
334
|
+
model = modelId(anyM.model) ?? model;
|
|
299
335
|
opts.onEvent({ type: 'tool', data: { type: m.type, subtype: anyM.subtype } });
|
|
300
336
|
}
|
|
301
337
|
}
|
|
@@ -310,6 +346,6 @@ export class ClaudeAdapter {
|
|
|
310
346
|
}
|
|
311
347
|
if (!finalText)
|
|
312
348
|
finalText = lastText.join('\n');
|
|
313
|
-
return { finalText, sessionId, costUsd, costCumulative: true, ok, error };
|
|
349
|
+
return { finalText, sessionId, costUsd, costCumulative: true, ok, error, ...(model ? { model } : {}), ...(effort ? { effort } : {}) };
|
|
314
350
|
}
|
|
315
351
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SandboxMode, ThreadOptions, Usage } from '@openai/codex-sdk';
|
|
2
2
|
import type { Perm } from '../perm.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type AdapterResult, type AdapterRunOptions, type RuntimeAdapter } from './types.js';
|
|
4
4
|
/** USD per 1M tokens. Configurable via ACH_CODEX_PRICE='{"input":..,"cached_input":..,"output":..}'. */
|
|
5
5
|
export interface PriceTable {
|
|
6
6
|
input: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { readable, systemPaths } from './scope.js';
|
|
3
3
|
import { KILL_GRACE_MS } from './procgroup.js';
|
|
4
|
+
import { modelId } from './types.js';
|
|
4
5
|
export const DEFAULT_CODEX_PRICE = { input: 1.25, cached_input: 0.125, output: 10 };
|
|
5
6
|
export function priceFromEnv(env = process.env) {
|
|
6
7
|
try {
|
|
@@ -328,6 +329,8 @@ export class CodexAdapter {
|
|
|
328
329
|
estimated: true,
|
|
329
330
|
ok: !error,
|
|
330
331
|
error,
|
|
332
|
+
// Codex does not say which model it used: only a model pinned with --model is known
|
|
333
|
+
...(modelId(this.o.model) ? { model: this.o.model } : {}),
|
|
331
334
|
};
|
|
332
335
|
}
|
|
333
336
|
}
|
|
@@ -58,6 +58,7 @@ export class FakeAdapter {
|
|
|
58
58
|
const ach = this.o.ach ?? spawnAch;
|
|
59
59
|
let text = '';
|
|
60
60
|
let cost;
|
|
61
|
+
let used = {};
|
|
61
62
|
try {
|
|
62
63
|
for (const step of this.o.script(info)) {
|
|
63
64
|
if (opts.signal.aborted)
|
|
@@ -85,6 +86,9 @@ export class FakeAdapter {
|
|
|
85
86
|
cost = step.cost;
|
|
86
87
|
opts.onEvent({ type: 'usage', data: { costUsd: cost } });
|
|
87
88
|
}
|
|
89
|
+
else if ('used' in step) {
|
|
90
|
+
used = step.used;
|
|
91
|
+
}
|
|
88
92
|
else if ('thinking' in step) {
|
|
89
93
|
opts.onEvent({ type: 'thinking', data: step.thinking });
|
|
90
94
|
}
|
|
@@ -101,7 +105,7 @@ export class FakeAdapter {
|
|
|
101
105
|
opts.onEvent({ type: 'tool_end', data: { id: step.toolEnd } });
|
|
102
106
|
}
|
|
103
107
|
else if ('fail' in step) {
|
|
104
|
-
return { finalText: text, sessionId, costUsd: cost, ok: false, error: step.fail };
|
|
108
|
+
return { finalText: text, sessionId, costUsd: cost, ...used, ok: false, error: step.fail };
|
|
105
109
|
}
|
|
106
110
|
else if ('throw' in step) {
|
|
107
111
|
throw new Error(step.throw);
|
|
@@ -109,8 +113,8 @@ export class FakeAdapter {
|
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
catch (e) {
|
|
112
|
-
return { finalText: text, sessionId, costUsd: cost, ok: false, error: opts.signal.aborted ? 'aborted' : String(e?.message ?? e) };
|
|
116
|
+
return { finalText: text, sessionId, costUsd: cost, ...used, ok: false, error: opts.signal.aborted ? 'aborted' : String(e?.message ?? e) };
|
|
113
117
|
}
|
|
114
|
-
return { finalText: text, sessionId, costUsd: cost, ok: true };
|
|
118
|
+
return { finalText: text, sessionId, costUsd: cost, ...used, ok: true };
|
|
115
119
|
}
|
|
116
120
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AdapterEvent, type AdapterResult, type AdapterRunOptions, type RuntimeAdapter } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Kiro runtime: each run is a Kiro cloud session started headlessly with
|
|
4
4
|
* `kiro-cli chat --v3 --no-interactive --cloud --repo <owner/name> "<prompt>"` (KIRO_API_KEY).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { spawnGroup } from './procgroup.js';
|
|
3
|
+
import { modelId } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Kiro runtime: each run is a Kiro cloud session started headlessly with
|
|
5
6
|
* `kiro-cli chat --v3 --no-interactive --cloud --repo <owner/name> "<prompt>"` (KIRO_API_KEY).
|
|
@@ -288,7 +289,7 @@ export class KiroAdapter {
|
|
|
288
289
|
const ok = !err && code === 0 && !opts.signal.aborted;
|
|
289
290
|
const error = ok ? undefined : opts.signal.aborted ? 'aborted' : err ?? (stripAnsi(stderr).trim().split('\n').slice(-3).join(' ') || `kiro-cli exited ${code}`);
|
|
290
291
|
// Kiro bills credits, not dollars, and the CLI does not print them (2.37.1): the cost stays unknown, never guessed.
|
|
291
|
-
resolve({ result: { finalText, sessionId: out.sessionId, ok, error, estimated: true }, progressed });
|
|
292
|
+
resolve({ result: { finalText, sessionId: out.sessionId, ok, error, estimated: true, ...(modelId(this.o.model) ? { model: this.o.model } : {}) }, progressed });
|
|
292
293
|
};
|
|
293
294
|
child.on('error', (e) => finish(null, e?.code === 'ENOENT' ? `kiro-cli not found (${bin}): install it (curl -fsSL https://cli.kiro.dev/install | bash) or set ACH_KIRO_BIN` : String(e?.message ?? e)));
|
|
294
295
|
child.on('close', (code) => finish(code));
|
|
@@ -10,6 +10,8 @@ export interface AdapterEvent {
|
|
|
10
10
|
data: any;
|
|
11
11
|
}
|
|
12
12
|
export type RunMode = 'work' | 'answer' | 'mention';
|
|
13
|
+
/** A model id as the hub stores and the panel shows it: a plain token, nothing a tool could put a sentence into. */
|
|
14
|
+
export declare function modelId(v: unknown): string | undefined;
|
|
13
15
|
export interface AdapterRunOptions {
|
|
14
16
|
prompt: string;
|
|
15
17
|
cwd: string;
|
|
@@ -51,6 +53,13 @@ export interface AdapterResult {
|
|
|
51
53
|
costCumulative?: boolean;
|
|
52
54
|
/** True when cost is estimated from tokens (codex). */
|
|
53
55
|
estimated?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* What the run really used, as the tool reported it (not what anyone configured): the model's id (claude: the one the CLI named
|
|
58
|
+
* when it started, e.g. claude-opus-5-5) and the reasoning effort it applied after its own downgrades. Left out when unknown:
|
|
59
|
+
* codex and kiro only say what `--model` pinned.
|
|
60
|
+
*/
|
|
61
|
+
model?: string;
|
|
62
|
+
effort?: string;
|
|
54
63
|
ok: boolean;
|
|
55
64
|
error?: string;
|
|
56
65
|
}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -41,6 +41,14 @@ export declare function main(argv: string[], io?: Io): Promise<number>;
|
|
|
41
41
|
* with npx or `node dist/src/cli.js`). Returns the dir to prepend to PATH.
|
|
42
42
|
*/
|
|
43
43
|
export declare function writeAchShim(home: string): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* `ach run` where the agent's key is not stored: the key lives only on its own machine and the hub keeps a hash of it, so it
|
|
46
|
+
* cannot be read back. The way back is a new key (the panel: the agent's page, Settings or the stopped-runner card) and its join line.
|
|
47
|
+
*/
|
|
48
|
+
export declare const NO_KEY_MESSAGE: {
|
|
49
|
+
readonly en: "ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent's project directory.";
|
|
50
|
+
readonly zh: "ach run:这台机器上没有这个智能体的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开这个智能体,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。";
|
|
51
|
+
};
|
|
44
52
|
/** B7: `ach run` exit code when the hub answers 401 (systemd: RestartPreventExitStatus=78). */
|
|
45
53
|
export declare const AUTH_EXIT_CODE = 78;
|
|
46
54
|
export declare const AUTH_EXIT_MESSAGE = "ach run: key rotated or agent deactivated \u2014 run ach join";
|
package/dist/src/cli.js
CHANGED
|
@@ -1566,8 +1566,10 @@ async function runCommand(p, io) {
|
|
|
1566
1566
|
if (env.ACH_RUN_TOKEN)
|
|
1567
1567
|
throw new UsageError('run: refusing to start a runner inside a spawned agent (ACH_RUN_TOKEN is set)');
|
|
1568
1568
|
const cfg = loadConfig(env);
|
|
1569
|
+
// No key on this machine (deleted, a new machine or directory). It exits like a refused key: a service that exits 2 here
|
|
1570
|
+
// would be restarted for ever, and `ach login` is no way back for someone who no longer has the key.
|
|
1569
1571
|
if (!cfg.key)
|
|
1570
|
-
|
|
1572
|
+
return authExit(io, NO_KEY_MESSAGE[isZh(env) ? 'zh' : 'en']);
|
|
1571
1573
|
// the hub names the newest release on every answer: the updater hears it at once instead of at its next 6-hourly check
|
|
1572
1574
|
let updater;
|
|
1573
1575
|
const c = clientFromConfig(cfg, { fetch: io.fetch, role: 'runner', onLatestClient: (latest) => void updater?.heardLatest(latest)?.catch(() => { }) });
|
|
@@ -1737,9 +1739,17 @@ async function runCommand(p, io) {
|
|
|
1737
1739
|
}
|
|
1738
1740
|
return 0;
|
|
1739
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* `ach run` where the agent's key is not stored: the key lives only on its own machine and the hub keeps a hash of it, so it
|
|
1744
|
+
* cannot be read back. The way back is a new key (the panel: the agent's page, Settings or the stopped-runner card) and its join line.
|
|
1745
|
+
*/
|
|
1746
|
+
export const NO_KEY_MESSAGE = {
|
|
1747
|
+
en: 'ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent\'s project directory.',
|
|
1748
|
+
zh: 'ach run:这台机器上没有这个智能体的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开这个智能体,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。',
|
|
1749
|
+
};
|
|
1740
1750
|
/** B7: print the rejoin hint and return the auth exit code (ACH_AUTH_EXIT_CODE overrides it). */
|
|
1741
|
-
function authExit(io) {
|
|
1742
|
-
io.err(
|
|
1751
|
+
function authExit(io, message = AUTH_EXIT_MESSAGE) {
|
|
1752
|
+
io.err(message);
|
|
1743
1753
|
const code = Number(io.env.ACH_AUTH_EXIT_CODE ?? AUTH_EXIT_CODE);
|
|
1744
1754
|
return Number.isInteger(code) && code >= 0 ? code : AUTH_EXIT_CODE;
|
|
1745
1755
|
}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { type Attachment, type StorageConfig, type TaskFile } from './attachment
|
|
|
3
3
|
export type TaskStatus = 'submitted' | 'working' | 'input-required' | 'awaiting_acceptance' | 'completed' | 'failed' | 'canceled';
|
|
4
4
|
export declare const TERMINAL: readonly TaskStatus[];
|
|
5
5
|
export declare function isTerminal(s: string | undefined): boolean;
|
|
6
|
+
/** What a run really ran with, as its tool reported it (see AdapterResult.model). */
|
|
7
|
+
export interface RunUsed {
|
|
8
|
+
model?: string;
|
|
9
|
+
effort?: string;
|
|
10
|
+
}
|
|
6
11
|
export type MessageKind = 'question' | 'answer' | 'decision_request' | 'decision' | 'progress' | 'result' | 'note';
|
|
7
12
|
export interface Agent {
|
|
8
13
|
id: string;
|
|
@@ -411,7 +416,8 @@ export declare class Client {
|
|
|
411
416
|
cancel(taskId: string, reason: string): Promise<any>;
|
|
412
417
|
/** The total size of a work prompt (Memory trial metrics). */
|
|
413
418
|
promptSize(taskId: string, run_id: string, chars: number, parts?: Record<string, number>): Promise<any>;
|
|
414
|
-
|
|
419
|
+
/** `used`: the model and the effort the run really ran with, when the tool said (the panel shows them on the run). */
|
|
420
|
+
usage(taskId: string, run_id: string, cost_usd: number, estimated: boolean, used?: RunUsed): Promise<any>;
|
|
415
421
|
/**
|
|
416
422
|
* design §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
|
|
417
423
|
* "needs setup" with the fix.
|
|
@@ -486,7 +492,7 @@ export declare class Client {
|
|
|
486
492
|
/** Take an @mention: a read-only "mention" run token for its thread. */
|
|
487
493
|
mentionRun(mentionId: string, run_id: string): Promise<MentionRun>;
|
|
488
494
|
mentionEnd(mentionId: string, run_id: string): Promise<any>;
|
|
489
|
-
mentionUsage(mentionId: string, run_id: string, cost_usd: number, estimated: boolean): Promise<any>;
|
|
495
|
+
mentionUsage(mentionId: string, run_id: string, cost_usd: number, estimated: boolean, used?: RunUsed): Promise<any>;
|
|
490
496
|
agentProfile(name: string): Promise<any>;
|
|
491
497
|
/** `ach remember`: a fact or lesson with its source (hub permalink or GitHub URL); toTeam promotes it to the team overview. */
|
|
492
498
|
remember(text: string, source: string, o?: {
|
package/dist/src/client.js
CHANGED
|
@@ -7,6 +7,7 @@ export const TERMINAL = ['completed', 'failed', 'canceled'];
|
|
|
7
7
|
export function isTerminal(s) {
|
|
8
8
|
return !!s && TERMINAL.includes(s);
|
|
9
9
|
}
|
|
10
|
+
const usedBody = (u) => ({ ...(u?.model ? { model: u.model } : {}), ...(u?.effort ? { effort: u.effort } : {}) });
|
|
10
11
|
/** Parse `name` or `name@base` (CLI `--read-repo`). */
|
|
11
12
|
export function parseLinkRepo(v) {
|
|
12
13
|
const i = v.indexOf('@');
|
|
@@ -349,8 +350,9 @@ export class Client {
|
|
|
349
350
|
async promptSize(taskId, run_id, chars, parts = {}) {
|
|
350
351
|
return this.ach('POST', '/memory/prompt-size', { task: taskId, run_id, chars, parts });
|
|
351
352
|
}
|
|
352
|
-
|
|
353
|
-
|
|
353
|
+
/** `used`: the model and the effort the run really ran with, when the tool said (the panel shows them on the run). */
|
|
354
|
+
async usage(taskId, run_id, cost_usd, estimated, used) {
|
|
355
|
+
return this.ach('POST', `/tasks/${enc(taskId)}/usage`, { run_id, cost_usd, estimated, ...usedBody(used) });
|
|
354
356
|
}
|
|
355
357
|
/**
|
|
356
358
|
* design §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
|
|
@@ -452,8 +454,8 @@ export class Client {
|
|
|
452
454
|
async mentionEnd(mentionId, run_id) {
|
|
453
455
|
return this.ach('POST', `/mentions/${enc(mentionId)}/end`, { run_id });
|
|
454
456
|
}
|
|
455
|
-
async mentionUsage(mentionId, run_id, cost_usd, estimated) {
|
|
456
|
-
return this.ach('POST', `/mentions/${enc(mentionId)}/usage`, { run_id, cost_usd, estimated });
|
|
457
|
+
async mentionUsage(mentionId, run_id, cost_usd, estimated, used) {
|
|
458
|
+
return this.ach('POST', `/mentions/${enc(mentionId)}/usage`, { run_id, cost_usd, estimated, ...usedBody(used) });
|
|
457
459
|
}
|
|
458
460
|
async agentProfile(name) {
|
|
459
461
|
return this.ach('GET', `/profiles/agents/${enc(name)}`);
|
|
@@ -1112,7 +1112,7 @@ export class Runner {
|
|
|
1112
1112
|
});
|
|
1113
1113
|
const result = await this.execute(rec, entry, prompt, undefined, 'mention', structured ? ANSWER_SCHEMA : undefined, {
|
|
1114
1114
|
threadId,
|
|
1115
|
-
usage: (cost, est) => client.mentionUsage(mid, runId, cost, est),
|
|
1115
|
+
usage: (cost, est, used) => client.mentionUsage(mid, runId, cost, est, used),
|
|
1116
1116
|
});
|
|
1117
1117
|
if (structured && result.ok && !entry.reason)
|
|
1118
1118
|
await this.postStructuredReply(threadId, run.run_token, result.finalText, key);
|
|
@@ -1366,10 +1366,11 @@ export class Runner {
|
|
|
1366
1366
|
this.state.setSession(taskId, mode, { id: result.sessionId, cwd: rec.workdir, ...(result.costCumulative && result.costUsd !== undefined ? { costTotal: Number(result.costUsd) } : {}) });
|
|
1367
1367
|
}
|
|
1368
1368
|
// §14.7: usage after every adapter run, success or failure.
|
|
1369
|
-
|
|
1369
|
+
// with the model and the effort the run really ran with: the panel shows them on the run, so nobody has to guess
|
|
1370
|
+
const usage = extra.usage ?? ((cost, est, used) => client.usage(taskId, rec.runId, cost, est, used));
|
|
1370
1371
|
if (!this.fatal)
|
|
1371
|
-
await usage(runCost, !!result.estimated).catch((e) => this.log(`usage ${taskId}: ${e?.message ?? e}`));
|
|
1372
|
-
this.taskLog(taskId, `${mode} run end ok=${result.ok} cost=${result.costUsd ?? 0} err=${result.error ?? ''}`);
|
|
1372
|
+
await usage(runCost, !!result.estimated, { model: result.model, effort: result.effort }).catch((e) => this.log(`usage ${taskId}: ${e?.message ?? e}`));
|
|
1373
|
+
this.taskLog(taskId, `${mode} run end ok=${result.ok} cost=${result.costUsd ?? 0} model=${result.model ?? '?'} effort=${result.effort ?? '?'} err=${result.error ?? ''}`);
|
|
1373
1374
|
if (mode !== 'mention')
|
|
1374
1375
|
await this.uploadTrace(taskId, rec.runId, mode, startedAt, result, recorder, !this.fatal);
|
|
1375
1376
|
return result;
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.31.0",
|
|
4
4
|
"description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentchannel",
|