@tangle-network/agent-interface 0.54.0 → 0.55.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.
@@ -0,0 +1,416 @@
1
+ import { z } from "zod";
2
+ import type { AgentTerminalSession } from "./environment-terminal.js";
3
+ import { type AgentExactRunControlRef } from "./runtime-control.js";
4
+ declare const AgentInteractiveSessionRunCoordinatesSchema: z.ZodObject<{
5
+ provider: z.ZodString;
6
+ environmentId: z.ZodString;
7
+ sessionId: z.ZodString;
8
+ executionId: z.ZodString;
9
+ }, z.core.$strict>;
10
+ export type AgentInteractiveSessionRunCoordinates = z.infer<typeof AgentInteractiveSessionRunCoordinatesSchema>;
11
+ /**
12
+ * Durable identity of one coding-agent TUI.
13
+ *
14
+ * This reference identifies the exact admitted run and effective profile.
15
+ * It is not a generic shell id and cannot be used to create another process.
16
+ */
17
+ export declare const AgentInteractiveSessionRefSchema: z.ZodObject<{
18
+ run: z.ZodObject<{
19
+ runId: z.ZodString;
20
+ provider: z.ZodString;
21
+ environmentId: z.ZodString;
22
+ sessionId: z.ZodString;
23
+ executionId: z.ZodString;
24
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
25
+ }, z.core.$strict>;
26
+ requestedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
27
+ admittedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
28
+ incarnationId: z.ZodString;
29
+ harness: z.ZodEnum<{
30
+ "claude-code": "claude-code";
31
+ nanoclaw: "nanoclaw";
32
+ codex: "codex";
33
+ opencode: "opencode";
34
+ "kimi-code": "kimi-code";
35
+ pi: "pi";
36
+ prime: "prime";
37
+ gemini: "gemini";
38
+ hermes: "hermes";
39
+ openclaw: "openclaw";
40
+ amp: "amp";
41
+ "factory-droids": "factory-droids";
42
+ forge: "forge";
43
+ cursor: "cursor";
44
+ acp: "acp";
45
+ "cli-base": "cli-base";
46
+ }>;
47
+ startedAt: z.ZodISODateTime;
48
+ }, z.core.$strict>;
49
+ export type AgentInteractiveSessionRef = z.infer<typeof AgentInteractiveSessionRefSchema>;
50
+ /** Start one native coding-agent TUI for an already admitted run. */
51
+ export declare const AgentInteractiveSessionStartSchema: z.ZodObject<{
52
+ run: z.ZodObject<{
53
+ runId: z.ZodString;
54
+ provider: z.ZodString;
55
+ environmentId: z.ZodString;
56
+ sessionId: z.ZodString;
57
+ executionId: z.ZodString;
58
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
59
+ }, z.core.$strict>;
60
+ profile: z.ZodObject<{
61
+ name: z.ZodOptional<z.ZodString>;
62
+ description: z.ZodOptional<z.ZodString>;
63
+ version: z.ZodOptional<z.ZodString>;
64
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
+ prompt: z.ZodOptional<z.ZodObject<{
66
+ systemPrompt: z.ZodOptional<z.ZodString>;
67
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
68
+ instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
+ }, z.core.$strict>>;
70
+ model: z.ZodOptional<z.ZodObject<{
71
+ default: z.ZodOptional<z.ZodString>;
72
+ small: z.ZodOptional<z.ZodString>;
73
+ provider: z.ZodOptional<z.ZodString>;
74
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
75
+ none: "none";
76
+ minimal: "minimal";
77
+ low: "low";
78
+ medium: "medium";
79
+ high: "high";
80
+ xhigh: "xhigh";
81
+ ultracode: "ultracode";
82
+ }>>;
83
+ maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
84
+ maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
85
+ maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
86
+ metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
87
+ }, z.core.$strict>>;
88
+ harness: z.ZodOptional<z.ZodEnum<{
89
+ "claude-code": "claude-code";
90
+ nanoclaw: "nanoclaw";
91
+ codex: "codex";
92
+ opencode: "opencode";
93
+ "kimi-code": "kimi-code";
94
+ pi: "pi";
95
+ prime: "prime";
96
+ gemini: "gemini";
97
+ hermes: "hermes";
98
+ openclaw: "openclaw";
99
+ amp: "amp";
100
+ "factory-droids": "factory-droids";
101
+ forge: "forge";
102
+ cursor: "cursor";
103
+ acp: "acp";
104
+ "cli-base": "cli-base";
105
+ }>>;
106
+ permissions: z.ZodOptional<z.ZodType<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown, z.core.$ZodTypeInternals<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown>>>;
107
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
108
+ mcp: z.ZodOptional<z.ZodType<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown, z.core.$ZodTypeInternals<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown>>>;
109
+ connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ connectionId: z.ZodString;
111
+ capabilities: z.ZodArray<z.ZodString>;
112
+ alias: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strict>>>;
114
+ subagents: z.ZodOptional<z.ZodType<Record<string, {
115
+ description?: string | undefined;
116
+ prompt?: string | undefined;
117
+ model?: string | undefined;
118
+ tools?: Record<string, boolean> | undefined;
119
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
120
+ maxSteps?: number | undefined;
121
+ metadata?: Record<string, unknown> | undefined;
122
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
123
+ description?: string | undefined;
124
+ prompt?: string | undefined;
125
+ model?: string | undefined;
126
+ tools?: Record<string, boolean> | undefined;
127
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
128
+ maxSteps?: number | undefined;
129
+ metadata?: Record<string, unknown> | undefined;
130
+ }>, unknown>>>;
131
+ resources: z.ZodOptional<z.ZodObject<{
132
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
+ path: z.ZodString;
134
+ resource: z.ZodUnion<readonly [z.ZodObject<{
135
+ kind: z.ZodLiteral<"inline">;
136
+ name: z.ZodString;
137
+ content: z.ZodString;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ kind: z.ZodLiteral<"github">;
140
+ repository: z.ZodOptional<z.ZodString>;
141
+ path: z.ZodString;
142
+ ref: z.ZodOptional<z.ZodString>;
143
+ name: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$strict>]>;
145
+ executable: z.ZodOptional<z.ZodBoolean>;
146
+ }, z.core.$strict>>>;
147
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
148
+ kind: z.ZodLiteral<"inline">;
149
+ name: z.ZodString;
150
+ content: z.ZodString;
151
+ }, z.core.$strict>, z.ZodObject<{
152
+ kind: z.ZodLiteral<"github">;
153
+ repository: z.ZodOptional<z.ZodString>;
154
+ path: z.ZodString;
155
+ ref: z.ZodOptional<z.ZodString>;
156
+ name: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strict>]>>>;
158
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
159
+ kind: z.ZodLiteral<"inline">;
160
+ name: z.ZodString;
161
+ content: z.ZodString;
162
+ }, z.core.$strict>, z.ZodObject<{
163
+ kind: z.ZodLiteral<"github">;
164
+ repository: z.ZodOptional<z.ZodString>;
165
+ path: z.ZodString;
166
+ ref: z.ZodOptional<z.ZodString>;
167
+ name: z.ZodOptional<z.ZodString>;
168
+ }, z.core.$strict>]>>>;
169
+ agents: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
170
+ kind: z.ZodLiteral<"inline">;
171
+ name: z.ZodString;
172
+ content: z.ZodString;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ kind: z.ZodLiteral<"github">;
175
+ repository: z.ZodOptional<z.ZodString>;
176
+ path: z.ZodString;
177
+ ref: z.ZodOptional<z.ZodString>;
178
+ name: z.ZodOptional<z.ZodString>;
179
+ }, z.core.$strict>]>>>;
180
+ commands: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
181
+ kind: z.ZodLiteral<"inline">;
182
+ name: z.ZodString;
183
+ content: z.ZodString;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ kind: z.ZodLiteral<"github">;
186
+ repository: z.ZodOptional<z.ZodString>;
187
+ path: z.ZodString;
188
+ ref: z.ZodOptional<z.ZodString>;
189
+ name: z.ZodOptional<z.ZodString>;
190
+ }, z.core.$strict>]>>>;
191
+ instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
192
+ kind: z.ZodLiteral<"inline">;
193
+ name: z.ZodString;
194
+ content: z.ZodString;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ kind: z.ZodLiteral<"github">;
197
+ repository: z.ZodOptional<z.ZodString>;
198
+ path: z.ZodString;
199
+ ref: z.ZodOptional<z.ZodString>;
200
+ name: z.ZodOptional<z.ZodString>;
201
+ }, z.core.$strict>]>]>>;
202
+ failOnError: z.ZodOptional<z.ZodBoolean>;
203
+ }, z.core.$strict>>;
204
+ hooks: z.ZodOptional<z.ZodType<Record<string, {
205
+ command: string;
206
+ timeoutMs?: number | undefined;
207
+ blocking?: boolean | undefined;
208
+ matcher?: string | undefined;
209
+ env?: Record<string, {
210
+ kind: "public";
211
+ value: string;
212
+ } | {
213
+ kind: "secret-ref";
214
+ key: string;
215
+ format?: "raw" | "bearer" | undefined;
216
+ }> | undefined;
217
+ }[]>, unknown, z.core.$ZodTypeInternals<Record<string, {
218
+ command: string;
219
+ timeoutMs?: number | undefined;
220
+ blocking?: boolean | undefined;
221
+ matcher?: string | undefined;
222
+ env?: Record<string, {
223
+ kind: "public";
224
+ value: string;
225
+ } | {
226
+ kind: "secret-ref";
227
+ key: string;
228
+ format?: "raw" | "bearer" | undefined;
229
+ }> | undefined;
230
+ }[]>, unknown>>>;
231
+ modes: z.ZodOptional<z.ZodType<Record<string, {
232
+ description?: string | undefined;
233
+ model?: string | undefined;
234
+ prompt?: string | undefined;
235
+ tools?: Record<string, boolean> | undefined;
236
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
237
+ metadata?: Record<string, unknown> | undefined;
238
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
239
+ description?: string | undefined;
240
+ model?: string | undefined;
241
+ prompt?: string | undefined;
242
+ tools?: Record<string, boolean> | undefined;
243
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
244
+ metadata?: Record<string, unknown> | undefined;
245
+ }>, unknown>>>;
246
+ confidential: z.ZodOptional<z.ZodObject<{
247
+ tee: z.ZodOptional<z.ZodString>;
248
+ attestationNonce: z.ZodOptional<z.ZodString>;
249
+ sealed: z.ZodOptional<z.ZodBoolean>;
250
+ attestationRefresh: z.ZodOptional<z.ZodBoolean>;
251
+ }, z.core.$strict>>;
252
+ metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
253
+ extensions: z.ZodOptional<z.ZodType<Record<string, Record<string, unknown> | undefined>, unknown, z.core.$ZodTypeInternals<Record<string, Record<string, unknown> | undefined>, unknown>>>;
254
+ }, z.core.$strict>;
255
+ requestedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
256
+ initialPrompt: z.ZodOptional<z.ZodString>;
257
+ cwd: z.ZodOptional<z.ZodString>;
258
+ cols: z.ZodOptional<z.ZodNumber>;
259
+ rows: z.ZodOptional<z.ZodNumber>;
260
+ }, z.core.$strict>;
261
+ export type AgentInteractiveSessionStart = z.infer<typeof AgentInteractiveSessionStartSchema>;
262
+ export type AgentInteractiveSessionStartInput = Omit<AgentInteractiveSessionStart, "run">;
263
+ /** Digest the exact process-start request independently of its derived run id. */
264
+ export declare function agentInteractiveSessionRequestDigest(coordinates: AgentInteractiveSessionRunCoordinates, input: AgentInteractiveSessionStartInput): `sha256:${string}`;
265
+ /** Mint the one exact run reference a provider must acknowledge for this start. */
266
+ export declare function agentInteractiveSessionRunRef(coordinates: AgentInteractiveSessionRunCoordinates, input: AgentInteractiveSessionStartInput): AgentExactRunControlRef;
267
+ /** Geometry for one attachment to the existing coding-agent TUI. */
268
+ export declare const AgentInteractiveSessionAttachSchema: z.ZodObject<{
269
+ cols: z.ZodOptional<z.ZodNumber>;
270
+ rows: z.ZodOptional<z.ZodNumber>;
271
+ }, z.core.$strict>;
272
+ export type AgentInteractiveSessionAttach = z.infer<typeof AgentInteractiveSessionAttachSchema>;
273
+ /** Provider-observed lifecycle of one native coding-agent TUI. */
274
+ export declare const AgentInteractiveSessionStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
275
+ state: z.ZodLiteral<"running">;
276
+ ref: z.ZodObject<{
277
+ run: z.ZodObject<{
278
+ runId: z.ZodString;
279
+ provider: z.ZodString;
280
+ environmentId: z.ZodString;
281
+ sessionId: z.ZodString;
282
+ executionId: z.ZodString;
283
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
284
+ }, z.core.$strict>;
285
+ requestedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
286
+ admittedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
287
+ incarnationId: z.ZodString;
288
+ harness: z.ZodEnum<{
289
+ "claude-code": "claude-code";
290
+ nanoclaw: "nanoclaw";
291
+ codex: "codex";
292
+ opencode: "opencode";
293
+ "kimi-code": "kimi-code";
294
+ pi: "pi";
295
+ prime: "prime";
296
+ gemini: "gemini";
297
+ hermes: "hermes";
298
+ openclaw: "openclaw";
299
+ amp: "amp";
300
+ "factory-droids": "factory-droids";
301
+ forge: "forge";
302
+ cursor: "cursor";
303
+ acp: "acp";
304
+ "cli-base": "cli-base";
305
+ }>;
306
+ startedAt: z.ZodISODateTime;
307
+ }, z.core.$strict>;
308
+ }, z.core.$strict>, z.ZodObject<{
309
+ state: z.ZodLiteral<"exited">;
310
+ ref: z.ZodObject<{
311
+ run: z.ZodObject<{
312
+ runId: z.ZodString;
313
+ provider: z.ZodString;
314
+ environmentId: z.ZodString;
315
+ sessionId: z.ZodString;
316
+ executionId: z.ZodString;
317
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
318
+ }, z.core.$strict>;
319
+ requestedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
320
+ admittedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
321
+ incarnationId: z.ZodString;
322
+ harness: z.ZodEnum<{
323
+ "claude-code": "claude-code";
324
+ nanoclaw: "nanoclaw";
325
+ codex: "codex";
326
+ opencode: "opencode";
327
+ "kimi-code": "kimi-code";
328
+ pi: "pi";
329
+ prime: "prime";
330
+ gemini: "gemini";
331
+ hermes: "hermes";
332
+ openclaw: "openclaw";
333
+ amp: "amp";
334
+ "factory-droids": "factory-droids";
335
+ forge: "forge";
336
+ cursor: "cursor";
337
+ acp: "acp";
338
+ "cli-base": "cli-base";
339
+ }>;
340
+ startedAt: z.ZodISODateTime;
341
+ }, z.core.$strict>;
342
+ endedAt: z.ZodISODateTime;
343
+ reason: z.ZodEnum<{
344
+ exited: "exited";
345
+ stopped: "stopped";
346
+ lost: "lost";
347
+ }>;
348
+ exitCode: z.ZodOptional<z.ZodNumber>;
349
+ exitSignal: z.ZodOptional<z.ZodString>;
350
+ }, z.core.$strict>, z.ZodObject<{
351
+ state: z.ZodLiteral<"unknown">;
352
+ ref: z.ZodObject<{
353
+ run: z.ZodObject<{
354
+ runId: z.ZodString;
355
+ provider: z.ZodString;
356
+ environmentId: z.ZodString;
357
+ sessionId: z.ZodString;
358
+ executionId: z.ZodString;
359
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
360
+ }, z.core.$strict>;
361
+ requestedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
362
+ admittedProfileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
363
+ incarnationId: z.ZodString;
364
+ harness: z.ZodEnum<{
365
+ "claude-code": "claude-code";
366
+ nanoclaw: "nanoclaw";
367
+ codex: "codex";
368
+ opencode: "opencode";
369
+ "kimi-code": "kimi-code";
370
+ pi: "pi";
371
+ prime: "prime";
372
+ gemini: "gemini";
373
+ hermes: "hermes";
374
+ openclaw: "openclaw";
375
+ amp: "amp";
376
+ "factory-droids": "factory-droids";
377
+ forge: "forge";
378
+ cursor: "cursor";
379
+ acp: "acp";
380
+ "cli-base": "cli-base";
381
+ }>;
382
+ startedAt: z.ZodISODateTime;
383
+ }, z.core.$strict>;
384
+ message: z.ZodString;
385
+ retryable: z.ZodBoolean;
386
+ }, z.core.$strict>], "state">;
387
+ export type AgentInteractiveSessionStatus = z.infer<typeof AgentInteractiveSessionStatusSchema>;
388
+ /**
389
+ * Exact native TUI selected for one run.
390
+ *
391
+ * `attach` reaches the existing process. It never creates a shell or starts a
392
+ * second coding-agent process. Detach and terminal close affect only the live
393
+ * socket; `stop` terminates the provider-owned coding-agent process.
394
+ */
395
+ export interface AgentInteractiveSession {
396
+ readonly ref: AgentInteractiveSessionRef;
397
+ status(options?: {
398
+ signal?: AbortSignal;
399
+ }): Promise<AgentInteractiveSessionStatus>;
400
+ attach(request?: AgentInteractiveSessionAttach, options?: {
401
+ signal?: AbortSignal;
402
+ }): Promise<AgentTerminalSession>;
403
+ sendPrompt?(prompt: string, options?: {
404
+ signal?: AbortSignal;
405
+ }): Promise<void>;
406
+ stop(options?: {
407
+ signal?: AbortSignal;
408
+ }): Promise<AgentInteractiveSessionStatus>;
409
+ }
410
+ /** Parse a start request and prove its profile identity before provider work. */
411
+ export declare function exactAgentInteractiveSessionStart(value: AgentInteractiveSessionStart): AgentInteractiveSessionStart;
412
+ /** Prove that a provider returned the exact run, profile, and runner requested. */
413
+ export declare function agentInteractiveSessionRefMatchesStart(request: AgentInteractiveSessionStart, ref: AgentInteractiveSessionRef): boolean;
414
+ /** Prove that a status belongs to the handle that requested it. */
415
+ export declare function agentInteractiveSessionStatusMatchesRef(ref: AgentInteractiveSessionRef, status: AgentInteractiveSessionStatus): boolean;
416
+ export {};
@@ -0,0 +1,159 @@
1
+ import { z } from "zod";
2
+ import { canonicalCandidateDigest, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
3
+ import { canonicalAgentProfileDigest } from "./agent-execution-preparation.js";
4
+ import { boundedIdentifierSchema, boundedStringSchema, } from "./contract-limits.js";
5
+ import { harnessTypeSchema } from "./harness.js";
6
+ import { agentProfileSchema } from "./profile-schema.js";
7
+ import { AgentExactRunControlRefSchema, } from "./runtime-control.js";
8
+ const INTERACTIVE_MAX_DIMENSION = 10_000;
9
+ const interactiveDimensionSchema = z
10
+ .number()
11
+ .int()
12
+ .positive()
13
+ .max(INTERACTIVE_MAX_DIMENSION);
14
+ const AgentInteractiveSessionRunCoordinatesSchema = z.strictObject({
15
+ provider: boundedIdentifierSchema,
16
+ environmentId: boundedIdentifierSchema,
17
+ sessionId: boundedIdentifierSchema,
18
+ executionId: boundedIdentifierSchema,
19
+ });
20
+ /**
21
+ * Durable identity of one coding-agent TUI.
22
+ *
23
+ * This reference identifies the exact admitted run and effective profile.
24
+ * It is not a generic shell id and cannot be used to create another process.
25
+ */
26
+ export const AgentInteractiveSessionRefSchema = z.strictObject({
27
+ run: AgentExactRunControlRefSchema,
28
+ /** Canonical digest of the AgentProfile submitted by the caller. */
29
+ requestedProfileDigest: sha256DigestSchema,
30
+ /** Canonical digest of the effective profile the provider admitted. */
31
+ admittedProfileDigest: sha256DigestSchema,
32
+ /** Provider-issued identity of this exact process incarnation. */
33
+ incarnationId: boundedIdentifierSchema,
34
+ harness: harnessTypeSchema,
35
+ startedAt: z.iso.datetime().max(64),
36
+ });
37
+ /** Start one native coding-agent TUI for an already admitted run. */
38
+ export const AgentInteractiveSessionStartSchema = z.strictObject({
39
+ run: AgentExactRunControlRefSchema,
40
+ profile: agentProfileSchema,
41
+ requestedProfileDigest: sha256DigestSchema,
42
+ initialPrompt: boundedStringSchema.optional(),
43
+ cwd: boundedStringSchema.min(1).optional(),
44
+ cols: interactiveDimensionSchema.optional(),
45
+ rows: interactiveDimensionSchema.optional(),
46
+ });
47
+ /** Digest the exact process-start request independently of its derived run id. */
48
+ export function agentInteractiveSessionRequestDigest(coordinates, input) {
49
+ const exactCoordinates = AgentInteractiveSessionRunCoordinatesSchema.parse(coordinates);
50
+ const exactInput = AgentInteractiveSessionStartSchema.omit({ run: true }).parse(input);
51
+ return canonicalCandidateDigest({
52
+ kind: "agent-interactive-session-start.v1",
53
+ run: exactCoordinates,
54
+ requestedProfileDigest: exactInput.requestedProfileDigest,
55
+ ...(exactInput.initialPrompt === undefined
56
+ ? {}
57
+ : { initialPrompt: exactInput.initialPrompt }),
58
+ ...(exactInput.cwd === undefined ? {} : { cwd: exactInput.cwd }),
59
+ ...(exactInput.cols === undefined ? {} : { cols: exactInput.cols }),
60
+ ...(exactInput.rows === undefined ? {} : { rows: exactInput.rows }),
61
+ });
62
+ }
63
+ /** Mint the one exact run reference a provider must acknowledge for this start. */
64
+ export function agentInteractiveSessionRunRef(coordinates, input) {
65
+ const exactCoordinates = AgentInteractiveSessionRunCoordinatesSchema.parse(coordinates);
66
+ const requestDigest = agentInteractiveSessionRequestDigest(exactCoordinates, input);
67
+ return AgentExactRunControlRefSchema.parse({
68
+ ...exactCoordinates,
69
+ runId: `interactive-run-${requestDigest.slice("sha256:".length)}`,
70
+ requestDigest,
71
+ });
72
+ }
73
+ /** Geometry for one attachment to the existing coding-agent TUI. */
74
+ export const AgentInteractiveSessionAttachSchema = z.strictObject({
75
+ cols: interactiveDimensionSchema.optional(),
76
+ rows: interactiveDimensionSchema.optional(),
77
+ });
78
+ /** Provider-observed lifecycle of one native coding-agent TUI. */
79
+ export const AgentInteractiveSessionStatusSchema = z.discriminatedUnion("state", [
80
+ z.strictObject({
81
+ state: z.literal("running"),
82
+ ref: AgentInteractiveSessionRefSchema,
83
+ }),
84
+ z.strictObject({
85
+ state: z.literal("exited"),
86
+ ref: AgentInteractiveSessionRefSchema,
87
+ endedAt: z.iso.datetime().max(64),
88
+ reason: z.enum(["exited", "stopped", "lost"]),
89
+ exitCode: z.number().int().optional(),
90
+ exitSignal: boundedStringSchema.min(1).optional(),
91
+ }),
92
+ z.strictObject({
93
+ state: z.literal("unknown"),
94
+ ref: AgentInteractiveSessionRefSchema,
95
+ message: boundedStringSchema.min(1),
96
+ retryable: z.boolean(),
97
+ }),
98
+ ]);
99
+ /** Parse a start request and prove its profile identity before provider work. */
100
+ export function exactAgentInteractiveSessionStart(value) {
101
+ const parsed = AgentInteractiveSessionStartSchema.parse(value);
102
+ if (parsed.profile.harness === undefined) {
103
+ throw new Error("interactive agent sessions require AgentProfile.harness");
104
+ }
105
+ const digest = canonicalAgentProfileDigest(parsed.profile);
106
+ if (digest !== parsed.requestedProfileDigest) {
107
+ throw new Error("interactive agent session requested profile digest does not match its profile");
108
+ }
109
+ const { run, ...input } = parsed;
110
+ const expectedRun = agentInteractiveSessionRunRef(runCoordinates(run), input);
111
+ if (!sameExactRun(run, expectedRun)) {
112
+ throw new Error("interactive agent session run identity does not match its start request");
113
+ }
114
+ return parsed;
115
+ }
116
+ /** Prove that a provider returned the exact run, profile, and runner requested. */
117
+ export function agentInteractiveSessionRefMatchesStart(request, ref) {
118
+ const parsedRequest = AgentInteractiveSessionStartSchema.safeParse(request);
119
+ const parsedRef = AgentInteractiveSessionRefSchema.safeParse(ref);
120
+ if (!parsedRequest.success || !parsedRef.success)
121
+ return false;
122
+ const harness = parsedRequest.data.profile.harness;
123
+ if (harness === undefined)
124
+ return false;
125
+ return (parsedRef.data.requestedProfileDigest ===
126
+ parsedRequest.data.requestedProfileDigest &&
127
+ parsedRef.data.harness === harness &&
128
+ sameExactRun(parsedRef.data.run, parsedRequest.data.run));
129
+ }
130
+ /** Prove that a status belongs to the handle that requested it. */
131
+ export function agentInteractiveSessionStatusMatchesRef(ref, status) {
132
+ const parsedRef = AgentInteractiveSessionRefSchema.safeParse(ref);
133
+ const parsedStatus = AgentInteractiveSessionStatusSchema.safeParse(status);
134
+ if (!parsedRef.success || !parsedStatus.success)
135
+ return false;
136
+ const observed = parsedStatus.data.ref;
137
+ return (observed.requestedProfileDigest === parsedRef.data.requestedProfileDigest &&
138
+ observed.admittedProfileDigest === parsedRef.data.admittedProfileDigest &&
139
+ observed.incarnationId === parsedRef.data.incarnationId &&
140
+ observed.harness === parsedRef.data.harness &&
141
+ observed.startedAt === parsedRef.data.startedAt &&
142
+ sameExactRun(observed.run, parsedRef.data.run));
143
+ }
144
+ function sameExactRun(left, right) {
145
+ return (left.runId === right.runId &&
146
+ left.provider === right.provider &&
147
+ left.environmentId === right.environmentId &&
148
+ left.sessionId === right.sessionId &&
149
+ left.executionId === right.executionId &&
150
+ left.requestDigest === right.requestDigest);
151
+ }
152
+ function runCoordinates(run) {
153
+ return {
154
+ provider: run.provider,
155
+ environmentId: run.environmentId,
156
+ sessionId: run.sessionId,
157
+ executionId: run.executionId,
158
+ };
159
+ }
@@ -107,8 +107,8 @@ export declare const AgentEnvironmentStatusSchema: z.ZodEnum<{
107
107
  expired: "expired";
108
108
  pending: "pending";
109
109
  running: "running";
110
- provisioning: "provisioning";
111
110
  stopped: "stopped";
111
+ provisioning: "provisioning";
112
112
  }>;
113
113
  /** Lifecycle, cleanup, continuity, and persistence of one environment. */
114
114
  export declare const EnvironmentLifecycleSchema: z.ZodObject<{
@@ -118,8 +118,8 @@ export declare const EnvironmentLifecycleSchema: z.ZodObject<{
118
118
  expired: "expired";
119
119
  pending: "pending";
120
120
  running: "running";
121
- provisioning: "provisioning";
122
121
  stopped: "stopped";
122
+ provisioning: "provisioning";
123
123
  }>;
124
124
  cleanup: z.ZodOptional<z.ZodObject<{
125
125
  policy: z.ZodOptional<z.ZodEnum<{
@@ -135,8 +135,8 @@ export declare const EnvironmentLifecycleSchema: z.ZodObject<{
135
135
  resumable: z.ZodBoolean;
136
136
  mode: z.ZodOptional<z.ZodEnum<{
137
137
  none: "none";
138
- native: "native";
139
138
  replayed: "replayed";
139
+ native: "native";
140
140
  }>>;
141
141
  }, z.core.$strict>>;
142
142
  persistence: z.ZodOptional<z.ZodObject<{
@@ -443,8 +443,8 @@ export declare const AgentEnvironmentObservationSchema: z.ZodObject<{
443
443
  expired: "expired";
444
444
  pending: "pending";
445
445
  running: "running";
446
- provisioning: "provisioning";
447
446
  stopped: "stopped";
447
+ provisioning: "provisioning";
448
448
  }>;
449
449
  cleanup: z.ZodOptional<z.ZodObject<{
450
450
  policy: z.ZodOptional<z.ZodEnum<{
@@ -460,8 +460,8 @@ export declare const AgentEnvironmentObservationSchema: z.ZodObject<{
460
460
  resumable: z.ZodBoolean;
461
461
  mode: z.ZodOptional<z.ZodEnum<{
462
462
  none: "none";
463
- native: "native";
464
463
  replayed: "replayed";
464
+ native: "native";
465
465
  }>>;
466
466
  }, z.core.$strict>>;
467
467
  persistence: z.ZodOptional<z.ZodObject<{
@@ -491,8 +491,8 @@ export declare const AgentEnvironmentObservationSchema: z.ZodObject<{
491
491
  expired: "expired";
492
492
  pending: "pending";
493
493
  running: "running";
494
- provisioning: "provisioning";
495
494
  stopped: "stopped";
495
+ provisioning: "provisioning";
496
496
  }>;
497
497
  cleanup: z.ZodOptional<z.ZodObject<{
498
498
  policy: z.ZodOptional<z.ZodEnum<{
@@ -508,8 +508,8 @@ export declare const AgentEnvironmentObservationSchema: z.ZodObject<{
508
508
  resumable: z.ZodBoolean;
509
509
  mode: z.ZodOptional<z.ZodEnum<{
510
510
  none: "none";
511
- native: "native";
512
511
  replayed: "replayed";
512
+ native: "native";
513
513
  }>>;
514
514
  }, z.core.$strict>>;
515
515
  persistence: z.ZodOptional<z.ZodObject<{
@@ -1,5 +1,6 @@
1
1
  export * from "./environment-requests.js";
2
2
  export * from "./environment-exact-process.js";
3
+ export * from "./environment-interactive.js";
3
4
  export * from "./environment-observation.js";
4
5
  export * from "./environment-terminal.js";
5
6
  export * from "./environment-runtime.js";
@@ -1,5 +1,6 @@
1
1
  export * from "./environment-requests.js";
2
2
  export * from "./environment-exact-process.js";
3
+ export * from "./environment-interactive.js";
3
4
  export * from "./environment-observation.js";
4
5
  export * from "./environment-terminal.js";
5
6
  export * from "./environment-runtime.js";
@@ -10,6 +10,7 @@ import type { AgentWorkspaceBranching } from "./workspace-branching.js";
10
10
  import type { AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSessionStatus, CheckpointRef, CheckpointRequest, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from "./environment-requests.js";
11
11
  import type { AgentExactProcessEgressMode, AgentExactProcessProvider } from "./environment-exact-process.js";
12
12
  import type { AgentEnvironmentObservation } from "./environment-observation.js";
13
+ import type { AgentInteractiveSession, AgentInteractiveSessionRef, AgentInteractiveSessionStart } from "./environment-interactive.js";
13
14
  import type { AgentTerminalSession, TerminalAttachRequest, TerminalAttachResult } from "./environment-terminal.js";
14
15
  export interface AgentTurnInput {
15
16
  prompt?: string;
@@ -688,6 +689,12 @@ export interface AgentEnvironment {
688
689
  terminal?(terminalSessionId: string, options?: {
689
690
  signal?: AbortSignal;
690
691
  }): AgentTerminalSession;
692
+ /** Start one native coding-agent TUI bound to an exact admitted run. */
693
+ startInteractive?(request: AgentInteractiveSessionStart, options?: {
694
+ signal?: AbortSignal;
695
+ }): Promise<AgentInteractiveSessionRef>;
696
+ /** Reconstruct the exact native coding-agent TUI named by a durable reference. */
697
+ interactive?(ref: AgentInteractiveSessionRef): AgentInteractiveSession;
691
698
  refresh?(options?: {
692
699
  signal?: AbortSignal;
693
700
  }): Promise<void>;
@@ -766,6 +773,17 @@ export interface AgentEnvironmentCapabilities {
766
773
  resize: boolean;
767
774
  reattach: boolean;
768
775
  };
776
+ /** Present only when the provider can start and rediscover exact agent TUIs. */
777
+ interactiveAgent?: {
778
+ start: boolean;
779
+ status: boolean;
780
+ attach: boolean;
781
+ reattach: boolean;
782
+ sendPrompt: boolean;
783
+ input: boolean;
784
+ resize: boolean;
785
+ stop: boolean;
786
+ };
769
787
  }
770
788
  /** Strict runtime validator for provider capability negotiation. */
771
789
  export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
@@ -875,6 +893,16 @@ export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
875
893
  resize: z.ZodBoolean;
876
894
  reattach: z.ZodBoolean;
877
895
  }, z.core.$strict>>;
896
+ interactiveAgent: z.ZodOptional<z.ZodObject<{
897
+ start: z.ZodBoolean;
898
+ status: z.ZodBoolean;
899
+ attach: z.ZodBoolean;
900
+ reattach: z.ZodBoolean;
901
+ sendPrompt: z.ZodBoolean;
902
+ input: z.ZodBoolean;
903
+ resize: z.ZodBoolean;
904
+ stop: z.ZodBoolean;
905
+ }, z.core.$strict>>;
878
906
  }, z.core.$strict>;
879
907
  export interface CreateAgentEnvironmentInput {
880
908
  profile: AgentProfileRef;
@@ -189,6 +189,18 @@ export const AgentEnvironmentCapabilitiesSchema = z
189
189
  reattach: z.boolean(),
190
190
  })
191
191
  .optional(),
192
+ interactiveAgent: z
193
+ .strictObject({
194
+ start: z.boolean(),
195
+ status: z.boolean(),
196
+ attach: z.boolean(),
197
+ reattach: z.boolean(),
198
+ sendPrompt: z.boolean(),
199
+ input: z.boolean(),
200
+ resize: z.boolean(),
201
+ stop: z.boolean(),
202
+ })
203
+ .optional(),
192
204
  })
193
205
  .superRefine((capabilities, refinement) => {
194
206
  if (capabilities.retainedControl !== undefined &&
@@ -249,6 +261,31 @@ export const AgentEnvironmentCapabilitiesSchema = z
249
261
  message: "interactive terminal input, resize, and reattach each require attach",
250
262
  });
251
263
  }
264
+ const interactiveAgent = capabilities.interactiveAgent;
265
+ if (interactiveAgent !== undefined &&
266
+ (interactiveAgent.status ||
267
+ interactiveAgent.attach ||
268
+ interactiveAgent.reattach ||
269
+ interactiveAgent.sendPrompt ||
270
+ interactiveAgent.input ||
271
+ interactiveAgent.resize ||
272
+ interactiveAgent.stop) &&
273
+ !interactiveAgent.start) {
274
+ refinement.addIssue({
275
+ code: "custom",
276
+ path: ["interactiveAgent"],
277
+ message: "interactive agent status, attach, reattach, sendPrompt, input, resize, and stop each require start",
278
+ });
279
+ }
280
+ if (interactiveAgent !== undefined &&
281
+ (interactiveAgent.reattach || interactiveAgent.input || interactiveAgent.resize) &&
282
+ !interactiveAgent.attach) {
283
+ refinement.addIssue({
284
+ code: "custom",
285
+ path: ["interactiveAgent"],
286
+ message: "interactive agent reattach, input, and resize each require attach",
287
+ });
288
+ }
252
289
  const extensions = capabilities.profile.extensions;
253
290
  if (extensions && new Set(extensions).size !== extensions.length) {
254
291
  refinement.addIssue({
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export * from "./host-services.js";
8
8
  export * from "./mcp.js";
9
9
  export * from "./provider-adapter.js";
10
10
  export type * from "./environment-provider.js";
11
- export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
11
+ export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
12
12
  export * from "./plan.js";
13
13
  export * from "./runtime-control.js";
14
14
  export * from "./portable-context.js";
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export * from "./provider-config.js";
7
7
  export * from "./host-services.js";
8
8
  export * from "./mcp.js";
9
9
  export * from "./provider-adapter.js";
10
- export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
10
+ export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
11
11
  export * from "./plan.js";
12
12
  export * from "./runtime-control.js";
13
13
  export * from "./portable-context.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "0.54.0",
3
+ "version": "0.55.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",