@swirls/deploy 0.6.0 → 0.7.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/README.md CHANGED
@@ -112,7 +112,7 @@ Lowering refuses a `kind` that is not one of the six. It does not check `options
112
112
 
113
113
  ## Computers and streams
114
114
 
115
- A computer lowers to its recipe (`compileComputerRecipe`) plus `lowerComputerRuntime`: `repos` with the language's defaults applied (`access: 'read'`, `depth: 'shallow'`, `submodules` and `lfs` false; `path` and `ref` only when written), `egress` as written, and `idle:` and `keep:` as `idleSeconds` and `keepSeconds`. `lowerComputerRepo` lowers one entry. A disk adds no packages to the recipe, and there is no `needsMountTooling`: the machine mounts its disks itself.
115
+ A computer lowers to its recipe (`compileComputerRecipe`) plus `lowerComputerRuntime`: `repos` with the language's defaults applied (`access: 'read'`, `depth: 'shallow'`, `submodules` and `lfs` false; `path` and `ref` only when written), `egress` as `{ host, secrets }` entries (`lowerComputerEgress`; a plain host has no secrets, a header is lower-cased and `format` defaults to `plain`), and `idle:` and `keep:` as `idleSeconds` and `keepSeconds`. `lowerComputerRepo` lowers one entry. A disk adds no packages to the recipe, and there is no `needsMountTooling`: the machine mounts its disks itself.
116
116
 
117
117
  A stream's `retention:` lowers to `retentionSeconds`. A `type: stream` node lowers literal keys to their typed forms and leaves code as code, recorded in `configValueKinds`:
118
118
 
package/dist/index.d.ts CHANGED
@@ -208,6 +208,31 @@ declare const channelPlatformSchema: z.ZodEnum<{
208
208
  swirls: "swirls";
209
209
  }>;
210
210
  type ChannelPlatform = z.infer<typeof channelPlatformSchema>;
211
+ /**
212
+ * One host a computer's machine may reach, and the secrets it may receive. A
213
+ * plain string, as definitions stored before secrets existed hold, reads as
214
+ * the host with no secrets.
215
+ */
216
+ declare const deploymentDefinitionComputerEgressSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
217
+ host: string;
218
+ secrets: {
219
+ block: string;
220
+ variable: string;
221
+ header: string;
222
+ format: "bearer" | "plain";
223
+ }[];
224
+ }, string>>, z.ZodObject<{
225
+ host: z.ZodString;
226
+ secrets: z.ZodArray<z.ZodObject<{
227
+ block: z.ZodString;
228
+ variable: z.ZodString;
229
+ header: z.ZodString;
230
+ format: z.ZodEnum<{
231
+ bearer: "bearer";
232
+ plain: "plain";
233
+ }>;
234
+ }, z.core.$strip>>;
235
+ }, z.core.$strip>]>;
211
236
  /** One `repos:` entry: a working copy of a repository the computer starts each step with. */
212
237
  declare const deploymentDefinitionComputerRepoSchema: z.ZodObject<{
213
238
  repo: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -283,7 +308,26 @@ declare const deploymentDefinitionComputerBlockSchema: z.ZodObject<{
283
308
  submodules: z.ZodBoolean;
284
309
  lfs: z.ZodBoolean;
285
310
  }, z.core.$strip>>>;
286
- egress: z.ZodDefault<z.ZodArray<z.ZodString>>;
311
+ egress: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
312
+ host: string;
313
+ secrets: {
314
+ block: string;
315
+ variable: string;
316
+ header: string;
317
+ format: "bearer" | "plain";
318
+ }[];
319
+ }, string>>, z.ZodObject<{
320
+ host: z.ZodString;
321
+ secrets: z.ZodArray<z.ZodObject<{
322
+ block: z.ZodString;
323
+ variable: z.ZodString;
324
+ header: z.ZodString;
325
+ format: z.ZodEnum<{
326
+ bearer: "bearer";
327
+ plain: "plain";
328
+ }>;
329
+ }, z.core.$strip>>;
330
+ }, z.core.$strip>]>>>;
287
331
  idleSeconds: z.ZodOptional<z.ZodNumber>;
288
332
  keepSeconds: z.ZodOptional<z.ZodNumber>;
289
333
  harness: z.ZodOptional<z.ZodObject<{
@@ -848,7 +892,26 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
848
892
  submodules: z.ZodBoolean;
849
893
  lfs: z.ZodBoolean;
850
894
  }, z.core.$strip>>>;
851
- egress: z.ZodDefault<z.ZodArray<z.ZodString>>;
895
+ egress: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
896
+ host: string;
897
+ secrets: {
898
+ block: string;
899
+ variable: string;
900
+ header: string;
901
+ format: "bearer" | "plain";
902
+ }[];
903
+ }, string>>, z.ZodObject<{
904
+ host: z.ZodString;
905
+ secrets: z.ZodArray<z.ZodObject<{
906
+ block: z.ZodString;
907
+ variable: z.ZodString;
908
+ header: z.ZodString;
909
+ format: z.ZodEnum<{
910
+ bearer: "bearer";
911
+ plain: "plain";
912
+ }>;
913
+ }, z.core.$strip>>;
914
+ }, z.core.$strip>]>>>;
852
915
  idleSeconds: z.ZodOptional<z.ZodNumber>;
853
916
  keepSeconds: z.ZodOptional<z.ZodNumber>;
854
917
  harness: z.ZodOptional<z.ZodObject<{
@@ -1442,6 +1505,7 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
1442
1505
  type DeploymentDefinition = z.infer<typeof deploymentDefinitionSchema>;
1443
1506
  type DeploymentDefinitionComputerBlock = z.infer<typeof deploymentDefinitionComputerBlockSchema>;
1444
1507
  type DeploymentDefinitionComputerRepo = z.infer<typeof deploymentDefinitionComputerRepoSchema>;
1508
+ type DeploymentDefinitionComputerEgress = z.infer<typeof deploymentDefinitionComputerEgressSchema>;
1445
1509
  type DeploymentDefinitionOperationBlock = z.infer<typeof deploymentDefinitionOperationBlockSchema>;
1446
1510
  declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<{
1447
1511
  version?: number | undefined;
@@ -1853,7 +1917,15 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1853
1917
  } | undefined;
1854
1918
  title?: string | undefined;
1855
1919
  }[];
1856
- egress: string[];
1920
+ egress: {
1921
+ host: string;
1922
+ secrets: {
1923
+ block: string;
1924
+ variable: string;
1925
+ header: string;
1926
+ format: "bearer" | "plain";
1927
+ }[];
1928
+ }[];
1857
1929
  recipeHash: string;
1858
1930
  description?: string | undefined;
1859
1931
  idleSeconds?: number | undefined;
@@ -2614,8 +2686,8 @@ interface AgentDecl {
2614
2686
  teamRanges?: SourceRange[];
2615
2687
  /**
2616
2688
  * Top-level shared `disk` block names the agent's file tools reach: mounted
2617
- * on its computer with `computer:`, mounted into its sandbox with the
2618
- * deprecated `sandbox:`, and read and written with no machine otherwise.
2689
+ * on its computer with `computer:`, and read and written with no machine
2690
+ * otherwise.
2619
2691
  */
2620
2692
  disks?: string[];
2621
2693
  disksRanges?: SourceRange[];
@@ -2989,10 +3061,33 @@ interface ComputerRepoDecl {
2989
3061
  lfs?: ComputerRepoValue<boolean>;
2990
3062
  range: SourceRange;
2991
3063
  }
2992
- /** One `egress:` host as written. */
3064
+ /**
3065
+ * One secret an egress host may receive, as written:
3066
+ * `{ secret: block.VAR, header: "authorization", format: bearer }`.
3067
+ */
3068
+ interface ComputerEgressSecretDecl {
3069
+ /** The `secret` block's name. */
3070
+ block: string;
3071
+ /** The variable in that block. */
3072
+ variable: string;
3073
+ secretRange: SourceRange;
3074
+ /** The request header the gateway writes the value into, as written. */
3075
+ header?: string;
3076
+ headerRange?: SourceRange;
3077
+ /** `bearer` or `plain`, as written. Absent means `plain`. */
3078
+ format?: string;
3079
+ formatRange?: SourceRange;
3080
+ range: SourceRange;
3081
+ }
3082
+ /**
3083
+ * One `egress:` entry as written: a quoted host, or `{ host: "...", secrets: [...] }`
3084
+ * naming the secrets the host may receive.
3085
+ */
2993
3086
  interface ComputerEgressHost {
2994
3087
  host: string;
2995
3088
  range: SourceRange;
3089
+ /** Present only for the object form, even when its list is empty. */
3090
+ secrets?: ComputerEgressSecretDecl[];
2996
3091
  }
2997
3092
  /** `idle:` or `keep:` as written, with the seconds it means (`null` when it does not parse). */
2998
3093
  interface ComputerDurationDecl {
@@ -4618,6 +4713,12 @@ declare function daytonaSnapshotResources(resources: CompiledComputerResources):
4618
4713
 
4619
4714
  /** One `repos:` entry with the language's defaults applied. */
4620
4715
  declare function lowerComputerRepo(entry: ComputerRepoDecl): DeploymentDefinitionComputerRepo;
4716
+ /**
4717
+ * One egress entry as the runtime reads it: the host, and each secret requests
4718
+ * to it may carry with the header it goes in (lower case) and its format
4719
+ * (`plain` when not written).
4720
+ */
4721
+ declare function lowerComputerEgress(entry: ComputerEgressHost): DeploymentDefinitionComputerEgress;
4621
4722
  /** The run-time fields of a computer block in the deployment definition. */
4622
4723
  declare function lowerComputerRuntime(computer: ComputerDecl): Pick<DeploymentDefinitionComputerBlock, 'repos' | 'egress' | 'idleSeconds' | 'keepSeconds'>;
4623
4724
 
@@ -5403,4 +5504,4 @@ declare function buildDeploymentSourceManifest({ definition, ast, files, }: {
5403
5504
  */
5404
5505
  declare function stripEditorMetadata(value: unknown): unknown;
5405
5506
 
5406
- export { AGENTS_SKILLS_DIR, type BuildDefinitionOptions, COMPUTER_BASELINE_KIT, COMPUTER_BASELINE_PACKAGES, COMPUTER_HARNESS_RESOURCE_DEFAULTS, COMPUTER_HARNESS_RUNTIME, COMPUTER_RESOURCE_DEFAULTS, type CompiledComputer, type CompiledComputerHarness, type ComputerHarnessBake, type ComputerHarnessInput, type ComputerRecipeInput, type DeployBundleDirent, type DeployBundleFs, type DeploymentDefinition, type DeploymentSkillFilePayload, type DeploymentSkillFilesBundle, type DeploymentSourceFileContent, type DeploymentSourceManifest, type DeploymentSourceManifestV2, type DeploymentSourceResourceKind, type DeploymentSourceResourceKindV2, type Diagnostic, HARNESS_DEBIAN_STAGE_DIR, HARNESS_PROVIDERS, HARNESS_ROOT_DIR, type HarnessCatalog, type HarnessDebianPackage, type HarnessProvider, type HarnessRuntimePackage, type LanguageHost, type LowerDiagnostic, type LowerMountsOptions, type LowerMountsResult, type LowerOptions, type LowerResult, type LowerStage, MAX_SKILL_FILES, MAX_SKILL_FILE_BYTES, MAX_SKILL_TREE_BYTES, MOUNT_SKILLS_ROOT, type MergeProjectOptions, type MountDiagnostic, type MountFingerprint, type MountSite, type MountSkillFiles, type MountSourceFile, type OpenUiSupport, type ProviderCatalog, SKILL_MD_FILENAME, type SkillBlockRef, type SkillBundle, type SkillClassificationResult, type SkillDeployFs, type SkillDeployStat, type SkillFileEntry, type SkillMdFrontmatter, type SourceRange, type SwirlsFile, type SwirlsMount, type SwirlsMountFiles, type SwirlsSources, buildConfigValueKindsFromNodeDecl, buildDeploymentDefinitionPayload, buildDeploymentSourceManifest, buildWorkflowNodeConfigFromNodeDecl, canonicalizeForStableJson, classifySkillBundle, collectDeploymentSkillFiles, collectDeploymentSourceFiles, collectReferencedSkillBlocksFromAst, collectSwirlsFiles, combineDeploymentAndSourceFingerprints, compileComputerRecipe, compileGoalBlock, compileOperationBlock, computeDefinitionHash, computeDeploymentDefinitionFingerprint, computeDeploymentSourceFingerprint, computeGoalContractHash, computeSkillChecksum, computerHarnessBake, computerSnapshotName, createMemoryRepoFs, createNodeDeployBundleFs, daytonaSnapshotResources, deployBundleToSkillDeployFs, deployBundleToWorkspaceFileSystem, deploymentSourceManifestV2Schema, flattenArchivePathMap, flattenInlineSubgraphsInGraph, floxManifestToml, harnessPrepScript, harnessRuntimePackages, isHarnessProvider, isKnownScriptExtension, isScriptsOrBinDirectory, lowerComputerRepo, lowerComputerRuntime, lowerSwirlsMounts, lowerSwirlsSources, mergeProjectSwirlsFiles, normalizeDeploymentSourcePath, operationScriptSha256, parseDeploymentDefinition, parseDeploymentSourceManifestV2, parseSkillMdFrontmatter, platformComputerSnapshotName, recipePackages, resolveSkillTree, sha256Hex, sliceRepoFilesToRoot, stripEditorMetadata, swirlsHost, uuidv7, validateDeploymentSourceInput, virtualRepoCwd };
5507
+ export { AGENTS_SKILLS_DIR, type BuildDefinitionOptions, COMPUTER_BASELINE_KIT, COMPUTER_BASELINE_PACKAGES, COMPUTER_HARNESS_RESOURCE_DEFAULTS, COMPUTER_HARNESS_RUNTIME, COMPUTER_RESOURCE_DEFAULTS, type CompiledComputer, type CompiledComputerHarness, type ComputerHarnessBake, type ComputerHarnessInput, type ComputerRecipeInput, type DeployBundleDirent, type DeployBundleFs, type DeploymentDefinition, type DeploymentSkillFilePayload, type DeploymentSkillFilesBundle, type DeploymentSourceFileContent, type DeploymentSourceManifest, type DeploymentSourceManifestV2, type DeploymentSourceResourceKind, type DeploymentSourceResourceKindV2, type Diagnostic, HARNESS_DEBIAN_STAGE_DIR, HARNESS_PROVIDERS, HARNESS_ROOT_DIR, type HarnessCatalog, type HarnessDebianPackage, type HarnessProvider, type HarnessRuntimePackage, type LanguageHost, type LowerDiagnostic, type LowerMountsOptions, type LowerMountsResult, type LowerOptions, type LowerResult, type LowerStage, MAX_SKILL_FILES, MAX_SKILL_FILE_BYTES, MAX_SKILL_TREE_BYTES, MOUNT_SKILLS_ROOT, type MergeProjectOptions, type MountDiagnostic, type MountFingerprint, type MountSite, type MountSkillFiles, type MountSourceFile, type OpenUiSupport, type ProviderCatalog, SKILL_MD_FILENAME, type SkillBlockRef, type SkillBundle, type SkillClassificationResult, type SkillDeployFs, type SkillDeployStat, type SkillFileEntry, type SkillMdFrontmatter, type SourceRange, type SwirlsFile, type SwirlsMount, type SwirlsMountFiles, type SwirlsSources, buildConfigValueKindsFromNodeDecl, buildDeploymentDefinitionPayload, buildDeploymentSourceManifest, buildWorkflowNodeConfigFromNodeDecl, canonicalizeForStableJson, classifySkillBundle, collectDeploymentSkillFiles, collectDeploymentSourceFiles, collectReferencedSkillBlocksFromAst, collectSwirlsFiles, combineDeploymentAndSourceFingerprints, compileComputerRecipe, compileGoalBlock, compileOperationBlock, computeDefinitionHash, computeDeploymentDefinitionFingerprint, computeDeploymentSourceFingerprint, computeGoalContractHash, computeSkillChecksum, computerHarnessBake, computerSnapshotName, createMemoryRepoFs, createNodeDeployBundleFs, daytonaSnapshotResources, deployBundleToSkillDeployFs, deployBundleToWorkspaceFileSystem, deploymentSourceManifestV2Schema, flattenArchivePathMap, flattenInlineSubgraphsInGraph, floxManifestToml, harnessPrepScript, harnessRuntimePackages, isHarnessProvider, isKnownScriptExtension, isScriptsOrBinDirectory, lowerComputerEgress, lowerComputerRepo, lowerComputerRuntime, lowerSwirlsMounts, lowerSwirlsSources, mergeProjectSwirlsFiles, normalizeDeploymentSourcePath, operationScriptSha256, parseDeploymentDefinition, parseDeploymentSourceManifestV2, parseSkillMdFrontmatter, platformComputerSnapshotName, recipePackages, resolveSkillTree, sha256Hex, sliceRepoFilesToRoot, stripEditorMetadata, swirlsHost, uuidv7, validateDeploymentSourceInput, virtualRepoCwd };
package/dist/index.js CHANGED
@@ -1303,7 +1303,7 @@ var deploymentDefinitionAgentBlockSchema = z10.object({
1303
1303
  * machine; with `sandbox`, they are mounted into the sandbox.
1304
1304
  */
1305
1305
  disks: z10.array(z10.string()).optional(),
1306
- /** Deprecated: the language warns on `sandbox:` and points at `computer`. */
1306
+ /** Refused by the language, which points at `computer`; kept so an older definition still reads. */
1307
1307
  sandbox: deploymentDefinitionAgentSandboxSchema.optional(),
1308
1308
  wallet: deploymentDefinitionAgentWalletSchema.optional(),
1309
1309
  /** Context-engine overrides; absent means the managed defaults apply. */
@@ -1588,6 +1588,29 @@ var deploymentDefinitionComputerRepoRefSchema = z10.discriminatedUnion("kind", [
1588
1588
  /** A full commit id: 40 or 64 lowercase hex characters. */
1589
1589
  z10.object({ kind: z10.literal("commit"), sha: z10.string().regex(/^([0-9a-f]{40}|[0-9a-f]{64})$/) })
1590
1590
  ]);
1591
+ var deploymentDefinitionComputerEgressSecretSchema = z10.object({
1592
+ /** The `secret` block's name. */
1593
+ block: z10.string().min(1),
1594
+ /** The variable in that block. */
1595
+ variable: z10.string().min(1),
1596
+ /** The request header the value goes in, in lower case. */
1597
+ header: z10.string().min(1),
1598
+ /** `bearer`: the header is `Bearer <value>`. `plain`: the value alone. */
1599
+ format: z10.enum(["bearer", "plain"])
1600
+ });
1601
+ var deploymentDefinitionComputerEgressObjectSchema = z10.object({
1602
+ /** An exact lowercase host name, or `*.` and a domain for any subdomain of it. */
1603
+ host: z10.string(),
1604
+ /** The secrets requests to this host may carry. Empty: none. */
1605
+ secrets: z10.array(deploymentDefinitionComputerEgressSecretSchema)
1606
+ });
1607
+ var deploymentDefinitionComputerEgressSchema = z10.union([
1608
+ z10.string().transform((host) => ({
1609
+ host,
1610
+ secrets: []
1611
+ })),
1612
+ deploymentDefinitionComputerEgressObjectSchema
1613
+ ]);
1591
1614
  var deploymentDefinitionComputerRepoSchema = z10.object({
1592
1615
  /**
1593
1616
  * The repository: `self` for the one this file is in, or a repository the
@@ -1632,10 +1655,11 @@ var deploymentDefinitionComputerBlockSchema = z10.object({
1632
1655
  repos: z10.array(deploymentDefinitionComputerRepoSchema).default([]),
1633
1656
  /**
1634
1657
  * Hosts the machine may reach: exact lowercase domain names, or `*.` and a
1635
- * domain for any subdomain of it. Empty: no outside host. A definition
1636
- * stored before the key existed reads as empty.
1658
+ * domain for any subdomain of it, each with the secrets requests to it may
1659
+ * carry. Empty: no outside host. A definition stored before the key existed
1660
+ * reads as empty.
1637
1661
  */
1638
- egress: z10.array(z10.string()).default([]),
1662
+ egress: z10.array(deploymentDefinitionComputerEgressSchema).default([]),
1639
1663
  /** From `idle:`: how long a machine may sit with no step running before it stops. */
1640
1664
  idleSeconds: z10.number().int().positive().optional(),
1641
1665
  /**
@@ -2835,39 +2859,6 @@ var PROVIDER_EXPECTED_VARS = {
2835
2859
  function diag4(message, range2, severity = "error") {
2836
2860
  return { message, range: range2, severity };
2837
2861
  }
2838
- function validateSandboxDecl(decl, label) {
2839
- const out = [];
2840
- if (decl.cpus !== void 0 && decl.cpus < 1) {
2841
- out.push(diag4(`${label}: sandbox.cpus must be at least 1`, decl.cpusRange ?? decl.range));
2842
- }
2843
- if (decl.memoryMiB !== void 0 && decl.memoryMiB < 128) {
2844
- out.push(
2845
- diag4(`${label}: sandbox.memoryMiB must be at least 128`, decl.memoryMiBRange ?? decl.range)
2846
- );
2847
- }
2848
- if (decl.diskGiB !== void 0 && decl.diskGiB < 1) {
2849
- out.push(diag4(`${label}: sandbox.diskGiB must be at least 1`, decl.diskGiBRange ?? decl.range));
2850
- }
2851
- for (const [field, value, range2] of [
2852
- ["autoStopMinutes", decl.autoStopMinutes, decl.autoStopMinutesRange],
2853
- ["autoArchiveMinutes", decl.autoArchiveMinutes, decl.autoArchiveMinutesRange],
2854
- ["autoDeleteMinutes", decl.autoDeleteMinutes, decl.autoDeleteMinutesRange]
2855
- ]) {
2856
- if (value === void 0) {
2857
- continue;
2858
- }
2859
- if (field === "autoArchiveMinutes" || field === "autoDeleteMinutes") {
2860
- if (value < -1) {
2861
- out.push(diag4(`${label}: sandbox.${field} must be >= -1`, range2 ?? decl.range));
2862
- }
2863
- continue;
2864
- }
2865
- if (value < 0) {
2866
- out.push(diag4(`${label}: sandbox.${field} must be >= 0`, range2 ?? decl.range));
2867
- }
2868
- }
2869
- return out;
2870
- }
2871
2862
  var WALLET_CADENCES = ["daily", "weekly", "monthly"];
2872
2863
  function validateWalletDecl(decl, label) {
2873
2864
  const out = [];
@@ -3253,8 +3244,7 @@ function validateAgentBlocks(ast, options) {
3253
3244
  );
3254
3245
  }
3255
3246
  if (a.sandbox) {
3256
- out.push(...validateSandboxDecl(a.sandbox, `Agent "${a.name}"`));
3257
- out.push(sandboxDeprecation(a.sandbox, `Agent "${a.name}"`));
3247
+ out.push(sandboxRefusal(a.sandbox, `Agent "${a.name}"`));
3258
3248
  }
3259
3249
  if (a.wallet) {
3260
3250
  out.push(...validateWalletDecl(a.wallet, `Agent "${a.name}"`));
@@ -3280,10 +3270,7 @@ function validateAgentBlocks(ast, options) {
3280
3270
  );
3281
3271
  }
3282
3272
  if (profile.sandbox) {
3283
- out.push(
3284
- ...validateSandboxDecl(profile.sandbox, `Agent "${a.name}" profile "${profile.name}"`),
3285
- sandboxDeprecation(profile.sandbox, `Agent "${a.name}" profile "${profile.name}"`)
3286
- );
3273
+ out.push(sandboxRefusal(profile.sandbox, `Agent "${a.name}" profile "${profile.name}"`));
3287
3274
  }
3288
3275
  }
3289
3276
  const agentToolSet = new Set(a.tools ?? []);
@@ -3399,15 +3386,6 @@ function validateAgentBlocks(ast, options) {
3399
3386
  );
3400
3387
  }
3401
3388
  const bound = computers.get(computerName);
3402
- const reposNote = bound?.repos && bound.repos.length > 0 ? `; computer "${computerName}" lists repos:, which only a computer checks out` : "";
3403
- if (a.sandbox !== void 0) {
3404
- out.push(
3405
- diag4(
3406
- `Agent "${a.name}" cannot set sandbox together with computer:${reposNote}`,
3407
- a.sandbox.range
3408
- )
3409
- );
3410
- }
3411
3389
  const computerDisks = new Set(bound?.disks ?? []);
3412
3390
  for (let di = 0; di < agentDisks.length; di++) {
3413
3391
  const diskName = agentDisks[di] ?? "";
@@ -3421,16 +3399,6 @@ function validateAgentBlocks(ast, options) {
3421
3399
  );
3422
3400
  }
3423
3401
  }
3424
- for (const profile of a.profiles ?? []) {
3425
- if (profile.sandbox !== void 0) {
3426
- out.push(
3427
- diag4(
3428
- `Profile "${profile.name}" of agent "${a.name}" cannot set sandbox: when the agent sets computer:${reposNote}`,
3429
- profile.sandbox.range
3430
- )
3431
- );
3432
- }
3433
- }
3434
3402
  }
3435
3403
  }
3436
3404
  out.push(...validateTeamCycles(agentByName));
@@ -3463,13 +3431,12 @@ function sandboxFieldAdvice(decl) {
3463
3431
  }
3464
3432
  return advice;
3465
3433
  }
3466
- function sandboxDeprecation(decl, label) {
3434
+ function sandboxRefusal(decl, label) {
3467
3435
  const advice = sandboxFieldAdvice(decl);
3468
3436
  const where = advice.length > 0 ? ` On the computer, ${advice.join("; ")}.` : " Its fields go to the computer: cpus, memoryMiB and diskGiB to resources, autoStopMinutes to idle, autoDeleteMinutes to keep; autoArchiveMinutes and ephemeral are dropped.";
3469
3437
  return diag4(
3470
- `${label}: sandbox: is deprecated and will be refused in a later release. Declare a computer block and set computer: on the agent instead.${where}`,
3471
- decl.range,
3472
- "warning"
3438
+ `${label}: sandbox: is no longer accepted. Declare a computer block and set computer: on the agent instead.${where}`,
3439
+ decl.range
3473
3440
  );
3474
3441
  }
3475
3442
  function validateTeamCycles(agents) {
@@ -6932,6 +6899,257 @@ function parseRepoList(d, key) {
6932
6899
  }
6933
6900
  return repos;
6934
6901
  }
6902
+ function parseEgressSecretRef(d, at) {
6903
+ const first = d.peek();
6904
+ const block = bareName(first);
6905
+ if (block === null || !first) {
6906
+ d.error(
6907
+ "egress: secret must be written as block.VARIABLE, such as model_keys.OPENAI_API_KEY",
6908
+ first ?? at
6909
+ );
6910
+ skipEntryValue(d);
6911
+ return null;
6912
+ }
6913
+ d.advance();
6914
+ if (d.peek()?.kind !== "dot") {
6915
+ d.error(
6916
+ `egress: secret must name a variable of the block, as in ${block}.VARIABLE`,
6917
+ d.peek() ?? first
6918
+ );
6919
+ skipEntryValue(d);
6920
+ return null;
6921
+ }
6922
+ d.advance();
6923
+ const last = d.peek();
6924
+ const variable = bareName(last);
6925
+ if (variable === null || !last) {
6926
+ d.error(`egress: expected a variable name after ${block}.`, last ?? first);
6927
+ skipEntryValue(d);
6928
+ return null;
6929
+ }
6930
+ d.advance();
6931
+ return { block, variable, range: rangeFromTokens5(first, last) };
6932
+ }
6933
+ var EGRESS_SECRET_KEYS = ["secret", "header", "format"];
6934
+ function isEgressSecretKey(value) {
6935
+ return EGRESS_SECRET_KEYS.some((key) => key === value);
6936
+ }
6937
+ function parseEgressSecret(d, open) {
6938
+ d.advance();
6939
+ const seen = /* @__PURE__ */ new Set();
6940
+ let ref = null;
6941
+ const entry = {};
6942
+ let valid = true;
6943
+ while (!d.eof()) {
6944
+ const t = d.peek();
6945
+ if (!t || t.kind === "rbrace" || t.kind === "rbracket") {
6946
+ break;
6947
+ }
6948
+ if (t.kind === "block_comment" || t.kind === "comma") {
6949
+ d.advance();
6950
+ continue;
6951
+ }
6952
+ const key = d.parsePropertyKey();
6953
+ if (!key) {
6954
+ d.error("egress: expected secret, header or format", t);
6955
+ d.advance();
6956
+ valid = false;
6957
+ continue;
6958
+ }
6959
+ if (!d.expect("colon")) {
6960
+ d.error(`egress: expected : after ${key}`, d.peek());
6961
+ valid = false;
6962
+ continue;
6963
+ }
6964
+ if (!isEgressSecretKey(key)) {
6965
+ d.error(
6966
+ `Unknown egress secret property "${key}"; expected one of ${EGRESS_SECRET_KEYS.join(", ")}`,
6967
+ t
6968
+ );
6969
+ skipEntryValue(d);
6970
+ valid = false;
6971
+ continue;
6972
+ }
6973
+ if (seen.has(key)) {
6974
+ d.error(`egress: "${key}" is written twice in one secret`, t);
6975
+ skipEntryValue(d);
6976
+ valid = false;
6977
+ continue;
6978
+ }
6979
+ seen.add(key);
6980
+ if (key === "secret") {
6981
+ ref = parseEgressSecretRef(d, t);
6982
+ continue;
6983
+ }
6984
+ const tok = d.peek();
6985
+ if (key === "header") {
6986
+ if (tok?.kind === "string" && typeof tok.value === "string") {
6987
+ d.advance();
6988
+ entry.header = tok.value;
6989
+ entry.headerRange = tok.range;
6990
+ } else {
6991
+ d.error('egress: header must be a quoted header name, such as "authorization"', tok ?? t);
6992
+ skipEntryValue(d);
6993
+ valid = false;
6994
+ }
6995
+ continue;
6996
+ }
6997
+ const word = bareName(tok);
6998
+ if (word !== null && tok) {
6999
+ d.advance();
7000
+ entry.format = word;
7001
+ entry.formatRange = tok.range;
7002
+ } else {
7003
+ d.error("egress: format must be bearer or plain", tok ?? t);
7004
+ skipEntryValue(d);
7005
+ valid = false;
7006
+ }
7007
+ }
7008
+ const close = d.expect("rbrace");
7009
+ if (!close) {
7010
+ d.error("egress: expected } to close the secret", d.peek());
7011
+ return null;
7012
+ }
7013
+ if (!seen.has("secret")) {
7014
+ d.error("egress: each secret needs secret: block.VARIABLE", open);
7015
+ return null;
7016
+ }
7017
+ if (!seen.has("header")) {
7018
+ d.error("egress: each secret needs header, the request header its value goes in", open);
7019
+ return null;
7020
+ }
7021
+ if (!ref || !valid) {
7022
+ return null;
7023
+ }
7024
+ return {
7025
+ block: ref.block,
7026
+ variable: ref.variable,
7027
+ secretRange: ref.range,
7028
+ ...entry,
7029
+ range: rangeFromTokens5(open, close)
7030
+ };
7031
+ }
7032
+ function parseEgressSecretList(d, at) {
7033
+ if (!d.expect("lbracket")) {
7034
+ d.error(
7035
+ 'egress: secrets expected [ { secret: block.VARIABLE, header: "..." } ]',
7036
+ d.peek() ?? at
7037
+ );
7038
+ skipEntryValue(d);
7039
+ return null;
7040
+ }
7041
+ const secrets = [];
7042
+ let valid = true;
7043
+ while (!d.eof()) {
7044
+ const t = d.peek();
7045
+ if (!t || t.kind === "rbracket") {
7046
+ break;
7047
+ }
7048
+ if (t.kind === "block_comment" || t.kind === "comma") {
7049
+ d.advance();
7050
+ continue;
7051
+ }
7052
+ if (t.kind === "lbrace") {
7053
+ const secret = parseEgressSecret(d, t);
7054
+ if (secret) {
7055
+ secrets.push(secret);
7056
+ } else {
7057
+ valid = false;
7058
+ }
7059
+ continue;
7060
+ }
7061
+ d.error('egress: each secret is { secret: block.VARIABLE, header: "...", format: bearer }', t);
7062
+ valid = false;
7063
+ const before = d.peek();
7064
+ skipEntryValue(d);
7065
+ if (d.peek() === before) {
7066
+ d.advance();
7067
+ }
7068
+ }
7069
+ if (!d.expect("rbracket")) {
7070
+ d.error("Expected ] after egress secrets", d.peek());
7071
+ return null;
7072
+ }
7073
+ return valid ? secrets : null;
7074
+ }
7075
+ var EGRESS_ENTRY_KEYS = ["host", "secrets"];
7076
+ function isEgressEntryKey(value) {
7077
+ return EGRESS_ENTRY_KEYS.some((key) => key === value);
7078
+ }
7079
+ function parseEgressObject(d, open) {
7080
+ d.advance();
7081
+ const seen = /* @__PURE__ */ new Set();
7082
+ let host = null;
7083
+ let secrets = null;
7084
+ let valid = true;
7085
+ while (!d.eof()) {
7086
+ const t = d.peek();
7087
+ if (!t || t.kind === "rbrace" || t.kind === "rbracket") {
7088
+ break;
7089
+ }
7090
+ if (t.kind === "block_comment" || t.kind === "comma") {
7091
+ d.advance();
7092
+ continue;
7093
+ }
7094
+ const key = d.parsePropertyKey();
7095
+ if (!key) {
7096
+ d.error("egress: expected host or secrets", t);
7097
+ d.advance();
7098
+ valid = false;
7099
+ continue;
7100
+ }
7101
+ if (!d.expect("colon")) {
7102
+ d.error(`egress: expected : after ${key}`, d.peek());
7103
+ valid = false;
7104
+ continue;
7105
+ }
7106
+ if (!isEgressEntryKey(key)) {
7107
+ d.error(
7108
+ `Unknown egress property "${key}"; expected one of ${EGRESS_ENTRY_KEYS.join(", ")}`,
7109
+ t
7110
+ );
7111
+ skipEntryValue(d);
7112
+ valid = false;
7113
+ continue;
7114
+ }
7115
+ if (seen.has(key)) {
7116
+ d.error(`egress: "${key}" is written twice in one entry`, t);
7117
+ skipEntryValue(d);
7118
+ valid = false;
7119
+ continue;
7120
+ }
7121
+ seen.add(key);
7122
+ if (key === "host") {
7123
+ const tok = d.peek();
7124
+ if (tok?.kind === "string" && typeof tok.value === "string") {
7125
+ d.advance();
7126
+ host = tok.value;
7127
+ } else {
7128
+ d.error('egress: host must be a quoted string, such as "api.example.com"', tok ?? t);
7129
+ skipEntryValue(d);
7130
+ valid = false;
7131
+ }
7132
+ continue;
7133
+ }
7134
+ secrets = parseEgressSecretList(d, t);
7135
+ if (secrets === null) {
7136
+ valid = false;
7137
+ }
7138
+ }
7139
+ const close = d.expect("rbrace");
7140
+ if (!close) {
7141
+ d.error("egress: expected } to close the entry", d.peek());
7142
+ return null;
7143
+ }
7144
+ if (!seen.has("host")) {
7145
+ d.error("egress: an entry needs host, a quoted host name", open);
7146
+ return null;
7147
+ }
7148
+ if (host === null || !valid) {
7149
+ return null;
7150
+ }
7151
+ return { host, secrets: secrets ?? [], range: rangeFromTokens5(open, close) };
7152
+ }
6935
7153
  function parseEgressList(d, key) {
6936
7154
  if (!d.expect("lbracket")) {
6937
7155
  d.error('egress: expected [ "host", ... ]', d.peek() ?? key);
@@ -6953,7 +7171,17 @@ function parseEgressList(d, key) {
6953
7171
  hosts.push({ host: t.value, range: t.range });
6954
7172
  continue;
6955
7173
  }
6956
- d.error('egress: each host must be a quoted string, such as "api.example.com"', t);
7174
+ if (t.kind === "lbrace") {
7175
+ const entry = parseEgressObject(d, t);
7176
+ if (entry) {
7177
+ hosts.push(entry);
7178
+ }
7179
+ continue;
7180
+ }
7181
+ d.error(
7182
+ 'egress: each entry must be a quoted host, such as "api.example.com", or { host: "...", secrets: [...] }',
7183
+ t
7184
+ );
6957
7185
  const before = d.peek();
6958
7186
  skipEntryValue(d);
6959
7187
  if (d.peek() === before) {
@@ -16199,6 +16427,7 @@ function validateComputerBlocks(ast, options) {
16199
16427
  const blocks = ast.computer ?? [];
16200
16428
  const names = /* @__PURE__ */ new Set();
16201
16429
  const diskByName = diskBlockMap2(ast, options?.workspace);
16430
+ const secretVars = secretVarMap(ast, options?.workspace);
16202
16431
  for (const computer of blocks) {
16203
16432
  out.push(...validateResourceName3(computer.name, computer.range, "Computer block"));
16204
16433
  if (names.has(computer.name)) {
@@ -16251,7 +16480,7 @@ function validateComputerBlocks(ast, options) {
16251
16480
  }
16252
16481
  out.push(...validateHarness(computer, options?.host?.harnesses));
16253
16482
  out.push(...validateRepos(computer));
16254
- out.push(...validateEgress(computer));
16483
+ out.push(...validateEgress(computer, secretVars));
16255
16484
  out.push(...validateLifecycle(computer));
16256
16485
  }
16257
16486
  if (options?.includeUnboundComputerWarnings) {
@@ -16494,9 +16723,40 @@ function validateShellNodes(ast, options) {
16494
16723
  }
16495
16724
  out.push(...validateShellSecretVarsUnique(node));
16496
16725
  }
16726
+ function checkSecretsReachMachine(node) {
16727
+ const computerCv = node.configFields.computer;
16728
+ if (!computerCv || computerCv.kind !== "string") {
16729
+ return;
16730
+ }
16731
+ const computer = computers.get(computerCv.value.trim());
16732
+ if (!computer) {
16733
+ return;
16734
+ }
16735
+ const allowed = new Set(
16736
+ (computer.egress ?? []).flatMap(
16737
+ (entry) => (entry.secrets ?? []).map((secret) => `${secret.block}.${secret.variable}`)
16738
+ )
16739
+ );
16740
+ for (const [blockName, vars] of Object.entries(node.secretsMap ?? {})) {
16741
+ const range2 = node.secretsMapBlockRanges?.find((entry) => entry.blockName === blockName)?.range ?? node.range;
16742
+ for (const variable of vars) {
16743
+ const ref = `${blockName}.${variable}`;
16744
+ if (!allowed.has(ref)) {
16745
+ out.push(
16746
+ diag7(
16747
+ `Secret "${ref}" is not allowed for any egress host of computer "${computer.name}", so the machine will not receive it`,
16748
+ range2,
16749
+ "warning"
16750
+ )
16751
+ );
16752
+ }
16753
+ }
16754
+ }
16755
+ }
16497
16756
  for (const workflow of ast.workflows ?? []) {
16498
16757
  for (const node of workflow.nodes) {
16499
16758
  checkNode(node);
16759
+ checkSecretsReachMachine(node);
16500
16760
  }
16501
16761
  }
16502
16762
  return out;
@@ -16705,11 +16965,110 @@ function egressHostProblem(host) {
16705
16965
  }
16706
16966
  return null;
16707
16967
  }
16708
- function validateEgress(computer) {
16968
+ var HEADER_TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
16969
+ var RESERVED_HEADERS = /* @__PURE__ */ new Set([
16970
+ "host",
16971
+ "content-length",
16972
+ "transfer-encoding",
16973
+ "connection",
16974
+ "upgrade",
16975
+ "te",
16976
+ "trailer",
16977
+ "keep-alive",
16978
+ "proxy-authorization",
16979
+ "proxy-connection"
16980
+ ]);
16981
+ var RESERVED_HEADER_PREFIXES = ["archil-", "x-swirls-"];
16982
+ var EGRESS_SECRET_FORMATS = ["bearer", "plain"];
16983
+ function egressHeaderProblem(header) {
16984
+ if (!HEADER_TOKEN.test(header)) {
16985
+ return 'is not a header name; use letters, digits and hyphens, such as "authorization"';
16986
+ }
16987
+ const lower = header.toLowerCase();
16988
+ if (RESERVED_HEADERS.has(lower)) {
16989
+ return "is set by the connection itself and cannot carry a secret";
16990
+ }
16991
+ if (RESERVED_HEADER_PREFIXES.some((prefix) => lower.startsWith(prefix))) {
16992
+ return "is kept for the gateway that forwards the machine\u2019s requests";
16993
+ }
16994
+ return null;
16995
+ }
16996
+ function secretVarMap(ast, workspace) {
16997
+ const m = /* @__PURE__ */ new Map();
16998
+ if (workspace?.secrets) {
16999
+ for (const [name, entry] of workspace.secrets) {
17000
+ m.set(name, entry.vars);
17001
+ }
17002
+ }
17003
+ for (const block of ast.secrets ?? []) {
17004
+ m.set(block.name, block.vars);
17005
+ }
17006
+ return m;
17007
+ }
17008
+ function validateEgressSecrets(computer, entry, secretVars) {
17009
+ const out = [];
17010
+ const label = `Computer "${computer.name}" egress "${entry.host}"`;
17011
+ if (entry.secrets === void 0) {
17012
+ return out;
17013
+ }
17014
+ if (entry.secrets.length === 0) {
17015
+ out.push(
17016
+ diag7(
17017
+ `${label} lists no secrets; write the host as a plain string, "${entry.host}"`,
17018
+ entry.range,
17019
+ "warning"
17020
+ )
17021
+ );
17022
+ return out;
17023
+ }
17024
+ const seen = /* @__PURE__ */ new Set();
17025
+ for (const secret of entry.secrets) {
17026
+ const ref = `${secret.block}.${secret.variable}`;
17027
+ const vars = secretVars.get(secret.block);
17028
+ if (vars === void 0) {
17029
+ out.push(
17030
+ diag7(
17031
+ `${label} names secret "${ref}", but no secret block "${secret.block}" is declared`,
17032
+ secret.secretRange
17033
+ )
17034
+ );
17035
+ } else if (!vars.includes(secret.variable)) {
17036
+ out.push(
17037
+ diag7(
17038
+ `${label} names secret "${ref}", but secret block "${secret.block}" has no variable "${secret.variable}"`,
17039
+ secret.secretRange
17040
+ )
17041
+ );
17042
+ }
17043
+ if (seen.has(ref)) {
17044
+ out.push(diag7(`${label} lists secret "${ref}" twice`, secret.secretRange));
17045
+ }
17046
+ seen.add(ref);
17047
+ if (secret.header !== void 0) {
17048
+ const problem = egressHeaderProblem(secret.header);
17049
+ if (problem) {
17050
+ out.push(
17051
+ diag7(`${label} header "${secret.header}" ${problem}`, secret.headerRange ?? secret.range)
17052
+ );
17053
+ }
17054
+ }
17055
+ if (secret.format !== void 0 && !EGRESS_SECRET_FORMATS.some((format) => format === secret.format)) {
17056
+ out.push(
17057
+ diag7(
17058
+ `${label} format "${secret.format}" is not one of ${EGRESS_SECRET_FORMATS.join(", ")}`,
17059
+ secret.formatRange ?? secret.range
17060
+ )
17061
+ );
17062
+ }
17063
+ }
17064
+ return out;
17065
+ }
17066
+ function validateEgress(computer, secretVars) {
16709
17067
  const out = [];
16710
17068
  const seen = /* @__PURE__ */ new Set();
16711
17069
  const valid = [];
16712
17070
  for (const entry of computer.egress ?? []) {
17071
+ out.push(...validateEgressSecrets(computer, entry, secretVars));
16713
17072
  const problem = egressHostProblem(entry.host);
16714
17073
  if (problem) {
16715
17074
  out.push(diag7(`Computer "${computer.name}" egress "${entry.host}" ${problem}`, entry.range));
@@ -22440,12 +22799,23 @@ function lowerComputerRepo(entry) {
22440
22799
  lfs: entry.lfs?.value ?? false
22441
22800
  };
22442
22801
  }
22802
+ function lowerComputerEgress(entry) {
22803
+ return {
22804
+ host: entry.host,
22805
+ secrets: (entry.secrets ?? []).map((secret) => ({
22806
+ block: secret.block,
22807
+ variable: secret.variable,
22808
+ header: (secret.header ?? "").toLowerCase(),
22809
+ format: secret.format === "bearer" ? "bearer" : "plain"
22810
+ }))
22811
+ };
22812
+ }
22443
22813
  function lowerComputerRuntime(computer) {
22444
22814
  const idleSeconds = computer.idle?.seconds ?? void 0;
22445
22815
  const keepSeconds = computer.keep?.seconds ?? void 0;
22446
22816
  return {
22447
22817
  repos: (computer.repos ?? []).map(lowerComputerRepo),
22448
- egress: (computer.egress ?? []).map((entry) => entry.host),
22818
+ egress: (computer.egress ?? []).map(lowerComputerEgress),
22449
22819
  ...idleSeconds !== void 0 ? { idleSeconds } : {},
22450
22820
  ...keepSeconds !== void 0 ? { keepSeconds } : {}
22451
22821
  };
@@ -25952,6 +26322,7 @@ export {
25952
26322
  isHarnessProvider,
25953
26323
  isKnownScriptExtension,
25954
26324
  isScriptsOrBinDirectory,
26325
+ lowerComputerEgress,
25955
26326
  lowerComputerRepo,
25956
26327
  lowerComputerRuntime,
25957
26328
  lowerSwirlsMounts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/deploy",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Lowers .swirls source files into a Swirls deployment definition.",
5
5
  "license": "MIT",
6
6
  "repository": {