@coltonkirsten/a12s 0.2.1 → 0.4.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.
@@ -8,28 +8,124 @@ export interface Harness {
8
8
  version: string;
9
9
  model?: string;
10
10
  }
11
- /** A parsed fleet.yaml. a12s validates it; the client passes it through. */
12
- export type Fleet = Record<string, unknown> & {
13
- metadata: {
11
+ export interface AgentComputerSpec {
12
+ harness?: {
13
+ kind: "claude-code" | "codex" | (string & {});
14
+ version?: string;
15
+ model?: string;
16
+ };
17
+ image?: string;
18
+ instructions?: string;
19
+ /** File contents by path, written into the agent computer's home. */
20
+ files?: Record<string, string>;
21
+ resources?: {
22
+ cpu?: string | number;
23
+ memory?: string | number;
24
+ };
25
+ home?: {
26
+ size?: string | number;
27
+ preset?: string;
28
+ };
29
+ autonomy?: "full" | "restricted";
30
+ /** Credential names; their values come from `a12s up` or the credentials API. */
31
+ credentials?: string[];
32
+ drives?: Array<{
33
+ name: string;
34
+ at: string;
35
+ readOnly?: boolean;
36
+ }>;
37
+ egress?: {
38
+ allow?: string[];
39
+ };
40
+ /** `seccomp` is the profile JSON itself. */
41
+ security?: {
42
+ seccomp?: Record<string, unknown>;
43
+ };
44
+ inbox?: {
45
+ maxMessages?: number;
46
+ maxBytes?: string;
47
+ intro?: string;
48
+ };
49
+ power?: {
50
+ sleepAfterIdle?: string;
51
+ wakeOnMessage?: {
52
+ from: string[];
53
+ maxWakesPerHour?: number;
54
+ };
55
+ };
56
+ uses?: Array<string | {
14
57
  name: string;
58
+ mcp?: boolean;
59
+ }>;
60
+ grants?: {
61
+ send?: string[];
15
62
  };
63
+ }
64
+ /** A JSON merge patch of T: a key set to null is deleted. */
65
+ export type MergePatch<T> = {
66
+ [K in keyof T]?: T[K] | null;
16
67
  };
68
+ /** A Fleet as written: the defaults and each agent computer before the defaults are merged in. */
69
+ export interface FleetSpec {
70
+ apiVersion: string;
71
+ kind: string;
72
+ metadata: {
73
+ name: string;
74
+ };
75
+ egress?: {
76
+ enforcement?: string;
77
+ allowPrivate?: string[];
78
+ };
79
+ defaults?: AgentComputerSpec;
80
+ drives?: Record<string, {
81
+ size?: string | number;
82
+ access: string;
83
+ }>;
84
+ agent_computers: Record<string, AgentComputerSpec>;
85
+ services?: Record<string, Record<string, unknown>>;
86
+ }
87
+ export interface Change {
88
+ op: "create" | "update" | "remove" | (string & {});
89
+ kind: "agentComputer" | "service" | (string & {});
90
+ name: string;
91
+ /** "idle" for an update that waits for a busy agent computer's next idle boundary. */
92
+ when: "now" | "idle" | (string & {});
93
+ /** The top-level spec fields that differ, for an update. */
94
+ fields?: string[];
95
+ }
96
+ export interface FleetResponse {
97
+ version: number;
98
+ fleet: FleetSpec | null;
99
+ /** What changed through the API since the last whole-Fleet write: `a12s up` from the file undoes it. */
100
+ drift: Change[];
101
+ }
102
+ export interface AgentComputerData {
103
+ name: string;
104
+ /** As written. */
105
+ spec: AgentComputerSpec;
106
+ /** With the Fleet's defaults merged in. */
107
+ effective: AgentComputerSpec;
108
+ status: ComputerStatus;
109
+ }
110
+ export interface AgentComputersResponse {
111
+ agentComputers: AgentComputerData[];
112
+ }
17
113
  export interface Lock {
18
114
  a12s?: string;
19
115
  images: Record<string, string>;
20
116
  bundles: Record<string, string>;
21
117
  presets: Record<string, string>;
22
118
  services?: Record<string, string>;
119
+ /** Each security.seccomp profile's digest, by its path in the Fleet file. */
120
+ seccomp?: Record<string, string>;
23
121
  }
24
122
  export interface PutFleetRequest {
25
- fleet: Fleet;
123
+ fleet: FleetSpec;
26
124
  lock?: Lock;
27
125
  /** Credential values by name, base64-encoded (Go []byte). Kept in the Controller's memory only. */
28
126
  credentials?: Record<string, string>;
29
127
  asleep?: boolean;
30
128
  refresh?: string[];
31
- /** Home presets as base64 tar streams, keyed by their path in the Fleet. */
32
- presets?: Record<string, string>;
33
129
  }
34
130
  export interface ServiceChanges {
35
131
  created: string[] | null;
@@ -37,6 +133,10 @@ export interface ServiceChanges {
37
133
  removed: string[] | null;
38
134
  }
39
135
  export interface PutFleetResponse {
136
+ /** The Fleet's version after the write; unchanged by a dry run or a write that changed nothing. */
137
+ version: number;
138
+ dryRun?: boolean;
139
+ changes: Change[];
40
140
  created: string[] | null;
41
141
  updated: string[] | null;
42
142
  staged: string[] | null;
@@ -45,6 +145,10 @@ export interface PutFleetResponse {
45
145
  errors?: Record<string, string>;
46
146
  warnings?: string[];
47
147
  services: ServiceChanges;
148
+ /** The written agent computer, after a PUT or PATCH of one. */
149
+ agentComputer?: AgentComputerData;
150
+ /** The written Service, after a PUT or PATCH of one. */
151
+ service?: ServiceStatus;
48
152
  }
49
153
  export interface LimitValue {
50
154
  value: number;
@@ -97,6 +201,8 @@ export interface ComputerStatus {
97
201
  activeTurn?: string;
98
202
  harness: Harness;
99
203
  image: string;
204
+ /** The Fleet's security.seccomp path, when the Computer runs with a custom seccomp profile. */
205
+ seccomp?: string;
100
206
  autonomy: string;
101
207
  generation: number;
102
208
  stagedGeneration?: number;
@@ -140,10 +246,14 @@ export interface ServiceStatus {
140
246
  stateDrive?: string;
141
247
  egressMode?: string;
142
248
  warnings?: string[];
249
+ /** The Service as written in the Fleet. */
250
+ spec?: Record<string, unknown>;
143
251
  }
144
252
  export interface StatusResponse {
145
253
  fleet: string;
146
254
  egressEnforcement: string;
255
+ agentComputers: ComputerStatus[];
256
+ /** @deprecated `agentComputers` under its old name. */
147
257
  computers: ComputerStatus[];
148
258
  orphanedDrives?: DriveRow[];
149
259
  credentialsLoaded: boolean;
@@ -207,10 +317,12 @@ export interface InboxListOptions {
207
317
  bodies?: boolean;
208
318
  after?: number;
209
319
  }
210
- /** The fields every journal event has. `seq` is the Computer's journal position and the SSE id. */
320
+ /** The fields every event has. `seq` is the agent computer's journal position (0 for the Controller's own events). */
211
321
  export interface EventEnvelope {
212
322
  v: number;
213
- /** The Computer that journaled it. */
323
+ /** The agent computer it is about; absent on `fleet.changed` and in journals older than the field. */
324
+ agentComputer?: string;
325
+ /** `agentComputer` under its old name, for one release. */
214
326
  computer: string;
215
327
  session: string;
216
328
  /** The Turn it belongs to; "" for events outside a Turn. */
@@ -258,8 +370,34 @@ export interface TurnFinishedData {
258
370
  status: "completed" | "failed" | "interrupted";
259
371
  /** The harness's own usage object (tokens, cost), or null. */
260
372
  usage: unknown;
373
+ /** The same usage, normalized across harnesses, when the harness reported it. */
374
+ tokens?: TokenUsage;
261
375
  error?: string;
262
376
  }
377
+ /** A Turn's token usage, the same for every harness. `input` excludes cached input. */
378
+ export interface TokenUsage {
379
+ input: number;
380
+ output: number;
381
+ cacheRead: number;
382
+ cacheWrite: number;
383
+ }
384
+ /** The egress proxy refused a connection. */
385
+ export interface EgressDeniedData {
386
+ host: string;
387
+ port: number;
388
+ reason?: string;
389
+ }
390
+ /** The Fleet's version moved; `names` are the agent computers and Services the write changed. */
391
+ export interface FleetChangedData {
392
+ version: number;
393
+ /** Who wrote it. */
394
+ by: string;
395
+ names: string[];
396
+ }
397
+ export interface PhaseData {
398
+ phase: Phase;
399
+ error?: Failure;
400
+ }
263
401
  export interface ToolStartedData {
264
402
  id: string;
265
403
  /** MCP tools are named `mcp__<server>__<tool>`, e.g. `mcp__a12s__send`. */
@@ -325,10 +463,15 @@ export type TurnRefusedEvent = Ev<"turn.refused", {
325
463
  }>;
326
464
  /** A Message that ended without delivery (cleared, withdrawn, expired, replaced), body included. */
327
465
  export type InboxDiscardedEvent = Ev<"inbox.discarded", Record<string, unknown>>;
466
+ export type EgressDeniedEvent = Ev<"egress.denied", EgressDeniedData>;
467
+ /** Made by the Controller, on the fleet-wide stream only. */
468
+ export type FleetChangedEvent = Ev<"fleet.changed", FleetChangedData>;
469
+ /** Made by the Controller, on the fleet-wide stream only. */
470
+ export type PhaseEvent = Ev<"agent_computer.phase", PhaseData>;
328
471
  /** Made by the SDK, never journaled: the stream could not resume from its cursor and events were lost. */
329
472
  export type GapEvent = Ev<"gap", GapData>;
330
- /** One event of a Computer's journal. Narrow on `type` to get typed `data`. */
331
- export type A12sEvent = TurnStartedEvent | TurnDispatchedEvent | TextDeltaEvent | ToolStartedEvent | ToolFinishedEvent | PermissionEvent | DiagnosticEvent | TurnFinishedEvent | SessionChangedEvent | ResumeFailedEvent | LifecycleEvent | HarnessRestartedEvent | ContinuationAbandonedEvent | TurnRefusedEvent | InboxDiscardedEvent | GapEvent;
473
+ /** One event of an agent computer's journal, or the Controller's own on the fleet-wide stream. Narrow on `type` to get typed `data`. */
474
+ export type A12sEvent = TurnStartedEvent | TurnDispatchedEvent | TextDeltaEvent | ToolStartedEvent | ToolFinishedEvent | PermissionEvent | DiagnosticEvent | TurnFinishedEvent | SessionChangedEvent | ResumeFailedEvent | LifecycleEvent | HarnessRestartedEvent | ContinuationAbandonedEvent | TurnRefusedEvent | InboxDiscardedEvent | EgressDeniedEvent | FleetChangedEvent | PhaseEvent | GapEvent;
332
475
  export type EventType = A12sEvent["type"];
333
476
  /** One tool call in a Turn. A `send` to another Computer is `mcp__a12s__send` with `input.body`. */
334
477
  export interface ToolCall {
@@ -340,6 +483,8 @@ export interface ToolCall {
340
483
  }
341
484
  /** A finished Turn: what `turns()` yields and `prompt()` returns. */
342
485
  export interface Turn {
486
+ agentComputer: string;
487
+ /** `agentComputer` under its old name, for one release. */
343
488
  computer: string;
344
489
  /** The Turn id. */
345
490
  id: string;
@@ -353,24 +498,47 @@ export interface Turn {
353
498
  /** The tools it called, in order, with their input and output: what it `send`s to other Computers is here. */
354
499
  tools: ToolCall[];
355
500
  usage: unknown;
501
+ tokens?: TokenUsage;
356
502
  startedAt?: string;
357
503
  finishedAt: string;
358
504
  }
505
+ /** Past Turns, newest first, as GET /v1/agent-computers/{name}/turns sends them. */
506
+ export interface TurnsResponse {
507
+ turns: Array<Omit<Turn, "computer" | "tools"> & {
508
+ tools: Array<Omit<ToolCall, "isError"> & {
509
+ isError?: boolean;
510
+ }>;
511
+ }>;
512
+ }
359
513
  export interface ApiErrorBody {
360
514
  code: string;
361
515
  message: string;
362
516
  fix?: string;
363
517
  details?: Record<string, string>;
364
518
  }
519
+ export type TokenAction = "send" | "inbox" | "status" | "events" | "power" | "stop";
520
+ /** Either `prefix`, or `actions` on `computers` (agent computer names, or "*"). */
365
521
  export interface TokenRequest {
366
522
  name: string;
367
- actions: Array<"send" | "inbox" | "status" | "events" | "power" | "stop">;
368
- computers: string[];
523
+ actions?: TokenAction[];
524
+ computers?: string[];
525
+ /** Every power over agent computers, Services and credentials whose names start with it; none outside. */
526
+ prefix?: string;
527
+ }
528
+ /** A credential's name, whether it has a value, and who uses it. */
529
+ export interface CredentialInfo {
530
+ name: string;
531
+ set: boolean;
532
+ usedBy?: string[];
533
+ }
534
+ export interface CredentialsResponse {
535
+ credentials: CredentialInfo[];
369
536
  }
370
537
  export interface Token {
371
538
  name: string;
372
539
  actions: string[];
373
540
  computers: string[];
541
+ prefix?: string;
374
542
  createdAt: string;
375
543
  secret?: string;
376
544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coltonkirsten/a12s",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript client for a12s: send work to agent Computers, stream their events and Turns, in Node or the browser",
5
5
  "license": "MIT",
6
6
  "type": "module",