@cleocode/contracts 2026.5.2 → 2026.5.4

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 (46) hide show
  1. package/dist/index.d.ts +5 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/lafs.d.ts +16 -143
  5. package/dist/lafs.d.ts.map +1 -1
  6. package/dist/lafs.js +11 -4
  7. package/dist/lafs.js.map +1 -1
  8. package/dist/operations/conduit.d.ts +15 -3
  9. package/dist/operations/conduit.d.ts.map +1 -1
  10. package/dist/operations/docs.d.ts +18 -15
  11. package/dist/operations/docs.d.ts.map +1 -1
  12. package/dist/operations/index.d.ts +5 -0
  13. package/dist/operations/index.d.ts.map +1 -1
  14. package/dist/operations/index.js +5 -0
  15. package/dist/operations/index.js.map +1 -1
  16. package/dist/operations/lifecycle.d.ts +3 -4
  17. package/dist/operations/lifecycle.d.ts.map +1 -1
  18. package/dist/operations/nexus.d.ts +341 -34
  19. package/dist/operations/nexus.d.ts.map +1 -1
  20. package/dist/operations/session.d.ts +201 -9
  21. package/dist/operations/session.d.ts.map +1 -1
  22. package/dist/operations/tasks.d.ts +381 -35
  23. package/dist/operations/tasks.d.ts.map +1 -1
  24. package/dist/operations/tasks.js +4 -3
  25. package/dist/operations/tasks.js.map +1 -1
  26. package/dist/tasks.d.ts +357 -0
  27. package/dist/tasks.d.ts.map +1 -0
  28. package/dist/tasks.js +18 -0
  29. package/dist/tasks.js.map +1 -0
  30. package/package.json +4 -2
  31. package/schemas/acceptance-gate.schema.json +484 -5
  32. package/schemas/attachment.schema.json +210 -5
  33. package/schemas/gate-result-details.schema.json +174 -5
  34. package/schemas/gate-result.schema.json +236 -5
  35. package/schemas/task-evidence.schema.json +199 -5
  36. package/schemas/task.schema.json +568 -5
  37. package/src/index.ts +37 -7
  38. package/src/lafs.ts +34 -162
  39. package/src/operations/conduit.ts +16 -3
  40. package/src/operations/docs.ts +22 -16
  41. package/src/operations/index.ts +5 -0
  42. package/src/operations/lifecycle.ts +3 -5
  43. package/src/operations/nexus.ts +355 -34
  44. package/src/operations/session.ts +213 -10
  45. package/src/operations/tasks.ts +377 -36
  46. package/src/tasks.ts +413 -0
package/src/lafs.ts CHANGED
@@ -1,175 +1,44 @@
1
1
  /**
2
2
  * LAFS (LLM-Agent-First Schema) unified envelope types.
3
3
  *
4
- * Defines canonical LAFS types inline (contracts has ZERO external dependencies).
5
- * In the main CLEO codebase these are re-exported from @cleocode/lafs;
6
- * here they are defined as plain interfaces for maximum portability.
4
+ * Protocol-level types (`LAFSEnvelope`, `LAFSMeta`, `LAFSError`,
5
+ * `LAFSErrorCategory`, `LAFSTransport`, `LAFSPage*`, `MVILevel`, `Warning`)
6
+ * are owned by `@cleocode/lafs` (ADR-039) and re-exported here so that
7
+ * downstream consumers can import from a single well-known contracts path.
8
+ *
9
+ * Contracts-specific types (`LafsEnvelope`, `LafsSuccess`, `LafsError`,
10
+ * `LafsErrorDetail`, `LafsAlternative`, `GatewayMeta`, `GatewayEnvelope`,
11
+ * `CleoResponse`) are defined here because they represent CLEO's CLI-layer
12
+ * and gateway-layer response contracts that depend on the protocol types but
13
+ * are not part of the LAFS SDK itself.
7
14
  *
8
15
  * @epic T4654
9
- * @task T4655
16
+ * @task T1706
10
17
  */
11
18
 
12
19
  // ---------------------------------------------------------------------------
13
- // Canonical LAFS types (inlined from @cleocode/lafs)
20
+ // Re-export canonical LAFS protocol types from @cleocode/lafs (ADR-039)
14
21
  // ---------------------------------------------------------------------------
15
22
 
16
- /** LAFS error category. */
17
- export type LAFSErrorCategory =
18
- | 'validation'
19
- | 'not_found'
20
- | 'conflict'
21
- | 'authorization'
22
- | 'internal'
23
- | 'rate_limit'
24
- | 'timeout'
25
- | 'dependency';
26
-
27
- /** LAFS error object. */
28
- export interface LAFSError {
29
- /** Stable error code (numeric HTTP status or string identifier). */
30
- code: number | string;
31
- /** High-level error classification category. */
32
- category: LAFSErrorCategory;
33
- /** Human-readable error description. */
34
- message: string;
35
- /**
36
- * Suggested fix or recovery action for the caller.
37
- *
38
- * @defaultValue undefined
39
- */
40
- fix?: string;
41
- /**
42
- * Arbitrary key-value pairs with additional error context.
43
- *
44
- * @defaultValue undefined
45
- */
46
- details?: Record<string, unknown>;
47
- }
48
-
49
- /** LAFS warning. */
50
- export interface Warning {
51
- /** Machine-readable warning code. */
52
- code: string;
53
- /** Human-readable warning description. */
54
- message: string;
55
- }
56
-
57
- /** LAFS transport metadata. */
58
- export type LAFSTransport = 'cli' | 'http' | 'sdk';
59
-
60
- /** MVI (Minimal Viable Information) level. */
61
- export type MVILevel = 'minimal' | 'standard' | 'full';
62
-
63
- /**
64
- * LAFS page — no pagination.
65
- *
66
- * Discriminator field is `mode` to match the canonical {@link "@cleocode/lafs"}
67
- * spec (LAFSPageNone). Contracts cannot depend on `@cleocode/lafs` directly
68
- * (zero external deps invariant) so the type is inlined with matching shape.
69
- */
70
- export interface LAFSPageNone {
71
- /** Discriminant indicating no pagination. */
72
- mode: 'none';
73
- }
74
-
75
- /**
76
- * LAFS page — offset-based pagination.
77
- *
78
- * Discriminator field is `mode` to match the canonical {@link "@cleocode/lafs"}
79
- * spec (LAFSPageOffset).
80
- */
81
- export interface LAFSPageOffset {
82
- /** Discriminant identifying offset-based pagination. */
83
- mode: 'offset';
84
- /** Maximum number of items per page. */
85
- limit: number;
86
- /** Zero-based index of the first item in this page. */
87
- offset: number;
88
- /** Whether additional pages exist beyond the current one. */
89
- hasMore: boolean;
90
- /** Total number of items across all pages, or `null` if unknown. */
91
- total?: number | null;
92
- }
93
-
94
- /**
95
- * LAFS page — cursor-based pagination.
96
- *
97
- * Discriminator field is `mode` to match the canonical {@link "@cleocode/lafs"}
98
- * spec (LAFSPageCursor).
99
- */
100
- export interface LAFSPageCursor {
101
- /** Discriminant identifying cursor-based pagination. */
102
- mode: 'cursor';
103
- /** Opaque cursor for fetching the next page, or `null` when at the end. */
104
- nextCursor: string | null;
105
- /** Whether additional pages exist beyond the current one. */
106
- hasMore: boolean;
107
- /** Maximum number of items per page. */
108
- limit?: number;
109
- /** Total number of items across all pages, or `null` if unknown. */
110
- total?: number | null;
111
- }
112
-
113
- /**
114
- * LAFS page union.
115
- *
116
- * Structurally compatible with `@cleocode/lafs` `LAFSPage` so that values
117
- * flow freely between dispatch (which uses contracts) and core (which uses
118
- * lafs). Both export the same three variants discriminated on `mode`.
119
- */
120
- export type LAFSPage = LAFSPageNone | LAFSPageOffset | LAFSPageCursor;
23
+ export type {
24
+ LAFSEnvelope,
25
+ LAFSError,
26
+ LAFSErrorCategory,
27
+ LAFSMeta,
28
+ LAFSPage,
29
+ LAFSPageCursor,
30
+ LAFSPageNone,
31
+ LAFSPageOffset,
32
+ LAFSTransport,
33
+ MVILevel,
34
+ Warning,
35
+ } from '@cleocode/lafs';
121
36
 
122
- /** LAFS metadata block. */
123
- export interface LAFSMeta {
124
- /** Transport protocol used for this envelope. */
125
- transport: LAFSTransport;
126
- /** Minimum Viable Information level controlling verbosity. */
127
- mvi: MVILevel;
128
- /**
129
- * Pagination metadata when the result is a paginated collection.
130
- *
131
- * @defaultValue undefined
132
- */
133
- page?: LAFSPage;
134
- /**
135
- * Non-fatal warnings to surface to the consuming agent.
136
- *
137
- * @defaultValue undefined
138
- */
139
- warnings?: Warning[];
140
- /**
141
- * Operation duration in milliseconds.
142
- *
143
- * @defaultValue undefined
144
- */
145
- durationMs?: number;
146
- }
147
-
148
- /** LAFS envelope (canonical protocol type). */
149
- export interface LAFSEnvelope<T = unknown> {
150
- /** Whether the operation completed successfully. */
151
- success: boolean;
152
- /**
153
- * Operation result payload on success.
154
- *
155
- * @defaultValue undefined
156
- */
157
- data?: T;
158
- /**
159
- * Structured error payload on failure.
160
- *
161
- * @defaultValue undefined
162
- */
163
- error?: LAFSError;
164
- /**
165
- * Protocol and transport metadata.
166
- *
167
- * @defaultValue undefined
168
- */
169
- _meta?: LAFSMeta;
170
- }
37
+ // ---------------------------------------------------------------------------
38
+ // Contracts-specific types (not part of the LAFS SDK)
39
+ // ---------------------------------------------------------------------------
171
40
 
172
- /** Flag input for conformance checks. */
41
+ /** Input for conformance checks. */
173
42
  export interface FlagInput {
174
43
  /** Name of the flag being checked. */
175
44
  flag: string;
@@ -267,12 +136,15 @@ export interface LafsError {
267
136
  export type LafsEnvelope<T = unknown> = LafsSuccess<T> | LafsError;
268
137
 
269
138
  // ---------------------------------------------------------------------------
270
- // Gateway envelope extension (extends LAFSMeta)
139
+ // Gateway envelope extension (extends LAFSMeta from @cleocode/lafs)
271
140
  // ---------------------------------------------------------------------------
272
141
 
142
+ import type { LAFSMeta } from '@cleocode/lafs';
143
+
273
144
  /**
274
145
  * Metadata attached to every gateway response.
275
- * Extends the canonical LAFSMeta with CLEO gateway-specific fields.
146
+ * Extends the canonical LAFSMeta from @cleocode/lafs with CLEO
147
+ * gateway-specific fields.
276
148
  *
277
149
  * @task T4655
278
150
  */
@@ -184,8 +184,21 @@ export interface ConduitSendParams {
184
184
  /** Send as this agent. Omit to use the active agent from the registry. */
185
185
  agentId?: string;
186
186
  }
187
- /** Result of `conduit.send`. */
188
- export interface ConduitSendResult {
187
+
188
+ /**
189
+ * Operation result of `conduit.send`.
190
+ *
191
+ * @remarks
192
+ * This is the wire-format result for the `conduit.send` CLI/HTTP dispatch
193
+ * operation. It carries transport metadata (`from`, `to`, `transport`,
194
+ * `sentAt`) not present in the transport-layer {@link ConduitSendResult}
195
+ * defined in `../conduit.ts`.
196
+ *
197
+ * The transport-layer type (`@cleocode/contracts` top-level `ConduitSendResult`)
198
+ * covers the `Conduit` interface (ConduitClient / publishToTopic). This type
199
+ * covers the CLI dispatch surface.
200
+ */
201
+ export interface ConduitSendOperationResult {
189
202
  /** The assigned message id. */
190
203
  messageId: string;
191
204
  /** Sender agent id. */
@@ -329,7 +342,7 @@ export type ConduitOps = {
329
342
  listen: [ConduitListenParams, ConduitListenResult];
330
343
  start: [ConduitStartParams, ConduitStartResult];
331
344
  stop: [ConduitStopParams, ConduitStopResult];
332
- send: [ConduitSendParams, ConduitSendResult];
345
+ send: [ConduitSendParams, ConduitSendOperationResult];
333
346
  subscribe: [ConduitSubscribeParams, ConduitSubscribeResult];
334
347
  publish: [ConduitPublishParams, ConduitPublishResult];
335
348
  };
@@ -28,6 +28,8 @@
28
28
  * @see packages/contracts/src/operations/index.ts
29
29
  */
30
30
 
31
+ import type { AttachmentKind } from '../attachment.js';
32
+
31
33
  // ============================================================================
32
34
  // Shared Attachment Types (API wire format)
33
35
  // ============================================================================
@@ -45,22 +47,26 @@ export type AttachmentOwnerType =
45
47
  | 'learning'
46
48
  | 'pattern';
47
49
 
48
- /**
49
- * Supported attachment kind (storage mode).
50
- *
51
- * - `local-file` — file path tracked in metadata; bytes stored in blob
52
- * - `blob` — inline content uploaded; bytes stored in blob
53
- * - `url` — URL-only reference; no bytes stored
54
- * - `llms-txt` — generated content from `docs.generate --attach`
55
- */
56
- export type AttachmentKind = 'local-file' | 'blob' | 'url' | 'llms-txt';
50
+ // Re-export the canonical AttachmentKind so consumers of this module do not
51
+ // need a separate import from `../attachment.js`.
52
+ export type { AttachmentKind } from '../attachment.js';
57
53
 
58
54
  /**
59
- * Attachment metadata fragment returned by query operations.
55
+ * Flattened wire-format attachment row returned by docs query operations.
56
+ *
57
+ * This is the **API response shape** — a denormalised projection of the domain
58
+ * {@link import('../attachment.js').AttachmentMetadata} registry row suitable for
59
+ * CLI/HTTP serialisation. Key differences from the domain type:
60
+ *
61
+ * - `kind` is lifted from the nested `attachment` object to the top level.
62
+ * - `mime` and `size` are lifted and made optional (not all kinds carry them).
63
+ * - The full `attachment` discriminated-union value is NOT included (too verbose
64
+ * for list/fetch wire responses).
60
65
  *
61
- * Includes kind, mime type, size (when applicable), description, and labels.
66
+ * @see {@link import('../attachment.js').AttachmentMetadata} the full domain
67
+ * registry row stored in `.cleo/attachments/index.db`.
62
68
  */
63
- export interface AttachmentMetadata {
69
+ export interface DocsAttachmentRow {
64
70
  /** Attachment identifier (UUID-like string). */
65
71
  id: string;
66
72
  /** SHA-256 hash of content; truncated to 8 chars in list views. */
@@ -96,7 +102,7 @@ export type AttachmentBackend = 'legacy' | 'llmstxt-v2';
96
102
  */
97
103
  export interface AttachmentRecord {
98
104
  /** Attachment metadata. */
99
- metadata: AttachmentMetadata;
105
+ metadata: DocsAttachmentRow;
100
106
  /** File system path where bytes are stored (if applicable). */
101
107
  path?: string;
102
108
  /** Size in bytes. */
@@ -140,7 +146,7 @@ export interface DocsListResult {
140
146
  /** Count of attachments for this owner. */
141
147
  count: number;
142
148
  /** Attachment metadata array. */
143
- attachments: AttachmentMetadata[];
149
+ attachments: DocsAttachmentRow[];
144
150
  /** Current attachment backend in use. */
145
151
  attachmentBackend?: AttachmentBackend;
146
152
  }
@@ -161,8 +167,8 @@ export interface DocsFetchParams {
161
167
  * Result of `docs.fetch`.
162
168
  */
163
169
  export interface DocsFetchResult {
164
- /** Attachment record with metadata and optional inline bytes. */
165
- metadata: AttachmentMetadata;
170
+ /** Flattened attachment metadata row for this attachment. */
171
+ metadata: DocsAttachmentRow;
166
172
  /** File system path where bytes are stored (if applicable). */
167
173
  path?: string;
168
174
  /** Total size in bytes. */
@@ -5,8 +5,12 @@
5
5
  * to avoid name collisions with canonical domain types.
6
6
  */
7
7
 
8
+ export * from './admin.js';
8
9
  export * from './brain.js';
9
10
  export * from './conduit.js';
11
+ export * from './dialectic.js';
12
+ export * from './docs.js';
13
+ export * from './intelligence.js';
10
14
  export * from './issues.js';
11
15
  export * from './lifecycle.js';
12
16
  export * from './llm.js';
@@ -22,6 +26,7 @@ export * from './research.js';
22
26
  export * from './sentient.js';
23
27
  export * from './session.js';
24
28
  export * from './skills.js';
29
+ export * from './sticky.js';
25
30
  export * from './system.js';
26
31
  export * from './tasks.js';
27
32
  export * from './validate.js';
@@ -5,9 +5,9 @@
5
5
  * Mutate operations: 5
6
6
  */
7
7
 
8
- import type { StageStatus } from '../status-registry.js';
8
+ import type { GateStatus, StageStatus } from '../status-registry.js';
9
9
 
10
- export type { StageStatus };
10
+ export type { GateStatus, StageStatus };
11
11
 
12
12
  /**
13
13
  * Common lifecycle types
@@ -23,8 +23,6 @@ export type LifecycleStage =
23
23
  | 'testing'
24
24
  | 'release';
25
25
 
26
- export type GateStatus = 'passed' | 'failed' | 'blocked' | null;
27
-
28
26
  export interface StageRecord {
29
27
  stage: LifecycleStage;
30
28
  status: StageStatus;
@@ -85,7 +83,7 @@ export interface LifecycleCheckResult {
85
83
  /** Ordered list of stages that must complete first. @task T963 */
86
84
  missingPrerequisites: LifecycleStage[];
87
85
  /** Current gate status for the target stage. @task T963 */
88
- gateStatus: 'passed' | 'failed' | 'pending';
86
+ gateStatus: GateStatus;
89
87
  }
90
88
 
91
89
  // lifecycle.status