@cleocode/runtime 2026.10.13-rc.ci.682 → 2026.10.14-rc.ci.683
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.
|
@@ -1,7 +1,140 @@
|
|
|
1
1
|
import './gateway-handler-DCU6E0a2.js';
|
|
2
|
-
import { SuggestedNextOp, OperationDef, Resolution } from '@cleocode/contracts';
|
|
3
|
-
import '@cleocode/contracts/engine-result.js';
|
|
2
|
+
import { EngineResult, ProblemDetails, SuggestedNextOp, OperationDef, Resolution } from '@cleocode/contracts';
|
|
4
3
|
import { Source, DispatchResponse, DispatchResponseMeta, Middleware, Gateway, CanonicalDomain, Tier } from '@cleocode/contracts/gateway';
|
|
4
|
+
import '@cleocode/contracts/engine-result.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Centralized engine error helper for the transport-agnostic gateway.
|
|
8
|
+
*
|
|
9
|
+
* Every domain handler (and the engine barrel) imports `engineError()` /
|
|
10
|
+
* `engineSuccess()` from this module to produce consistently typed error
|
|
11
|
+
* results with correct exit codes and pino logging.
|
|
12
|
+
*
|
|
13
|
+
* The STRING_TO_EXIT map is the canonical mapping from string error codes
|
|
14
|
+
* to numeric exit codes. It mirrors ERROR_CODE_TO_EXIT in cli.ts.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Relocated from `packages/cleo/src/dispatch/engines/_error.ts` into
|
|
18
|
+
* `@cleocode/runtime/gateway` (R3-K1 · T11455 · SG-RUNTIME-UNIFICATION) so the
|
|
19
|
+
* runtime owns the shared handler dependencies and can assemble the handler map
|
|
20
|
+
* without importing `@cleocode/cleo`. A thin re-export shim remains at the old
|
|
21
|
+
* `engines/_error.ts` path so in-package import sites compile unchanged.
|
|
22
|
+
*
|
|
23
|
+
* Error codes are organized into numeric ranges:
|
|
24
|
+
* - 1-9: General errors (invalid input, file, dependency, validation)
|
|
25
|
+
* - 10-19: Hierarchy errors (parent, depth, siblings, circular deps)
|
|
26
|
+
* - 20-29: Concurrency errors (checksum, modification, collision)
|
|
27
|
+
* - 30-39: Session errors (scope, claims, active task)
|
|
28
|
+
* - 40-47: Verification errors (gates, agents, rounds)
|
|
29
|
+
* - 50-54: Context safeguard (warning through emergency)
|
|
30
|
+
* - 60-67: Orchestrator / protocol errors
|
|
31
|
+
* - 70-79: Nexus errors
|
|
32
|
+
* - 80-94: Lifecycle, artifact, provenance errors
|
|
33
|
+
* - 95-99: Adapter errors
|
|
34
|
+
* - 100+: Special informational codes (not errors)
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Canonical mapping from string error codes to numeric exit codes.
|
|
39
|
+
*
|
|
40
|
+
* Source of truth: src/types/exit-codes.ts (ExitCode enum).
|
|
41
|
+
* Must stay in sync with ERROR_CODE_TO_EXIT in src/dispatch/adapters/cli.ts.
|
|
42
|
+
*/
|
|
43
|
+
declare const STRING_TO_EXIT: Record<string, number>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a typed engine error result with pino logging and correct exit code.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* The exit code is derived from the {@link STRING_TO_EXIT} mapping. If the
|
|
49
|
+
* code is not found in the map, exit code 1 (general error) is used.
|
|
50
|
+
* Pino logging is automatically triggered at the appropriate level
|
|
51
|
+
* (error for internal issues, warn for user/domain errors, debug for
|
|
52
|
+
* informational codes). Logging is suppressed under Vitest to keep
|
|
53
|
+
* test output clean.
|
|
54
|
+
*
|
|
55
|
+
* @param code - String error code (e.g., 'E_NOT_FOUND')
|
|
56
|
+
* @param message - Human-readable error message
|
|
57
|
+
* @param options - Optional details, fix command, and alternatives
|
|
58
|
+
* @returns EngineResult with success=false and properly structured error
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { engineError } from './_error.js';
|
|
63
|
+
*
|
|
64
|
+
* return engineError('E_NOT_FOUND', `Task ${id} not found`, {
|
|
65
|
+
* fix: `cleo show ${id}`,
|
|
66
|
+
* details: { taskId: id },
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function engineError<T>(code: string, message: string, options?: {
|
|
71
|
+
exitCode?: number;
|
|
72
|
+
details?: Record<string, unknown>;
|
|
73
|
+
fix?: string;
|
|
74
|
+
alternatives?: Array<{
|
|
75
|
+
action: string;
|
|
76
|
+
command: string;
|
|
77
|
+
}>;
|
|
78
|
+
problemDetails?: ProblemDetails;
|
|
79
|
+
}): EngineResult<T>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Minimal meta shape carrying the request ID for RFC 7807 `instance` population.
|
|
83
|
+
*
|
|
84
|
+
* Callers may pass the dispatch-layer `DispatchRequest.requestId` (or any
|
|
85
|
+
* other correlation identifier) so that the resulting `problemDetails.instance`
|
|
86
|
+
* URI uniquely identifies the specific error occurrence.
|
|
87
|
+
*/
|
|
88
|
+
interface ErrorMeta {
|
|
89
|
+
/** Unique request identifier (used as the RFC 7807 `instance` field). */
|
|
90
|
+
requestId?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Convert any caught value into an {@link EngineResult}, forwarding the rich
|
|
94
|
+
* `fix`, `details`, and `alternatives` fields when the caught value is a
|
|
95
|
+
* `CleoError` (or structurally compatible object).
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* This is the canonical catch-block helper for all dispatch engines. It
|
|
99
|
+
* replaces the previous pattern of:
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const code = (err as { code?: number })?.code;
|
|
102
|
+
* if (code === 4) return engineError('E_NOT_FOUND', …);
|
|
103
|
+
* …
|
|
104
|
+
* ```
|
|
105
|
+
* with a single call that preserves every field the core layer attached.
|
|
106
|
+
*
|
|
107
|
+
* The `fallbackCode` is used when the numeric `err.code` is not present in
|
|
108
|
+
* the {@link STRING_TO_EXIT} mapping (e.g. unknown exit codes, plain `Error`
|
|
109
|
+
* instances, or values thrown by non-CLEO code).
|
|
110
|
+
*
|
|
111
|
+
* RFC 7807 `problemDetails` is always populated from the resolved code, message,
|
|
112
|
+
* and exit code. The optional `meta.requestId` is forwarded to the `instance`
|
|
113
|
+
* field so every error occurrence is uniquely identifiable.
|
|
114
|
+
*
|
|
115
|
+
* @param err - The caught value (unknown type)
|
|
116
|
+
* @param fallbackCode - String error code to use when mapping fails
|
|
117
|
+
* @param fallbackMessage - Human-readable message when `err.message` is absent
|
|
118
|
+
* @param meta - Optional dispatch meta carrying `requestId` for RFC 7807 `instance`
|
|
119
|
+
* @returns EngineResult with all available rich fields propagated
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import { cleoErrorToEngineError } from './_error.js';
|
|
124
|
+
*
|
|
125
|
+
* } catch (err: unknown) {
|
|
126
|
+
* return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'Task database not initialized');
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example With requestId for RFC 7807 instance field:
|
|
131
|
+
* ```typescript
|
|
132
|
+
* } catch (err: unknown) {
|
|
133
|
+
* return cleoErrorToEngineError(err, 'E_NOT_FOUND', 'Not found', { requestId });
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
declare function cleoErrorToEngineError<T>(err: unknown, fallbackCode: string, fallbackMessage: string, meta?: ErrorMeta): EngineResult<T>;
|
|
5
138
|
|
|
6
139
|
/**
|
|
7
140
|
* Dispatch-local metadata factory.
|
|
@@ -287,4 +420,4 @@ declare function getCounts(): {
|
|
|
287
420
|
total: number;
|
|
288
421
|
};
|
|
289
422
|
|
|
290
|
-
export { BRAIN_DB_FILENAME as B, CLEO_DIR_NAME as C, OPERATIONS as O,
|
|
423
|
+
export { BRAIN_DB_FILENAME as B, CLEO_DIR_NAME as C, type ErrorMeta as E, OPERATIONS as O, STRING_TO_EXIT as S, WORKFLOWS_SUBDIR as W, type StreamResolution as a, buildNexusMetaExtensions as b, cleoErrorToEngineError as c, compose as d, createDispatchMeta as e, deriveGatewayMatrix as f, engineError as g, formatSuggestedNext as h, getActiveDomains as i, getByDomain as j, getByGateway as k, getByTier as l, getCounts as m, getGatewayDomains as n, inferGateway as o, pickDecoratorMetaExtensions as p, resolveStreamRoute as q, resolve as r, stampNexusMeta as s, validateSuggestedNext as t, validateRequiredParams as v };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { D as Dispatcher, a as DispatcherConfig, G as GatewayHandler, c as createGatewayHandler } from '../gateway-handler-DCU6E0a2.js';
|
|
2
|
+
export { B as BRAIN_DB_FILENAME, C as CLEO_DIR_NAME, O as OPERATIONS, W as WORKFLOWS_SUBDIR, b as buildNexusMetaExtensions, c as cleoErrorToEngineError, d as compose, e as createDispatchMeta, f as deriveGatewayMatrix, h as formatSuggestedNext, i as getActiveDomains, j as getByDomain, k as getByGateway, l as getByTier, m as getCounts, n as getGatewayDomains, p as pickDecoratorMetaExtensions, r as resolve, s as stampNexusMeta, v as validateRequiredParams, t as validateSuggestedNext } from '../dispatch-DOd44kC3.js';
|
|
2
3
|
export { OperationDef, Resolution } from '@cleocode/contracts';
|
|
3
4
|
export { engineSuccess } from '@cleocode/contracts/engine-result.js';
|
|
4
|
-
export { B as BRAIN_DB_FILENAME, C as CLEO_DIR_NAME, O as OPERATIONS, W as WORKFLOWS_SUBDIR, b as buildNexusMetaExtensions, c as compose, a as createDispatchMeta, d as deriveGatewayMatrix, f as formatSuggestedNext, g as getActiveDomains, e as getByDomain, h as getByGateway, i as getByTier, j as getCounts, k as getGatewayDomains, p as pickDecoratorMetaExtensions, r as resolve, s as stampNexusMeta, v as validateRequiredParams, n as validateSuggestedNext } from '../dispatch-BWjVeeMg.js';
|
|
5
5
|
import '@cleocode/contracts/gateway';
|
package/dist/gateway/dispatch.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Dispatcher,
|
|
5
5
|
WORKFLOWS_SUBDIR,
|
|
6
6
|
buildNexusMetaExtensions,
|
|
7
|
+
cleoErrorToEngineError,
|
|
7
8
|
compose,
|
|
8
9
|
createDispatchMeta,
|
|
9
10
|
createGatewayHandler,
|
|
@@ -32,6 +33,7 @@ export {
|
|
|
32
33
|
OPERATIONS,
|
|
33
34
|
WORKFLOWS_SUBDIR,
|
|
34
35
|
buildNexusMetaExtensions,
|
|
36
|
+
cleoErrorToEngineError,
|
|
35
37
|
compose,
|
|
36
38
|
createDispatchMeta,
|
|
37
39
|
createGatewayHandler,
|
package/dist/gateway/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackgroundJobManager } from '@cleocode/core/store/background-jobs.js';
|
|
2
2
|
export { BackgroundJob, BackgroundJobManager, BackgroundJobManagerConfig, BackgroundJobStatus, DurableJobStore } from '@cleocode/core/store/background-jobs.js';
|
|
3
|
-
import { Subsystem
|
|
3
|
+
import { Subsystem } from '@cleocode/contracts';
|
|
4
4
|
export { MinimalTaskRecord, OperationDef, Resolution, Session as SessionRecord, TaskRecord } from '@cleocode/contracts';
|
|
5
5
|
import { HttpServerHandle, HttpServerOptions } from './http/index.js';
|
|
6
6
|
export { GatewayStreamSource, HttpUnaryRequest, HttpUnaryResult, SSE_HEADERS, STUDIO_PREFIX, SseEmitter, SseFrame, SseSource, StreamSourceContext, StreamSourceTeardown, StudioStaticOptions, createSseStream, encodeSseFrame, encodeStreamEvent, isStudioPath, mimeType, parseHttpRoute, registerStreamSource, resolveStreamSource, resolveStudioAssetPath, resolveStudioStaticDir, routeUnary, serveStudioStatic, startHttpServer, statusForResponse, tickStreamSource, writeBundleAbsentError } from './http/index.js';
|
|
@@ -11,10 +11,10 @@ export { D as Dispatcher, a as DispatcherConfig, c as createGatewayHandler } fro
|
|
|
11
11
|
export { OrchestratePlanResult } from '@cleocode/contracts/operations/orchestrate';
|
|
12
12
|
import * as _cleocode_core_internal from '@cleocode/core/internal';
|
|
13
13
|
export { ArchiveStatsResult as ArchiveStatsData, AuditResult as AuditData, BackupResult as BackupData, BackupEntry as BackupEntryData, CleanupResult as CleanupData, CompactTask, ComplianceData, ContextData, DashboardData, DecisionRecord, DiagnosticsResult as DiagnosticsData, FileRestoreResult, HealthResult as HealthData, HelpData, HookMatrixResult, InjectGenerateResult as InjectGenerateData, IssueTemplate, IvtrHistoryEntry, LabelsResult as LabelsData, LifecycleStageEntry, LogQueryData, SystemMetricsResult as MetricsData, MigrateResult as MigrateData, OrchestratePlanInput, PathsData, PlanWarning, PlanWave, PlanWorkerEntry, ProviderMatrixEntry, ManifestEntry as ResearchManifestEntry, RestoreResult as RestoreData, RuntimeDiagnostics as RuntimeData, SafestopResult as SafestopData, ScaffoldHubData, StatsData, SyncData, TemplateConfig, TemplateSection, UncancelResult as UncancelData, addTaskWithSessionScope, completeTaskStrict, configGet, configListPresets, configSet, configSetPreset, ensureInitialized, filterEntries as filterManifestEntries, getVersion, initProject, isAutoInitEnabled, lifecycleCheck, lifecycleGateFail, lifecycleGatePass, lifecycleGates, lifecycleHistory, lifecyclePrerequisites, lifecycleProgress, lifecycleReset, lifecycleSkip, lifecycleStatus, mapCodebase, memoryBrainStats, memoryContradictions, memoryDecisionFind, memoryDecisionStore, memoryFetch, memoryFind, memoryGraphAdd, memoryGraphContext, memoryGraphNeighbors, memoryGraphRelated, memoryGraphRemove, memoryGraphShow, memoryGraphStatsFull, memoryGraphTrace, memoryLearningFind, memoryLearningStats, memoryLearningStore, memoryLink, memoryObserve, memoryPatternFind, memoryPatternStats, memoryPatternStore, memoryQualityReport, memoryReasonSimilar, memoryReasonWhy, memorySearchHybrid, memoryShow, memorySuperseded, memoryTimeline, memoryUnlink, orchestrateAnalyze, orchestrateBootstrap, orchestrateCheck, orchestrateContext, orchestrateCriticalPath, orchestrateHandoff, orchestrateNext, orchestrateParallelEnd, orchestrateParallelStart, orchestratePlan, orchestrateReady, orchestrateReport, orchestrateSkillInject, orchestrateSpawn, orchestrateSpawnExecute, orchestrateStartup, orchestrateStatus, orchestrateUnblockOpportunities, orchestrateValidate, orchestrateWaves, phaseAdvance, phaseComplete, phaseDelete, phaseList, phaseRename, phaseSet, phaseShow, phaseStart, pipelineManifestAppend, pipelineManifestArchive, pipelineManifestFind, pipelineManifestList, pipelineManifestPending, pipelineManifestShow, pipelineManifestStats, queryCommonHooks, queryHookProviders, readManifestEntries, releaseCancel, releaseCommit, releaseGateCheck, releaseGatesRun, releaseIvtrAutoSuggest, releaseList, releaseOpen, releasePlan, releasePrStatus, releasePrepare, releasePush, releaseReconcileV2, releaseRollback, releaseRollbackFull, releaseShow, releaseTag, sessionAdopt, sessionArchive, sessionBriefing, sessionChainShow, sessionCleanup, sessionComputeDebrief, sessionComputeHandoff, sessionContextDrift, sessionContextInject, sessionDebriefShow, sessionDecisionLog, sessionEnd, sessionFind, sessionGc, sessionHandoff, sessionHistory, sessionList, sessionRecordAssumption, sessionRecordDecision, sessionResume, sessionShow, sessionStart, sessionStats, sessionStatus, sessionSuspend, sessionSwitch, systemHooksMatrix, taskAnalyze, taskArchive, taskAssignee, taskBatchValidate, taskBlockers, taskBulkMove, taskCancel, taskClaim, taskComplete, taskComplexityEstimate, taskCurrentGet, taskDecompose, taskDelete, taskDepends, taskDeps, taskDepsCycles, taskDepsOverview, taskDepsTree, taskDepsValidate, taskExists, taskExport, taskFind, taskHistory, taskImpact, taskImport, taskLabelList, taskLabelShow, taskLint, taskList, taskNext, taskPlan, taskPromote, taskRankingHistory, taskRankingRevert, taskReconcileScope, taskRelates, taskRelatesAdd, taskRelatesAddBatch, taskRelatesFind, taskRelatesRemove, taskReopen, taskReorder, taskReorderRank, taskReparent, taskRestore, taskShow, taskShowIvtrHistory, taskShowOperation, taskShowWithHistory, taskSlice, taskStart, taskStats, taskStop, taskSyncLinks, taskSyncLinksRemove, taskSyncReconcile, taskTree, taskUnarchive, taskUnclaim, taskUpdate, taskWorkHistory, tasksAddBatchOp, coreBatchValidate as validateBatchValidate, validateChangelog, coreCoherenceCheck as validateCoherenceCheck, coreComplianceRecord as validateComplianceRecord, coreComplianceSummary as validateComplianceSummary, coreComplianceViolations as validateComplianceViolations, validateGateVerify, coreValidateManifest as validateManifestOp, coreValidateOutput as validateOutput, coreValidateProtocol as validateProtocol, validateProtocolArchitectureDecision, validateProtocolArtifactPublish, validateProtocolConsensus, validateProtocolContribution, validateProtocolDecomposition, validateProtocolImplementation, validateProtocolProvenance, validateProtocolRelease, validateProtocolResearch, validateProtocolSpecification, validateProtocolTesting, validateProtocolValidation, coreValidateSchema as validateSchemaOp, coreValidateTask as validateTaskOp, coreTestCoverage as validateTestCoverage, coreTestRun as validateTestRun, coreTestStatus as validateTestStatus } from '@cleocode/core/internal';
|
|
14
|
-
import { EngineResult
|
|
14
|
+
import { EngineResult } from '@cleocode/core';
|
|
15
15
|
export { EngineResult } from '@cleocode/core';
|
|
16
|
+
export { B as BRAIN_DB_FILENAME, C as CLEO_DIR_NAME, E as ErrorMeta, O as OPERATIONS, S as STRING_TO_EXIT, a as StreamResolution, W as WORKFLOWS_SUBDIR, b as buildNexusMetaExtensions, c as cleoErrorToEngineError, d as compose, e as createDispatchMeta, f as deriveGatewayMatrix, g as engineError, h as formatSuggestedNext, i as getActiveDomains, j as getByDomain, k as getByGateway, l as getByTier, m as getCounts, n as getGatewayDomains, o as inferGateway, p as pickDecoratorMetaExtensions, r as resolve, q as resolveStreamRoute, s as stampNexusMeta, v as validateRequiredParams, t as validateSuggestedNext } from '../dispatch-DOd44kC3.js';
|
|
16
17
|
export { GatewayOperationKey, MCP_TOOL_PREFIX, McpContent, McpInputProperty, McpServerOptions, McpTool, McpToolResult, buildToolsList, callTool, exposedOperations, operationToMcpTool, operationToToolName, startMcpServer, toolNameToOperationKey } from './mcp/index.js';
|
|
17
|
-
export { B as BRAIN_DB_FILENAME, C as CLEO_DIR_NAME, O as OPERATIONS, S as StreamResolution, W as WORKFLOWS_SUBDIR, b as buildNexusMetaExtensions, c as compose, a as createDispatchMeta, d as deriveGatewayMatrix, f as formatSuggestedNext, g as getActiveDomains, e as getByDomain, h as getByGateway, i as getByTier, j as getCounts, k as getGatewayDomains, l as inferGateway, p as pickDecoratorMetaExtensions, r as resolve, m as resolveStreamRoute, s as stampNexusMeta, v as validateRequiredParams, n as validateSuggestedNext } from '../dispatch-BWjVeeMg.js';
|
|
18
18
|
export { engineSuccess } from '@cleocode/contracts/engine-result.js';
|
|
19
19
|
import 'node:http';
|
|
20
20
|
import '@cleocode/contracts/gateway';
|
|
@@ -166,139 +166,6 @@ declare function gatewaySubsystemName(scope: GatewayScope): string;
|
|
|
166
166
|
*/
|
|
167
167
|
declare function defineGatewaySubsystem(opts: GatewaySubsystemOptions): Subsystem<GatewaySubsystemContext>;
|
|
168
168
|
|
|
169
|
-
/**
|
|
170
|
-
* Centralized engine error helper for the transport-agnostic gateway.
|
|
171
|
-
*
|
|
172
|
-
* Every domain handler (and the engine barrel) imports `engineError()` /
|
|
173
|
-
* `engineSuccess()` from this module to produce consistently typed error
|
|
174
|
-
* results with correct exit codes and pino logging.
|
|
175
|
-
*
|
|
176
|
-
* The STRING_TO_EXIT map is the canonical mapping from string error codes
|
|
177
|
-
* to numeric exit codes. It mirrors ERROR_CODE_TO_EXIT in cli.ts.
|
|
178
|
-
*
|
|
179
|
-
* @remarks
|
|
180
|
-
* Relocated from `packages/cleo/src/dispatch/engines/_error.ts` into
|
|
181
|
-
* `@cleocode/runtime/gateway` (R3-K1 · T11455 · SG-RUNTIME-UNIFICATION) so the
|
|
182
|
-
* runtime owns the shared handler dependencies and can assemble the handler map
|
|
183
|
-
* without importing `@cleocode/cleo`. A thin re-export shim remains at the old
|
|
184
|
-
* `engines/_error.ts` path so in-package import sites compile unchanged.
|
|
185
|
-
*
|
|
186
|
-
* Error codes are organized into numeric ranges:
|
|
187
|
-
* - 1-9: General errors (invalid input, file, dependency, validation)
|
|
188
|
-
* - 10-19: Hierarchy errors (parent, depth, siblings, circular deps)
|
|
189
|
-
* - 20-29: Concurrency errors (checksum, modification, collision)
|
|
190
|
-
* - 30-39: Session errors (scope, claims, active task)
|
|
191
|
-
* - 40-47: Verification errors (gates, agents, rounds)
|
|
192
|
-
* - 50-54: Context safeguard (warning through emergency)
|
|
193
|
-
* - 60-67: Orchestrator / protocol errors
|
|
194
|
-
* - 70-79: Nexus errors
|
|
195
|
-
* - 80-94: Lifecycle, artifact, provenance errors
|
|
196
|
-
* - 95-99: Adapter errors
|
|
197
|
-
* - 100+: Special informational codes (not errors)
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Canonical mapping from string error codes to numeric exit codes.
|
|
202
|
-
*
|
|
203
|
-
* Source of truth: src/types/exit-codes.ts (ExitCode enum).
|
|
204
|
-
* Must stay in sync with ERROR_CODE_TO_EXIT in src/dispatch/adapters/cli.ts.
|
|
205
|
-
*/
|
|
206
|
-
declare const STRING_TO_EXIT: Record<string, number>;
|
|
207
|
-
/**
|
|
208
|
-
* Create a typed engine error result with pino logging and correct exit code.
|
|
209
|
-
*
|
|
210
|
-
* @remarks
|
|
211
|
-
* The exit code is derived from the {@link STRING_TO_EXIT} mapping. If the
|
|
212
|
-
* code is not found in the map, exit code 1 (general error) is used.
|
|
213
|
-
* Pino logging is automatically triggered at the appropriate level
|
|
214
|
-
* (error for internal issues, warn for user/domain errors, debug for
|
|
215
|
-
* informational codes). Logging is suppressed under Vitest to keep
|
|
216
|
-
* test output clean.
|
|
217
|
-
*
|
|
218
|
-
* @param code - String error code (e.g., 'E_NOT_FOUND')
|
|
219
|
-
* @param message - Human-readable error message
|
|
220
|
-
* @param options - Optional details, fix command, and alternatives
|
|
221
|
-
* @returns EngineResult with success=false and properly structured error
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* ```typescript
|
|
225
|
-
* import { engineError } from './_error.js';
|
|
226
|
-
*
|
|
227
|
-
* return engineError('E_NOT_FOUND', `Task ${id} not found`, {
|
|
228
|
-
* fix: `cleo show ${id}`,
|
|
229
|
-
* details: { taskId: id },
|
|
230
|
-
* });
|
|
231
|
-
* ```
|
|
232
|
-
*/
|
|
233
|
-
declare function engineError<T>(code: string, message: string, options?: {
|
|
234
|
-
exitCode?: number;
|
|
235
|
-
details?: Record<string, unknown>;
|
|
236
|
-
fix?: string;
|
|
237
|
-
alternatives?: Array<{
|
|
238
|
-
action: string;
|
|
239
|
-
command: string;
|
|
240
|
-
}>;
|
|
241
|
-
problemDetails?: ProblemDetails;
|
|
242
|
-
}): EngineResult<T>;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Minimal meta shape carrying the request ID for RFC 7807 `instance` population.
|
|
246
|
-
*
|
|
247
|
-
* Callers may pass the dispatch-layer `DispatchRequest.requestId` (or any
|
|
248
|
-
* other correlation identifier) so that the resulting `problemDetails.instance`
|
|
249
|
-
* URI uniquely identifies the specific error occurrence.
|
|
250
|
-
*/
|
|
251
|
-
interface ErrorMeta {
|
|
252
|
-
/** Unique request identifier (used as the RFC 7807 `instance` field). */
|
|
253
|
-
requestId?: string;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Convert any caught value into an {@link EngineResult}, forwarding the rich
|
|
257
|
-
* `fix`, `details`, and `alternatives` fields when the caught value is a
|
|
258
|
-
* `CleoError` (or structurally compatible object).
|
|
259
|
-
*
|
|
260
|
-
* @remarks
|
|
261
|
-
* This is the canonical catch-block helper for all dispatch engines. It
|
|
262
|
-
* replaces the previous pattern of:
|
|
263
|
-
* ```typescript
|
|
264
|
-
* const code = (err as { code?: number })?.code;
|
|
265
|
-
* if (code === 4) return engineError('E_NOT_FOUND', …);
|
|
266
|
-
* …
|
|
267
|
-
* ```
|
|
268
|
-
* with a single call that preserves every field the core layer attached.
|
|
269
|
-
*
|
|
270
|
-
* The `fallbackCode` is used when the numeric `err.code` is not present in
|
|
271
|
-
* the {@link STRING_TO_EXIT} mapping (e.g. unknown exit codes, plain `Error`
|
|
272
|
-
* instances, or values thrown by non-CLEO code).
|
|
273
|
-
*
|
|
274
|
-
* RFC 7807 `problemDetails` is always populated from the resolved code, message,
|
|
275
|
-
* and exit code. The optional `meta.requestId` is forwarded to the `instance`
|
|
276
|
-
* field so every error occurrence is uniquely identifiable.
|
|
277
|
-
*
|
|
278
|
-
* @param err - The caught value (unknown type)
|
|
279
|
-
* @param fallbackCode - String error code to use when mapping fails
|
|
280
|
-
* @param fallbackMessage - Human-readable message when `err.message` is absent
|
|
281
|
-
* @param meta - Optional dispatch meta carrying `requestId` for RFC 7807 `instance`
|
|
282
|
-
* @returns EngineResult with all available rich fields propagated
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```typescript
|
|
286
|
-
* import { cleoErrorToEngineError } from './_error.js';
|
|
287
|
-
*
|
|
288
|
-
* } catch (err: unknown) {
|
|
289
|
-
* return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'Task database not initialized');
|
|
290
|
-
* }
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* @example With requestId for RFC 7807 instance field:
|
|
294
|
-
* ```typescript
|
|
295
|
-
* } catch (err: unknown) {
|
|
296
|
-
* return cleoErrorToEngineError(err, 'E_NOT_FOUND', 'Not found', { requestId });
|
|
297
|
-
* }
|
|
298
|
-
* ```
|
|
299
|
-
*/
|
|
300
|
-
declare function cleoErrorToEngineError<T>(err: unknown, fallbackCode: string, fallbackMessage: string, meta?: ErrorMeta): EngineResult<T>;
|
|
301
|
-
|
|
302
169
|
/**
|
|
303
170
|
* Parse all templates from the repo's .github/ISSUE_TEMPLATE/ directory.
|
|
304
171
|
*
|
|
@@ -317,7 +184,7 @@ declare function cleoErrorToEngineError<T>(err: unknown, fallbackCode: string, f
|
|
|
317
184
|
* }
|
|
318
185
|
* ```
|
|
319
186
|
*/
|
|
320
|
-
declare function parseIssueTemplates(projectRoot: string): EngineResult
|
|
187
|
+
declare function parseIssueTemplates(projectRoot: string): EngineResult<_cleocode_core_internal.TemplateConfig>;
|
|
321
188
|
/**
|
|
322
189
|
* Get template config for a specific subcommand (bug/feature/help).
|
|
323
190
|
*
|
|
@@ -334,7 +201,7 @@ declare function parseIssueTemplates(projectRoot: string): EngineResult$1<_cleoc
|
|
|
334
201
|
* const result = getTemplateForSubcommand('/path/to/project', 'bug');
|
|
335
202
|
* ```
|
|
336
203
|
*/
|
|
337
|
-
declare function getTemplateForSubcommand(projectRoot: string, subcommand: string): EngineResult
|
|
204
|
+
declare function getTemplateForSubcommand(projectRoot: string, subcommand: string): EngineResult<_cleocode_core_internal.IssueTemplate>;
|
|
338
205
|
/**
|
|
339
206
|
* Generate and cache the config as .cleo/issue-templates.json.
|
|
340
207
|
*
|
|
@@ -349,7 +216,7 @@ declare function getTemplateForSubcommand(projectRoot: string, subcommand: strin
|
|
|
349
216
|
* const result = await generateTemplateConfig('/path/to/project');
|
|
350
217
|
* ```
|
|
351
218
|
*/
|
|
352
|
-
declare function generateTemplateConfig(projectRoot: string): Promise<EngineResult
|
|
219
|
+
declare function generateTemplateConfig(projectRoot: string): Promise<EngineResult<_cleocode_core_internal.TemplateConfig>>;
|
|
353
220
|
/**
|
|
354
221
|
* Validate that labels exist on a GitHub repo.
|
|
355
222
|
*
|
|
@@ -365,7 +232,7 @@ declare function generateTemplateConfig(projectRoot: string): Promise<EngineResu
|
|
|
365
232
|
* const result = validateLabels(['bug', 'enhancement'], repoLabels);
|
|
366
233
|
* ```
|
|
367
234
|
*/
|
|
368
|
-
declare function validateLabels(labels: string[], repoLabels: string[]): EngineResult
|
|
235
|
+
declare function validateLabels(labels: string[], repoLabels: string[]): EngineResult<{
|
|
369
236
|
existing: string[];
|
|
370
237
|
missing: string[];
|
|
371
238
|
}>;
|
|
@@ -553,4 +420,4 @@ interface ServeGatewayHandle {
|
|
|
553
420
|
*/
|
|
554
421
|
declare function serveGateway(opts: ServeGatewayOptions): Promise<ServeGatewayHandle>;
|
|
555
422
|
|
|
556
|
-
export {
|
|
423
|
+
export { GatewayHandler, type GatewayScope, type GatewaySubsystemContext, type GatewaySubsystemOptions, HttpServerHandle, HttpServerOptions, RpcServerHandle, RpcServerOptions, type ServeGatewayHandle, type ServeGatewayOptions, defineGatewaySubsystem, gatewaySubsystemName, generateTemplateConfig, getJobManager, getTemplateForSubcommand, mapNumericExitCodeToString, parseIssueTemplates, serveGateway, setJobManager, validateLabels };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleocode/runtime",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.14-rc.ci.683",
|
|
4
4
|
"description": "Long-running process layer for CLEO — agent polling, SSE connections, heartbeat, key rotation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"node-cron": "^4.2.1",
|
|
40
|
-
"@cleocode/contracts": "2026.10.
|
|
41
|
-
"@cleocode/core": "2026.10.
|
|
40
|
+
"@cleocode/contracts": "2026.10.14-rc.ci.683",
|
|
41
|
+
"@cleocode/core": "2026.10.14-rc.ci.683"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^8.0.0",
|