@tangle-network/agent-interface 2.3.0 → 2.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.
- package/README.md +7 -0
- package/dist/agent-execution-preparation-receipt.d.ts +6 -0
- package/dist/agent-profile-materialization.d.ts +2 -2
- package/dist/agent-profile-materialization.js +19 -26
- package/dist/environment-interactive-control.d.ts +30 -0
- package/dist/environment-runtime.d.ts +42 -4
- package/dist/environment-runtime.js +25 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime-attachments.d.ts +7 -0
- package/dist/runtime-attachments.js +15 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -228,3 +228,10 @@ An exhaustiveness check that assigns the remaining case to `never` fails when a
|
|
|
228
228
|
## License
|
|
229
229
|
|
|
230
230
|
MIT
|
|
231
|
+
|
|
232
|
+
`AgentEnvironmentEvent.usageMode` describes token usage within one turn.
|
|
233
|
+
`delta` contributes new usage; `cumulative` includes earlier contributions and replaces the prior turn total.
|
|
234
|
+
Repeated cumulative totals do not add spend.
|
|
235
|
+
An absent mode means the aggregation semantics are unknown.
|
|
236
|
+
Materialization receipts cover all three model token ceilings at their exact requested paths.
|
|
237
|
+
A strict profile rejects unsupported ceilings instead of silently accepting them.
|
|
@@ -111,6 +111,9 @@ export declare const agentExecutionPreparationAxisResultSchema: z.ZodObject<{
|
|
|
111
111
|
mcp: "mcp";
|
|
112
112
|
metadata: "metadata";
|
|
113
113
|
modelDefault: "modelDefault";
|
|
114
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
115
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
116
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
114
117
|
modelMetadata: "modelMetadata";
|
|
115
118
|
modelProvider: "modelProvider";
|
|
116
119
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -259,6 +262,9 @@ export declare const agentExecutionPreparationReceiptSchema: z.ZodObject<{
|
|
|
259
262
|
mcp: "mcp";
|
|
260
263
|
metadata: "metadata";
|
|
261
264
|
modelDefault: "modelDefault";
|
|
265
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
266
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
267
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
262
268
|
modelMetadata: "modelMetadata";
|
|
263
269
|
modelProvider: "modelProvider";
|
|
264
270
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentProfile } from "./agent-profile.js";
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
3
|
+
* The canonical AgentProfile leaves that can affect one execution.
|
|
4
4
|
*
|
|
5
5
|
* Compound parents such as `model`, `prompt`, and `resources` are deliberately
|
|
6
6
|
* absent. A producer must report the exact requested leaf instead of claiming
|
|
@@ -9,7 +9,7 @@ import type { AgentProfile } from "./agent-profile.js";
|
|
|
9
9
|
* can only add text must report the requested replacement as unsatisfied rather
|
|
10
10
|
* than acknowledge it.
|
|
11
11
|
*/
|
|
12
|
-
export declare const AGENT_PROFILE_MATERIALIZATION_AXES: readonly ["name", "description", "version", "tags", "systemPrompt", "appendSystemPrompt", "instructions", "modelDefault", "modelSmall", "modelProvider", "modelReasoningEffort", "modelMetadata", "harness", "permissions", "tools", "mcp", "connections", "subagents", "files", "resourceTools", "skills", "resourceAgents", "commands", "resourceInstructions", "resourceFailOnError", "hooks", "modes", "confidential", "metadata", "extensions"];
|
|
12
|
+
export declare const AGENT_PROFILE_MATERIALIZATION_AXES: readonly ["name", "description", "version", "tags", "systemPrompt", "appendSystemPrompt", "instructions", "modelDefault", "modelSmall", "modelProvider", "modelReasoningEffort", "modelMaxVisibleOutputTokens", "modelMaxReasoningTokens", "modelMaxTotalOutputTokens", "modelMetadata", "harness", "permissions", "tools", "mcp", "connections", "subagents", "files", "resourceTools", "skills", "resourceAgents", "commands", "resourceInstructions", "resourceFailOnError", "hooks", "modes", "confidential", "metadata", "extensions"];
|
|
13
13
|
/** One exact leaf of the public AgentProfile contract. */
|
|
14
14
|
export type AgentProfileMaterializationAxis = (typeof AGENT_PROFILE_MATERIALIZATION_AXES)[number];
|
|
15
15
|
/** Compatibility name used by runtimes that distinguish canonical axes. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The canonical AgentProfile leaves that can affect one execution.
|
|
3
3
|
*
|
|
4
4
|
* Compound parents such as `model`, `prompt`, and `resources` are deliberately
|
|
5
5
|
* absent. A producer must report the exact requested leaf instead of claiming
|
|
@@ -20,6 +20,9 @@ export const AGENT_PROFILE_MATERIALIZATION_AXES = [
|
|
|
20
20
|
"modelSmall",
|
|
21
21
|
"modelProvider",
|
|
22
22
|
"modelReasoningEffort",
|
|
23
|
+
"modelMaxVisibleOutputTokens",
|
|
24
|
+
"modelMaxReasoningTokens",
|
|
25
|
+
"modelMaxTotalOutputTokens",
|
|
23
26
|
"modelMetadata",
|
|
24
27
|
"harness",
|
|
25
28
|
"permissions",
|
|
@@ -58,6 +61,16 @@ const profileProperties = [
|
|
|
58
61
|
];
|
|
59
62
|
const profilePropertiesAreExhaustive = true;
|
|
60
63
|
void profilePropertiesAreExhaustive;
|
|
64
|
+
const MODEL_AXES = {
|
|
65
|
+
default: "modelDefault",
|
|
66
|
+
small: "modelSmall",
|
|
67
|
+
provider: "modelProvider",
|
|
68
|
+
reasoningEffort: "modelReasoningEffort",
|
|
69
|
+
maxVisibleOutputTokens: "modelMaxVisibleOutputTokens",
|
|
70
|
+
maxReasoningTokens: "modelMaxReasoningTokens",
|
|
71
|
+
maxTotalOutputTokens: "modelMaxTotalOutputTokens",
|
|
72
|
+
metadata: "modelMetadata",
|
|
73
|
+
};
|
|
61
74
|
const AXIS_DESCRIPTORS = [
|
|
62
75
|
{ axis: "name", rootPath: "/name", value: (profile) => profile.name },
|
|
63
76
|
{
|
|
@@ -82,31 +95,11 @@ const AXIS_DESCRIPTORS = [
|
|
|
82
95
|
rootPath: "/prompt/instructions",
|
|
83
96
|
value: (profile) => profile.prompt?.instructions,
|
|
84
97
|
},
|
|
85
|
-
{
|
|
86
|
-
axis
|
|
87
|
-
rootPath:
|
|
88
|
-
value: (profile) => profile.model?.
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
axis: "modelSmall",
|
|
92
|
-
rootPath: "/model/small",
|
|
93
|
-
value: (profile) => profile.model?.small,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
axis: "modelProvider",
|
|
97
|
-
rootPath: "/model/provider",
|
|
98
|
-
value: (profile) => profile.model?.provider,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
axis: "modelReasoningEffort",
|
|
102
|
-
rootPath: "/model/reasoningEffort",
|
|
103
|
-
value: (profile) => profile.model?.reasoningEffort,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
axis: "modelMetadata",
|
|
107
|
-
rootPath: "/model/metadata",
|
|
108
|
-
value: (profile) => profile.model?.metadata,
|
|
109
|
-
},
|
|
98
|
+
...Object.entries(MODEL_AXES).map(([property, axis]) => ({
|
|
99
|
+
axis,
|
|
100
|
+
rootPath: `/model/${property}`,
|
|
101
|
+
value: (profile) => profile.model?.[property],
|
|
102
|
+
})),
|
|
110
103
|
{ axis: "harness", rootPath: "/harness", value: (profile) => profile.harness },
|
|
111
104
|
{
|
|
112
105
|
axis: "permissions",
|
|
@@ -105,6 +105,9 @@ export declare const AgentInteractiveSessionRefSchema: z.ZodObject<{
|
|
|
105
105
|
mcp: "mcp";
|
|
106
106
|
metadata: "metadata";
|
|
107
107
|
modelDefault: "modelDefault";
|
|
108
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
109
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
110
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
108
111
|
modelMetadata: "modelMetadata";
|
|
109
112
|
modelProvider: "modelProvider";
|
|
110
113
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -277,6 +280,9 @@ export declare const AgentInteractiveSessionControlClaimRequestSchema: z.ZodObje
|
|
|
277
280
|
mcp: "mcp";
|
|
278
281
|
metadata: "metadata";
|
|
279
282
|
modelDefault: "modelDefault";
|
|
283
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
284
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
285
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
280
286
|
modelMetadata: "modelMetadata";
|
|
281
287
|
modelProvider: "modelProvider";
|
|
282
288
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -442,6 +448,9 @@ export declare const AgentInteractiveSessionControlClaimAcknowledgementSchema: z
|
|
|
442
448
|
mcp: "mcp";
|
|
443
449
|
metadata: "metadata";
|
|
444
450
|
modelDefault: "modelDefault";
|
|
451
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
452
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
453
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
445
454
|
modelMetadata: "modelMetadata";
|
|
446
455
|
modelProvider: "modelProvider";
|
|
447
456
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -628,6 +637,9 @@ export declare const AgentInteractiveSessionStatusSchema: z.ZodDiscriminatedUnio
|
|
|
628
637
|
mcp: "mcp";
|
|
629
638
|
metadata: "metadata";
|
|
630
639
|
modelDefault: "modelDefault";
|
|
640
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
641
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
642
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
631
643
|
modelMetadata: "modelMetadata";
|
|
632
644
|
modelProvider: "modelProvider";
|
|
633
645
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -773,6 +785,9 @@ export declare const AgentInteractiveSessionStatusSchema: z.ZodDiscriminatedUnio
|
|
|
773
785
|
mcp: "mcp";
|
|
774
786
|
metadata: "metadata";
|
|
775
787
|
modelDefault: "modelDefault";
|
|
788
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
789
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
790
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
776
791
|
modelMetadata: "modelMetadata";
|
|
777
792
|
modelProvider: "modelProvider";
|
|
778
793
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -926,6 +941,9 @@ export declare const AgentInteractiveSessionStatusSchema: z.ZodDiscriminatedUnio
|
|
|
926
941
|
mcp: "mcp";
|
|
927
942
|
metadata: "metadata";
|
|
928
943
|
modelDefault: "modelDefault";
|
|
944
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
945
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
946
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
929
947
|
modelMetadata: "modelMetadata";
|
|
930
948
|
modelProvider: "modelProvider";
|
|
931
949
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1084,6 +1102,9 @@ export declare const AgentInteractiveSessionStopCommandSchema: z.ZodObject<{
|
|
|
1084
1102
|
mcp: "mcp";
|
|
1085
1103
|
metadata: "metadata";
|
|
1086
1104
|
modelDefault: "modelDefault";
|
|
1105
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
1106
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
1107
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
1087
1108
|
modelMetadata: "modelMetadata";
|
|
1088
1109
|
modelProvider: "modelProvider";
|
|
1089
1110
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1251,6 +1272,9 @@ export declare const AgentInteractiveSessionStopAcknowledgementSchema: z.ZodObje
|
|
|
1251
1272
|
mcp: "mcp";
|
|
1252
1273
|
metadata: "metadata";
|
|
1253
1274
|
modelDefault: "modelDefault";
|
|
1275
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
1276
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
1277
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
1254
1278
|
modelMetadata: "modelMetadata";
|
|
1255
1279
|
modelProvider: "modelProvider";
|
|
1256
1280
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1434,6 +1458,9 @@ export declare const AgentInteractiveSessionPromptCommandSchema: z.ZodObject<{
|
|
|
1434
1458
|
mcp: "mcp";
|
|
1435
1459
|
metadata: "metadata";
|
|
1436
1460
|
modelDefault: "modelDefault";
|
|
1461
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
1462
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
1463
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
1437
1464
|
modelMetadata: "modelMetadata";
|
|
1438
1465
|
modelProvider: "modelProvider";
|
|
1439
1466
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1600,6 +1627,9 @@ export declare const AgentInteractiveSessionPromptAcknowledgementSchema: z.ZodOb
|
|
|
1600
1627
|
mcp: "mcp";
|
|
1601
1628
|
metadata: "metadata";
|
|
1602
1629
|
modelDefault: "modelDefault";
|
|
1630
|
+
modelMaxReasoningTokens: "modelMaxReasoningTokens";
|
|
1631
|
+
modelMaxTotalOutputTokens: "modelMaxTotalOutputTokens";
|
|
1632
|
+
modelMaxVisibleOutputTokens: "modelMaxVisibleOutputTokens";
|
|
1603
1633
|
modelMetadata: "modelMetadata";
|
|
1604
1634
|
modelProvider: "modelProvider";
|
|
1605
1635
|
modelReasoningEffort: "modelReasoningEffort";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { AgentRuntimeAttachments } from "./runtime-attachments.js";
|
|
3
|
+
export { AgentRuntimeAttachmentsSchema, type AgentRuntimeAttachments } from "./runtime-attachments.js";
|
|
2
4
|
import type { Sha256Digest } from "./agent-candidate.js";
|
|
3
5
|
import type { AgentProfileCapabilities, AgentProfileValidationResult } from "./agent-profile.js";
|
|
4
6
|
import type { InputPart } from "./parts.js";
|
|
@@ -283,6 +285,10 @@ export declare const AgentTurnResultSchema: z.ZodObject<{
|
|
|
283
285
|
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
284
286
|
cost: z.ZodOptional<z.ZodNumber>;
|
|
285
287
|
}, z.core.$strict>>;
|
|
288
|
+
usageMode: z.ZodOptional<z.ZodEnum<{
|
|
289
|
+
cumulative: "cumulative";
|
|
290
|
+
delta: "delta";
|
|
291
|
+
}>>;
|
|
286
292
|
providerEvent: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
287
293
|
}, z.core.$strict>>>;
|
|
288
294
|
contextTransferReceipt: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -435,6 +441,10 @@ export declare const AgentNativeContextContinuationResultSchema: z.ZodUnion<read
|
|
|
435
441
|
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
436
442
|
cost: z.ZodOptional<z.ZodNumber>;
|
|
437
443
|
}, z.core.$strict>>;
|
|
444
|
+
usageMode: z.ZodOptional<z.ZodEnum<{
|
|
445
|
+
cumulative: "cumulative";
|
|
446
|
+
delta: "delta";
|
|
447
|
+
}>>;
|
|
438
448
|
providerEvent: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
439
449
|
}, z.core.$strict>>>;
|
|
440
450
|
contextTransferReceipt: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -640,6 +650,12 @@ export interface AgentEnvironmentEvent {
|
|
|
640
650
|
id?: string;
|
|
641
651
|
normalized?: StreamEvent;
|
|
642
652
|
usage?: TokenUsage;
|
|
653
|
+
/**
|
|
654
|
+
* Delta is one new contribution; cumulative is the total so far for this turn.
|
|
655
|
+
* Cumulative totals include earlier deltas and may repeat during replay.
|
|
656
|
+
* Omission means the provider has not established the aggregation semantics.
|
|
657
|
+
*/
|
|
658
|
+
usageMode?: "delta" | "cumulative";
|
|
643
659
|
providerEvent?: unknown;
|
|
644
660
|
}
|
|
645
661
|
export interface AgentSession {
|
|
@@ -844,9 +860,8 @@ export interface AgentEnvironmentCapabilities {
|
|
|
844
860
|
egress: readonly AgentExactProcessEgressMode[];
|
|
845
861
|
};
|
|
846
862
|
/**
|
|
847
|
-
* Present only when create honors
|
|
848
|
-
*
|
|
849
|
-
* caller that needs either must not send it and call the result a policy.
|
|
863
|
+
* Present only when create honors at least one optional field below.
|
|
864
|
+
* Callers must check each requested field; an absent capability cannot satisfy it.
|
|
850
865
|
*
|
|
851
866
|
* Each member is present only when that field is honored, and the block carries at least one of
|
|
852
867
|
* them. A provider that takes a billing owner but no caller-controlled egress therefore states
|
|
@@ -864,6 +879,10 @@ export interface AgentEnvironmentCapabilities {
|
|
|
864
879
|
* authorizes the caller for that account; this flag states only that the field is not dropped.
|
|
865
880
|
*/
|
|
866
881
|
billingOwner?: boolean;
|
|
882
|
+
/** Runtime-owned MCP bindings applied without changing the authored profile. */
|
|
883
|
+
runtimeAttachments?: {
|
|
884
|
+
mcp: true;
|
|
885
|
+
};
|
|
867
886
|
};
|
|
868
887
|
/** Per-surface flags for the normalized environment observation. */
|
|
869
888
|
observation?: {
|
|
@@ -1007,6 +1026,9 @@ export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
|
|
|
1007
1026
|
strict: "strict";
|
|
1008
1027
|
}>>>;
|
|
1009
1028
|
billingOwner: z.ZodOptional<z.ZodBoolean>;
|
|
1029
|
+
runtimeAttachments: z.ZodOptional<z.ZodObject<{
|
|
1030
|
+
mcp: z.ZodLiteral<true>;
|
|
1031
|
+
}, z.core.$strict>>;
|
|
1010
1032
|
}, z.core.$strict>>;
|
|
1011
1033
|
observation: z.ZodOptional<z.ZodObject<{
|
|
1012
1034
|
identity: z.ZodBoolean;
|
|
@@ -1039,6 +1061,13 @@ export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
|
|
|
1039
1061
|
}, z.core.$strict>;
|
|
1040
1062
|
export interface CreateAgentEnvironmentInput {
|
|
1041
1063
|
profile: AgentProfileRef;
|
|
1064
|
+
/**
|
|
1065
|
+
* Runtime-owned execution inputs, separate from authored profile identity.
|
|
1066
|
+
* Providers must refuse unsupported attachments and authored MCP alias collisions.
|
|
1067
|
+
* Credentials are sensitive transport input; never include them in receipts or logs.
|
|
1068
|
+
* Attachments participate in keyed create identity and cannot be refreshed by replay.
|
|
1069
|
+
*/
|
|
1070
|
+
runtimeAttachments?: AgentRuntimeAttachments;
|
|
1042
1071
|
/** Exact caller-owned id required by an accepted destination contract. */
|
|
1043
1072
|
requestedId?: string;
|
|
1044
1073
|
/** Agent backend inside the provider, for example "opencode" or "codex". */
|
|
@@ -1087,6 +1116,8 @@ export interface CreateAgentEnvironmentInput {
|
|
|
1087
1116
|
* The operation key names the request and the abort signal controls one
|
|
1088
1117
|
* attempt, so neither belongs in the input identity. Every other field is
|
|
1089
1118
|
* canonicalized with the shared RFC 8785 JSON representation.
|
|
1119
|
+
* A keyed create therefore accepts only canonical JSON material.
|
|
1120
|
+
* Unkeyed creates can retain opaque provider-native mapper values.
|
|
1090
1121
|
* @internal
|
|
1091
1122
|
*/
|
|
1092
1123
|
export declare function agentEnvironmentCreateInputDigest(input: CreateAgentEnvironmentInput): Sha256Digest;
|
|
@@ -1118,9 +1149,15 @@ export declare function replayedAgentEnvironmentView<T extends object>(environme
|
|
|
1118
1149
|
* with the creation verdict the provider could prove. Every same-key call
|
|
1119
1150
|
* after it, including one that awaited the same pending create, receives
|
|
1120
1151
|
* {@link replayedAgentEnvironmentView} of that environment.
|
|
1152
|
+
*
|
|
1153
|
+
* A keyed create callback receives one immutable canonical JSON snapshot.
|
|
1154
|
+
* Its digest and provider therefore read identical request bytes even when
|
|
1155
|
+
* the caller mutates its original object after this function returns.
|
|
1156
|
+
* An unkeyed create retains its original input so opaque provider-native
|
|
1157
|
+
* mapper values retain their public identity.
|
|
1121
1158
|
* @internal
|
|
1122
1159
|
*/
|
|
1123
|
-
export declare function createAgentEnvironmentWithIdempotency<T extends object>(records: Map<string, AgentEnvironmentCreateIdempotencyRecord<T>>, input: CreateAgentEnvironmentInput, create: () => Promise<T>): Promise<T>;
|
|
1160
|
+
export declare function createAgentEnvironmentWithIdempotency<T extends object>(records: Map<string, AgentEnvironmentCreateIdempotencyRecord<T>>, input: CreateAgentEnvironmentInput, create: (input: CreateAgentEnvironmentInput) => Promise<T>): Promise<T>;
|
|
1124
1161
|
export interface AgentEnvironmentProvider {
|
|
1125
1162
|
readonly name: string;
|
|
1126
1163
|
readonly exactProcess?: AgentExactProcessProvider;
|
|
@@ -1150,6 +1187,7 @@ export interface AgentEnvironmentProvider {
|
|
|
1150
1187
|
*
|
|
1151
1188
|
* With `input.idempotencyKey`, the provider must return the same environment
|
|
1152
1189
|
* for the same canonical input and reject any changed input before creating.
|
|
1190
|
+
* A provider without durable keyed admission must reject a keyed request before provisioning.
|
|
1153
1191
|
* Without a key, each call may create a fresh environment.
|
|
1154
1192
|
*/
|
|
1155
1193
|
create(input: CreateAgentEnvironmentInput): Promise<AgentEnvironment>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
2
|
+
export { AgentRuntimeAttachmentsSchema } from "./runtime-attachments.js";
|
|
3
|
+
import { canonicalCandidateDigest, canonicalCandidateJson, } from "./agent-candidate-schema-common.js";
|
|
3
4
|
import { InteractionCapabilitiesSchema, RequestedInteractionsSchema } from "./interaction.js";
|
|
4
5
|
import { ContextTransferReceiptSchema, ContextTransferRequestSchema, NativeContextBoundaryProofSchema, NativeContextContinuationAcknowledgementSchema, NativeContextContinuationRequestSchema, nativeContextContinuationAcknowledgementMatches } from "./portable-context.js";
|
|
5
6
|
import { AgentExactRunControlRefSchema, AgentRunControlRefSchema, CanonicalStreamEventSchema } from "./runtime-control.js";
|
|
6
7
|
import { AgentProfileCapabilitiesSchema } from "./environment-profile-capabilities.js";
|
|
7
8
|
import { boundedIdentifierSchema, boundedJsonRecordSchema, boundedJsonSchema, boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH } from "./contract-limits.js";
|
|
8
9
|
import { InputPartSchema } from "./portable-context-shared.js";
|
|
10
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
9
11
|
export const AgentTurnInputSchema = z.strictObject({
|
|
10
12
|
prompt: boundedStringSchema.optional(),
|
|
11
13
|
parts: z.array(InputPartSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
@@ -39,6 +41,7 @@ const AgentEnvironmentEventSchema = z.strictObject({
|
|
|
39
41
|
id: boundedIdentifierSchema.optional(),
|
|
40
42
|
normalized: CanonicalStreamEventSchema.optional(),
|
|
41
43
|
usage: TokenUsageSchema.optional(),
|
|
44
|
+
usageMode: z.enum(["delta", "cumulative"]).optional(),
|
|
42
45
|
providerEvent: boundedJsonSchema.optional(),
|
|
43
46
|
});
|
|
44
47
|
/** Runtime validator for a provider turn returned from durable continuation. */
|
|
@@ -239,6 +242,7 @@ export const AgentEnvironmentCapabilitiesSchema = z
|
|
|
239
242
|
.max(CONTRACT_MAX_ARRAY_LENGTH)
|
|
240
243
|
.optional(),
|
|
241
244
|
billingOwner: z.boolean().optional(),
|
|
245
|
+
runtimeAttachments: z.strictObject({ mcp: z.literal(true) }).optional(),
|
|
242
246
|
})
|
|
243
247
|
.optional(),
|
|
244
248
|
observation: z
|
|
@@ -345,7 +349,7 @@ export const AgentEnvironmentCapabilitiesSchema = z
|
|
|
345
349
|
}
|
|
346
350
|
const create = capabilities.create;
|
|
347
351
|
if (create !== undefined) {
|
|
348
|
-
if (create.egress === undefined && create.billingOwner === undefined) {
|
|
352
|
+
if (create.egress === undefined && create.billingOwner === undefined && create.runtimeAttachments === undefined) {
|
|
349
353
|
refinement.addIssue({
|
|
350
354
|
code: "custom",
|
|
351
355
|
path: ["create"],
|
|
@@ -423,6 +427,8 @@ export const AgentEnvironmentCapabilitiesSchema = z
|
|
|
423
427
|
* The operation key names the request and the abort signal controls one
|
|
424
428
|
* attempt, so neither belongs in the input identity. Every other field is
|
|
425
429
|
* canonicalized with the shared RFC 8785 JSON representation.
|
|
430
|
+
* A keyed create therefore accepts only canonical JSON material.
|
|
431
|
+
* Unkeyed creates can retain opaque provider-native mapper values.
|
|
426
432
|
* @internal
|
|
427
433
|
*/
|
|
428
434
|
export function agentEnvironmentCreateInputDigest(input) {
|
|
@@ -460,14 +466,26 @@ export function replayedAgentEnvironmentView(environment) {
|
|
|
460
466
|
* with the creation verdict the provider could prove. Every same-key call
|
|
461
467
|
* after it, including one that awaited the same pending create, receives
|
|
462
468
|
* {@link replayedAgentEnvironmentView} of that environment.
|
|
469
|
+
*
|
|
470
|
+
* A keyed create callback receives one immutable canonical JSON snapshot.
|
|
471
|
+
* Its digest and provider therefore read identical request bytes even when
|
|
472
|
+
* the caller mutates its original object after this function returns.
|
|
473
|
+
* An unkeyed create retains its original input so opaque provider-native
|
|
474
|
+
* mapper values retain their public identity.
|
|
463
475
|
* @internal
|
|
464
476
|
*/
|
|
465
477
|
export async function createAgentEnvironmentWithIdempotency(records, input, create) {
|
|
466
|
-
input
|
|
467
|
-
|
|
478
|
+
const { idempotencyKey: key, signal, ...material } = input;
|
|
479
|
+
signal?.throwIfAborted();
|
|
468
480
|
if (key === undefined)
|
|
469
|
-
return create();
|
|
470
|
-
const
|
|
481
|
+
return create(input);
|
|
482
|
+
const snapshot = deepFreeze(JSON.parse(canonicalCandidateJson(material)));
|
|
483
|
+
const acceptedInput = Object.freeze({
|
|
484
|
+
...snapshot,
|
|
485
|
+
idempotencyKey: key,
|
|
486
|
+
...(signal === undefined ? {} : { signal }),
|
|
487
|
+
});
|
|
488
|
+
const digest = agentEnvironmentCreateInputDigest(acceptedInput);
|
|
471
489
|
const existing = records.get(key);
|
|
472
490
|
if (existing !== undefined) {
|
|
473
491
|
if (existing.digest !== digest) {
|
|
@@ -475,7 +493,7 @@ export async function createAgentEnvironmentWithIdempotency(records, input, crea
|
|
|
475
493
|
}
|
|
476
494
|
return replayedAgentEnvironmentView(existing.environment ?? (await existing.pending));
|
|
477
495
|
}
|
|
478
|
-
const pending = Promise.resolve().then(create);
|
|
496
|
+
const pending = Promise.resolve().then(() => create(acceptedInput));
|
|
479
497
|
const record = {
|
|
480
498
|
digest,
|
|
481
499
|
pending,
|
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, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, AgentEnvironmentCreationSchema, createAgentEnvironmentWithIdempotency, replayedAgentEnvironmentView, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
11
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, AgentEnvironmentCreationSchema, createAgentEnvironmentWithIdempotency, replayedAgentEnvironmentView, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, 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, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, AgentEnvironmentCreationSchema, createAgentEnvironmentWithIdempotency, replayedAgentEnvironmentView, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
10
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, AgentEnvironmentCreationSchema, createAgentEnvironmentWithIdempotency, replayedAgentEnvironmentView, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, 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";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentProfileMcpServer } from "./agent-profile.js";
|
|
3
|
+
/** Runtime-owned bindings do not alter the authored AgentProfile or candidate identity. */
|
|
4
|
+
export interface AgentRuntimeAttachments {
|
|
5
|
+
mcp: Record<string, AgentProfileMcpServer>;
|
|
6
|
+
}
|
|
7
|
+
export declare const AgentRuntimeAttachmentsSchema: z.ZodType<AgentRuntimeAttachments>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentProfileSchema } from "./profile-schema.js";
|
|
3
|
+
import { boundedIdentifierSchema, boundedJsonSchema } from "./contract-limits.js";
|
|
4
|
+
export const AgentRuntimeAttachmentsSchema = boundedJsonSchema.pipe(z.strictObject({
|
|
5
|
+
mcp: agentProfileSchema.shape.mcp.unwrap().superRefine((servers, context) => {
|
|
6
|
+
for (const alias of Object.keys(servers)) {
|
|
7
|
+
const result = boundedIdentifierSchema.safeParse(alias);
|
|
8
|
+
if (!result.success) {
|
|
9
|
+
for (const issue of result.error.issues) {
|
|
10
|
+
context.addIssue({ ...issue, path: [alias, ...issue.path] });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}),
|
|
15
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-interface",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"zod": "4.5.4"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@types/node": "26.4.
|
|
91
|
+
"@types/node": "26.4.1",
|
|
92
92
|
"@types/spdx-expression-parse": "4.0.0",
|
|
93
93
|
"typescript": "7.0.2",
|
|
94
94
|
"vitest": "4.1.11"
|