@swirls/deploy 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +396 -31
  2. package/dist/index.js +2550 -1153
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -3,6 +3,119 @@ import { JSONSchema7 } from 'json-schema';
3
3
  import { z } from 'zod';
4
4
  import fs from 'node:fs';
5
5
 
6
+ declare const goalOnViolationSchema: z.ZodEnum<{
7
+ block: "block";
8
+ review: "review";
9
+ }>;
10
+ type GoalOnViolation = z.infer<typeof goalOnViolationSchema>;
11
+ declare const goalBuiltInOptimizeMetricSchema: z.ZodEnum<{
12
+ duration: "duration";
13
+ cost: "cost";
14
+ interventions: "interventions";
15
+ tokens: "tokens";
16
+ }>;
17
+ type GoalBuiltInOptimizeMetric = z.infer<typeof goalBuiltInOptimizeMetricSchema>;
18
+ declare const goalOptimizeDirectionSchema: z.ZodEnum<{
19
+ minimize: "minimize";
20
+ maximize: "maximize";
21
+ }>;
22
+ type GoalOptimizeDirection = z.infer<typeof goalOptimizeDirectionSchema>;
23
+ /** One named completion check inside `goal.ensure`. */
24
+ declare const goalCheckSchema: z.ZodObject<{
25
+ name: z.ZodString;
26
+ query: z.ZodOptional<z.ZodString>;
27
+ checkCode: z.ZodString;
28
+ }, z.core.$strip>;
29
+ type GoalCheck = z.infer<typeof goalCheckSchema>;
30
+ /** One named hard guardrail inside `goal.invariant`. */
31
+ declare const goalInvariantSchema: z.ZodObject<{
32
+ name: z.ZodString;
33
+ before: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ query: z.ZodOptional<z.ZodString>;
35
+ onViolation: z.ZodOptional<z.ZodEnum<{
36
+ block: "block";
37
+ review: "review";
38
+ }>>;
39
+ checkCode: z.ZodString;
40
+ }, z.core.$strip>;
41
+ type GoalInvariant = z.infer<typeof goalInvariantSchema>;
42
+ /** Execution budget envelope for a goal run. */
43
+ declare const goalBudgetSchema: z.ZodObject<{
44
+ cost: z.ZodOptional<z.ZodNumber>;
45
+ tokens: z.ZodOptional<z.ZodNumber>;
46
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
47
+ attempts: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>;
49
+ type GoalBudget = z.infer<typeof goalBudgetSchema>;
50
+ /**
51
+ * A deployed operational goal contract (`goal <name> { … }`).
52
+ *
53
+ * `contractHash` is the SHA-256 hex digest of the canonical contract surface
54
+ * (input/output schemas, invariants, ensure checks, and budget), allowing
55
+ * runtimes and `deploy_protect` to detect any relaxation or alteration of
56
+ * success criteria across deployments.
57
+ */
58
+ declare const deploymentDefinitionGoalSchema: z.ZodObject<{
59
+ id: z.ZodUUID;
60
+ name: z.ZodString;
61
+ label: z.ZodString;
62
+ description: z.ZodOptional<z.ZodString>;
63
+ objective: z.ZodOptional<z.ZodString>;
64
+ inputSchema: z.ZodOptional<z.ZodType<json_schema.JSONSchema7, json_schema.JSONSchema7, z.core.$ZodTypeInternals<json_schema.JSONSchema7, json_schema.JSONSchema7>>>;
65
+ outputSchema: z.ZodOptional<z.ZodType<json_schema.JSONSchema7, json_schema.JSONSchema7, z.core.$ZodTypeInternals<json_schema.JSONSchema7, json_schema.JSONSchema7>>>;
66
+ executorKind: z.ZodEnum<{
67
+ workflow: "workflow";
68
+ agent: "agent";
69
+ }>;
70
+ executorName: z.ZodString;
71
+ executorId: z.ZodUUID;
72
+ invariants: z.ZodOptional<z.ZodArray<z.ZodObject<{
73
+ name: z.ZodString;
74
+ before: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ query: z.ZodOptional<z.ZodString>;
76
+ onViolation: z.ZodOptional<z.ZodEnum<{
77
+ block: "block";
78
+ review: "review";
79
+ }>>;
80
+ checkCode: z.ZodString;
81
+ }, z.core.$strip>>>;
82
+ ensure: z.ZodArray<z.ZodObject<{
83
+ name: z.ZodString;
84
+ query: z.ZodOptional<z.ZodString>;
85
+ checkCode: z.ZodString;
86
+ }, z.core.$strip>>;
87
+ optimize: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
88
+ direction: z.ZodEnum<{
89
+ minimize: "minimize";
90
+ maximize: "maximize";
91
+ }>;
92
+ metric: z.ZodEnum<{
93
+ duration: "duration";
94
+ cost: "cost";
95
+ interventions: "interventions";
96
+ tokens: "tokens";
97
+ }>;
98
+ name: z.ZodOptional<z.ZodNever>;
99
+ scoreCode: z.ZodOptional<z.ZodNever>;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ direction: z.ZodEnum<{
102
+ minimize: "minimize";
103
+ maximize: "maximize";
104
+ }>;
105
+ name: z.ZodString;
106
+ scoreCode: z.ZodString;
107
+ metric: z.ZodOptional<z.ZodNever>;
108
+ }, z.core.$strip>]>>>;
109
+ budget: z.ZodOptional<z.ZodObject<{
110
+ cost: z.ZodOptional<z.ZodNumber>;
111
+ tokens: z.ZodOptional<z.ZodNumber>;
112
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
113
+ attempts: z.ZodOptional<z.ZodNumber>;
114
+ }, z.core.$strip>>;
115
+ contractHash: z.ZodString;
116
+ }, z.core.$strip>;
117
+ type DeploymentDefinitionGoal = z.infer<typeof deploymentDefinitionGoalSchema>;
118
+
6
119
  /**
7
120
  * Where a channel can be bound. Part of the definition, so the language reads
8
121
  * its platform list from here instead of keeping a copy.
@@ -440,6 +553,7 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
440
553
  label: z.ZodOptional<z.ZodString>;
441
554
  }, z.core.$strip>>;
442
555
  synthetic: z.ZodOptional<z.ZodBoolean>;
556
+ achieves: z.ZodOptional<z.ZodString>;
443
557
  }, z.core.$strip>>>;
444
558
  schemas: z.ZodOptional<z.ZodArray<z.ZodObject<{
445
559
  id: z.ZodUUID;
@@ -457,7 +571,8 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
457
571
  schedule: "schedule";
458
572
  }>;
459
573
  resourceId: z.ZodUUID;
460
- workflowId: z.ZodUUID;
574
+ workflowId: z.ZodOptional<z.ZodUUID>;
575
+ goalId: z.ZodOptional<z.ZodUUID>;
461
576
  enabled: z.ZodOptional<z.ZodBoolean>;
462
577
  }, z.core.$strip>>>;
463
578
  secretBlocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -687,6 +802,7 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
687
802
  label: z.ZodString;
688
803
  message: z.ZodString;
689
804
  }, z.core.$strip>>>;
805
+ achieves: z.ZodOptional<z.ZodString>;
690
806
  }, z.core.$strip>>>;
691
807
  channelBlocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
692
808
  id: z.ZodUUID;
@@ -1011,6 +1127,7 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
1011
1127
  role: z.ZodString;
1012
1128
  agent: z.ZodString;
1013
1129
  workflow: z.ZodOptional<z.ZodNever>;
1130
+ goal: z.ZodOptional<z.ZodNever>;
1014
1131
  workflows: z.ZodOptional<z.ZodArray<z.ZodString>>;
1015
1132
  tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1016
1133
  }, z.core.$strip>, z.ZodObject<{
@@ -1021,6 +1138,18 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
1021
1138
  role: z.ZodString;
1022
1139
  workflow: z.ZodString;
1023
1140
  agent: z.ZodOptional<z.ZodNever>;
1141
+ goal: z.ZodOptional<z.ZodNever>;
1142
+ workflows: z.ZodOptional<z.ZodNever>;
1143
+ tools: z.ZodOptional<z.ZodNever>;
1144
+ }, z.core.$strip>, z.ZodObject<{
1145
+ effect: z.ZodEnum<{
1146
+ allow: "allow";
1147
+ deny: "deny";
1148
+ }>;
1149
+ role: z.ZodString;
1150
+ goal: z.ZodString;
1151
+ agent: z.ZodOptional<z.ZodNever>;
1152
+ workflow: z.ZodOptional<z.ZodNever>;
1024
1153
  workflows: z.ZodOptional<z.ZodNever>;
1025
1154
  tools: z.ZodOptional<z.ZodNever>;
1026
1155
  }, z.core.$strip>]>>;
@@ -1033,6 +1162,65 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
1033
1162
  }, z.core.$strip>], "mode">;
1034
1163
  }, z.core.$strip>>;
1035
1164
  }, z.core.$strip>>>;
1165
+ goals: z.ZodOptional<z.ZodArray<z.ZodObject<{
1166
+ id: z.ZodUUID;
1167
+ name: z.ZodString;
1168
+ label: z.ZodString;
1169
+ description: z.ZodOptional<z.ZodString>;
1170
+ objective: z.ZodOptional<z.ZodString>;
1171
+ inputSchema: z.ZodOptional<z.ZodType<json_schema.JSONSchema7, json_schema.JSONSchema7, z.core.$ZodTypeInternals<json_schema.JSONSchema7, json_schema.JSONSchema7>>>;
1172
+ outputSchema: z.ZodOptional<z.ZodType<json_schema.JSONSchema7, json_schema.JSONSchema7, z.core.$ZodTypeInternals<json_schema.JSONSchema7, json_schema.JSONSchema7>>>;
1173
+ executorKind: z.ZodEnum<{
1174
+ workflow: "workflow";
1175
+ agent: "agent";
1176
+ }>;
1177
+ executorName: z.ZodString;
1178
+ executorId: z.ZodUUID;
1179
+ invariants: z.ZodOptional<z.ZodArray<z.ZodObject<{
1180
+ name: z.ZodString;
1181
+ before: z.ZodOptional<z.ZodArray<z.ZodString>>;
1182
+ query: z.ZodOptional<z.ZodString>;
1183
+ onViolation: z.ZodOptional<z.ZodEnum<{
1184
+ block: "block";
1185
+ review: "review";
1186
+ }>>;
1187
+ checkCode: z.ZodString;
1188
+ }, z.core.$strip>>>;
1189
+ ensure: z.ZodArray<z.ZodObject<{
1190
+ name: z.ZodString;
1191
+ query: z.ZodOptional<z.ZodString>;
1192
+ checkCode: z.ZodString;
1193
+ }, z.core.$strip>>;
1194
+ optimize: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1195
+ direction: z.ZodEnum<{
1196
+ minimize: "minimize";
1197
+ maximize: "maximize";
1198
+ }>;
1199
+ metric: z.ZodEnum<{
1200
+ duration: "duration";
1201
+ cost: "cost";
1202
+ interventions: "interventions";
1203
+ tokens: "tokens";
1204
+ }>;
1205
+ name: z.ZodOptional<z.ZodNever>;
1206
+ scoreCode: z.ZodOptional<z.ZodNever>;
1207
+ }, z.core.$strip>, z.ZodObject<{
1208
+ direction: z.ZodEnum<{
1209
+ minimize: "minimize";
1210
+ maximize: "maximize";
1211
+ }>;
1212
+ name: z.ZodString;
1213
+ scoreCode: z.ZodString;
1214
+ metric: z.ZodOptional<z.ZodNever>;
1215
+ }, z.core.$strip>]>>>;
1216
+ budget: z.ZodOptional<z.ZodObject<{
1217
+ cost: z.ZodOptional<z.ZodNumber>;
1218
+ tokens: z.ZodOptional<z.ZodNumber>;
1219
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
1220
+ attempts: z.ZodOptional<z.ZodNumber>;
1221
+ }, z.core.$strip>>;
1222
+ contractHash: z.ZodString;
1223
+ }, z.core.$strip>>>;
1036
1224
  mockBlocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1037
1225
  id: z.ZodUUID;
1038
1226
  name: z.ZodString;
@@ -1042,6 +1230,7 @@ declare const deploymentDefinitionSchema: z.ZodObject<{
1042
1230
  name: z.ZodString;
1043
1231
  }, z.core.$loose>>>;
1044
1232
  }, z.core.$strip>;
1233
+
1045
1234
  type DeploymentDefinition = z.infer<typeof deploymentDefinitionSchema>;
1046
1235
  type DeploymentDefinitionOperationBlock = z.infer<typeof deploymentDefinitionOperationBlockSchema>;
1047
1236
  declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<{
@@ -1336,6 +1525,7 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1336
1525
  concurrency?: number | undefined;
1337
1526
  executionTokenTtlSeconds?: number | undefined;
1338
1527
  synthetic?: boolean | undefined;
1528
+ achieves?: string | undefined;
1339
1529
  }[] | undefined;
1340
1530
  schemas?: {
1341
1531
  id: string;
@@ -1349,7 +1539,8 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1349
1539
  name: string;
1350
1540
  resourceType: "form" | "webhook" | "schedule";
1351
1541
  resourceId: string;
1352
- workflowId: string;
1542
+ workflowId?: string | undefined;
1543
+ goalId?: string | undefined;
1353
1544
  enabled?: boolean | undefined;
1354
1545
  }[] | undefined;
1355
1546
  secretBlocks?: {
@@ -1556,6 +1747,7 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1556
1747
  label: string;
1557
1748
  message: string;
1558
1749
  }[] | undefined;
1750
+ achieves?: string | undefined;
1559
1751
  }[] | undefined;
1560
1752
  channelBlocks?: {
1561
1753
  id: string;
@@ -1804,6 +1996,7 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1804
1996
  role: string;
1805
1997
  agent: string;
1806
1998
  workflow?: undefined;
1999
+ goal?: undefined;
1807
2000
  workflows?: string[] | undefined;
1808
2001
  tools?: string[] | undefined;
1809
2002
  } | {
@@ -1811,6 +2004,15 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1811
2004
  role: string;
1812
2005
  workflow: string;
1813
2006
  agent?: undefined;
2007
+ goal?: undefined;
2008
+ workflows?: undefined;
2009
+ tools?: undefined;
2010
+ } | {
2011
+ effect: "allow" | "deny";
2012
+ role: string;
2013
+ goal: string;
2014
+ agent?: undefined;
2015
+ workflow?: undefined;
1814
2016
  workflows?: undefined;
1815
2017
  tools?: undefined;
1816
2018
  })[];
@@ -1823,6 +2025,48 @@ declare function parseDeploymentDefinition(data: unknown): z.ZodSafeParseResult<
1823
2025
  };
1824
2026
  } | undefined;
1825
2027
  }[] | undefined;
2028
+ goals?: {
2029
+ id: string;
2030
+ name: string;
2031
+ label: string;
2032
+ executorKind: "workflow" | "agent";
2033
+ executorName: string;
2034
+ executorId: string;
2035
+ ensure: {
2036
+ name: string;
2037
+ checkCode: string;
2038
+ query?: string | undefined;
2039
+ }[];
2040
+ contractHash: string;
2041
+ description?: string | undefined;
2042
+ objective?: string | undefined;
2043
+ inputSchema?: json_schema.JSONSchema7 | undefined;
2044
+ outputSchema?: json_schema.JSONSchema7 | undefined;
2045
+ invariants?: {
2046
+ name: string;
2047
+ checkCode: string;
2048
+ before?: string[] | undefined;
2049
+ query?: string | undefined;
2050
+ onViolation?: "block" | "review" | undefined;
2051
+ }[] | undefined;
2052
+ optimize?: ({
2053
+ direction: "minimize" | "maximize";
2054
+ metric: "duration" | "cost" | "interventions" | "tokens";
2055
+ name?: undefined;
2056
+ scoreCode?: undefined;
2057
+ } | {
2058
+ direction: "minimize" | "maximize";
2059
+ name: string;
2060
+ scoreCode: string;
2061
+ metric?: undefined;
2062
+ })[] | undefined;
2063
+ budget?: {
2064
+ cost?: number | undefined;
2065
+ tokens?: number | undefined;
2066
+ durationSeconds?: number | undefined;
2067
+ attempts?: number | undefined;
2068
+ } | undefined;
2069
+ }[] | undefined;
1826
2070
  mockBlocks?: {
1827
2071
  [x: string]: unknown;
1828
2072
  id: string;
@@ -1860,8 +2104,9 @@ declare const deploymentSourceResourceKindSchema: z.ZodEnum<{
1860
2104
  schedule: "schedule";
1861
2105
  mcp: "mcp";
1862
2106
  channel: "channel";
1863
- view: "view";
2107
+ goal: "goal";
1864
2108
  trigger: "trigger";
2109
+ view: "view";
1865
2110
  secret: "secret";
1866
2111
  migration: "migration";
1867
2112
  skill: "skill";
@@ -1895,8 +2140,9 @@ declare const deploymentSourceManifestSchema: z.ZodObject<{
1895
2140
  schedule: "schedule";
1896
2141
  mcp: "mcp";
1897
2142
  channel: "channel";
1898
- view: "view";
2143
+ goal: "goal";
1899
2144
  trigger: "trigger";
2145
+ view: "view";
1900
2146
  secret: "secret";
1901
2147
  migration: "migration";
1902
2148
  skill: "skill";
@@ -2141,6 +2387,9 @@ interface AgentDecl {
2141
2387
  context?: AgentContextDecl;
2142
2388
  /** Optional starter prompts shown in Cloud agent chat zero state. */
2143
2389
  suggestions?: AgentSuggestionDecl[];
2390
+ /** Optional `goal` block name this agent conforms to (`achieves: <goal>`). */
2391
+ achieves?: string;
2392
+ achievesRange?: SourceRange;
2144
2393
  profiles: AgentProfileDecl[];
2145
2394
  docComment?: string;
2146
2395
  range: SourceRange;
@@ -2630,6 +2879,93 @@ interface DiskDecl {
2630
2879
  range: SourceRange;
2631
2880
  }
2632
2881
 
2882
+ /**
2883
+ * AST types for top-level `goal <name> { … }` blocks.
2884
+ */
2885
+
2886
+ /** One named completion check inside `goal.ensure { … }`. */
2887
+ interface GoalCheckDecl {
2888
+ name: string;
2889
+ nameRange: SourceRange;
2890
+ /** Optional `query` block reference whose rows are bound to `context.rows`. */
2891
+ query?: string;
2892
+ queryRange?: SourceRange;
2893
+ /** `@ts { … }` or `@ts "…"` predicate returning `boolean | { pass, reason?, evidence? }`. */
2894
+ check?: ConfigValue;
2895
+ range: SourceRange;
2896
+ }
2897
+ /** One named hard guardrail inside `goal.invariant { … }`. */
2898
+ interface GoalInvariantDecl {
2899
+ name: string;
2900
+ nameRange: SourceRange;
2901
+ /** Actions or tools guarded synchronously before side effects commit. */
2902
+ before?: string[];
2903
+ beforeRanges?: SourceRange[];
2904
+ /** Optional `query` block reference whose rows are bound to `context.rows`. */
2905
+ query?: string;
2906
+ queryRange?: SourceRange;
2907
+ /** Handling when violated synchronously (`block` | `review`). */
2908
+ onViolation?: GoalOnViolation;
2909
+ onViolationRange?: SourceRange;
2910
+ /** `@ts { … }` or `@ts "…"` predicate returning `boolean | { pass, reason?, evidence? }`. */
2911
+ check?: ConfigValue;
2912
+ range: SourceRange;
2913
+ }
2914
+ /** One optimization objective inside `goal.optimize { … }`. */
2915
+ type GoalOptimizeDecl = {
2916
+ kind: 'builtin';
2917
+ direction: GoalOptimizeDirection;
2918
+ metric: GoalBuiltInOptimizeMetric;
2919
+ metricRange: SourceRange;
2920
+ range: SourceRange;
2921
+ } | {
2922
+ kind: 'custom';
2923
+ direction: GoalOptimizeDirection;
2924
+ name: string;
2925
+ nameRange: SourceRange;
2926
+ score?: ConfigValue;
2927
+ range: SourceRange;
2928
+ };
2929
+ /** Execution budget envelope inside `goal.budget { … }`. */
2930
+ interface GoalBudgetDecl {
2931
+ cost?: number;
2932
+ costRange?: SourceRange;
2933
+ tokens?: number;
2934
+ tokensRange?: SourceRange;
2935
+ duration?: string;
2936
+ durationSeconds?: number;
2937
+ durationRange?: SourceRange;
2938
+ attempts?: number;
2939
+ attemptsRange?: SourceRange;
2940
+ range: SourceRange;
2941
+ }
2942
+ /** Top-level `goal <name> { … }` operational contract declaration. */
2943
+ interface GoalDecl {
2944
+ /** Set by deploy bundle / tooling; not produced by the parser. */
2945
+ id?: string;
2946
+ name: string;
2947
+ label: string;
2948
+ description?: string;
2949
+ objective?: string;
2950
+ inputSchema?: JsonSchemaLiteral;
2951
+ inputSchemaBlock?: JsonBlockInfo;
2952
+ inputSchemaRef?: string;
2953
+ inputSchemaRefRange?: SourceRange;
2954
+ outputSchema?: JsonSchemaLiteral;
2955
+ outputSchemaBlock?: JsonBlockInfo;
2956
+ outputSchemaRef?: string;
2957
+ outputSchemaRefRange?: SourceRange;
2958
+ /** Active executor: name of a top-level `workflow` or `agent` block. */
2959
+ by: string;
2960
+ byRange?: SourceRange;
2961
+ invariants: GoalInvariantDecl[];
2962
+ ensure: GoalCheckDecl[];
2963
+ optimize: GoalOptimizeDecl[];
2964
+ budget?: GoalBudgetDecl;
2965
+ docComment?: string;
2966
+ range: SourceRange;
2967
+ }
2968
+
2633
2969
  /**
2634
2970
  * AST types for top-level `mcp name { … }` blocks referenced by `agent.mcp:`.
2635
2971
  *
@@ -2705,6 +3041,8 @@ interface MockDecl {
2705
3041
  /** Static output (@json). */
2706
3042
  output?: JsonBlockInfo;
2707
3043
  outputLiteral?: Record<string, unknown>;
3044
+ /** Stateful handler (@ts { … } or @ts "…") receiving `{ args, state }`. */
3045
+ handler?: ConfigValue;
2708
3046
  /** LLM-generated stub; true or inline ai config. */
2709
3047
  generate?: boolean | MockAiConfig;
2710
3048
  review?: MockReviewConfig;
@@ -2804,7 +3142,7 @@ interface OperationDecl {
2804
3142
  }
2805
3143
 
2806
3144
  /**
2807
- * AST for top-level `playbook` blocks (hosted test suites).
3145
+ * AST for top-level `playbook` blocks (hosted test suites and benchmarks).
2808
3146
  */
2809
3147
 
2810
3148
  type AssertionSeverity = 'soft' | 'gate';
@@ -2815,13 +3153,6 @@ type ExpectAssertion = {
2815
3153
  severity?: AssertionSeverity;
2816
3154
  label?: string;
2817
3155
  range: SourceRange;
2818
- } | {
2819
- kind: 'duration';
2820
- max: string;
2821
- maxSeconds?: number;
2822
- severity?: AssertionSeverity;
2823
- label?: string;
2824
- range: SourceRange;
2825
3156
  } | {
2826
3157
  kind: 'output';
2827
3158
  value?: JsonBlockInfo;
@@ -2916,20 +3247,6 @@ interface ExpectDecl {
2916
3247
  assertions: ExpectAssertion[];
2917
3248
  range: SourceRange;
2918
3249
  }
2919
- interface PlaybookCaseDecl {
2920
- name: string;
2921
- workflow: string;
2922
- workflowRange?: SourceRange;
2923
- input?: JsonBlockInfo;
2924
- inputLiteral?: Record<string, unknown>;
2925
- dataset?: JsonBlockInfo;
2926
- timeout?: string;
2927
- timeoutSeconds?: number;
2928
- tags?: string[];
2929
- skip?: string;
2930
- expect?: ExpectDecl;
2931
- range: SourceRange;
2932
- }
2933
3250
  interface JudgeDecl {
2934
3251
  rubric?: string;
2935
3252
  criteria?: string;
@@ -2937,14 +3254,25 @@ interface JudgeDecl {
2937
3254
  severity?: AssertionSeverity;
2938
3255
  label?: string;
2939
3256
  model?: string;
2940
- /** Deterministic @ts scorer over execution outputs. */
3257
+ /** Deterministic @ts scorer (or @ts file ref) over execution outputs. */
2941
3258
  ts?: ConfigValue;
2942
3259
  range: SourceRange;
2943
3260
  }
2944
- interface PlaybookEvalDecl {
3261
+ /**
3262
+ * One scenario inside a `playbook` block (authored as `case <name> { … }`;
3263
+ * `eval <name> { … }` is accepted as a parser alias). Targets either a
3264
+ * `workflow:` or a `goal:` (with optional `by:` executor override for
3265
+ * benchmarking competing strategies against the same goal).
3266
+ */
3267
+ interface PlaybookCaseDecl {
2945
3268
  name: string;
2946
- workflow: string;
3269
+ workflow?: string;
2947
3270
  workflowRange?: SourceRange;
3271
+ goal?: string;
3272
+ goalRange?: SourceRange;
3273
+ /** Optional executor override (`workflow` or `agent`) when targeting a `goal:`. */
3274
+ by?: string;
3275
+ byRange?: SourceRange;
2948
3276
  input?: JsonBlockInfo;
2949
3277
  inputLiteral?: Record<string, unknown>;
2950
3278
  dataset?: JsonBlockInfo;
@@ -2968,7 +3296,6 @@ interface PlaybookDecl {
2968
3296
  mocksRange?: SourceRange;
2969
3297
  tags?: string[];
2970
3298
  cases: PlaybookCaseDecl[];
2971
- evals: PlaybookEvalDecl[];
2972
3299
  range: SourceRange;
2973
3300
  }
2974
3301
 
@@ -3096,9 +3423,15 @@ interface PolicyGrantBase {
3096
3423
  type PolicyGrant = PolicyGrantBase & ({
3097
3424
  agent: string;
3098
3425
  workflow?: never;
3426
+ goal?: never;
3099
3427
  } | {
3100
3428
  workflow: string;
3101
3429
  agent?: never;
3430
+ goal?: never;
3431
+ } | {
3432
+ goal: string;
3433
+ agent?: never;
3434
+ workflow?: never;
3102
3435
  });
3103
3436
  /** File retention settings inside `policy { files { … } }`. */
3104
3437
  interface FilePolicySettings {
@@ -3473,6 +3806,9 @@ interface WorkflowDecl {
3473
3806
  concurrency?: number;
3474
3807
  /** Lifetime of the execution authorization token (`executionTokenTtl:`). */
3475
3808
  executionTokenTtl?: string;
3809
+ /** Optional `goal` block name this workflow conforms to (`achieves: <goal>`). */
3810
+ achieves?: string;
3811
+ achievesRange?: SourceRange;
3476
3812
  /** Doc comment (block-comment style) immediately above this declaration; shown on hover. */
3477
3813
  docComment?: string;
3478
3814
  nodes: NodeDecl[];
@@ -3488,9 +3824,15 @@ interface TriggerDecl {
3488
3824
  resourceType: TriggerType;
3489
3825
  resourceName: string;
3490
3826
  workflowName: string;
3827
+ /** Explicit or resolved goal target (`form: req -> goal generate_quote` or bare goal name). */
3828
+ goalName?: string;
3829
+ goalNameRange?: SourceRange;
3830
+ /** Explicitly written target kind when author wrote `-> goal <name>` or `-> workflow <name>`. */
3831
+ targetKind?: 'workflow' | 'goal';
3491
3832
  /** Resolved UUIDs for deploy payloads; not produced by the parser. */
3492
3833
  resourceId?: string;
3493
3834
  workflowId?: string;
3835
+ goalId?: string;
3494
3836
  /** Doc comment (block-comment style) immediately above this declaration; shown on hover. */
3495
3837
  docComment?: string;
3496
3838
  enabled?: boolean;
@@ -3575,6 +3917,8 @@ interface SwirlsFile {
3575
3917
  /** Role-to-resource grants (`policy { allow <role> -> agent … }`). A policy
3576
3918
  * with grants opts the deployment into deny-by-default enforcement. */
3577
3919
  policies: PolicyDecl[];
3920
+ /** Operational goal contracts (`goal name { … }`). */
3921
+ goals?: GoalDecl[];
3578
3922
  /** Bespoke OpenUI-backed interfaces (`app name { shell, nav, page … }`). */
3579
3923
  apps: AppDecl[];
3580
3924
  /** Side-effect stubs for playbook runs (`mock name { … }`). */
@@ -3960,6 +4304,27 @@ declare function computeDefinitionHash(stripped: SwirlsFile): string;
3960
4304
  */
3961
4305
  declare function computeDeploymentDefinitionFingerprint(def: DeploymentDefinition): string;
3962
4306
 
4307
+ /**
4308
+ * Deterministic SHA-256 hex digest of a goal's verification contract surface
4309
+ * (`inputSchema`, `outputSchema`, `invariants`, `ensure`, `budget`).
4310
+ *
4311
+ * Intentionally excludes executor binding (`by:`) and prose (`label`, `objective`)
4312
+ * so swapping implementations (e.g. agent -> workflow) keeps the same contract hash,
4313
+ * while any edit to invariants, ensure checks, schemas, or budgets changes it.
4314
+ */
4315
+ declare function computeGoalContractHash(contract: {
4316
+ inputSchema?: DeploymentDefinitionGoal['inputSchema'];
4317
+ outputSchema?: DeploymentDefinitionGoal['outputSchema'];
4318
+ invariants?: GoalInvariant[];
4319
+ ensure: GoalCheck[];
4320
+ budget?: GoalBudget;
4321
+ }): string;
4322
+ declare function compileGoalBlock(goal: GoalDecl, deps: {
4323
+ id: string;
4324
+ workflowByName: Map<string, string>;
4325
+ agentByName: Map<string, string>;
4326
+ }): DeploymentDefinitionGoal;
4327
+
3963
4328
  /**
3964
4329
  * A UUIDv7 (RFC 9562): 48 bits of Unix time in milliseconds, then random bits.
3965
4330
  * Ids made later sort later, which keeps stored definitions in creation order.
@@ -4694,4 +5059,4 @@ declare function buildDeploymentSourceManifest({ definition, ast, files, }: {
4694
5059
  */
4695
5060
  declare function stripEditorMetadata(value: unknown): unknown;
4696
5061
 
4697
- export { AGENTS_SKILLS_DIR, type BuildDefinitionOptions, COMPUTER_BASELINE_KIT, COMPUTER_BASELINE_PACKAGES, COMPUTER_HARNESS_RESOURCE_DEFAULTS, COMPUTER_HARNESS_RUNTIME, COMPUTER_MOUNT_KIT, COMPUTER_MOUNT_PACKAGES, 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, EXECUTABLE_STRING_FIELDS, 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, compileOperationBlock, computeDefinitionHash, computeDeploymentDefinitionFingerprint, computeDeploymentSourceFingerprint, computeSkillChecksum, computerHarnessBake, computerSnapshotName, createMemoryRepoFs, createNodeDeployBundleFs, daytonaSnapshotResources, deployBundleToSkillDeployFs, deployBundleToWorkspaceFileSystem, deploymentSourceManifestV2Schema, flattenArchivePathMap, flattenInlineSubgraphsInGraph, floxManifestToml, harnessPrepScript, harnessRuntimePackages, isHarnessProvider, isKnownScriptExtension, isScriptsOrBinDirectory, lowerSwirlsMounts, lowerSwirlsSources, mergeProjectSwirlsFiles, normalizeDeploymentSourcePath, operationScriptSha256, parseDeploymentDefinition, parseDeploymentSourceManifestV2, parseSkillMdFrontmatter, platformComputerSnapshotName, recipePackages, resolveSkillTree, sha256Hex, sliceRepoFilesToRoot, stripEditorMetadata, swirlsHost, uuidv7, validateDeploymentSourceInput, virtualRepoCwd };
5062
+ export { AGENTS_SKILLS_DIR, type BuildDefinitionOptions, COMPUTER_BASELINE_KIT, COMPUTER_BASELINE_PACKAGES, COMPUTER_HARNESS_RESOURCE_DEFAULTS, COMPUTER_HARNESS_RUNTIME, COMPUTER_MOUNT_KIT, COMPUTER_MOUNT_PACKAGES, 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, EXECUTABLE_STRING_FIELDS, 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, lowerSwirlsMounts, lowerSwirlsSources, mergeProjectSwirlsFiles, normalizeDeploymentSourcePath, operationScriptSha256, parseDeploymentDefinition, parseDeploymentSourceManifestV2, parseSkillMdFrontmatter, platformComputerSnapshotName, recipePackages, resolveSkillTree, sha256Hex, sliceRepoFilesToRoot, stripEditorMetadata, swirlsHost, uuidv7, validateDeploymentSourceInput, virtualRepoCwd };