@parcha/agentrun-client 0.1.0-beta.48 → 0.1.0-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -108,6 +108,18 @@ checkout; these new exports are not a guarantee about the current npm release.
108
108
  | Claude Agent SDK `query` and custom tools | [Preserve the native query, add checked learning](../../docs/tutorials/claude-sdk-learning.md) |
109
109
  | Codex SDK client, project and tools | [Preserve native threads, add checked learning](../../docs/tutorials/codex-sdk-learning.md) |
110
110
 
111
+ For OpenClaw, Capy or another platform that executes its own agents, use `BackendLearningClient` from
112
+ `@parcha/agentrun-client/learning` with `{runtime: "external", platform, input, instructions}`. The required platform
113
+ label is 1–80 Unicode characters without surrounding whitespace, controls or unpaired surrogates. These sources
114
+ report runs and receive owner corrections; they cannot supply a workflow bridge. See [external platform reporting](../../docs/tutorials/platform-sdk-runs.md).
115
+ `BackendLearningSource` accepts either the existing, extensible `BackendLearningStart` interface or an `ExternalLearningStart`.
116
+
117
+ The generated `StartSdkRunBody` type is now a union: external starts require `platform` and exclude workflow fields.
118
+ If your code extends this generated type with an interface, use a type intersection such as
119
+ `type JobStart = StartSdkRunBody & { jobId: string }` instead. To refer to SDK workflow fields, first select
120
+ `Extract<StartSdkRunBody, { runtime: "claude-agent-sdk" | "codex-sdk" | "eve" }>` or narrow a value by its `runtime`.
121
+ The higher-level `BackendLearningStart` remains an interface that applications can extend.
122
+
111
123
  Your backend still starts and cancels tasks. The wrapper records original source policy/input, assistant text,
112
124
  tool names/status and usage. With an explicit workflow bridge, bounded arguments/results for its registered tools also supply compilation evidence; other raw tool payloads and SDK credentials are not sent. AgentRun supplies the
113
125
  owner's corrections (`corrections.md`, whole) to the next fresh task, and compiles a workflow once the agent has
@@ -1,5 +1,15 @@
1
1
  import { AgentRun, type ClientOptions } from './client.js';
2
- export type BackendSdkRuntime = 'claude-agent-sdk' | 'codex-sdk' | 'eve';
2
+ /** Where a backend run comes from. External platforms report execution through these calls; their display label
3
+ * never selects a managed runtime or grants workflow capabilities. */
4
+ export declare const BACKEND_SDK_RUNTIMES: readonly ["claude-agent-sdk", "codex-sdk", "eve", "external"];
5
+ export type BackendSdkRuntime = (typeof BACKEND_SDK_RUNTIMES)[number];
6
+ export type BackendSdkBinding = {
7
+ runtime: Exclude<BackendSdkRuntime, 'external'>;
8
+ platform?: never;
9
+ } | {
10
+ runtime: 'external';
11
+ platform: string;
12
+ };
3
13
  export interface BackendWorkflowToolManifest {
4
14
  name: string;
5
15
  description: string;
@@ -80,7 +90,7 @@ type SdkReceipt = Awaited<ReturnType<AgentRun['sdkRuns']['start']>>;
80
90
  export interface BackendLearningCheckpoint {
81
91
  baseUrl: string;
82
92
  agentId: string;
83
- source: BackendLearningStart;
93
+ source: BackendLearningSource;
84
94
  receipt: SdkReceipt;
85
95
  /** A completed shadow result is replayed verbatim after transport ambiguity; it never reruns a host callback. */
86
96
  shadow?: {
@@ -108,12 +118,19 @@ export interface BackendLearningSubmitOptions {
108
118
  /** Persist the private updated receipt before the first shadow-result upload. */
109
119
  onCheckpoint?(checkpoint: BackendLearningCheckpoint): void | Promise<void>;
110
120
  }
121
+ /** The existing SDK start remains an interface so applications can extend it with their own task fields. */
111
122
  export interface BackendLearningStart {
112
- runtime: BackendSdkRuntime;
123
+ runtime: Exclude<BackendSdkRuntime, 'external'>;
124
+ platform?: never;
113
125
  input: string;
114
126
  instructions: string;
115
127
  model?: string;
116
128
  }
129
+ export interface ExternalLearningStart extends Omit<BackendLearningStart, 'runtime' | 'platform'> {
130
+ runtime: 'external';
131
+ platform: string;
132
+ }
133
+ export type BackendLearningSource = BackendLearningStart | ExternalLearningStart;
117
134
  export type SdkLearningEvent = {
118
135
  type: 'text';
119
136
  text: string;
@@ -202,7 +219,7 @@ export declare class BackendLearningError extends Error {
202
219
  export declare class BackendLearningClient {
203
220
  #private;
204
221
  constructor(config: BackendLearningConfig);
205
- begin(source: BackendLearningStart, signal?: AbortSignal, options?: BackendLearningBeginOptions): Promise<BackendLearningSession>;
222
+ begin(source: BackendLearningSource, signal?: AbortSignal, options?: BackendLearningBeginOptions): Promise<BackendLearningSession>;
206
223
  /** Restore a persisted receipt without registering or admitting a second native turn. */
207
224
  resume(checkpoint: BackendLearningCheckpoint): BackendLearningSession;
208
225
  /** Observe completion immediately; the original SDK call can return without waiting for the run's learning. */
package/dist/learning.js CHANGED
@@ -2,6 +2,11 @@
2
2
  // policy, task and selected execution evidence to AgentRun; reflection and checked learning run on the server.
3
3
  import { AgentRun } from './client.js';
4
4
  import { AgentRunRefused, AgentRunTimeout, AgentRunUsage } from './errors.js';
5
+ /** Where a backend run comes from. External platforms report execution through these calls; their display label
6
+ * never selects a managed runtime or grants workflow capabilities. */
7
+ export const BACKEND_SDK_RUNTIMES = ['claude-agent-sdk', 'codex-sdk', 'eve', 'external'];
8
+ /** Only these SDK integrations support an explicit host workflow bridge. */
9
+ const WORKFLOW_RUNTIMES = ['claude-agent-sdk', 'codex-sdk', 'eve'];
5
10
  /** A persistence or learning failure, separate from the application's original SDK result or error. */
6
11
  export class BackendLearningError extends Error {
7
12
  runId;
@@ -21,6 +26,20 @@ const duration = (value, fallback, name) => {
21
26
  };
22
27
  const clone = (value) => JSON.parse(JSON.stringify(value));
23
28
  const size = (text) => new TextEncoder().encode(text).byteLength;
29
+ const bindingOf = (source) => {
30
+ if (!BACKEND_SDK_RUNTIMES.includes(source.runtime))
31
+ throw new AgentRunUsage('Unsupported backend SDK runtime.');
32
+ if (source.runtime === 'external') {
33
+ const { platform } = source;
34
+ if (typeof platform !== 'string' || !platform || platform.trim() !== platform || [...platform].length > 80 || /[\u0000-\u001f\u007f-\u009f\ud800-\udfff]/u.test(platform))
35
+ throw new AgentRunUsage('An external platform must be 1–80 Unicode characters without surrounding whitespace, control characters or unpaired surrogates.');
36
+ return { runtime: 'external', platform };
37
+ }
38
+ if (source.platform !== undefined)
39
+ throw new AgentRunUsage('A platform label is only allowed for the external runtime.');
40
+ return { runtime: source.runtime };
41
+ };
42
+ const sameBinding = (left, right) => left.runtime === right.runtime && left.platform === right.platform;
24
43
  const statusOf = (value, runId) => {
25
44
  const row = value;
26
45
  if (!row || row.run_id !== runId || !['running', 'processing', 'completed', 'failed', 'cancelled'].includes(row.state ?? '')) {
@@ -77,7 +96,7 @@ export class BackendLearningClient {
77
96
  #pending = new Set();
78
97
  #errors = [];
79
98
  #registration;
80
- #runtime;
99
+ #binding;
81
100
  constructor(config) {
82
101
  if (typeof config.agentId !== 'string' || !config.agentId.trim())
83
102
  throw new AgentRunUsage('agentId must be a stable, nonempty agent id.');
@@ -90,15 +109,16 @@ export class BackendLearningClient {
90
109
  if (options.idempotencyKey !== undefined && (!options.idempotencyKey.trim() || options.idempotencyKey.length > 256 || /[^\x21-\x7e]/.test(options.idempotencyKey)))
91
110
  throw new AgentRunUsage('idempotencyKey must be a nonempty printable ASCII string of at most 256 characters.');
92
111
  signal?.throwIfAborted();
93
- if (source.runtime !== 'claude-agent-sdk' && source.runtime !== 'codex-sdk' && source.runtime !== 'eve')
94
- throw new AgentRunUsage('Unsupported backend SDK runtime.');
112
+ const binding = bindingOf(source);
113
+ if (this.#config.workflows && !WORKFLOW_RUNTIMES.includes(binding.runtime))
114
+ throw new AgentRunUsage('External runs cannot use a workflow bridge; report their execution from the platform.');
95
115
  if (typeof source.input !== 'string' || typeof source.instructions !== 'string')
96
116
  throw new AgentRunUsage('SDK input and source instructions must be strings.');
97
117
  // Freeze the source before the registration request: caller mutation cannot change the policy after validation.
98
118
  const start = clone({ ...source, ...(this.#config.workflows ? { workflow_tools: [...this.#config.workflows.catalog], workflow_adapters: [...this.#config.workflows.adapters] } : {}) });
99
- if (this.#runtime !== undefined && this.#runtime !== start.runtime)
100
- throw new AgentRunUsage('A backend learning client belongs to one SDK runtime.');
101
- this.#runtime = start.runtime;
119
+ if (this.#binding !== undefined && !sameBinding(this.#binding, binding))
120
+ throw new AgentRunUsage('A backend learning client belongs to one runtime and platform.');
121
+ this.#binding = binding;
102
122
  this.#registration ??= this.#register(start).catch(error => { this.#registration = undefined; throw error; });
103
123
  await waitFor(this.#registration, signal);
104
124
  signal?.throwIfAborted();
@@ -134,11 +154,14 @@ export class BackendLearningClient {
134
154
  const saved = clone(checkpoint), { receipt, source } = saved;
135
155
  if (saved.baseUrl !== this.#owner.baseUrl || saved.agentId !== this.#config.agentId || receipt?.agent_id !== saved.agentId ||
136
156
  typeof receipt.run_id !== 'string' || !receipt.run_id || typeof receipt.token !== 'string' || !receipt.token || !receipt.learning ||
137
- !source || !['claude-agent-sdk', 'codex-sdk', 'eve'].includes(source.runtime) || typeof source.input !== 'string' || typeof source.instructions !== 'string')
157
+ !source || typeof source.input !== 'string' || typeof source.instructions !== 'string')
138
158
  throw new AgentRunUsage('The SDK receipt belongs to another server or agent, or has no original source.');
139
- if (this.#runtime !== undefined && this.#runtime !== source.runtime)
140
- throw new AgentRunUsage('A backend learning client belongs to one SDK runtime.');
141
- this.#runtime = source.runtime;
159
+ const binding = bindingOf(source);
160
+ if (this.#config.workflows && !WORKFLOW_RUNTIMES.includes(binding.runtime))
161
+ throw new AgentRunUsage('External runs cannot use a workflow bridge; report their execution from the platform.');
162
+ if (this.#binding !== undefined && !sameBinding(this.#binding, binding))
163
+ throw new AgentRunUsage('A backend learning client belongs to one runtime and platform.');
164
+ this.#binding = binding;
142
165
  const scoped = new AgentRun({ baseUrl: saved.baseUrl, apiKey: receipt.token,
143
166
  fetch: this.#config.fetch, timeoutMs: this.#config.timeoutMs, maxRetries: this.#config.maxRetries });
144
167
  const session = new BackendLearningSession(scoped, {
@@ -167,7 +190,7 @@ export class BackendLearningClient {
167
190
  const on = learning === true || (typeof learning === 'object' && learning !== null);
168
191
  const definition = {
169
192
  id: agentId, name: this.#config.name ?? agentId, instructions: source.instructions,
170
- sdk: { runtime: source.runtime }, learning: on ? (learning === true ? true : { ...learning, agree_on: learning.agree_on ? [...learning.agree_on] : undefined }) : false,
193
+ sdk: bindingOf(source), learning: on ? (learning === true ? true : { ...learning, agree_on: learning.agree_on ? [...learning.agree_on] : undefined }) : false,
171
194
  };
172
195
  try {
173
196
  await this.#owner.agents.create({ definition }, { 'Idempotency-Key': uuid() });
@@ -179,8 +202,9 @@ export class BackendLearningClient {
179
202
  }
180
203
  agent = (await read()).body;
181
204
  }
182
- if (agent.definition.sdk?.runtime !== source.runtime)
183
- throw new AgentRunUsage('The existing agent uses a different runtime; choose its matching SDK wrapper or a new agentId.');
205
+ const sdk = agent.definition.sdk;
206
+ if (!sdk || sdk.runtime !== source.runtime || (sdk.runtime === 'external' ? sdk.platform : undefined) !== source.platform)
207
+ throw new AgentRunUsage('The existing agent uses a different runtime or platform; choose its matching source or a new agentId.');
184
208
  }
185
209
  /** Observe completion immediately; the original SDK call can return without waiting for the run's learning. */
186
210
  track(promise) {
@@ -119,6 +119,9 @@ export type DefinitionInput = {
119
119
  max_cost_usd?: number;
120
120
  sdk?: {
121
121
  runtime: "claude-agent-sdk" | "codex-sdk" | "eve";
122
+ } | {
123
+ runtime: "external";
124
+ platform: string;
122
125
  };
123
126
  native?: {
124
127
  runtime: "claude-code" | "codex";
@@ -204,6 +207,9 @@ export type DefinitionInput = {
204
207
  provider?: "auto" | "native" | "exa-keyless" | "parallel" | "off";
205
208
  permission?: "allow" | "ask" | "deny";
206
209
  };
210
+ web_save?: {
211
+ permission?: "allow" | "ask" | "deny";
212
+ };
207
213
  email_search?: {
208
214
  permission?: "allow" | "ask" | "deny";
209
215
  scope?: "thread" | "mailbox";
@@ -267,6 +273,8 @@ export type DefinitionInput = {
267
273
  hold_window?: number;
268
274
  hold_disagree?: number;
269
275
  stop_window?: number;
276
+ repick?: boolean;
277
+ repick_max_chars?: number;
270
278
  };
271
279
  checkout?: "pull_request" | "none";
272
280
  };
@@ -342,6 +350,19 @@ export type RunSummary = {
342
350
  cache_write_tokens?: number | null;
343
351
  cost_usd?: number | null;
344
352
  } | null;
353
+ } | {
354
+ runtime: "external";
355
+ platform: string;
356
+ model: string | null;
357
+ session_id: string | null;
358
+ learning_revision: string | null;
359
+ usage: {
360
+ input_tokens?: number | null;
361
+ output_tokens?: number | null;
362
+ cache_read_tokens?: number | null;
363
+ cache_write_tokens?: number | null;
364
+ cost_usd?: number | null;
365
+ } | null;
345
366
  };
346
367
  native?: {
347
368
  runtime: string;
@@ -599,6 +620,19 @@ export type Run = {
599
620
  cache_write_tokens?: number | null;
600
621
  cost_usd?: number | null;
601
622
  } | null;
623
+ } | {
624
+ runtime: "external";
625
+ platform: string;
626
+ model: string | null;
627
+ session_id: string | null;
628
+ learning_revision: string | null;
629
+ usage: {
630
+ input_tokens?: number | null;
631
+ output_tokens?: number | null;
632
+ cache_read_tokens?: number | null;
633
+ cache_write_tokens?: number | null;
634
+ cost_usd?: number | null;
635
+ } | null;
602
636
  };
603
637
  native?: {
604
638
  runtime: string;
@@ -1249,7 +1283,7 @@ export interface CreateAgentParams {
1249
1283
  "Idempotency-Key"?: string;
1250
1284
  }
1251
1285
  export type CreateAgentResponse = Agent;
1252
- /** Delete an agent another system owns (DELETE /agents/{agent_id}). */
1286
+ /** Delete an agent another system owns, or purge an archived agent made here (DELETE /agents/{agent_id}). */
1253
1287
  /** Remove an agent's own Archil disk, and everything on it (DELETE /agents/{agent_id}/archil). */
1254
1288
  export type DeleteAgentArchilResponse = {
1255
1289
  on: boolean;
@@ -3227,6 +3261,7 @@ export type CreateRunComputerViewerResponse = {
3227
3261
  url: string;
3228
3262
  expires_at: string;
3229
3263
  };
3264
+ /** Purge a run's content and keep its cost (DELETE /runs/{run_id}). */
3230
3265
  /** The files the run wrote (GET /runs/{run_id}/files). */
3231
3266
  export type ListRunFilesResponse = RunFileList;
3232
3267
  /** One run (GET /runs/{run_id}). */
@@ -3502,6 +3537,77 @@ export type GetRunTraceResponse = {
3502
3537
  };
3503
3538
  /** Show the archived run in the lists again (POST /runs/{run_id}/unarchive). */
3504
3539
  export type UnarchiveRunResponse = Record<string, unknown>;
3540
+ /** What a run cost, by model, by who charged for its tools, and by browser provider (GET /runs/{run_id}/usage). */
3541
+ export type GetRunUsageResponse = {
3542
+ run_id: Id;
3543
+ ended_at: string | null;
3544
+ currency: "USD";
3545
+ total: {
3546
+ usd: number | null;
3547
+ so_far_usd?: number;
3548
+ unpriced?: number;
3549
+ upper_bound?: true;
3550
+ } | null;
3551
+ lines: Array<{
3552
+ meter: "tokens" | "tools" | "browser_time" | "compute_time";
3553
+ model: string | null;
3554
+ provider: string | null;
3555
+ charged_by: string | null;
3556
+ quantity: number | null;
3557
+ unit: "token" | "call" | "second" | "vcpu_second" | "gib_second" | "gpu_second" | "gb_month";
3558
+ basis: "reported" | "estimate" | "unpriced";
3559
+ usd: number | null;
3560
+ so_far_usd?: number;
3561
+ unpriced?: number;
3562
+ upper_bound?: true;
3563
+ requests?: number;
3564
+ tokens?: {
3565
+ input: number;
3566
+ output: number;
3567
+ cache_read: number;
3568
+ cache_write: number;
3569
+ };
3570
+ unmetered_requests?: number;
3571
+ not_metered_calls?: number;
3572
+ resource?: "vcpu" | "memory" | "gpu" | "disk";
3573
+ gpu_type?: string | null;
3574
+ unheld_quantity?: number | null;
3575
+ open_computers?: number;
3576
+ measured_to?: string;
3577
+ }> | null;
3578
+ browser_sessions: Array<{
3579
+ provider: string;
3580
+ tag: string;
3581
+ provider_session_id: string | null;
3582
+ started_at: string | null;
3583
+ ended_at: string | null;
3584
+ release_reason: string | null;
3585
+ charged_seconds: number | null;
3586
+ provider_record: {
3587
+ started_at: string | null;
3588
+ ended_at: string | null;
3589
+ proxy_bytes: number | null;
3590
+ } | null;
3591
+ provider_record_status: "read" | "not_offered" | "not_found" | "failed" | "no_session" | null;
3592
+ }> | null;
3593
+ computer_intervals: Array<{
3594
+ provider: string;
3595
+ provider_id: string;
3596
+ kind: string | null;
3597
+ gpu: {
3598
+ type: string | null;
3599
+ count: number | null;
3600
+ } | null;
3601
+ cpus: number | null;
3602
+ memory_mb: number | null;
3603
+ disk_gb: number | null;
3604
+ started_at: string;
3605
+ ended_at: string | null;
3606
+ kept: boolean;
3607
+ booked_seconds: number;
3608
+ }> | null;
3609
+ reason: "running" | "not_booked" | "reopened" | null;
3610
+ };
3505
3611
  /** Complete a backend SDK task (POST /sdk-runs/{run_id}/complete). */
3506
3612
  export type CompleteSdkRunBody = {
3507
3613
  status: "completed" | "failed" | "cancelled";
@@ -3583,6 +3689,12 @@ export type StartSdkRunBody = {
3583
3689
  price_usd?: number;
3584
3690
  }>;
3585
3691
  workflow_adapters?: Array<"runNode" | "runJudge">;
3692
+ } | {
3693
+ runtime: "external";
3694
+ platform: string;
3695
+ input: string;
3696
+ instructions: string;
3697
+ model?: string;
3586
3698
  };
3587
3699
  export interface StartSdkRunParams {
3588
3700
  "Idempotency-Key": string;
@@ -3854,6 +3966,7 @@ export type ApplyTemplateResponse = {
3854
3966
  template: string;
3855
3967
  version: string;
3856
3968
  agent_id: string;
3969
+ revision_version: number;
3857
3970
  servers: Record<string, string | null>;
3858
3971
  trigger_ids: Array<string>;
3859
3972
  warnings: Array<InputIssue>;
@@ -4126,6 +4239,9 @@ export type PutToolSettingsBody = {
4126
4239
  provider?: "auto" | "native" | "exa-keyless" | "parallel" | "off";
4127
4240
  permission?: "allow" | "ask" | "deny";
4128
4241
  };
4242
+ web_save?: {
4243
+ permission?: "allow" | "ask" | "deny";
4244
+ };
4129
4245
  email_search?: {
4130
4246
  permission?: "allow" | "ask" | "deny";
4131
4247
  };
@@ -5363,7 +5479,7 @@ export declare function resources(call: Call): {
5363
5479
  connectNative: (body: ConnectNativeBody, options?: RequestOptions) => Promise<ConnectNativeResponse>;
5364
5480
  /** Create an agent home (POST /agents). */
5365
5481
  create: (body: CreateAgentBody, params?: CreateAgentParams, options?: RequestOptions) => Promise<CreateAgentResponse>;
5366
- /** Delete an agent another system owns (DELETE /agents/{agent_id}). */
5482
+ /** Delete an agent another system owns, or purge an archived agent made here (DELETE /agents/{agent_id}). */
5367
5483
  deleteAgent: (agentId: string, options?: RequestOptions) => Promise<void>;
5368
5484
  /** Remove an agent's own Archil disk, and everything on it (DELETE /agents/{agent_id}/archil). */
5369
5485
  deleteAgentArchil: (agentId: string, options?: RequestOptions) => Promise<DeleteAgentArchilResponse>;
@@ -5579,6 +5695,8 @@ export declare function resources(call: Call): {
5579
5695
  createInlineRun: (body: CreateInlineRunBody, params?: CreateInlineRunParams, options?: RequestOptions) => Promise<CreateInlineRunResponse>;
5580
5696
  /** Mint a link to the run's live view for the backend's user (POST /runs/{run_id}/computer/viewer). */
5581
5697
  createRunComputerViewer: (runId: string, body?: CreateRunComputerViewerBody, options?: RequestOptions) => Promise<CreateRunComputerViewerResponse>;
5698
+ /** Purge a run's content and keep its cost (DELETE /runs/{run_id}). */
5699
+ delete: (runId: string, options?: RequestOptions) => Promise<void>;
5582
5700
  /** The files the run wrote (GET /runs/{run_id}/files). */
5583
5701
  files: (runId: string, options?: RequestOptions) => Promise<ListRunFilesResponse>;
5584
5702
  /** One run (GET /runs/{run_id}). */
@@ -5619,6 +5737,8 @@ export declare function resources(call: Call): {
5619
5737
  trace: (runId: string, options?: RequestOptions) => Promise<GetRunTraceResponse>;
5620
5738
  /** Show the archived run in the lists again (POST /runs/{run_id}/unarchive). */
5621
5739
  unarchive: (runId: string, options?: RequestOptions) => Promise<UnarchiveRunResponse>;
5740
+ /** What a run cost, by model, by who charged for its tools, and by browser provider (GET /runs/{run_id}/usage). */
5741
+ usage: (runId: string, options?: RequestOptions) => Promise<GetRunUsageResponse>;
5622
5742
  };
5623
5743
  sdkRuns: {
5624
5744
  /** Complete a backend SDK task (POST /sdk-runs/{run_id}/complete). */
@@ -106,6 +106,7 @@ export const OPERATIONS = {
106
106
  releaseRunComputer: { "method": "POST", "path": "/runs/{run_id}/computer/release", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": { "required": false, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
107
107
  createInlineRun: { "method": "POST", "path": "/runs", "pathParams": [], "multiSegment": [], "query": [], "headers": ["Idempotency-Key"], "body": { "required": true, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
108
108
  createRunComputerViewer: { "method": "POST", "path": "/runs/{run_id}/computer/viewer", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": { "required": false, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
109
+ deleteRun: { "method": "DELETE", "path": "/runs/{run_id}", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "none", "secret": false, "publicFields": [], "tagged": false },
109
110
  listRunFiles: { "method": "GET", "path": "/runs/{run_id}/files", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
110
111
  getRun: { "method": "GET", "path": "/runs/{run_id}", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
111
112
  gradeRun: { "method": "PUT", "path": "/runs/{run_id}/grade", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": { "required": true, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
@@ -126,6 +127,7 @@ export const OPERATIONS = {
126
127
  getTimeline: { "method": "GET", "path": "/runs/{run_id}/timeline", "pathParams": ["run_id"], "multiSegment": [], "query": ["after", "wait_ms", "limit", "calls"], "headers": ["Last-Event-ID"], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
127
128
  getRunTrace: { "method": "GET", "path": "/runs/{run_id}/trace", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
128
129
  unarchiveRun: { "method": "POST", "path": "/runs/{run_id}/unarchive", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
130
+ getRunUsage: { "method": "GET", "path": "/runs/{run_id}/usage", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
129
131
  completeSdkRun: { "method": "POST", "path": "/sdk-runs/{run_id}/complete", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": ["Idempotency-Key"], "body": { "required": true, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
130
132
  sdkRunEvents: { "method": "POST", "path": "/sdk-runs/{run_id}/events", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": ["Idempotency-Key"], "body": { "required": true, "types": ["application/json"] }, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
131
133
  getSdkRun: { "method": "GET", "path": "/sdk-runs/{run_id}", "pathParams": ["run_id"], "multiSegment": [], "query": [], "headers": [], "body": null, "answer": "json", "secret": false, "publicFields": [], "tagged": false },
@@ -178,7 +180,7 @@ export function resources(call) {
178
180
  connectNative: (body, options) => call("connectNative", [], body, undefined, options),
179
181
  /** Create an agent home (POST /agents). */
180
182
  create: (body, params, options) => call("createAgent", [], body, params, options),
181
- /** Delete an agent another system owns (DELETE /agents/{agent_id}). */
183
+ /** Delete an agent another system owns, or purge an archived agent made here (DELETE /agents/{agent_id}). */
182
184
  deleteAgent: (agentId, options) => call("deleteAgent", [agentId], undefined, undefined, options),
183
185
  /** Remove an agent's own Archil disk, and everything on it (DELETE /agents/{agent_id}/archil). */
184
186
  deleteAgentArchil: (agentId, options) => call("deleteAgentArchil", [agentId], undefined, undefined, options),
@@ -394,6 +396,8 @@ export function resources(call) {
394
396
  createInlineRun: (body, params, options) => call("createInlineRun", [], body, params, options),
395
397
  /** Mint a link to the run's live view for the backend's user (POST /runs/{run_id}/computer/viewer). */
396
398
  createRunComputerViewer: (runId, body, options) => call("createRunComputerViewer", [runId], body, undefined, options),
399
+ /** Purge a run's content and keep its cost (DELETE /runs/{run_id}). */
400
+ delete: (runId, options) => call("deleteRun", [runId], undefined, undefined, options),
397
401
  /** The files the run wrote (GET /runs/{run_id}/files). */
398
402
  files: (runId, options) => call("listRunFiles", [runId], undefined, undefined, options),
399
403
  /** One run (GET /runs/{run_id}). */
@@ -434,6 +438,8 @@ export function resources(call) {
434
438
  trace: (runId, options) => call("getRunTrace", [runId], undefined, undefined, options),
435
439
  /** Show the archived run in the lists again (POST /runs/{run_id}/unarchive). */
436
440
  unarchive: (runId, options) => call("unarchiveRun", [runId], undefined, undefined, options),
441
+ /** What a run cost, by model, by who charged for its tools, and by browser provider (GET /runs/{run_id}/usage). */
442
+ usage: (runId, options) => call("getRunUsage", [runId], undefined, undefined, options),
437
443
  },
438
444
  sdkRuns: {
439
445
  /** Complete a backend SDK task (POST /sdk-runs/{run_id}/complete). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-client",
3
- "version": "0.1.0-beta.48",
3
+ "version": "0.1.0-beta.50",
4
4
  "description": "A typed TypeScript client for a self-hosted AgentRun server: a method per operation of its API, typed from its OpenAPI document, with waiting for a run and following its timeline. No dependencies; fetch only.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -83,6 +83,6 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@parcha/agentrun-dsl": "0.1.0-beta.48"
86
+ "@parcha/agentrun-dsl": "0.1.0-beta.50"
87
87
  }
88
88
  }