@sublang/slc 0.1.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/LICENSE +201 -0
- package/README.md +192 -0
- package/dist/app.d.ts +85 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +233 -0
- package/dist/app.js.map +1 -0
- package/dist/artifacts.d.ts +61 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +97 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/cligent-agent.d.ts +11 -0
- package/dist/cligent-agent.d.ts.map +1 -0
- package/dist/cligent-agent.js +66 -0
- package/dist/cligent-agent.js.map +1 -0
- package/dist/compiled-executor.d.ts +42 -0
- package/dist/compiled-executor.d.ts.map +1 -0
- package/dist/compiled-executor.js +433 -0
- package/dist/compiled-executor.js.map +1 -0
- package/dist/config-file.d.ts +52 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +159 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +161 -0
- package/dist/config.js.map +1 -0
- package/dist/entry-module.d.ts +22 -0
- package/dist/entry-module.d.ts.map +1 -0
- package/dist/entry-module.js +216 -0
- package/dist/entry-module.js.map +1 -0
- package/dist/execution.d.ts +71 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +207 -0
- package/dist/execution.js.map +1 -0
- package/dist/file-capability.d.ts +46 -0
- package/dist/file-capability.d.ts.map +1 -0
- package/dist/file-capability.js +234 -0
- package/dist/file-capability.js.map +1 -0
- package/dist/file-grants.d.ts +79 -0
- package/dist/file-grants.d.ts.map +1 -0
- package/dist/file-grants.js +133 -0
- package/dist/file-grants.js.map +1 -0
- package/dist/hash.d.ts +14 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +34 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter.d.ts +48 -0
- package/dist/interpreter.d.ts.map +1 -0
- package/dist/interpreter.js +118 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/invocation.d.ts +64 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +148 -0
- package/dist/invocation.js.map +1 -0
- package/dist/link.d.ts +63 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +172 -0
- package/dist/link.js.map +1 -0
- package/dist/markdown.d.ts +12 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +63 -0
- package/dist/markdown.js.map +1 -0
- package/dist/normalize.md +68 -0
- package/dist/phase-runner.d.ts +64 -0
- package/dist/phase-runner.d.ts.map +1 -0
- package/dist/phase-runner.js +322 -0
- package/dist/phase-runner.js.map +1 -0
- package/dist/phase.d.ts +62 -0
- package/dist/phase.d.ts.map +1 -0
- package/dist/phase.js +111 -0
- package/dist/phase.js.map +1 -0
- package/dist/pin-closure.d.ts +19 -0
- package/dist/pin-closure.d.ts.map +1 -0
- package/dist/pin-closure.js +110 -0
- package/dist/pin-closure.js.map +1 -0
- package/dist/pin-currency.d.ts +55 -0
- package/dist/pin-currency.d.ts.map +1 -0
- package/dist/pin-currency.js +435 -0
- package/dist/pin-currency.js.map +1 -0
- package/dist/pin-generate.d.ts +46 -0
- package/dist/pin-generate.d.ts.map +1 -0
- package/dist/pin-generate.js +131 -0
- package/dist/pin-generate.js.map +1 -0
- package/dist/pin-paths.d.ts +11 -0
- package/dist/pin-paths.d.ts.map +1 -0
- package/dist/pin-paths.js +108 -0
- package/dist/pin-paths.js.map +1 -0
- package/dist/pins.d.ts +84 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +265 -0
- package/dist/pins.js.map +1 -0
- package/dist/pipeline.d.ts +61 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +147 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/playbook-contract.d.ts +194 -0
- package/dist/playbook-contract.d.ts.map +1 -0
- package/dist/playbook-contract.js +180 -0
- package/dist/playbook-contract.js.map +1 -0
- package/dist/playbook-ports.d.ts +53 -0
- package/dist/playbook-ports.d.ts.map +1 -0
- package/dist/playbook-ports.js +217 -0
- package/dist/playbook-ports.js.map +1 -0
- package/dist/resolver.d.ts +68 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +133 -0
- package/dist/resolver.js.map +1 -0
- package/dist/runner.d.ts +45 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +506 -0
- package/dist/runner.js.map +1 -0
- package/dist/runtime-package.d.ts +7 -0
- package/dist/runtime-package.d.ts.map +1 -0
- package/dist/runtime-package.js +132 -0
- package/dist/runtime-package.js.map +1 -0
- package/dist/slc.config.template.yaml +5 -0
- package/dist/verify-coverage.d.ts +99 -0
- package/dist/verify-coverage.d.ts.map +1 -0
- package/dist/verify-coverage.js +1949 -0
- package/dist/verify-coverage.js.map +1 -0
- package/dist/verify-support.d.ts +10 -0
- package/dist/verify-support.d.ts.map +1 -0
- package/dist/verify-support.js +52 -0
- package/dist/verify-support.js.map +1 -0
- package/dist/verify.d.ts +393 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +1790 -0
- package/dist/verify.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.js","sourceRoot":"","sources":["../src/config-file.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAA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,eAAe,GAAG,QAAQ,IAAI,6BAA6B,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAc,EACd,GAAW,EACX,IAAY;IAEZ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CACvB,gBAAgB,EAChB,eAAe,GAAG,QAAQ,IAAI,gCAAgC,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACrD,MAAM,IAAI,eAAe,CACvB,gBAAgB,EAChB,eAAe,GAAG,IAAI,KAAK,SAAS,IAAI,6BAA6B,CACtE,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AgentAdapter, PermissionPolicy } from '@sublang/cligent';
|
|
2
|
+
import type { PhaseExecutor } from './execution.js';
|
|
3
|
+
import type { AgentClient } from './interpreter.js';
|
|
4
|
+
import type { CompiledSelection } from './runner.js';
|
|
5
|
+
/** Agent CLI ids the executable registers (CLI-7). */
|
|
6
|
+
export declare const SUPPORTED_AGENTS: readonly ["claude-code", "codex", "gemini", "opencode"];
|
|
7
|
+
/** One of the registered agent CLI ids (CLI-7). */
|
|
8
|
+
export type SupportedAgent = (typeof SUPPORTED_AGENTS)[number];
|
|
9
|
+
/** Constructs the Cligent adapter for a supported agent id (CLI-7). */
|
|
10
|
+
export type AdapterFactory = (agent: SupportedAgent) => AgentAdapter;
|
|
11
|
+
/** Default factory: Cligent's built-in adapters, constructed on demand (CLI-7). */
|
|
12
|
+
export declare const defaultAdapterFactory: AdapterFactory;
|
|
13
|
+
/** A resolved agent/model/effort selection (CLI-7). */
|
|
14
|
+
export interface AgentSelection {
|
|
15
|
+
agent: SupportedAgent;
|
|
16
|
+
/** Optional model; omitted so the agent CLI uses its own default. */
|
|
17
|
+
model?: string;
|
|
18
|
+
/** Optional adapter-scoped reasoning effort; omitted for the default. */
|
|
19
|
+
effort?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Machine-readable reason agent configuration was refused (CLI-12). */
|
|
22
|
+
export type ConfigErrorCode = 'agent-unset' | 'agent-unsupported' | 'effort-unsupported';
|
|
23
|
+
/** Raised when `SLC_AGENT` is unset or names an unsupported agent CLI (CLI-12). */
|
|
24
|
+
export declare class ConfigError extends Error {
|
|
25
|
+
readonly code: ConfigErrorCode;
|
|
26
|
+
constructor(code: ConfigErrorCode, message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Reports whether `agent` is one of the registered ids (CLI-7). */
|
|
29
|
+
export declare function isSupportedAgent(agent: string): agent is SupportedAgent;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the agent/model/effort selection from environment configuration
|
|
32
|
+
* (CLI-7, CLI-12): `SLC_AGENT` names a registered agent CLI, `SLC_MODEL`
|
|
33
|
+
* optionally names a model, and `SLC_EFFORT` optionally selects an
|
|
34
|
+
* adapter-scoped reasoning effort validated against Cligent's support
|
|
35
|
+
* metadata.
|
|
36
|
+
*
|
|
37
|
+
* @throws {ConfigError} when `SLC_AGENT` is unset/blank (`agent-unset`) or
|
|
38
|
+
* outside the registered set (`agent-unsupported`), or when `SLC_EFFORT`
|
|
39
|
+
* names a value the selected agent does not support
|
|
40
|
+
* (`effort-unsupported`); no implicit default agent is applied.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveAgentSelection(env: Record<string, string | undefined>): AgentSelection;
|
|
43
|
+
/**
|
|
44
|
+
* Builds the interpreted {@link PhaseExecutor} for a selection (CLI-7, CLI-8):
|
|
45
|
+
* constructs the agent CLI's adapter, wraps it as a Cligent-backed transport,
|
|
46
|
+
* and binds the optional model as configuration, not phase semantics
|
|
47
|
+
* (PHEXEC-13). The adapter factory is injectable so tests can fake adapter
|
|
48
|
+
* construction; `permissions` is where a host configures the DR-003 write-scope
|
|
49
|
+
* sandbox.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createConfiguredExecutor(selection: AgentSelection, opts?: {
|
|
52
|
+
adapterFactory?: AdapterFactory;
|
|
53
|
+
cwd?: string;
|
|
54
|
+
maxTurns?: number;
|
|
55
|
+
permissions?: PermissionPolicy;
|
|
56
|
+
}): PhaseExecutor;
|
|
57
|
+
/**
|
|
58
|
+
* Builds one Cligent-backed {@link AgentClient} for a selection (CLI-7): a fresh
|
|
59
|
+
* adapter wrapped as a transport. Each client is a single-flight Cligent
|
|
60
|
+
* instance that resumes its own agent session across calls, so callers wanting
|
|
61
|
+
* isolated sessions construct one client per role or player.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createConfiguredAgentClient(selection: AgentSelection, opts?: {
|
|
64
|
+
adapterFactory?: AdapterFactory;
|
|
65
|
+
maxTurns?: number;
|
|
66
|
+
permissions?: PermissionPolicy;
|
|
67
|
+
}): AgentClient;
|
|
68
|
+
/**
|
|
69
|
+
* Builds the compiled-execution factory the bin injects as `SlcDeps.compiled`
|
|
70
|
+
* (CLI-8, PHEXEC-27): for a current pinned phase it drives the pinned `playbook`
|
|
71
|
+
* artifact — resolved against its pipeline directory — through the compiled
|
|
72
|
+
* executor, backing the runtime's player ports with one agent transport per
|
|
73
|
+
* player id and its Captain/judge ports with one shared transport (PHEXEC-25),
|
|
74
|
+
* and applying the selected model as the default per-player model (PHEXEC-13).
|
|
75
|
+
*/
|
|
76
|
+
export declare function createConfiguredCompiledFactory(selection: AgentSelection, opts?: {
|
|
77
|
+
adapterFactory?: AdapterFactory;
|
|
78
|
+
cwd?: string;
|
|
79
|
+
maxTurns?: number;
|
|
80
|
+
permissions?: PermissionPolicy;
|
|
81
|
+
}): (choice: CompiledSelection) => PhaseExecutor;
|
|
82
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,yDAKnB,CAAC;AAEX,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,YAAY,CAAC;AAErE,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,EAAE,cAWnC,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,CAAC;AAEzB,mFAAmF;AACnF,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;gBAEnB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,cAAc,CA2BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,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;CAC3B,GACL,aAAa,CAMf;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;CAC3B,GACL,WAAW,CAUb;AAED;;;;;;;GAOG;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;CAC3B,GACL,CAAC,MAAM,EAAE,iBAAiB,KAAK,aAAa,CAc9C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/**
|
|
4
|
+
* Agent/model configuration and executor construction for the `slc` bin (CLI-7,
|
|
5
|
+
* CLI-8, CLI-12, DR-004, DR-005).
|
|
6
|
+
*
|
|
7
|
+
* `resolveAgentSelection` reads `SLC_AGENT`/`SLC_MODEL` from the environment and
|
|
8
|
+
* refuses an unset or unsupported agent with no implicit default (CLI-12).
|
|
9
|
+
* `createConfiguredExecutor` builds the interpreted executor and
|
|
10
|
+
* `createConfiguredCompiledFactory` the compiled-execution factory pinned phases
|
|
11
|
+
* select, both over Cligent-backed transports for the selected agent, binding
|
|
12
|
+
* the optional model as configuration — not phase semantics (PHEXEC-13);
|
|
13
|
+
* credentials are left for the agent CLI to read from the inherited process
|
|
14
|
+
* environment. The adapter factory is injectable so tests can fake adapter
|
|
15
|
+
* construction. See specs/dev/cli.md.
|
|
16
|
+
*/
|
|
17
|
+
import { resolve } from 'node:path';
|
|
18
|
+
import { ClaudeCodeAdapter } from '@sublang/cligent/adapters/claude-code';
|
|
19
|
+
import { CodexAdapter } from '@sublang/cligent/adapters/codex';
|
|
20
|
+
import { GeminiAdapter } from '@sublang/cligent/adapters/gemini';
|
|
21
|
+
import { OpenCodeAdapter } from '@sublang/cligent/adapters/opencode';
|
|
22
|
+
import { isEffortSupported, supportedEffortValues } from '@sublang/cligent';
|
|
23
|
+
import { createCligentAgent } from './cligent-agent.js';
|
|
24
|
+
import { createCompiledExecutor } from './compiled-executor.js';
|
|
25
|
+
import { createInterpretedExecutor } from './interpreter.js';
|
|
26
|
+
/** Agent CLI ids the executable registers (CLI-7). */
|
|
27
|
+
export const SUPPORTED_AGENTS = [
|
|
28
|
+
'claude-code',
|
|
29
|
+
'codex',
|
|
30
|
+
'gemini',
|
|
31
|
+
'opencode',
|
|
32
|
+
];
|
|
33
|
+
/** Default factory: Cligent's built-in adapters, constructed on demand (CLI-7). */
|
|
34
|
+
export const defaultAdapterFactory = (agent) => {
|
|
35
|
+
switch (agent) {
|
|
36
|
+
case 'claude-code':
|
|
37
|
+
return new ClaudeCodeAdapter();
|
|
38
|
+
case 'codex':
|
|
39
|
+
return new CodexAdapter();
|
|
40
|
+
case 'gemini':
|
|
41
|
+
return new GeminiAdapter();
|
|
42
|
+
case 'opencode':
|
|
43
|
+
return new OpenCodeAdapter();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/** Raised when `SLC_AGENT` is unset or names an unsupported agent CLI (CLI-12). */
|
|
47
|
+
export class ConfigError extends Error {
|
|
48
|
+
code;
|
|
49
|
+
constructor(code, message) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = 'ConfigError';
|
|
52
|
+
this.code = code;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Reports whether `agent` is one of the registered ids (CLI-7). */
|
|
56
|
+
export function isSupportedAgent(agent) {
|
|
57
|
+
return SUPPORTED_AGENTS.includes(agent);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the agent/model/effort selection from environment configuration
|
|
61
|
+
* (CLI-7, CLI-12): `SLC_AGENT` names a registered agent CLI, `SLC_MODEL`
|
|
62
|
+
* optionally names a model, and `SLC_EFFORT` optionally selects an
|
|
63
|
+
* adapter-scoped reasoning effort validated against Cligent's support
|
|
64
|
+
* metadata.
|
|
65
|
+
*
|
|
66
|
+
* @throws {ConfigError} when `SLC_AGENT` is unset/blank (`agent-unset`) or
|
|
67
|
+
* outside the registered set (`agent-unsupported`), or when `SLC_EFFORT`
|
|
68
|
+
* names a value the selected agent does not support
|
|
69
|
+
* (`effort-unsupported`); no implicit default agent is applied.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveAgentSelection(env) {
|
|
72
|
+
const agent = (env.SLC_AGENT ?? '').trim();
|
|
73
|
+
if (agent === '') {
|
|
74
|
+
throw new ConfigError('agent-unset', `SLC_AGENT is not set; set it to one of: ${SUPPORTED_AGENTS.join(', ')}`);
|
|
75
|
+
}
|
|
76
|
+
if (!isSupportedAgent(agent)) {
|
|
77
|
+
throw new ConfigError('agent-unsupported', `SLC_AGENT "${agent}" is not a supported agent CLI; choose one of: ${SUPPORTED_AGENTS.join(', ')}`);
|
|
78
|
+
}
|
|
79
|
+
const model = (env.SLC_MODEL ?? '').trim();
|
|
80
|
+
const effort = (env.SLC_EFFORT ?? '').trim();
|
|
81
|
+
if (effort !== '' && !isEffortSupported(agent, effort)) {
|
|
82
|
+
throw new ConfigError('effort-unsupported', `SLC_EFFORT "${effort}" is not supported by ${agent}; choose one of: ${(supportedEffortValues(agent) ?? []).join(', ')}`);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
agent,
|
|
86
|
+
model: model === '' ? undefined : model,
|
|
87
|
+
effort: effort === '' ? undefined : effort,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Builds the interpreted {@link PhaseExecutor} for a selection (CLI-7, CLI-8):
|
|
92
|
+
* constructs the agent CLI's adapter, wraps it as a Cligent-backed transport,
|
|
93
|
+
* and binds the optional model as configuration, not phase semantics
|
|
94
|
+
* (PHEXEC-13). The adapter factory is injectable so tests can fake adapter
|
|
95
|
+
* construction; `permissions` is where a host configures the DR-003 write-scope
|
|
96
|
+
* sandbox.
|
|
97
|
+
*/
|
|
98
|
+
export function createConfiguredExecutor(selection, opts = {}) {
|
|
99
|
+
const agent = createConfiguredAgentClient(selection, opts);
|
|
100
|
+
return createInterpretedExecutor({
|
|
101
|
+
agent,
|
|
102
|
+
config: { model: selection.model, cwd: opts.cwd },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Builds one Cligent-backed {@link AgentClient} for a selection (CLI-7): a fresh
|
|
107
|
+
* adapter wrapped as a transport. Each client is a single-flight Cligent
|
|
108
|
+
* instance that resumes its own agent session across calls, so callers wanting
|
|
109
|
+
* isolated sessions construct one client per role or player.
|
|
110
|
+
*/
|
|
111
|
+
export function createConfiguredAgentClient(selection, opts = {}) {
|
|
112
|
+
const adapter = (opts.adapterFactory ?? defaultAdapterFactory)(selection.agent);
|
|
113
|
+
return createCligentAgent({
|
|
114
|
+
adapter,
|
|
115
|
+
maxTurns: opts.maxTurns,
|
|
116
|
+
permissions: opts.permissions,
|
|
117
|
+
effort: selection.effort,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Builds the compiled-execution factory the bin injects as `SlcDeps.compiled`
|
|
122
|
+
* (CLI-8, PHEXEC-27): for a current pinned phase it drives the pinned `playbook`
|
|
123
|
+
* artifact — resolved against its pipeline directory — through the compiled
|
|
124
|
+
* executor, backing the runtime's player ports with one agent transport per
|
|
125
|
+
* player id and its Captain/judge ports with one shared transport (PHEXEC-25),
|
|
126
|
+
* and applying the selected model as the default per-player model (PHEXEC-13).
|
|
127
|
+
*/
|
|
128
|
+
export function createConfiguredCompiledFactory(selection, opts = {}) {
|
|
129
|
+
const client = () => createConfiguredAgentClient(selection, opts);
|
|
130
|
+
return (choice) => createCompiledExecutor({
|
|
131
|
+
artifactPath: resolve(choice.pipelineDir, choice.record.artifact.path),
|
|
132
|
+
runRoot: opts.cwd ?? process.cwd(),
|
|
133
|
+
playbookId: choice.phase,
|
|
134
|
+
runtimeContract: runtimeContractForPin(choice),
|
|
135
|
+
player: () => client(),
|
|
136
|
+
judge: client(),
|
|
137
|
+
defaultModel: selection.model,
|
|
138
|
+
cwd: opts.cwd,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function runtimeContractForPin(choice) {
|
|
142
|
+
const provenance = choice.record.linkTarget.provenance;
|
|
143
|
+
if (provenance === undefined || provenance === '@sublang/playbook@0.9.0') {
|
|
144
|
+
return 'legacy';
|
|
145
|
+
}
|
|
146
|
+
// Playbook 0.10 ships the composed six-port contract (DR-011); artifacts
|
|
147
|
+
// linked against it run through the composed session profile. 1.0.0 is the
|
|
148
|
+
// published release of that same contract generation — 0.10.0 was cut
|
|
149
|
+
// locally and superseded before it ever reached the registry. 2.0.0 keeps
|
|
150
|
+
// the six-port boundary and structured results while moving Captain host
|
|
151
|
+
// failures onto the resolved `failed` path and emitting thin linked
|
|
152
|
+
// modules (DR-017), so all three provenances select the composed profile.
|
|
153
|
+
// 1.3.0 was never installed or reviewed and stays fail-closed.
|
|
154
|
+
if (provenance === '@sublang/playbook@0.10.0' ||
|
|
155
|
+
provenance === '@sublang/playbook@1.0.0' ||
|
|
156
|
+
provenance === '@sublang/playbook@2.0.0') {
|
|
157
|
+
return 'composed-v2';
|
|
158
|
+
}
|
|
159
|
+
throw new Error(`unsupported pinned Playbook runtime contract: ${provenance}`);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;GAaG;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,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,aAAa;IACb,OAAO;IACP,QAAQ;IACR,UAAU;CACF,CAAC;AAQX,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAAmB,CAAC,KAAK,EAAE,EAAE;IAC7D,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,aAAa;YAChB,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,IAAI,YA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,GAAgB,EAAE,CAC/B,2BAA2B,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,sBAAsB,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtE,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;QAClC,UAAU,EAAE,MAAM,CAAC,KAAK;QACxB,eAAe,EAAE,qBAAqB,CAAC,MAAM,CAAC;QAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE;QACtB,KAAK,EAAE,MAAM,EAAE;QACf,YAAY,EAAE,SAAS,CAAC,KAAK;QAC7B,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC,CAAC;AACP,CAAC;AAED,SAAS,qBAAqB,CAC5B,MAAyB;IAEzB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;IACvD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,yBAAyB,EAAE,CAAC;QACzE,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,yEAAyE;IACzE,2EAA2E;IAC3E,sEAAsE;IACtE,0EAA0E;IAC1E,yEAAyE;IACzE,oEAAoE;IACpE,0EAA0E;IAC1E,+DAA+D;IAC/D,IACE,UAAU,KAAK,0BAA0B;QACzC,UAAU,KAAK,yBAAyB;QACxC,UAAU,KAAK,yBAAyB,EACxC,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,UAAU,EAAE,CAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Options for {@link emitEntryModule}. */
|
|
2
|
+
export interface EmitEntryModuleOptions {
|
|
3
|
+
/** Invocation working directory the module is written into (DR-014). */
|
|
4
|
+
cwd: string;
|
|
5
|
+
/** The DR-001 basename naming the entry module and the bundle. */
|
|
6
|
+
basename: string;
|
|
7
|
+
/** Pipeline reference forming the bundle directory leaf `<basename>.<pipeline>`. */
|
|
8
|
+
pipeline: string;
|
|
9
|
+
/** The optimized gears artifact: players and script items. */
|
|
10
|
+
gearsPath: string;
|
|
11
|
+
/** The normalized (or entry-form) text source: title and lead line. */
|
|
12
|
+
textPath: string;
|
|
13
|
+
}
|
|
14
|
+
/** Emits the entry module and returns its path. */
|
|
15
|
+
export declare function emitEntryModule(opts: EmitEntryModuleOptions): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* The gears `Players:` declaration, verbatim in source order (SELFHOST-15).
|
|
18
|
+
* Alias declarations (`` `A` = `B` | `C` ``) are launcher options, not
|
|
19
|
+
* required roles, and are excluded.
|
|
20
|
+
*/
|
|
21
|
+
export declare function declaredPlayers(gears: string): string[];
|
|
22
|
+
//# sourceMappingURL=entry-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-module.d.ts","sourceRoot":"","sources":["../src/entry-module.ts"],"names":[],"mappings":"AAwBA,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAC;IACZ,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mDAAmD;AACnD,wBAAsB,eAAe,CACnC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBvD"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic entry-module emission (DR-014, DR-017, SELFHOST-15).
|
|
5
|
+
*
|
|
6
|
+
* After a successful full-link of the `playbook` pipeline, {@link
|
|
7
|
+
* emitEntryModule} writes `<cwd>/<basename>.ts`: an erasable-TypeScript module
|
|
8
|
+
* default-exporting a Playbook registry entry derived entirely from the
|
|
9
|
+
* compiled bundle — `id`/`command` from the basename, `requiredRoleIds` from
|
|
10
|
+
* the gears `Players:` declaration, `intent` from the normalized source's
|
|
11
|
+
* title and lead line, an option allowlist carrying `cwd` exactly when the
|
|
12
|
+
* source compiled a script item, and `createRuntime` wiring the linked default
|
|
13
|
+
* factory behind the DR-017 role-binding boundary, which maps the linked
|
|
14
|
+
* runtime's lowercased player ids back to the declared role ids at the
|
|
15
|
+
* session's `callPlayer` port. `playbook run ./<basename>.ts "<task>"`
|
|
16
|
+
* consumes it unchanged (SELFHOST-14). See specs/dev/self-hosting.md.
|
|
17
|
+
*/
|
|
18
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
import { parseGearsItems } from './verify.js';
|
|
21
|
+
/** Emits the entry module and returns its path. */
|
|
22
|
+
export async function emitEntryModule(opts) {
|
|
23
|
+
const gears = await readFile(opts.gearsPath, 'utf8');
|
|
24
|
+
const text = await readFile(opts.textPath, 'utf8');
|
|
25
|
+
const players = declaredPlayers(gears);
|
|
26
|
+
// The role-binding boundary keys declared ids by their lowercased form; a
|
|
27
|
+
// case-insensitive collision would make the binding ambiguous (DR-017).
|
|
28
|
+
const byLowered = new Map();
|
|
29
|
+
for (const player of players) {
|
|
30
|
+
const existing = byLowered.get(player.toLowerCase());
|
|
31
|
+
if (existing !== undefined && existing !== player) {
|
|
32
|
+
throw new Error(`entry emission failed: declared players "${existing}" and "${player}" collide case-insensitively`);
|
|
33
|
+
}
|
|
34
|
+
byLowered.set(player.toLowerCase(), player);
|
|
35
|
+
}
|
|
36
|
+
const hasScript = parseGearsItems(gears).some((item) => item.actor === 'script');
|
|
37
|
+
const intent = deriveIntent(text) ?? opts.basename;
|
|
38
|
+
const path = join(opts.cwd, `${opts.basename}.ts`);
|
|
39
|
+
await writeFile(path, renderEntryModule({
|
|
40
|
+
basename: opts.basename,
|
|
41
|
+
bundleLeaf: `${opts.basename}.${opts.pipeline}`,
|
|
42
|
+
players,
|
|
43
|
+
hasScript,
|
|
44
|
+
intent,
|
|
45
|
+
}), 'utf8');
|
|
46
|
+
return path;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The gears `Players:` declaration, verbatim in source order (SELFHOST-15).
|
|
50
|
+
* Alias declarations (`` `A` = `B` | `C` ``) are launcher options, not
|
|
51
|
+
* required roles, and are excluded.
|
|
52
|
+
*/
|
|
53
|
+
export function declaredPlayers(gears) {
|
|
54
|
+
const players = [];
|
|
55
|
+
let inBlock = false;
|
|
56
|
+
for (const line of gears.split('\n')) {
|
|
57
|
+
if (/^Players:\s*$/.test(line)) {
|
|
58
|
+
inBlock = true;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!inBlock)
|
|
62
|
+
continue;
|
|
63
|
+
const bullet = /^-\s+(.*)$/.exec(line.trim());
|
|
64
|
+
if (bullet === null) {
|
|
65
|
+
if (line.trim() === '')
|
|
66
|
+
continue;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
const declaration = bullet[1];
|
|
70
|
+
if (declaration.includes('='))
|
|
71
|
+
continue;
|
|
72
|
+
const name = /^[`"“]?([^`"”]+?)[`"”]?\s*$/.exec(declaration.trim());
|
|
73
|
+
if (name !== null && name[1].length > 0)
|
|
74
|
+
players.push(name[1]);
|
|
75
|
+
}
|
|
76
|
+
return players;
|
|
77
|
+
}
|
|
78
|
+
/** Title and lead line of the normalized source, joined as the intent. */
|
|
79
|
+
function deriveIntent(text) {
|
|
80
|
+
let title;
|
|
81
|
+
let lead;
|
|
82
|
+
for (const line of text.split('\n')) {
|
|
83
|
+
const trimmed = line.trim();
|
|
84
|
+
if (trimmed === '' || trimmed.startsWith('<!--'))
|
|
85
|
+
continue;
|
|
86
|
+
if (title === undefined) {
|
|
87
|
+
const heading = /^#\s+(.*)$/.exec(trimmed);
|
|
88
|
+
if (heading !== null) {
|
|
89
|
+
title = heading[1].trim();
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (trimmed.startsWith('#') ||
|
|
94
|
+
trimmed.startsWith('-') ||
|
|
95
|
+
/^Players:\s*$/.test(trimmed)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
lead = trimmed;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (title !== undefined && lead !== undefined)
|
|
102
|
+
return `${title} — ${lead}`;
|
|
103
|
+
return title ?? lead;
|
|
104
|
+
}
|
|
105
|
+
function renderEntryModule(spec) {
|
|
106
|
+
const allowed = spec.hasScript ? `['cwd']` : `[]`;
|
|
107
|
+
const cwdWiring = spec.hasScript
|
|
108
|
+
? `{\n ...validated,\n cwd: validated.cwd ?? process.cwd(),\n }`
|
|
109
|
+
: `validated`;
|
|
110
|
+
return `// SPDX-License-Identifier: Apache-2.0
|
|
111
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
112
|
+
//
|
|
113
|
+
// Generated by slc (DR-014): the registry entry exposing the compiled
|
|
114
|
+
// playbook to \`playbook run\`. Derived deterministically from the compiled
|
|
115
|
+
// bundle; recompiling regenerates it. The role-binding boundary (DR-017)
|
|
116
|
+
// hands the host's \`callPlayer\` port only declared role ids.
|
|
117
|
+
|
|
118
|
+
import createPlaybookRuntime from './${spec.bundleLeaf}/${spec.basename}.playbook.ts';
|
|
119
|
+
|
|
120
|
+
type RuntimeOptions = NonNullable<Parameters<typeof createPlaybookRuntime>[0]>;
|
|
121
|
+
|
|
122
|
+
const ALLOWED_OPTION_KEYS: readonly string[] = ${allowed};
|
|
123
|
+
|
|
124
|
+
const REQUIRED_ROLE_IDS: readonly string[] = [${spec.players.map(sourceString).join(', ')}];
|
|
125
|
+
|
|
126
|
+
const ROLE_ID_BY_RESOLVED: ReadonlyMap<string, string> = new Map(
|
|
127
|
+
REQUIRED_ROLE_IDS.map((id): [string, string] => [id.toLowerCase(), id]),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
function bindRoleIds(session: unknown): unknown {
|
|
131
|
+
if (typeof session !== 'object' || session === null) return session;
|
|
132
|
+
const ports = (session as { ports?: unknown }).ports;
|
|
133
|
+
if (typeof ports !== 'object' || ports === null) return session;
|
|
134
|
+
const callPlayer = (ports as Record<string, unknown>).callPlayer;
|
|
135
|
+
if (typeof callPlayer !== 'function') return session;
|
|
136
|
+
return {
|
|
137
|
+
...session,
|
|
138
|
+
ports: {
|
|
139
|
+
...(ports as Record<string, unknown>),
|
|
140
|
+
callPlayer: (playerId: unknown, ...rest: unknown[]) =>
|
|
141
|
+
(callPlayer as (...args: unknown[]) => unknown).call(
|
|
142
|
+
ports,
|
|
143
|
+
typeof playerId === 'string'
|
|
144
|
+
? (ROLE_ID_BY_RESOLVED.get(playerId) ?? playerId)
|
|
145
|
+
: playerId,
|
|
146
|
+
...rest,
|
|
147
|
+
),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function withRoleBinding<T extends object>(runtime: T): T {
|
|
153
|
+
return new Proxy(runtime, {
|
|
154
|
+
get(target, property, receiver) {
|
|
155
|
+
const value = Reflect.get(target, property, receiver);
|
|
156
|
+
if (
|
|
157
|
+
(property === 'init' || property === 'restore') &&
|
|
158
|
+
typeof value === 'function'
|
|
159
|
+
) {
|
|
160
|
+
return (session: unknown, ...rest: unknown[]) =>
|
|
161
|
+
(value as (...args: unknown[]) => unknown).call(
|
|
162
|
+
target,
|
|
163
|
+
bindRoleIds(session),
|
|
164
|
+
...rest,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return value;
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function validateOptions(value: unknown): RuntimeOptions {
|
|
173
|
+
if (value === undefined) return {};
|
|
174
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
175
|
+
throw new Error('playbook options must be an object');
|
|
176
|
+
}
|
|
177
|
+
const options: Record<string, string> = {};
|
|
178
|
+
for (const [key, option] of Object.entries(value)) {
|
|
179
|
+
if (!ALLOWED_OPTION_KEYS.includes(key)) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
\`unknown option "\${key}" (allowed: \${ALLOWED_OPTION_KEYS.join(', ') || 'none'})\`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if (typeof option !== 'string' || option === '') {
|
|
185
|
+
throw new Error(\`option "\${key}" must be a non-empty string\`);
|
|
186
|
+
}
|
|
187
|
+
options[key] = option;
|
|
188
|
+
}
|
|
189
|
+
return options as RuntimeOptions;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const entry = {
|
|
193
|
+
id: ${sourceString(spec.basename)},
|
|
194
|
+
command: ${sourceString(spec.basename)},
|
|
195
|
+
intent: ${sourceString(spec.intent)},
|
|
196
|
+
requiredRoleIds: [...REQUIRED_ROLE_IDS],
|
|
197
|
+
validateOptions,
|
|
198
|
+
createRuntime(options: { captainOptions?: unknown }) {
|
|
199
|
+
const validated = validateOptions(options.captainOptions);
|
|
200
|
+
return withRoleBinding(createPlaybookRuntime(${cwdWiring}));
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default entry;
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
function sourceString(value) {
|
|
208
|
+
// Single-quoted source form (the repo's prettier style), derived from the
|
|
209
|
+
// JSON escape so control characters stay escaped.
|
|
210
|
+
const json = JSON.stringify(value)
|
|
211
|
+
.replace(/\u2028/g, '\\u2028')
|
|
212
|
+
.replace(/\u2029/g, '\\u2029');
|
|
213
|
+
const inner = json.slice(1, -1).replace(/\\"/g, '"').replace(/'/g, "\\'");
|
|
214
|
+
return `'${inner}'`;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=entry-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-module.js","sourceRoot":"","sources":["../src/entry-module.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAgB9C,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA4B;IAE5B,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACvC,0EAA0E;IAC1E,wEAAwE;IACxE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CACb,4CAA4C,QAAQ,UAAU,MAAM,8BAA8B,CACnG,CAAC;QACJ,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;I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OptionPair {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
/** What a phase execution is asked to produce: a compile target or a linked artifact. */
|
|
7
|
+
export type ExecuteRequest = {
|
|
8
|
+
kind: 'compile';
|
|
9
|
+
/** Path to the phase definition, the semantic source of truth (PHEXEC-2). */
|
|
10
|
+
definitionPath: string;
|
|
11
|
+
source: string;
|
|
12
|
+
target: string;
|
|
13
|
+
/**
|
|
14
|
+
* Read-only reference documents the definition tells the executor to
|
|
15
|
+
* consult — e.g. the entry-phase definition a generic normalize step
|
|
16
|
+
* rewrites the source toward (DR-013). Protected like definitions.
|
|
17
|
+
*/
|
|
18
|
+
references?: readonly string[];
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'link';
|
|
21
|
+
/** Path to the `link.md` definition, the semantic source of truth (PHEXEC-2). */
|
|
22
|
+
definitionPath: string;
|
|
23
|
+
objects: string[];
|
|
24
|
+
linkTarget: string;
|
|
25
|
+
options: LinkOptionPair[];
|
|
26
|
+
linked: string;
|
|
27
|
+
};
|
|
28
|
+
/** Terminal status an executor reports for a phase run. */
|
|
29
|
+
export type ExecutorStatus = 'ok' | 'blocked' | 'error';
|
|
30
|
+
/** The outcome an executor returns, with diagnostics drained for every status. */
|
|
31
|
+
export interface ExecutorResult {
|
|
32
|
+
status: ExecutorStatus;
|
|
33
|
+
diagnostics: string[];
|
|
34
|
+
}
|
|
35
|
+
/** Runs one phase or link execution; implemented by the interpreted/compiled executors. */
|
|
36
|
+
export interface PhaseExecutor {
|
|
37
|
+
run(request: ExecuteRequest, signal: AbortSignal): Promise<ExecutorResult>;
|
|
38
|
+
}
|
|
39
|
+
/** A failure naming the phase, target path, and reasons (PHEXEC-9). */
|
|
40
|
+
export interface FailureReport {
|
|
41
|
+
phase: string;
|
|
42
|
+
target: string;
|
|
43
|
+
reasons: string[];
|
|
44
|
+
}
|
|
45
|
+
/** The result of a generic-checked phase run. */
|
|
46
|
+
export type PhaseResult = {
|
|
47
|
+
ok: true;
|
|
48
|
+
target: string;
|
|
49
|
+
diagnostics: string[];
|
|
50
|
+
} | {
|
|
51
|
+
ok: false;
|
|
52
|
+
report: FailureReport;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Runs a single phase through the execution boundary: generic mechanics only,
|
|
56
|
+
* plus the DR-003 generic checks and blocked protocol (PHEXEC-1, PHEXEC-4..9).
|
|
57
|
+
*/
|
|
58
|
+
export declare function runPhase(opts: {
|
|
59
|
+
request: ExecuteRequest;
|
|
60
|
+
phase: string;
|
|
61
|
+
targetExt: string;
|
|
62
|
+
executor: PhaseExecutor;
|
|
63
|
+
/** Other chain definition files to protect; the executing phase's is always protected. */
|
|
64
|
+
definitions?: readonly string[];
|
|
65
|
+
/** Re-checks that the pipeline chain still infers; throws when it no longer does (PHEXEC-5). */
|
|
66
|
+
revalidate?: () => void | Promise<void>;
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}): Promise<PhaseResult>;
|
|
69
|
+
/** Renders a failure report as a multi-line diagnostic string (PHEXEC-9). */
|
|
70
|
+
export declare function formatFailureReport(report: FailureReport): string;
|
|
71
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AA4BA,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yFAAyF;AACzF,MAAM,MAAM,cAAc,GACtB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,6EAA6E;IAC7E,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;I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