@cleocode/contracts 2026.5.61 → 2026.5.63
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/__tests__/llm-config-schema.test.d.ts +20 -0
- package/dist/__tests__/llm-config-schema.test.d.ts.map +1 -0
- package/dist/__tests__/llm-config-schema.test.js +121 -0
- package/dist/__tests__/llm-config-schema.test.js.map +1 -0
- package/dist/__tests__/nexus-scope-map.test.d.ts +8 -0
- package/dist/__tests__/nexus-scope-map.test.d.ts.map +1 -0
- package/dist/__tests__/nexus-scope-map.test.js +145 -0
- package/dist/__tests__/nexus-scope-map.test.js.map +1 -0
- package/dist/branch-lock.d.ts +11 -0
- package/dist/branch-lock.d.ts.map +1 -1
- package/dist/branch-lock.js +11 -0
- package/dist/branch-lock.js.map +1 -1
- package/dist/config.d.ts +116 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/data-accessor.d.ts +2 -0
- package/dist/data-accessor.d.ts.map +1 -1
- package/dist/data-accessor.js.map +1 -1
- package/dist/engine-result.d.ts +170 -0
- package/dist/engine-result.d.ts.map +1 -0
- package/dist/engine-result.js +123 -0
- package/dist/engine-result.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +31 -0
- package/dist/errors.js.map +1 -1
- package/dist/exit-codes.d.ts +8 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +7 -0
- package/dist/exit-codes.js.map +1 -1
- package/dist/graph.d.ts +88 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +35 -0
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/operations/llm.d.ts +380 -0
- package/dist/operations/llm.d.ts.map +1 -1
- package/dist/operations/nexus-scope-map.d.ts +540 -0
- package/dist/operations/nexus-scope-map.d.ts.map +1 -0
- package/dist/operations/nexus-scope-map.js +556 -0
- package/dist/operations/nexus-scope-map.js.map +1 -0
- package/dist/operations/nexus-scope.d.ts +185 -0
- package/dist/operations/nexus-scope.d.ts.map +1 -0
- package/dist/operations/nexus-scope.js +9 -0
- package/dist/operations/nexus-scope.js.map +1 -0
- package/dist/operations/session.d.ts +79 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/tasks.d.ts +28 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/worktree.d.ts +33 -0
- package/dist/operations/worktree.d.ts.map +1 -1
- package/dist/task.d.ts +17 -2
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +11 -1
- package/dist/task.js.map +1 -1
- package/dist/tasks.d.ts +0 -2
- package/dist/tasks.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/llm-config-schema.test.ts +135 -0
- package/src/__tests__/nexus-scope-map.test.ts +183 -0
- package/src/branch-lock.ts +11 -0
- package/src/config.ts +122 -5
- package/src/data-accessor.ts +3 -0
- package/src/engine-result.ts +220 -0
- package/src/errors.ts +34 -0
- package/src/exit-codes.ts +8 -0
- package/src/graph.ts +112 -0
- package/src/index.ts +82 -2
- package/src/operations/llm.ts +437 -0
- package/src/operations/nexus-scope-map.ts +597 -0
- package/src/operations/nexus-scope.ts +217 -0
- package/src/operations/session.ts +87 -0
- package/src/operations/tasks.ts +30 -0
- package/src/operations/worktree.ts +33 -0
- package/src/task.ts +30 -1
- package/src/tasks.ts +0 -2
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical EngineResult type — the single discriminated-union shape used by
|
|
3
|
+
* all SDK return paths, dispatch engines, and CLI domain handlers.
|
|
4
|
+
*
|
|
5
|
+
* Defined here in @cleocode/contracts so it is available to every consumer
|
|
6
|
+
* without creating a dependency on @cleocode/core. @cleocode/core re-exports
|
|
7
|
+
* these types and helpers transparently.
|
|
8
|
+
*
|
|
9
|
+
* @epic T1685 — T-CSL-RESET Wave 1: EngineResult canonicalization
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { LAFSPage } from '@cleocode/lafs';
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// RFC 9457 Problem Details — canonical definition (moved from core/errors.ts)
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* RFC 9457 Problem Details object.
|
|
20
|
+
* Structured error representation for API responses.
|
|
21
|
+
*
|
|
22
|
+
* @see https://www.rfc-editor.org/rfc/rfc9457
|
|
23
|
+
*/
|
|
24
|
+
export interface ProblemDetails {
|
|
25
|
+
/** URI reference identifying the problem type. */
|
|
26
|
+
type: string;
|
|
27
|
+
/** Short human-readable summary of the problem type. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** HTTP status code. */
|
|
30
|
+
status: number;
|
|
31
|
+
/** Human-readable explanation specific to this occurrence. */
|
|
32
|
+
detail: string;
|
|
33
|
+
/** URI reference identifying the specific problem instance. */
|
|
34
|
+
instance?: string;
|
|
35
|
+
/** Extension members carrying additional problem information. */
|
|
36
|
+
extensions?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// EngineResult — discriminated union
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Successful engine result branch — carries `data` and optional `page`.
|
|
45
|
+
*
|
|
46
|
+
* @task T1685 — canonical home moved to contracts
|
|
47
|
+
*/
|
|
48
|
+
export interface EngineSuccess<T = unknown> {
|
|
49
|
+
readonly success: true;
|
|
50
|
+
readonly data: T;
|
|
51
|
+
readonly page?: LAFSPage;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Structured engine error payload — carries machine-readable code + human
|
|
56
|
+
* message plus optional exitCode, details, fix hint, alternative actions,
|
|
57
|
+
* and RFC 9457 problem details.
|
|
58
|
+
*
|
|
59
|
+
* @task T1707 — problemDetails field
|
|
60
|
+
* @task T1685 — canonical home moved to contracts
|
|
61
|
+
*/
|
|
62
|
+
export interface EngineErrorPayload {
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
exitCode?: number;
|
|
66
|
+
details?: unknown;
|
|
67
|
+
fix?: string;
|
|
68
|
+
alternatives?: Array<{ action: string; command: string }>;
|
|
69
|
+
/**
|
|
70
|
+
* RFC 9457 problem details for structured error reporting.
|
|
71
|
+
*
|
|
72
|
+
* @see ProblemDetails
|
|
73
|
+
*/
|
|
74
|
+
problemDetails?: ProblemDetails;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Failed engine result branch — carries structured `error`.
|
|
79
|
+
*
|
|
80
|
+
* @task T1685 — canonical home moved to contracts
|
|
81
|
+
*/
|
|
82
|
+
export interface EngineFailure {
|
|
83
|
+
readonly success: false;
|
|
84
|
+
readonly error: EngineErrorPayload;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Canonical EngineResult — discriminated union of success and failure.
|
|
89
|
+
*
|
|
90
|
+
* Use `result.success` to narrow:
|
|
91
|
+
* - `true` → `result.data: T` is present; `result.error` does not exist
|
|
92
|
+
* - `false` → `result.error: EngineErrorPayload` is present; `result.data` does not exist
|
|
93
|
+
*
|
|
94
|
+
* @task T1685 — canonical home moved to contracts
|
|
95
|
+
*/
|
|
96
|
+
export type EngineResult<T = unknown> = EngineSuccess<T> | EngineFailure;
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Constructors
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Construct a successful EngineResult.
|
|
104
|
+
*
|
|
105
|
+
* @param data - the operation's payload
|
|
106
|
+
* @param page - optional pagination metadata
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { engineSuccess } from '@cleocode/contracts';
|
|
111
|
+
* return engineSuccess({ items: [], total: 0 });
|
|
112
|
+
* return engineSuccess(items, { mode: 'offset', limit: 10, offset: 0, total: 100, hasMore: true });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export function engineSuccess<T>(data: T, page?: LAFSPage): EngineResult<T> {
|
|
116
|
+
return page ? { success: true, data, page } : { success: true, data };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Construct a failed EngineResult with structured error.
|
|
121
|
+
*
|
|
122
|
+
* @param code - stable machine-readable error code (e.g. `'E_NOT_FOUND'`)
|
|
123
|
+
* @param message - human-readable error description
|
|
124
|
+
* @param options - optional `exitCode`, `details`, `fix`, `alternatives`, `problemDetails`
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { engineError } from '@cleocode/contracts';
|
|
129
|
+
* return engineError('E_NOT_FOUND', `Task ${id} not found`, { fix: `cleo show ${id}` });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function engineError<T = unknown>(
|
|
133
|
+
code: string,
|
|
134
|
+
message: string,
|
|
135
|
+
options?: {
|
|
136
|
+
exitCode?: number;
|
|
137
|
+
details?: unknown;
|
|
138
|
+
fix?: string;
|
|
139
|
+
alternatives?: Array<{ action: string; command: string }>;
|
|
140
|
+
problemDetails?: ProblemDetails;
|
|
141
|
+
},
|
|
142
|
+
): EngineResult<T> {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: {
|
|
146
|
+
code,
|
|
147
|
+
message,
|
|
148
|
+
...(options?.exitCode !== undefined ? { exitCode: options.exitCode } : {}),
|
|
149
|
+
...(options?.details !== undefined ? { details: options.details } : {}),
|
|
150
|
+
...(options?.fix !== undefined ? { fix: options.fix } : {}),
|
|
151
|
+
...(options?.alternatives ? { alternatives: options.alternatives } : {}),
|
|
152
|
+
...(options?.problemDetails !== undefined ? { problemDetails: options.problemDetails } : {}),
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
// unwrap() — throw-style ergonomic helper for SDK consumers
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Error thrown by {@link unwrap} when an {@link EngineResult} carries a
|
|
163
|
+
* failure. Preserves the full {@link EngineErrorPayload} shape so callers
|
|
164
|
+
* can inspect `code`, `message`, `exitCode`, `details`, `fix`,
|
|
165
|
+
* `alternatives`, and `problemDetails` after catching.
|
|
166
|
+
*
|
|
167
|
+
* @task T1725
|
|
168
|
+
*/
|
|
169
|
+
export class EngineResultError extends Error {
|
|
170
|
+
/** Machine-readable error code (e.g. `'E_NOT_FOUND'`). */
|
|
171
|
+
readonly code: string;
|
|
172
|
+
/** Numeric process exit code, if present. */
|
|
173
|
+
readonly exitCode?: number;
|
|
174
|
+
/** Structured field-level details, if present. */
|
|
175
|
+
readonly details?: unknown;
|
|
176
|
+
/** Human-readable fix hint, if present. */
|
|
177
|
+
readonly fix?: string;
|
|
178
|
+
/** Alternative actions the caller may take, if present. */
|
|
179
|
+
readonly alternatives?: Array<{ action: string; command: string }>;
|
|
180
|
+
/** RFC 9457 problem details, if present. */
|
|
181
|
+
readonly problemDetails?: ProblemDetails;
|
|
182
|
+
|
|
183
|
+
constructor(payload: EngineErrorPayload) {
|
|
184
|
+
super(payload.message);
|
|
185
|
+
this.name = 'EngineResultError';
|
|
186
|
+
this.code = payload.code;
|
|
187
|
+
if (payload.exitCode !== undefined) this.exitCode = payload.exitCode;
|
|
188
|
+
if (payload.details !== undefined) this.details = payload.details;
|
|
189
|
+
if (payload.fix !== undefined) this.fix = payload.fix;
|
|
190
|
+
if (payload.alternatives !== undefined) this.alternatives = payload.alternatives;
|
|
191
|
+
if (payload.problemDetails !== undefined) this.problemDetails = payload.problemDetails;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Unwrap an {@link EngineResult}, returning the payload data on success or
|
|
197
|
+
* throwing an {@link EngineResultError} on failure.
|
|
198
|
+
*
|
|
199
|
+
* Intended for public SDK consumers who prefer a throw-style API over the
|
|
200
|
+
* internal discriminated-union pattern. Internal dispatch code SHOULD
|
|
201
|
+
* continue using the `if (result.success)` pattern directly.
|
|
202
|
+
*
|
|
203
|
+
* @param result - an {@link EngineResult} to unwrap
|
|
204
|
+
* @returns the `data` value when `result.success` is `true`
|
|
205
|
+
* @throws {@link EngineResultError} when `result.success` is `false`
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { unwrap } from '@cleocode/contracts';
|
|
210
|
+
* const task = unwrap(await engine.getTask(id));
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @task T1725
|
|
214
|
+
*/
|
|
215
|
+
export function unwrap<T>(result: EngineResult<T>): T {
|
|
216
|
+
if (result.success) {
|
|
217
|
+
return result.data;
|
|
218
|
+
}
|
|
219
|
+
throw new EngineResultError(result.error);
|
|
220
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -199,6 +199,40 @@ export class DecisionValidatorFailedError extends Error {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Thrown when a Lead session attempts to end without delegating any work.
|
|
204
|
+
*
|
|
205
|
+
* Hard gate enforcement for T9230 (ADR-070): a Lead session with
|
|
206
|
+
* `delegate_task_count=0` and `tasks_completed > 0` is a bypass attempt.
|
|
207
|
+
* Leads MUST fan out work to Workers via `delegate_task`.
|
|
208
|
+
*
|
|
209
|
+
* @codeName E_LEAD_BYPASS_DETECTED
|
|
210
|
+
* @task T9230
|
|
211
|
+
* @adr ADR-070
|
|
212
|
+
*/
|
|
213
|
+
export class LeadBypassDetectedError extends Error {
|
|
214
|
+
/** Stable LAFS error code string for envelope emission. */
|
|
215
|
+
readonly code = 'E_LEAD_BYPASS_DETECTED';
|
|
216
|
+
/** Numeric exit code aligned with {@link ExitCode.LEAD_BYPASS_DETECTED} (107). */
|
|
217
|
+
readonly exitCode = 107;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param tasksCompleted - Number of tasks completed in the session.
|
|
221
|
+
* @param sessionId - The session ID being ended.
|
|
222
|
+
*/
|
|
223
|
+
constructor(
|
|
224
|
+
public readonly tasksCompleted: number,
|
|
225
|
+
public readonly sessionId: string,
|
|
226
|
+
) {
|
|
227
|
+
super(
|
|
228
|
+
`E_LEAD_BYPASS_DETECTED: Lead session ${sessionId} completed ${tasksCompleted} task(s) ` +
|
|
229
|
+
`without any delegate_task call. Leads MUST fan out work to Workers (T9230 / ADR-070). ` +
|
|
230
|
+
`Set CLEO_OWNER_OVERRIDE=1 with reason to override (audited).`,
|
|
231
|
+
);
|
|
232
|
+
this.name = 'LeadBypassDetectedError';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
202
236
|
/**
|
|
203
237
|
* Normalize any thrown value into a standardized error object.
|
|
204
238
|
*
|
package/src/exit-codes.ts
CHANGED
|
@@ -216,6 +216,14 @@ export enum ExitCode {
|
|
|
216
216
|
* @task T1828
|
|
217
217
|
*/
|
|
218
218
|
DECISION_VALIDATOR_FAILED = 106,
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Lead session attempted to end without delegating any work — `delegate_task_count=0`
|
|
222
|
+
* with `tasks_completed > 0`. Leads MUST fan out to Workers (T9230 / ADR-070).
|
|
223
|
+
* @codeName E_LEAD_BYPASS_DETECTED
|
|
224
|
+
* @task T9230
|
|
225
|
+
*/
|
|
226
|
+
LEAD_BYPASS_DETECTED = 107,
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
/** Check if an exit code represents an error (1-99). */
|
package/src/graph.ts
CHANGED
|
@@ -204,6 +204,118 @@ export function confidenceLabelFromNumeric(confidence: number): GraphEdgeConfide
|
|
|
204
204
|
return 'AMBIGUOUS';
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// ConfidenceProvenance — structured provenance for confidence scores
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Structured provenance for an EXTRACTED confidence assignment.
|
|
213
|
+
*
|
|
214
|
+
* Used when confidence was derived from direct AST evidence (same-file
|
|
215
|
+
* lookup, import-scoped resolution) or an explicit source annotation.
|
|
216
|
+
*
|
|
217
|
+
* @since T9145
|
|
218
|
+
*/
|
|
219
|
+
export interface ExtractedProvenance {
|
|
220
|
+
/** Discriminant. */
|
|
221
|
+
readonly kind: 'extracted';
|
|
222
|
+
/**
|
|
223
|
+
* AST / static-analysis source that produced this confidence value.
|
|
224
|
+
* Examples: `"ast"`, `"import-scope"`, `"same-file"`, `"defines"`.
|
|
225
|
+
*/
|
|
226
|
+
readonly source: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Structured provenance for an INFERRED confidence assignment.
|
|
231
|
+
*
|
|
232
|
+
* Used when confidence was derived from resolution heuristics (cross-file
|
|
233
|
+
* type lookup, heritage-map inference, name matching).
|
|
234
|
+
*
|
|
235
|
+
* @since T9145
|
|
236
|
+
*/
|
|
237
|
+
export interface InferredProvenance {
|
|
238
|
+
/** Discriminant. */
|
|
239
|
+
readonly kind: 'inferred';
|
|
240
|
+
/**
|
|
241
|
+
* Heuristic or rule that produced this confidence value.
|
|
242
|
+
* Examples: `"heritage-map"`, `"name-match"`, `"global-tier"`.
|
|
243
|
+
*/
|
|
244
|
+
readonly heuristic: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Structured provenance for an AMBIGUOUS confidence assignment.
|
|
249
|
+
*
|
|
250
|
+
* Used when confidence is low because multiple candidates were found,
|
|
251
|
+
* the parent is external / unresolvable, or resolution fell to a global stub.
|
|
252
|
+
*
|
|
253
|
+
* @since T9145
|
|
254
|
+
*/
|
|
255
|
+
export interface AmbiguousProvenance {
|
|
256
|
+
/** Discriminant. */
|
|
257
|
+
readonly kind: 'ambiguous';
|
|
258
|
+
/**
|
|
259
|
+
* Candidate node IDs that competed for this resolution slot.
|
|
260
|
+
* May be empty when the ambiguity is due to an unresolvable external type.
|
|
261
|
+
*/
|
|
262
|
+
readonly candidates: ReadonlyArray<string>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Discriminated union of structured confidence provenance variants.
|
|
267
|
+
*
|
|
268
|
+
* Replaces the bare numeric `confidence` field on {@link GraphRelation} as
|
|
269
|
+
* part of the Beta gradient deprecation (phase 0: addition, phase 1:
|
|
270
|
+
* co-existence, removal at v2026.9).
|
|
271
|
+
*
|
|
272
|
+
* **Backfill mapping** for existing records created without structured
|
|
273
|
+
* provenance:
|
|
274
|
+
* - `confidence === 1.0` → `{ kind: 'extracted', source: 'ast' }`
|
|
275
|
+
* - `confidence >= 0.90` → `{ kind: 'extracted', source: 'legacy' }`
|
|
276
|
+
* - `confidence >= 0.80` → `{ kind: 'inferred', heuristic: 'legacy' }`
|
|
277
|
+
* - `confidence < 0.80` → `{ kind: 'ambiguous', candidates: [] }`
|
|
278
|
+
*
|
|
279
|
+
* @since T9145
|
|
280
|
+
* @deprecated Numeric `confidence` on {@link GraphRelation} will be removed in v2026.9.
|
|
281
|
+
* Use `confidenceProvenance` instead. Migration: `confidenceFromProvenance()` maps back.
|
|
282
|
+
*/
|
|
283
|
+
export type ConfidenceProvenance = ExtractedProvenance | InferredProvenance | AmbiguousProvenance;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Backfill a {@link ConfidenceProvenance} from a legacy numeric confidence value.
|
|
287
|
+
*
|
|
288
|
+
* @param confidence - Numeric confidence in range [0.0, 1.0]
|
|
289
|
+
* @returns A structured provenance record consistent with the numeric value
|
|
290
|
+
* @since T9145
|
|
291
|
+
*/
|
|
292
|
+
export function provenanceFromNumeric(confidence: number): ConfidenceProvenance {
|
|
293
|
+
if (confidence === 1.0) return { kind: 'extracted', source: 'ast' };
|
|
294
|
+
if (confidence >= 0.9) return { kind: 'extracted', source: 'legacy' };
|
|
295
|
+
if (confidence >= 0.8) return { kind: 'inferred', heuristic: 'legacy' };
|
|
296
|
+
return { kind: 'ambiguous', candidates: [] };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Recover a numeric confidence value from a {@link ConfidenceProvenance} record.
|
|
301
|
+
*
|
|
302
|
+
* Inverse of {@link provenanceFromNumeric} for backward-compat bridging.
|
|
303
|
+
*
|
|
304
|
+
* @param provenance - Structured provenance record
|
|
305
|
+
* @returns Best-effort numeric confidence in range [0.0, 1.0]
|
|
306
|
+
* @since T9145
|
|
307
|
+
*/
|
|
308
|
+
export function confidenceFromProvenance(provenance: ConfidenceProvenance): number {
|
|
309
|
+
switch (provenance.kind) {
|
|
310
|
+
case 'extracted':
|
|
311
|
+
return provenance.source === 'ast' ? 1.0 : 0.95;
|
|
312
|
+
case 'inferred':
|
|
313
|
+
return 0.85;
|
|
314
|
+
case 'ambiguous':
|
|
315
|
+
return 0.5;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
207
319
|
// ---------------------------------------------------------------------------
|
|
208
320
|
// Relation interface
|
|
209
321
|
// ---------------------------------------------------------------------------
|
package/src/index.ts
CHANGED
|
@@ -219,7 +219,10 @@ export type {
|
|
|
219
219
|
LifecycleConfig,
|
|
220
220
|
LifecycleEnforcementMode,
|
|
221
221
|
LlmConfig,
|
|
222
|
+
LlmDefaultConfig,
|
|
222
223
|
LlmProviderEntry,
|
|
224
|
+
LlmRoleConfig,
|
|
225
|
+
LlmTransport,
|
|
223
226
|
LoggingConfig,
|
|
224
227
|
LogLevel,
|
|
225
228
|
MemoryBridgeMode,
|
|
@@ -227,6 +230,7 @@ export type {
|
|
|
227
230
|
OutputFormat,
|
|
228
231
|
ProviderConfig,
|
|
229
232
|
ResolvedValue,
|
|
233
|
+
RoleName,
|
|
230
234
|
SessionConfig,
|
|
231
235
|
SessionSummaryInput,
|
|
232
236
|
SharingConfig,
|
|
@@ -265,6 +269,20 @@ export type {
|
|
|
265
269
|
StoreDocParams,
|
|
266
270
|
StoreDocResult,
|
|
267
271
|
} from './docs-accessor.js';
|
|
272
|
+
export type {
|
|
273
|
+
EngineErrorPayload,
|
|
274
|
+
EngineFailure,
|
|
275
|
+
EngineResult,
|
|
276
|
+
EngineSuccess,
|
|
277
|
+
ProblemDetails,
|
|
278
|
+
} from './engine-result.js';
|
|
279
|
+
// === EngineResult — canonical discriminated-union SDK type (T1685) ===
|
|
280
|
+
export {
|
|
281
|
+
EngineResultError,
|
|
282
|
+
engineError,
|
|
283
|
+
engineSuccess,
|
|
284
|
+
unwrap,
|
|
285
|
+
} from './engine-result.js';
|
|
268
286
|
// === Error Utilities ===
|
|
269
287
|
export {
|
|
270
288
|
ClassifierUnregisteredAgentError,
|
|
@@ -275,6 +293,7 @@ export {
|
|
|
275
293
|
getErrorMessage,
|
|
276
294
|
isErrorResult,
|
|
277
295
|
isErrorType,
|
|
296
|
+
LeadBypassDetectedError,
|
|
278
297
|
LifecycleScopeDeniedError,
|
|
279
298
|
normalizeError,
|
|
280
299
|
ThinAgentViolationError,
|
|
@@ -352,20 +371,28 @@ export {
|
|
|
352
371
|
AGENT_TYPES,
|
|
353
372
|
BRAIN_OBSERVATION_TYPES,
|
|
354
373
|
} from './facade.js';
|
|
355
|
-
// === Graph Intelligence Types (T512, T529, T1862) ===
|
|
374
|
+
// === Graph Intelligence Types (T512, T529, T1862, T9145) ===
|
|
356
375
|
export type {
|
|
376
|
+
AmbiguousProvenance,
|
|
357
377
|
CommunityNode,
|
|
378
|
+
ConfidenceProvenance,
|
|
379
|
+
ExtractedProvenance,
|
|
358
380
|
GraphEdgeConfidenceLabel,
|
|
359
381
|
GraphNode,
|
|
360
382
|
GraphNodeKind,
|
|
361
383
|
GraphRelation,
|
|
362
384
|
GraphRelationType,
|
|
363
385
|
ImpactResult,
|
|
386
|
+
InferredProvenance,
|
|
364
387
|
KnowledgeGraph,
|
|
365
388
|
ProcessNode,
|
|
366
389
|
SymbolIndex,
|
|
367
390
|
} from './graph.js';
|
|
368
|
-
export {
|
|
391
|
+
export {
|
|
392
|
+
confidenceFromProvenance,
|
|
393
|
+
confidenceLabelFromNumeric,
|
|
394
|
+
provenanceFromNumeric,
|
|
395
|
+
} from './graph.js';
|
|
369
396
|
export type { AdapterHookProvider } from './hooks.js';
|
|
370
397
|
export type { AdapterInstallProvider, InstallOptions, InstallResult } from './install.js';
|
|
371
398
|
export type {
|
|
@@ -591,6 +618,35 @@ export type {
|
|
|
591
618
|
LifecycleStatusResult,
|
|
592
619
|
StageRecord,
|
|
593
620
|
} from './operations/lifecycle.js';
|
|
621
|
+
// === LLM Credential + Role-Resolver Wire Types (T-LLM-CRED Phase 1/2 — T9255) ===
|
|
622
|
+
export type {
|
|
623
|
+
AuthTypeWire,
|
|
624
|
+
CredentialResultWire,
|
|
625
|
+
CredentialSourceWire,
|
|
626
|
+
CredentialsStoreStrategyWire,
|
|
627
|
+
// `cleo llm` CLI / dispatch operation contracts (T9258)
|
|
628
|
+
LlmAddParams,
|
|
629
|
+
LlmAddResult,
|
|
630
|
+
LlmListParams,
|
|
631
|
+
LlmListResult,
|
|
632
|
+
LlmProfileParams,
|
|
633
|
+
LlmProfileResult,
|
|
634
|
+
LlmRemoveParams,
|
|
635
|
+
LlmRemoveResult,
|
|
636
|
+
LlmStoredCredentialView,
|
|
637
|
+
LlmTestParams,
|
|
638
|
+
LlmTestResult,
|
|
639
|
+
LlmUseParams,
|
|
640
|
+
LlmUseResult,
|
|
641
|
+
LlmWhoamiEntry,
|
|
642
|
+
LlmWhoamiParams,
|
|
643
|
+
LlmWhoamiResult,
|
|
644
|
+
ModelTransport,
|
|
645
|
+
ResolutionSource,
|
|
646
|
+
ResolvedLLM,
|
|
647
|
+
ResolveLLMForRoleOptions,
|
|
648
|
+
StoredAuthTypeWire,
|
|
649
|
+
} from './operations/llm.js';
|
|
594
650
|
// Multi-pass retrieval bundle types (PSYCHE Wave 4 · T1090)
|
|
595
651
|
export type {
|
|
596
652
|
PassMask,
|
|
@@ -752,6 +808,23 @@ export type {
|
|
|
752
808
|
NexusWhyResult,
|
|
753
809
|
NexusWikiParams,
|
|
754
810
|
} from './operations/nexus.js';
|
|
811
|
+
// === Nexus Scope Contracts (T9145 + T9146) ===
|
|
812
|
+
export type {
|
|
813
|
+
MetaWithNexusScope,
|
|
814
|
+
NexusBindingSource,
|
|
815
|
+
NexusEffect,
|
|
816
|
+
NexusOperationDescriptor,
|
|
817
|
+
NexusScope,
|
|
818
|
+
NexusScopeMeta,
|
|
819
|
+
NexusStore,
|
|
820
|
+
ScopeBinding,
|
|
821
|
+
SuggestedNextOp,
|
|
822
|
+
} from './operations/nexus-scope.js';
|
|
823
|
+
export {
|
|
824
|
+
getNexusDescriptor,
|
|
825
|
+
listOpsByScope,
|
|
826
|
+
NEXUS_SCOPE_MAP,
|
|
827
|
+
} from './operations/nexus-scope-map.js';
|
|
755
828
|
// === NEXUS User Profile Types (T1076 PSYCHE Wave 1) ===
|
|
756
829
|
// Re-exported at top level so @cleocode/core/nexus and CLI dispatch can
|
|
757
830
|
// import without the `ops.` namespace hop.
|
|
@@ -812,6 +885,10 @@ export type {
|
|
|
812
885
|
// Session operation param/result types — re-exported at top level for typed-dispatch consumers
|
|
813
886
|
// (T975 Wave D · ADR-051 migration)
|
|
814
887
|
export type {
|
|
888
|
+
BriefingExcludeProvenance,
|
|
889
|
+
BriefingFieldContract,
|
|
890
|
+
BriefingFieldRule,
|
|
891
|
+
ContractViolation,
|
|
815
892
|
DecisionRecord,
|
|
816
893
|
SessionBriefingShowParams,
|
|
817
894
|
SessionBriefingShowResult,
|
|
@@ -894,6 +971,8 @@ export type {
|
|
|
894
971
|
TasksRelatesAddParams,
|
|
895
972
|
TasksRelatesAddResult,
|
|
896
973
|
TasksRelatesParams,
|
|
974
|
+
TasksRelatesRemoveParams,
|
|
975
|
+
TasksRelatesRemoveResult,
|
|
897
976
|
TasksRelatesResult,
|
|
898
977
|
TasksReorderDispatchResult,
|
|
899
978
|
TasksReorderQueryParams,
|
|
@@ -1199,6 +1278,7 @@ export type {
|
|
|
1199
1278
|
VerificationFailure,
|
|
1200
1279
|
VerificationGate,
|
|
1201
1280
|
} from './task.js';
|
|
1281
|
+
export { isTestFixtureOrigin, TASK_ORIGIN_CANONICAL } from './task.js';
|
|
1202
1282
|
// === Task Evidence Types (T801) ===
|
|
1203
1283
|
export type {
|
|
1204
1284
|
CommandOutputEvidence,
|