agentplane 0.3.8 → 0.3.10

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 (268) hide show
  1. package/assets/AGENTS.md +4 -2
  2. package/assets/agents/CODER.json +1 -1
  3. package/assets/policy/dod.core.md +1 -1
  4. package/assets/policy/governance.md +3 -0
  5. package/assets/policy/incidents.md +22 -11
  6. package/assets/policy/workflow.branch_pr.md +2 -0
  7. package/assets/policy/workflow.direct.md +3 -1
  8. package/dist/.build-manifest.json +323 -128
  9. package/dist/cli/bootstrap-guide.d.ts +1 -0
  10. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  11. package/dist/cli/bootstrap-guide.js +19 -1
  12. package/dist/cli/command-invocations.d.ts.map +1 -1
  13. package/dist/cli/command-invocations.js +2 -0
  14. package/dist/cli/command-snippets.d.ts +2 -0
  15. package/dist/cli/command-snippets.d.ts.map +1 -1
  16. package/dist/cli/command-snippets.js +2 -0
  17. package/dist/cli/run-cli/command-catalog/core.d.ts +1 -1
  18. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  19. package/dist/cli/run-cli/command-catalog/core.js +10 -0
  20. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  21. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  22. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  23. package/dist/cli/run-cli/commands/config.js +13 -0
  24. package/dist/cli/run-cli.js +2 -2
  25. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  26. package/dist/cli/run-cli.test-helpers.js +34 -8
  27. package/dist/commands/backend.d.ts.map +1 -1
  28. package/dist/commands/backend.js +4 -0
  29. package/dist/commands/hooks/index.d.ts.map +1 -1
  30. package/dist/commands/hooks/index.js +8 -4
  31. package/dist/commands/incidents/advise.command.d.ts +15 -0
  32. package/dist/commands/incidents/advise.command.d.ts.map +1 -0
  33. package/dist/commands/incidents/advise.command.js +139 -0
  34. package/dist/commands/incidents/collect.command.d.ts +11 -0
  35. package/dist/commands/incidents/collect.command.d.ts.map +1 -0
  36. package/dist/commands/incidents/collect.command.js +67 -0
  37. package/dist/commands/incidents/incidents.command.d.ts +5 -0
  38. package/dist/commands/incidents/incidents.command.d.ts.map +1 -0
  39. package/dist/commands/incidents/incidents.command.js +21 -0
  40. package/dist/commands/incidents/shared.d.ts +42 -0
  41. package/dist/commands/incidents/shared.d.ts.map +1 -0
  42. package/dist/commands/incidents/shared.js +107 -0
  43. package/dist/commands/pr/check.d.ts.map +1 -1
  44. package/dist/commands/pr/check.js +73 -2
  45. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  46. package/dist/commands/pr/integrate/cmd.js +4 -0
  47. package/dist/commands/pr/integrate/internal/merge.d.ts +4 -0
  48. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  49. package/dist/commands/pr/integrate/internal/merge.js +23 -2
  50. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  51. package/dist/commands/pr/integrate/internal/prepare.js +26 -1
  52. package/dist/commands/pr/internal/note-store.d.ts +18 -0
  53. package/dist/commands/pr/internal/note-store.d.ts.map +1 -0
  54. package/dist/commands/pr/internal/note-store.js +66 -0
  55. package/dist/commands/pr/internal/pr-paths.d.ts +3 -0
  56. package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -1
  57. package/dist/commands/pr/internal/pr-paths.js +3 -0
  58. package/dist/commands/pr/internal/review-template.d.ts +24 -4
  59. package/dist/commands/pr/internal/review-template.d.ts.map +1 -1
  60. package/dist/commands/pr/internal/review-template.js +188 -33
  61. package/dist/commands/pr/internal/sync.d.ts +32 -0
  62. package/dist/commands/pr/internal/sync.d.ts.map +1 -0
  63. package/dist/commands/pr/internal/sync.js +258 -0
  64. package/dist/commands/pr/note.d.ts.map +1 -1
  65. package/dist/commands/pr/note.js +37 -4
  66. package/dist/commands/pr/open.d.ts.map +1 -1
  67. package/dist/commands/pr/open.js +7 -54
  68. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  69. package/dist/commands/pr/pr.command.js +6 -3
  70. package/dist/commands/pr/update.d.ts.map +1 -1
  71. package/dist/commands/pr/update.js +5 -79
  72. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  73. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  74. package/dist/commands/recipes/impl/apply.js +1 -1
  75. package/dist/commands/recipes/impl/commands/cache-prune.d.ts.map +1 -1
  76. package/dist/commands/recipes/impl/commands/cache-prune.js +14 -0
  77. package/dist/commands/recipes/impl/commands/explain.js +1 -1
  78. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  79. package/dist/commands/recipes/impl/commands/install.js +3 -2
  80. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  81. package/dist/commands/recipes/impl/commands/list-remote.js +1 -0
  82. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  83. package/dist/commands/recipes/impl/commands/remove.js +9 -1
  84. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  85. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  86. package/dist/commands/recipes/impl/installed-recipes.js +2 -1
  87. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +1 -1
  88. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  89. package/dist/commands/recipes/impl/project-installed-recipes.js +2 -1
  90. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  91. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  92. package/dist/commands/recipes/impl/resolver.js +1 -1
  93. package/dist/commands/recipes.d.ts +4 -4
  94. package/dist/commands/recipes.d.ts.map +1 -1
  95. package/dist/commands/recipes.js +3 -3
  96. package/dist/commands/release/apply.command.d.ts.map +1 -1
  97. package/dist/commands/release/apply.command.js +9 -0
  98. package/dist/commands/release.test-helpers.d.ts +14 -0
  99. package/dist/commands/release.test-helpers.d.ts.map +1 -1
  100. package/dist/commands/release.test-helpers.js +14 -3
  101. package/dist/commands/shared/approval-requirements.d.ts +5 -7
  102. package/dist/commands/shared/approval-requirements.d.ts.map +1 -1
  103. package/dist/commands/shared/approval-requirements.js +3 -73
  104. package/dist/commands/shared/network-approval.d.ts +2 -0
  105. package/dist/commands/shared/network-approval.d.ts.map +1 -1
  106. package/dist/commands/shared/network-approval.js +1 -1
  107. package/dist/commands/shared/pr-meta.d.ts +9 -0
  108. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  109. package/dist/commands/shared/pr-meta.js +27 -3
  110. package/dist/commands/shared/task-backend.d.ts +2 -0
  111. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  112. package/dist/commands/shared/task-local-freshness.d.ts +13 -0
  113. package/dist/commands/shared/task-local-freshness.d.ts.map +1 -0
  114. package/dist/commands/shared/task-local-freshness.js +20 -0
  115. package/dist/commands/shared/task-mutation.d.ts +2 -0
  116. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  117. package/dist/commands/shared/task-mutation.js +7 -0
  118. package/dist/commands/task/block.d.ts.map +1 -1
  119. package/dist/commands/task/block.js +1 -0
  120. package/dist/commands/task/close-shared.d.ts.map +1 -1
  121. package/dist/commands/task/close-shared.js +1 -0
  122. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  123. package/dist/commands/task/finish-shared.js +5 -2
  124. package/dist/commands/task/finish.d.ts.map +1 -1
  125. package/dist/commands/task/finish.js +24 -0
  126. package/dist/commands/task/new.d.ts.map +1 -1
  127. package/dist/commands/task/new.js +69 -29
  128. package/dist/commands/task/set-status.d.ts.map +1 -1
  129. package/dist/commands/task/set-status.js +1 -0
  130. package/dist/commands/task/shared/transition-command.d.ts +2 -0
  131. package/dist/commands/task/shared/transition-command.d.ts.map +1 -1
  132. package/dist/commands/task/shared/transition-command.js +1 -0
  133. package/dist/commands/task/start-ready.d.ts.map +1 -1
  134. package/dist/commands/task/start-ready.js +12 -1
  135. package/dist/commands/task/start.d.ts.map +1 -1
  136. package/dist/commands/task/start.js +11 -0
  137. package/dist/commands/task/verify-record.d.ts.map +1 -1
  138. package/dist/commands/task/verify-record.js +27 -0
  139. package/dist/commands/upgrade.d.ts.map +1 -1
  140. package/dist/commands/upgrade.js +6 -1
  141. package/dist/policy/engine.d.ts +3 -1
  142. package/dist/policy/engine.d.ts.map +1 -1
  143. package/dist/policy/engine.js +5 -6
  144. package/dist/policy/taxonomy.d.ts +17 -0
  145. package/dist/policy/taxonomy.d.ts.map +1 -0
  146. package/dist/policy/taxonomy.js +302 -0
  147. package/dist/policy/types.d.ts +2 -1
  148. package/dist/policy/types.d.ts.map +1 -1
  149. package/dist/runner/artifacts.d.ts.map +1 -1
  150. package/dist/runner/artifacts.js +2 -0
  151. package/dist/runner/context/base-prompts.d.ts +25 -0
  152. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  153. package/dist/runner/context/base-prompts.js +182 -54
  154. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  155. package/dist/runner/context/recipe-context.js +5 -0
  156. package/dist/runner/types.d.ts +12 -0
  157. package/dist/runner/types.d.ts.map +1 -1
  158. package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -1
  159. package/dist/runner/usecases/scenario-materialize-task.js +81 -11
  160. package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -1
  161. package/dist/runner/usecases/task-run-inspect.js +9 -7
  162. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -1
  163. package/dist/runner/usecases/task-run-lifecycle-shared.js +8 -6
  164. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  165. package/dist/runner/usecases/task-run.js +59 -12
  166. package/dist/runtime/approvals/index.d.ts +3 -0
  167. package/dist/runtime/approvals/index.d.ts.map +1 -0
  168. package/dist/runtime/approvals/index.js +1 -0
  169. package/dist/runtime/approvals/runtime.d.ts +12 -0
  170. package/dist/runtime/approvals/runtime.d.ts.map +1 -0
  171. package/dist/runtime/approvals/runtime.js +154 -0
  172. package/dist/runtime/approvals/types.d.ts +31 -0
  173. package/dist/runtime/approvals/types.d.ts.map +1 -0
  174. package/dist/runtime/approvals/types.js +1 -0
  175. package/dist/runtime/behavior/index.d.ts +3 -0
  176. package/dist/runtime/behavior/index.d.ts.map +1 -0
  177. package/dist/runtime/behavior/index.js +1 -0
  178. package/dist/runtime/behavior/resolve.d.ts +7 -0
  179. package/dist/runtime/behavior/resolve.d.ts.map +1 -0
  180. package/dist/runtime/behavior/resolve.js +66 -0
  181. package/dist/runtime/behavior/types.d.ts +25 -0
  182. package/dist/runtime/behavior/types.d.ts.map +1 -0
  183. package/dist/runtime/behavior/types.js +1 -0
  184. package/dist/runtime/capabilities/backend.d.ts +7 -0
  185. package/dist/runtime/capabilities/backend.d.ts.map +1 -0
  186. package/dist/runtime/capabilities/backend.js +104 -0
  187. package/dist/runtime/capabilities/index.d.ts +6 -0
  188. package/dist/runtime/capabilities/index.d.ts.map +1 -0
  189. package/dist/runtime/capabilities/index.js +4 -0
  190. package/dist/runtime/capabilities/recipe.d.ts +10 -0
  191. package/dist/runtime/capabilities/recipe.d.ts.map +1 -0
  192. package/dist/runtime/capabilities/recipe.js +123 -0
  193. package/dist/runtime/capabilities/registry.d.ts +6 -0
  194. package/dist/runtime/capabilities/registry.d.ts.map +1 -0
  195. package/dist/runtime/capabilities/registry.js +69 -0
  196. package/dist/runtime/capabilities/runner.d.ts +8 -0
  197. package/dist/runtime/capabilities/runner.d.ts.map +1 -0
  198. package/dist/runtime/capabilities/runner.js +73 -0
  199. package/dist/runtime/capabilities/types.d.ts +28 -0
  200. package/dist/runtime/capabilities/types.d.ts.map +1 -0
  201. package/dist/runtime/capabilities/types.js +1 -0
  202. package/dist/runtime/execution-profile/index.d.ts +3 -0
  203. package/dist/runtime/execution-profile/index.d.ts.map +1 -0
  204. package/dist/runtime/execution-profile/index.js +1 -0
  205. package/dist/runtime/execution-profile/resolve.d.ts +9 -0
  206. package/dist/runtime/execution-profile/resolve.d.ts.map +1 -0
  207. package/dist/runtime/execution-profile/resolve.js +80 -0
  208. package/dist/runtime/execution-profile/types.d.ts +27 -0
  209. package/dist/runtime/execution-profile/types.d.ts.map +1 -0
  210. package/dist/runtime/execution-profile/types.js +1 -0
  211. package/dist/runtime/explain/index.d.ts +3 -0
  212. package/dist/runtime/explain/index.d.ts.map +1 -0
  213. package/dist/runtime/explain/index.js +1 -0
  214. package/dist/runtime/explain/resolve.d.ts +14 -0
  215. package/dist/runtime/explain/resolve.d.ts.map +1 -0
  216. package/dist/runtime/explain/resolve.js +50 -0
  217. package/dist/runtime/explain/types.d.ts +28 -0
  218. package/dist/runtime/explain/types.d.ts.map +1 -0
  219. package/dist/runtime/explain/types.js +1 -0
  220. package/dist/runtime/harness/index.d.ts +4 -0
  221. package/dist/runtime/harness/index.d.ts.map +1 -0
  222. package/dist/runtime/harness/index.js +2 -0
  223. package/dist/runtime/harness/resolve-from-command-context.d.ts +4 -0
  224. package/dist/runtime/harness/resolve-from-command-context.d.ts.map +1 -0
  225. package/dist/runtime/harness/resolve-from-command-context.js +11 -0
  226. package/dist/runtime/harness/resolve.d.ts +13 -0
  227. package/dist/runtime/harness/resolve.d.ts.map +1 -0
  228. package/dist/runtime/harness/resolve.js +146 -0
  229. package/dist/runtime/harness/types.d.ts +65 -0
  230. package/dist/runtime/harness/types.d.ts.map +1 -0
  231. package/dist/runtime/harness/types.js +1 -0
  232. package/dist/runtime/incidents/index.d.ts +3 -0
  233. package/dist/runtime/incidents/index.d.ts.map +1 -0
  234. package/dist/runtime/incidents/index.js +1 -0
  235. package/dist/runtime/incidents/resolve.d.ts +26 -0
  236. package/dist/runtime/incidents/resolve.d.ts.map +1 -0
  237. package/dist/runtime/incidents/resolve.js +437 -0
  238. package/dist/runtime/incidents/types.d.ts +72 -0
  239. package/dist/runtime/incidents/types.d.ts.map +1 -0
  240. package/dist/runtime/incidents/types.js +1 -0
  241. package/dist/runtime/protocol/index.d.ts +3 -0
  242. package/dist/runtime/protocol/index.d.ts.map +1 -0
  243. package/dist/runtime/protocol/index.js +2 -0
  244. package/dist/runtime/protocol/resolve.d.ts +16 -0
  245. package/dist/runtime/protocol/resolve.d.ts.map +1 -0
  246. package/dist/runtime/protocol/resolve.js +36 -0
  247. package/dist/runtime/protocol/types.d.ts +36 -0
  248. package/dist/runtime/protocol/types.d.ts.map +1 -0
  249. package/dist/runtime/protocol/types.js +1 -0
  250. package/dist/runtime/task-intake/index.d.ts +3 -0
  251. package/dist/runtime/task-intake/index.d.ts.map +1 -0
  252. package/dist/runtime/task-intake/index.js +1 -0
  253. package/dist/runtime/task-intake/resolve.d.ts +48 -0
  254. package/dist/runtime/task-intake/resolve.d.ts.map +1 -0
  255. package/dist/runtime/task-intake/resolve.js +316 -0
  256. package/dist/runtime/task-intake/types.d.ts +117 -0
  257. package/dist/runtime/task-intake/types.d.ts.map +1 -0
  258. package/dist/runtime/task-intake/types.js +1 -0
  259. package/dist/shared/protected-paths.d.ts +4 -0
  260. package/dist/shared/protected-paths.d.ts.map +1 -1
  261. package/dist/shared/protected-paths.js +4 -4
  262. package/dist/usecases/context/resolve-context.d.ts +55 -6
  263. package/dist/usecases/context/resolve-context.d.ts.map +1 -1
  264. package/dist/usecases/context/resolve-context.js +96 -6
  265. package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
  266. package/dist/usecases/task/task-list-usecase.js +8 -2
  267. package/dist/usecases/task/task-new-usecase.js +4 -4
  268. package/package.json +2 -3
@@ -0,0 +1,437 @@
1
+ const INCIDENTS_HEADER = [
2
+ "# Policy Incidents Log",
3
+ "",
4
+ "This is the single file for incident-derived and situational policy rules.",
5
+ ].join("\n");
6
+ function normalizeLines(text) {
7
+ return text.replaceAll("\r\n", "\n").split("\n");
8
+ }
9
+ function normalizeKey(key) {
10
+ return key
11
+ .trim()
12
+ .toLowerCase()
13
+ .replaceAll(/[\s_-]+/g, "");
14
+ }
15
+ function normalizeSearchText(text) {
16
+ return text
17
+ .toLowerCase()
18
+ .replaceAll(/[^a-z0-9]+/gi, " ")
19
+ .trim();
20
+ }
21
+ function tokenize(text) {
22
+ const normalized = normalizeSearchText(text);
23
+ if (!normalized)
24
+ return [];
25
+ return normalized
26
+ .split(/\s+/)
27
+ .map((token) => token.trim())
28
+ .filter((token) => token.length >= 3);
29
+ }
30
+ function dedupeCaseInsensitive(values) {
31
+ const seen = new Set();
32
+ const out = [];
33
+ for (const value of values) {
34
+ const trimmed = String(value ?? "").trim();
35
+ if (!trimmed)
36
+ continue;
37
+ const key = trimmed.toLowerCase();
38
+ if (seen.has(key))
39
+ continue;
40
+ seen.add(key);
41
+ out.push(trimmed);
42
+ }
43
+ return out;
44
+ }
45
+ function parseCsvList(value) {
46
+ if (!value)
47
+ return [];
48
+ return dedupeCaseInsensitive(value
49
+ .split(",")
50
+ .map((item) => item.trim())
51
+ .filter(Boolean));
52
+ }
53
+ function parseBoolean(value) {
54
+ const normalized = String(value ?? "")
55
+ .trim()
56
+ .toLowerCase();
57
+ return normalized === "true" || normalized === "yes" || normalized === "y" || normalized === "1";
58
+ }
59
+ function parseEntryState(value) {
60
+ return value === "open" || value === "promoted" ? value : "stabilized";
61
+ }
62
+ function appendFieldValue(record, key, value, joiner = " ") {
63
+ if (!record[key]) {
64
+ record[key] = value.trim();
65
+ return;
66
+ }
67
+ record[key] = `${record[key]}${joiner}${value.trim()}`.trim();
68
+ }
69
+ function buildIncidentFingerprint(entry) {
70
+ return [
71
+ entry.sourceTask ?? "",
72
+ normalizeSearchText(entry.scope),
73
+ normalizeSearchText(entry.failure),
74
+ normalizeSearchText(entry.rule),
75
+ ].join("|");
76
+ }
77
+ function buildMatchTerms(opts) {
78
+ const scopeTokens = tokenize(opts.scope);
79
+ return dedupeCaseInsensitive([...opts.explicitMatch, ...opts.tags, ...scopeTokens]).slice(0, 12);
80
+ }
81
+ export function createIncidentRegistrySkeleton() {
82
+ return [
83
+ INCIDENTS_HEADER,
84
+ "",
85
+ "## Entry contract",
86
+ "",
87
+ "- Add entries append-only.",
88
+ "- Every entry MUST include: `id`, `date`, `scope`, `failure`, `rule`, `evidence`, `enforcement`, `state`.",
89
+ "- New machine-matched entries SHOULD also include: `tags`, `match`, `advice`, `source_task`, `fixability`.",
90
+ "- `rule` MUST be concrete and testable (`MUST` / `MUST NOT`).",
91
+ "- `fixability: external` means the issue cannot be removed by changing only repository code and should instead stay as reusable operational advice.",
92
+ "- `state` values: `open`, `stabilized`, `promoted`.",
93
+ "",
94
+ "## Entry template",
95
+ "",
96
+ "- id: `INC-YYYYMMDD-NN`",
97
+ "- date: `YYYY-MM-DD`",
98
+ "- scope: `<affected scope>`",
99
+ "- tags: `<comma-separated matching tags>`",
100
+ "- match: `<comma-separated lookup keywords>`",
101
+ "- failure: `<observed failure mode>`",
102
+ "- advice: `<reusable recovery or prevention guidance>`",
103
+ "- rule: `<new or refined MUST/MUST NOT>`",
104
+ "- evidence: `<task ids / logs / links>`",
105
+ "- enforcement: `<CI|test|lint|script|manual>`",
106
+ "- source_task: `<task id>`",
107
+ "- fixability: `<external>`",
108
+ "- state: `<open|stabilized|promoted>`",
109
+ "",
110
+ "## Entries",
111
+ "",
112
+ ].join("\n");
113
+ }
114
+ export function parseIncidentRegistry(text) {
115
+ const lines = normalizeLines(text);
116
+ const entries = [];
117
+ let inEntries = false;
118
+ let currentFields = null;
119
+ let currentLine = 0;
120
+ let currentKey = null;
121
+ const flush = () => {
122
+ if (!currentFields)
123
+ return;
124
+ const id = currentFields.id?.trim();
125
+ if (!id) {
126
+ currentFields = null;
127
+ currentKey = null;
128
+ currentLine = 0;
129
+ return;
130
+ }
131
+ const scope = currentFields.scope?.trim() ?? "";
132
+ const failure = currentFields.failure?.trim() ?? "";
133
+ const rule = currentFields.rule?.trim() ?? "";
134
+ const evidence = currentFields.evidence?.trim() ?? "";
135
+ const enforcement = currentFields.enforcement?.trim() ?? "manual";
136
+ entries.push({
137
+ id,
138
+ date: currentFields.date?.trim() ?? "",
139
+ scope,
140
+ failure,
141
+ rule,
142
+ evidence,
143
+ enforcement,
144
+ state: parseEntryState(currentFields.state),
145
+ tags: parseCsvList(currentFields.tags),
146
+ match: parseCsvList(currentFields.match),
147
+ advice: currentFields.advice?.trim() || null,
148
+ sourceTask: currentFields.source_task?.trim() || null,
149
+ fixability: currentFields.fixability?.trim().toLowerCase() === "external" ? "external" : null,
150
+ rawFields: { ...currentFields },
151
+ line: currentLine,
152
+ });
153
+ currentFields = null;
154
+ currentKey = null;
155
+ currentLine = 0;
156
+ };
157
+ for (const [index, line] of lines.entries()) {
158
+ const trimmed = line.trim();
159
+ if (!inEntries) {
160
+ if (trimmed === "## Entries")
161
+ inEntries = true;
162
+ continue;
163
+ }
164
+ if (/^##\s+/.test(trimmed))
165
+ break;
166
+ const idMatch = /^- id:\s*(.+?)\s*$/.exec(trimmed);
167
+ if (idMatch) {
168
+ flush();
169
+ currentFields = { id: idMatch[1] ?? "" };
170
+ currentKey = "id";
171
+ currentLine = index + 1;
172
+ continue;
173
+ }
174
+ if (!currentFields)
175
+ continue;
176
+ const fieldMatch = /^\s{2}([a-z_]+):\s*(.*?)\s*$/.exec(line);
177
+ if (fieldMatch) {
178
+ currentKey = String(fieldMatch[1] ?? "").trim();
179
+ currentFields[currentKey] = fieldMatch[2] ?? "";
180
+ continue;
181
+ }
182
+ if (currentKey && /^\s{4,}\S/.test(line)) {
183
+ appendFieldValue(currentFields, currentKey, line.trim(), "\n");
184
+ continue;
185
+ }
186
+ if (!trimmed) {
187
+ flush();
188
+ }
189
+ }
190
+ flush();
191
+ return { entries };
192
+ }
193
+ export function formatIncidentRegistryEntry(entry) {
194
+ return [
195
+ `- id: ${entry.id}`,
196
+ ` date: ${entry.date}`,
197
+ ` scope: ${entry.scope}`,
198
+ ...(entry.tags.length > 0 ? [` tags: ${entry.tags.join(", ")}`] : []),
199
+ ...(entry.match.length > 0 ? [` match: ${entry.match.join(", ")}`] : []),
200
+ ` failure: ${entry.failure}`,
201
+ ...(entry.advice ? [` advice: ${entry.advice}`] : []),
202
+ ` rule: ${entry.rule}`,
203
+ ` evidence: ${entry.evidence}`,
204
+ ` enforcement: ${entry.enforcement}`,
205
+ ...(entry.sourceTask ? [` source_task: ${entry.sourceTask}`] : []),
206
+ ...(entry.fixability ? [` fixability: ${entry.fixability}`] : []),
207
+ ` state: ${entry.state}`,
208
+ ].join("\n");
209
+ }
210
+ export function appendIncidentRegistryEntries(currentText, entries) {
211
+ if (entries.length === 0)
212
+ return currentText;
213
+ const base = currentText.trim().length > 0
214
+ ? currentText.trimEnd()
215
+ : createIncidentRegistrySkeleton().trimEnd();
216
+ const suffix = entries.map((entry) => formatIncidentRegistryEntry(entry)).join("\n\n");
217
+ return `${base}\n\n${suffix}\n`;
218
+ }
219
+ export function extractIncidentCandidatesFromFindings(findings) {
220
+ const lines = normalizeLines(findings);
221
+ const candidates = [];
222
+ let currentFields = null;
223
+ let currentLine = 0;
224
+ let currentKey = null;
225
+ const flush = () => {
226
+ if (!currentFields)
227
+ return;
228
+ const promotion = currentFields.promotion?.trim() ?? "";
229
+ if (promotion.toLowerCase() !== "incident-candidate") {
230
+ currentFields = null;
231
+ currentKey = null;
232
+ currentLine = 0;
233
+ return;
234
+ }
235
+ const observation = currentFields.observation?.trim() ?? "";
236
+ if (!observation) {
237
+ currentFields = null;
238
+ currentKey = null;
239
+ currentLine = 0;
240
+ return;
241
+ }
242
+ candidates.push({
243
+ observation,
244
+ impact: currentFields.impact?.trim() || null,
245
+ resolution: currentFields.resolution?.trim() || null,
246
+ promotion,
247
+ incidentScope: currentFields.incidentscope?.trim() || null,
248
+ incidentRule: currentFields.incidentrule?.trim() || null,
249
+ incidentAdvice: currentFields.incidentadvice?.trim() || null,
250
+ incidentTags: parseCsvList(currentFields.incidenttags),
251
+ incidentMatch: parseCsvList(currentFields.incidentmatch),
252
+ incidentExternal: parseBoolean(currentFields.incidentexternal),
253
+ line: currentLine,
254
+ rawFields: { ...currentFields },
255
+ });
256
+ currentFields = null;
257
+ currentKey = null;
258
+ currentLine = 0;
259
+ };
260
+ for (const [index, line] of lines.entries()) {
261
+ const observationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
262
+ if (observationMatch) {
263
+ flush();
264
+ currentFields = { observation: observationMatch[1] ?? "" };
265
+ currentKey = "observation";
266
+ currentLine = index + 1;
267
+ continue;
268
+ }
269
+ if (!currentFields)
270
+ continue;
271
+ if (/^\s*-\s+/.test(line)) {
272
+ flush();
273
+ const nestedObservationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
274
+ if (nestedObservationMatch) {
275
+ currentFields = { observation: nestedObservationMatch[1] ?? "" };
276
+ currentKey = "observation";
277
+ currentLine = index + 1;
278
+ }
279
+ continue;
280
+ }
281
+ const fieldMatch = /^\s{2,}([A-Za-z][A-Za-z0-9 _-]*):\s*(.*?)\s*$/.exec(line);
282
+ if (fieldMatch) {
283
+ currentKey = normalizeKey(fieldMatch[1] ?? "");
284
+ currentFields[currentKey] = fieldMatch[2] ?? "";
285
+ continue;
286
+ }
287
+ if (currentKey && /^\s{2,}\S/.test(line)) {
288
+ appendFieldValue(currentFields, currentKey, line.trim(), "\n");
289
+ continue;
290
+ }
291
+ if (!line.trim()) {
292
+ continue;
293
+ }
294
+ if (currentKey) {
295
+ appendFieldValue(currentFields, currentKey, line.trim());
296
+ }
297
+ }
298
+ flush();
299
+ return candidates;
300
+ }
301
+ function nextIncidentId(entries, now) {
302
+ const dateStamp = `${now.getUTCFullYear()}${String(now.getUTCMonth() + 1).padStart(2, "0")}${String(now.getUTCDate()).padStart(2, "0")}`;
303
+ const prefix = `INC-${dateStamp}-`;
304
+ let max = 0;
305
+ for (const entry of entries) {
306
+ if (!entry.id.startsWith(prefix))
307
+ continue;
308
+ const num = Number.parseInt(entry.id.slice(prefix.length), 10);
309
+ if (Number.isInteger(num) && num > max)
310
+ max = num;
311
+ }
312
+ return `${prefix}${String(max + 1).padStart(2, "0")}`;
313
+ }
314
+ function buildPromotionIssues(candidate) {
315
+ const missingFields = [];
316
+ if (!candidate.incidentExternal)
317
+ missingFields.push("IncidentExternal: true");
318
+ if (!candidate.incidentScope)
319
+ missingFields.push("IncidentScope");
320
+ if (!candidate.incidentRule)
321
+ missingFields.push("IncidentRule");
322
+ if (!candidate.incidentAdvice)
323
+ missingFields.push("IncidentAdvice");
324
+ return missingFields.length > 0 ? { candidate, missingFields } : null;
325
+ }
326
+ function buildIncidentRegistryEntry(opts) {
327
+ const date = opts.now.toISOString().slice(0, 10);
328
+ const tags = dedupeCaseInsensitive([
329
+ ...opts.candidate.incidentTags,
330
+ ...opts.task.tags.map((tag) => tag.trim()),
331
+ ]);
332
+ const match = buildMatchTerms({
333
+ scope: opts.candidate.incidentScope ?? opts.task.title,
334
+ tags,
335
+ explicitMatch: opts.candidate.incidentMatch,
336
+ });
337
+ return {
338
+ id: nextIncidentId(opts.existingEntries, opts.now),
339
+ date,
340
+ scope: opts.candidate.incidentScope ?? opts.task.title,
341
+ failure: opts.candidate.observation,
342
+ rule: opts.candidate.incidentRule ?? "",
343
+ evidence: `task ${opts.task.id}${opts.task.commitHash ? `; commit ${opts.task.commitHash.slice(0, 12)}` : ""}`,
344
+ enforcement: "manual",
345
+ state: "stabilized",
346
+ tags,
347
+ match,
348
+ advice: opts.candidate.incidentAdvice,
349
+ sourceTask: opts.task.id,
350
+ fixability: "external",
351
+ rawFields: {},
352
+ line: 0,
353
+ };
354
+ }
355
+ export function planIncidentCollection(opts) {
356
+ const candidates = extractIncidentCandidatesFromFindings(opts.findings);
357
+ const issues = [];
358
+ const promotable = [];
359
+ const duplicates = [];
360
+ const now = opts.now ?? new Date();
361
+ const seenFingerprints = new Set(opts.registry.entries.map((entry) => buildIncidentFingerprint(entry)));
362
+ for (const candidate of candidates) {
363
+ const issue = buildPromotionIssues(candidate);
364
+ if (issue) {
365
+ issues.push(issue);
366
+ continue;
367
+ }
368
+ const entry = buildIncidentRegistryEntry({
369
+ task: opts.task,
370
+ candidate,
371
+ now,
372
+ existingEntries: [...opts.registry.entries, ...promotable.map((item) => item.entry)],
373
+ });
374
+ const fingerprint = buildIncidentFingerprint(entry);
375
+ const draft = { candidate, entry, fingerprint };
376
+ if (seenFingerprints.has(fingerprint)) {
377
+ duplicates.push(draft);
378
+ continue;
379
+ }
380
+ seenFingerprints.add(fingerprint);
381
+ promotable.push(draft);
382
+ }
383
+ return { candidates, promotable, duplicates, issues };
384
+ }
385
+ export function buildIncidentAdviceQueryFromTask(opts) {
386
+ return {
387
+ taskId: opts.taskId,
388
+ title: opts.title,
389
+ description: opts.description,
390
+ scope: opts.scope ?? null,
391
+ tags: dedupeCaseInsensitive(opts.tags),
392
+ };
393
+ }
394
+ export function resolveIncidentAdviceMatches(opts) {
395
+ const limit = Math.max(1, opts.limit ?? 5);
396
+ const tagSet = new Set(opts.query.tags.map((tag) => tag.trim().toLowerCase()).filter(Boolean));
397
+ const haystack = [opts.query.title, opts.query.description, opts.query.scope ?? ""].join(" ");
398
+ const normalizedHaystack = normalizeSearchText(haystack);
399
+ const queryTokens = new Set([...tokenize(haystack), ...tagSet]);
400
+ const matches = [];
401
+ for (const entry of opts.registry.entries) {
402
+ if (entry.state === "open")
403
+ continue;
404
+ const matchedTags = entry.tags.filter((tag) => tagSet.has(tag.trim().toLowerCase()));
405
+ const matchedTerms = entry.match.filter((term) => queryTokens.has(term.trim().toLowerCase()) ||
406
+ normalizedHaystack.includes(normalizeSearchText(term)));
407
+ const normalizedScope = normalizeSearchText(entry.scope);
408
+ const scopeMatched = normalizedScope.length > 0 && normalizedHaystack.includes(normalizedScope);
409
+ const score = matchedTags.length * 5 + matchedTerms.length * 2 + (scopeMatched ? 3 : 0);
410
+ if (score <= 0)
411
+ continue;
412
+ matches.push({ entry, score, matchedTags, matchedTerms, scopeMatched });
413
+ }
414
+ matches.sort((left, right) => {
415
+ if (right.score !== left.score)
416
+ return right.score - left.score;
417
+ return right.entry.date.localeCompare(left.entry.date);
418
+ });
419
+ return matches.slice(0, limit);
420
+ }
421
+ export function renderIncidentAdvice(matches) {
422
+ if (matches.length === 0)
423
+ return "No matching incident advice.";
424
+ return matches
425
+ .map((match) => {
426
+ const lines = [
427
+ `- ${match.entry.id} | scope: ${match.entry.scope}`,
428
+ ` failure: ${match.entry.failure}`,
429
+ ` advice: ${match.entry.advice ?? match.entry.rule}`,
430
+ ` rule: ${match.entry.rule}`,
431
+ ];
432
+ if (match.entry.evidence)
433
+ lines.push(` evidence: ${match.entry.evidence}`);
434
+ return lines.join("\n");
435
+ })
436
+ .join("\n");
437
+ }
@@ -0,0 +1,72 @@
1
+ export type IncidentRegistryEntryState = "open" | "stabilized" | "promoted";
2
+ export type IncidentRegistryEntry = {
3
+ id: string;
4
+ date: string;
5
+ scope: string;
6
+ failure: string;
7
+ rule: string;
8
+ evidence: string;
9
+ enforcement: string;
10
+ state: IncidentRegistryEntryState;
11
+ tags: string[];
12
+ match: string[];
13
+ advice: string | null;
14
+ sourceTask: string | null;
15
+ fixability: "external" | null;
16
+ rawFields: Record<string, string>;
17
+ line: number;
18
+ };
19
+ export type IncidentRegistry = {
20
+ entries: IncidentRegistryEntry[];
21
+ };
22
+ export type IncidentFindingCandidate = {
23
+ observation: string;
24
+ impact: string | null;
25
+ resolution: string | null;
26
+ promotion: string;
27
+ incidentScope: string | null;
28
+ incidentRule: string | null;
29
+ incidentAdvice: string | null;
30
+ incidentTags: string[];
31
+ incidentMatch: string[];
32
+ incidentExternal: boolean;
33
+ line: number;
34
+ rawFields: Record<string, string>;
35
+ };
36
+ export type IncidentPromotionTaskContext = {
37
+ id: string;
38
+ title: string;
39
+ description: string;
40
+ tags: string[];
41
+ commitHash?: string | null;
42
+ };
43
+ export type IncidentPromotionDraft = {
44
+ candidate: IncidentFindingCandidate;
45
+ entry: IncidentRegistryEntry;
46
+ fingerprint: string;
47
+ };
48
+ export type IncidentPromotionIssue = {
49
+ candidate: IncidentFindingCandidate;
50
+ missingFields: string[];
51
+ };
52
+ export type IncidentCollectionPlan = {
53
+ candidates: IncidentFindingCandidate[];
54
+ promotable: IncidentPromotionDraft[];
55
+ duplicates: IncidentPromotionDraft[];
56
+ issues: IncidentPromotionIssue[];
57
+ };
58
+ export type IncidentAdviceQuery = {
59
+ taskId?: string;
60
+ title: string;
61
+ description: string;
62
+ scope?: string | null;
63
+ tags: string[];
64
+ };
65
+ export type IncidentAdviceMatch = {
66
+ entry: IncidentRegistryEntry;
67
+ score: number;
68
+ matchedTags: string[];
69
+ matchedTerms: string[];
70
+ scopeMatched: boolean;
71
+ };
72
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,0BAA0B,CAAC;IAClC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,wBAAwB,CAAC;IACpC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,wBAAwB,CAAC;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,UAAU,EAAE,sBAAsB,EAAE,CAAC;IACrC,UAAU,EAAE,sBAAsB,EAAE,CAAC;IACrC,MAAM,EAAE,sBAAsB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { AGENTPLANE_PROTOCOL_COMPATIBILITY, buildFrameworkExplainProtocolResult, buildFrameworkProtocolSurface, buildProtocolErrorResult, buildProtocolSuccessResult, } from "./resolve.js";
2
+ export { AGENTPLANE_PROTOCOL_SCHEMA_VERSION, type AgentplaneProtocolBase, type AgentplaneProtocolCompatibility, type AgentplaneProtocolError, type AgentplaneProtocolErrorResult, type AgentplaneProtocolKind, type AgentplaneProtocolResult, type AgentplaneProtocolSchemaVersion, type AgentplaneProtocolStatus, type AgentplaneProtocolSuccessResult, type FrameworkExplainProtocolResult, type FrameworkProtocolSurface, } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/protocol/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,mCAAmC,EACnC,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kCAAkC,EAClC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { AGENTPLANE_PROTOCOL_COMPATIBILITY, buildFrameworkExplainProtocolResult, buildFrameworkProtocolSurface, buildProtocolErrorResult, buildProtocolSuccessResult, } from "./resolve.js";
2
+ export { AGENTPLANE_PROTOCOL_SCHEMA_VERSION, } from "./types.js";
@@ -0,0 +1,16 @@
1
+ import type { FrameworkExplainPayload } from "../explain/index.js";
2
+ import { type AgentplaneProtocolCompatibility, type AgentplaneProtocolError, type AgentplaneProtocolErrorResult, type AgentplaneProtocolKind, type AgentplaneProtocolSuccessResult, type FrameworkExplainProtocolResult, type FrameworkProtocolSurface } from "./types.js";
3
+ export declare const AGENTPLANE_PROTOCOL_COMPATIBILITY: AgentplaneProtocolCompatibility;
4
+ export declare function buildProtocolSuccessResult<TKind extends AgentplaneProtocolKind, TData>(opts: {
5
+ kind: TKind;
6
+ data: TData;
7
+ }): AgentplaneProtocolSuccessResult<TKind, TData>;
8
+ export declare function buildProtocolErrorResult<TKind extends AgentplaneProtocolKind>(opts: {
9
+ kind: TKind;
10
+ error: AgentplaneProtocolError;
11
+ }): AgentplaneProtocolErrorResult<TKind>;
12
+ export declare function buildFrameworkExplainProtocolResult(explain: FrameworkExplainPayload): FrameworkExplainProtocolResult;
13
+ export declare function buildFrameworkProtocolSurface(opts: {
14
+ explain: FrameworkExplainPayload;
15
+ }): FrameworkProtocolSurface;
16
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/runtime/protocol/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iCAAiC,EAAE,+BAK/C,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,KAAK,SAAS,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE;IAC5F,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;CACb,GAAG,+BAA+B,CAAC,KAAK,EAAE,KAAK,CAAC,CAQhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,sBAAsB,EAAE,IAAI,EAAE;IACnF,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,uBAAuB,CAAC;CAChC,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAQvC;AAED,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,uBAAuB,GAC/B,8BAA8B,CAKhC;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,OAAO,EAAE,uBAAuB,CAAC;CAClC,GAAG,wBAAwB,CAI3B"}
@@ -0,0 +1,36 @@
1
+ import { AGENTPLANE_PROTOCOL_SCHEMA_VERSION, } from "./types.js";
2
+ export const AGENTPLANE_PROTOCOL_COMPATIBILITY = {
3
+ strategy: "additive",
4
+ breaking_changes_require_schema_version: true,
5
+ additive_fields_allowed: true,
6
+ new_result_kinds_allowed: true,
7
+ };
8
+ export function buildProtocolSuccessResult(opts) {
9
+ return {
10
+ schema_version: AGENTPLANE_PROTOCOL_SCHEMA_VERSION,
11
+ kind: opts.kind,
12
+ status: "ok",
13
+ compatibility: structuredClone(AGENTPLANE_PROTOCOL_COMPATIBILITY),
14
+ data: structuredClone(opts.data),
15
+ };
16
+ }
17
+ export function buildProtocolErrorResult(opts) {
18
+ return {
19
+ schema_version: AGENTPLANE_PROTOCOL_SCHEMA_VERSION,
20
+ kind: opts.kind,
21
+ status: "error",
22
+ compatibility: structuredClone(AGENTPLANE_PROTOCOL_COMPATIBILITY),
23
+ error: structuredClone(opts.error),
24
+ };
25
+ }
26
+ export function buildFrameworkExplainProtocolResult(explain) {
27
+ return buildProtocolSuccessResult({
28
+ kind: "framework.explain",
29
+ data: explain,
30
+ });
31
+ }
32
+ export function buildFrameworkProtocolSurface(opts) {
33
+ return {
34
+ explain: buildFrameworkExplainProtocolResult(opts.explain),
35
+ };
36
+ }
@@ -0,0 +1,36 @@
1
+ import type { FrameworkExplainPayload } from "../explain/index.js";
2
+ export declare const AGENTPLANE_PROTOCOL_SCHEMA_VERSION: 1;
3
+ export type AgentplaneProtocolSchemaVersion = typeof AGENTPLANE_PROTOCOL_SCHEMA_VERSION;
4
+ export type AgentplaneProtocolStatus = "ok" | "error";
5
+ export type AgentplaneProtocolKind = string;
6
+ export type AgentplaneProtocolCompatibility = {
7
+ strategy: "additive";
8
+ breaking_changes_require_schema_version: true;
9
+ additive_fields_allowed: true;
10
+ new_result_kinds_allowed: true;
11
+ };
12
+ export type AgentplaneProtocolBase<TKind extends AgentplaneProtocolKind> = {
13
+ schema_version: AgentplaneProtocolSchemaVersion;
14
+ kind: TKind;
15
+ compatibility: AgentplaneProtocolCompatibility;
16
+ };
17
+ export type AgentplaneProtocolSuccessResult<TKind extends AgentplaneProtocolKind, TData> = AgentplaneProtocolBase<TKind> & {
18
+ status: "ok";
19
+ data: TData;
20
+ };
21
+ export type AgentplaneProtocolError = {
22
+ code: string;
23
+ message: string;
24
+ retryable?: boolean;
25
+ details?: Record<string, unknown>;
26
+ };
27
+ export type AgentplaneProtocolErrorResult<TKind extends AgentplaneProtocolKind> = AgentplaneProtocolBase<TKind> & {
28
+ status: "error";
29
+ error: AgentplaneProtocolError;
30
+ };
31
+ export type AgentplaneProtocolResult<TKind extends AgentplaneProtocolKind, TData> = AgentplaneProtocolSuccessResult<TKind, TData> | AgentplaneProtocolErrorResult<TKind>;
32
+ export type FrameworkExplainProtocolResult = AgentplaneProtocolSuccessResult<"framework.explain", FrameworkExplainPayload>;
33
+ export type FrameworkProtocolSurface = {
34
+ explain: FrameworkExplainProtocolResult;
35
+ };
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/protocol/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,eAAO,MAAM,kCAAkC,EAAG,CAAU,CAAC;AAE7D,MAAM,MAAM,+BAA+B,GAAG,OAAO,kCAAkC,CAAC;AAExF,MAAM,MAAM,wBAAwB,GAAG,IAAI,GAAG,OAAO,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE5C,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,EAAE,UAAU,CAAC;IACrB,uCAAuC,EAAE,IAAI,CAAC;IAC9C,uBAAuB,EAAE,IAAI,CAAC;IAC9B,wBAAwB,EAAE,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,KAAK,SAAS,sBAAsB,IAAI;IACzE,cAAc,EAAE,+BAA+B,CAAC;IAChD,IAAI,EAAE,KAAK,CAAC;IACZ,aAAa,EAAE,+BAA+B,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,+BAA+B,CACzC,KAAK,SAAS,sBAAsB,EACpC,KAAK,IACH,sBAAsB,CAAC,KAAK,CAAC,GAAG;IAClC,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,6BAA6B,CAAC,KAAK,SAAS,sBAAsB,IAC5E,sBAAsB,CAAC,KAAK,CAAC,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAEJ,MAAM,MAAM,wBAAwB,CAAC,KAAK,SAAS,sBAAsB,EAAE,KAAK,IAC5E,+BAA+B,CAAC,KAAK,EAAE,KAAK,CAAC,GAC7C,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAEzC,MAAM,MAAM,8BAA8B,GAAG,+BAA+B,CAC1E,mBAAmB,EACnB,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,8BAA8B,CAAC;CACzC,CAAC"}
@@ -0,0 +1 @@
1
+ export const AGENTPLANE_PROTOCOL_SCHEMA_VERSION = 1;
@@ -0,0 +1,3 @@
1
+ export { createClarificationContract, createTaskGraphDraft, createTaskIntakeContext, createTaskIntakeRuntime, materializeTaskGraphDraft, } from "./resolve.js";
2
+ export type { ClarificationContract, ClarificationQuestion, TaskGraphDependency, TaskGraphDraft, TaskGraphDraftTask, TaskIntakeContext, TaskIntakeInput, TaskIntakeInputKind, TaskIntakePrecedence, TaskIntakeRuntime, TaskIntakeSourceId, TaskIntakeSourceRef, TaskMaterializationEntry, TaskMaterializationPlan, } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/task-intake/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { createClarificationContract, createTaskGraphDraft, createTaskIntakeContext, createTaskIntakeRuntime, materializeTaskGraphDraft, } from "./resolve.js";