@cleocode/core 2026.6.5 → 2026.6.7
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.
- package/dist/dispatch/contracts/output-contracts.d.ts +36 -0
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -0
- package/dist/dispatch/contracts/output-contracts.js +38 -0
- package/dist/dispatch/contracts/output-contracts.js.map +1 -0
- package/dist/dispatch/describe-operation.d.ts +98 -0
- package/dist/dispatch/describe-operation.d.ts.map +1 -0
- package/dist/dispatch/describe-operation.js +101 -0
- package/dist/dispatch/describe-operation.js.map +1 -0
- package/dist/docs/export-document.js +933 -489
- package/dist/docs/export-document.js.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +6 -0
- package/dist/internal.js.map +1 -1
- package/dist/llm/api-mode.d.ts +64 -0
- package/dist/llm/api-mode.d.ts.map +1 -0
- package/dist/llm/api-mode.js +72 -0
- package/dist/llm/api-mode.js.map +1 -0
- package/dist/llm/api.d.ts.map +1 -1
- package/dist/llm/api.js +6 -37
- package/dist/llm/api.js.map +1 -1
- package/dist/llm/auxiliary-fallback.d.ts.map +1 -1
- package/dist/llm/auxiliary-fallback.js +24 -38
- package/dist/llm/auxiliary-fallback.js.map +1 -1
- package/dist/llm/index.d.ts +1 -3
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -2
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/model-metadata.d.ts +14 -0
- package/dist/llm/model-metadata.d.ts.map +1 -1
- package/dist/llm/model-metadata.js +23 -0
- package/dist/llm/model-metadata.js.map +1 -1
- package/dist/llm/model-runner.d.ts +127 -0
- package/dist/llm/model-runner.d.ts.map +1 -0
- package/dist/llm/model-runner.js +312 -0
- package/dist/llm/model-runner.js.map +1 -0
- package/dist/llm/plugin-facade.js +30084 -1748
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/provider-registry/builtin/anthropic.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/anthropic.js +4 -0
- package/dist/llm/provider-registry/builtin/anthropic.js.map +1 -1
- package/dist/llm/provider-registry/builtin/gemini.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/gemini.js +4 -0
- package/dist/llm/provider-registry/builtin/gemini.js.map +1 -1
- package/dist/llm/provider-registry/builtin/ollama.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/ollama.js +4 -0
- package/dist/llm/provider-registry/builtin/ollama.js.map +1 -1
- package/dist/llm/provider-registry/builtin/openai.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/openai.js +6 -0
- package/dist/llm/provider-registry/builtin/openai.js.map +1 -1
- package/dist/llm/role-executor.d.ts +6 -5
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +40 -86
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts +28 -1
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +10 -0
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/session-factory.d.ts +4 -6
- package/dist/llm/session-factory.d.ts.map +1 -1
- package/dist/llm/session-factory.js +6 -72
- package/dist/llm/session-factory.js.map +1 -1
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +6 -0
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/llm/tool-loop.d.ts.map +1 -1
- package/dist/llm/tool-loop.js +9 -32
- package/dist/llm/tool-loop.js.map +1 -1
- package/dist/llm/transports/index.d.ts +5 -3
- package/dist/llm/transports/index.d.ts.map +1 -1
- package/dist/llm/transports/index.js +5 -2
- package/dist/llm/transports/index.js.map +1 -1
- package/dist/reconciliation/reconciliation-engine.d.ts.map +1 -1
- package/dist/reconciliation/reconciliation-engine.js +3 -0
- package/dist/reconciliation/reconciliation-engine.js.map +1 -1
- package/dist/release/plan.d.ts +27 -0
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +36 -2
- package/dist/release/plan.js.map +1 -1
- package/dist/release/provenance-fk.d.ts +74 -0
- package/dist/release/provenance-fk.d.ts.map +1 -0
- package/dist/release/provenance-fk.js +122 -0
- package/dist/release/provenance-fk.js.map +1 -0
- package/dist/release/reconcile.d.ts +10 -0
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +107 -2
- package/dist/release/reconcile.js.map +1 -1
- package/dist/sticky/convert.d.ts.map +1 -1
- package/dist/sticky/convert.js +3 -0
- package/dist/sticky/convert.js.map +1 -1
- package/dist/store/exodus/column-transforms.d.ts +275 -0
- package/dist/store/exodus/column-transforms.d.ts.map +1 -0
- package/dist/store/exodus/column-transforms.js +478 -0
- package/dist/store/exodus/column-transforms.js.map +1 -0
- package/dist/store/exodus/count-parity.d.ts +71 -0
- package/dist/store/exodus/count-parity.d.ts.map +1 -0
- package/dist/store/exodus/count-parity.js +124 -0
- package/dist/store/exodus/count-parity.js.map +1 -0
- package/dist/store/exodus/health.d.ts +70 -0
- package/dist/store/exodus/health.d.ts.map +1 -0
- package/dist/store/exodus/health.js +130 -0
- package/dist/store/exodus/health.js.map +1 -0
- package/dist/store/exodus/index.d.ts +3 -0
- package/dist/store/exodus/index.d.ts.map +1 -1
- package/dist/store/exodus/index.js +3 -0
- package/dist/store/exodus/index.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +103 -298
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/plan.d.ts +48 -4
- package/dist/store/exodus/plan.d.ts.map +1 -1
- package/dist/store/exodus/plan.js +67 -9
- package/dist/store/exodus/plan.js.map +1 -1
- package/dist/store/exodus/seal.d.ts +69 -0
- package/dist/store/exodus/seal.d.ts.map +1 -0
- package/dist/store/exodus/seal.js +73 -0
- package/dist/store/exodus/seal.js.map +1 -0
- package/dist/store/exodus/types.d.ts +24 -1
- package/dist/store/exodus/types.d.ts.map +1 -1
- package/dist/store/exodus/types.js.map +1 -1
- package/dist/store/exodus/verify-migration.d.ts.map +1 -1
- package/dist/store/exodus/verify-migration.js +109 -24
- package/dist/store/exodus/verify-migration.js.map +1 -1
- package/dist/tasks/add.d.ts +13 -0
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +50 -18
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/archive.d.ts.map +1 -1
- package/dist/tasks/archive.js +12 -7
- package/dist/tasks/archive.js.map +1 -1
- package/dist/tasks/child-disposition.d.ts +66 -0
- package/dist/tasks/child-disposition.d.ts.map +1 -0
- package/dist/tasks/child-disposition.js +80 -0
- package/dist/tasks/child-disposition.js.map +1 -0
- package/dist/tasks/delete-preview.js +1 -1
- package/dist/tasks/delete-preview.js.map +1 -1
- package/dist/tasks/deletion-strategy.d.ts +21 -3
- package/dist/tasks/deletion-strategy.d.ts.map +1 -1
- package/dist/tasks/deletion-strategy.js +61 -15
- package/dist/tasks/deletion-strategy.js.map +1 -1
- package/dist/tasks/engine-wrap.d.ts +8 -0
- package/dist/tasks/engine-wrap.d.ts.map +1 -1
- package/dist/tasks/engine-wrap.js +22 -9
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +12 -0
- package/dist/tasks/update.js.map +1 -1
- package/package.json +12 -12
- package/dist/llm/transports/openai.d.ts +0 -181
- package/dist/llm/transports/openai.d.ts.map +0 -1
- package/dist/llm/transports/openai.js +0 -645
- package/dist/llm/transports/openai.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OUTPUT_CONTRACTS accessor — SSoT lookup for per-operation OUTPUT contracts.
|
|
3
|
+
*
|
|
4
|
+
* The OUTPUT-side mirror of {@link getInputContract}. The contract DATA lives
|
|
5
|
+
* in `@cleocode/contracts` (a leaf, zero-runtime-dep package) as
|
|
6
|
+
* {@link OUTPUT_CONTRACTS}; this module re-exports it and provides the null-safe
|
|
7
|
+
* accessor that the SDK `describeOperation` and the `cleo <op> --describe`
|
|
8
|
+
* surface consult.
|
|
9
|
+
*
|
|
10
|
+
* Keyed by the canonical `<domain>.<verb>` operation identifier (e.g.
|
|
11
|
+
* `'tasks.show'`). A `null` lookup is expected (the registry is populated
|
|
12
|
+
* incrementally, high-traffic ops first) and MUST NOT error.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
* @module @cleocode/core/dispatch/contracts/output-contracts
|
|
16
|
+
*
|
|
17
|
+
* @epic T11679
|
|
18
|
+
* @task T11692 — DHQ-057: per-operation output schema SSoT
|
|
19
|
+
*/
|
|
20
|
+
import { type OperationOutputContract, OUTPUT_CONTRACTS } from '@cleocode/contracts';
|
|
21
|
+
export { OUTPUT_CONTRACTS };
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the {@link OperationOutputContract} for an operation id, or return
|
|
24
|
+
* `null` when no contract is registered.
|
|
25
|
+
*
|
|
26
|
+
* Used by the SDK `describeOperation` and the `cleo <op> --describe`
|
|
27
|
+
* introspection surface to render the result-shape contract (data schema +
|
|
28
|
+
* valid `--field` pointers). Mirrors {@link getInputContract} exactly.
|
|
29
|
+
*
|
|
30
|
+
* @param operation - Canonical `<domain>.<verb>` operation identifier.
|
|
31
|
+
* @returns The matching contract, or `null` when none is registered.
|
|
32
|
+
*
|
|
33
|
+
* @task T11692
|
|
34
|
+
*/
|
|
35
|
+
export declare function getOutputContract(operation: string): OperationOutputContract | null;
|
|
36
|
+
//# sourceMappingURL=output-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-contracts.d.ts","sourceRoot":"","sources":["../../../src/dispatch/contracts/output-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAEnF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OUTPUT_CONTRACTS accessor — SSoT lookup for per-operation OUTPUT contracts.
|
|
3
|
+
*
|
|
4
|
+
* The OUTPUT-side mirror of {@link getInputContract}. The contract DATA lives
|
|
5
|
+
* in `@cleocode/contracts` (a leaf, zero-runtime-dep package) as
|
|
6
|
+
* {@link OUTPUT_CONTRACTS}; this module re-exports it and provides the null-safe
|
|
7
|
+
* accessor that the SDK `describeOperation` and the `cleo <op> --describe`
|
|
8
|
+
* surface consult.
|
|
9
|
+
*
|
|
10
|
+
* Keyed by the canonical `<domain>.<verb>` operation identifier (e.g.
|
|
11
|
+
* `'tasks.show'`). A `null` lookup is expected (the registry is populated
|
|
12
|
+
* incrementally, high-traffic ops first) and MUST NOT error.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
* @module @cleocode/core/dispatch/contracts/output-contracts
|
|
16
|
+
*
|
|
17
|
+
* @epic T11679
|
|
18
|
+
* @task T11692 — DHQ-057: per-operation output schema SSoT
|
|
19
|
+
*/
|
|
20
|
+
import { OUTPUT_CONTRACTS } from '@cleocode/contracts';
|
|
21
|
+
export { OUTPUT_CONTRACTS };
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the {@link OperationOutputContract} for an operation id, or return
|
|
24
|
+
* `null` when no contract is registered.
|
|
25
|
+
*
|
|
26
|
+
* Used by the SDK `describeOperation` and the `cleo <op> --describe`
|
|
27
|
+
* introspection surface to render the result-shape contract (data schema +
|
|
28
|
+
* valid `--field` pointers). Mirrors {@link getInputContract} exactly.
|
|
29
|
+
*
|
|
30
|
+
* @param operation - Canonical `<domain>.<verb>` operation identifier.
|
|
31
|
+
* @returns The matching contract, or `null` when none is registered.
|
|
32
|
+
*
|
|
33
|
+
* @task T11692
|
|
34
|
+
*/
|
|
35
|
+
export function getOutputContract(operation) {
|
|
36
|
+
return OUTPUT_CONTRACTS[operation] ?? null;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=output-contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-contracts.js","sourceRoot":"","sources":["../../../src/dispatch/contracts/output-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAgC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,gBAAgB,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* describeOperation — SDK introspection of a CLEO operation's I/O contract.
|
|
3
|
+
*
|
|
4
|
+
* The programmatic counterpart to `cleo <op> --describe`. Given a canonical
|
|
5
|
+
* `<domain>.<verb>` operation id (e.g. `'tasks.show'`), composes a single
|
|
6
|
+
* typed {@link OperationDescriptor} from the three SSoT surfaces:
|
|
7
|
+
*
|
|
8
|
+
* 1. {@link OperationDef} (from `@cleocode/contracts`) — gateway, tier,
|
|
9
|
+
* idempotency, session requirement, and the declared `params`.
|
|
10
|
+
* 2. The INPUT contract (`getInputContract`, T9918) — JSON Schema for the
|
|
11
|
+
* accepted request payload + worked examples. The schemas set
|
|
12
|
+
* `additionalProperties: false`, so unknown keys (e.g. `relates` on
|
|
13
|
+
* `tasks.add-batch`) are rejected LOUDLY (DHQ-033).
|
|
14
|
+
* 3. The OUTPUT contract (`getOutputContract`, T11692) — JSON Schema for the
|
|
15
|
+
* LAFS envelope's `data` payload + the curated list of valid `--field`
|
|
16
|
+
* JSON pointers (DHQ-057). This is what lets an agent predict the result
|
|
17
|
+
* shape instead of guessing (`/data/task/title`, NOT `/data/title`).
|
|
18
|
+
*
|
|
19
|
+
* This is the root fix for "agents cannot predict the envelope" (T11692):
|
|
20
|
+
* `--field` pointers, result parsing, and SDK consumers all resolve against
|
|
21
|
+
* ONE declared contract rather than hand-sniffing per verb.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
* @module @cleocode/core/dispatch/describe-operation
|
|
25
|
+
*
|
|
26
|
+
* @epic T11679
|
|
27
|
+
* @task T11692 — DHQ-057: per-operation output schema SSoT
|
|
28
|
+
*/
|
|
29
|
+
import { type OperationInputContract, type OperationOutputContract } from '@cleocode/contracts';
|
|
30
|
+
import { type OperationSchema } from '@cleocode/lafs';
|
|
31
|
+
/**
|
|
32
|
+
* Fully-resolved I/O contract for a single CLEO operation.
|
|
33
|
+
*
|
|
34
|
+
* Returned by {@link describeOperation}. Bundles the operation's identity, its
|
|
35
|
+
* parameter signature (`params`/`gates` via the LAFS schema), the INPUT
|
|
36
|
+
* contract, and the OUTPUT contract into one machine- and human-readable
|
|
37
|
+
* descriptor. `inputContract` / `outputContract` are `null` for operations not
|
|
38
|
+
* yet migrated to the schema-first surface — callers render the descriptor with
|
|
39
|
+
* a "no contract yet" note rather than failing.
|
|
40
|
+
*/
|
|
41
|
+
export interface OperationDescriptor {
|
|
42
|
+
/** Fully-qualified operation key, e.g. `"tasks.show"`. */
|
|
43
|
+
operation: string;
|
|
44
|
+
/** CQRS gateway — read-only (`"query"`) or state-modifying (`"mutate"`). */
|
|
45
|
+
gateway: 'query' | 'mutate';
|
|
46
|
+
/** One-line description of what the operation does. */
|
|
47
|
+
description: string;
|
|
48
|
+
/** Agent progressive-disclosure tier (0=basic, 1=memory/check, 2=full). */
|
|
49
|
+
tier: number;
|
|
50
|
+
/** Whether the operation is safe to retry. */
|
|
51
|
+
idempotent: boolean;
|
|
52
|
+
/** Whether the operation requires an active session. */
|
|
53
|
+
sessionRequired: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Parameter signature + declared precondition gates, derived from the LAFS
|
|
56
|
+
* {@link OperationSchema}. The authoritative human-readable param list.
|
|
57
|
+
*/
|
|
58
|
+
params: OperationSchema;
|
|
59
|
+
/**
|
|
60
|
+
* Schema-first INPUT contract (JSON Schema + examples), or `null` when the
|
|
61
|
+
* operation has no registered input contract yet.
|
|
62
|
+
*/
|
|
63
|
+
inputContract: OperationInputContract<unknown> | null;
|
|
64
|
+
/**
|
|
65
|
+
* Schema-first OUTPUT contract (envelope `data` JSON Schema + valid `--field`
|
|
66
|
+
* pointers), or `null` when the operation has no registered output contract
|
|
67
|
+
* yet.
|
|
68
|
+
*/
|
|
69
|
+
outputContract: OperationOutputContract | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Describe a CLEO operation's full INPUT + OUTPUT contract.
|
|
73
|
+
*
|
|
74
|
+
* The SDK entry point behind `cleo <op> --describe`. Resolves the operation by
|
|
75
|
+
* its canonical `<domain>.<verb>` id and returns a single typed
|
|
76
|
+
* {@link OperationDescriptor}, or `null` when the operation id is unknown.
|
|
77
|
+
*
|
|
78
|
+
* Contract resolution prefers an inline contract carried on the
|
|
79
|
+
* {@link OperationDef} (`def.inputSchema` / `def.outputSchema`) and falls back
|
|
80
|
+
* to the SSoT registries (`getInputContract` / `getOutputContract`). This lets
|
|
81
|
+
* a definition self-describe while keeping the registries authoritative.
|
|
82
|
+
*
|
|
83
|
+
* @param operation - Canonical `<domain>.<verb>` operation id (e.g. `"tasks.show"`).
|
|
84
|
+
* @returns The resolved descriptor, or `null` when the operation is unknown.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { describeOperation } from '@cleocode/core';
|
|
89
|
+
*
|
|
90
|
+
* const d = describeOperation('tasks.show');
|
|
91
|
+
* // d.outputContract.fieldPointers includes '/data/task/title'
|
|
92
|
+
* // → the correct pointer; '/data/title' would E_FIELD_NOT_FOUND.
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @task T11692
|
|
96
|
+
*/
|
|
97
|
+
export declare function describeOperation(operation: string): OperationDescriptor | null;
|
|
98
|
+
//# sourceMappingURL=describe-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-operation.d.ts","sourceRoot":"","sources":["../../src/dispatch/describe-operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAI3F;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;;OAGG;IACH,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACtD;;;;OAIG;IACH,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAChD;AAyBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAoB/E"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* describeOperation — SDK introspection of a CLEO operation's I/O contract.
|
|
3
|
+
*
|
|
4
|
+
* The programmatic counterpart to `cleo <op> --describe`. Given a canonical
|
|
5
|
+
* `<domain>.<verb>` operation id (e.g. `'tasks.show'`), composes a single
|
|
6
|
+
* typed {@link OperationDescriptor} from the three SSoT surfaces:
|
|
7
|
+
*
|
|
8
|
+
* 1. {@link OperationDef} (from `@cleocode/contracts`) — gateway, tier,
|
|
9
|
+
* idempotency, session requirement, and the declared `params`.
|
|
10
|
+
* 2. The INPUT contract (`getInputContract`, T9918) — JSON Schema for the
|
|
11
|
+
* accepted request payload + worked examples. The schemas set
|
|
12
|
+
* `additionalProperties: false`, so unknown keys (e.g. `relates` on
|
|
13
|
+
* `tasks.add-batch`) are rejected LOUDLY (DHQ-033).
|
|
14
|
+
* 3. The OUTPUT contract (`getOutputContract`, T11692) — JSON Schema for the
|
|
15
|
+
* LAFS envelope's `data` payload + the curated list of valid `--field`
|
|
16
|
+
* JSON pointers (DHQ-057). This is what lets an agent predict the result
|
|
17
|
+
* shape instead of guessing (`/data/task/title`, NOT `/data/title`).
|
|
18
|
+
*
|
|
19
|
+
* This is the root fix for "agents cannot predict the envelope" (T11692):
|
|
20
|
+
* `--field` pointers, result parsing, and SDK consumers all resolve against
|
|
21
|
+
* ONE declared contract rather than hand-sniffing per verb.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
* @module @cleocode/core/dispatch/describe-operation
|
|
25
|
+
*
|
|
26
|
+
* @epic T11679
|
|
27
|
+
* @task T11692 — DHQ-057: per-operation output schema SSoT
|
|
28
|
+
*/
|
|
29
|
+
import { OPERATIONS, } from '@cleocode/contracts';
|
|
30
|
+
import { describeOperation as describeParams } from '@cleocode/lafs';
|
|
31
|
+
import { getInputContract } from './contracts/input-contracts.js';
|
|
32
|
+
import { getOutputContract } from './contracts/output-contracts.js';
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the {@link OperationDef} for a canonical `<domain>.<verb>` key.
|
|
35
|
+
*
|
|
36
|
+
* The first dot separates domain from operation, so dotted operation names like
|
|
37
|
+
* `"complexity.estimate"` are handled correctly. When the key has no dot, an
|
|
38
|
+
* unambiguous single-domain match is returned (else `null`).
|
|
39
|
+
*
|
|
40
|
+
* @param operation - The operation id (e.g. `"tasks.show"`).
|
|
41
|
+
* @returns The matching {@link OperationDef}, or `null` if not found / ambiguous.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
function resolveOperationDef(operation) {
|
|
46
|
+
const dotIdx = operation.indexOf('.');
|
|
47
|
+
if (dotIdx === -1) {
|
|
48
|
+
const matches = OPERATIONS.filter((op) => op.operation === operation);
|
|
49
|
+
return matches.length === 1 ? (matches[0] ?? null) : null;
|
|
50
|
+
}
|
|
51
|
+
const domain = operation.slice(0, dotIdx);
|
|
52
|
+
const op = operation.slice(dotIdx + 1);
|
|
53
|
+
return OPERATIONS.find((o) => o.domain === domain && o.operation === op) ?? null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Describe a CLEO operation's full INPUT + OUTPUT contract.
|
|
57
|
+
*
|
|
58
|
+
* The SDK entry point behind `cleo <op> --describe`. Resolves the operation by
|
|
59
|
+
* its canonical `<domain>.<verb>` id and returns a single typed
|
|
60
|
+
* {@link OperationDescriptor}, or `null` when the operation id is unknown.
|
|
61
|
+
*
|
|
62
|
+
* Contract resolution prefers an inline contract carried on the
|
|
63
|
+
* {@link OperationDef} (`def.inputSchema` / `def.outputSchema`) and falls back
|
|
64
|
+
* to the SSoT registries (`getInputContract` / `getOutputContract`). This lets
|
|
65
|
+
* a definition self-describe while keeping the registries authoritative.
|
|
66
|
+
*
|
|
67
|
+
* @param operation - Canonical `<domain>.<verb>` operation id (e.g. `"tasks.show"`).
|
|
68
|
+
* @returns The resolved descriptor, or `null` when the operation is unknown.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { describeOperation } from '@cleocode/core';
|
|
73
|
+
*
|
|
74
|
+
* const d = describeOperation('tasks.show');
|
|
75
|
+
* // d.outputContract.fieldPointers includes '/data/task/title'
|
|
76
|
+
* // → the correct pointer; '/data/title' would E_FIELD_NOT_FOUND.
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @task T11692
|
|
80
|
+
*/
|
|
81
|
+
export function describeOperation(operation) {
|
|
82
|
+
const def = resolveOperationDef(operation);
|
|
83
|
+
if (def === null)
|
|
84
|
+
return null;
|
|
85
|
+
const key = `${def.domain}.${def.operation}`;
|
|
86
|
+
const params = describeParams(def, { includeGates: true, includeExamples: true });
|
|
87
|
+
const inputContract = def.inputSchema ?? getInputContract(key);
|
|
88
|
+
const outputContract = def.outputSchema ?? getOutputContract(key);
|
|
89
|
+
return {
|
|
90
|
+
operation: key,
|
|
91
|
+
gateway: def.gateway,
|
|
92
|
+
description: def.description,
|
|
93
|
+
tier: def.tier,
|
|
94
|
+
idempotent: def.idempotent,
|
|
95
|
+
sessionRequired: def.sessionRequired,
|
|
96
|
+
params,
|
|
97
|
+
inputContract,
|
|
98
|
+
outputContract,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=describe-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-operation.js","sourceRoot":"","sources":["../../src/dispatch/describe-operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,UAAU,GAIX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,IAAI,cAAc,EAAwB,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AA2CpE;;;;;;;;;;;GAWG;AACH,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;QACtE,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;AACnF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,MAAM,GAAG,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,MAAM,aAAa,GAAG,GAAG,CAAC,WAAW,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,GAAG,CAAC,YAAY,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAElE,OAAO;QACL,SAAS,EAAE,GAAG;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,MAAM;QACN,aAAa;QACb,cAAc;KACf,CAAC;AACJ,CAAC"}
|