@claxedo/agent-runtime-contract 0.8.0 → 0.10.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.
Files changed (65) hide show
  1. package/README.md +27 -9
  2. package/dist/agent-runtime-event.d.ts +975 -0
  3. package/dist/availability.d.ts +3 -4
  4. package/dist/background-work.d.ts +10 -0
  5. package/dist/claims.d.ts +2 -0
  6. package/dist/connections.d.ts +66 -1
  7. package/dist/content.d.ts +72 -15
  8. package/dist/credential-broker-errors.d.ts +4 -0
  9. package/dist/custom-provider-headers.d.ts +12 -0
  10. package/dist/d1-bookmarks.d.ts +39 -0
  11. package/dist/daemon-ownership-snapshot.d.ts +40 -0
  12. package/dist/diagnostics.d.ts +24 -0
  13. package/dist/elicitation-pattern-worker.d.ts +6 -0
  14. package/dist/elicitation-pattern-worker.mjs +17 -0
  15. package/dist/elicitation-validation.d.ts +23 -0
  16. package/dist/elicitation.d.ts +51 -0
  17. package/dist/errors.d.ts +8 -1
  18. package/dist/event-cursor.d.ts +19 -0
  19. package/dist/events.d.ts +146 -216
  20. package/dist/files.d.ts +2 -0
  21. package/dist/first-turn-error.d.ts +12 -0
  22. package/dist/goals.d.ts +28 -0
  23. package/dist/harness-permission-modes.d.ts +76 -0
  24. package/dist/harness-table.d.ts +66 -4
  25. package/dist/harnesses.d.ts +19 -1
  26. package/dist/ids.d.ts +4 -0
  27. package/dist/index.d.ts +46 -1
  28. package/dist/index.mjs +2814 -95
  29. package/dist/mcp-app.d.ts +24 -0
  30. package/dist/message-page.d.ts +101 -0
  31. package/dist/permissions.d.ts +47 -0
  32. package/dist/pi-providers.d.ts +36 -0
  33. package/dist/prompt-title.d.ts +2 -0
  34. package/dist/provider-projection.d.ts +166 -0
  35. package/dist/raw-harness-event.d.ts +7 -0
  36. package/dist/recovery/actions.d.ts +20 -0
  37. package/dist/recovery/budgets.d.ts +16 -0
  38. package/dist/recovery/facts.d.ts +37 -0
  39. package/dist/recovery/operations.d.ts +66 -0
  40. package/dist/recovery/outcomes.d.ts +48 -0
  41. package/dist/recovery/payload-line.d.ts +19 -0
  42. package/dist/recovery/postconditions.d.ts +18 -0
  43. package/dist/recovery/requests.d.ts +44 -0
  44. package/dist/recovery/targets.d.ts +55 -0
  45. package/dist/recovery/validation.d.ts +9 -0
  46. package/dist/runtime-content.d.ts +34 -0
  47. package/dist/session-handoff.d.ts +4 -0
  48. package/dist/session-titles.d.ts +14 -0
  49. package/dist/sessions.d.ts +183 -5
  50. package/dist/stream-heartbeat.d.ts +11 -0
  51. package/dist/subagents.d.ts +92 -0
  52. package/dist/tool-header.d.ts +13 -0
  53. package/dist/tool-names.d.ts +5 -0
  54. package/dist/transcript-notice.d.ts +28 -0
  55. package/dist/turn-account.d.ts +26 -0
  56. package/dist/turn-error-classes.d.ts +10 -0
  57. package/dist/turn-fold.d.ts +111 -0
  58. package/dist/turn-fold.mjs +414 -0
  59. package/dist/turn-message-ids.d.ts +16 -0
  60. package/dist/turn-outline.d.ts +37 -0
  61. package/dist/turn-page.d.ts +58 -0
  62. package/dist/usage-streams.d.ts +19 -0
  63. package/dist/vendor-body.d.ts +31 -0
  64. package/dist/vendor-providers.d.ts +11 -0
  65. package/package.json +17 -3
@@ -0,0 +1,44 @@
1
+ import { type RecoveryAction } from "./actions";
2
+ import { type RecoveryTarget } from "./targets";
3
+ /**
4
+ * The drain a `release_drain` reopens, by operation id.
5
+ *
6
+ * Releasing is always about one earlier operation's gates, never about "the
7
+ * fence" in general: two drains can hold overlapping owners, and reopening
8
+ * whatever happens to be closed would un-gate a scope its own caller never
9
+ * authorized reopening. The id rides in `linkedOperationId`, which is the field
10
+ * for exactly this — a request that names another operation — so a release
11
+ * without one is refused before it reaches an owner.
12
+ */
13
+ export declare function releasedDrainOperationId(request: RecoveryRequest): string | undefined;
14
+ export type RecoveryRequest = {
15
+ /** Unique per caller, not globally: two callers may reuse the same string. */
16
+ requestId: string;
17
+ action: RecoveryAction;
18
+ target: RecoveryTarget;
19
+ /** The revision of the impact scope the caller was shown and authorized. */
20
+ scopeRevision: string;
21
+ attempt: number;
22
+ /** The failed operation an explicit retry, or a nested child, is linked to. */
23
+ linkedOperationId?: string;
24
+ };
25
+ /**
26
+ * The part of a request that decides whether a second delivery of the same
27
+ * request id is the same command. Attempt and request id are excluded: a retry
28
+ * is a new attempt of one intent, and the id is the key being compared under.
29
+ */
30
+ export type RecoveryIntent = {
31
+ action: RecoveryAction;
32
+ scopeRevision: string;
33
+ target: RecoveryTarget;
34
+ linkedOperationId?: string;
35
+ };
36
+ /**
37
+ * Key order comes from the literals here rather than from the caller's object,
38
+ * so `JSON.stringify` of the result is canonical and can be stored as the
39
+ * column an owner compares a repeated request id against.
40
+ */
41
+ export declare function normalizeRecoveryIntent(request: RecoveryRequest): RecoveryIntent;
42
+ /** Repeated deliveries must compare canonical intent rather than caller-supplied key order. */
43
+ export declare function recoveryIntentEquals(a: RecoveryRequest, b: RecoveryRequest): boolean;
44
+ export declare function parseRecoveryRequest(input: unknown): RecoveryRequest;
@@ -0,0 +1,55 @@
1
+ import { type RecoveryGeneration } from "./facts";
2
+ export declare const RECOVERY_TARGET_SCOPES: readonly ["turn", "session", "harness", "machine"];
3
+ export type RecoveryTargetScope = (typeof RECOVERY_TARGET_SCOPES)[number];
4
+ export type RecoveryTurnTarget = {
5
+ scope: "turn";
6
+ machineId?: string;
7
+ workspaceId: string;
8
+ sessionId: string;
9
+ turnId: string;
10
+ ownerGeneration: RecoveryGeneration;
11
+ /** The durable lease or token id whose holder may write for this target. */
12
+ writeAuthority?: string;
13
+ };
14
+ export type RecoverySessionTarget = {
15
+ scope: "session";
16
+ machineId?: string;
17
+ workspaceId: string;
18
+ sessionId: string;
19
+ ownerGeneration: RecoveryGeneration;
20
+ };
21
+ export type RecoveryHarnessTarget = {
22
+ scope: "harness";
23
+ machineId?: string;
24
+ workspaceId: string;
25
+ /** The harness generation's own key; a harness may serve several sessions. */
26
+ harnessKey: string;
27
+ ownerGeneration: RecoveryGeneration;
28
+ };
29
+ export type RecoveryMachineTarget = {
30
+ scope: "machine";
31
+ machineId: string;
32
+ ownerGeneration: RecoveryGeneration;
33
+ };
34
+ /**
35
+ * The scopes carry different fields because they name different things: a
36
+ * daemon has no session and a harness generation outlives any one turn.
37
+ * Flattening them would make a caller invent a session id to drain a daemon,
38
+ * and an invented identity is indistinguishable from a real one downstream.
39
+ */
40
+ export type RecoveryTarget = RecoveryTurnTarget | RecoverySessionTarget | RecoveryHarnessTarget | RecoveryMachineTarget;
41
+ export declare function normalizeRecoveryTarget(target: RecoveryTarget): RecoveryTarget;
42
+ /**
43
+ * Whether two targets name the same resource under the same owner generation.
44
+ * `writeAuthority` is excluded: a lease may be renewed or reissued for the very
45
+ * turn a caller is checking, so comparing it would call a live target stale.
46
+ */
47
+ export declare function recoveryTargetsMatch(a: RecoveryTarget, b: RecoveryTarget): boolean;
48
+ export declare function parseRecoveryTarget(input: unknown): RecoveryTarget;
49
+ /**
50
+ * The row a repeated recovery request is compared under. A turn operation and a
51
+ * session operation share their session's key, so a caller cannot escape its
52
+ * own uniqueness by naming a different turn of the same session.
53
+ */
54
+ export declare function recoveryScopeKey(target: RecoveryTarget): string;
55
+ export declare function recoveryTargetSessionId(target: RecoveryTarget): string | null;
@@ -0,0 +1,9 @@
1
+ export declare const RECOVERY_CONTRACT_ERROR_CODES: readonly ["invalid_payload", "invalid_request_id", "invalid_action", "invalid_attempt", "invalid_scope_revision", "invalid_target", "invalid_target_scope", "scope_mismatch", "missing_generation", "invalid_observed_at", "invalid_fact", "invalid_operation", "invalid_refusal", "invalid_budget"];
2
+ export type RecoveryContractErrorCode = (typeof RECOVERY_CONTRACT_ERROR_CODES)[number];
3
+ export declare class RecoveryContractError extends Error {
4
+ readonly code: RecoveryContractErrorCode;
5
+ constructor(code: RecoveryContractErrorCode, message: string);
6
+ }
7
+ export declare function member<T extends string>(values: readonly T[], value: unknown): value is T;
8
+ export declare function requireRecoveryText(value: unknown, code: RecoveryContractErrorCode, label: string): string;
9
+ export declare function requireRecoveryNumber(value: unknown, code: RecoveryContractErrorCode, label: string): number;
@@ -0,0 +1,34 @@
1
+ export type RuntimeContentBlock = {
2
+ type: "text";
3
+ text: string;
4
+ } | {
5
+ type: "image";
6
+ data: string;
7
+ mimeType: string;
8
+ uri?: string | null;
9
+ } | {
10
+ type: "audio";
11
+ data: string;
12
+ mimeType: string;
13
+ } | {
14
+ type: "resource_link";
15
+ uri: string;
16
+ name: string;
17
+ mimeType?: string | null;
18
+ title?: string | null;
19
+ } | {
20
+ type: "resource";
21
+ resource: unknown;
22
+ };
23
+ export type RuntimeToolCallContent = {
24
+ type: "content";
25
+ content: RuntimeContentBlock;
26
+ } | {
27
+ type: "diff";
28
+ path: string;
29
+ oldText?: string | null;
30
+ newText: string;
31
+ } | {
32
+ type: "terminal";
33
+ terminalId: string;
34
+ };
@@ -0,0 +1,4 @@
1
+ import type { AgentMessage } from "./content";
2
+ import { type SessionHarness } from "./harnesses";
3
+ export declare function renderSessionTranscript(rows: readonly AgentMessage[]): string;
4
+ export declare function renderSessionHandoff(rows: readonly AgentMessage[], from: SessionHarness): string;
@@ -0,0 +1,14 @@
1
+ import type { PromptModel } from "./sessions";
2
+ /**
3
+ * What a harness receives when the runtime asks it for a title: the shared
4
+ * instruction, the conversation excerpt, and the session's own model, so
5
+ * the side turn runs under the same credentials as the session.
6
+ */
7
+ export type SessionTitleRequest = {
8
+ directory: string;
9
+ system: string;
10
+ user: string;
11
+ /** The session's selected model; absent when the session runs the harness default. */
12
+ model?: PromptModel;
13
+ signal: AbortSignal;
14
+ };
@@ -1,5 +1,16 @@
1
+ import type { SessionHarness } from "./harnesses";
2
+ import type { SessionModelGroup } from "./session-group";
3
+ import type { AutoLevel } from "./permissions";
4
+ import type { CleanupFact, ExecutionFact } from "./recovery/facts";
5
+ import type { RecoveryErrorCode } from "./recovery/operations";
1
6
  import type { ExecutionAvailability } from "./availability";
2
7
  import type { AgentAgentPartInput, AgentFilePartInput, AgentTextPartInput } from "./content";
8
+ import type { FirstTurnErrorClass } from "./turn-error-classes";
9
+ import type { TurnAccount } from "./turn-account";
10
+ export type SessionRef = Readonly<{
11
+ sessionId: string;
12
+ workspaceId: string;
13
+ }>;
3
14
  export type AgentWorkspaceIdentity = {
4
15
  workspaceId: string;
5
16
  directory: string;
@@ -9,13 +20,48 @@ export type AgentWorkspaceIdentity = {
9
20
  * `upstreamSessionId` is opaque: Claxedo stores and forwards it but never
10
21
  * parses it or uses it to discover sessions.
11
22
  */
12
- export type AgentWorkspaceExecutionBinding = AgentWorkspaceIdentity & {
23
+ export type AgentWorkspaceExecutionBinding = AgentWorkspaceIdentity & SessionRef & {
13
24
  scope?: "workspace";
14
- sessionId: string;
15
25
  connectionId: string;
16
26
  upstreamSessionId: string;
17
27
  };
18
28
  export type AgentExecutionBinding = AgentWorkspaceExecutionBinding;
29
+ /** Ownership of creation before the provider has returned any session identity. */
30
+ export type AgentSessionStartBinding = AgentWorkspaceIdentity & SessionRef & {
31
+ connectionId: string;
32
+ operationId: string;
33
+ };
34
+ export type AgentSessionStart = {
35
+ binding: AgentSessionStartBinding;
36
+ createdAt: number;
37
+ updatedAt: number;
38
+ } & ({
39
+ status: "starting";
40
+ } | {
41
+ status: "created";
42
+ upstreamSessionId: string;
43
+ } | {
44
+ status: "failed";
45
+ error: string;
46
+ });
47
+ export interface AgentSessionStarts {
48
+ get(sessionId: string): AgentSessionStart | undefined;
49
+ begin(binding: AgentSessionStartBinding): AgentSessionStart;
50
+ finish(binding: AgentSessionStartBinding, outcome: {
51
+ status: "created";
52
+ upstreamSessionId: string;
53
+ } | {
54
+ status: "failed";
55
+ error: string;
56
+ }): AgentSessionStart;
57
+ /**
58
+ * Gives the id back after an authorized deletion has already removed the
59
+ * provider session. Every binding field must still match, so an operation
60
+ * that read the record before a newer one took the id cannot retire it.
61
+ * Answers whether this call removed the record.
62
+ */
63
+ retire(binding: AgentSessionStartBinding): boolean;
64
+ }
19
65
  export type AgentExecutionBindingField = keyof AgentExecutionBinding;
20
66
  export type AgentExecutionBindingExpectation = Readonly<{
21
67
  scope?: "workspace";
@@ -25,10 +71,25 @@ export type AgentExecutionBindingExpectation = Readonly<{
25
71
  connectionId: string;
26
72
  upstreamSessionId: string;
27
73
  }>;
74
+ /**
75
+ * Who wrote the current title, ranked: a user rename beats a harness or
76
+ * model-generated title, which beats the first-prompt placeholder. A writer of
77
+ * lower rank than the stored one is dropped by the store.
78
+ */
79
+ export type AgentSessionTitleSource = "prompt" | "harness" | "user";
80
+ /** Commands advertised by this agent session; invoked as slash-prefixed prompts. */
81
+ export type AgentSessionCommand = {
82
+ name: string;
83
+ description: string;
84
+ input?: {
85
+ hint: string;
86
+ } | null;
87
+ };
28
88
  export type AgentSession = {
29
89
  id: string;
30
90
  workspaceId?: string;
31
91
  title?: string | null;
92
+ titleSource?: AgentSessionTitleSource;
32
93
  slug?: string;
33
94
  version?: string;
34
95
  directory?: string;
@@ -47,6 +108,7 @@ export type AgentSession = {
47
108
  lastTurn?: AgentTurnOutcome;
48
109
  executionAvailability?: ExecutionAvailability;
49
110
  harnessPayload?: unknown;
111
+ commands?: AgentSessionCommand[];
50
112
  };
51
113
  export type AgentPresentationSession = AgentSession & {
52
114
  tags?: string[];
@@ -104,10 +166,15 @@ export type AgentTurnOutcome = ({
104
166
  status: "completed";
105
167
  completedAt: number;
106
168
  reason?: string;
107
- } | {
169
+ }
170
+ /** `detail` is what the harness's transport established about the failure, carried onto the turn's error record. */
171
+ | {
108
172
  status: "failed";
109
173
  completedAt: number;
110
174
  error: string;
175
+ errorClass?: FirstTurnErrorClass;
176
+ account?: TurnAccount;
177
+ detail?: Readonly<Record<string, string>>;
111
178
  } | {
112
179
  status: "cancelled";
113
180
  completedAt: number;
@@ -115,6 +182,8 @@ export type AgentTurnOutcome = ({
115
182
  }) & {
116
183
  assistantMessageId?: string;
117
184
  };
185
+ /** A session's last turn as a session list row and a turn-end frame carry it: the two facts every store of it keeps. */
186
+ export type SessionLastTurn = Pick<AgentTurnOutcome, "status" | "completedAt">;
118
187
  export type PromptModel = {
119
188
  providerID: string;
120
189
  modelID: string;
@@ -136,12 +205,17 @@ export type PromptInput = {
136
205
  /** Existing user intent that owns a provider-initiated continuation. */
137
206
  parentMessageId?: string;
138
207
  assistantMessageId: string;
139
- agent: string;
140
- model: PromptModel;
208
+ agent?: string;
209
+ model?: PromptModel;
141
210
  tools?: Record<string, boolean>;
142
211
  format?: PromptFormat;
143
212
  system?: string;
144
213
  variant?: string;
214
+ /**
215
+ * A faster tier the selected model advertises (Codex `priority`, "Fast").
216
+ * Absent runs the standard tier; a harness drops a tier the model lacks.
217
+ */
218
+ serviceTier?: string;
145
219
  permissionMode?: string;
146
220
  /**
147
221
  * What to do when the session is already running a turn. `steer` hands this
@@ -164,3 +238,107 @@ export declare function connectionIdForHarness(harness: {
164
238
  id: string;
165
239
  access: string;
166
240
  }): string;
241
+ /**
242
+ * Conversation context owed to a session's fresh native thread, carried on
243
+ * every turn until one completes. `announced` records that the harness change
244
+ * was written onto a sent user message, so a retried first turn does not mark
245
+ * it again.
246
+ */
247
+ export type SessionHandoff = {
248
+ from: SessionHarness;
249
+ pending: true;
250
+ transcript: string;
251
+ announced?: true;
252
+ source?: SessionHandoffSource;
253
+ };
254
+ /**
255
+ * The native session of the harness a handoff left, and the config it ran
256
+ * under. It is kept until a message is sent on the new harness, so picking the
257
+ * left harness back resumes its own thread instead of a transcript copy.
258
+ */
259
+ export type SessionHandoffSource = {
260
+ agentSessionId: string;
261
+ upstreamSessionId: string;
262
+ ownerKey: string | null;
263
+ model?: PromptModel;
264
+ variant?: string | null;
265
+ agent?: string | null;
266
+ handoff?: Omit<SessionHandoff, "source">;
267
+ };
268
+ export type SessionConfig = {
269
+ /** Host-owned maximum permission level, retained across harness changes. */
270
+ permissionCeiling?: AutoLevel;
271
+ /** Accepted harness mode, persisted by the permission-mode operation. */
272
+ permissionMode?: string;
273
+ /**
274
+ * The accepted mode's name as the agent listed it when the mode was stored.
275
+ * Only a harness whose modes the runtime contract does not declare has one,
276
+ * so a client can name the mode without asking the agent for its list.
277
+ */
278
+ permissionModeLabel?: string;
279
+ /** Native permission state accepted by the driver; opaque to shared consumers. */
280
+ permissionState?: Record<string, unknown>;
281
+ harness: SessionHarness;
282
+ model?: PromptModel;
283
+ variant?: string | null;
284
+ agent?: string | null;
285
+ /**
286
+ * Standing instructions this session was created with. Retained so a session
287
+ * reopened after a restart keeps them without the caller resending anything;
288
+ * where they reach the harness is that harness's own `instructionChannel`,
289
+ * and one with none refuses the create rather than dropping them.
290
+ */
291
+ instructions?: string | null;
292
+ /**
293
+ * The resolved model group this session was created under, machine-readable
294
+ * so a later reader — a delegation request naming a slot, say — resolves the
295
+ * same harness/model/effort the creator chose instead of re-parsing the
296
+ * instruction prose the group was also rendered into.
297
+ */
298
+ group?: SessionModelGroup | null;
299
+ handoff?: SessionHandoff | null;
300
+ };
301
+ /**
302
+ * Partial update for a session config.
303
+ *
304
+ * - `undefined` leaves a field unchanged.
305
+ * - `null` clears optional nullable fields.
306
+ * - a value replaces the field.
307
+ *
308
+ * `harness` is a full replacement, not a deep merge.
309
+ */
310
+ export type SessionConfigUpdate = {
311
+ permissionCeiling?: SessionConfig["permissionCeiling"];
312
+ permissionMode?: string | null;
313
+ permissionModeLabel?: string | null;
314
+ permissionState?: Record<string, unknown> | null;
315
+ harness?: SessionHarness;
316
+ model?: PromptModel | null;
317
+ variant?: string | null;
318
+ agent?: string | null;
319
+ instructions?: string | null;
320
+ group?: SessionModelGroup | null;
321
+ handoff?: SessionHandoff | null;
322
+ };
323
+ /**
324
+ * What an adapter observed while trying to stop a turn. Execution and cleanup
325
+ * are separate facts because acknowledging a cancel is not stopping, and an
326
+ * adapter that closed its own stream has not thereby released the provider's
327
+ * terminals or child processes. `unknown` is the answer whenever the adapter's
328
+ * protocol cannot tell those apart; the runtime keeps the turn owned on it.
329
+ */
330
+ export type AdapterCancelOutcome = {
331
+ execution: ExecutionFact;
332
+ cleanup: CleanupFact;
333
+ error?: {
334
+ code: RecoveryErrorCode;
335
+ message: string;
336
+ };
337
+ };
338
+ export type SteerResult = {
339
+ ok: true;
340
+ } | {
341
+ ok: false;
342
+ status: "no_active_turn" | "declined" | "unsupported" | "unknown";
343
+ message: string;
344
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * How often every event stream writes a heartbeat frame: a workspace
3
+ * runtime's `wr/events`, the local daemon's `cp/events`, and the hosted
4
+ * `cp/events` whether it bridges a live-sync room or stands alone.
5
+ */
6
+ export declare const EVENT_STREAM_HEARTBEAT_MS = 10000;
7
+ /**
8
+ * How long a reader waits for any frame before it drops the stream: two
9
+ * missed heartbeats, plus one beat of jitter for the third to arrive.
10
+ */
11
+ export declare const EVENT_STREAM_STALL_TIMEOUT_MS: number;
@@ -0,0 +1,92 @@
1
+ export declare const RUNTIME_GOAL_STATUSES: readonly ["active", "paused", "blocked", "limited", "complete"];
2
+ export type RuntimeGoalStatus = typeof RUNTIME_GOAL_STATUSES[number];
3
+ export type RuntimeGoalSnapshot = {
4
+ /** Claxedo session identity. One session owns at most one Goal. */
5
+ sessionId: string;
6
+ objective: string;
7
+ status: RuntimeGoalStatus;
8
+ createdAt: number;
9
+ updatedAt: number;
10
+ /** Provider-reported fields. Absence means unknown and must remain absent. */
11
+ tokenBudget?: number;
12
+ tokensUsed?: number;
13
+ timeUsedSeconds?: number;
14
+ iteration?: number;
15
+ lastReason?: string;
16
+ };
17
+ export declare function isRuntimeGoalStatus(value: unknown): value is RuntimeGoalStatus;
18
+ export declare const SUBAGENT_STATUSES: readonly ["pending", "running", "paused", "interrupted", "completed", "failed", "killed"];
19
+ export type SubagentStatus = typeof SUBAGENT_STATUSES[number];
20
+ export declare function isTerminalSubagentStatus(status: string | undefined): boolean;
21
+ export declare const SUBAGENT_MODES: readonly ["foreground", "background"];
22
+ export type SubagentMode = typeof SUBAGENT_MODES[number];
23
+ export declare const SUBAGENT_TOOL_CALL_ROLES: readonly ["spawn", "interaction"];
24
+ export type SubagentToolCallRole = typeof SUBAGENT_TOOL_CALL_ROLES[number];
25
+ /**
26
+ * The completion wake a host-owned child owes its parent: `pending` until the
27
+ * runtime has started the parent turn that carries the child's summary.
28
+ */
29
+ export declare const SUBAGENT_WAKES: readonly ["pending", "delivered"];
30
+ export type SubagentWake = typeof SUBAGENT_WAKES[number];
31
+ export declare const SUBAGENT_TRANSCRIPT_KINDS: readonly ["live", "file", "messages", "none"];
32
+ export type SubagentTranscript = {
33
+ kind: typeof SUBAGENT_TRANSCRIPT_KINDS[number];
34
+ ref?: string;
35
+ };
36
+ export declare const isSubagentStatus: (value: unknown) => value is SubagentStatus;
37
+ export declare const isSubagentMode: (value: unknown) => value is SubagentMode;
38
+ export declare const isSubagentToolCallRole: (value: unknown) => value is SubagentToolCallRole;
39
+ export declare const isSubagentWake: (value: unknown) => value is SubagentWake;
40
+ export declare const isSubagentTranscriptKind: (value: unknown) => value is SubagentTranscript["kind"];
41
+ /** One revision of a subagent row, as the runtime observed it. */
42
+ export type AgentSubagentUpdate = {
43
+ subagentKey: string;
44
+ revision: number;
45
+ toolCallId?: string;
46
+ toolCallRole?: SubagentToolCallRole;
47
+ mode?: SubagentMode;
48
+ status?: SubagentStatus;
49
+ /** Revision at which the admission store verified the current run identity. */
50
+ runRevision?: number;
51
+ label?: string;
52
+ subagentType?: string;
53
+ description?: string;
54
+ providerId?: string;
55
+ providerKind?: string;
56
+ childSessionId?: string;
57
+ transcript?: SubagentTranscript;
58
+ /** Permission and question requests the child is holding open, to be answered by a human. */
59
+ attention?: number;
60
+ wake?: SubagentWake;
61
+ };
62
+ export type SubagentObservation = {
63
+ observationId: string;
64
+ harnessExecutionId?: string;
65
+ subagentKey?: string;
66
+ stableCorrelationId?: string;
67
+ toolCallId?: string;
68
+ toolCallRole?: SubagentToolCallRole;
69
+ mode?: SubagentMode;
70
+ status?: SubagentStatus;
71
+ label?: string;
72
+ subagentType?: string;
73
+ description?: string;
74
+ providerId?: string;
75
+ providerKind?: string;
76
+ childSessionId?: string;
77
+ transcript?: SubagentTranscript;
78
+ attention?: number;
79
+ /** The finished run's outcome, owed to the parent until a `wakeReceipt` names this observation. */
80
+ wakeResult?: {
81
+ status: SubagentStatus;
82
+ text: string;
83
+ assistantMessageId?: string;
84
+ };
85
+ wakeReceipt?: string;
86
+ };
87
+ export declare class UnknownHostSubagentKeyError extends Error {
88
+ readonly parentSessionId: string;
89
+ readonly observationId: string;
90
+ readonly subagentKey: string | undefined;
91
+ constructor(parentSessionId: string, observationId: string, subagentKey: string | undefined);
92
+ }
@@ -0,0 +1,13 @@
1
+ import type { AgentToolPart } from "./content";
2
+ export type ToolOpenSettings = {
3
+ readonly shell: boolean;
4
+ readonly edit: boolean;
5
+ };
6
+ export declare function toolOpensByDefault(tool: string, settings: ToolOpenSettings): boolean | undefined;
7
+ /**
8
+ * A tool part as its collapsed row draws it: status, title, time, error and
9
+ * the input and metadata its header reads, marked `headerOnly` so a reader
10
+ * fetches the whole part, attachments included, when the row opens. A tool
11
+ * whose row has no body is returned whole.
12
+ */
13
+ export declare function toolPartHeader(part: AgentToolPart): AgentToolPart;
@@ -1,3 +1,8 @@
1
1
  export declare function canonicalToolName(name: string): string;
2
2
  /** The alias spellings themselves, for consumers that register one entry per name. */
3
3
  export declare function toolNameAliases(): ReadonlyArray<readonly [alias: string, target: string]>;
4
+ declare const CLAXEDO_TOOL_NAMES: readonly ["task_list", "task_get", "task_create", "task_edit", "task_start", "session_create", "sessions_list", "session_get", "session_transcript", "session_send", "session_cancel_turn", "session_handoff", "session_rename", "session_delete", "session_changes", "documents_list", "documents_open", "subagent_capabilities", "create_subagent", "subagent_status", "subagent_list", "subagent_cancel", "sessions_board", "permission_reply", "question_reply", "question_reject", "wait_for_attention", "workspaces_list", "workspace_status", "workspace_checkpoint", "workspace_restore", "workspace_lifecycle", "app_plugin_create", "app_plugin_check", "app_plugin_add", "app_plugin_guide", "ui_show", "ui_guide"];
5
+ export type ClaxedoToolName = (typeof CLAXEDO_TOOL_NAMES)[number];
6
+ export declare function isClaxedoToolName(name: string): name is ClaxedoToolName;
7
+ export declare function claxedoToolName(tool: string, input?: Record<string, unknown>): string | undefined;
8
+ export {};
@@ -0,0 +1,28 @@
1
+ export type TranscriptNoticeSeverity = "info" | "warn" | "error";
2
+ export type TranscriptCompaction = {
3
+ status: "running";
4
+ } | {
5
+ status: "completed";
6
+ } | {
7
+ status: "failed";
8
+ error: string;
9
+ };
10
+ export type TranscriptNotice = {
11
+ kind: "harness";
12
+ code: string;
13
+ message: string;
14
+ severity: TranscriptNoticeSeverity;
15
+ } | {
16
+ kind: "agent-message";
17
+ sender: string;
18
+ senderName?: string;
19
+ message: string;
20
+ senderTaskId?: string;
21
+ sourceSessionId?: string;
22
+ } | ({
23
+ kind: "compaction";
24
+ } & TranscriptCompaction) | {
25
+ kind: "conversation-reset";
26
+ trigger: string;
27
+ };
28
+ export declare function isTranscriptNotice(value: unknown): value is TranscriptNotice;
@@ -0,0 +1,26 @@
1
+ import type { NativeSdkHarnessId } from "./harnesses";
2
+ import { type ProviderDirect, type ProviderProjection } from "./provider-projection";
3
+ /**
4
+ * The account a turn ran on: a stored credential the broker spent, named by
5
+ * its non-secret metadata, or the harness's own login on this machine when no
6
+ * credential was bound for it.
7
+ */
8
+ export type TurnAccount = {
9
+ readonly kind: "stored";
10
+ readonly harnessId: NativeSdkHarnessId;
11
+ readonly credentialId: string;
12
+ readonly providerId: string;
13
+ readonly label?: string;
14
+ readonly revision?: number;
15
+ } | {
16
+ readonly kind: "machine";
17
+ readonly harnessId: NativeSdkHarnessId;
18
+ };
19
+ export declare function turnAccount(input: unknown): TurnAccount | undefined;
20
+ /**
21
+ * The account a turn launched on this delivery runs on: a binding, or a
22
+ * credential handed over direct. Nothing handed means the harness's own login
23
+ * on this machine; a delivery from an authority that names no account, or one
24
+ * that cannot be bound, names nothing.
25
+ */
26
+ export declare function turnAccountFor(harnessId: NativeSdkHarnessId, delivery: ProviderProjection | ProviderDirect | undefined): TurnAccount | undefined;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * What a failed turn tells the operator to do. `rate_limit` is a temporary
3
+ * refusal (HTTP 429, "try again later") that the same account clears by
4
+ * waiting; `usage_limit` is an exhausted plan or quota window that only another
5
+ * model or account gets past until it resets; `egress` is the vendor's edge
6
+ * refusing the host the turn ran on (a challenge page, not an API answer),
7
+ * which says nothing about the account and clears on another connection.
8
+ */
9
+ export declare const FIRST_TURN_ERROR_CLASSES: readonly ["credential", "harness", "model", "rate_limit", "usage_limit", "egress", "workspace", "session", "unknown"];
10
+ export type FirstTurnErrorClass = (typeof FIRST_TURN_ERROR_CLASSES)[number];