@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,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cligent-backed `PlaybookPorts` adapter for compiled phase execution (PHEXEC-25;
|
|
3
|
+
* DR-005, DR-004).
|
|
4
|
+
*
|
|
5
|
+
* A compiled artifact reaches coding agents and judges only through Playbook's
|
|
6
|
+
* source-owned ports. This adapter backs those ports with the same
|
|
7
|
+
* {@link AgentClient} transport the interpreter uses (Cligent in production,
|
|
8
|
+
* fakes in tests): `callPlayer` runs a coding agent with Playbook's explicit
|
|
9
|
+
* continuation selection, `callCaptain` and `callJudge` share the Captain
|
|
10
|
+
* transport's single-flight queue, `callPlaybook` fails closed because SLC has
|
|
11
|
+
* no child stack, and status plus non-trace operational telemetry can be
|
|
12
|
+
* drained as diagnostics. A transformation-performing direct Captain call —
|
|
13
|
+
* one whose source-owned options carry no tool restriction — additionally
|
|
14
|
+
* carries the host workspace contract appended to its composed prompt, because
|
|
15
|
+
* the linked artifact is host-agnostic and only the host owns the request's
|
|
16
|
+
* workspace paths (PHEXEC-34). Exact `playbook.trace` payloads stay out of ordinary
|
|
17
|
+
* diagnostics (DR-010, DR-011). The adapter holds no host specifics beyond the
|
|
18
|
+
* injected transports. See specs/dev/phase-execution.md.
|
|
19
|
+
*/
|
|
20
|
+
import type { AgentClient } from './interpreter.js';
|
|
21
|
+
import type { CompatiblePlaybookPorts } from './playbook-contract.js';
|
|
22
|
+
/** Source-owned ports plus a host-only non-sensitive diagnostic drain. */
|
|
23
|
+
export interface PlaybookPortsAdapter extends CompatiblePlaybookPorts {
|
|
24
|
+
/** Returns collected status/operational telemetry and clears the buffer. */
|
|
25
|
+
drainDiagnostics(): string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The transport(s) backing `callPlayer`: one shared client, or a per-player
|
|
29
|
+
* factory so each player id keeps its own agent session (a Cligent transport is
|
|
30
|
+
* single-flight and resumes its own session across calls).
|
|
31
|
+
*/
|
|
32
|
+
export type PlayerTransport = AgentClient | ((playerId: string) => AgentClient);
|
|
33
|
+
/** Builds a {@link PlaybookPortsAdapter} over coding-agent transports (PHEXEC-25). */
|
|
34
|
+
export declare function createPlaybookPorts(opts: {
|
|
35
|
+
/** Transport backing `callPlayer`; a factory yields one client per player id. */
|
|
36
|
+
player: PlayerTransport;
|
|
37
|
+
/** Shared transport backing `callCaptain` and `callJudge`. */
|
|
38
|
+
judge: AgentClient;
|
|
39
|
+
/** Per-player model binding, applied as configuration (PHEXEC-13). */
|
|
40
|
+
models?: Readonly<Record<string, string>>;
|
|
41
|
+
/** Model for players the `models` binding does not name (PHEXEC-13). */
|
|
42
|
+
defaultModel?: string;
|
|
43
|
+
/** Working directory handed to the transports. */
|
|
44
|
+
cwd?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Host workspace contract appended to transformation-performing direct
|
|
47
|
+
* Captain prompts — those whose source-owned options carry no `allowedTools`
|
|
48
|
+
* restriction (PHEXEC-34). Routing-only Captain and judge calls never
|
|
49
|
+
* carry it.
|
|
50
|
+
*/
|
|
51
|
+
captainWorkspace?: string;
|
|
52
|
+
}): PlaybookPortsAdapter;
|
|
53
|
+
//# sourceMappingURL=playbook-ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-ports.d.ts","sourceRoot":"","sources":["../src/playbook-ports.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAGV,uBAAuB,EAKxB,MAAM,wBAAwB,CAAC;AAEhC,0EAA0E;AAC1E,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACnE,4EAA4E;IAC5E,gBAAgB,IAAI,MAAM,EAAE,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC;AAEhF,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,iFAAiF;IACjF,MAAM,EAAE,eAAe,CAAC;IACxB,8DAA8D;IAC9D,KAAK,EAAE,WAAW,CAAC;IACnB,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,oBAAoB,CAgIvB"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/** Builds a {@link PlaybookPortsAdapter} over coding-agent transports (PHEXEC-25). */
|
|
4
|
+
export function createPlaybookPorts(opts) {
|
|
5
|
+
const diagnostics = [];
|
|
6
|
+
const players = new Map();
|
|
7
|
+
let captainGate = Promise.resolve();
|
|
8
|
+
const playerFor = (playerId) => {
|
|
9
|
+
if (typeof opts.player !== 'function')
|
|
10
|
+
return opts.player;
|
|
11
|
+
let client = players.get(playerId);
|
|
12
|
+
if (client === undefined) {
|
|
13
|
+
client = opts.player(playerId);
|
|
14
|
+
players.set(playerId, client);
|
|
15
|
+
}
|
|
16
|
+
return client;
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
async callPlayer(playerId, prompt, signal, options) {
|
|
20
|
+
const result = await playerFor(playerId).run({
|
|
21
|
+
prompt,
|
|
22
|
+
model: opts.models?.[playerId] ?? opts.defaultModel,
|
|
23
|
+
cwd: opts.cwd,
|
|
24
|
+
...(options !== undefined ? { resume: options.resume } : {}),
|
|
25
|
+
signal,
|
|
26
|
+
});
|
|
27
|
+
return toPlayerResult(result, signal);
|
|
28
|
+
},
|
|
29
|
+
async callCaptain(prompt, signal, options) {
|
|
30
|
+
const isolation = requireCaptainCallOptions(options);
|
|
31
|
+
// A transformation-performing Captain (absent source-owned tool
|
|
32
|
+
// restriction) gets the host workspace contract appended: the artifact
|
|
33
|
+
// composes host-agnostic prompts, and only the host knows the request's
|
|
34
|
+
// absolute source/target paths (PHEXEC-34).
|
|
35
|
+
const transported = isolation.allowedTools === undefined &&
|
|
36
|
+
opts.captainWorkspace !== undefined
|
|
37
|
+
? `${prompt}\n\n${opts.captainWorkspace}`
|
|
38
|
+
: prompt;
|
|
39
|
+
return withSerialCaptain(signal, async () => {
|
|
40
|
+
const result = await opts.judge.run({
|
|
41
|
+
prompt: transported,
|
|
42
|
+
model: opts.defaultModel,
|
|
43
|
+
cwd: opts.cwd,
|
|
44
|
+
resume: isolation.resume,
|
|
45
|
+
allowedTools: isolation.allowedTools,
|
|
46
|
+
signal,
|
|
47
|
+
});
|
|
48
|
+
return toCaptainResult(result, signal);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
async callJudge(prompt, signal) {
|
|
52
|
+
return withSerialCaptain(signal, async () => {
|
|
53
|
+
const result = await opts.judge.run({
|
|
54
|
+
prompt,
|
|
55
|
+
model: opts.defaultModel,
|
|
56
|
+
cwd: opts.cwd,
|
|
57
|
+
resume: false,
|
|
58
|
+
allowedTools: [],
|
|
59
|
+
signal,
|
|
60
|
+
});
|
|
61
|
+
if (result.status !== 'success') {
|
|
62
|
+
throw new Error(`judge did not complete (${result.status})${result.text ? `: ${result.text}` : ''}`);
|
|
63
|
+
}
|
|
64
|
+
return result.text;
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
async callPlaybook(request) {
|
|
68
|
+
return unsupportedNestedCall(request);
|
|
69
|
+
},
|
|
70
|
+
async emitStatus(message, data) {
|
|
71
|
+
diagnostics.push(data === undefined ? message : `${message} ${stringify(data)}`);
|
|
72
|
+
},
|
|
73
|
+
async emitTelemetry(event) {
|
|
74
|
+
if (event.topic === 'playbook.trace')
|
|
75
|
+
return;
|
|
76
|
+
diagnostics.push(`[${event.topic}] ${stringify(event.payload)}`);
|
|
77
|
+
},
|
|
78
|
+
drainDiagnostics() {
|
|
79
|
+
return diagnostics.splice(0);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
async function withSerialCaptain(signal, run) {
|
|
83
|
+
const previous = captainGate;
|
|
84
|
+
let release;
|
|
85
|
+
const gate = new Promise((resolve) => {
|
|
86
|
+
release = resolve;
|
|
87
|
+
});
|
|
88
|
+
captainGate = previous.then(() => gate);
|
|
89
|
+
try {
|
|
90
|
+
await waitForGate(previous, signal);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
void previous.then(release, release);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
if (signal.aborted)
|
|
98
|
+
throw abortReason(signal);
|
|
99
|
+
return await run();
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
release();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Maps a normalized agent outcome onto Playbook's direct-Captain result. */
|
|
107
|
+
function toCaptainResult(result, signal) {
|
|
108
|
+
switch (result.status) {
|
|
109
|
+
case 'success':
|
|
110
|
+
return { status: 'ok', finalText: result.text };
|
|
111
|
+
case 'error':
|
|
112
|
+
return {
|
|
113
|
+
status: 'error',
|
|
114
|
+
error: result.text || 'Captain agent reported an error',
|
|
115
|
+
};
|
|
116
|
+
case 'incomplete':
|
|
117
|
+
return signal.aborted
|
|
118
|
+
? { status: 'aborted' }
|
|
119
|
+
: {
|
|
120
|
+
status: 'error',
|
|
121
|
+
error: result.text || 'Captain agent did not finish',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function requireCaptainCallOptions(options) {
|
|
126
|
+
if (typeof options !== 'object' || options === null) {
|
|
127
|
+
throw new TypeError('callCaptain requires CaptainCallOptions');
|
|
128
|
+
}
|
|
129
|
+
const visibility = Object.getOwnPropertyDescriptor(options, 'visibility');
|
|
130
|
+
if (visibility === undefined ||
|
|
131
|
+
!Object.prototype.hasOwnProperty.call(visibility, 'value') ||
|
|
132
|
+
(visibility.value !== 'visible' && visibility.value !== 'hidden')) {
|
|
133
|
+
throw new TypeError('callCaptain options.visibility must be visible or hidden');
|
|
134
|
+
}
|
|
135
|
+
const resume = Object.getOwnPropertyDescriptor(options, 'resume');
|
|
136
|
+
if (resume === undefined ||
|
|
137
|
+
!Object.prototype.hasOwnProperty.call(resume, 'value') ||
|
|
138
|
+
resume.value !== false) {
|
|
139
|
+
throw new TypeError('callCaptain options.resume must be false');
|
|
140
|
+
}
|
|
141
|
+
// The tool restriction is source-owned (link.md §PlaybookPorts contract):
|
|
142
|
+
// a routing-only Captain passes an explicitly empty allowlist; a
|
|
143
|
+
// transformation-performing Captain omits the property so the host
|
|
144
|
+
// Captain works with its tools.
|
|
145
|
+
const allowedTools = Object.getOwnPropertyDescriptor(options, 'allowedTools');
|
|
146
|
+
if (allowedTools === undefined) {
|
|
147
|
+
return { resume: false };
|
|
148
|
+
}
|
|
149
|
+
if (!Object.prototype.hasOwnProperty.call(allowedTools, 'value') ||
|
|
150
|
+
!Array.isArray(allowedTools.value) ||
|
|
151
|
+
allowedTools.value.length !== 0) {
|
|
152
|
+
throw new TypeError('callCaptain options.allowedTools must be absent or an explicitly empty array');
|
|
153
|
+
}
|
|
154
|
+
return { resume: false, allowedTools: [] };
|
|
155
|
+
}
|
|
156
|
+
/** Maps a normalized agent outcome onto Playbook's {@link PlayerResult} (DR-005). */
|
|
157
|
+
function toPlayerResult(result, signal) {
|
|
158
|
+
const continuation = result.resumeToken === undefined ? {} : { resumeToken: result.resumeToken };
|
|
159
|
+
switch (result.status) {
|
|
160
|
+
case 'success':
|
|
161
|
+
return { status: 'ok', finalText: result.text, ...continuation };
|
|
162
|
+
case 'error':
|
|
163
|
+
return {
|
|
164
|
+
status: 'error',
|
|
165
|
+
error: result.text || 'agent reported an error',
|
|
166
|
+
...continuation,
|
|
167
|
+
};
|
|
168
|
+
case 'incomplete':
|
|
169
|
+
return signal.aborted
|
|
170
|
+
? { status: 'aborted', ...continuation }
|
|
171
|
+
: {
|
|
172
|
+
status: 'error',
|
|
173
|
+
error: result.text || 'agent did not finish',
|
|
174
|
+
...continuation,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function unsupportedNestedCall(request) {
|
|
179
|
+
return {
|
|
180
|
+
state: 'settled',
|
|
181
|
+
result: {
|
|
182
|
+
status: 'error',
|
|
183
|
+
playbookId: request.playbookId,
|
|
184
|
+
error: {
|
|
185
|
+
name: 'UnsupportedOperationError',
|
|
186
|
+
message: 'nested playbook calls are unavailable in SLC compiled phase execution',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function waitForGate(gate, signal) {
|
|
192
|
+
if (signal.aborted)
|
|
193
|
+
return Promise.reject(abortReason(signal));
|
|
194
|
+
return new Promise((resolve, reject) => {
|
|
195
|
+
const onAbort = () => reject(abortReason(signal));
|
|
196
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
197
|
+
void gate.then(() => {
|
|
198
|
+
signal.removeEventListener('abort', onAbort);
|
|
199
|
+
resolve();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function abortReason(signal) {
|
|
204
|
+
return signal.reason ?? new Error('operation aborted');
|
|
205
|
+
}
|
|
206
|
+
function stringify(value) {
|
|
207
|
+
if (typeof value === 'string') {
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
return JSON.stringify(value) ?? String(value);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return String(value);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=playbook-ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-ports.js","sourceRoot":"","sources":["../src/playbook-ports.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AA8C1E,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,IAkBnC;IACC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC/C,IAAI,WAAW,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACnD,MAAM,SAAS,GAAG,CAAC,QAAgB,EA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AC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { PipelineResolver } from './pipeline.js';
|
|
2
|
+
/** The reserved meta-pipeline reference (DR-005, SELFHOST-2). */
|
|
3
|
+
export declare const RESERVED_SLC_PIPELINE = "slc";
|
|
4
|
+
/**
|
|
5
|
+
* The `playbook` domain pipeline, which shares the reserved `slc` pipeline's
|
|
6
|
+
* Playbook-authored definitions (DR-009, SELFHOST-6).
|
|
7
|
+
*/
|
|
8
|
+
export declare const RESERVED_PLAYBOOK_PIPELINE = "playbook";
|
|
9
|
+
/**
|
|
10
|
+
* Whether a reference names a pipeline whose definitions `@sublang/playbook`
|
|
11
|
+
* provides — the reserved `slc` meta-pipeline or the `playbook` domain pipeline,
|
|
12
|
+
* which share one definition set and differ only by name (DR-009). Such a link
|
|
13
|
+
* phase consumes Playbook's target-less `link.md` (PIPE-11).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isReservedPipeline(reference: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Computes the ordered pipeline search roots from a pipeline-path value (CLI-6):
|
|
18
|
+
* either the `SLC_PIPELINE_PATH` OS path-list string or the config file's
|
|
19
|
+
* `pipelinePath` sequence (DR-006). Entries are resolved to absolute, normalized
|
|
20
|
+
* roots against `cwd`, defaulting to `[cwd]` when the value is unset, empty, or
|
|
21
|
+
* all blank. Normalization (via `resolve`) strips trailing slashes and redundant
|
|
22
|
+
* segments so duplicate roots collapse while order is preserved.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pipelineSearchRoots(pipelinePath: string | string[] | undefined, cwd: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Builds a {@link PipelineResolver} over the given search roots (CLI-6).
|
|
27
|
+
*
|
|
28
|
+
* A `<reference>` matches `join(root, reference)` only when that path exists, is
|
|
29
|
+
* a directory, and sits directly under the root — so nested paths and `..`
|
|
30
|
+
* traversal yield no match. Matches are returned in root order, deduplicated.
|
|
31
|
+
*
|
|
32
|
+
* Roots are canonicalized once at construction (trailing slashes and redundant
|
|
33
|
+
* segments dropped) so the direct-child check holds even when a caller supplies
|
|
34
|
+
* a root like `/pipes/`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPipelineResolver(searchRoots: readonly string[]): PipelineResolver;
|
|
37
|
+
/**
|
|
38
|
+
* Locates the meta-pipeline definitions that `@sublang/playbook` ships under
|
|
39
|
+
* `slc/` (its `text2gears`, `gears2fsm`, and `link` phases), which back both the
|
|
40
|
+
* reserved `slc` meta-pipeline and the `playbook` domain pipeline, so `slc`
|
|
41
|
+
* self-hosts on Playbook's canonical source rather than a duplicate (DR-005,
|
|
42
|
+
* DR-009, SELFHOST-2).
|
|
43
|
+
*
|
|
44
|
+
* @throws when `@sublang/playbook` does not provide the `slc/` definitions.
|
|
45
|
+
*/
|
|
46
|
+
export declare function reservedSlcPipelineDir(): string;
|
|
47
|
+
/**
|
|
48
|
+
* The default link target for the `playbook` pipeline (DR-014, SELFHOST-13):
|
|
49
|
+
* the installed `@sublang/playbook` runtime contract module's TypeScript
|
|
50
|
+
* source, the same file the pin generator records as the link target.
|
|
51
|
+
*
|
|
52
|
+
* @throws when `@sublang/playbook` is not installed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function defaultPlaybookLinkTarget(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Wraps a resolver so a Playbook-owned reference — the reserved `slc`
|
|
57
|
+
* meta-pipeline or the `playbook` domain pipeline — resolves to the shared
|
|
58
|
+
* definition set, leaving every other reference to `inner`. Both names share one
|
|
59
|
+
* definition set and differ only by name, hence by their DR-001 artifact
|
|
60
|
+
* directory (DR-009, SELFHOST-2, SELFHOST-6).
|
|
61
|
+
*
|
|
62
|
+
* The shared set is the first search-root directory named `playbook` when one
|
|
63
|
+
* exists — a committed vendor of Playbook's definitions, whose `slc.pins.json`
|
|
64
|
+
* can pin both pipelines to compiled artifacts — otherwise the definitions the
|
|
65
|
+
* installed `@sublang/playbook` provides (SELFHOST-9).
|
|
66
|
+
*/
|
|
67
|
+
export declare function withReservedPipelines(inner: PipelineResolver): PipelineResolver;
|
|
68
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,iEAAiE;AACjE,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,0BAA0B,aAAa,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAK7D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAC3C,GAAG,EAAE,MAAM,GACV,MAAM,EAAE,CAUV;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,gBAAgB,CAalB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAOlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,CAMlB"}
|
package/dist/resolver.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/**
|
|
4
|
+
* Concrete pipeline-reference resolver for the `slc` bin (CLI-6, DR-001).
|
|
5
|
+
*
|
|
6
|
+
* DR-001 leaves pipeline-to-directory resolution to the consumer; this is the
|
|
7
|
+
* bin's host policy: a `<reference>` resolves to the directories named
|
|
8
|
+
* `<reference>` directly under each search root from `SLC_PIPELINE_PATH` (an OS
|
|
9
|
+
* path-list), defaulting to the working directory when unset. The resolver
|
|
10
|
+
* returns every existing match so `runSlc`'s exactly-one rule (PIPE-16) refuses
|
|
11
|
+
* zero or many; it does not check that a match is a well-formed pipeline, which
|
|
12
|
+
* `loadPipeline` does. See specs/dev/cli.md.
|
|
13
|
+
*/
|
|
14
|
+
import { stat } from 'node:fs/promises';
|
|
15
|
+
import { createRequire } from 'node:module';
|
|
16
|
+
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
17
|
+
const requireFrom = createRequire(import.meta.url);
|
|
18
|
+
/** The reserved meta-pipeline reference (DR-005, SELFHOST-2). */
|
|
19
|
+
export const RESERVED_SLC_PIPELINE = 'slc';
|
|
20
|
+
/**
|
|
21
|
+
* The `playbook` domain pipeline, which shares the reserved `slc` pipeline's
|
|
22
|
+
* Playbook-authored definitions (DR-009, SELFHOST-6).
|
|
23
|
+
*/
|
|
24
|
+
export const RESERVED_PLAYBOOK_PIPELINE = 'playbook';
|
|
25
|
+
/**
|
|
26
|
+
* Whether a reference names a pipeline whose definitions `@sublang/playbook`
|
|
27
|
+
* provides — the reserved `slc` meta-pipeline or the `playbook` domain pipeline,
|
|
28
|
+
* which share one definition set and differ only by name (DR-009). Such a link
|
|
29
|
+
* phase consumes Playbook's target-less `link.md` (PIPE-11).
|
|
30
|
+
*/
|
|
31
|
+
export function isReservedPipeline(reference) {
|
|
32
|
+
return (reference === RESERVED_SLC_PIPELINE ||
|
|
33
|
+
reference === RESERVED_PLAYBOOK_PIPELINE);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Computes the ordered pipeline search roots from a pipeline-path value (CLI-6):
|
|
37
|
+
* either the `SLC_PIPELINE_PATH` OS path-list string or the config file's
|
|
38
|
+
* `pipelinePath` sequence (DR-006). Entries are resolved to absolute, normalized
|
|
39
|
+
* roots against `cwd`, defaulting to `[cwd]` when the value is unset, empty, or
|
|
40
|
+
* all blank. Normalization (via `resolve`) strips trailing slashes and redundant
|
|
41
|
+
* segments so duplicate roots collapse while order is preserved.
|
|
42
|
+
*/
|
|
43
|
+
export function pipelineSearchRoots(pipelinePath, cwd) {
|
|
44
|
+
const rawEntries = Array.isArray(pipelinePath)
|
|
45
|
+
? pipelinePath
|
|
46
|
+
: (pipelinePath ?? '').split(delimiter);
|
|
47
|
+
const entries = rawEntries
|
|
48
|
+
.map((entry) => entry.trim())
|
|
49
|
+
.filter((entry) => entry.length > 0);
|
|
50
|
+
const roots = entries.length > 0 ? entries : [cwd];
|
|
51
|
+
const normalized = roots.map((root) => resolve(cwd, root));
|
|
52
|
+
return [...new Set(normalized)];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Builds a {@link PipelineResolver} over the given search roots (CLI-6).
|
|
56
|
+
*
|
|
57
|
+
* A `<reference>` matches `join(root, reference)` only when that path exists, is
|
|
58
|
+
* a directory, and sits directly under the root — so nested paths and `..`
|
|
59
|
+
* traversal yield no match. Matches are returned in root order, deduplicated.
|
|
60
|
+
*
|
|
61
|
+
* Roots are canonicalized once at construction (trailing slashes and redundant
|
|
62
|
+
* segments dropped) so the direct-child check holds even when a caller supplies
|
|
63
|
+
* a root like `/pipes/`.
|
|
64
|
+
*/
|
|
65
|
+
export function createPipelineResolver(searchRoots) {
|
|
66
|
+
// `join(root, '.')` drops a trailing slash and redundant segments without
|
|
67
|
+
// forcing the root absolute, matching the form `dirname(join(root, ref))` yields.
|
|
68
|
+
const roots = searchRoots.map((root) => join(root, '.'));
|
|
69
|
+
return async (reference) => {
|
|
70
|
+
const matches = [];
|
|
71
|
+
for (const root of roots) {
|
|
72
|
+
const candidate = join(root, reference);
|
|
73
|
+
if (dirname(candidate) !== root)
|
|
74
|
+
continue;
|
|
75
|
+
if (await isDirectory(candidate))
|
|
76
|
+
matches.push(candidate);
|
|
77
|
+
}
|
|
78
|
+
return [...new Set(matches)];
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Locates the meta-pipeline definitions that `@sublang/playbook` ships under
|
|
83
|
+
* `slc/` (its `text2gears`, `gears2fsm`, and `link` phases), which back both the
|
|
84
|
+
* reserved `slc` meta-pipeline and the `playbook` domain pipeline, so `slc`
|
|
85
|
+
* self-hosts on Playbook's canonical source rather than a duplicate (DR-005,
|
|
86
|
+
* DR-009, SELFHOST-2).
|
|
87
|
+
*
|
|
88
|
+
* @throws when `@sublang/playbook` does not provide the `slc/` definitions.
|
|
89
|
+
*/
|
|
90
|
+
export function reservedSlcPipelineDir() {
|
|
91
|
+
return dirname(requireFrom.resolve('@sublang/playbook/slc/link.md'));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The default link target for the `playbook` pipeline (DR-014, SELFHOST-13):
|
|
95
|
+
* the installed `@sublang/playbook` runtime contract module's TypeScript
|
|
96
|
+
* source, the same file the pin generator records as the link target.
|
|
97
|
+
*
|
|
98
|
+
* @throws when `@sublang/playbook` is not installed.
|
|
99
|
+
*/
|
|
100
|
+
export function defaultPlaybookLinkTarget() {
|
|
101
|
+
// `./runtime` resolves to `src/runtime.js`; the convention (and the pinned
|
|
102
|
+
// identity) targets its TypeScript sibling in the same directory.
|
|
103
|
+
return join(dirname(requireFrom.resolve('@sublang/playbook/runtime')), 'runtime.ts');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Wraps a resolver so a Playbook-owned reference — the reserved `slc`
|
|
107
|
+
* meta-pipeline or the `playbook` domain pipeline — resolves to the shared
|
|
108
|
+
* definition set, leaving every other reference to `inner`. Both names share one
|
|
109
|
+
* definition set and differ only by name, hence by their DR-001 artifact
|
|
110
|
+
* directory (DR-009, SELFHOST-2, SELFHOST-6).
|
|
111
|
+
*
|
|
112
|
+
* The shared set is the first search-root directory named `playbook` when one
|
|
113
|
+
* exists — a committed vendor of Playbook's definitions, whose `slc.pins.json`
|
|
114
|
+
* can pin both pipelines to compiled artifacts — otherwise the definitions the
|
|
115
|
+
* installed `@sublang/playbook` provides (SELFHOST-9).
|
|
116
|
+
*/
|
|
117
|
+
export function withReservedPipelines(inner) {
|
|
118
|
+
return async (reference) => {
|
|
119
|
+
if (!isReservedPipeline(reference))
|
|
120
|
+
return inner(reference);
|
|
121
|
+
const vendored = await inner(RESERVED_PLAYBOOK_PIPELINE);
|
|
122
|
+
return vendored.length > 0 ? vendored : [reservedSlcPipelineDir()];
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function isDirectory(path) {
|
|
126
|
+
try {
|
|
127
|
+
return (await stat(path)).isDirectory();
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI9D,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEnD,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AA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AAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type PhaseExecutor } from './execution.js';
|
|
2
|
+
import { type PinRecord } from './pins.js';
|
|
3
|
+
import { type PipelineResolver } from './pipeline.js';
|
|
4
|
+
/** A current pinned phase and the record that selected its compiled artifact. */
|
|
5
|
+
export interface CompiledSelection {
|
|
6
|
+
/** Pin key: the phase name, or `link` for the reserved link phase. */
|
|
7
|
+
phase: string;
|
|
8
|
+
/** The pipeline directory holding `slc.pins.json`. */
|
|
9
|
+
pipelineDir: string;
|
|
10
|
+
/** The current pin record naming the compiled artifact and its inputs. */
|
|
11
|
+
record: PinRecord;
|
|
12
|
+
}
|
|
13
|
+
/** Host-supplied capabilities for a run. */
|
|
14
|
+
export interface SlcDeps {
|
|
15
|
+
/** Resolves a pipeline reference to candidate directories (DR-001). */
|
|
16
|
+
resolver: PipelineResolver;
|
|
17
|
+
/** Executes a phase by interpretation; the fallback for an unpinned phase (DR-004). */
|
|
18
|
+
executor: PhaseExecutor;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the executor for a current pinned phase (DR-005, DR-007). When absent,
|
|
21
|
+
* a host runs interpreted only, so a current pin fails closed rather than
|
|
22
|
+
* silently interpreting a phase the pipeline pinned to a compiled artifact.
|
|
23
|
+
*/
|
|
24
|
+
compiled?: (selection: CompiledSelection) => PhaseExecutor;
|
|
25
|
+
/** Invocation working directory anchoring artifact placement (DR-014); defaults to the process cwd. */
|
|
26
|
+
cwd?: string;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
/** The outcome of an `slc` run. */
|
|
30
|
+
export interface SlcResult {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
/** Artifact paths written, in order. */
|
|
33
|
+
outputs: string[];
|
|
34
|
+
/** Diagnostics: agent summaries on success, or the failure report. */
|
|
35
|
+
diagnostics: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parses argv and runs the requested pipeline, phase, or link end-to-end.
|
|
39
|
+
* Never rejects: malformed invocations, refusals, and phase failures all return
|
|
40
|
+
* `{ ok: false }` with diagnostics.
|
|
41
|
+
*/
|
|
42
|
+
export declare function runSlc(argv: readonly string[], deps: SlcDeps): Promise<SlcResult>;
|
|
43
|
+
/** Resolves the built-in pipeline-agnostic normalize definition (DR-013). */
|
|
44
|
+
export declare function normalizeDefinitionPath(): string;
|
|
45
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EAEL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAavB,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,4CAA4C;AAC5C,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,uFAAuF;IACvF,QAAQ,EAAE,aAAa,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,aAAa,CAAC;IAC3D,uGAAuG;IACvG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,OAAO,CAAC;IACZ,wCAAwC;IACxC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,SAAS,CAAC,CAoCpB;AAgVD,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
|