@tangle-network/agent-interface 2.1.1 → 2.2.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/dist/environment-provider.d.ts +1 -0
- package/dist/environment-provider.js +1 -0
- package/dist/environment-requests.d.ts +31 -0
- package/dist/environment-requests.js +28 -1
- package/dist/environment-runtime.d.ts +60 -2
- package/dist/environment-runtime.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,37 @@ import type { AgentProfile } from "./agent-profile.js";
|
|
|
5
5
|
export type AgentProfileRef = AgentProfile | string;
|
|
6
6
|
export type AgentEnvironmentStatus = "pending" | "provisioning" | "running" | "stopped" | "failed" | "expired" | "unknown";
|
|
7
7
|
export type AgentSessionStatus = AgentEnvironmentStatus | "completed" | "cancelled";
|
|
8
|
+
/** Outbound network modes an ordinary agent environment can request. */
|
|
9
|
+
export type AgentEnvironmentEgressMode = "open" | "strict" | "blocked";
|
|
10
|
+
/**
|
|
11
|
+
* Outbound network policy for one agent environment.
|
|
12
|
+
*
|
|
13
|
+
* `open` permits every destination. `strict` permits only the named domains plus the model
|
|
14
|
+
* endpoints the provider itself provisioned into the environment. `blocked` denies every
|
|
15
|
+
* destination.
|
|
16
|
+
*
|
|
17
|
+
* A provider that cannot satisfy the requested mode must fail the create. It must never weaken
|
|
18
|
+
* the policy and never widen it: a policy that differs from the request is invisible from inside
|
|
19
|
+
* the environment, and the refusal it produces there reads as an authorization error that names
|
|
20
|
+
* nothing.
|
|
21
|
+
*/
|
|
22
|
+
export type AgentEnvironmentEgressPolicy = {
|
|
23
|
+
mode: "open";
|
|
24
|
+
} | {
|
|
25
|
+
mode: "blocked";
|
|
26
|
+
} | {
|
|
27
|
+
mode: "strict";
|
|
28
|
+
allowDomains?: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
/** Runtime contract for the portable egress policy carried by providers. */
|
|
31
|
+
export declare const AgentEnvironmentEgressPolicySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
32
|
+
mode: z.ZodLiteral<"open">;
|
|
33
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
+
mode: z.ZodLiteral<"blocked">;
|
|
35
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
36
|
+
mode: z.ZodLiteral<"strict">;
|
|
37
|
+
allowDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
}, z.core.$strict>], "mode">;
|
|
8
39
|
export interface WorkspaceRequest {
|
|
9
40
|
/** Provider-specific environment/template id, for example "universal". */
|
|
10
41
|
environment?: string;
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { boundedIdentifierSchema, boundedJsonRecordSchema, boundedStringSchema, } from "./contract-limits.js";
|
|
2
|
+
import { boundedIdentifierSchema, boundedJsonRecordSchema, boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, } from "./contract-limits.js";
|
|
3
3
|
import { workspaceCwdSchema } from "./workspace-cwd.js";
|
|
4
|
+
/**
|
|
5
|
+
* One allowed destination host.
|
|
6
|
+
*
|
|
7
|
+
* A whitespace-only or outer-padded entry matches no host, so a policy carrying one is an
|
|
8
|
+
* allowlist the caller believes is in force and is not. That is the same silent-weakening this
|
|
9
|
+
* contract refuses everywhere else, so the entry is rejected rather than trimmed: trimming would
|
|
10
|
+
* accept a typo and change what the caller asked for.
|
|
11
|
+
*/
|
|
12
|
+
const egressAllowDomainSchema = boundedIdentifierSchema;
|
|
13
|
+
/** Runtime contract for the portable egress policy carried by providers. */
|
|
14
|
+
export const AgentEnvironmentEgressPolicySchema = z.discriminatedUnion("mode", [
|
|
15
|
+
z.strictObject({ mode: z.literal("open") }),
|
|
16
|
+
z.strictObject({ mode: z.literal("blocked") }),
|
|
17
|
+
z.strictObject({
|
|
18
|
+
mode: z.literal("strict"),
|
|
19
|
+
/**
|
|
20
|
+
* Order does not change the policy, but it does change the create identity: this value is
|
|
21
|
+
* canonicalized into {@link agentEnvironmentCreateInputDigest}, so two same-key creates whose
|
|
22
|
+
* domains differ only in order are read as different creates and the second is refused. Build
|
|
23
|
+
* the list in a stable order.
|
|
24
|
+
*/
|
|
25
|
+
allowDomains: z
|
|
26
|
+
.array(egressAllowDomainSchema)
|
|
27
|
+
.max(CONTRACT_MAX_ARRAY_LENGTH)
|
|
28
|
+
.optional(),
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
4
31
|
/** Runtime contract for the portable workspace request carried by providers. */
|
|
5
32
|
export const WorkspaceRequestSchema = z
|
|
6
33
|
.strictObject({
|
|
@@ -8,7 +8,7 @@ import { type InteractionAcknowledgement, type InteractionCapabilities, type Int
|
|
|
8
8
|
import { type ContextTransferReceipt, type ContextTransferRequest, type ContextTransferResult, type NativeContextBoundaryProof, type NativeContextContinuationRequest, type NativeContextContinuationTurn } from "./portable-context.js";
|
|
9
9
|
import { type AgentExactRunControlRef, type AgentRunCancellationAcknowledgement, type AgentRunCancellationRequest, type AgentRunControlRef } from "./runtime-control.js";
|
|
10
10
|
import type { AgentWorkspaceBranching, AgentWorkspaceBranchingProvider } from "./workspace-branching.js";
|
|
11
|
-
import type { AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSessionStatus, CheckpointRef, CheckpointRequest, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from "./environment-requests.js";
|
|
11
|
+
import type { AgentEnvironmentEgressMode, AgentEnvironmentEgressPolicy, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSessionStatus, CheckpointRef, CheckpointRequest, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from "./environment-requests.js";
|
|
12
12
|
import type { AgentExactProcessEgressMode, AgentExactProcessProvider } from "./environment-exact-process.js";
|
|
13
13
|
import type { AgentEnvironmentObservation } from "./environment-observation.js";
|
|
14
14
|
import type { AgentInteractiveSession, AgentInteractiveSessionRef, AgentInteractiveSessionStart } from "./environment-interactive.js";
|
|
@@ -841,6 +841,28 @@ export interface AgentEnvironmentCapabilities {
|
|
|
841
841
|
exactProcess?: {
|
|
842
842
|
egress: readonly AgentExactProcessEgressMode[];
|
|
843
843
|
};
|
|
844
|
+
/**
|
|
845
|
+
* Present only when create honors {@link CreateAgentEnvironmentInput.egress} or
|
|
846
|
+
* {@link CreateAgentEnvironmentInput.billingOwner}. Absent means neither field is read, so a
|
|
847
|
+
* caller that needs either must not send it and call the result a policy.
|
|
848
|
+
*
|
|
849
|
+
* Each member is present only when that field is honored, and the block carries at least one of
|
|
850
|
+
* them. A provider that takes a billing owner but no caller-controlled egress therefore states
|
|
851
|
+
* exactly that, instead of advertising an egress mode it does not accept.
|
|
852
|
+
*/
|
|
853
|
+
create?: {
|
|
854
|
+
/**
|
|
855
|
+
* Egress modes create accepts, each named once. A mode absent here is refused, never weakened
|
|
856
|
+
* or widened. Absent altogether means create does not read
|
|
857
|
+
* {@link CreateAgentEnvironmentInput.egress} at all.
|
|
858
|
+
*/
|
|
859
|
+
egress?: readonly AgentEnvironmentEgressMode[];
|
|
860
|
+
/**
|
|
861
|
+
* True when create carries the billing owner to the platform unchanged. The platform still
|
|
862
|
+
* authorizes the caller for that account; this flag states only that the field is not dropped.
|
|
863
|
+
*/
|
|
864
|
+
billingOwner?: boolean;
|
|
865
|
+
};
|
|
844
866
|
/** Per-surface flags for the normalized environment observation. */
|
|
845
867
|
observation?: {
|
|
846
868
|
identity: boolean;
|
|
@@ -975,6 +997,14 @@ export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
|
|
|
975
997
|
strict: "strict";
|
|
976
998
|
}>>;
|
|
977
999
|
}, z.core.$strict>>;
|
|
1000
|
+
create: z.ZodOptional<z.ZodObject<{
|
|
1001
|
+
egress: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1002
|
+
blocked: "blocked";
|
|
1003
|
+
open: "open";
|
|
1004
|
+
strict: "strict";
|
|
1005
|
+
}>>>;
|
|
1006
|
+
billingOwner: z.ZodOptional<z.ZodBoolean>;
|
|
1007
|
+
}, z.core.$strict>>;
|
|
978
1008
|
observation: z.ZodOptional<z.ZodObject<{
|
|
979
1009
|
identity: z.ZodBoolean;
|
|
980
1010
|
lifecycle: z.ZodBoolean;
|
|
@@ -1014,6 +1044,26 @@ export interface CreateAgentEnvironmentInput {
|
|
|
1014
1044
|
resources?: ResourceRequest;
|
|
1015
1045
|
env?: Record<string, string>;
|
|
1016
1046
|
secrets?: string[] | Record<string, string>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Outbound network policy for this environment.
|
|
1049
|
+
*
|
|
1050
|
+
* When absent the provider applies its own default. That default can be a strict allowlist,
|
|
1051
|
+
* and a model endpoint the environment must reach is then refused inside the environment as an
|
|
1052
|
+
* authorization error that names no policy. Declare the policy whenever the destinations the
|
|
1053
|
+
* environment needs are known.
|
|
1054
|
+
*
|
|
1055
|
+
* A provider that cannot satisfy the requested mode must fail the create rather than weaken or
|
|
1056
|
+
* widen the policy. {@link AgentEnvironmentCapabilities.create} names the modes it accepts.
|
|
1057
|
+
*/
|
|
1058
|
+
egress?: AgentEnvironmentEgressPolicy;
|
|
1059
|
+
/**
|
|
1060
|
+
* Platform account whose balance funds this environment's managed model usage.
|
|
1061
|
+
*
|
|
1062
|
+
* A trusted first-party service acting for an authenticated user sets it. The provider honors
|
|
1063
|
+
* it only for a caller its platform has authorized to bill that account, and rejects the create
|
|
1064
|
+
* otherwise. It never grants a caller permission to charge an arbitrary account.
|
|
1065
|
+
*/
|
|
1066
|
+
billingOwner?: string;
|
|
1017
1067
|
metadata?: Record<string, unknown>;
|
|
1018
1068
|
name?: string;
|
|
1019
1069
|
/**
|
|
@@ -1085,7 +1135,15 @@ export interface AgentEnvironmentProvider {
|
|
|
1085
1135
|
capabilities(): AgentEnvironmentCapabilities | Promise<AgentEnvironmentCapabilities>;
|
|
1086
1136
|
validateProfile?(profile: AgentProfileRef): AgentProfileValidationResult | Promise<AgentProfileValidationResult>;
|
|
1087
1137
|
/**
|
|
1088
|
-
* Create or reconstruct one environment.
|
|
1138
|
+
* Create or reconstruct one environment that is ready to accept a turn.
|
|
1139
|
+
*
|
|
1140
|
+
* A returned environment answers {@link AgentEnvironment.stream} and every
|
|
1141
|
+
* other operation its capability document claims. A provider whose platform
|
|
1142
|
+
* starts an environment asynchronously holds this call until the environment
|
|
1143
|
+
* is running, and fails the call with the platform's reason when it never
|
|
1144
|
+
* gets there; it never returns a half-started environment for the caller to
|
|
1145
|
+
* poll. Every runtime seam relies on this: a caller streams the first turn
|
|
1146
|
+
* immediately after create, with nothing in between.
|
|
1089
1147
|
*
|
|
1090
1148
|
* With `input.idempotencyKey`, the provider must return the same environment
|
|
1091
1149
|
* for the same canonical input and reject any changed input before creating.
|
|
@@ -230,6 +230,16 @@ export const AgentEnvironmentCapabilitiesSchema = z
|
|
|
230
230
|
.max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
231
231
|
})
|
|
232
232
|
.optional(),
|
|
233
|
+
create: z
|
|
234
|
+
.strictObject({
|
|
235
|
+
egress: z
|
|
236
|
+
.array(z.enum(["open", "strict", "blocked"]))
|
|
237
|
+
.min(1)
|
|
238
|
+
.max(CONTRACT_MAX_ARRAY_LENGTH)
|
|
239
|
+
.optional(),
|
|
240
|
+
billingOwner: z.boolean().optional(),
|
|
241
|
+
})
|
|
242
|
+
.optional(),
|
|
233
243
|
observation: z
|
|
234
244
|
.strictObject({
|
|
235
245
|
identity: z.boolean(),
|
|
@@ -332,6 +342,23 @@ export const AgentEnvironmentCapabilitiesSchema = z
|
|
|
332
342
|
message: "exact process egress modes must be unique",
|
|
333
343
|
});
|
|
334
344
|
}
|
|
345
|
+
const create = capabilities.create;
|
|
346
|
+
if (create !== undefined) {
|
|
347
|
+
if (create.egress === undefined && create.billingOwner === undefined) {
|
|
348
|
+
refinement.addIssue({
|
|
349
|
+
code: "custom",
|
|
350
|
+
path: ["create"],
|
|
351
|
+
message: "a create capability block must state at least one honored field",
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (create.egress && new Set(create.egress).size !== create.egress.length) {
|
|
355
|
+
refinement.addIssue({
|
|
356
|
+
code: "custom",
|
|
357
|
+
path: ["create", "egress"],
|
|
358
|
+
message: "create egress modes must be unique",
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
335
362
|
const terminal = capabilities.interactiveTerminal;
|
|
336
363
|
if (terminal !== undefined &&
|
|
337
364
|
(terminal.input || terminal.resize || terminal.reattach) &&
|
package/dist/index.d.ts
CHANGED
|
@@ -41,3 +41,4 @@ export * from "./profile-schema.js";
|
|
|
41
41
|
export * from "./profile-security.js";
|
|
42
42
|
export * from "./sandbox-size.js";
|
|
43
43
|
export { CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, } from "./contract-limits.js";
|
|
44
|
+
export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
|
package/dist/index.js
CHANGED
|
@@ -39,3 +39,4 @@ export * from "./profile-schema.js";
|
|
|
39
39
|
export * from "./profile-security.js";
|
|
40
40
|
export * from "./sandbox-size.js";
|
|
41
41
|
export { CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, } from "./contract-limits.js";
|
|
42
|
+
export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
|