@tangle-network/agent-interface 5.10.9 → 5.10.10

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.
@@ -1,4 +1,5 @@
1
1
  import type { AgentCandidateTermination } from "./agent-candidate.js";
2
+ import type { AgentEnvironmentEgressAllowDomain } from "./environment-requests.js";
2
3
  export type AgentExactProcessEgressMode = "blocked" | "strict";
3
4
  /**
4
5
  * Outbound network policy for an exact process environment. `blocked` denies
@@ -9,7 +10,7 @@ export type AgentExactProcessEgressPolicy = {
9
10
  mode: "blocked";
10
11
  } | {
11
12
  mode: "strict";
12
- allowDomains: readonly string[];
13
+ allowDomains: readonly AgentEnvironmentEgressAllowDomain[];
13
14
  };
14
15
  /** Explicit portable limits for an exact process environment. */
15
16
  export interface AgentExactProcessResources {
@@ -27,8 +27,26 @@ export type AgentEnvironmentEgressPolicy = {
27
27
  mode: "blocked";
28
28
  } | {
29
29
  mode: "strict";
30
- allowDomains?: readonly string[];
30
+ allowDomains?: readonly AgentEnvironmentEgressAllowDomain[];
31
31
  };
32
+ /**
33
+ * One allowed destination: a host, or a host whose resolved private addresses are also reachable
34
+ * within the named CIDR ranges. This is the Sandbox platform's entry shape, carried verbatim.
35
+ */
36
+ export type AgentEnvironmentEgressAllowDomain = string | {
37
+ domain: string;
38
+ allowPrivateIps: readonly string[];
39
+ };
40
+ /**
41
+ * A whitespace-only or outer-padded host matches nothing, so a policy carrying one is an
42
+ * allowlist the caller believes is in force and is not. That is the same silent-weakening this
43
+ * contract refuses everywhere else, so the entry is rejected rather than trimmed: trimming would
44
+ * accept a typo and change what the caller asked for.
45
+ */
46
+ export declare const AgentEnvironmentEgressAllowDomainSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
47
+ domain: z.ZodString;
48
+ allowPrivateIps: z.ZodArray<z.ZodUnion<readonly [z.ZodCIDRv4, z.ZodCIDRv6]>>;
49
+ }, z.core.$strict>]>;
32
50
  /** Runtime contract for the portable egress policy carried by providers. */
33
51
  export declare const AgentEnvironmentEgressPolicySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
34
52
  mode: z.ZodLiteral<"open">;
@@ -36,7 +54,10 @@ export declare const AgentEnvironmentEgressPolicySchema: z.ZodDiscriminatedUnion
36
54
  mode: z.ZodLiteral<"blocked">;
37
55
  }, z.core.$strict>, z.ZodObject<{
38
56
  mode: z.ZodLiteral<"strict">;
39
- allowDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
57
+ allowDomains: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
58
+ domain: z.ZodString;
59
+ allowPrivateIps: z.ZodArray<z.ZodUnion<readonly [z.ZodCIDRv4, z.ZodCIDRv6]>>;
60
+ }, z.core.$strict>]>>>;
40
61
  }, z.core.$strict>], "mode">;
41
62
  export interface WorkspaceRequest {
42
63
  /** Provider-specific environment/template id, for example "universal". */
@@ -4,14 +4,18 @@ import { workspaceCwdSchema } from "./workspace-cwd.js";
4
4
  import { WorkspaceCheckpointRefSchema } from "./workspace-checkpoint.js";
5
5
  import { AgentWorkspaceSnapshotRefSchema } from "./workspace-snapshot.js";
6
6
  /**
7
- * One allowed destination host.
8
- *
9
- * A whitespace-only or outer-padded entry matches no host, so a policy carrying one is an
7
+ * A whitespace-only or outer-padded host matches nothing, so a policy carrying one is an
10
8
  * allowlist the caller believes is in force and is not. That is the same silent-weakening this
11
9
  * contract refuses everywhere else, so the entry is rejected rather than trimmed: trimming would
12
10
  * accept a typo and change what the caller asked for.
13
11
  */
14
- const egressAllowDomainSchema = boundedIdentifierSchema;
12
+ export const AgentEnvironmentEgressAllowDomainSchema = z.union([
13
+ boundedIdentifierSchema,
14
+ z.strictObject({
15
+ domain: boundedIdentifierSchema,
16
+ allowPrivateIps: z.array(z.union([z.cidrv4(), z.cidrv6()])).min(1).max(100),
17
+ }),
18
+ ]);
15
19
  /** Runtime contract for the portable egress policy carried by providers. */
16
20
  export const AgentEnvironmentEgressPolicySchema = z.discriminatedUnion("mode", [
17
21
  z.strictObject({ mode: z.literal("open") }),
@@ -24,10 +28,7 @@ export const AgentEnvironmentEgressPolicySchema = z.discriminatedUnion("mode", [
24
28
  * domains differ only in order are read as different creates and the second is refused. Build
25
29
  * the list in a stable order.
26
30
  */
27
- allowDomains: z
28
- .array(egressAllowDomainSchema)
29
- .max(CONTRACT_MAX_ARRAY_LENGTH)
30
- .optional(),
31
+ allowDomains: z.array(AgentEnvironmentEgressAllowDomainSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
31
32
  }),
32
33
  ]);
33
34
  /** Runtime contract for the portable workspace request carried by providers. */
@@ -43,32 +44,17 @@ export const WorkspaceRequestSchema = z
43
44
  providerOptions: boundedJsonRecordSchema.optional(),
44
45
  })
45
46
  .superRefine((workspace, refinement) => {
46
- if (workspace.snapshot !== undefined && (workspace.repoUrl !== undefined || workspace.gitRef !== undefined || workspace.checkpoint !== undefined)) {
47
- refinement.addIssue({ code: "custom", path: ["snapshot"], message: "workspace snapshot cannot be combined with another workspace source" });
48
- }
49
- if (workspace.snapshot !== undefined && workspace.cwd?.base === "host") {
50
- refinement.addIssue({ code: "custom", path: ["cwd"], message: "workspace snapshot cwd must be relative to its restored repository" });
51
- }
52
- if (workspace.checkpoint !== undefined && workspace.repoUrl !== undefined) {
53
- refinement.addIssue({
54
- code: "custom",
55
- path: ["checkpoint"],
56
- message: "workspace cannot start from both a checkpoint and a repository",
57
- });
58
- }
59
- if (workspace.environment !== undefined && workspace.image !== undefined) {
60
- refinement.addIssue({
61
- code: "custom",
62
- path: ["image"],
63
- message: "workspace cannot specify both environment and image",
64
- });
65
- }
66
- if (workspace.gitRef !== undefined && workspace.repoUrl === undefined) {
67
- refinement.addIssue({
68
- code: "custom",
69
- path: ["gitRef"],
70
- message: "workspace gitRef requires repoUrl",
71
- });
47
+ const { snapshot, repoUrl, gitRef, checkpoint, cwd, environment, image } = workspace;
48
+ const conflicts = [
49
+ [snapshot !== undefined && (repoUrl ?? gitRef ?? checkpoint) !== undefined, "snapshot", "workspace snapshot cannot be combined with another workspace source"],
50
+ [snapshot !== undefined && cwd?.base === "host", "cwd", "workspace snapshot cwd must be relative to its restored repository"],
51
+ [checkpoint !== undefined && repoUrl !== undefined, "checkpoint", "workspace cannot start from both a checkpoint and a repository"],
52
+ [environment !== undefined && image !== undefined, "image", "workspace cannot specify both environment and image"],
53
+ [gitRef !== undefined && repoUrl === undefined, "gitRef", "workspace gitRef requires repoUrl"],
54
+ ];
55
+ for (const [conflict, path, message] of conflicts) {
56
+ if (conflict)
57
+ refinement.addIssue({ code: "custom", path: [path], message });
72
58
  }
73
59
  });
74
60
  /** The resource request used by environment creation and accepted transfers. */
package/dist/index.d.ts CHANGED
@@ -43,7 +43,7 @@ export * from "./profile-schema.js";
43
43
  export * from "./profile-security.js";
44
44
  export * from "./sandbox-size.js";
45
45
  export { CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, CONTRACT_MAX_IDENTIFIER_LENGTH, CONTRACT_MAX_JSON_BYTES, CONTRACT_MAX_JSON_DEPTH, CONTRACT_MAX_JSON_NODES, CONTRACT_MAX_MAP_ENTRIES, CONTRACT_MAX_STRING_LENGTH, boundedEventContentJsonSchema, boundedEventContentRecordSchema, boundedEventContentStringSchema, isBoundedEventContentJson, } from "./contract-limits.js";
46
- export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
46
+ export { AgentEnvironmentEgressAllowDomainSchema, AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
47
47
  export * from "./native-session-event.js";
48
48
  export * from "./learning-state.js";
49
49
  export { ownPropertyRecordSchema } from "./own-property-record.js";
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ export {
45
45
  // this contract validates can assert its own limits fit — the seam test in agent-provider-tangle
46
46
  // does exactly that, after three bound mismatches shipped through it (agent-sdk#311, #312, #314).
47
47
  CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, CONTRACT_MAX_IDENTIFIER_LENGTH, CONTRACT_MAX_JSON_BYTES, CONTRACT_MAX_JSON_DEPTH, CONTRACT_MAX_JSON_NODES, CONTRACT_MAX_MAP_ENTRIES, CONTRACT_MAX_STRING_LENGTH, boundedEventContentJsonSchema, boundedEventContentRecordSchema, boundedEventContentStringSchema, isBoundedEventContentJson, } from "./contract-limits.js";
48
- export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
48
+ export { AgentEnvironmentEgressAllowDomainSchema, AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
49
49
  export * from "./native-session-event.js";
50
50
  export * from "./learning-state.js";
51
51
  export { ownPropertyRecordSchema } from "./own-property-record.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "5.10.9",
3
+ "version": "5.10.10",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",