@tacuchi/agent-workflow-cli 21.0.0 → 21.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 (170) hide show
  1. package/README.md +3 -2
  2. package/dist/adapters/git-cli.js +12 -7
  3. package/dist/adapters/git-cli.js.map +1 -1
  4. package/dist/application/capability/compose.js +161 -0
  5. package/dist/application/capability/compose.js.map +1 -0
  6. package/dist/application/capability/descriptor-loader.js +109 -0
  7. package/dist/application/capability/descriptor-loader.js.map +1 -0
  8. package/dist/application/capability/design-handler.js +299 -0
  9. package/dist/application/capability/design-handler.js.map +1 -0
  10. package/dist/application/capability/dispatcher.js +312 -0
  11. package/dist/application/capability/dispatcher.js.map +1 -0
  12. package/dist/application/capability/durable-effect.js +220 -0
  13. package/dist/application/capability/durable-effect.js.map +1 -0
  14. package/dist/application/capability/installed-inventory.js +168 -0
  15. package/dist/application/capability/installed-inventory.js.map +1 -0
  16. package/dist/application/capability/readiness.js +204 -0
  17. package/dist/application/capability/readiness.js.map +1 -0
  18. package/dist/application/capability/resolution.js +264 -0
  19. package/dist/application/capability/resolution.js.map +1 -0
  20. package/dist/application/capability/wrapper.js +195 -0
  21. package/dist/application/capability/wrapper.js.map +1 -0
  22. package/dist/application/context/manifest.js +11 -5
  23. package/dist/application/context/manifest.js.map +1 -1
  24. package/dist/application/context/measure.js +5 -2
  25. package/dist/application/context/measure.js.map +1 -1
  26. package/dist/application/context/plan-service.js +6 -6
  27. package/dist/application/context/plan-service.js.map +1 -1
  28. package/dist/application/design/design-bundle-service.js +148 -0
  29. package/dist/application/design/design-bundle-service.js.map +1 -0
  30. package/dist/application/design/design-proposal-service.js +69 -0
  31. package/dist/application/design/design-proposal-service.js.map +1 -0
  32. package/dist/application/design/design-publish-service.js +275 -7
  33. package/dist/application/design/design-publish-service.js.map +1 -1
  34. package/dist/application/design/design-record-service.js +100 -0
  35. package/dist/application/design/design-record-service.js.map +1 -0
  36. package/dist/application/flow/advance.js +533 -0
  37. package/dist/application/flow/advance.js.map +1 -0
  38. package/dist/application/flow/flow-service.js +65 -0
  39. package/dist/application/flow/flow-service.js.map +1 -0
  40. package/dist/application/flow/run-projection.js +80 -0
  41. package/dist/application/flow/run-projection.js.map +1 -0
  42. package/dist/application/flow/run-state-service.js +107 -0
  43. package/dist/application/flow/run-state-service.js.map +1 -0
  44. package/dist/application/flow/submit.js +423 -0
  45. package/dist/application/flow/submit.js.map +1 -0
  46. package/dist/application/markdown.js +16 -2
  47. package/dist/application/markdown.js.map +1 -1
  48. package/dist/application/resume-service.js +23 -10
  49. package/dist/application/resume-service.js.map +1 -1
  50. package/dist/application/self/hooks-toml.js +137 -17
  51. package/dist/application/self/hooks-toml.js.map +1 -1
  52. package/dist/application/self/host-states.js +87 -1
  53. package/dist/application/self/host-states.js.map +1 -1
  54. package/dist/application/self/install-hooks.js +62 -6
  55. package/dist/application/self/install-hooks.js.map +1 -1
  56. package/dist/application/self/install-skill.js +37 -6
  57. package/dist/application/self/install-skill.js.map +1 -1
  58. package/dist/application/self/uninstall.js +21 -0
  59. package/dist/application/self/uninstall.js.map +1 -1
  60. package/dist/application/skills-resolver-service.js +8 -2
  61. package/dist/application/skills-resolver-service.js.map +1 -1
  62. package/dist/application/status-service.js +4 -1
  63. package/dist/application/status-service.js.map +1 -1
  64. package/dist/application/workline-index-service.js +15 -2
  65. package/dist/application/workline-index-service.js.map +1 -1
  66. package/dist/application/workspace-init-service.js +13 -1
  67. package/dist/application/workspace-init-service.js.map +1 -1
  68. package/dist/cli/commands/capability.js +182 -0
  69. package/dist/cli/commands/capability.js.map +1 -0
  70. package/dist/cli/commands/flow.js +71 -0
  71. package/dist/cli/commands/flow.js.map +1 -0
  72. package/dist/cli/commands/index.js +4 -0
  73. package/dist/cli/commands/index.js.map +1 -1
  74. package/dist/cli/commands/skills.js +55 -2
  75. package/dist/cli/commands/skills.js.map +1 -1
  76. package/dist/cli/commands/status.js +5 -0
  77. package/dist/cli/commands/status.js.map +1 -1
  78. package/dist/cli/help-groups.js +6 -0
  79. package/dist/cli/help-groups.js.map +1 -1
  80. package/dist/cli/parser.js +6 -0
  81. package/dist/cli/parser.js.map +1 -1
  82. package/dist/cli/tui/components/host-admin-section.js +14 -2
  83. package/dist/cli/tui/components/host-admin-section.js.map +1 -1
  84. package/dist/cli/tui/data/workflow-content.js +13 -1
  85. package/dist/cli/tui/data/workflow-content.js.map +1 -1
  86. package/dist/cli/tui/tabs/workflow-tab.js +8 -1
  87. package/dist/cli/tui/tabs/workflow-tab.js.map +1 -1
  88. package/dist/domain/capability/descriptor.js +553 -0
  89. package/dist/domain/capability/descriptor.js.map +1 -0
  90. package/dist/domain/capability/effects.js +90 -0
  91. package/dist/domain/capability/effects.js.map +1 -0
  92. package/dist/domain/capability/protocol.js +494 -0
  93. package/dist/domain/capability/protocol.js.map +1 -0
  94. package/dist/domain/contract-reader.js +84 -0
  95. package/dist/domain/contract-reader.js.map +1 -0
  96. package/dist/domain/design/adapter.js +161 -0
  97. package/dist/domain/design/adapter.js.map +1 -0
  98. package/dist/domain/design/artifact.js +148 -4
  99. package/dist/domain/design/artifact.js.map +1 -1
  100. package/dist/domain/design/capability.js +263 -4
  101. package/dist/domain/design/capability.js.map +1 -1
  102. package/dist/domain/design/direct.js +108 -0
  103. package/dist/domain/design/direct.js.map +1 -0
  104. package/dist/domain/design/external-send.js +65 -0
  105. package/dist/domain/design/external-send.js.map +1 -0
  106. package/dist/domain/design/maturity.js +71 -0
  107. package/dist/domain/design/maturity.js.map +1 -1
  108. package/dist/domain/design/offline.js +92 -0
  109. package/dist/domain/design/offline.js.map +1 -0
  110. package/dist/domain/design/profiles.js +212 -0
  111. package/dist/domain/design/profiles.js.map +1 -0
  112. package/dist/domain/design/proposal.js +234 -0
  113. package/dist/domain/design/proposal.js.map +1 -0
  114. package/dist/domain/design/render-bundle.js +0 -0
  115. package/dist/domain/design/render-bundle.js.map +1 -0
  116. package/dist/domain/design/rendition.js +472 -0
  117. package/dist/domain/design/rendition.js.map +1 -0
  118. package/dist/domain/design/sources.js +180 -0
  119. package/dist/domain/design/sources.js.map +1 -0
  120. package/dist/domain/design/validation.js +12 -68
  121. package/dist/domain/design/validation.js.map +1 -1
  122. package/dist/domain/design/visual-evidence.js +155 -0
  123. package/dist/domain/design/visual-evidence.js.map +1 -0
  124. package/dist/domain/flow/answer.js +459 -0
  125. package/dist/domain/flow/answer.js.map +1 -0
  126. package/dist/domain/flow/authority.js +2338 -0
  127. package/dist/domain/flow/authority.js.map +1 -0
  128. package/dist/domain/flow/authorization.js +62 -0
  129. package/dist/domain/flow/authorization.js.map +1 -0
  130. package/dist/domain/flow/directive.js +421 -0
  131. package/dist/domain/flow/directive.js.map +1 -0
  132. package/dist/domain/flow/rules.js +140 -0
  133. package/dist/domain/flow/rules.js.map +1 -0
  134. package/dist/domain/flow/run-state.js +317 -0
  135. package/dist/domain/flow/run-state.js.map +1 -0
  136. package/dist/domain/harnesses.js +124 -4
  137. package/dist/domain/harnesses.js.map +1 -1
  138. package/dist/domain/host-verification.js +8 -8
  139. package/dist/domain/skills.js +13 -14
  140. package/dist/domain/skills.js.map +1 -1
  141. package/dist/domain/structured-choice-stamp.js +106 -0
  142. package/dist/domain/structured-choice-stamp.js.map +1 -0
  143. package/package.json +1 -1
  144. package/skills/w/SKILL.md +5 -5
  145. package/skills/w/context/MANIFEST.json +42 -1
  146. package/skills/w/harness/HARNESS.md +30 -4
  147. package/skills/w/loops/CHASSIS.md +11 -20
  148. package/skills/w/loops/CODE-POLICIES.md +9 -15
  149. package/skills/w/loops/plan-exec-loop/LOOP.md +11 -13
  150. package/skills/w/loops/plan-new-loop/LOOP.md +6 -4
  151. package/skills/w/loops/plan-refine-loop/LOOP.md +5 -3
  152. package/skills/w/loops/quick-loop/LOOP.md +18 -26
  153. package/skills/w/loops/spec-refine-loop/LOOP.md +14 -18
  154. package/skills/w/modules/COMPACTION.md +2 -6
  155. package/skills/w/modules/DB-SCRIPTS-ONLY.md +2 -0
  156. package/skills/w/modules/DESIGN-REFERENCES.md +15 -11
  157. package/skills/w/modules/IDEATION-GATE.md +3 -3
  158. package/skills/w/modules/PLAN-EXECUTION-BATCHES.md +17 -36
  159. package/skills/w/modules/PLAN-INPUT.md +5 -3
  160. package/skills/w/modules/PLAN-REFINE-SPLIT.md +3 -1
  161. package/skills/w/modules/PLAN-SPLIT-GATE.md +7 -5
  162. package/skills/w/modules/PROMPT-CONTINUITY.md +3 -1
  163. package/skills/w/modules/SPEC-CHANGE-SHAPE.md +4 -4
  164. package/skills/w/roles/README.md +2 -0
  165. package/skills/w/roles/design/CONTRACT.md +80 -0
  166. package/skills/w/roles/design/ROLE.md +7 -0
  167. package/skills/w/schemas/capability-descriptor.schema.json +260 -0
  168. package/skills/w/schemas/design/design-render-bundle.v1.schema.json +191 -0
  169. package/skills/w/schemas/design/design-rendition.v1.schema.json +232 -0
  170. package/skills/w/schemas/design/ui-screen.v1.schema.json +29 -1
@@ -0,0 +1,299 @@
1
+ /**
2
+ * The built-in floor of `design`.
3
+ *
4
+ * "Floor" is not a placeholder: it is the implementation a core gate can count
5
+ * on when nothing extra is installed, and it is the same code an improvement
6
+ * gets compared against. It is built entirely out of what already exists —
7
+ * the package index, the published validators, the adapter registry, the
8
+ * semantic handshake — because a floor that reimplemented the design domain
9
+ * would be a second design domain.
10
+ *
11
+ * The split between the CLI and the agent is the repo's usual one, and it is why
12
+ * the authoring operations answer `needs_input` first: the CLI owns identity,
13
+ * destinations, limits, validation and writing; the AGENT authors the content.
14
+ * `create` cannot invent a package body, so it says what a valid answer must
15
+ * contain and waits for one — that is a question, not a failure.
16
+ */
17
+ import { requireAdapter } from "../../domain/design/adapter.js";
18
+ import { DESIGN_DESCRIPTOR, DESIGN_OPERATIONS } from "../../domain/design/capability.js";
19
+ import { attainedMaturity, isIndexable, resolveOutputRoot, } from "../../domain/design/direct.js";
20
+ import { DESIGN_ADAPTERS } from "../../domain/design/profiles.js";
21
+ import { classifySource, reportSources } from "../../domain/design/sources.js";
22
+ import { readDesignIndex, resolveDesignPackage } from "../design/design-index-service.js";
23
+ import { checkRecordPrecondition } from "../design/design-record-service.js";
24
+ import { buildSemanticRequest, parseSemanticResponse } from "../semantic-operation/protocol.js";
25
+ import { registerCapability } from "./dispatcher.js";
26
+ /** Artefact ceilings for one authored revision. Generous, and still a ceiling. */
27
+ const LIMITS = { max_artifacts: 60, max_artifact_bytes: 256_000 };
28
+ export const designHandler = {
29
+ descriptor: DESIGN_DESCRIPTOR,
30
+ async run(ctx) {
31
+ if (ctx.operation.name === "validate")
32
+ return validatePackage(ctx);
33
+ return authoring(ctx);
34
+ },
35
+ };
36
+ registerCapability(designHandler);
37
+ /**
38
+ * Judge a package without writing anything.
39
+ *
40
+ * The one operation that survives `off`, so it deliberately depends on nothing
41
+ * but the workspace it was pointed at: it reads the index, resolves BY IDENTITY
42
+ * (never by path) and reports the validator's own verdict.
43
+ */
44
+ async function validatePackage(ctx) {
45
+ const id = inputValue(ctx, "package");
46
+ if (typeof id !== "string" || id.trim().length === 0) {
47
+ return { kind: "needs_input", gaps: ["la identidad del package a validar, p. ej. 'DES-001'"] };
48
+ }
49
+ if (ctx.workspace === null) {
50
+ return {
51
+ kind: "blocked",
52
+ failure: {
53
+ code: "DESIGN_WORKSPACE_ABSENT",
54
+ message: "no hay workspace donde buscar el package",
55
+ action: "corré la validación desde el workspace que contiene docs/designs/",
56
+ },
57
+ };
58
+ }
59
+ const index = await readDesignIndex(ctx.fs, ctx.workspace);
60
+ const found = resolveDesignPackage(index, id.trim());
61
+ if (found === null) {
62
+ return {
63
+ kind: "blocked",
64
+ failure: {
65
+ code: "DESIGN_PACKAGE_NOT_FOUND",
66
+ message: `no hay ningún package con identidad ${id}`,
67
+ action: `revisá 'aw designs' para ver las identidades publicadas bajo ${index.root}/`,
68
+ },
69
+ };
70
+ }
71
+ const validations = [
72
+ {
73
+ id: "design-manifest",
74
+ passed: found.ok,
75
+ detail: found.ok ? null : found.failures.map((f) => `${f.code}: ${f.message}`).join("; "),
76
+ },
77
+ ];
78
+ const report = reportSources([], `${id}`);
79
+ const maturity = attainedMaturity(requestedMaturity(ctx), found.ok ? "handoff" : "outline", report);
80
+ const fields = {
81
+ package: found.id,
82
+ baseline: found.current_baseline === null
83
+ ? null
84
+ : { revision: found.current_baseline.revision, digest: found.current_baseline.digest },
85
+ path: found.path,
86
+ root: "workspace",
87
+ indexable: true,
88
+ maturity: { requested: requestedMaturity(ctx), attained: maturity.attained },
89
+ sources: [],
90
+ renditions: [],
91
+ };
92
+ return {
93
+ kind: "completed",
94
+ validations,
95
+ output: {
96
+ value: { design: fields, ok: found.ok, failures: found.failures },
97
+ reference: found.id === null || found.current_baseline === null
98
+ ? null
99
+ : {
100
+ id: found.id,
101
+ revision: found.current_baseline.revision,
102
+ digest: found.current_baseline.digest,
103
+ locator: found.path,
104
+ },
105
+ // A verdict is either produced or not; there is no half of one, which is
106
+ // why `validate` declares only `complete` in its descriptor.
107
+ completeness: "complete",
108
+ },
109
+ };
110
+ }
111
+ /**
112
+ * The authoring operations, through the handshake the repo already uses.
113
+ *
114
+ * `prepare` publishes the contract a valid answer has to satisfy and stops;
115
+ * `validate` parses the answer against that same contract — destinations,
116
+ * limits, staleness — and hands back the artifacts for the durable step. Every
117
+ * rejection there comes from `parseSemanticResponse`, so the authoring path
118
+ * inherits the write boundary rather than restating it.
119
+ */
120
+ async function authoring(ctx) {
121
+ // Where the output lands is decided BEFORE anything else: outside a workspace
122
+ // an explicit root is required, and without one nothing is written anywhere.
123
+ const root = resolveOutputRoot(ctx.workspace, ctx.request.context.target, ctx.operation.name);
124
+ if (!root.ok) {
125
+ return {
126
+ kind: "blocked",
127
+ failure: {
128
+ code: root.failure.code,
129
+ message: root.failure.message,
130
+ action: root.failure.action,
131
+ },
132
+ };
133
+ }
134
+ const precondition = await operationPrecondition(ctx);
135
+ if (precondition !== null)
136
+ return { kind: "blocked", failure: precondition };
137
+ const sources = declaredSources(ctx);
138
+ const report = reportSources(sources, ctx.operation.name);
139
+ if (report.failures.length > 0) {
140
+ const first = report.failures[0];
141
+ return {
142
+ kind: "blocked",
143
+ failure: {
144
+ code: first?.code ?? "DESIGN_SOURCE_INVALID",
145
+ message: first?.message ?? "una fuente declarada no es reportable",
146
+ action: first?.action ?? "declará la causa de cada fuente que no se usó",
147
+ },
148
+ };
149
+ }
150
+ const request = buildSemanticRequest({
151
+ operation: `${ctx.request.capability}.${ctx.request.operation}`,
152
+ inputs: ctx.request.inputs.map((i) => ({ name: i.name, value: i.value })),
153
+ contract: contractFor(ctx.operation.name),
154
+ inventory: { root: root.value.root, mode: root.value.kind },
155
+ allowedDestinations: [root.value.root],
156
+ limits: LIMITS,
157
+ readSet: [],
158
+ readSetBytes: 0,
159
+ });
160
+ if (ctx.verb !== "validate") {
161
+ return {
162
+ kind: "needs_input",
163
+ gaps: [request.contract, `destinos permitidos: ${request.allowed_destinations.join(", ")}`],
164
+ };
165
+ }
166
+ if (ctx.answer === null || ctx.answer.trim().length === 0) {
167
+ return {
168
+ kind: "needs_input",
169
+ gaps: ["la respuesta autorada, como un único objeto JSON por stdin"],
170
+ };
171
+ }
172
+ // The answer is DATA to validate. Its own `input_digest` has to match the one
173
+ // this request was built from, which is what stops an answer written against
174
+ // a world that has since moved.
175
+ const parsed = parseSemanticResponse(ctx.answer, request);
176
+ if (!parsed.ok)
177
+ return { kind: "blocked", failure: parsed.failure };
178
+ const artifacts = (parsed.value.artifacts ?? []).map((a) => ({
179
+ path: a.path,
180
+ content: a.content,
181
+ }));
182
+ // The gate verdict the `012` computes is not available until the package is
183
+ // on disk, so a proposal can never claim more than `outline` here — which is
184
+ // exactly the rule that stops a partial from being promoted.
185
+ const maturity = attainedMaturity(requestedMaturity(ctx), "outline", report);
186
+ const fields = {
187
+ package: typeof inputValue(ctx, "package") === "string" ? String(inputValue(ctx, "package")) : null,
188
+ baseline: null,
189
+ path: root.value.root,
190
+ root: root.value.kind,
191
+ indexable: isIndexable(root.value),
192
+ maturity: { requested: requestedMaturity(ctx), attained: maturity.attained },
193
+ sources: report.sources,
194
+ renditions: [],
195
+ };
196
+ return {
197
+ kind: "durable",
198
+ artifacts,
199
+ output: {
200
+ value: { design: fields, artifacts: artifacts.map((a) => a.path), gaps: maturity.gaps },
201
+ reference: null,
202
+ // The durable step has not run yet, so nothing is published. Claiming
203
+ // `complete` here would let a gate accept a proposal as a package.
204
+ completeness: "partial",
205
+ },
206
+ base: null,
207
+ };
208
+ }
209
+ /**
210
+ * What each operation has to be true BEFORE it can even ask for content.
211
+ *
212
+ * Kept apart from the authoring path so the two read as what they are: this is
213
+ * about the world (does the profile exist, is the evidence still current), the
214
+ * other is about the answer.
215
+ */
216
+ async function operationPrecondition(ctx) {
217
+ // `record` seals a statement ABOUT a revision, so its evidence has to still
218
+ // be the evidence. This is the check the end of B2 deferred in writing.
219
+ if (ctx.operation.name === "record" && ctx.workspace !== null) {
220
+ const id = inputValue(ctx, "package");
221
+ if (typeof id === "string" && id.trim().length > 0) {
222
+ const outcome = await checkRecordPrecondition(ctx.fs, ctx.workspace, id.trim());
223
+ const first = outcome.failures[0];
224
+ if (!outcome.ok && first !== undefined) {
225
+ return { code: first.code, message: first.message, action: first.action };
226
+ }
227
+ }
228
+ }
229
+ // `render` resolves its profile BY ID, which is what the adapter registry is
230
+ // for: asking for one that does not exist has to list the ones that do.
231
+ if (ctx.operation.name === "render") {
232
+ const profile = inputValue(ctx, "profile");
233
+ const adapter = requireAdapter(String(profile ?? ""), DESIGN_ADAPTERS, ctx.operation.name);
234
+ if (!adapter.ok) {
235
+ const { code, message, action } = adapter.failure;
236
+ return { code, message, action };
237
+ }
238
+ }
239
+ return null;
240
+ }
241
+ /**
242
+ * The sources the invocation declared, classified.
243
+ *
244
+ * A locator the catalog does not recognize becomes `unsupported` WITH its
245
+ * reason rather than an error: one unreadable attachment must not sink an
246
+ * operation that had four good sources — it has to show up in the receipt and
247
+ * cost the run its `handoff`, which is a very different thing.
248
+ */
249
+ function declaredSources(ctx) {
250
+ const raw = ctx.request.inputs.find((i) => i.name === "sources")?.value;
251
+ const locators = Array.isArray(raw) ? raw.map(String) : typeof raw === "string" ? [raw] : [];
252
+ return locators.map((locator) => {
253
+ const kind = classifySource(locator);
254
+ if (kind === null) {
255
+ return {
256
+ name: "sources",
257
+ kind: "host_context",
258
+ locator,
259
+ disposition: "unsupported",
260
+ reason: `'${locator}' no corresponde a ningún tipo de fuente del catálogo v1`,
261
+ derived: [],
262
+ sensitivity: "public",
263
+ essential: true,
264
+ };
265
+ }
266
+ return {
267
+ name: "sources",
268
+ kind,
269
+ locator,
270
+ disposition: "used",
271
+ reason: null,
272
+ derived: [],
273
+ sensitivity: "public",
274
+ essential: true,
275
+ };
276
+ });
277
+ }
278
+ function requestedMaturity(ctx) {
279
+ const value = inputValue(ctx, "maturity");
280
+ return value === "handoff" || value === "outline" ? value : null;
281
+ }
282
+ function contractFor(operation) {
283
+ const shared = "Respondé un único objeto JSON con 'version', 'operation', 'input_digest', 'state': 'proposed' " +
284
+ "y 'artifacts': [{path, content}]. Cada 'path' es relativo al workspace y cae dentro de los " +
285
+ "destinos permitidos. Ningún artefacto inventa un formato: los del UI Design Package v1 son los únicos aceptados.";
286
+ const perOperation = {
287
+ create: "Autorá la PRIMERA revisión del package a partir de las fuentes declaradas.",
288
+ update: "Autorá la revisión SIGUIENTE sobre la base declarada. No reescribas revisiones ya selladas.",
289
+ render: "Regenerá las proyecciones de la revisión indicada. Una proyección no es normativa y nunca se sella.",
290
+ record: "Sellá la decisión de gobierno sobre la revisión indicada, sin tocar el contenido del package.",
291
+ };
292
+ return `${perOperation[operation] ?? ""} ${shared}`.trim();
293
+ }
294
+ function inputValue(ctx, name) {
295
+ return ctx.request.inputs.find((i) => i.name === name)?.value;
296
+ }
297
+ /** The five operations this floor answers — the descriptor's, not a second list. */
298
+ export const DESIGN_FLOOR_OPERATIONS = DESIGN_OPERATIONS;
299
+ //# sourceMappingURL=design-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-handler.js","sour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AE;YACX,WAAW,EAAE,QAAiB;YAC9B,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAmB;IAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC1C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AAED,SAAS,WAAW,CAAC,SAAiB;IACpC,MAAM,MAAM,GACV,gGAAgG;QAChG,6FAA6F;QAC7F,kHAAkH,CAAC;IACrH,MAAM,YAAY,GAA2B;QAC3C,MAAM,EAAE,4EAA4E;QACpF,MAAM,EACJ,6FAA6F;QAC/F,MAAM,EACJ,qGAAqG;QACvG,MAAM,EACJ,+FAA+F;KAClG,CAAC;IACF,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,UAAU,CAAC,GAAmB,EAAE,IAAY;IACnD,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC;AAChE,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,312 @@
1
+ /**
2
+ * The one road into a capability — for the direct wrapper and for a flow alike.
3
+ *
4
+ * Everything a caller can influence goes through here: the envelope is built by
5
+ * the shared builder, the capability is resolved against real instances, the
6
+ * effects are authorized before anything runs, and the attempt comes back as
7
+ * outcome + output + receipt. Neither route can take a shortcut around it
8
+ * without the difference showing up in a digest, which is what makes
9
+ * "the two routes share a contract" a checkable property.
10
+ *
11
+ * The four verbs are STAGES of the adapter, not a second operation table. The
12
+ * operation (`create`, `validate`, …) travels in the envelope; `prepare`,
13
+ * `continue`, `validate` and `apply` say where in the durable handshake the
14
+ * attempt is. A capability with a sixth operation adds it to its descriptor; it
15
+ * never adds a verb here.
16
+ *
17
+ * Handlers register themselves by capability NAME in a registry. That is the
18
+ * mechanism behind "no branches by name": adding a capability means adding a
19
+ * descriptor and a handler, and nothing in SPEC, PLAN or QUICK changes.
20
+ */
21
+ import { findOperation, } from "../../domain/capability/descriptor.js";
22
+ import { authorizeEffects } from "../../domain/capability/effects.js";
23
+ import { buildCapabilityRequest, buildReceipt, checkWorkspaceRequirement, continueInvocation, newInvocationId, receiptPersistence, } from "../../domain/capability/protocol.js";
24
+ import { RETIRED_SKILL_IDENTITIES, classifyCapabilityBinding } from "../../domain/skills.js";
25
+ import { resolveSkills } from "../skills-resolver-service.js";
26
+ import { applyDurableEffect, prepareDurableEffect, reconcileAfterFailure, } from "./durable-effect.js";
27
+ import { buildCapabilityInventory } from "./installed-inventory.js";
28
+ import { checkPin, pinSelection, resolveCapability, } from "./resolution.js";
29
+ const HANDLERS = new Map();
30
+ export function registerCapability(handler) {
31
+ HANDLERS.set(handler.descriptor.name, handler);
32
+ }
33
+ export function capabilityHandler(name) {
34
+ return HANDLERS.get(name) ?? null;
35
+ }
36
+ export function registeredCapabilities() {
37
+ return [...HANDLERS.keys()].sort();
38
+ }
39
+ export async function dispatchCapability(input, ctx) {
40
+ const retired = RETIRED_SKILL_IDENTITIES.get(input.capability.toLowerCase());
41
+ if (retired !== undefined) {
42
+ // Not an alias, and not a silent fallback to the live name either: honoring
43
+ // it here would make the retired name an accepted one.
44
+ return {
45
+ ok: false,
46
+ failure: {
47
+ code: "CAPABILITY_NAME_RETIRED",
48
+ message: `'${input.capability}' está retirado — ${retired}`,
49
+ action: "invocá la capacidad por su nombre vigente: 'design'",
50
+ },
51
+ };
52
+ }
53
+ const handler = capabilityHandler(input.capability);
54
+ if (handler === null) {
55
+ return {
56
+ ok: false,
57
+ failure: {
58
+ code: "CAPABILITY_UNKNOWN",
59
+ message: `no hay ninguna capacidad registrada con el nombre '${input.capability}'`,
60
+ action: `usá una de: ${registeredCapabilities().join(", ") || "(ninguna)"}`,
61
+ },
62
+ };
63
+ }
64
+ if (input.verb === "apply")
65
+ return applyStage(input, ctx, handler);
66
+ return attemptStage(input, ctx, handler);
67
+ }
68
+ async function attemptStage(input, ctx, handler) {
69
+ const { descriptor } = handler;
70
+ const resolved = await resolveFor(input, ctx, descriptor);
71
+ const operationName = input.operation ?? input.parent?.operation ?? descriptor.default_operation;
72
+ if (operationName === null || operationName === undefined) {
73
+ return {
74
+ ok: false,
75
+ failure: {
76
+ code: "CAPABILITY_OPERATION_MISSING",
77
+ message: `'${descriptor.name}' no declara operación por defecto`,
78
+ action: `nombrá la operación: ${descriptor.operations.map((o) => o.name).join(", ")}`,
79
+ },
80
+ };
81
+ }
82
+ const built = buildFor(input, ctx, descriptor, operationName);
83
+ if (!built.ok)
84
+ return { ok: false, failure: built.failure };
85
+ const { request, operation } = built;
86
+ // A continuation runs against the selection the FIRST attempt fixed. If those
87
+ // bytes moved, the conversation is answering something that no longer exists.
88
+ if (input.pin != null) {
89
+ const stillThere = checkPin(input.pin, await buildCapabilityInventory(ctx.fs, ctx.env));
90
+ if (!stillThere.ok) {
91
+ return receiptOf(request, descriptor, resolved, {
92
+ kind: "blocked",
93
+ failure: {
94
+ code: "CAPABILITY_SELECTION_CHANGED",
95
+ message: stillThere.degradation.loss,
96
+ action: stillThere.action,
97
+ },
98
+ });
99
+ }
100
+ }
101
+ const blocked = blockedByResolution(resolved, operation);
102
+ if (blocked !== null) {
103
+ return receiptOf(request, descriptor, resolved, {
104
+ kind: "blocked",
105
+ failure: blocked,
106
+ });
107
+ }
108
+ const workspace = checkWorkspaceRequirement(operation, request.context);
109
+ if (!workspace.ok) {
110
+ return receiptOf(request, descriptor, resolved, {
111
+ kind: "blocked",
112
+ failure: workspace.failure,
113
+ });
114
+ }
115
+ const authorization = authorizeEffects(operation.effects, {
116
+ sensitiveSources: input.sensitiveSources === true,
117
+ scopeExpanded: false,
118
+ }, ctx.effectPolicy);
119
+ const result = await handler.run({
120
+ ...ctx,
121
+ verb: input.verb,
122
+ request,
123
+ operation,
124
+ answer: input.answer ?? null,
125
+ });
126
+ if (result.kind !== "durable")
127
+ return receiptOf(request, descriptor, resolved, result);
128
+ const prepared = prepareDurableEffect({
129
+ request,
130
+ authorization,
131
+ artifacts: result.artifacts,
132
+ base: result.base ?? null,
133
+ });
134
+ if (!prepared.ok) {
135
+ return receiptOf(request, descriptor, resolved, {
136
+ kind: "blocked",
137
+ failure: prepared.failure,
138
+ });
139
+ }
140
+ // A durable candidate is not an applied one. The attempt stops here with the
141
+ // preview and the seal, and `apply` is a separate, authorized step.
142
+ return receiptOf(request, descriptor, resolved, {
143
+ kind: "needs_input",
144
+ gaps: [
145
+ `aprobación visible para: ${prepared.plan.requires_approval.join(", ") || "publicar los artefactos propuestos"}`,
146
+ ],
147
+ }, { plan: prepared.plan, output: result.output, authorization });
148
+ }
149
+ async function applyStage(input, ctx, handler) {
150
+ const { descriptor } = handler;
151
+ if (input.plan == null || input.approval == null || input.request == null) {
152
+ return {
153
+ ok: false,
154
+ failure: {
155
+ code: "CAPABILITY_APPLY_INCOMPLETE",
156
+ message: "apply necesita el plan, su request y la aprobación",
157
+ action: "pasá el plan que devolvió validate junto con el digest aprobado",
158
+ },
159
+ };
160
+ }
161
+ if (ctx.workspace === null) {
162
+ return {
163
+ ok: false,
164
+ failure: {
165
+ code: "CAPABILITY_WORKSPACE_REQUIRED",
166
+ message: "aplicar un efecto durable necesita un workspace",
167
+ action: "corré apply dentro del workspace donde se preparó la propuesta",
168
+ },
169
+ };
170
+ }
171
+ const resolved = await resolveFor(input, ctx, descriptor);
172
+ const operation = findOperation(descriptor, input.request.operation);
173
+ const authorization = authorizeEffects(operation.effects, { sensitiveSources: input.sensitiveSources === true, scopeExpanded: false }, ctx.effectPolicy);
174
+ const applied = await applyDurableEffect(ctx.fs, ctx.paths, {
175
+ root: ctx.workspace,
176
+ plan: input.plan,
177
+ approval: input.approval,
178
+ selfAuthorized: authorization.selfAuthorized,
179
+ });
180
+ if (!applied.ok) {
181
+ // Whatever landed is enumerated with the failure, and the next action is a
182
+ // reconciliation — never a shrug that reads as "nothing happened".
183
+ const reconciliation = reconcileAfterFailure("failed", applied.applied.map((cls) => ({ class: cls, what: `efecto '${cls}' ya aplicado` })));
184
+ return receiptOf(input.request, descriptor, resolved, { kind: "blocked", failure: { ...applied.failure, action: reconciliation.next_action } }, { applied: reconciliation.applied, authorization });
185
+ }
186
+ return receiptOf(input.request, descriptor, resolved, {
187
+ kind: "completed",
188
+ output: {
189
+ value: { written: applied.result.written },
190
+ reference: null,
191
+ completeness: "complete",
192
+ },
193
+ }, { applied: applied.result.applied, authorization });
194
+ }
195
+ async function resolveFor(input, ctx, descriptor) {
196
+ const skills = await resolveSkills(ctx.fs, ctx.paths);
197
+ const slot = skills.skills[descriptor.name];
198
+ const binding = slot === undefined
199
+ ? { state: "floor_and_improvements", reason: null, action: null }
200
+ : classifyCapabilityBinding(slot, descriptor.name);
201
+ const inventory = await buildCapabilityInventory(ctx.fs, ctx.env);
202
+ return resolveCapability({
203
+ descriptor,
204
+ binding,
205
+ inventory,
206
+ hostSelection: input.hostSelection ?? null,
207
+ operation: input.operation ?? input.parent?.operation ?? null,
208
+ });
209
+ }
210
+ function blockedByResolution(resolved, operation) {
211
+ const availability = resolved.operations.find((o) => o.operation === operation.name);
212
+ if (availability === undefined || availability.available)
213
+ return null;
214
+ return {
215
+ code: resolved.state === "disabled" ? "CAPABILITY_OPERATION_OFF" : "CAPABILITY_UNAVAILABLE",
216
+ message: availability.reason ?? `'${operation.name}' no está disponible`,
217
+ action: resolved.action ?? "revisá 'aw skills --detail' para ver el estado de la capacidad",
218
+ };
219
+ }
220
+ function buildFor(input, ctx, descriptor, operationName) {
221
+ const caller = { route: input.route, host: ctx.host, flow: input.flow ?? null };
222
+ const context = {
223
+ workspace: ctx.workspace,
224
+ target: input.target ?? null,
225
+ base: input.base ?? null,
226
+ profile: input.profile ?? null,
227
+ };
228
+ const policy = {
229
+ sensitive_sources: input.sensitiveSources === true,
230
+ external_transmission: input.externalTransmission === true,
231
+ };
232
+ const built = input.verb === "continue" && input.parent != null
233
+ ? continueInvocation({
234
+ parent: input.parent,
235
+ descriptor,
236
+ inputs: input.inputs ?? [],
237
+ caller,
238
+ context,
239
+ policy,
240
+ authorizations: [],
241
+ })
242
+ : buildCapabilityRequest({
243
+ invocationId: input.parent?.invocation_id ?? newInvocationId(),
244
+ attempt: 1,
245
+ descriptor,
246
+ operation: operationName,
247
+ caller,
248
+ context,
249
+ inputs: input.inputs ?? [],
250
+ policy,
251
+ authorizations: [],
252
+ parentRequestDigest: null,
253
+ });
254
+ if (!built.ok)
255
+ return { ok: false, failure: built.failure };
256
+ return { ok: true, request: built.request, operation: built.operation };
257
+ }
258
+ function receiptOf(request, descriptor, resolution, result, extras = {}) {
259
+ const dispositions = request.inputs.map((i) => ({
260
+ name: i.name,
261
+ used: true,
262
+ reason: null,
263
+ provenance: i.provenance,
264
+ }));
265
+ const output = result.kind === "completed" ? result.output : (extras.output ?? null);
266
+ const built = buildReceipt({
267
+ request,
268
+ descriptor,
269
+ outcome: result.kind === "durable" ? "completed" : result.kind,
270
+ floor: resolution.floor,
271
+ selection: resolution.selection,
272
+ inputs: dispositions,
273
+ output,
274
+ validations: result.kind === "completed" ? (result.validations ?? []) : [],
275
+ effects: {
276
+ planned: [...(extras.authorization?.planned ?? [])],
277
+ approved: [...(extras.authorization?.needsPreflight ?? [])].filter((c) => (extras.applied ?? []).includes(c)),
278
+ applied: [...(extras.applied ?? [])],
279
+ },
280
+ degradations: resolution.degradations,
281
+ gaps: result.kind === "needs_input" ? result.gaps : [],
282
+ error: result.kind === "blocked" ? result.failure : null,
283
+ nextAction: nextAction(result, resolution),
284
+ });
285
+ if (!built.ok)
286
+ return { ok: false, failure: built.failure };
287
+ return {
288
+ ok: true,
289
+ attempt: {
290
+ request,
291
+ receipt: built.receipt,
292
+ output,
293
+ resolution,
294
+ pin: pinSelection(resolution, descriptor),
295
+ persistence: receiptPersistence(built.receipt),
296
+ plan: extras.plan ?? null,
297
+ },
298
+ };
299
+ }
300
+ function nextAction(result, resolution) {
301
+ if (result.kind === "needs_input") {
302
+ return "contestá con 'aw capability continue' o, si hay una propuesta, aprobala y corré 'apply'";
303
+ }
304
+ if (result.kind === "blocked")
305
+ return result.failure.action;
306
+ if (result.kind === "durable")
307
+ return "revisá la propuesta y aprobala para aplicarla";
308
+ return resolution.degradations.length > 0
309
+ ? "el resultado salió del floor: revisá la degradación del receipt"
310
+ : "nada pendiente: el intento se completó";
311
+ }
312
+ //# sourceMappingURL=dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../src/application/capability/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,aAAa,GACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EASL,sBAAsB,EACtB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAK7F,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAIL,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAIL,QAAQ,EACR,YAAY,EACZ,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAuCzB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;AAEtD,MAAM,UAA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