@tangle-network/agent-interface 0.45.0 → 0.46.1

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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-candidate-profile-schema.d.ts +2 -2
  3. package/dist/agent-candidate-promotion-schema.d.ts +22 -22
  4. package/dist/agent-candidate-schema-common.js +1 -1
  5. package/dist/agent-candidate-schema.d.ts +2 -2
  6. package/dist/agent-execution-preparation.d.ts +26 -26
  7. package/dist/agent-profile.d.ts +10 -3
  8. package/dist/agent-profile.js +45 -22
  9. package/dist/backend-message.d.ts +14 -0
  10. package/dist/backend-message.js +1 -0
  11. package/dist/contract-limits.d.ts +26 -0
  12. package/dist/contract-limits.js +175 -0
  13. package/dist/environment-exact-process.d.ts +161 -0
  14. package/dist/environment-exact-process.js +1 -0
  15. package/dist/environment-profile-capabilities.d.ts +26 -0
  16. package/dist/environment-profile-capabilities.js +34 -0
  17. package/dist/environment-provider.d.ts +3 -730
  18. package/dist/environment-provider.js +3 -245
  19. package/dist/environment-requests.d.ts +70 -0
  20. package/dist/environment-requests.js +1 -0
  21. package/dist/environment-runtime.d.ts +834 -0
  22. package/dist/environment-runtime.js +228 -0
  23. package/dist/execution-types.d.ts +50 -0
  24. package/dist/execution-types.js +1 -0
  25. package/dist/host-services.d.ts +91 -0
  26. package/dist/host-services.js +1 -0
  27. package/dist/index.d.ts +10 -617
  28. package/dist/index.js +10 -125
  29. package/dist/interaction-answer-validation.d.ts +13 -0
  30. package/dist/interaction-answer-validation.js +149 -0
  31. package/dist/interaction-data.d.ts +22 -0
  32. package/dist/interaction-data.js +46 -0
  33. package/dist/interaction-envelope.d.ts +267 -0
  34. package/dist/interaction-envelope.js +247 -0
  35. package/dist/interaction-fields.d.ts +130 -0
  36. package/dist/interaction-fields.js +227 -0
  37. package/dist/interaction-permissions.d.ts +28 -0
  38. package/dist/interaction-permissions.js +57 -0
  39. package/dist/interaction-resolution-validation.d.ts +9 -0
  40. package/dist/interaction-resolution-validation.js +50 -0
  41. package/dist/interaction-response-validation.d.ts +17 -0
  42. package/dist/interaction-response-validation.js +102 -0
  43. package/dist/interaction.d.ts +6 -397
  44. package/dist/interaction.js +6 -603
  45. package/dist/mcp.d.ts +38 -0
  46. package/dist/mcp.js +1 -0
  47. package/dist/parts.d.ts +104 -0
  48. package/dist/parts.js +55 -0
  49. package/dist/portable-context-base.d.ts +82 -0
  50. package/dist/portable-context-base.js +63 -0
  51. package/dist/portable-context-continuation.d.ts +168 -0
  52. package/dist/portable-context-continuation.js +194 -0
  53. package/dist/portable-context-plan-request.d.ts +86 -0
  54. package/dist/portable-context-plan-request.js +102 -0
  55. package/dist/portable-context-plan.d.ts +229 -0
  56. package/dist/portable-context-plan.js +241 -0
  57. package/dist/portable-context-shared.d.ts +36 -0
  58. package/dist/portable-context-shared.js +46 -0
  59. package/dist/portable-context-transfer.d.ts +319 -0
  60. package/dist/portable-context-transfer.js +206 -0
  61. package/dist/portable-context.d.ts +5 -753
  62. package/dist/portable-context.js +5 -754
  63. package/dist/profile-diff.js +56 -47
  64. package/dist/provider-adapter.d.ts +45 -0
  65. package/dist/provider-adapter.js +1 -0
  66. package/dist/provider-config.d.ts +58 -0
  67. package/dist/provider-config.js +42 -0
  68. package/dist/runtime-control.d.ts +87 -10
  69. package/dist/runtime-control.js +159 -38
  70. package/dist/stream-events.d.ts +55 -0
  71. package/dist/stream-events.js +1 -0
  72. package/dist/workspace-branching-shared.d.ts +7 -0
  73. package/dist/workspace-branching-shared.js +20 -0
  74. package/dist/workspace-branching.d.ts +4 -254
  75. package/dist/workspace-branching.js +4 -400
  76. package/dist/workspace-checkpoint.d.ts +99 -0
  77. package/dist/workspace-checkpoint.js +169 -0
  78. package/dist/workspace-cleanup.d.ts +85 -0
  79. package/dist/workspace-cleanup.js +156 -0
  80. package/dist/workspace-confidentiality.d.ts +59 -0
  81. package/dist/workspace-confidentiality.js +123 -0
  82. package/dist/workspace-fork.d.ts +182 -0
  83. package/dist/workspace-fork.js +267 -0
  84. package/package.json +1 -1
@@ -1,245 +1,3 @@
1
- import { z } from "zod";
2
- import { InteractionCapabilitiesSchema, } from "./interaction.js";
3
- /*
4
- * Keep the provider contract runtime-validatable. Provider capability data is
5
- * commonly read from a remote service or adapter configuration, so its static
6
- * TypeScript type is not a trust boundary.
7
- */
8
- const AgentProfileCapabilitiesSchema = z.strictObject({
9
- namedProfiles: z.boolean(),
10
- /*
11
- * Both bits are required with no default: a document that omits either one,
12
- * or sends a bare boolean, fails validation instead of being read as
13
- * replacement-supported, which for every append-only backend is false.
14
- */
15
- systemPrompt: z.strictObject({
16
- replace: z.boolean(),
17
- append: z.boolean(),
18
- }),
19
- instructions: z.boolean(),
20
- tools: z.boolean(),
21
- permissions: z.boolean(),
22
- mcp: z.boolean(),
23
- subagents: z.boolean(),
24
- resources: z.strictObject({
25
- files: z.boolean(),
26
- instructions: z.boolean(),
27
- tools: z.boolean().optional(),
28
- skills: z.boolean().optional(),
29
- agents: z.boolean().optional(),
30
- commands: z.boolean().optional(),
31
- }),
32
- hooks: z.boolean().optional(),
33
- modes: z.boolean().optional(),
34
- runtimeUpdate: z.boolean(),
35
- validation: z.boolean(),
36
- extensions: z.array(z.string().min(1)).optional(),
37
- });
38
- import { ContextTransferReceiptSchema, NativeContextContinuationAcknowledgementSchema, NativeContextContinuationRequestSchema, nativeContextContinuationAcknowledgementMatches, } from "./portable-context.js";
39
- import { AgentRunControlRefSchema, CanonicalStreamEventSchema, } from "./runtime-control.js";
40
- const TokenUsageSchema = z.strictObject({
41
- inputTokens: z.number().int().nonnegative(),
42
- outputTokens: z.number().int().nonnegative(),
43
- totalTokens: z.number().int().nonnegative().optional(),
44
- cacheReadInputTokens: z.number().int().nonnegative().optional(),
45
- cacheCreationInputTokens: z.number().int().nonnegative().optional(),
46
- reasoningTokens: z.number().int().nonnegative().optional(),
47
- cost: z.number().finite().nonnegative().optional(),
48
- });
49
- const AgentEnvironmentEventSchema = z.strictObject({
50
- type: z.string().min(1),
51
- data: z.record(z.string(), z.unknown()),
52
- id: z.string().min(1).optional(),
53
- normalized: CanonicalStreamEventSchema.optional(),
54
- usage: TokenUsageSchema.optional(),
55
- providerEvent: z.unknown().optional(),
56
- });
57
- /** Runtime validator for a provider turn returned from durable continuation. */
58
- export const AgentTurnResultSchema = z.strictObject({
59
- text: z.string(),
60
- success: z.boolean(),
61
- error: z.string().optional(),
62
- sessionId: z.string().min(1).optional(),
63
- usage: TokenUsageSchema.optional(),
64
- metadata: z.record(z.string(), z.unknown()).optional(),
65
- events: z.array(AgentEnvironmentEventSchema).optional(),
66
- contextTransferReceipt: ContextTransferReceiptSchema.optional(),
67
- });
68
- /** Durable provider result for one digest-bound native continuation operation. */
69
- export const AgentNativeContextContinuationResultSchema = z.union([
70
- z
71
- .strictObject({
72
- acknowledgement: NativeContextContinuationAcknowledgementSchema.and(z.object({ status: z.enum(["accepted", "replayed"]) })),
73
- result: AgentTurnResultSchema,
74
- /** Exact provider coordinates after the continuation completed. */
75
- controlRef: AgentRunControlRefSchema,
76
- })
77
- .superRefine((outcome, refinement) => {
78
- if (outcome.result.contextTransferReceipt !== undefined) {
79
- refinement.addIssue({
80
- code: "custom",
81
- path: ["result", "contextTransferReceipt"],
82
- message: "native continuation cannot return a context transfer receipt",
83
- });
84
- }
85
- }),
86
- z
87
- .strictObject({
88
- acknowledgement: NativeContextContinuationAcknowledgementSchema.and(z.object({
89
- status: z.enum([
90
- "conflict",
91
- "boundary_mismatch",
92
- "unverified",
93
- "unknown_session",
94
- "transport_failure",
95
- ]),
96
- })),
97
- })
98
- .superRefine((outcome, refinement) => {
99
- if (outcome.acknowledgement.status === "transport_failure" &&
100
- outcome.acknowledgement.retryable !== true) {
101
- refinement.addIssue({
102
- code: "custom",
103
- path: ["acknowledgement", "retryable"],
104
- message: "a durable native continuation transport failure must be retryable",
105
- });
106
- }
107
- }),
108
- ]);
109
- /** Cross-check a successful result against its exact request and retained session. */
110
- export function agentNativeContextContinuationResultMatchesRequest(request, outcome) {
111
- const parsedRequest = NativeContextContinuationRequestSchema.safeParse(request);
112
- const parsedOutcome = AgentNativeContextContinuationResultSchema.safeParse(outcome);
113
- if (!parsedRequest.success || !parsedOutcome.success)
114
- return false;
115
- const exactOutcome = parsedOutcome.data;
116
- if (exactOutcome.acknowledgement.status !== "accepted" &&
117
- exactOutcome.acknowledgement.status !== "replayed") {
118
- return false;
119
- }
120
- if (!("result" in exactOutcome) || !("controlRef" in exactOutcome)) {
121
- return false;
122
- }
123
- if (!nativeContextContinuationAcknowledgementMatches(parsedRequest.data, exactOutcome.acknowledgement)) {
124
- return false;
125
- }
126
- const source = parsedRequest.data.run;
127
- const current = exactOutcome.controlRef;
128
- return (current.provider === source.provider &&
129
- current.environmentId === source.environmentId &&
130
- current.sessionId === source.sessionId &&
131
- (exactOutcome.result.sessionId === undefined ||
132
- exactOutcome.result.sessionId === current.sessionId));
133
- }
134
- /** Strict runtime validator for provider capability negotiation. */
135
- export const AgentEnvironmentCapabilitiesSchema = z
136
- .strictObject({
137
- profile: AgentProfileCapabilitiesSchema,
138
- streaming: z.strictObject({
139
- live: z.boolean(),
140
- replay: z.boolean(),
141
- detach: z.boolean(),
142
- turnIdempotency: z.boolean(),
143
- }),
144
- sessions: z.strictObject({
145
- continue: z.boolean(),
146
- list: z.boolean(),
147
- messages: z.boolean(),
148
- }),
149
- retainedControl: z
150
- .strictObject({
151
- exactRunIdentity: z.boolean(),
152
- resultIdentity: z.boolean(),
153
- eventIdentity: z.boolean(),
154
- cancellationIdempotency: z.boolean(),
155
- })
156
- .optional(),
157
- nativeContinuation: z
158
- .strictObject({
159
- atomicBoundary: z.boolean(),
160
- requestIdempotency: z.boolean(),
161
- })
162
- .optional(),
163
- interactions: InteractionCapabilitiesSchema.optional(),
164
- workspace: z.strictObject({
165
- read: z.boolean(),
166
- write: z.boolean(),
167
- exec: z.boolean(),
168
- git: z.boolean(),
169
- upload: z.boolean(),
170
- download: z.boolean(),
171
- }),
172
- branching: z.strictObject({
173
- checkpoint: z.boolean(),
174
- fork: z.boolean(),
175
- retrySafe: z.boolean().optional(),
176
- lookup: z.boolean().optional(),
177
- cleanup: z.boolean().optional(),
178
- }),
179
- placement: z.boolean(),
180
- usage: z.boolean(),
181
- confidential: z.boolean(),
182
- exactProcess: z
183
- .strictObject({
184
- egress: z.array(z.enum(["blocked", "strict"])).min(1),
185
- })
186
- .optional(),
187
- })
188
- .superRefine((capabilities, refinement) => {
189
- if (capabilities.retainedControl !== undefined &&
190
- (!capabilities.retainedControl.exactRunIdentity ||
191
- !capabilities.retainedControl.resultIdentity ||
192
- !capabilities.retainedControl.eventIdentity ||
193
- !capabilities.retainedControl.cancellationIdempotency ||
194
- !capabilities.streaming.replay ||
195
- !capabilities.streaming.detach ||
196
- !capabilities.streaming.turnIdempotency ||
197
- !capabilities.sessions.continue)) {
198
- refinement.addIssue({
199
- code: "custom",
200
- path: ["retainedControl"],
201
- message: "retained control requires exact run, result, event, cancellation, replay, detach, turn, and session identity together",
202
- });
203
- }
204
- if (capabilities.nativeContinuation !== undefined &&
205
- (!capabilities.nativeContinuation.atomicBoundary ||
206
- !capabilities.nativeContinuation.requestIdempotency ||
207
- !capabilities.sessions.continue)) {
208
- refinement.addIssue({
209
- code: "custom",
210
- path: ["nativeContinuation"],
211
- message: "native continuation requires session continuation, atomic boundary admission, and request idempotency together",
212
- });
213
- }
214
- const durableBranching = [
215
- capabilities.branching.retrySafe ?? false,
216
- capabilities.branching.lookup ?? false,
217
- capabilities.branching.cleanup ?? false,
218
- ];
219
- if (durableBranching.some(Boolean) &&
220
- (!durableBranching.every(Boolean) ||
221
- !capabilities.branching.checkpoint ||
222
- !capabilities.branching.fork)) {
223
- refinement.addIssue({
224
- code: "custom",
225
- path: ["branching"],
226
- message: "retry-safe branching requires checkpoint, fork, lookup, and cleanup together",
227
- });
228
- }
229
- const egress = capabilities.exactProcess?.egress;
230
- if (egress && new Set(egress).size !== egress.length) {
231
- refinement.addIssue({
232
- code: "custom",
233
- path: ["exactProcess", "egress"],
234
- message: "exact process egress modes must be unique",
235
- });
236
- }
237
- const extensions = capabilities.profile.extensions;
238
- if (extensions && new Set(extensions).size !== extensions.length) {
239
- refinement.addIssue({
240
- code: "custom",
241
- path: ["profile", "extensions"],
242
- message: "profile extension namespaces must be unique",
243
- });
244
- }
245
- });
1
+ export * from "./environment-requests.js";
2
+ export * from "./environment-exact-process.js";
3
+ export * from "./environment-runtime.js";
@@ -0,0 +1,70 @@
1
+ import type { AgentProfile } from "./agent-profile.js";
2
+ /** Portable profile reference: inline profile or provider catalog id. */
3
+ export type AgentProfileRef = AgentProfile | string;
4
+ export type AgentEnvironmentStatus = "pending" | "provisioning" | "running" | "stopped" | "failed" | "expired" | "unknown";
5
+ export type AgentSessionStatus = AgentEnvironmentStatus | "completed" | "cancelled";
6
+ export interface WorkspaceRequest {
7
+ /** Provider-specific environment/template id, for example "universal". */
8
+ environment?: string;
9
+ /** Container image or image alias when the provider supports image-backed workspaces. */
10
+ image?: string;
11
+ /** Repository to clone or mount before the agent runs. */
12
+ repoUrl?: string;
13
+ /** Git ref for {@link repoUrl}. */
14
+ gitRef?: string;
15
+ /** Initial working directory inside the environment. */
16
+ cwd?: string;
17
+ /** Opaque provider-native workspace fields. */
18
+ providerOptions?: Record<string, unknown>;
19
+ }
20
+ export interface ResourceRequest {
21
+ cpu?: number;
22
+ memoryMb?: number;
23
+ diskMb?: number;
24
+ gpu?: string;
25
+ providerOptions?: Record<string, unknown>;
26
+ }
27
+ export interface AgentEnvironmentQuery {
28
+ name?: string;
29
+ metadata?: Record<string, unknown>;
30
+ providerOptions?: Record<string, unknown>;
31
+ }
32
+ export interface AgentEnvironmentSummary {
33
+ id: string;
34
+ provider: string;
35
+ name?: string;
36
+ status?: AgentEnvironmentStatus;
37
+ metadata?: Record<string, unknown>;
38
+ }
39
+ export interface ExecRequest {
40
+ cwd?: string;
41
+ env?: Record<string, string>;
42
+ timeoutMs?: number;
43
+ signal?: AbortSignal;
44
+ }
45
+ export interface ExecResult {
46
+ exitCode: number;
47
+ stdout: string;
48
+ stderr: string;
49
+ }
50
+ export interface CheckpointRequest {
51
+ name?: string;
52
+ metadata?: Record<string, unknown>;
53
+ }
54
+ export interface CheckpointRef {
55
+ id: string;
56
+ provider?: string;
57
+ metadata?: Record<string, unknown>;
58
+ }
59
+ export interface ForkRequest {
60
+ name?: string;
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+ export interface PlacementInfo {
64
+ kind: "local" | "sandbox" | "fleet" | "provider";
65
+ sandboxId?: string;
66
+ fleetId?: string;
67
+ machineId?: string;
68
+ region?: string;
69
+ providerMetadata?: Record<string, unknown>;
70
+ }
@@ -0,0 +1 @@
1
+ export {};