@intentius/chant-lexicon-fountain 0.124.97 → 0.124.99

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 (249) hide show
  1. package/dist/acp/command-line.d.ts +0 -1
  2. package/dist/acp/host.d.ts +0 -1
  3. package/dist/acp/index.d.ts +0 -1
  4. package/dist/acp/jsonrpc.d.ts +0 -1
  5. package/dist/acp/output.d.ts +0 -1
  6. package/dist/acp/protocol.d.ts +0 -1
  7. package/dist/acp/serve.d.ts +0 -1
  8. package/dist/acp/server.d.ts +0 -1
  9. package/dist/acp/turn.d.ts +0 -1
  10. package/dist/allowlist-refs.d.ts +0 -1
  11. package/dist/audit-entities.d.ts +0 -1
  12. package/dist/codegen/docs-cli.d.ts +0 -1
  13. package/dist/codegen/docs.d.ts +0 -1
  14. package/dist/codegen/generate-cli.d.ts +0 -1
  15. package/dist/codegen/generate-lexicon.d.ts +0 -1
  16. package/dist/codegen/generate-typescript.d.ts +0 -1
  17. package/dist/codegen/generate.d.ts +0 -1
  18. package/dist/codegen/naming.d.ts +0 -1
  19. package/dist/codegen/package.d.ts +0 -1
  20. package/dist/composites/box.d.ts +0 -1
  21. package/dist/composites/concierge-stack.d.ts +0 -1
  22. package/dist/composites/steward.d.ts +0 -1
  23. package/dist/config.d.ts +0 -1
  24. package/dist/coverage.d.ts +0 -1
  25. package/dist/deep-observe-hooks.d.ts +0 -1
  26. package/dist/deep-observe.d.ts +0 -1
  27. package/dist/describe-resources.d.ts +0 -1
  28. package/dist/detect.d.ts +0 -1
  29. package/dist/entity-props.d.ts +0 -1
  30. package/dist/export-resources.d.ts +0 -1
  31. package/dist/generated/index.d.ts +0 -1
  32. package/dist/generated/runtime.d.ts +0 -1
  33. package/dist/import/generator.d.ts +0 -1
  34. package/dist/import/local-agents.d.ts +0 -1
  35. package/dist/import/parser.d.ts +0 -1
  36. package/dist/index.d.ts +0 -1
  37. package/dist/init-templates.d.ts +0 -1
  38. package/dist/integrity.json +2 -2
  39. package/dist/lint/audit-catalog.d.ts +0 -1
  40. package/dist/lint/audit-lineage.d.ts +0 -1
  41. package/dist/lint/post-synth/ftn010-networking-explicit.d.ts +0 -1
  42. package/dist/lint/post-synth/ftn011-no-unrestricted-networking.d.ts +0 -1
  43. package/dist/lint/post-synth/ftn012-no-cloud-credential-env.d.ts +0 -1
  44. package/dist/lint/post-synth/ftn013-substitution-resolvable.d.ts +0 -1
  45. package/dist/lint/post-synth/ftn014-vault-shadowing.d.ts +0 -1
  46. package/dist/lint/post-synth/ftn015-mcp-secret-env-substitution.d.ts +0 -1
  47. package/dist/lint/post-synth/ftn016-runtime-model-valid.d.ts +0 -1
  48. package/dist/lint/post-synth/ftn017-unique-resource-names.d.ts +0 -1
  49. package/dist/lint/post-synth/ftn023-acp-runtime-command.d.ts +0 -1
  50. package/dist/lint/post-synth/ftn024-setup-timeout-range.d.ts +0 -1
  51. package/dist/lint/post-synth/ftn025-removed-upstream.d.ts +0 -1
  52. package/dist/lint/post-synth/index.d.ts +0 -1
  53. package/dist/lint/rules/ftn001-no-secret-literals.d.ts +0 -1
  54. package/dist/lint/rules/index.d.ts +0 -1
  55. package/dist/live-identity.d.ts +0 -1
  56. package/dist/lsp/completions.d.ts +0 -1
  57. package/dist/lsp/hover.d.ts +0 -1
  58. package/dist/lsp/lexicon-index.d.ts +0 -1
  59. package/dist/manifest.json +1 -1
  60. package/dist/op/activities/fountain-apply.d.ts +0 -1
  61. package/dist/op/activities/fountain-prompt.d.ts +0 -1
  62. package/dist/op/activities/fountain-run.d.ts +0 -1
  63. package/dist/op/activities/index.d.ts +0 -1
  64. package/dist/op/run-prompt.d.ts +0 -1
  65. package/dist/op/runtime.d.ts +0 -1
  66. package/dist/package-cli.d.ts +0 -1
  67. package/dist/plugin.d.ts +0 -1
  68. package/dist/reference-catalog.d.ts +0 -1
  69. package/dist/retired.d.ts +0 -1
  70. package/dist/serializer.d.ts +0 -1
  71. package/dist/spec/fetch.d.ts +0 -1
  72. package/dist/spec/parse.d.ts +0 -1
  73. package/dist/validate-cli.d.ts +0 -1
  74. package/dist/validate.d.ts +0 -1
  75. package/package.json +3 -4
  76. package/dist/acp/command-line.d.ts.map +0 -1
  77. package/dist/acp/host.d.ts.map +0 -1
  78. package/dist/acp/index.d.ts.map +0 -1
  79. package/dist/acp/jsonrpc.d.ts.map +0 -1
  80. package/dist/acp/output.d.ts.map +0 -1
  81. package/dist/acp/protocol.d.ts.map +0 -1
  82. package/dist/acp/serve.d.ts.map +0 -1
  83. package/dist/acp/server.d.ts.map +0 -1
  84. package/dist/acp/turn.d.ts.map +0 -1
  85. package/dist/allowlist-refs.d.ts.map +0 -1
  86. package/dist/audit-entities.d.ts.map +0 -1
  87. package/dist/codegen/docs-cli.d.ts.map +0 -1
  88. package/dist/codegen/docs.d.ts.map +0 -1
  89. package/dist/codegen/generate-cli.d.ts.map +0 -1
  90. package/dist/codegen/generate-lexicon.d.ts.map +0 -1
  91. package/dist/codegen/generate-typescript.d.ts.map +0 -1
  92. package/dist/codegen/generate.d.ts.map +0 -1
  93. package/dist/codegen/naming.d.ts.map +0 -1
  94. package/dist/codegen/package.d.ts.map +0 -1
  95. package/dist/composites/box.d.ts.map +0 -1
  96. package/dist/composites/concierge-stack.d.ts.map +0 -1
  97. package/dist/composites/steward.d.ts.map +0 -1
  98. package/dist/config.d.ts.map +0 -1
  99. package/dist/coverage.d.ts.map +0 -1
  100. package/dist/deep-observe-hooks.d.ts.map +0 -1
  101. package/dist/deep-observe.d.ts.map +0 -1
  102. package/dist/describe-resources.d.ts.map +0 -1
  103. package/dist/detect.d.ts.map +0 -1
  104. package/dist/entity-props.d.ts.map +0 -1
  105. package/dist/export-resources.d.ts.map +0 -1
  106. package/dist/generated/index.d.ts.map +0 -1
  107. package/dist/generated/runtime.d.ts.map +0 -1
  108. package/dist/import/generator.d.ts.map +0 -1
  109. package/dist/import/local-agents.d.ts.map +0 -1
  110. package/dist/import/parser.d.ts.map +0 -1
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/init-templates.d.ts.map +0 -1
  113. package/dist/lint/audit-catalog.d.ts.map +0 -1
  114. package/dist/lint/audit-lineage.d.ts.map +0 -1
  115. package/dist/lint/post-synth/ftn010-networking-explicit.d.ts.map +0 -1
  116. package/dist/lint/post-synth/ftn011-no-unrestricted-networking.d.ts.map +0 -1
  117. package/dist/lint/post-synth/ftn012-no-cloud-credential-env.d.ts.map +0 -1
  118. package/dist/lint/post-synth/ftn013-substitution-resolvable.d.ts.map +0 -1
  119. package/dist/lint/post-synth/ftn014-vault-shadowing.d.ts.map +0 -1
  120. package/dist/lint/post-synth/ftn015-mcp-secret-env-substitution.d.ts.map +0 -1
  121. package/dist/lint/post-synth/ftn016-runtime-model-valid.d.ts.map +0 -1
  122. package/dist/lint/post-synth/ftn017-unique-resource-names.d.ts.map +0 -1
  123. package/dist/lint/post-synth/ftn023-acp-runtime-command.d.ts.map +0 -1
  124. package/dist/lint/post-synth/ftn024-setup-timeout-range.d.ts.map +0 -1
  125. package/dist/lint/post-synth/ftn025-removed-upstream.d.ts.map +0 -1
  126. package/dist/lint/post-synth/index.d.ts.map +0 -1
  127. package/dist/lint/rules/ftn001-no-secret-literals.d.ts.map +0 -1
  128. package/dist/lint/rules/index.d.ts.map +0 -1
  129. package/dist/live-identity.d.ts.map +0 -1
  130. package/dist/lsp/completions.d.ts.map +0 -1
  131. package/dist/lsp/hover.d.ts.map +0 -1
  132. package/dist/lsp/lexicon-index.d.ts.map +0 -1
  133. package/dist/op/activities/fountain-apply.d.ts.map +0 -1
  134. package/dist/op/activities/fountain-prompt.d.ts.map +0 -1
  135. package/dist/op/activities/fountain-run.d.ts.map +0 -1
  136. package/dist/op/activities/index.d.ts.map +0 -1
  137. package/dist/op/run-prompt.d.ts.map +0 -1
  138. package/dist/op/runtime.d.ts.map +0 -1
  139. package/dist/package-cli.d.ts.map +0 -1
  140. package/dist/plugin.d.ts.map +0 -1
  141. package/dist/reference-catalog.d.ts.map +0 -1
  142. package/dist/retired.d.ts.map +0 -1
  143. package/dist/serializer.d.ts.map +0 -1
  144. package/dist/spec/fetch.d.ts.map +0 -1
  145. package/dist/spec/parse.d.ts.map +0 -1
  146. package/dist/validate-cli.d.ts.map +0 -1
  147. package/dist/validate.d.ts.map +0 -1
  148. package/src/acp/acp.test.ts +0 -850
  149. package/src/acp/command-line.ts +0 -192
  150. package/src/acp/gate-resolution.test.ts +0 -81
  151. package/src/acp/host.ts +0 -121
  152. package/src/acp/index.ts +0 -64
  153. package/src/acp/jsonrpc.ts +0 -239
  154. package/src/acp/output.ts +0 -59
  155. package/src/acp/protocol.ts +0 -164
  156. package/src/acp/serve.ts +0 -67
  157. package/src/acp/server.ts +0 -376
  158. package/src/acp/turn.ts +0 -349
  159. package/src/allowlist-refs.ts +0 -138
  160. package/src/audit-entities.test.ts +0 -157
  161. package/src/audit-entities.ts +0 -43
  162. package/src/codegen/docs-cli.ts +0 -7
  163. package/src/codegen/docs.ts +0 -139
  164. package/src/codegen/generate-cli.ts +0 -8
  165. package/src/codegen/generate-lexicon.ts +0 -70
  166. package/src/codegen/generate-typescript.ts +0 -69
  167. package/src/codegen/generate.ts +0 -109
  168. package/src/codegen/naming.ts +0 -45
  169. package/src/codegen/package.ts +0 -36
  170. package/src/composites/box.ts +0 -321
  171. package/src/composites/composites.test.ts +0 -530
  172. package/src/composites/concierge-stack.ts +0 -71
  173. package/src/composites/steward.ts +0 -285
  174. package/src/config.test.ts +0 -160
  175. package/src/config.ts +0 -148
  176. package/src/coverage.test.ts +0 -127
  177. package/src/coverage.ts +0 -278
  178. package/src/deep-observe-hooks.ts +0 -238
  179. package/src/deep-observe.test.ts +0 -684
  180. package/src/deep-observe.ts +0 -346
  181. package/src/describe-resources.test.ts +0 -215
  182. package/src/describe-resources.ts +0 -181
  183. package/src/detect.ts +0 -43
  184. package/src/entity-props.ts +0 -22
  185. package/src/export-resources.ts +0 -159
  186. package/src/generated/index.d.ts +0 -87
  187. package/src/generated/index.ts +0 -10
  188. package/src/generated/runtime.ts +0 -4
  189. package/src/import/generator.ts +0 -128
  190. package/src/import/local-agents.test.ts +0 -216
  191. package/src/import/local-agents.ts +0 -364
  192. package/src/import/parser.ts +0 -90
  193. package/src/import/roundtrip.test.ts +0 -256
  194. package/src/index.ts +0 -68
  195. package/src/init-templates.e2e.test.ts +0 -171
  196. package/src/init-templates.ts +0 -223
  197. package/src/lint/audit-catalog.ts +0 -145
  198. package/src/lint/audit-lineage.ts +0 -15
  199. package/src/lint/post-synth/ftn010-networking-explicit.ts +0 -37
  200. package/src/lint/post-synth/ftn011-no-unrestricted-networking.ts +0 -36
  201. package/src/lint/post-synth/ftn012-no-cloud-credential-env.ts +0 -58
  202. package/src/lint/post-synth/ftn013-substitution-resolvable.ts +0 -93
  203. package/src/lint/post-synth/ftn014-vault-shadowing.ts +0 -61
  204. package/src/lint/post-synth/ftn015-mcp-secret-env-substitution.ts +0 -49
  205. package/src/lint/post-synth/ftn016-runtime-model-valid.ts +0 -89
  206. package/src/lint/post-synth/ftn017-unique-resource-names.ts +0 -43
  207. package/src/lint/post-synth/ftn023-acp-runtime-command.ts +0 -58
  208. package/src/lint/post-synth/ftn024-setup-timeout-range.ts +0 -48
  209. package/src/lint/post-synth/ftn025-removed-upstream.ts +0 -65
  210. package/src/lint/post-synth/index.ts +0 -27
  211. package/src/lint/post-synth/post-synth.test.ts +0 -261
  212. package/src/lint/rules/ftn001-no-secret-literals.ts +0 -126
  213. package/src/lint/rules/index.ts +0 -7
  214. package/src/lint/rules/rules.test.ts +0 -161
  215. package/src/live-identity.ts +0 -153
  216. package/src/lsp/completions.test.ts +0 -67
  217. package/src/lsp/completions.ts +0 -11
  218. package/src/lsp/hover.test.ts +0 -65
  219. package/src/lsp/hover.ts +0 -68
  220. package/src/lsp/lexicon-index.ts +0 -46
  221. package/src/op/activities/fountain-apply.test.ts +0 -666
  222. package/src/op/activities/fountain-apply.ts +0 -458
  223. package/src/op/activities/fountain-prompt.test.ts +0 -117
  224. package/src/op/activities/fountain-prompt.ts +0 -197
  225. package/src/op/activities/fountain-run.test.ts +0 -295
  226. package/src/op/activities/fountain-run.ts +0 -292
  227. package/src/op/activities/index.ts +0 -38
  228. package/src/op/activities/op-runtime.test.ts +0 -194
  229. package/src/op/run-prompt.ts +0 -118
  230. package/src/op/runtime.test.ts +0 -1471
  231. package/src/op/runtime.ts +0 -1464
  232. package/src/package-cli.ts +0 -26
  233. package/src/plugin.test.ts +0 -88
  234. package/src/plugin.ts +0 -234
  235. package/src/reference-catalog.ts +0 -27
  236. package/src/retired.ts +0 -55
  237. package/src/serializer.test.ts +0 -262
  238. package/src/serializer.ts +0 -191
  239. package/src/skills/chant-fountain-locked-sandboxes.md +0 -34
  240. package/src/skills/chant-fountain-ops.md +0 -166
  241. package/src/skills/chant-fountain-secrets.md +0 -29
  242. package/src/skills/chant-fountain.md +0 -69
  243. package/src/spec/fetch.ts +0 -113
  244. package/src/spec/parse.ts +0 -484
  245. package/src/spec/spec.e2e.test.ts +0 -171
  246. package/src/validate-cli.ts +0 -13
  247. package/src/validate.ts +0 -39
  248. /package/{src → dist}/generated/lexicon-fountain.json +0 -0
  249. /package/{src → dist}/spec/fountain-openapi.snapshot.json +0 -0
@@ -1,321 +0,0 @@
1
- /**
2
- * Box — a long-lived machine that serves an app repo and its tools (#2705).
3
- *
4
- * A box is an `Environment` whose `setup_script` provisions the machine (for
5
- * an arugula studio box, the studio's `box/provision-template.sh`), an
6
- * `Agent` whose conversations are provisioned from it, and optionally a
7
- * `Vault` for the secrets every box of this kind shares. `repo` is optional:
8
- * when given, the Environment's `repositories` clones it in before setup
9
- * runs; when omitted (#2759 — a blank-slate app, such as the one hud's
10
- * `init` makes, has no git remote yet), the Environment holds no
11
- * `repositories` at all and `setup_script` still runs on an empty sandbox.
12
- *
13
- * The machine is one conversation, not the agent (managoat/managoat#2793).
14
- * Managoat gives every conversation a sandbox of its own (its ADR 0073) and
15
- * refuses `sandbox_mode: "persistent"` with 422, so the Agent declares no
16
- * `sandbox_mode`. A box's runtime opens one conversation per box and resumes
17
- * it by `channel_id`; that conversation's sandbox keeps its disk across park
18
- * and wake and is destroyed only when the conversation is terminated, which
19
- * is the long-lived machine a persistent agent used to stand for (planter#59
20
- * made the same move).
21
- *
22
- * ```ts
23
- * export const { environment, agent, vault } = Box({
24
- * name: "studio-box",
25
- * repo: { url: "https://github.com/arugula-salad/studio", ref: "main" },
26
- * setupScript: readFileSync("box/provision-template.sh", "utf8"),
27
- * model: "anthropic/claude-sonnet-4-5",
28
- * permissionPolicy: { default: "auto_allow" },
29
- * allowedHosts: ["registry.npmjs.org", "github.com"],
30
- * vault: { secrets: [{ key: "STUDIO_SECRET", value: "${STUDIO_SECRET}" }] },
31
- * });
32
- * ```
33
- *
34
- * Beside `Steward`: a steward is an environment's one writer, an `acp` agent
35
- * whose every turn is a chant command line, run on one long-lived
36
- * conversation of its own. A box is where people and their agents work
37
- * on an app: a conversational runtime (`claude` by default), the app repo
38
- * cloned in (when there is one), the provisioning script run as setup, and
39
- * one served port. Nothing here starts a conversation. Starting and reaping a box stays a runtime act, as
40
- * it is in hud's box runtime.
41
- *
42
- * The defaults are the closed ones, as `ConciergeStack`'s are, and loosening
43
- * one is a visible parameter: networking is `limited` with an empty allowlist
44
- * until `allowedHosts` names hosts or `unrestrictedNetworking: true` opens it
45
- * (which FTN011 then warns about); `allowed_vault_ids` holds the box's own
46
- * vault, or nothing, until `allowedVaults` widens it; `sandbox_provider` is
47
- * unset (the instance default) until `sandboxProvider` names one of the
48
- * pinned spec's `sprites` or `e2b` (Managoat removed `daytona` and `runner`;
49
- * FTN025 reports either on an Agent built some other way). `permission_policy`
50
- * has no default at all, because fountain's unset policy is `auto_allow` and
51
- * that should be a choice someone wrote down.
52
- *
53
- * ## Credentials
54
- *
55
- * A box holds no credential (#2726). What it reaches outside itself
56
- * (inference, Fountain's own API) goes through a broker, such as a studio's
57
- * lobby, that holds the key and enforces a scope. Those capabilities are
58
- * declared in the workspace declaration's `box` block on the member that
59
- * holds this composite, not here: `chant workspace check` and the read
60
- * contract read the declaration without running this code. Here, a vault
61
- * secret's value and an `envVars` value are references (`${VAR}`, `op://`,
62
- * `bws://`, `infisical://`) that resolve at apply, never a literal, and never
63
- * `process.env.X`, which writes the secret into the built manifest. `chant
64
- * workspace check` fails a box member whose files hold one
65
- * (`box-credential-declared`).
66
- *
67
- * One credential reaches the box anyway (#2780). Managoat gives every
68
- * sandbox a callback token, `FOUNTAIN_TOKEN`, in the environment of each exec
69
- * it makes into it (the setup script's included), scoped to the owner
70
- * (`sandbox_api_access: owner`) unless the conversation opts out. The opt-out,
71
- * `sandbox_api_access: none`, is a field of the conversation's launch, not of
72
- * the Agent, and Managoat accepts it only for a fresh sandbox, never on a
73
- * `channel_id` resume (managoat/fountain#2497). A box is resumed by
74
- * `channel_id`, so no option here can turn it off. The composite records it
75
- * instead: the Agent's metadata carries `box-sandbox-api-access: owner`
76
- * (`BOX_SANDBOX_API_ACCESS_METADATA_KEY`), and the member's `box` block is
77
- * expected to declare the capability that stands for it,
78
- * `BOX_FOUNTAIN_CALLBACK_CAPABILITY`: `fountain-callback`, brokered by fountain
79
- * itself, with scope `owner`. It is named apart from a `fountain` capability a
80
- * lobby brokers, which a box may declare as well. `chant workspace check`
81
- * reports a box member that builds a `Box` and does not declare it
82
- * (`box-fountain-callback-undeclared`).
83
- *
84
- * ## The port
85
- *
86
- * fountain's `Environment` and `Agent` have no field for a served port (the
87
- * pinned spec, v0.29.0). The port is recorded in the metadata of both, under
88
- * `box-port`, and returned as `port`, so whatever builds the box's URL reads
89
- * it from the declaration or from fountain's own record without a guess.
90
- *
91
- * ## Allowed vaults in the read contract
92
- *
93
- * `sandbox_provider` is a plain `Agent` field, so `chant workspace graph
94
- * --json` (and `chant graph`) already carry it on the agent's node like any
95
- * other declared attribute. `allowed_vault_ids` is not as plain to read:
96
- * fountain's own convention (and this composite's, per `allowedVaults`
97
- * above) is that an *unset* list means "any vault the tenant owns", so a
98
- * graph reader can't tell "no vaults declared" from "any vault" just by the
99
- * key's absence. #2759 — a runtime that creates a vault per box (hud's box
100
- * runtime) needs to check that the declaration permits it — so the resolved
101
- * list, or the literal string `"any"`, is also recorded in the agent's
102
- * metadata under `box-allowed-vault-ids` (`BOX_ALLOWED_VAULTS_METADATA_KEY`).
103
- * It is read-only bookkeeping, alongside `box-port`: the manifest's real
104
- * `allowed_vault_ids` field is what fountain applies.
105
- */
106
-
107
- import { Agent, Environment, Vault } from "../generated/index";
108
-
109
- /** The metadata key a box's served port is recorded under, on its Environment and Agent. */
110
- export const BOX_PORT_METADATA_KEY = "box-port";
111
-
112
- /** The metadata key a box agent's resolved allowed vaults (or `"any"`) are recorded under, for the read contract. */
113
- export const BOX_ALLOWED_VAULTS_METADATA_KEY = "box-allowed-vault-ids";
114
-
115
- /**
116
- * The metadata key a box agent's sandbox callback access is recorded under
117
- * (#2780): `owner`, the scope of the `FOUNTAIN_TOKEN` Managoat gives every
118
- * sandbox by default.
119
- */
120
- export const BOX_SANDBOX_API_ACCESS_METADATA_KEY = "box-sandbox-api-access";
121
-
122
- /**
123
- * The sandbox callback access a box has on the pinned spec: `owner`. Managoat
124
- * accepts `none` only on a fresh sandbox's launch, and a box's conversation is
125
- * resumed (managoat/fountain#2497).
126
- */
127
- export const BOX_SANDBOX_API_ACCESS = "owner";
128
-
129
- /**
130
- * The capability a box member's `box` block declares for fountain's callback
131
- * token (#2780), as `chant workspace check` expects it: fountain brokers it
132
- * itself, and its scope is the owner's.
133
- */
134
- export const BOX_FOUNTAIN_CALLBACK_CAPABILITY = {
135
- name: "fountain-callback",
136
- broker: "fountain",
137
- scope: [BOX_SANDBOX_API_ACCESS],
138
- } as const;
139
-
140
- /** `Agent.sandbox_provider`'s values at the pinned spec. */
141
- export const BOX_SANDBOX_PROVIDERS = ["sprites", "e2b"] as const;
142
-
143
- /** A sandbox backend, per the pinned spec's `sandbox_provider` enum. */
144
- export type BoxSandboxProvider = (typeof BOX_SANDBOX_PROVIDERS)[number];
145
-
146
- /** The port a box serves when none is given: the door's. */
147
- export const BOX_DEFAULT_PORT = 8080;
148
-
149
- /** Where the app repo is cloned when no `mountPath` is given. */
150
- export const BOX_DEFAULT_MOUNT_PATH = "/workspace/app";
151
-
152
- /** A permission verdict per tool key, plus an optional `default`. */
153
- export type BoxPermissionPolicy = Record<string, "ask" | "auto_allow" | "auto_deny">;
154
-
155
- /** The app repo the box serves. Shape of fountain's `Repository`. */
156
- export interface BoxRepositoryOpts {
157
- /** https clone url. */
158
- url: string;
159
- /** Absolute path the repo is cloned to. Default `/workspace/app`. */
160
- mountPath?: string;
161
- /** Branch or tag. The default branch when omitted. */
162
- ref?: string;
163
- /** Name of the secret holding a clone token. Required for a private repo. */
164
- secretKey?: string;
165
- }
166
-
167
- /** The secrets every box of this kind shares, held in a Vault of the box's own. */
168
- export interface BoxVaultOpts {
169
- /** Vault name. Default `<name>-secrets`. */
170
- name?: string;
171
- description?: string;
172
- /** Written at apply. A reference such as `${VAR}` or `op://...` that resolves at apply, never a literal (FTN001, and `box-credential-declared` in `chant workspace check`). */
173
- secrets?: { key: string; value: string }[];
174
- }
175
-
176
- export interface BoxOpts {
177
- /** The Agent's name. The Environment is `<name>-env`. */
178
- name: string;
179
- /** The app repo the box serves, cloned into the sandbox before setup runs. Omit for a blank-slate app with no repo yet: the Environment declares no `repositories`, and `setupScript` runs against whatever working tree the sandbox already has. */
180
- repo?: BoxRepositoryOpts;
181
- /** The provisioning script's text, run as the Environment's `setup_script`. */
182
- setupScript: string;
183
- /** Setup exec timeout, 1 to 900 seconds (FTN024). fountain's default is 120. */
184
- setupTimeoutSeconds?: number;
185
- /** Agent runtime. Default `claude`. */
186
- runtime?: "claude" | "codex" | "gemini";
187
- /**
188
- * Canonical provider/model_id. Required (#2776): Managoat refuses an Agent with no model for every runtime but `acp`
189
- * (`model: can't be blank` at apply), and a Box's runtime is never `acp`.
190
- * FTN016 flags the same gap on an Agent built any other way.
191
- */
192
- model: string;
193
- /** Sandbox backend override. Omitted, the instance default (`SANDBOX_PROVIDER`). A plain `Agent.sandbox_provider` field, so it is already visible on the graph node without extra bookkeeping (unlike `allowedVaults`; see "Allowed vaults in the read contract" above). */
194
- sandboxProvider?: BoxSandboxProvider;
195
- /** Per-tool permission policy. Required: fountain's unset policy is `auto_allow`. */
196
- permissionPolicy: BoxPermissionPolicy;
197
- /** Environment packages, passed through. */
198
- packages?: Record<string, unknown>;
199
- /** Environment variables, passed through. Not for secrets: use `vault`. */
200
- envVars?: Record<string, string>;
201
- /** Egress allowlist under `limited` networking. Default [], deny-all. */
202
- allowedHosts?: string[];
203
- /** Open the sandbox's network. FTN011 warns on it. Refused with `allowedHosts`. */
204
- unrestrictedNetworking?: boolean;
205
- /** Declare a Vault for the box's shared secrets. */
206
- vault?: BoxVaultOpts;
207
- /**
208
- * Vaults a conversation may attach. Default: the box's own vault, or none.
209
- * `"any"` leaves the list unset, which fountain reads as any vault the
210
- * tenant owns: what a runtime that makes a vault per box (hud's) needs.
211
- */
212
- allowedVaults?: "any" | Array<InstanceType<typeof Vault> | string>;
213
- /** The port the box serves. Default 8080, the door's. Recorded as `box-port` metadata. */
214
- port?: number;
215
- system?: string;
216
- skills?: Array<Record<string, unknown>>;
217
- mcpServers?: Record<string, unknown>;
218
- /** Extra metadata, merged over the ownership marker on every resource the box declares. */
219
- metadata?: Record<string, unknown>;
220
- }
221
-
222
- export interface BoxResources {
223
- environment: InstanceType<typeof Environment>;
224
- agent: InstanceType<typeof Agent>;
225
- vault?: InstanceType<typeof Vault>;
226
- /** The served port, as recorded under `box-port`. */
227
- port: number;
228
- }
229
-
230
- export function Box(opts: BoxOpts): BoxResources {
231
- const port = opts.port ?? BOX_DEFAULT_PORT;
232
- if (!Number.isInteger(port) || port < 1 || port > 65535) {
233
- throw new Error(`Box "${opts.name}": port ${port} is not a TCP port (1 to 65535)`);
234
- }
235
- if (opts.unrestrictedNetworking && opts.allowedHosts !== undefined) {
236
- throw new Error(
237
- `Box "${opts.name}": allowedHosts and unrestrictedNetworking together — ` +
238
- `an allowlist means nothing on an open network. Pass one.`,
239
- );
240
- }
241
- // The type requires it; this is for an untyped caller, so it fails at build
242
- // rather than at fountain's apply.
243
- if (typeof opts.model !== "string" || !opts.model.trim()) {
244
- throw new Error(
245
- `Box "${opts.name}": model is required — Managoat refuses an Agent with no model ` +
246
- `for the ${opts.runtime ?? "claude"} runtime. Pass a canonical provider/model_id.`,
247
- );
248
- }
249
- if (!opts.setupScript.trim()) {
250
- throw new Error(`Box "${opts.name}": setupScript is empty — a box is provisioned by its setup script`);
251
- }
252
-
253
- const owned = { "managed-by": "chant", ...(opts.metadata ?? {}) };
254
- const metadata = { ...owned, [BOX_PORT_METADATA_KEY]: port };
255
-
256
- const repository = opts.repo
257
- ? {
258
- url: opts.repo.url,
259
- mount_path: opts.repo.mountPath ?? BOX_DEFAULT_MOUNT_PATH,
260
- ...(opts.repo.ref !== undefined ? { ref: opts.repo.ref } : {}),
261
- ...(opts.repo.secretKey !== undefined ? { secret_key: opts.repo.secretKey } : {}),
262
- }
263
- : undefined;
264
-
265
- const environment = new Environment({
266
- name: `${opts.name}-env`,
267
- ...(repository ? { repositories: [repository] } : {}),
268
- setup_script: opts.setupScript,
269
- ...(opts.setupTimeoutSeconds !== undefined ? { setup_timeout_seconds: opts.setupTimeoutSeconds } : {}),
270
- ...(opts.packages ? { packages: opts.packages } : {}),
271
- ...(opts.envVars ? { env_vars: opts.envVars } : {}),
272
- ...(opts.unrestrictedNetworking
273
- ? { networking_type: "unrestricted" as const }
274
- : { networking_type: "limited" as const, networking_config: { allowed_hosts: opts.allowedHosts ?? [] } }),
275
- metadata,
276
- });
277
-
278
- const vault = opts.vault
279
- ? new Vault({
280
- name: opts.vault.name ?? `${opts.name}-secrets`,
281
- ...(opts.vault.description !== undefined ? { description: opts.vault.description } : {}),
282
- ...(opts.vault.secrets ? { secrets: opts.vault.secrets } : {}),
283
- metadata: owned,
284
- })
285
- : undefined;
286
-
287
- // A Vault declaration rather than its `.id`, as in Steward: the manifest's
288
- // reference form is the resource's name, and an AttrRef would
289
- // serialize to the chant export name instead.
290
- const allowedVaults =
291
- opts.allowedVaults === "any" ? undefined : (opts.allowedVaults ?? (vault ? [vault] : []));
292
-
293
- // The resolved allowed-vaults value, for the read contract (see "Allowed
294
- // vaults in the read contract" above) — "any" when the list is left unset,
295
- // otherwise each entry's own declared name.
296
- const allowedVaultsForReadContract: "any" | string[] =
297
- opts.allowedVaults === "any"
298
- ? "any"
299
- : allowedVaults!.map((v) => (typeof v === "string" ? v : (v as unknown as { props: { name: string } }).props.name));
300
- const agentMetadata = {
301
- ...metadata,
302
- [BOX_ALLOWED_VAULTS_METADATA_KEY]: allowedVaultsForReadContract,
303
- [BOX_SANDBOX_API_ACCESS_METADATA_KEY]: BOX_SANDBOX_API_ACCESS,
304
- };
305
-
306
- const agent = new Agent({
307
- name: opts.name,
308
- runtime: opts.runtime ?? "claude",
309
- model: opts.model,
310
- ...(opts.sandboxProvider !== undefined ? { sandbox_provider: opts.sandboxProvider } : {}),
311
- environment,
312
- permission_policy: opts.permissionPolicy,
313
- ...(allowedVaults !== undefined ? { allowed_vault_ids: allowedVaults } : {}),
314
- ...(opts.skills ? { skills: opts.skills } : {}),
315
- ...(opts.mcpServers ? { mcp_servers: opts.mcpServers } : {}),
316
- ...(opts.system !== undefined ? { system: opts.system } : {}),
317
- metadata: agentMetadata,
318
- });
319
-
320
- return { environment, agent, ...(vault ? { vault } : {}), port };
321
- }