@nylorun/runtime 0.29.0-beta → 0.31.0-beta

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 (49) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/api/components.d.ts +240 -2
  3. package/dist/api/components.js +3 -1
  4. package/dist/api/http/routes/agent-manifests.d.ts +2 -1
  5. package/dist/api/http/routes/agent-manifests.js +62 -10
  6. package/dist/api/openapi.js +2 -0
  7. package/dist/gates/egress-credentials.js +2 -13
  8. package/dist/gates/handler.js +2 -1
  9. package/dist/gates/in-process.d.ts +9 -0
  10. package/dist/gates/in-process.js +21 -0
  11. package/dist/host/http.js +3 -1
  12. package/dist/host/main.js +2 -0
  13. package/dist/host/stack-config.d.ts +10 -0
  14. package/dist/host/stack-config.js +36 -0
  15. package/dist/management-openapi.json +361 -5
  16. package/dist/mcp/connect.d.ts +34 -5
  17. package/dist/mcp/connect.js +75 -14
  18. package/dist/mcp/gateway-outcomes.d.ts +14 -0
  19. package/dist/mcp/gateway-outcomes.js +46 -0
  20. package/dist/mcp/pool.js +5 -0
  21. package/dist/model/call-headers.d.ts +15 -0
  22. package/dist/model/call-headers.js +9 -0
  23. package/dist/model/models.d.ts +7 -0
  24. package/dist/model/models.js +3 -0
  25. package/dist/model/pi-model.d.ts +6 -0
  26. package/dist/model/pi-model.js +29 -3
  27. package/dist/openapi.json +654 -30
  28. package/dist/store/postgres/drizzle/0038_t6_agent_manifest_source.sql +1 -0
  29. package/dist/store/postgres/drizzle/meta/_journal.json +7 -0
  30. package/dist/store/postgres/schema.d.ts +21 -2
  31. package/dist/store/postgres/schema.js +7 -1
  32. package/dist/store/postgres/store.js +1 -0
  33. package/dist/store/types.d.ts +14 -0
  34. package/dist/tenant/agent-manifests.d.ts +18 -25
  35. package/dist/tenant/agent-manifests.js +136 -4
  36. package/dist/tenant/agents.js +7 -3
  37. package/dist/tenant/transcript.d.ts +8 -0
  38. package/dist/tenant/transcript.js +2 -0
  39. package/dist/vault/headers.d.ts +8 -0
  40. package/dist/vault/headers.js +25 -0
  41. package/dist/vault/host-model.js +8 -5
  42. package/dist/vault/service.d.ts +12 -5
  43. package/dist/vault/service.js +43 -6
  44. package/dist/vault/sources.js +22 -1
  45. package/dist/vault/workload-token.d.ts +16 -0
  46. package/dist/vault/workload-token.js +58 -0
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.31.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - aaa079f: The Runtime saves agent folders (track T6). `PUT /v1/agent-manifests/{name}` with `Content-Type: application/vnd.nylorun.folder+json` takes a folder by hash (`PutAgentFolderRequestSchema`): the files uploaded first, the Markdown and JSON read back from the definition file store and compiled with `compileAgentFolder`. A folder that does not compile is `422 folder_invalid`, with the compiler's diagnostics by file, line and column in `details.diagnostics`. A save keeps the folder as the version's source: `AgentManifestView.source` summarises it, `GET /v1/agent-manifests/{name}/versions/{v}/source` lists its files and `.../source/files/{path}` returns one. With `?dryRun=true` the plan adds the compiled `manifest`, the `diagnostics` and the `compiler`. A folder whose manifest is unchanged saves no version, and says so (`source_not_saved`). New Host feature `agent-folders`; new error code `folder_invalid`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Pin core to the tested release.
12
+ - Pin harness to the tested release.
13
+ - Updated dependencies [9ba6634]
14
+ - Updated dependencies [aaa079f]
15
+ - Updated dependencies
16
+ - @nylorun/core@0.27.0-beta
17
+ - @nylorun/harness@0.29.3-beta
18
+
19
+ ## 0.30.0-beta
20
+
21
+ ### Minor Changes
22
+
23
+ - fce0c9b: Headers for a custom model endpoint (#493). A custom endpoint's `settings` (`PUT /v1/tenant/model`) take `headers`, sent on every call, and `callHeaders`, whose values the Runtime resolves per call from the calling Agent: one of its labels (`{ from: "agent.label", key: "org" }`), its id (`agent.id`) or the session's owner when it is a person (`session.owner`). A source with no value sends no header. A Runtime that serves several orgs' Agents can then send each call's org (`x-nylorun-org` from the `org` label), so a model gateway attributes and budgets it while the call is made, in process and through the gates service alike. They are settings, read back by `GET /v1/tenant/model`: neither map may set `authorization`, a hop-by-hop or transport header, or `Nylorun-*`, and a name appears once across both. Studio keeps them when it saves the model.
24
+ - ab7c08a: A gateway's tool prefix (#494, Host feature `gateway-credentials`). A `bearer` or `headers` credential with `via`, written to an Agent's vault, may add `toolPrefix`: what the gateway at `via` puts before each tool name it lists, such as LiteLLM's `github-`. The Runtime lists the server's tools without it, so tool names (`github__create_issue`), a manifest's `tools` settings and tool policy rules name the server's own tools whether or not a gateway is in between, and calls each tool by the name the gateway listed. A listed tool that lacks the prefix keeps its name, and the server's `mcp.discovered` message names it. `toolPrefix` needs `via`, and secret views carry it. It is the installation's routing, never a manifest's: a manifest's secret slot cannot name it, and a slot's value write (`{ headers, toolPrefix }`) adds it. A fork keeps it while the new slot keeps `via`. No protocol change.
25
+ - 4a563e7: The workload token (#496). A Runtime given `NYLORUN_WORKLOAD_TOKEN_FILE`, a token a platform rotates through a file, reads it at each use and keeps nothing, so a rotation applies to the next request with no restart; a missing, unreadable or empty file fails the request, naming the variable, and nothing is sent without it. A custom model with `auth: { type: "workload" }` sends it as the endpoint's bearer. A new credential type, `workload` (`{ url, via, identity?, toolPrefix? }`, no value), sends `Authorization: Bearer <token>` to its `via` only, and only when `via`'s origin is in `NYLORUN_WORKLOAD_TOKEN_ORIGINS`, since an Agent's writer chooses `via`. A gateway's `401` is `credential_rejected` with `gateway`, its origin. The token stays in the process that makes the call: never in a sandbox, the model, an event or a log. Studio shows the credential and the model's auth.
26
+
27
+ ### Patch Changes
28
+
29
+ - 8c82ed9: An MCP gateway's report of an upstream `401` is `credential_rejected` (#495). Through a credential's `via`, a gateway that answers HTTP 200 but reports that the server behind it answered `401` is read like a `401`. LiteLLM does this for a token the provider revoked: a `tools/list` with no tools and `"auth_required"` for the server in `_meta["litellm.ai/server_outcomes"]` makes the server's `mcp.discovered` outcome `failed` ("MCP server returned 401"), and a tool error carrying that outcome, or LiteLLM's `HTTPStatusError: Client error '401 Unauthorized'` text, completes as `credential_rejected` with `retryable: false`, naming the server. A server reached without `via` is read as before.
30
+ - Pin core to the tested release.
31
+ - Pin harness to the tested release.
32
+ - Updated dependencies [fce0c9b]
33
+ - Updated dependencies [ab7c08a]
34
+ - Updated dependencies [4a563e7]
35
+ - Updated dependencies
36
+ - @nylorun/core@0.26.0-beta
37
+ - @nylorun/harness@0.29.2-beta
38
+
3
39
  ## 0.29.0-beta
4
40
 
5
41
  ### Minor Changes
@@ -21,6 +21,7 @@ export declare const Rejected: z.ZodObject<{
21
21
  credential_rejected: "credential_rejected";
22
22
  credential_required: "credential_required";
23
23
  definition_files_missing: "definition_files_missing";
24
+ folder_invalid: "folder_invalid";
24
25
  harness_mismatch: "harness_mismatch";
25
26
  host_rejected: "host_rejected";
26
27
  incompatible_host: "incompatible_host";
@@ -517,6 +518,29 @@ export declare const PutAgentManifestRequest: z.ZodObject<{
517
518
  }, z.core.$strict>>;
518
519
  requestId: z.ZodOptional<z.ZodString>;
519
520
  }, z.core.$strict>;
521
+ export declare const PutAgentFolderRequest: z.ZodObject<{
522
+ requestId: z.ZodOptional<z.ZodString>;
523
+ format: z.ZodLiteral<"nylorun.folder.v2">;
524
+ entries: z.ZodArray<z.ZodObject<{
525
+ path: z.ZodString;
526
+ size: z.ZodNumber;
527
+ sha256: z.ZodString;
528
+ contentType: z.ZodOptional<z.ZodString>;
529
+ mode: z.ZodOptional<z.ZodNumber>;
530
+ }, z.core.$strict>>;
531
+ }, z.core.$strict>;
532
+ export declare const AgentManifestSource: z.ZodObject<{
533
+ name: z.ZodString;
534
+ version: z.ZodNumber;
535
+ compiler: z.ZodString;
536
+ files: z.ZodNumber;
537
+ bytes: z.ZodNumber;
538
+ entries: z.ZodArray<z.ZodObject<{
539
+ path: z.ZodString;
540
+ size: z.ZodNumber;
541
+ sha256: z.ZodString;
542
+ }, z.core.$strict>>;
543
+ }, z.core.$strict>;
520
544
  export declare const AgentManifestView: z.ZodObject<{
521
545
  name: z.ZodString;
522
546
  version: z.ZodNumber;
@@ -622,6 +646,11 @@ export declare const AgentManifestView: z.ZodObject<{
622
646
  }, z.core.$strict>;
623
647
  createdAt: z.ZodString;
624
648
  agents: z.ZodNumber;
649
+ source: z.ZodOptional<z.ZodObject<{
650
+ compiler: z.ZodString;
651
+ files: z.ZodNumber;
652
+ bytes: z.ZodNumber;
653
+ }, z.core.$strict>>;
625
654
  }, z.core.$strict>;
626
655
  export declare const AgentManifestPlan: z.ZodObject<{
627
656
  name: z.ZodString;
@@ -654,6 +683,117 @@ export declare const AgentManifestPlan: z.ZodObject<{
654
683
  nextStart: z.ZodNumber;
655
684
  secrets: z.ZodNumber;
656
685
  }, z.core.$strict>;
686
+ manifest: z.ZodOptional<z.ZodObject<{
687
+ manifestSchemaVersion: z.ZodLiteral<8>;
688
+ name: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
689
+ description: z.ZodOptional<z.ZodString>;
690
+ metadata: z.ZodOptional<z.ZodType<import("@nylorun/core/define").JsonObject, unknown, z.core.$ZodTypeInternals<import("@nylorun/core/define").JsonObject, unknown>>>;
691
+ harness: z.ZodUnion<readonly [z.ZodType<import("@nylorun/core/contracts").WorkflowHarnessSection, unknown, z.core.$ZodTypeInternals<import("@nylorun/core/contracts").WorkflowHarnessSection, unknown>>, z.ZodType<import("@nylorun/core/contracts").AgentHarnessSection, unknown, z.core.$ZodTypeInternals<import("@nylorun/core/contracts").AgentHarnessSection, unknown>>]>;
692
+ runtime: z.ZodOptional<z.ZodObject<{
693
+ kind: z.ZodEnum<{
694
+ none: "none";
695
+ pod: "pod";
696
+ virtual: "virtual";
697
+ }>;
698
+ image: z.ZodOptional<z.ZodString>;
699
+ resources: z.ZodOptional<z.ZodObject<{
700
+ cpus: z.ZodOptional<z.ZodNumber>;
701
+ memory: z.ZodOptional<z.ZodString>;
702
+ }, z.core.$strict>>;
703
+ storage: z.ZodOptional<z.ZodString>;
704
+ network: z.ZodOptional<z.ZodObject<{
705
+ allowedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
706
+ }, z.core.$strict>>;
707
+ lifecycle: z.ZodOptional<z.ZodObject<{
708
+ idle: z.ZodOptional<z.ZodString>;
709
+ deleteAfter: z.ZodOptional<z.ZodString>;
710
+ }, z.core.$strict>>;
711
+ setup: z.ZodOptional<z.ZodArray<z.ZodObject<{
712
+ command: z.ZodString;
713
+ cwd: z.ZodOptional<z.ZodString>;
714
+ timeout: z.ZodOptional<z.ZodString>;
715
+ }, z.core.$strict>>>;
716
+ files: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
717
+ artifactId: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
718
+ version: z.ZodNumber;
719
+ path: z.ZodString;
720
+ }, z.core.$strict>, z.ZodObject<{
721
+ path: z.ZodString;
722
+ files: z.ZodRecord<z.ZodString, z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
723
+ }, z.core.$strict>]>>>;
724
+ limits: z.ZodOptional<z.ZodObject<{
725
+ artifacts: z.ZodOptional<z.ZodObject<{
726
+ fileBytes: z.ZodOptional<z.ZodNumber>;
727
+ totalBytes: z.ZodOptional<z.ZodNumber>;
728
+ }, z.core.$strict>>;
729
+ skills: z.ZodOptional<z.ZodObject<{
730
+ totalBytes: z.ZodOptional<z.ZodNumber>;
731
+ }, z.core.$strict>>;
732
+ disk: z.ZodOptional<z.ZodObject<{
733
+ versionBytes: z.ZodOptional<z.ZodNumber>;
734
+ versionEntries: z.ZodOptional<z.ZodNumber>;
735
+ }, z.core.$strict>>;
736
+ }, z.core.$strict>>;
737
+ secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
738
+ required: z.ZodOptional<z.ZodBoolean>;
739
+ description: z.ZodOptional<z.ZodString>;
740
+ type: z.ZodLiteral<"environment_secret">;
741
+ allowedHosts: z.ZodArray<z.ZodString>;
742
+ inject: z.ZodOptional<z.ZodObject<{
743
+ header: z.ZodString;
744
+ format: z.ZodString;
745
+ }, z.core.$strict>>;
746
+ }, z.core.$strict>, z.ZodObject<{
747
+ required: z.ZodOptional<z.ZodBoolean>;
748
+ description: z.ZodOptional<z.ZodString>;
749
+ type: z.ZodLiteral<"environment_variable">;
750
+ }, z.core.$strict>, z.ZodObject<{
751
+ via: z.ZodOptional<z.ZodString>;
752
+ identity: z.ZodOptional<z.ZodObject<{
753
+ header: z.ZodString;
754
+ }, z.core.$strict>>;
755
+ required: z.ZodOptional<z.ZodBoolean>;
756
+ description: z.ZodOptional<z.ZodString>;
757
+ type: z.ZodLiteral<"bearer">;
758
+ url: z.ZodString;
759
+ }, z.core.$strict>, z.ZodObject<{
760
+ via: z.ZodOptional<z.ZodString>;
761
+ identity: z.ZodOptional<z.ZodObject<{
762
+ header: z.ZodString;
763
+ }, z.core.$strict>>;
764
+ required: z.ZodOptional<z.ZodBoolean>;
765
+ description: z.ZodOptional<z.ZodString>;
766
+ type: z.ZodLiteral<"headers">;
767
+ url: z.ZodString;
768
+ }, z.core.$strict>], "type">>>;
769
+ triggers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
770
+ schedule: z.ZodOptional<z.ZodString>;
771
+ timezone: z.ZodOptional<z.ZodString>;
772
+ at: z.ZodOptional<z.ZodISODateTime>;
773
+ webhook: z.ZodOptional<z.ZodEnum<{
774
+ "standard-webhooks": "standard-webhooks";
775
+ }>>;
776
+ session: z.ZodString;
777
+ prompt: z.ZodString;
778
+ }, z.core.$strict>>>;
779
+ selfWake: z.ZodOptional<z.ZodBoolean>;
780
+ }, z.core.$strict>>;
781
+ }, z.core.$strict>>;
782
+ diagnostics: z.ZodOptional<z.ZodArray<z.ZodObject<{
783
+ severity: z.ZodEnum<{
784
+ error: "error";
785
+ info: "info";
786
+ note: "note";
787
+ warning: "warning";
788
+ }>;
789
+ code: z.ZodString;
790
+ message: z.ZodString;
791
+ file: z.ZodOptional<z.ZodString>;
792
+ line: z.ZodOptional<z.ZodNumber>;
793
+ column: z.ZodOptional<z.ZodNumber>;
794
+ pointer: z.ZodOptional<z.ZodString>;
795
+ }, z.core.$strict>>>;
796
+ compiler: z.ZodOptional<z.ZodString>;
657
797
  }, z.core.$strict>;
658
798
  export declare const SaveAgentManifestResponse: z.ZodObject<{
659
799
  manifest: z.ZodObject<{
@@ -761,12 +901,31 @@ export declare const SaveAgentManifestResponse: z.ZodObject<{
761
901
  }, z.core.$strict>;
762
902
  createdAt: z.ZodString;
763
903
  agents: z.ZodNumber;
904
+ source: z.ZodOptional<z.ZodObject<{
905
+ compiler: z.ZodString;
906
+ files: z.ZodNumber;
907
+ bytes: z.ZodNumber;
908
+ }, z.core.$strict>>;
764
909
  }, z.core.$strict>;
765
910
  unchanged: z.ZodBoolean;
766
911
  warnings: z.ZodArray<z.ZodObject<{
767
912
  code: z.ZodString;
768
913
  message: z.ZodString;
769
914
  }, z.core.$strict>>;
915
+ diagnostics: z.ZodOptional<z.ZodArray<z.ZodObject<{
916
+ severity: z.ZodEnum<{
917
+ error: "error";
918
+ info: "info";
919
+ note: "note";
920
+ warning: "warning";
921
+ }>;
922
+ code: z.ZodString;
923
+ message: z.ZodString;
924
+ file: z.ZodOptional<z.ZodString>;
925
+ line: z.ZodOptional<z.ZodNumber>;
926
+ column: z.ZodOptional<z.ZodNumber>;
927
+ pointer: z.ZodOptional<z.ZodString>;
928
+ }, z.core.$strict>>>;
770
929
  }, z.core.$strict>;
771
930
  export declare const ListAgentManifestsResponse: z.ZodObject<{
772
931
  manifests: z.ZodArray<z.ZodObject<{
@@ -874,6 +1033,11 @@ export declare const ListAgentManifestsResponse: z.ZodObject<{
874
1033
  }, z.core.$strict>;
875
1034
  createdAt: z.ZodString;
876
1035
  agents: z.ZodNumber;
1036
+ source: z.ZodOptional<z.ZodObject<{
1037
+ compiler: z.ZodString;
1038
+ files: z.ZodNumber;
1039
+ bytes: z.ZodNumber;
1040
+ }, z.core.$strict>>;
877
1041
  }, z.core.$strict>>;
878
1042
  }, z.core.$strict>;
879
1043
  export declare const AgentManifestVersions: z.ZodObject<{
@@ -897,6 +1061,7 @@ export declare const PutAgentSecretValueRequest: z.ZodObject<{
897
1061
  requestId: z.ZodOptional<z.ZodString>;
898
1062
  value: z.ZodOptional<z.ZodString>;
899
1063
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1064
+ toolPrefix: z.ZodOptional<z.ZodString>;
900
1065
  }, z.core.$strict>;
901
1066
  export declare const AgentSnapshot: z.ZodObject<{
902
1067
  agentId: z.ZodString;
@@ -4447,6 +4612,7 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
4447
4612
  code: z.ZodString;
4448
4613
  message: z.ZodString;
4449
4614
  server: z.ZodOptional<z.ZodString>;
4615
+ gateway: z.ZodOptional<z.ZodString>;
4450
4616
  retryable: z.ZodOptional<z.ZodBoolean>;
4451
4617
  }, z.core.$loose>>;
4452
4618
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -7179,6 +7345,7 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
7179
7345
  code: z.ZodString;
7180
7346
  message: z.ZodString;
7181
7347
  server: z.ZodOptional<z.ZodString>;
7348
+ gateway: z.ZodOptional<z.ZodString>;
7182
7349
  retryable: z.ZodOptional<z.ZodBoolean>;
7183
7350
  }, z.core.$loose>>;
7184
7351
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -9914,6 +10081,7 @@ export declare const SessionItemsResponse: z.ZodObject<{
9914
10081
  code: z.ZodString;
9915
10082
  message: z.ZodString;
9916
10083
  server: z.ZodOptional<z.ZodString>;
10084
+ gateway: z.ZodOptional<z.ZodString>;
9917
10085
  retryable: z.ZodOptional<z.ZodBoolean>;
9918
10086
  }, z.core.$loose>>;
9919
10087
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -12646,6 +12814,7 @@ export declare const SessionItemsResponse: z.ZodObject<{
12646
12814
  code: z.ZodString;
12647
12815
  message: z.ZodString;
12648
12816
  server: z.ZodOptional<z.ZodString>;
12817
+ gateway: z.ZodOptional<z.ZodString>;
12649
12818
  retryable: z.ZodOptional<z.ZodBoolean>;
12650
12819
  }, z.core.$loose>>;
12651
12820
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -13224,6 +13393,7 @@ export declare const TenantStatus: z.ZodObject<{
13224
13393
  authType: z.ZodEnum<{
13225
13394
  api_key: "api_key";
13226
13395
  oauth: "oauth";
13396
+ workload: "workload";
13227
13397
  }>;
13228
13398
  baseUrl: z.ZodOptional<z.ZodString>;
13229
13399
  settings: z.ZodOptional<z.ZodObject<{
@@ -13239,6 +13409,15 @@ export declare const TenantStatus: z.ZodObject<{
13239
13409
  video: "video";
13240
13410
  }>>>;
13241
13411
  compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13412
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13413
+ callHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
13414
+ from: z.ZodLiteral<"agent.label">;
13415
+ key: z.ZodString;
13416
+ }, z.core.$strict>, z.ZodObject<{
13417
+ from: z.ZodLiteral<"agent.id">;
13418
+ }, z.core.$strict>, z.ZodObject<{
13419
+ from: z.ZodLiteral<"session.owner">;
13420
+ }, z.core.$strict>], "from">>>;
13242
13421
  }, z.core.$strict>>;
13243
13422
  }, z.core.$strict>]>;
13244
13423
  agents: z.ZodArray<z.ZodObject<{
@@ -13357,6 +13536,15 @@ export declare const SeedTenantConfigRequest: z.ZodObject<{
13357
13536
  video: "video";
13358
13537
  }>>>;
13359
13538
  compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13539
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13540
+ callHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
13541
+ from: z.ZodLiteral<"agent.label">;
13542
+ key: z.ZodString;
13543
+ }, z.core.$strict>, z.ZodObject<{
13544
+ from: z.ZodLiteral<"agent.id">;
13545
+ }, z.core.$strict>, z.ZodObject<{
13546
+ from: z.ZodLiteral<"session.owner">;
13547
+ }, z.core.$strict>], "from">>>;
13360
13548
  }, z.core.$strict>>;
13361
13549
  auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
13362
13550
  type: z.ZodLiteral<"api_key">;
@@ -13367,7 +13555,9 @@ export declare const SeedTenantConfigRequest: z.ZodObject<{
13367
13555
  refresh: z.ZodString;
13368
13556
  access: z.ZodString;
13369
13557
  expires: z.ZodNumber;
13370
- }, z.core.$loose>], "type">;
13558
+ }, z.core.$loose>, z.ZodObject<{
13559
+ type: z.ZodLiteral<"workload">;
13560
+ }, z.core.$strict>], "type">;
13371
13561
  }, z.core.$strict>>;
13372
13562
  fixtureModel: z.ZodOptional<z.ZodLiteral<true>>;
13373
13563
  }, z.core.$strict>;
@@ -13626,6 +13816,7 @@ export declare const ListProvidersResponse: z.ZodObject<{
13626
13816
  authType: z.ZodEnum<{
13627
13817
  api_key: "api_key";
13628
13818
  oauth: "oauth";
13819
+ workload: "workload";
13629
13820
  }>;
13630
13821
  baseUrl: z.ZodOptional<z.ZodString>;
13631
13822
  settings: z.ZodOptional<z.ZodObject<{
@@ -13641,6 +13832,15 @@ export declare const ListProvidersResponse: z.ZodObject<{
13641
13832
  video: "video";
13642
13833
  }>>>;
13643
13834
  compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13835
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13836
+ callHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
13837
+ from: z.ZodLiteral<"agent.label">;
13838
+ key: z.ZodString;
13839
+ }, z.core.$strict>, z.ZodObject<{
13840
+ from: z.ZodLiteral<"agent.id">;
13841
+ }, z.core.$strict>, z.ZodObject<{
13842
+ from: z.ZodLiteral<"session.owner">;
13843
+ }, z.core.$strict>], "from">>>;
13644
13844
  }, z.core.$strict>>;
13645
13845
  inputs: z.ZodOptional<z.ZodArray<z.ZodEnum<{
13646
13846
  audio: "audio";
@@ -13663,6 +13863,7 @@ export declare const HostModelView: z.ZodUnion<readonly [z.ZodObject<{
13663
13863
  authType: z.ZodEnum<{
13664
13864
  api_key: "api_key";
13665
13865
  oauth: "oauth";
13866
+ workload: "workload";
13666
13867
  }>;
13667
13868
  baseUrl: z.ZodOptional<z.ZodString>;
13668
13869
  settings: z.ZodOptional<z.ZodObject<{
@@ -13678,6 +13879,15 @@ export declare const HostModelView: z.ZodUnion<readonly [z.ZodObject<{
13678
13879
  video: "video";
13679
13880
  }>>>;
13680
13881
  compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13882
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13883
+ callHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
13884
+ from: z.ZodLiteral<"agent.label">;
13885
+ key: z.ZodString;
13886
+ }, z.core.$strict>, z.ZodObject<{
13887
+ from: z.ZodLiteral<"agent.id">;
13888
+ }, z.core.$strict>, z.ZodObject<{
13889
+ from: z.ZodLiteral<"session.owner">;
13890
+ }, z.core.$strict>], "from">>>;
13681
13891
  }, z.core.$strict>>;
13682
13892
  }, z.core.$strict>]>;
13683
13893
  export declare const PutHostModelRequest: z.ZodObject<{
@@ -13699,6 +13909,15 @@ export declare const PutHostModelRequest: z.ZodObject<{
13699
13909
  video: "video";
13700
13910
  }>>>;
13701
13911
  compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13912
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13913
+ callHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
13914
+ from: z.ZodLiteral<"agent.label">;
13915
+ key: z.ZodString;
13916
+ }, z.core.$strict>, z.ZodObject<{
13917
+ from: z.ZodLiteral<"agent.id">;
13918
+ }, z.core.$strict>, z.ZodObject<{
13919
+ from: z.ZodLiteral<"session.owner">;
13920
+ }, z.core.$strict>], "from">>>;
13702
13921
  }, z.core.$strict>>;
13703
13922
  auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
13704
13923
  type: z.ZodLiteral<"api_key">;
@@ -13709,7 +13928,9 @@ export declare const PutHostModelRequest: z.ZodObject<{
13709
13928
  refresh: z.ZodString;
13710
13929
  access: z.ZodString;
13711
13930
  expires: z.ZodNumber;
13712
- }, z.core.$loose>], "type">;
13931
+ }, z.core.$loose>, z.ZodObject<{
13932
+ type: z.ZodLiteral<"workload">;
13933
+ }, z.core.$strict>], "type">;
13713
13934
  }, z.core.$strict>;
13714
13935
  export declare const SelectHostModelRequest: z.ZodObject<{
13715
13936
  requestId: z.ZodString;
@@ -13740,6 +13961,7 @@ export declare const PutAgentSecretRequest: z.ZodDiscriminatedUnion<[z.ZodObject
13740
13961
  type: z.ZodLiteral<"bearer">;
13741
13962
  url: z.ZodString;
13742
13963
  value: z.ZodString;
13964
+ toolPrefix: z.ZodOptional<z.ZodString>;
13743
13965
  }, z.core.$strict>, z.ZodObject<{
13744
13966
  via: z.ZodOptional<z.ZodString>;
13745
13967
  identity: z.ZodOptional<z.ZodObject<{
@@ -13749,6 +13971,16 @@ export declare const PutAgentSecretRequest: z.ZodDiscriminatedUnion<[z.ZodObject
13749
13971
  type: z.ZodLiteral<"headers">;
13750
13972
  url: z.ZodString;
13751
13973
  headers: z.ZodRecord<z.ZodString, z.ZodString>;
13974
+ toolPrefix: z.ZodOptional<z.ZodString>;
13975
+ }, z.core.$strict>, z.ZodObject<{
13976
+ requestId: z.ZodOptional<z.ZodString>;
13977
+ type: z.ZodLiteral<"workload">;
13978
+ url: z.ZodString;
13979
+ via: z.ZodString;
13980
+ identity: z.ZodOptional<z.ZodObject<{
13981
+ header: z.ZodString;
13982
+ }, z.core.$strict>>;
13983
+ toolPrefix: z.ZodOptional<z.ZodString>;
13752
13984
  }, z.core.$strict>], "type">;
13753
13985
  export declare const AgentSecretView: z.ZodObject<{
13754
13986
  name: z.ZodString;
@@ -13757,6 +13989,7 @@ export declare const AgentSecretView: z.ZodObject<{
13757
13989
  environment_secret: "environment_secret";
13758
13990
  environment_variable: "environment_variable";
13759
13991
  headers: "headers";
13992
+ workload: "workload";
13760
13993
  }>;
13761
13994
  binding: z.ZodObject<{
13762
13995
  url: z.ZodOptional<z.ZodString>;
@@ -13768,6 +14001,7 @@ export declare const AgentSecretView: z.ZodObject<{
13768
14001
  }, z.core.$strict>;
13769
14002
  headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
13770
14003
  via: z.ZodOptional<z.ZodString>;
14004
+ toolPrefix: z.ZodOptional<z.ZodString>;
13771
14005
  identity: z.ZodOptional<z.ZodObject<{
13772
14006
  header: z.ZodString;
13773
14007
  }, z.core.$strict>>;
@@ -13782,6 +14016,7 @@ export declare const ListAgentSecretsResponse: z.ZodObject<{
13782
14016
  environment_secret: "environment_secret";
13783
14017
  environment_variable: "environment_variable";
13784
14018
  headers: "headers";
14019
+ workload: "workload";
13785
14020
  }>;
13786
14021
  binding: z.ZodObject<{
13787
14022
  url: z.ZodOptional<z.ZodString>;
@@ -13793,6 +14028,7 @@ export declare const ListAgentSecretsResponse: z.ZodObject<{
13793
14028
  }, z.core.$strict>;
13794
14029
  headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
13795
14030
  via: z.ZodOptional<z.ZodString>;
14031
+ toolPrefix: z.ZodOptional<z.ZodString>;
13796
14032
  identity: z.ZodOptional<z.ZodObject<{
13797
14033
  header: z.ZodString;
13798
14034
  }, z.core.$strict>>;
@@ -16210,6 +16446,7 @@ export declare const HistoryPage: z.ZodObject<{
16210
16446
  code: z.ZodString;
16211
16447
  message: z.ZodString;
16212
16448
  server: z.ZodOptional<z.ZodString>;
16449
+ gateway: z.ZodOptional<z.ZodString>;
16213
16450
  retryable: z.ZodOptional<z.ZodBoolean>;
16214
16451
  }, z.core.$loose>>;
16215
16452
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -18942,6 +19179,7 @@ export declare const HistoryPage: z.ZodObject<{
18942
19179
  code: z.ZodString;
18943
19180
  message: z.ZodString;
18944
19181
  server: z.ZodOptional<z.ZodString>;
19182
+ gateway: z.ZodOptional<z.ZodString>;
18945
19183
  retryable: z.ZodOptional<z.ZodBoolean>;
18946
19184
  }, z.core.$loose>>;
18947
19185
  redacted: z.ZodOptional<z.ZodNumber>;
@@ -5,7 +5,7 @@
5
5
  * global registry.
6
6
  */
7
7
  import { z } from "zod";
8
- import { QueuedResponseSchema, TriggerListSchema, MemoryListSchema, MemorySchema, PutMemoryRequestSchema, MemoryVersionPageSchema, MemoryVersionDetailSchema, TriggerRunPageSchema, RunTriggerResponseSchema, WebhookSecretResponseSchema, WebhookAcceptedResponseSchema, AgentManifestV8Schema, EnvironmentSecretSlotsSchema, DeleteAgentManifestResponseSchema, AgentManifestPlanSchema, AgentManifestVersionsSchema, AgentManifestViewSchema, ListAgentManifestsResponseSchema, PutAgentManifestRequestSchema, PutAgentSecretValueRequestSchema, SaveAgentManifestResponseSchema, SessionListItemSchema, ModelCallSchema, SessionPageSchema, SessionManifestViewSchema, HistoryPageSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, ModelCallExportPageSchema, AgentPageSchema, ToolCallSchema, ToolCallsPageSchema, TurnTraceSchema, JwksSchema, SigningKeyListSchema, SigningKeyViewSchema, RotateSigningKeysRequestSchema, RevokeSigningKeyRequestSchema, MeResponseSchema, TenantStatusSchema, ResetTenantRequestSchema, ResetTenantResponseSchema, SeedTenantConfigRequestSchema, SeedTenantConfigResponseSchema, HostModelCatalogSchema, TenantSandboxViewSchema, ModelUsageTotalsSchema, ModelBudgetsSchema, PutModelBudgetsRequestSchema, ToolPolicySchema, PutToolPolicyRequestSchema, PutModelInputsRequestSchema, ModelInputsViewSchema, PutTenantEnvironmentsRequestSchema, ListProvidersResponseSchema, HostModelViewSchema, PutHostModelRequestSchema, SelectHostModelRequestSchema, PutAgentSecretRequestSchema, AgentSecretViewSchema, ListAgentSecretsResponseSchema, McpPreviewRequestSchema, McpPreviewSchema, CredentialCoverageRequestSchema, CredentialCoverageSchema, DeletedResponseSchema, ListSessionsResponseSchema, LiveEventSchema, PutAgentRequestSchema, PutSessionRequestSchema, SessionItemsResponseSchema, SessionViewSchema, StreamClosedFrameSchema, AcceptedResponseSchema, SandboxToolOutcomeSchema, AgentViewSchema, AgentSnapshotSchema, RestoreAgentRequestSchema, ForkAgentRequestSchema, AgentForkPlanSchema, ForkAgentResponseSchema, PutAgentDryRunResponseSchema, RestartAgentRequestSchema, AgentRestoreSchema, AgentDiskVersionsSchema, ListAgentsResponseSchema, DeleteAgentResponseSchema, ListAgentEventsResponseSchema, ArtifactViewSchema, ArtifactListItemSchema, ArtifactPageSchema, ArtifactVersionViewSchema, ListArtifactsResponseSchema, UploadArtifactResponseSchema, DefinitionFileViewSchema, DeleteArtifactResponseSchema, CreateArtifactLinkRequestSchema, ArtifactLinkSchema, PutTenantArtifactsRequestSchema, PutTenantSkillsRequestSchema, PutTenantLimitsRequestSchema, TenantLimitsViewSchema, TenantArtifactsViewSchema, TenantSkillsViewSchema, ArtifactTreeSchema, ArtifactDiffSchema, SessionCommandSchema, ListOperatorKeysResponseSchema, PutOperatorKeyResponseSchema, DeleteOperatorKeyResponseSchema, OperatorKeySchema, ProtocolRejectedResponseSchema, RejectedResponseSchema, EVENT_SCHEMAS, EVENT_TYPES, } from "@nylorun/core/contracts";
8
+ import { QueuedResponseSchema, TriggerListSchema, MemoryListSchema, MemorySchema, PutMemoryRequestSchema, MemoryVersionPageSchema, MemoryVersionDetailSchema, TriggerRunPageSchema, RunTriggerResponseSchema, WebhookSecretResponseSchema, WebhookAcceptedResponseSchema, AgentManifestV8Schema, EnvironmentSecretSlotsSchema, DeleteAgentManifestResponseSchema, AgentManifestPlanSchema, AgentManifestVersionsSchema, AgentManifestViewSchema, ListAgentManifestsResponseSchema, PutAgentManifestRequestSchema, PutAgentFolderRequestSchema, AgentManifestSourceSchema, PutAgentSecretValueRequestSchema, SaveAgentManifestResponseSchema, SessionListItemSchema, ModelCallSchema, SessionPageSchema, SessionManifestViewSchema, HistoryPageSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, ModelCallExportPageSchema, AgentPageSchema, ToolCallSchema, ToolCallsPageSchema, TurnTraceSchema, JwksSchema, SigningKeyListSchema, SigningKeyViewSchema, RotateSigningKeysRequestSchema, RevokeSigningKeyRequestSchema, MeResponseSchema, TenantStatusSchema, ResetTenantRequestSchema, ResetTenantResponseSchema, SeedTenantConfigRequestSchema, SeedTenantConfigResponseSchema, HostModelCatalogSchema, TenantSandboxViewSchema, ModelUsageTotalsSchema, ModelBudgetsSchema, PutModelBudgetsRequestSchema, ToolPolicySchema, PutToolPolicyRequestSchema, PutModelInputsRequestSchema, ModelInputsViewSchema, PutTenantEnvironmentsRequestSchema, ListProvidersResponseSchema, HostModelViewSchema, PutHostModelRequestSchema, SelectHostModelRequestSchema, PutAgentSecretRequestSchema, AgentSecretViewSchema, ListAgentSecretsResponseSchema, McpPreviewRequestSchema, McpPreviewSchema, CredentialCoverageRequestSchema, CredentialCoverageSchema, DeletedResponseSchema, ListSessionsResponseSchema, LiveEventSchema, PutAgentRequestSchema, PutSessionRequestSchema, SessionItemsResponseSchema, SessionViewSchema, StreamClosedFrameSchema, AcceptedResponseSchema, SandboxToolOutcomeSchema, AgentViewSchema, AgentSnapshotSchema, RestoreAgentRequestSchema, ForkAgentRequestSchema, AgentForkPlanSchema, ForkAgentResponseSchema, PutAgentDryRunResponseSchema, RestartAgentRequestSchema, AgentRestoreSchema, AgentDiskVersionsSchema, ListAgentsResponseSchema, DeleteAgentResponseSchema, ListAgentEventsResponseSchema, ArtifactViewSchema, ArtifactListItemSchema, ArtifactPageSchema, ArtifactVersionViewSchema, ListArtifactsResponseSchema, UploadArtifactResponseSchema, DefinitionFileViewSchema, DeleteArtifactResponseSchema, CreateArtifactLinkRequestSchema, ArtifactLinkSchema, PutTenantArtifactsRequestSchema, PutTenantSkillsRequestSchema, PutTenantLimitsRequestSchema, TenantLimitsViewSchema, TenantArtifactsViewSchema, TenantSkillsViewSchema, ArtifactTreeSchema, ArtifactDiffSchema, SessionCommandSchema, ListOperatorKeysResponseSchema, PutOperatorKeyResponseSchema, DeleteOperatorKeyResponseSchema, OperatorKeySchema, ProtocolRejectedResponseSchema, RejectedResponseSchema, EVENT_SCHEMAS, EVENT_TYPES, } from "@nylorun/core/contracts";
9
9
  function named(id, schema) {
10
10
  return schema.meta({ id });
11
11
  }
@@ -21,6 +21,8 @@ export const AgentView = named("AgentView", AgentViewSchema);
21
21
  export const EnvironmentSecretSlots = named("EnvironmentSecretSlots", EnvironmentSecretSlotsSchema);
22
22
  export const AgentManifest = named("AgentManifest", AgentManifestV8Schema);
23
23
  export const PutAgentManifestRequest = named("PutAgentManifestRequest", PutAgentManifestRequestSchema);
24
+ export const PutAgentFolderRequest = named("PutAgentFolderRequest", PutAgentFolderRequestSchema);
25
+ export const AgentManifestSource = named("AgentManifestSource", AgentManifestSourceSchema);
24
26
  export const AgentManifestView = named("AgentManifestView", AgentManifestViewSchema);
25
27
  export const AgentManifestPlan = named("AgentManifestPlan", AgentManifestPlanSchema);
26
28
  export const SaveAgentManifestResponse = named("SaveAgentManifestResponse", SaveAgentManifestResponseSchema);
@@ -3,7 +3,8 @@
3
3
  * versioned documents Agents are made from, each with a harness and a runtime section. A save
4
4
  * moves every Agent that tracks the manifest to the new version; a pinned one stays. Reading needs `agents:read` (or a write scope), saving and deleting
5
5
  * `agent-manifests:write`, from any client (Q12). A token caller reaches none: a manifest holds
6
- * an agent's instructions, tools and servers.
6
+ * an agent's instructions, tools and servers. A save may send an agent folder by hash instead of
7
+ * the manifest (track T6): the Runtime compiles it and keeps it as the version's source.
7
8
  */
8
9
  import type { OpenAPIHono } from "@hono/zod-openapi";
9
10
  import type { TenantEnv } from "../app.js";
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
- import { isAgentManifestName, PutAgentManifestRequestSchema } from "@nylorun/core/contracts";
3
- import { AgentManifestPlan, AgentManifestVersions, AgentManifestView, DeleteAgentManifestResponse, ListAgentManifestsResponse, PutAgentManifestRequest, SaveAgentManifestResponse, } from "../../components.js";
2
+ import { AGENT_FOLDER_MEDIA_TYPE, contentTypeFor, isAgentManifestName, PutAgentFolderRequestSchema, PutAgentManifestRequestSchema, } from "@nylorun/core/contracts";
3
+ import { AgentManifestPlan, AgentManifestSource, AgentManifestVersions, AgentManifestView, DeleteAgentManifestResponse, ListAgentManifestsResponse, PutAgentFolderRequest, PutAgentManifestRequest, SaveAgentManifestResponse, } from "../../components.js";
4
4
  import { requirePrincipal } from "../../../tenant/auth.js";
5
5
  import { fail } from "../../../tenant/http.js";
6
- import { agentManifestVersions, deleteAgentManifest, getAgentManifest, listAgentManifests, saveAgentManifest, } from "../../../tenant/agent-manifests.js";
6
+ import { agentManifestVersions, deleteAgentManifest, getAgentManifest, getAgentManifestSource, listAgentManifests, readAgentManifestSourceFile, saveAgentFolder, saveAgentManifest, } from "../../../tenant/agent-manifests.js";
7
7
  import { readJson } from "../body.js";
8
8
  import { tenantRoute } from "../define.js";
9
9
  import { jsonResponse } from "../respond.js";
@@ -59,13 +59,19 @@ export function agentManifestRoutes(api) {
59
59
  path: "/v1/agent-manifests/{name}",
60
60
  tags: ["Agent manifests"],
61
61
  summary: "Save an agent manifest",
62
- description: "Saves the manifest as its next version, or answers the latest unchanged when nothing differs. Every Agent that tracks the manifest moves to the new version: at once, at its pod's next start for a runtime change a pod applies only when it starts, or once a required secret the version adds is set; a pinned one stays, and so does one whose kind, harness or storage the version changes (`agents_behind`). The Runtime checks the harness and runtime sections against each other: a custom harness needs a pod with an image, every credential the harness names is a declared slot of the right type, and the runtime's kind gives the loop the sandbox it needs; every gap is named in one `422 manifest_inconsistent` (`details.gaps`). `If-Match: <version>` refuses the save with `412 manifest_changed` when the latest version is no longer the one you read (`0` for a manifest that does not exist yet). With `?dryRun=true` the answer is the plan: the changes by section, every reason a save would be refused (`errors`, the gaps first), warnings, the Agents it would move (`moves`) and how many stay on older versions (`behind`); nothing is saved. Clients compose the authoring files and drop their `$schema` before they send one document.",
62
+ description: "Saves the manifest as its next version, or answers the latest unchanged when nothing differs. Every Agent that tracks the manifest moves to the new version: at once, at its pod's next start for a runtime change a pod applies only when it starts, or once a required secret the version adds is set; a pinned one stays, and so does one whose kind, harness or storage the version changes (`agents_behind`). The Runtime checks the harness and runtime sections against each other: a custom harness needs a pod with an image, every credential the harness names is a declared slot of the right type, and the runtime's kind gives the loop the sandbox it needs; every gap is named in one `422 manifest_inconsistent` (`details.gaps`). `If-Match: <version>` refuses the save with `412 manifest_changed` when the latest version is no longer the one you read (`0` for a manifest that does not exist yet). With `?dryRun=true` the answer is the plan: the changes by section, every reason a save would be refused (`errors`, the gaps first), warnings, the Agents it would move (`moves`) and how many stay on older versions (`behind`); nothing is saved. Clients compose the authoring files and drop their `$schema` before they send one document. With `Content-Type: application/vnd.nylorun.folder+json` the body is an agent folder by hash instead (feature `agent-folders`): every file uploaded first with `PUT /v1/files/sha256:<hex>`, the Runtime compiles it with `@nylorun/core/folder`, a folder that does not compile is `422 folder_invalid` (`details.diagnostics`, each with its file, line and column), and the version keeps the folder as its source; the plan adds the compiled `manifest`, the compiler's `diagnostics` and `compiler`.",
63
63
  request: {
64
64
  params: namePath,
65
65
  query: z.object({
66
66
  dryRun: z.enum(["true", "false"]).optional().meta({ description: "`true`: answer the plan and save nothing" }),
67
67
  }),
68
- body: { required: true, content: { "application/json": { schema: PutAgentManifestRequest } } },
68
+ body: {
69
+ required: true,
70
+ content: {
71
+ "application/json": { schema: PutAgentManifestRequest },
72
+ [AGENT_FOLDER_MEDIA_TYPE]: { schema: PutAgentFolderRequest },
73
+ },
74
+ },
69
75
  },
70
76
  responses: {
71
77
  200: json(z.union([SaveAgentManifestResponse, AgentManifestPlan]), "The version saved, or the plan with dryRun"),
@@ -74,16 +80,23 @@ export function agentManifestRoutes(api) {
74
80
  },
75
81
  412: { description: "If-Match named a version that is no longer the latest (`manifest_changed`)" },
76
82
  413: { description: "A skill's files hold more than the manifest's skill limit together (`limit_exceeded`)" },
77
- 422: { description: "The harness and runtime sections do not fit (`manifest_inconsistent`, `details.gaps`)" },
83
+ 422: {
84
+ description: "The harness and runtime sections do not fit (`manifest_inconsistent`, `details.gaps`), or an agent folder does not compile (`folder_invalid`, `details.diagnostics`)",
85
+ },
78
86
  },
79
87
  }, async (c) => {
80
88
  const name = nameOf(c.req.param("name"));
81
- const body = PutAgentManifestRequestSchema.parse(await readJson(c));
82
89
  const ifMatch = ifMatchOf(c.req.header("if-match"));
83
- const options = ifMatch === undefined ? {} : { ifMatch };
84
- return jsonResponse(200, c.req.query("dryRun") === "true"
90
+ const options = { ...(ifMatch === undefined ? {} : { ifMatch }), ...(c.req.query("dryRun") === "true" ? { dryRun: true } : {}) };
91
+ const media = (c.req.header("content-type") ?? "").split(";")[0].trim().toLowerCase();
92
+ if (media === AGENT_FOLDER_MEDIA_TYPE) {
93
+ const folder = PutAgentFolderRequestSchema.parse(await readJson(c));
94
+ return jsonResponse(200, await saveAgentFolder(c.env.tenant, name, folder, c.get("scope"), options));
95
+ }
96
+ const body = PutAgentManifestRequestSchema.parse(await readJson(c));
97
+ return jsonResponse(200, options.dryRun
85
98
  ? await saveAgentManifest(c.env.tenant, name, body, c.get("scope"), { ...options, dryRun: true })
86
- : await saveAgentManifest(c.env.tenant, name, body, c.get("scope"), options));
99
+ : await saveAgentManifest(c.env.tenant, name, body, c.get("scope"), { ...options, dryRun: false }));
87
100
  });
88
101
  tenantRoute(api, READ, {
89
102
  method: "get",
@@ -120,6 +133,45 @@ export function agentManifestRoutes(api) {
120
133
  requirePrincipal(c.get("scope"));
121
134
  return jsonResponse(200, await getAgentManifest(c.env.tenant, nameOf(c.req.param("name")), versionOf(c.req.param("version"))));
122
135
  });
136
+ tenantRoute(api, READ, {
137
+ method: "get",
138
+ path: "/v1/agent-manifests/{name}/versions/{version}/source",
139
+ tags: ["Agent manifests"],
140
+ summary: "Get the folder a version was compiled from",
141
+ description: "The agent folder the version was saved from (feature `agent-folders`): its compiler, size and every file, sorted by path. A version saved as JSON has none (`404`).",
142
+ request: { params: namePath.extend({ version: z.string().meta({ description: "The version number" }) }) },
143
+ responses: { 200: json(AgentManifestSource, "The folder") },
144
+ }, async (c) => {
145
+ requirePrincipal(c.get("scope"));
146
+ return jsonResponse(200, await getAgentManifestSource(c.env.tenant, nameOf(c.req.param("name")), versionOf(c.req.param("version"))));
147
+ });
148
+ tenantRoute(api, READ, {
149
+ method: "get",
150
+ path: "/v1/agent-manifests/{name}/versions/{version}/source/files/{path}",
151
+ tags: ["Agent manifests"],
152
+ summary: "Download one file of a version's folder",
153
+ description: "Streams the file at `path` (its path in the folder, with `/` percent-encoded as `%2F`) as it was saved.",
154
+ request: {
155
+ params: namePath.extend({
156
+ version: z.string().meta({ description: "The version number" }),
157
+ path: z.string().meta({ description: "The file's path in the folder, percent-encoded" }),
158
+ }),
159
+ },
160
+ responses: {
161
+ 200: {
162
+ description: "The file's bytes",
163
+ content: { "application/octet-stream": { schema: z.string().meta({ format: "binary" }) } },
164
+ },
165
+ },
166
+ }, async (c) => {
167
+ requirePrincipal(c.get("scope"));
168
+ const path = c.req.param("path");
169
+ const file = await readAgentManifestSourceFile(c.env.tenant, nameOf(c.req.param("name")), versionOf(c.req.param("version")), path);
170
+ return new Response(file.body, {
171
+ status: 200,
172
+ headers: { "content-type": contentTypeFor(path), "content-length": String(file.size) },
173
+ });
174
+ });
123
175
  tenantRoute(api, WRITE, {
124
176
  method: "delete",
125
177
  path: "/v1/agent-manifests/{name}",
@@ -119,6 +119,8 @@ const RUNTIME_TAGS = [
119
119
  "GET /v1/agent-manifests/{name}",
120
120
  "GET /v1/agent-manifests/{name}/versions",
121
121
  "GET /v1/agent-manifests/{name}/versions/{version}",
122
+ "GET /v1/agent-manifests/{name}/versions/{version}/source",
123
+ "GET /v1/agent-manifests/{name}/versions/{version}/source/files/{path}",
122
124
  "DELETE /v1/agent-manifests/{name}",
123
125
  ],
124
126
  },