@sublang/slc 0.5.0 → 0.7.0
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/README.md +10 -5
- package/dist/app.d.ts +20 -20
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +44 -31
- package/dist/app.js.map +1 -1
- package/dist/artifacts.d.ts +6 -6
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +9 -9
- package/dist/artifacts.js.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cligent-agent.d.ts +9 -2
- package/dist/cligent-agent.d.ts.map +1 -1
- package/dist/cligent-agent.js +6 -5
- package/dist/cligent-agent.js.map +1 -1
- package/dist/compiled-execution.d.ts +44 -0
- package/dist/compiled-execution.d.ts.map +1 -0
- package/dist/compiled-execution.js +184 -0
- package/dist/compiled-execution.js.map +1 -0
- package/dist/compiled-executor.d.ts +16 -6
- package/dist/compiled-executor.d.ts.map +1 -1
- package/dist/compiled-executor.js +182 -35
- package/dist/compiled-executor.js.map +1 -1
- package/dist/config-file.d.ts +9 -6
- package/dist/config-file.d.ts.map +1 -1
- package/dist/config-file.js +27 -9
- package/dist/config-file.js.map +1 -1
- package/dist/config.d.ts +77 -24
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +128 -52
- package/dist/config.js.map +1 -1
- package/dist/emitted-imports.d.ts +14 -0
- package/dist/emitted-imports.d.ts.map +1 -1
- package/dist/emitted-imports.js +63 -7
- package/dist/emitted-imports.js.map +1 -1
- package/dist/entry-module.d.ts +5 -3
- package/dist/entry-module.d.ts.map +1 -1
- package/dist/entry-module.js +41 -13
- package/dist/entry-module.js.map +1 -1
- package/dist/execution.d.ts +10 -10
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +13 -13
- package/dist/execution.js.map +1 -1
- package/dist/hash.js +2 -2
- package/dist/interpreter.d.ts +2 -2
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +7 -7
- package/dist/invocation.d.ts +6 -6
- package/dist/invocation.d.ts.map +1 -1
- package/dist/invocation.js +1 -1
- package/dist/link.d.ts +4 -4
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +11 -11
- package/dist/link.js.map +1 -1
- package/dist/phase-runner.d.ts +13 -6
- package/dist/phase-runner.d.ts.map +1 -1
- package/dist/phase-runner.js +12 -10
- package/dist/phase-runner.js.map +1 -1
- package/dist/phase.d.ts +4 -4
- package/dist/phase.d.ts.map +1 -1
- package/dist/phase.js +7 -7
- package/dist/phase.js.map +1 -1
- package/dist/pin-closure.d.ts +35 -7
- package/dist/pin-closure.d.ts.map +1 -1
- package/dist/pin-closure.js +135 -21
- package/dist/pin-closure.js.map +1 -1
- package/dist/pin-currency.d.ts +9 -4
- package/dist/pin-currency.d.ts.map +1 -1
- package/dist/pin-currency.js +57 -20
- package/dist/pin-currency.js.map +1 -1
- package/dist/pin-generate.d.ts +7 -7
- package/dist/pin-generate.d.ts.map +1 -1
- package/dist/pin-generate.js +24 -10
- package/dist/pin-generate.js.map +1 -1
- package/dist/pin-inputs.d.ts +41 -0
- package/dist/pin-inputs.d.ts.map +1 -0
- package/dist/pin-inputs.js +179 -0
- package/dist/pin-inputs.js.map +1 -0
- package/dist/pin-paths.d.ts +1 -1
- package/dist/pin-paths.js +4 -4
- package/dist/pin-paths.js.map +1 -1
- package/dist/pins.d.ts +4 -4
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +5 -5
- package/dist/pins.js.map +1 -1
- package/dist/pipeline.d.ts +5 -5
- package/dist/pipeline.js +10 -10
- package/dist/playbook-contract.d.ts +49 -5
- package/dist/playbook-contract.d.ts.map +1 -1
- package/dist/playbook-contract.js +70 -21
- package/dist/playbook-contract.js.map +1 -1
- package/dist/playbook-ports.d.ts +9 -9
- package/dist/playbook-ports.d.ts.map +1 -1
- package/dist/playbook-ports.js +3 -3
- package/dist/playbook-ports.js.map +1 -1
- package/dist/progress.d.ts +8 -9
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +3 -3
- package/dist/progress.js.map +1 -1
- package/dist/resolver.d.ts +9 -9
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +12 -12
- package/dist/resolver.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +218 -81
- package/dist/runner.js.map +1 -1
- package/dist/runtime-contract.d.ts +17 -0
- package/dist/runtime-contract.d.ts.map +1 -0
- package/dist/runtime-contract.js +114 -0
- package/dist/runtime-contract.js.map +1 -0
- package/dist/slc.config.template.yaml +7 -2
- package/dist/verify-coverage.d.ts +4 -3
- package/dist/verify-coverage.d.ts.map +1 -1
- package/dist/verify-coverage.js +509 -71
- package/dist/verify-coverage.js.map +1 -1
- package/dist/verify.d.ts +153 -15
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +707 -59
- package/dist/verify.js.map +1 -1
- package/package.json +3 -3
package/dist/config.d.ts
CHANGED
|
@@ -1,52 +1,69 @@
|
|
|
1
1
|
import type { AgentAdapter, PermissionPolicy } from '@sublang/cligent';
|
|
2
2
|
import type { PhaseExecutor } from './execution.js';
|
|
3
3
|
import type { AgentClient } from './interpreter.js';
|
|
4
|
+
import type { RuntimeContractProfile } from './playbook-contract.js';
|
|
4
5
|
import type { CompiledSelection } from './runner.js';
|
|
5
|
-
/** Agent CLI ids the executable registers (
|
|
6
|
+
/** Agent CLI ids the executable registers (cli-7). */
|
|
6
7
|
export declare const SUPPORTED_AGENTS: readonly ["claude-code", "codex", "gemini", "opencode"];
|
|
7
|
-
/** One of the registered agent CLI ids (
|
|
8
|
+
/** One of the registered agent CLI ids (cli-7). */
|
|
8
9
|
export type SupportedAgent = (typeof SUPPORTED_AGENTS)[number];
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Constructs the Cligent adapter for a supported agent id (cli-7). Cligent
|
|
12
|
+
* types each adapter by its own effort vocabulary and fast-mode support, so
|
|
13
|
+
* the factory is typed at the widest adapter shape; the configuration layer
|
|
14
|
+
* validates effort against Cligent's per-agent support metadata (cli-12).
|
|
15
|
+
*/
|
|
16
|
+
export type AdapterFactory = (agent: SupportedAgent) => AgentAdapter<string, boolean>;
|
|
17
|
+
/** Default factory: Cligent's built-in adapters, constructed on demand (cli-7). */
|
|
12
18
|
export declare const defaultAdapterFactory: AdapterFactory;
|
|
13
|
-
/** A resolved Coder and optional Reviewer selection (
|
|
19
|
+
/** A resolved Coder and optional Reviewer selection (cli-7, DR-022). */
|
|
14
20
|
export interface AgentSelection {
|
|
15
21
|
agent: SupportedAgent;
|
|
16
22
|
/** Optional model; omitted so the agent CLI uses its own default. */
|
|
17
23
|
model?: string;
|
|
18
24
|
/** Optional adapter-scoped reasoning effort; omitted for the default. */
|
|
19
25
|
effort?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Literal adapter-scoped fast-mode request: `false` asks for it off, and
|
|
28
|
+
* omission leaves the agent CLI's own default. Validated against Cligent's
|
|
29
|
+
* fast-mode capability contract, which slc does not duplicate (cli-7).
|
|
30
|
+
*/
|
|
31
|
+
fastMode?: boolean;
|
|
20
32
|
/** Optional independent Reviewer selection; presence enables DR-022. */
|
|
21
33
|
reviewer?: Omit<AgentSelection, 'reviewer'>;
|
|
22
34
|
}
|
|
23
|
-
/** Machine-readable reason agent configuration was refused (
|
|
24
|
-
export type ConfigErrorCode = 'agent-unset' | 'agent-unsupported' | 'effort-unsupported' | 'reviewer-agent-unset' | 'reviewer-agent-unsupported' | 'reviewer-effort-unsupported';
|
|
35
|
+
/** Machine-readable reason agent configuration was refused (cli-12). */
|
|
36
|
+
export type ConfigErrorCode = 'agent-unset' | 'agent-unsupported' | 'effort-unsupported' | 'fast-mode-invalid' | 'fast-mode-unsupported' | 'reviewer-agent-unset' | 'reviewer-agent-unsupported' | 'reviewer-effort-unsupported' | 'reviewer-fast-mode-invalid' | 'reviewer-fast-mode-unsupported';
|
|
25
37
|
/** Raised when a required Coder or Reviewer selection is invalid. */
|
|
26
38
|
export declare class ConfigError extends Error {
|
|
27
39
|
readonly code: ConfigErrorCode;
|
|
28
40
|
constructor(code: ConfigErrorCode, message: string);
|
|
29
41
|
}
|
|
30
|
-
/** Reports whether `agent` is one of the registered ids (
|
|
42
|
+
/** Reports whether `agent` is one of the registered ids (cli-7). */
|
|
31
43
|
export declare function isSupportedAgent(agent: string): agent is SupportedAgent;
|
|
32
44
|
/**
|
|
33
45
|
* Resolves the Coder and optional Reviewer selections from environment configuration
|
|
34
|
-
* (
|
|
35
|
-
* optionally names a model,
|
|
46
|
+
* (cli-7, cli-12): `SLC_AGENT` names a registered agent CLI, `SLC_MODEL`
|
|
47
|
+
* optionally names a model, `SLC_EFFORT` optionally selects an
|
|
36
48
|
* adapter-scoped reasoning effort validated against Cligent's support
|
|
37
|
-
* metadata
|
|
49
|
+
* metadata, and `SLC_FAST_MODE` — exactly `true` or `false` — optionally
|
|
50
|
+
* requests adapter-scoped fast mode, accepted or refused by Cligent's
|
|
51
|
+
* fast-mode capability contract before any agent call.
|
|
38
52
|
*
|
|
39
53
|
* @throws {ConfigError} when `SLC_AGENT` is unset/blank (`agent-unset`) or
|
|
40
|
-
* outside the registered set (`agent-unsupported`),
|
|
54
|
+
* outside the registered set (`agent-unsupported`), when `SLC_EFFORT`
|
|
41
55
|
* names a value the selected agent does not support
|
|
42
|
-
* (`effort-unsupported`)
|
|
56
|
+
* (`effort-unsupported`), when `SLC_FAST_MODE` is neither `true` nor
|
|
57
|
+
* `false` (`fast-mode-invalid`), or when it is set for an agent Cligent
|
|
58
|
+
* reports without fast-mode request support (`fast-mode-unsupported`); no
|
|
59
|
+
* implicit default agent is applied.
|
|
43
60
|
*/
|
|
44
61
|
export declare function resolveAgentSelection(env: Record<string, string | undefined>): AgentSelection;
|
|
45
62
|
/**
|
|
46
|
-
* Builds the interpreted {@link PhaseExecutor} for a selection (
|
|
63
|
+
* Builds the interpreted {@link PhaseExecutor} for a selection (cli-7, cli-8):
|
|
47
64
|
* constructs the agent CLI's adapter, wraps it as a Cligent-backed transport,
|
|
48
65
|
* and binds the optional model as configuration, not phase semantics
|
|
49
|
-
* (
|
|
66
|
+
* (phase-execution-13). The adapter factory is injectable so tests can fake adapter
|
|
50
67
|
* construction; `permissions` is where a host configures the DR-003 write-scope
|
|
51
68
|
* sandbox.
|
|
52
69
|
*/
|
|
@@ -59,7 +76,7 @@ export declare function createConfiguredExecutor(selection: AgentSelection, opts
|
|
|
59
76
|
stallTimeoutMs?: number;
|
|
60
77
|
}): PhaseExecutor;
|
|
61
78
|
/**
|
|
62
|
-
* Builds one Cligent-backed {@link AgentClient} for a selection (
|
|
79
|
+
* Builds one Cligent-backed {@link AgentClient} for a selection (cli-7): a fresh
|
|
63
80
|
* adapter wrapped as a transport. Each client is a single-flight Cligent
|
|
64
81
|
* instance that resumes its own agent session across calls, so callers wanting
|
|
65
82
|
* isolated sessions construct one client per role or player.
|
|
@@ -73,11 +90,16 @@ export declare function createConfiguredAgentClient(selection: AgentSelection, o
|
|
|
73
90
|
}): AgentClient;
|
|
74
91
|
/**
|
|
75
92
|
* Builds the compiled-execution factory the bin injects as `SlcDeps.compiled`
|
|
76
|
-
* (
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
93
|
+
* (cli-8, phase-execution-27): for a current pinned phase it selects the
|
|
94
|
+
* runtime contract profile ({@link runtimeContractForPin}) and drives the
|
|
95
|
+
* pinned `playbook` artifact — resolved against its pipeline directory —
|
|
96
|
+
* through the compiled executor, backing the runtime's player ports with one
|
|
97
|
+
* agent transport per player id and its Captain/judge ports with one shared
|
|
98
|
+
* transport; the roleless composed-v3 path rejects its player port before that
|
|
99
|
+
* lazy player transport is constructed (phase-execution-25). The factory
|
|
100
|
+
* applies the selected model as the default per-player model
|
|
101
|
+
* (phase-execution-13). A rejected selection rejects the returned promise
|
|
102
|
+
* before any artifact loads or transport is built (phase-execution-30).
|
|
81
103
|
*/
|
|
82
104
|
export declare function createConfiguredCompiledFactory(selection: AgentSelection, opts?: {
|
|
83
105
|
adapterFactory?: AdapterFactory;
|
|
@@ -86,7 +108,38 @@ export declare function createConfiguredCompiledFactory(selection: AgentSelectio
|
|
|
86
108
|
permissions?: PermissionPolicy;
|
|
87
109
|
/** Agent-stall watchdog window in milliseconds; 0/absent disables (DR-019). */
|
|
88
110
|
stallTimeoutMs?: number;
|
|
89
|
-
/** Live status sink streaming the runtime's non-trace status (DR-019,
|
|
111
|
+
/** Live status sink streaming the runtime's non-trace status (DR-019, phase-execution-25). */
|
|
90
112
|
onStatus?: (line: string) => void;
|
|
91
|
-
}): (choice: CompiledSelection) => PhaseExecutor
|
|
113
|
+
}): (choice: CompiledSelection) => Promise<PhaseExecutor>;
|
|
114
|
+
/**
|
|
115
|
+
* The exact historical provenance maps, retained as recorded (DR-028):
|
|
116
|
+
* absent or Playbook 0.9.0 provenance is the `legacy` contract, and the
|
|
117
|
+
* reviewed six-port generation is `composed-v2`. Every other provenance is
|
|
118
|
+
* decided by the installed engine's declaration instead.
|
|
119
|
+
*
|
|
120
|
+
* Playbook 0.10 ships the composed six-port contract (DR-011); 1.0.0 is the
|
|
121
|
+
* published release of that same generation — 0.10.0 was cut locally and
|
|
122
|
+
* superseded before it reached the registry. 2.0.0 keeps the six-port
|
|
123
|
+
* boundary and structured results while moving Captain host failures onto
|
|
124
|
+
* the resolved `failed` path and emitting thin linked modules (DR-017).
|
|
125
|
+
* 3.1.0 ships runtime.ts byte-identical to 2.0.0 and only adds the additive
|
|
126
|
+
* DR-022 compat self-report (DR-018), and 4.0.0 keeps runtime.ts and the
|
|
127
|
+
* engine byte-identical to 3.1.0's — its major marks the SDK-topology break,
|
|
128
|
+
* not a contract change (DR-020) — so all five select `composed-v2`.
|
|
129
|
+
*/
|
|
130
|
+
export declare function historicalRuntimeContract(provenance: string | undefined): 'legacy' | 'composed-v2' | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Selects the runtime contract profile a current pin runs under
|
|
133
|
+
* (phase-execution-30; DR-010, DR-028). The historical exact maps decide
|
|
134
|
+
* `legacy` and `composed-v2`; every other provenance selects `composed-v3`
|
|
135
|
+
* exactly when the pin's link target resolves inside an installed
|
|
136
|
+
* `@sublang/playbook` whose engine declares `RUNTIME_ABI` `1` and
|
|
137
|
+
* `SUPPORTED_ARTIFACT_SCHEMAS` containing `3`, whatever its release version.
|
|
138
|
+
*
|
|
139
|
+
* @throws naming the declaration — or its absence — when the link target
|
|
140
|
+
* lies outside such a package, its engine cannot be read, or it declares
|
|
141
|
+
* another ABI or no schema 3; no profile is inferred from callable members
|
|
142
|
+
* and no other profile is retried.
|
|
143
|
+
*/
|
|
144
|
+
export declare function runtimeContractForPin(choice: CompiledSelection): Promise<RuntimeContractProfile>;
|
|
92
145
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQrD,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,yDAKnB,CAAC;AAEX,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,EAAE,cAAc,KAClB,YAAY,CA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AC,EAAE,MAAM,CAAC;CACpB,GACL,aAAa,CAOf;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,EACzB,IAAI,GAAE;IACJ,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,WAAW,CAYb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,cAAc,EACzB,IAAI,GAAE;IACJ,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B,GACL,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,aAAa,CAAC,CAmBvD;AA0BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,QAAQ,GAAG,aAAa,GAAG,SAAS,CActC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CA6BjC"}
|
package/dist/config.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
/**
|
|
4
|
-
* Agent/model configuration and executor construction for the `slc` bin (
|
|
5
|
-
*
|
|
4
|
+
* Agent/model configuration and executor construction for the `slc` bin (cli-7,
|
|
5
|
+
* cli-8, cli-12, DR-004, DR-005).
|
|
6
6
|
*
|
|
7
7
|
* `resolveAgentSelection` reads the Coder and optional Reviewer selections from
|
|
8
|
-
* the environment and refuses unset or unsupported required values (
|
|
8
|
+
* the environment and refuses unset or unsupported required values (cli-12,
|
|
9
9
|
* DR-022).
|
|
10
10
|
* `createConfiguredExecutor` builds the interpreted executor and
|
|
11
11
|
* `createConfiguredCompiledFactory` the compiled-execution factory pinned phases
|
|
12
12
|
* select, both over Cligent-backed transports for the selected agent, binding
|
|
13
|
-
* the optional model as configuration — not phase semantics (
|
|
13
|
+
* the optional model as configuration — not phase semantics (phase-execution-13);
|
|
14
14
|
* credentials are left for the agent CLI to read from the inherited process
|
|
15
15
|
* environment. The adapter factory is injectable so tests can fake adapter
|
|
16
|
-
* construction. See specs/
|
|
16
|
+
* construction. See specs/packages/cli.md.
|
|
17
17
|
*/
|
|
18
18
|
import { resolve } from 'node:path';
|
|
19
19
|
import { ClaudeCodeAdapter } from '@sublang/cligent/adapters/claude-code';
|
|
20
20
|
import { CodexAdapter } from '@sublang/cligent/adapters/codex';
|
|
21
21
|
import { GeminiAdapter } from '@sublang/cligent/adapters/gemini';
|
|
22
22
|
import { OpenCodeAdapter } from '@sublang/cligent/adapters/opencode';
|
|
23
|
-
import { isEffortSupported, supportedEffortValues } from '@sublang/cligent';
|
|
23
|
+
import { assertFastModeSupported, isEffortSupported, supportedEffortValues, } from '@sublang/cligent';
|
|
24
24
|
import { createCligentAgent } from './cligent-agent.js';
|
|
25
25
|
import { createCompiledExecutor } from './compiled-executor.js';
|
|
26
|
+
import { messageOf } from './errors.js';
|
|
26
27
|
import { createInterpretedExecutor } from './interpreter.js';
|
|
27
28
|
import { createReviewingAgent } from './reviewing-agent.js';
|
|
28
|
-
|
|
29
|
+
import { declaresComposedV3, describeRuntimeDeclaration, PLAYBOOK_PACKAGE, readPlaybookRuntimeDeclaration, } from './runtime-contract.js';
|
|
30
|
+
/** Agent CLI ids the executable registers (cli-7). */
|
|
29
31
|
export const SUPPORTED_AGENTS = [
|
|
30
32
|
'claude-code',
|
|
31
33
|
'codex',
|
|
32
34
|
'gemini',
|
|
33
35
|
'opencode',
|
|
34
36
|
];
|
|
35
|
-
/** Default factory: Cligent's built-in adapters, constructed on demand (
|
|
37
|
+
/** Default factory: Cligent's built-in adapters, constructed on demand (cli-7). */
|
|
36
38
|
export const defaultAdapterFactory = (agent) => {
|
|
37
39
|
switch (agent) {
|
|
38
40
|
case 'claude-code':
|
|
@@ -54,30 +56,38 @@ export class ConfigError extends Error {
|
|
|
54
56
|
this.code = code;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
|
-
/** Reports whether `agent` is one of the registered ids (
|
|
59
|
+
/** Reports whether `agent` is one of the registered ids (cli-7). */
|
|
58
60
|
export function isSupportedAgent(agent) {
|
|
59
61
|
return SUPPORTED_AGENTS.includes(agent);
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Resolves the Coder and optional Reviewer selections from environment configuration
|
|
63
|
-
* (
|
|
64
|
-
* optionally names a model,
|
|
65
|
+
* (cli-7, cli-12): `SLC_AGENT` names a registered agent CLI, `SLC_MODEL`
|
|
66
|
+
* optionally names a model, `SLC_EFFORT` optionally selects an
|
|
65
67
|
* adapter-scoped reasoning effort validated against Cligent's support
|
|
66
|
-
* metadata
|
|
68
|
+
* metadata, and `SLC_FAST_MODE` — exactly `true` or `false` — optionally
|
|
69
|
+
* requests adapter-scoped fast mode, accepted or refused by Cligent's
|
|
70
|
+
* fast-mode capability contract before any agent call.
|
|
67
71
|
*
|
|
68
72
|
* @throws {ConfigError} when `SLC_AGENT` is unset/blank (`agent-unset`) or
|
|
69
|
-
* outside the registered set (`agent-unsupported`),
|
|
73
|
+
* outside the registered set (`agent-unsupported`), when `SLC_EFFORT`
|
|
70
74
|
* names a value the selected agent does not support
|
|
71
|
-
* (`effort-unsupported`)
|
|
75
|
+
* (`effort-unsupported`), when `SLC_FAST_MODE` is neither `true` nor
|
|
76
|
+
* `false` (`fast-mode-invalid`), or when it is set for an agent Cligent
|
|
77
|
+
* reports without fast-mode request support (`fast-mode-unsupported`); no
|
|
78
|
+
* implicit default agent is applied.
|
|
72
79
|
*/
|
|
73
80
|
export function resolveAgentSelection(env) {
|
|
74
81
|
const selection = resolveOneSelection(env, {
|
|
75
82
|
agent: 'SLC_AGENT',
|
|
76
83
|
model: 'SLC_MODEL',
|
|
77
84
|
effort: 'SLC_EFFORT',
|
|
85
|
+
fastMode: 'SLC_FAST_MODE',
|
|
78
86
|
unsetCode: 'agent-unset',
|
|
79
87
|
unsupportedCode: 'agent-unsupported',
|
|
80
88
|
effortCode: 'effort-unsupported',
|
|
89
|
+
fastModeInvalidCode: 'fast-mode-invalid',
|
|
90
|
+
fastModeCode: 'fast-mode-unsupported',
|
|
81
91
|
required: true,
|
|
82
92
|
});
|
|
83
93
|
if (selection === undefined) {
|
|
@@ -87,9 +97,12 @@ export function resolveAgentSelection(env) {
|
|
|
87
97
|
agent: 'SLC_REVIEWER_AGENT',
|
|
88
98
|
model: 'SLC_REVIEWER_MODEL',
|
|
89
99
|
effort: 'SLC_REVIEWER_EFFORT',
|
|
100
|
+
fastMode: 'SLC_REVIEWER_FAST_MODE',
|
|
90
101
|
unsetCode: 'reviewer-agent-unset',
|
|
91
102
|
unsupportedCode: 'reviewer-agent-unsupported',
|
|
92
103
|
effortCode: 'reviewer-effort-unsupported',
|
|
104
|
+
fastModeInvalidCode: 'reviewer-fast-mode-invalid',
|
|
105
|
+
fastModeCode: 'reviewer-fast-mode-unsupported',
|
|
93
106
|
required: false,
|
|
94
107
|
});
|
|
95
108
|
return reviewer === undefined ? selection : { ...selection, reviewer };
|
|
@@ -98,12 +111,14 @@ function resolveOneSelection(env, names) {
|
|
|
98
111
|
const agent = (env[names.agent] ?? '').trim();
|
|
99
112
|
const model = (env[names.model] ?? '').trim();
|
|
100
113
|
const effort = (env[names.effort] ?? '').trim();
|
|
114
|
+
const fastMode = (env[names.fastMode] ?? '').trim();
|
|
101
115
|
if (agent === '') {
|
|
102
|
-
if (!names.required && model === '' && effort === '')
|
|
116
|
+
if (!names.required && model === '' && effort === '' && fastMode === '') {
|
|
103
117
|
return undefined;
|
|
118
|
+
}
|
|
104
119
|
throw new ConfigError(names.unsetCode, names.required
|
|
105
120
|
? `${names.agent} is not set; set it to one of: ${SUPPORTED_AGENTS.join(', ')}`
|
|
106
|
-
: `${names.agent} is not set; ${names.model} and ${names.
|
|
121
|
+
: `${names.agent} is not set; ${names.model}, ${names.effort}, and ${names.fastMode} require a reviewer agent; set ${names.agent} to one of: ${SUPPORTED_AGENTS.join(', ')}`);
|
|
107
122
|
}
|
|
108
123
|
if (!isSupportedAgent(agent)) {
|
|
109
124
|
throw new ConfigError(names.unsupportedCode, `${names.agent} "${agent}" is not a supported agent CLI; choose one of: ${SUPPORTED_AGENTS.join(', ')}`);
|
|
@@ -111,17 +126,31 @@ function resolveOneSelection(env, names) {
|
|
|
111
126
|
if (effort !== '' && !isEffortSupported(agent, effort)) {
|
|
112
127
|
throw new ConfigError(names.effortCode, `${names.effort} "${effort}" is not supported by ${agent}; choose one of: ${(supportedEffortValues(agent) ?? []).join(', ')}`);
|
|
113
128
|
}
|
|
129
|
+
if (fastMode !== '' && fastMode !== 'true' && fastMode !== 'false') {
|
|
130
|
+
throw new ConfigError(names.fastModeInvalidCode, `${names.fastMode} "${fastMode}" must be exactly true or false`);
|
|
131
|
+
}
|
|
132
|
+
if (fastMode !== '') {
|
|
133
|
+
// Cligent owns adapter capability: a literal request — `false` included —
|
|
134
|
+
// is accepted or refused by its contract, naming the adapter (cli-7).
|
|
135
|
+
try {
|
|
136
|
+
assertFastModeSupported(agent, names.fastMode);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new ConfigError(names.fastModeCode, messageOf(error));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
114
142
|
return {
|
|
115
143
|
agent,
|
|
116
144
|
model: model === '' ? undefined : model,
|
|
117
145
|
effort: effort === '' ? undefined : effort,
|
|
146
|
+
fastMode: fastMode === '' ? undefined : fastMode === 'true',
|
|
118
147
|
};
|
|
119
148
|
}
|
|
120
149
|
/**
|
|
121
|
-
* Builds the interpreted {@link PhaseExecutor} for a selection (
|
|
150
|
+
* Builds the interpreted {@link PhaseExecutor} for a selection (cli-7, cli-8):
|
|
122
151
|
* constructs the agent CLI's adapter, wraps it as a Cligent-backed transport,
|
|
123
152
|
* and binds the optional model as configuration, not phase semantics
|
|
124
|
-
* (
|
|
153
|
+
* (phase-execution-13). The adapter factory is injectable so tests can fake adapter
|
|
125
154
|
* construction; `permissions` is where a host configures the DR-003 write-scope
|
|
126
155
|
* sandbox.
|
|
127
156
|
*/
|
|
@@ -134,7 +163,7 @@ export function createConfiguredExecutor(selection, opts = {}) {
|
|
|
134
163
|
});
|
|
135
164
|
}
|
|
136
165
|
/**
|
|
137
|
-
* Builds one Cligent-backed {@link AgentClient} for a selection (
|
|
166
|
+
* Builds one Cligent-backed {@link AgentClient} for a selection (cli-7): a fresh
|
|
138
167
|
* adapter wrapped as a transport. Each client is a single-flight Cligent
|
|
139
168
|
* instance that resumes its own agent session across calls, so callers wanting
|
|
140
169
|
* isolated sessions construct one client per role or player.
|
|
@@ -146,33 +175,42 @@ export function createConfiguredAgentClient(selection, opts = {}) {
|
|
|
146
175
|
maxTurns: opts.maxTurns,
|
|
147
176
|
permissions: opts.permissions,
|
|
148
177
|
effort: selection.effort,
|
|
178
|
+
fastMode: selection.fastMode,
|
|
149
179
|
stallTimeoutMs: opts.stallTimeoutMs,
|
|
150
180
|
});
|
|
151
181
|
}
|
|
152
182
|
/**
|
|
153
183
|
* Builds the compiled-execution factory the bin injects as `SlcDeps.compiled`
|
|
154
|
-
* (
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
184
|
+
* (cli-8, phase-execution-27): for a current pinned phase it selects the
|
|
185
|
+
* runtime contract profile ({@link runtimeContractForPin}) and drives the
|
|
186
|
+
* pinned `playbook` artifact — resolved against its pipeline directory —
|
|
187
|
+
* through the compiled executor, backing the runtime's player ports with one
|
|
188
|
+
* agent transport per player id and its Captain/judge ports with one shared
|
|
189
|
+
* transport; the roleless composed-v3 path rejects its player port before that
|
|
190
|
+
* lazy player transport is constructed (phase-execution-25). The factory
|
|
191
|
+
* applies the selected model as the default per-player model
|
|
192
|
+
* (phase-execution-13). A rejected selection rejects the returned promise
|
|
193
|
+
* before any artifact loads or transport is built (phase-execution-30).
|
|
159
194
|
*/
|
|
160
195
|
export function createConfiguredCompiledFactory(selection, opts = {}) {
|
|
161
196
|
const client = () => {
|
|
162
197
|
const coder = createConfiguredAgentClient(selection, opts);
|
|
163
198
|
return configuredReviewingClient(selection, coder, opts);
|
|
164
199
|
};
|
|
165
|
-
return (choice) =>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
return async (choice) => {
|
|
201
|
+
const runtimeContract = await runtimeContractForPin(choice);
|
|
202
|
+
return createCompiledExecutor({
|
|
203
|
+
artifactPath: resolve(choice.pipelineDir, choice.record.artifact.path),
|
|
204
|
+
runRoot: opts.cwd ?? process.cwd(),
|
|
205
|
+
playbookId: choice.phase,
|
|
206
|
+
runtimeContract,
|
|
207
|
+
player: () => client(),
|
|
208
|
+
judge: client(),
|
|
209
|
+
defaultModel: selection.model,
|
|
210
|
+
cwd: opts.cwd,
|
|
211
|
+
onStatus: opts.onStatus,
|
|
212
|
+
});
|
|
213
|
+
};
|
|
176
214
|
}
|
|
177
215
|
function configuredReviewingClient(selection, coder, opts) {
|
|
178
216
|
const reviewer = selection.reviewer;
|
|
@@ -193,25 +231,26 @@ function configuredReviewingClient(selection, coder, opts) {
|
|
|
193
231
|
reviewerModel: reviewer.model,
|
|
194
232
|
});
|
|
195
233
|
}
|
|
196
|
-
|
|
197
|
-
|
|
234
|
+
/**
|
|
235
|
+
* The exact historical provenance maps, retained as recorded (DR-028):
|
|
236
|
+
* absent or Playbook 0.9.0 provenance is the `legacy` contract, and the
|
|
237
|
+
* reviewed six-port generation is `composed-v2`. Every other provenance is
|
|
238
|
+
* decided by the installed engine's declaration instead.
|
|
239
|
+
*
|
|
240
|
+
* Playbook 0.10 ships the composed six-port contract (DR-011); 1.0.0 is the
|
|
241
|
+
* published release of that same generation — 0.10.0 was cut locally and
|
|
242
|
+
* superseded before it reached the registry. 2.0.0 keeps the six-port
|
|
243
|
+
* boundary and structured results while moving Captain host failures onto
|
|
244
|
+
* the resolved `failed` path and emitting thin linked modules (DR-017).
|
|
245
|
+
* 3.1.0 ships runtime.ts byte-identical to 2.0.0 and only adds the additive
|
|
246
|
+
* DR-022 compat self-report (DR-018), and 4.0.0 keeps runtime.ts and the
|
|
247
|
+
* engine byte-identical to 3.1.0's — its major marks the SDK-topology break,
|
|
248
|
+
* not a contract change (DR-020) — so all five select `composed-v2`.
|
|
249
|
+
*/
|
|
250
|
+
export function historicalRuntimeContract(provenance) {
|
|
198
251
|
if (provenance === undefined || provenance === '@sublang/playbook@0.9.0') {
|
|
199
252
|
return 'legacy';
|
|
200
253
|
}
|
|
201
|
-
// Playbook 0.10 ships the composed six-port contract (DR-011); artifacts
|
|
202
|
-
// linked against it run through the composed session profile. 1.0.0 is the
|
|
203
|
-
// published release of that same contract generation — 0.10.0 was cut
|
|
204
|
-
// locally and superseded before it ever reached the registry. 2.0.0 keeps
|
|
205
|
-
// the six-port boundary and structured results while moving Captain host
|
|
206
|
-
// failures onto the resolved `failed` path and emitting thin linked
|
|
207
|
-
// modules (DR-017), so all three provenances select the composed profile.
|
|
208
|
-
// 3.1.0 ships runtime.ts byte-identical to 2.0.0 and only adds the
|
|
209
|
-
// additive DR-022 compat self-report on the shared engine, so it selects
|
|
210
|
-
// the same profile (DR-018). 4.0.0 keeps runtime.ts and the engine
|
|
211
|
-
// byte-identical to 3.1.0's — its major marks the SDK-topology break,
|
|
212
|
-
// with cligent owning runtime versions, not a contract change — so it
|
|
213
|
-
// selects the same profile (DR-020). 1.3.0 and 3.0.0 were never
|
|
214
|
-
// installed or reviewed here and stay fail-closed.
|
|
215
254
|
if (provenance === '@sublang/playbook@0.10.0' ||
|
|
216
255
|
provenance === '@sublang/playbook@1.0.0' ||
|
|
217
256
|
provenance === '@sublang/playbook@2.0.0' ||
|
|
@@ -219,6 +258,43 @@ function runtimeContractForPin(choice) {
|
|
|
219
258
|
provenance === '@sublang/playbook@4.0.0') {
|
|
220
259
|
return 'composed-v2';
|
|
221
260
|
}
|
|
222
|
-
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Selects the runtime contract profile a current pin runs under
|
|
265
|
+
* (phase-execution-30; DR-010, DR-028). The historical exact maps decide
|
|
266
|
+
* `legacy` and `composed-v2`; every other provenance selects `composed-v3`
|
|
267
|
+
* exactly when the pin's link target resolves inside an installed
|
|
268
|
+
* `@sublang/playbook` whose engine declares `RUNTIME_ABI` `1` and
|
|
269
|
+
* `SUPPORTED_ARTIFACT_SCHEMAS` containing `3`, whatever its release version.
|
|
270
|
+
*
|
|
271
|
+
* @throws naming the declaration — or its absence — when the link target
|
|
272
|
+
* lies outside such a package, its engine cannot be read, or it declares
|
|
273
|
+
* another ABI or no schema 3; no profile is inferred from callable members
|
|
274
|
+
* and no other profile is retried.
|
|
275
|
+
*/
|
|
276
|
+
export async function runtimeContractForPin(choice) {
|
|
277
|
+
const provenance = choice.record.linkTarget.provenance;
|
|
278
|
+
const historical = historicalRuntimeContract(provenance);
|
|
279
|
+
if (historical !== undefined)
|
|
280
|
+
return historical;
|
|
281
|
+
const locator = choice.record.linkTarget.locator;
|
|
282
|
+
const reject = (reason) => {
|
|
283
|
+
throw new Error(`unsupported pinned Playbook runtime contract: ${provenance} (${reason})`);
|
|
284
|
+
};
|
|
285
|
+
let declaration;
|
|
286
|
+
try {
|
|
287
|
+
declaration = await readPlaybookRuntimeDeclaration(resolve(choice.pipelineDir, locator));
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
return reject(messageOf(error));
|
|
291
|
+
}
|
|
292
|
+
if (declaration === undefined) {
|
|
293
|
+
return reject(`link target ${locator} is not inside an installed ${PLAYBOOK_PACKAGE} package`);
|
|
294
|
+
}
|
|
295
|
+
if (!declaresComposedV3(declaration)) {
|
|
296
|
+
return reject(`${describeRuntimeDeclaration(declaration)}; composed-v3 requires RUNTIME_ABI 1 and artifact schema 3`);
|
|
297
|
+
}
|
|
298
|
+
return 'composed-v3';
|
|
223
299
|
}
|
|
224
300
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAA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AAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;IACjD,MAAM,MAAM,GAAG,CAAC,MAAc,EAAS,EAAE;QACvC,MAAM,IAAI,KAAK,CACb,iDAAiD,UAAU,KAAK,MAAM,GAAG,CAC1E,CAAC;IACJ,CAAC,CAAC;IACF,IAAI,WAAW,CAAC;IAChB,IAAI,CAAC;QACH,WAAW,GAAG,MAAM,8BAA8B,CAChD,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CACrC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,CACX,eAAe,OAAO,+BAA+B,gBAAgB,UAAU,CAChF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,OAAO,MAAM,CACX,GAAG,0BAA0B,CAAC,WAAW,CAAC,4DAA4D,CACvG,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/** One deterministic extension correction applied to an emitted import. */
|
|
2
|
+
export interface ImportSpecifierRewrite {
|
|
3
|
+
from: string;
|
|
4
|
+
to: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Settles relative `.js`/`.ts` imports of the link's object artifacts from the
|
|
8
|
+
* files that actually exist beside an emitted module. A materialized
|
|
9
|
+
* JavaScript sibling wins; otherwise the declared TypeScript object's sibling
|
|
10
|
+
* is used when present. Unrelated imports and object specifiers with neither
|
|
11
|
+
* sibling are left for
|
|
12
|
+
* {@link unresolvableRelativeImports} to reject.
|
|
13
|
+
*/
|
|
14
|
+
export declare function reconcileLinkObjectImportSpecifiers(modulePath: string, objectPaths: readonly string[]): Promise<ImportSpecifierRewrite[]>;
|
|
1
15
|
/**
|
|
2
16
|
* The relative import specifiers of a `.ts`/`.js` module that do not resolve
|
|
3
17
|
* to an existing file from the module's own directory, in source order.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitted-imports.d.ts","sourceRoot":"","sources":["../src/emitted-imports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emitted-imports.d.ts","sourceRoot":"","sources":["../src/emitted-imports.ts"],"names":[],"mappings":"AAuBA,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAKD;;;;;;;GAOG;AACH,wBAAsB,mCAAmC,CACvD,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA8CnC;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
|
package/dist/emitted-imports.js
CHANGED
|
@@ -1,19 +1,75 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
/**
|
|
4
|
-
* Deterministic load-integrity
|
|
4
|
+
* Deterministic link-object import settlement and load-integrity checks for
|
|
5
|
+
* emitted modules (pipeline-40, verification-18).
|
|
5
6
|
*
|
|
6
7
|
* A linked artifact is code whose relative imports Node resolves with exact
|
|
7
8
|
* specifiers — `./workflow.fsm.js` does not find `workflow.fsm.ts`. An
|
|
8
|
-
* agent-performed link can emit the wrong extension
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* agent-performed link can emit the wrong extension for its object import. The
|
|
10
|
+
* host settles that exact edge mechanically against a `.js` or `.ts` sibling
|
|
11
|
+
* that currently exists, then requires every relative specifier to name an
|
|
12
|
+
* existing file beside it. A genuinely unloadable module still fails before
|
|
13
|
+
* the first `playbook run`.
|
|
12
14
|
*/
|
|
13
|
-
import { existsSync } from 'node:fs';
|
|
14
|
-
import { readFile } from 'node:fs/promises';
|
|
15
|
+
import { existsSync, statSync } from 'node:fs';
|
|
16
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
15
17
|
import { dirname, resolve } from 'node:path';
|
|
16
18
|
const IMPORT_SPECIFIER = /\bfrom\s+(['"])([^'"\n]+)\1|\bimport\s*\(\s*(['"])([^'"\n]+)\3\s*\)|\bimport\s+(['"])([^'"\n]+)\5/g;
|
|
19
|
+
const isRegularFile = (path) => statSync(path, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
20
|
+
/**
|
|
21
|
+
* Settles relative `.js`/`.ts` imports of the link's object artifacts from the
|
|
22
|
+
* files that actually exist beside an emitted module. A materialized
|
|
23
|
+
* JavaScript sibling wins; otherwise the declared TypeScript object's sibling
|
|
24
|
+
* is used when present. Unrelated imports and object specifiers with neither
|
|
25
|
+
* sibling are left for
|
|
26
|
+
* {@link unresolvableRelativeImports} to reject.
|
|
27
|
+
*/
|
|
28
|
+
export async function reconcileLinkObjectImportSpecifiers(modulePath, objectPaths) {
|
|
29
|
+
const source = await readFile(modulePath, 'utf8');
|
|
30
|
+
const dir = dirname(modulePath);
|
|
31
|
+
const emittedPath = resolve(modulePath);
|
|
32
|
+
const objectStems = new Set(objectPaths
|
|
33
|
+
.map((path) => resolve(path))
|
|
34
|
+
.filter((path) => path.endsWith('.js') || path.endsWith('.ts'))
|
|
35
|
+
.map((path) => path.slice(0, -3)));
|
|
36
|
+
const rewrites = [];
|
|
37
|
+
let cursor = 0;
|
|
38
|
+
let reconciled = '';
|
|
39
|
+
for (const match of source.matchAll(IMPORT_SPECIFIER)) {
|
|
40
|
+
const specifier = match[2] ?? match[4] ?? match[6];
|
|
41
|
+
if (specifier === undefined || match.index === undefined)
|
|
42
|
+
continue;
|
|
43
|
+
if (!specifier.startsWith('./') && !specifier.startsWith('../'))
|
|
44
|
+
continue;
|
|
45
|
+
if (!specifier.endsWith('.js') && !specifier.endsWith('.ts'))
|
|
46
|
+
continue;
|
|
47
|
+
const stem = specifier.slice(0, -3);
|
|
48
|
+
if (!objectStems.has(resolve(dir, stem)))
|
|
49
|
+
continue;
|
|
50
|
+
const jsSpecifier = `${stem}.js`;
|
|
51
|
+
const tsSpecifier = `${stem}.ts`;
|
|
52
|
+
const jsPath = resolve(dir, jsSpecifier);
|
|
53
|
+
const tsPath = resolve(dir, tsSpecifier);
|
|
54
|
+
const preferred = jsPath !== emittedPath && isRegularFile(jsPath)
|
|
55
|
+
? jsSpecifier
|
|
56
|
+
: tsPath !== emittedPath && isRegularFile(tsPath)
|
|
57
|
+
? tsSpecifier
|
|
58
|
+
: specifier;
|
|
59
|
+
if (preferred === specifier)
|
|
60
|
+
continue;
|
|
61
|
+
const specifierIndex = match[0].indexOf(specifier);
|
|
62
|
+
const start = match.index + specifierIndex;
|
|
63
|
+
reconciled += source.slice(cursor, start) + preferred;
|
|
64
|
+
cursor = start + specifier.length;
|
|
65
|
+
rewrites.push({ from: specifier, to: preferred });
|
|
66
|
+
}
|
|
67
|
+
if (rewrites.length > 0) {
|
|
68
|
+
reconciled += source.slice(cursor);
|
|
69
|
+
await writeFile(modulePath, reconciled, 'utf8');
|
|
70
|
+
}
|
|
71
|
+
return rewrites;
|
|
72
|
+
}
|
|
17
73
|
/**
|
|
18
74
|
* The relative import specifiers of a `.ts`/`.js` module that do not resolve
|
|
19
75
|
* to an existing file from the module's own directory, in source order.
|