@cleocode/contracts 2026.5.121 → 2026.5.123

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 (128) hide show
  1. package/dist/__tests__/completion-operation-contracts.test.d.ts +8 -0
  2. package/dist/__tests__/completion-operation-contracts.test.d.ts.map +1 -0
  3. package/dist/__tests__/completion-operation-contracts.test.js +114 -0
  4. package/dist/__tests__/completion-operation-contracts.test.js.map +1 -0
  5. package/dist/__tests__/operation-envelope-validation.test.d.ts +8 -0
  6. package/dist/__tests__/operation-envelope-validation.test.d.ts.map +1 -0
  7. package/dist/__tests__/operation-envelope-validation.test.js +105 -0
  8. package/dist/__tests__/operation-envelope-validation.test.js.map +1 -0
  9. package/dist/__tests__/satisfies-atom.test.d.ts +24 -0
  10. package/dist/__tests__/satisfies-atom.test.d.ts.map +1 -0
  11. package/dist/__tests__/satisfies-atom.test.js +320 -0
  12. package/dist/__tests__/satisfies-atom.test.js.map +1 -0
  13. package/dist/__tests__/validator-types.test.d.ts +13 -0
  14. package/dist/__tests__/validator-types.test.d.ts.map +1 -0
  15. package/dist/__tests__/validator-types.test.js +293 -0
  16. package/dist/__tests__/validator-types.test.js.map +1 -0
  17. package/dist/__tests__/workgraph-context-scaffold-contracts.test.d.ts +8 -0
  18. package/dist/__tests__/workgraph-context-scaffold-contracts.test.d.ts.map +1 -0
  19. package/dist/__tests__/workgraph-context-scaffold-contracts.test.js +188 -0
  20. package/dist/__tests__/workgraph-context-scaffold-contracts.test.js.map +1 -0
  21. package/dist/__tests__/workgraph-operation-contracts.test.d.ts +8 -0
  22. package/dist/__tests__/workgraph-operation-contracts.test.d.ts.map +1 -0
  23. package/dist/__tests__/workgraph-operation-contracts.test.js +115 -0
  24. package/dist/__tests__/workgraph-operation-contracts.test.js.map +1 -0
  25. package/dist/config.d.ts +56 -0
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/data-accessor.d.ts +194 -0
  28. package/dist/data-accessor.d.ts.map +1 -1
  29. package/dist/data-accessor.js.map +1 -1
  30. package/dist/dispatch/__tests__/docs-update-registry.test.d.ts +2 -0
  31. package/dist/dispatch/__tests__/docs-update-registry.test.d.ts.map +1 -0
  32. package/dist/dispatch/__tests__/docs-update-registry.test.js +27 -0
  33. package/dist/dispatch/__tests__/docs-update-registry.test.js.map +1 -0
  34. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.d.ts +2 -0
  35. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.d.ts.map +1 -0
  36. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.js +265 -0
  37. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.js.map +1 -0
  38. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  39. package/dist/dispatch/operations-registry.js +487 -7
  40. package/dist/dispatch/operations-registry.js.map +1 -1
  41. package/dist/evidence-atom-schema.d.ts +91 -0
  42. package/dist/evidence-atom-schema.d.ts.map +1 -1
  43. package/dist/evidence-atom-schema.js +162 -1
  44. package/dist/evidence-atom-schema.js.map +1 -1
  45. package/dist/exit-codes.d.ts +41 -1
  46. package/dist/exit-codes.d.ts.map +1 -1
  47. package/dist/exit-codes.js +40 -0
  48. package/dist/exit-codes.js.map +1 -1
  49. package/dist/index.d.ts +17 -9
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +12 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/operation-envelope-validation.d.ts +79 -0
  54. package/dist/operation-envelope-validation.d.ts.map +1 -0
  55. package/dist/operation-envelope-validation.js +219 -0
  56. package/dist/operation-envelope-validation.js.map +1 -0
  57. package/dist/operations/__tests__/agent-operation-contract.test.d.ts +2 -0
  58. package/dist/operations/__tests__/agent-operation-contract.test.d.ts.map +1 -0
  59. package/dist/operations/__tests__/agent-operation-contract.test.js +128 -0
  60. package/dist/operations/__tests__/agent-operation-contract.test.js.map +1 -0
  61. package/dist/operations/__tests__/tasks-input-contracts.test.js +15 -0
  62. package/dist/operations/__tests__/tasks-input-contracts.test.js.map +1 -1
  63. package/dist/operations/agent-operation-contract.d.ts +227 -0
  64. package/dist/operations/agent-operation-contract.d.ts.map +1 -0
  65. package/dist/operations/agent-operation-contract.js +38 -0
  66. package/dist/operations/agent-operation-contract.js.map +1 -0
  67. package/dist/operations/docs.d.ts +19 -1
  68. package/dist/operations/docs.d.ts.map +1 -1
  69. package/dist/operations/docs.js +20 -0
  70. package/dist/operations/docs.js.map +1 -1
  71. package/dist/operations/focus.d.ts +1 -1
  72. package/dist/operations/index.d.ts +1 -0
  73. package/dist/operations/index.d.ts.map +1 -1
  74. package/dist/operations/index.js +1 -0
  75. package/dist/operations/index.js.map +1 -1
  76. package/dist/operations/orchestrate.d.ts +66 -0
  77. package/dist/operations/orchestrate.d.ts.map +1 -1
  78. package/dist/operations/tasks.d.ts +617 -11
  79. package/dist/operations/tasks.d.ts.map +1 -1
  80. package/dist/operations/tasks.js +22 -3
  81. package/dist/operations/tasks.js.map +1 -1
  82. package/dist/task-record.d.ts +15 -0
  83. package/dist/task-record.d.ts.map +1 -1
  84. package/dist/task.d.ts +52 -5
  85. package/dist/task.d.ts.map +1 -1
  86. package/dist/task.js.map +1 -1
  87. package/dist/tasks.d.ts +944 -0
  88. package/dist/tasks.d.ts.map +1 -1
  89. package/dist/tasks.js +198 -1
  90. package/dist/tasks.js.map +1 -1
  91. package/dist/validator/index.d.ts +375 -0
  92. package/dist/validator/index.d.ts.map +1 -0
  93. package/dist/validator/index.js +162 -0
  94. package/dist/validator/index.js.map +1 -0
  95. package/dist/workgraph.d.ts +1950 -0
  96. package/dist/workgraph.d.ts.map +1 -0
  97. package/dist/workgraph.js +449 -0
  98. package/dist/workgraph.js.map +1 -0
  99. package/package.json +10 -2
  100. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  101. package/src/__tests__/completion-operation-contracts.test.ts +154 -0
  102. package/src/__tests__/operation-envelope-validation.test.ts +140 -0
  103. package/src/__tests__/satisfies-atom.test.ts +383 -0
  104. package/src/__tests__/validator-types.test.ts +359 -0
  105. package/src/__tests__/workgraph-context-scaffold-contracts.test.ts +232 -0
  106. package/src/__tests__/workgraph-operation-contracts.test.ts +151 -0
  107. package/src/config.ts +58 -0
  108. package/src/data-accessor.ts +213 -0
  109. package/src/dispatch/__tests__/docs-update-registry.test.ts +35 -0
  110. package/src/dispatch/__tests__/operation-envelope-snapshots.test.ts +283 -0
  111. package/src/dispatch/operations-registry.ts +502 -7
  112. package/src/evidence-atom-schema.ts +188 -1
  113. package/src/exit-codes.ts +42 -0
  114. package/src/index.ts +230 -2
  115. package/src/operation-envelope-validation.ts +319 -0
  116. package/src/operations/__tests__/agent-operation-contract.test.ts +161 -0
  117. package/src/operations/__tests__/tasks-input-contracts.test.ts +30 -0
  118. package/src/operations/agent-operation-contract.ts +253 -0
  119. package/src/operations/docs.ts +27 -7
  120. package/src/operations/focus.ts +1 -1
  121. package/src/operations/index.ts +1 -0
  122. package/src/operations/orchestrate.ts +71 -0
  123. package/src/operations/tasks.ts +662 -15
  124. package/src/task-record.ts +16 -0
  125. package/src/task.ts +54 -5
  126. package/src/tasks.ts +558 -0
  127. package/src/validator/index.ts +385 -0
  128. package/src/workgraph.ts +1153 -0
@@ -0,0 +1,283 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import type { OperationDef } from '../operation-def.js';
3
+ import { OPERATIONS } from '../operations-registry.js';
4
+
5
+ function opId(op: OperationDef): string {
6
+ return `${op.gateway}:${op.domain}:${op.operation}`;
7
+ }
8
+
9
+ function envelopeSnapshot(op: OperationDef | undefined) {
10
+ expect(op).toBeDefined();
11
+ return {
12
+ gateway: op?.gateway,
13
+ domain: op?.domain,
14
+ operation: op?.operation,
15
+ tier: op?.tier,
16
+ idempotent: op?.idempotent,
17
+ sessionRequired: op?.sessionRequired,
18
+ requiredParams: op?.requiredParams ?? [],
19
+ params: (op?.params ?? []).map((param) => ({
20
+ name: param.name,
21
+ type: param.type,
22
+ required: param.required,
23
+ cli: param.cli,
24
+ })),
25
+ };
26
+ }
27
+
28
+ function getOp(
29
+ gateway: OperationDef['gateway'],
30
+ domain: string,
31
+ operation: string,
32
+ ): OperationDef | undefined {
33
+ return OPERATIONS.find(
34
+ (op) => op.gateway === gateway && op.domain === domain && op.operation === operation,
35
+ );
36
+ }
37
+
38
+ describe('operation envelope registry snapshots (T10615)', () => {
39
+ it('keeps high-risk operation identities unique across gateway/domain/operation', () => {
40
+ const criticalIds = [
41
+ 'query:tasks:show',
42
+ 'query:tasks:workgraph.audit',
43
+ 'mutate:tasks:saga.create',
44
+ 'mutate:docs:update',
45
+ ];
46
+ const seen = new Set(OPERATIONS.map(opId));
47
+
48
+ expect([...seen].filter((id) => criticalIds.includes(id)).sort()).toEqual(
49
+ [...criticalIds].sort(),
50
+ );
51
+ });
52
+
53
+ it('keeps requiredParams aligned with declared params for high-risk envelopes', () => {
54
+ const criticalOps = [
55
+ getOp('query', 'tasks', 'show'),
56
+ getOp('query', 'tasks', 'workgraph.audit'),
57
+ getOp('mutate', 'tasks', 'saga.create'),
58
+ getOp('mutate', 'docs', 'update'),
59
+ ].filter((op): op is OperationDef => op !== undefined);
60
+
61
+ const offenders = criticalOps.flatMap((op) => {
62
+ const paramNames = new Set((op.params ?? []).map((param) => param.name));
63
+ return (op.requiredParams ?? [])
64
+ .filter((name) => !paramNames.has(name))
65
+ .map((missing) => `${opId(op)} missing declared param ${missing}`);
66
+ });
67
+
68
+ expect(offenders).toEqual([]);
69
+ });
70
+
71
+ it('snapshots high-risk operation envelopes consumed by CLI/domain dispatch adapters', () => {
72
+ const snapshots = {
73
+ 'query:tasks:show': envelopeSnapshot(getOp('query', 'tasks', 'show')),
74
+ 'query:tasks:workgraph.audit': envelopeSnapshot(getOp('query', 'tasks', 'workgraph.audit')),
75
+ 'mutate:tasks:saga.create': envelopeSnapshot(getOp('mutate', 'tasks', 'saga.create')),
76
+ 'mutate:docs:update': envelopeSnapshot(getOp('mutate', 'docs', 'update')),
77
+ };
78
+
79
+ expect(snapshots).toMatchInlineSnapshot(`
80
+ {
81
+ "mutate:docs:update": {
82
+ "domain": "docs",
83
+ "gateway": "mutate",
84
+ "idempotent": false,
85
+ "operation": "update",
86
+ "params": [
87
+ {
88
+ "cli": {
89
+ "positional": true,
90
+ },
91
+ "name": "slug",
92
+ "required": true,
93
+ "type": "string",
94
+ },
95
+ {
96
+ "cli": undefined,
97
+ "name": "file",
98
+ "required": false,
99
+ "type": "string",
100
+ },
101
+ {
102
+ "cli": {
103
+ "flag": "allow-external",
104
+ },
105
+ "name": "allowExternal",
106
+ "required": false,
107
+ "type": "boolean",
108
+ },
109
+ {
110
+ "cli": undefined,
111
+ "name": "content",
112
+ "required": false,
113
+ "type": "string",
114
+ },
115
+ {
116
+ "cli": undefined,
117
+ "name": "message",
118
+ "required": false,
119
+ "type": "string",
120
+ },
121
+ {
122
+ "cli": undefined,
123
+ "name": "status",
124
+ "required": false,
125
+ "type": "string",
126
+ },
127
+ {
128
+ "cli": {
129
+ "flag": "dry-run",
130
+ },
131
+ "name": "dryRun",
132
+ "required": false,
133
+ "type": "boolean",
134
+ },
135
+ {
136
+ "cli": undefined,
137
+ "name": "strict",
138
+ "required": false,
139
+ "type": "boolean",
140
+ },
141
+ {
142
+ "cli": {
143
+ "flag": "attached-by",
144
+ },
145
+ "name": "attachedBy",
146
+ "required": false,
147
+ "type": "string",
148
+ },
149
+ ],
150
+ "requiredParams": [
151
+ "slug",
152
+ ],
153
+ "sessionRequired": false,
154
+ "tier": 1,
155
+ },
156
+ "mutate:tasks:saga.create": {
157
+ "domain": "tasks",
158
+ "gateway": "mutate",
159
+ "idempotent": false,
160
+ "operation": "saga.create",
161
+ "params": [
162
+ {
163
+ "cli": {
164
+ "flag": "title",
165
+ },
166
+ "name": "title",
167
+ "required": true,
168
+ "type": "string",
169
+ },
170
+ {
171
+ "cli": {
172
+ "flag": "description",
173
+ "short": "-d",
174
+ },
175
+ "name": "description",
176
+ "required": false,
177
+ "type": "string",
178
+ },
179
+ {
180
+ "cli": {
181
+ "flag": "acceptance",
182
+ },
183
+ "name": "acceptance",
184
+ "required": false,
185
+ "type": "array",
186
+ },
187
+ {
188
+ "cli": {
189
+ "flag": "dry-run",
190
+ },
191
+ "name": "dryRun",
192
+ "required": false,
193
+ "type": "boolean",
194
+ },
195
+ ],
196
+ "requiredParams": [
197
+ "title",
198
+ ],
199
+ "sessionRequired": false,
200
+ "tier": 0,
201
+ },
202
+ "query:tasks:show": {
203
+ "domain": "tasks",
204
+ "gateway": "query",
205
+ "idempotent": true,
206
+ "operation": "show",
207
+ "params": [
208
+ {
209
+ "cli": {
210
+ "positional": true,
211
+ },
212
+ "name": "taskId",
213
+ "required": true,
214
+ "type": "string",
215
+ },
216
+ {
217
+ "cli": undefined,
218
+ "name": "history",
219
+ "required": false,
220
+ "type": "boolean",
221
+ },
222
+ {
223
+ "cli": undefined,
224
+ "name": "ivtr-history",
225
+ "required": false,
226
+ "type": "boolean",
227
+ },
228
+ ],
229
+ "requiredParams": [
230
+ "taskId",
231
+ ],
232
+ "sessionRequired": false,
233
+ "tier": 0,
234
+ },
235
+ "query:tasks:workgraph.audit": {
236
+ "domain": "tasks",
237
+ "gateway": "query",
238
+ "idempotent": true,
239
+ "operation": "workgraph.audit",
240
+ "params": [
241
+ {
242
+ "cli": {
243
+ "positional": true,
244
+ },
245
+ "name": "rootId",
246
+ "required": true,
247
+ "type": "string",
248
+ },
249
+ {
250
+ "cli": undefined,
251
+ "name": "maxDepth",
252
+ "required": false,
253
+ "type": "number",
254
+ },
255
+ {
256
+ "cli": undefined,
257
+ "name": "includeRelations",
258
+ "required": false,
259
+ "type": "boolean",
260
+ },
261
+ {
262
+ "cli": undefined,
263
+ "name": "cursor",
264
+ "required": false,
265
+ "type": "string",
266
+ },
267
+ {
268
+ "cli": undefined,
269
+ "name": "limit",
270
+ "required": false,
271
+ "type": "number",
272
+ },
273
+ ],
274
+ "requiredParams": [
275
+ "rootId",
276
+ ],
277
+ "sessionRequired": false,
278
+ "tier": 1,
279
+ },
280
+ }
281
+ `);
282
+ });
283
+ });