@tangle-network/agent-interface 0.21.0 → 0.23.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.
@@ -1,4 +1,10 @@
1
1
  import { z } from "zod";
2
+ export declare const agentCandidateModelAccessNetworkSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ mode: z.ZodLiteral<"disabled">;
4
+ }, z.core.$strict>, z.ZodObject<{
5
+ mode: z.ZodLiteral<"gateway-only">;
6
+ domains: z.ZodArray<z.ZodString>;
7
+ }, z.core.$strict>], "mode">;
2
8
  export declare const agentCandidateResolvedModelSchema: z.ZodObject<{
3
9
  requested: z.ZodString;
4
10
  provider: z.ZodString;
@@ -359,6 +365,12 @@ export declare const agentCandidateExecutionPlanMaterialSchema: z.ZodObject<{
359
365
  access: z.ZodObject<{
360
366
  kind: z.ZodLiteral<"evaluator-mediated">;
361
367
  grantDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
368
+ network: z.ZodDiscriminatedUnion<[z.ZodObject<{
369
+ mode: z.ZodLiteral<"disabled">;
370
+ }, z.core.$strict>, z.ZodObject<{
371
+ mode: z.ZodLiteral<"gateway-only">;
372
+ domains: z.ZodArray<z.ZodString>;
373
+ }, z.core.$strict>], "mode">;
362
374
  }, z.core.$strict>;
363
375
  routes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
364
376
  kind: z.ZodLiteral<"primary">;
@@ -684,6 +696,12 @@ export declare const agentCandidateExecutionPlanEvidenceSchema: z.ZodObject<{
684
696
  access: {
685
697
  kind: "evaluator-mediated";
686
698
  grantDigest: `sha256:${string}`;
699
+ network: {
700
+ mode: "disabled";
701
+ } | {
702
+ mode: "gateway-only";
703
+ domains: string[];
704
+ };
687
705
  };
688
706
  routes: ({
689
707
  kind: "primary";
@@ -989,6 +1007,12 @@ export declare const agentCandidateExecutionPlanEvidenceSchema: z.ZodObject<{
989
1007
  access: {
990
1008
  kind: "evaluator-mediated";
991
1009
  grantDigest: `sha256:${string}`;
1010
+ network: {
1011
+ mode: "disabled";
1012
+ } | {
1013
+ mode: "gateway-only";
1014
+ domains: string[];
1015
+ };
992
1016
  };
993
1017
  routes: ({
994
1018
  kind: "primary";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
3
3
  import { agentCandidateContainerSchema, agentCandidateInstructionDeliverySchema, agentCandidateWorkingDirectorySchema, } from "./agent-candidate-code-schema.js";
4
- import { addDuplicateIssues, agentCandidateConfigValueSchema, environmentConfigSchema, gitObjectSchema, isCanonicalJsonValue, isSafeExecutable, isSafeRelativePath, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
4
+ import { addDuplicateIssues, agentCandidateConfigValueSchema, environmentConfigSchema, gitObjectSchema, isCanonicalJsonValue, isObviouslyPrivateHostname, isSafeExecutable, isSafeRelativePath, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
5
5
  import { harnessTypeSchema } from "./harness.js";
6
6
  const reasoningEffortSchema = z.enum([
7
7
  "none",
@@ -21,6 +21,34 @@ function isCanonicalAbsolutePath(value) {
21
21
  function pathsOverlap(left, right) {
22
22
  return left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`);
23
23
  }
24
+ function isExactPublicGatewayDomain(value) {
25
+ if (value.length > 253 ||
26
+ value !== value.toLowerCase() ||
27
+ value.endsWith(".") ||
28
+ value.includes(":") ||
29
+ isObviouslyPrivateHostname(value)) {
30
+ return false;
31
+ }
32
+ const labels = value.split(".");
33
+ return (labels.length >= 2 &&
34
+ labels.every((label) => label.length >= 1 &&
35
+ label.length <= 63 &&
36
+ /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(label)) &&
37
+ /[a-z]/.test(labels.at(-1) ?? ""));
38
+ }
39
+ export const agentCandidateModelAccessNetworkSchema = z.discriminatedUnion("mode", [
40
+ z.object({ mode: z.literal("disabled") }).strict(),
41
+ z
42
+ .object({
43
+ mode: z.literal("gateway-only"),
44
+ domains: z
45
+ .array(z
46
+ .string()
47
+ .refine(isExactPublicGatewayDomain, "model gateway must be an exact lowercase public DNS name"))
48
+ .min(1),
49
+ })
50
+ .strict(),
51
+ ]);
24
52
  export const agentCandidateResolvedModelSchema = z
25
53
  .object({
26
54
  requested: z.string().min(1),
@@ -195,6 +223,7 @@ export const agentCandidateExecutionPlanMaterialSchema = z
195
223
  .object({
196
224
  kind: z.literal("evaluator-mediated"),
197
225
  grantDigest: sha256DigestSchema,
226
+ network: agentCandidateModelAccessNetworkSchema,
198
227
  })
199
228
  .strict(),
200
229
  routes: z
@@ -300,6 +329,33 @@ export const agentCandidateExecutionPlanMaterialSchema = z
300
329
  });
301
330
  }
302
331
  }
332
+ const modelNetwork = material.model.access.network;
333
+ if (material.limits.maxModelCalls === 0 && modelNetwork.mode !== "disabled") {
334
+ ctx.addIssue({
335
+ code: "custom",
336
+ path: ["model", "access", "network"],
337
+ message: "zero-call plans cannot expose a model gateway",
338
+ });
339
+ }
340
+ if (material.limits.maxModelCalls > 0 && modelNetwork.mode !== "gateway-only") {
341
+ ctx.addIssue({
342
+ code: "custom",
343
+ path: ["model", "access", "network"],
344
+ message: "model-calling plans require one frozen gateway allowlist",
345
+ });
346
+ }
347
+ if (modelNetwork.mode === "gateway-only") {
348
+ addDuplicateIssues(modelNetwork.domains, ["model", "access", "network", "domains"], ctx);
349
+ for (let index = 1; index < modelNetwork.domains.length; index++) {
350
+ if ((modelNetwork.domains[index - 1] ?? "") >= (modelNetwork.domains[index] ?? "")) {
351
+ ctx.addIssue({
352
+ code: "custom",
353
+ path: ["model", "access", "network", "domains", index],
354
+ message: "model gateway domains must be lexicographically sorted",
355
+ });
356
+ }
357
+ }
358
+ }
303
359
  const activeCode = material.codeKind !== "disabled";
304
360
  if (activeCode !== (material.candidateWorkspace !== undefined)) {
305
361
  ctx.addIssue({