@ordewell/core 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +41 -13
- package/dist/index.d.ts +41 -13
- package/dist/index.js +51 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4184,6 +4184,14 @@ ${tail}`;
|
|
|
4184
4184
|
|
|
4185
4185
|
${blocks.join("\n\n")}`;
|
|
4186
4186
|
}
|
|
4187
|
+
function augmentPromptWithPriorOutputs(task, allTasks) {
|
|
4188
|
+
const basePrompt = task.prompt ?? "";
|
|
4189
|
+
const outputs = collectDirectDependencyOutputs(task, allTasks);
|
|
4190
|
+
if (outputs.length === 0) return basePrompt;
|
|
4191
|
+
return `${renderPriorOutputs(outputs)}
|
|
4192
|
+
|
|
4193
|
+
${basePrompt}`;
|
|
4194
|
+
}
|
|
4187
4195
|
function planMapStatus(task, isCurrent) {
|
|
4188
4196
|
if (isCurrent) return "NOW";
|
|
4189
4197
|
if (task.status === "completed") return "done";
|
|
@@ -10164,7 +10172,11 @@ var HeadlessSession = class extends AbstractTerminalSession {
|
|
|
10164
10172
|
spawnImpl;
|
|
10165
10173
|
process = null;
|
|
10166
10174
|
outputBuffer = "";
|
|
10175
|
+
get isStarted() {
|
|
10176
|
+
return this.process !== null;
|
|
10177
|
+
}
|
|
10167
10178
|
start(launch, cwd, resolvedPath, env) {
|
|
10179
|
+
if (this.exited || this.process) return;
|
|
10168
10180
|
this.process = this.spawnImpl(launch.file, launch.args, {
|
|
10169
10181
|
env: withPath(process.env, resolvedPath, env),
|
|
10170
10182
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -10193,6 +10205,7 @@ Process error: ${err.message}
|
|
|
10193
10205
|
}
|
|
10194
10206
|
kill() {
|
|
10195
10207
|
killTree(this.process);
|
|
10208
|
+
if (!this.process) this.baseHandleExit(-1);
|
|
10196
10209
|
}
|
|
10197
10210
|
getOutput() {
|
|
10198
10211
|
return this.outputBuffer;
|
|
@@ -10208,6 +10221,8 @@ var HeadlessRunner = class extends AbstractRunner {
|
|
|
10208
10221
|
hasScriptCmd;
|
|
10209
10222
|
resolvePath;
|
|
10210
10223
|
launchDeps;
|
|
10224
|
+
/** Session shape when the caller names none; the VS Code runner overrides it to interactive. */
|
|
10225
|
+
defaultHeadless = true;
|
|
10211
10226
|
constructor(deps = {}) {
|
|
10212
10227
|
super();
|
|
10213
10228
|
this.spawnImpl = deps.spawnImpl ?? nodeSpawn2;
|
|
@@ -10215,9 +10230,12 @@ var HeadlessRunner = class extends AbstractRunner {
|
|
|
10215
10230
|
this.resolvePath = deps.resolvePath ?? augmentedPath;
|
|
10216
10231
|
this.launchDeps = { resolvePath: this.resolvePath, ...deps.launchDeps };
|
|
10217
10232
|
}
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10233
|
+
createSession(id, taskId) {
|
|
10234
|
+
return new HeadlessSession(id, taskId, this.spawnImpl);
|
|
10235
|
+
}
|
|
10236
|
+
/** Everything up to, but not including, spawning — so a surface that owns its own child reaches the same decisions. */
|
|
10237
|
+
async prepareLaunch(opts) {
|
|
10238
|
+
const headless = opts.headless ?? this.defaultHeadless;
|
|
10221
10239
|
const invocation = buildRunnerInvocation({
|
|
10222
10240
|
runner: opts.runner,
|
|
10223
10241
|
prompt: opts.prompt,
|
|
@@ -10225,21 +10243,27 @@ var HeadlessRunner = class extends AbstractRunner {
|
|
|
10225
10243
|
thinkingEffort: opts.thinkingEffort,
|
|
10226
10244
|
modelVariants: opts.modelVariants,
|
|
10227
10245
|
mode: opts.mode,
|
|
10228
|
-
headless
|
|
10246
|
+
headless,
|
|
10229
10247
|
registry: opts.registry
|
|
10230
10248
|
});
|
|
10231
10249
|
const manifest = opts.registry?.get(opts.runner)?.manifest;
|
|
10232
|
-
const
|
|
10233
|
-
const modeStr = opts.mode === "plan" ? "plan" : "build";
|
|
10234
|
-
console.error(`[headless] Starting ${opts.runner} [${modeStr}] (${opts.modelId || "default"}) for task ${opts.taskId.slice(0, 8)}${requiresTty ? " (PTY)" : ""}`);
|
|
10250
|
+
const pty = (manifest?.runner.requiresTty === true || !headless) && this.hasScriptCmd();
|
|
10235
10251
|
const resolvedPath = await this.resolvePath();
|
|
10236
|
-
const { command, args } =
|
|
10237
|
-
|
|
10238
|
-
await planDirectLaunch(command, args, this.launchDeps),
|
|
10239
|
-
opts.cwd,
|
|
10252
|
+
const { command, args } = pty ? wrapWithPty(invocation.command, invocation.args) : { command: invocation.command, args: invocation.args };
|
|
10253
|
+
return {
|
|
10254
|
+
launch: await planDirectLaunch(command, args, this.launchDeps),
|
|
10240
10255
|
resolvedPath,
|
|
10241
|
-
invocation.env
|
|
10242
|
-
|
|
10256
|
+
env: invocation.env,
|
|
10257
|
+
pty
|
|
10258
|
+
};
|
|
10259
|
+
}
|
|
10260
|
+
async spawn(opts) {
|
|
10261
|
+
const id = `ordewell-${opts.taskId.slice(0, 8)}`;
|
|
10262
|
+
const session = this.createSession(id, opts.taskId);
|
|
10263
|
+
const prepared = await this.prepareLaunch(opts);
|
|
10264
|
+
const modeStr = opts.mode === "plan" ? "plan" : "build";
|
|
10265
|
+
console.error(`[headless] Starting ${opts.runner} [${modeStr}] (${opts.modelId || "default"}) for task ${opts.taskId.slice(0, 8)}${prepared.pty ? " (PTY)" : ""}`);
|
|
10266
|
+
session.start(prepared.launch, opts.cwd, prepared.resolvedPath, prepared.env);
|
|
10243
10267
|
this.registerSession(id, session);
|
|
10244
10268
|
return session;
|
|
10245
10269
|
}
|
|
@@ -11266,6 +11290,7 @@ export {
|
|
|
11266
11290
|
GREP_DEFAULT_HEAD_LIMIT,
|
|
11267
11291
|
GeminiService,
|
|
11268
11292
|
HeadlessRunner,
|
|
11293
|
+
HeadlessSession,
|
|
11269
11294
|
JSON_REPAIR_INSTRUCTION,
|
|
11270
11295
|
LineBuffer,
|
|
11271
11296
|
ModelCatalog,
|
|
@@ -11301,6 +11326,7 @@ export {
|
|
|
11301
11326
|
addTaskToPlan,
|
|
11302
11327
|
applyHeadLimit,
|
|
11303
11328
|
applyTaskOps,
|
|
11329
|
+
augmentPromptWithPriorOutputs,
|
|
11304
11330
|
augmentedPath,
|
|
11305
11331
|
buildConversationSystemPrompt,
|
|
11306
11332
|
buildFallbackGrepArgs,
|
|
@@ -11333,7 +11359,9 @@ export {
|
|
|
11333
11359
|
clearResearchShellCache,
|
|
11334
11360
|
clearState,
|
|
11335
11361
|
coerceAssignments,
|
|
11362
|
+
collectDirectDependencyOutputs,
|
|
11336
11363
|
collectProviderCredentials,
|
|
11364
|
+
composeAugmentedPrompt,
|
|
11337
11365
|
configuredProviders,
|
|
11338
11366
|
createAiService,
|
|
11339
11367
|
createEmptyPlan,
|
|
@@ -11400,6 +11428,8 @@ export {
|
|
|
11400
11428
|
reEmitTaskOpsPrompt,
|
|
11401
11429
|
referencePattern,
|
|
11402
11430
|
removeTaskFromPlan,
|
|
11431
|
+
renderPlanMap,
|
|
11432
|
+
renderPriorOutputs,
|
|
11403
11433
|
renumberTasks,
|
|
11404
11434
|
repairLoop,
|
|
11405
11435
|
researchShellWarning,
|
|
@@ -11429,6 +11459,7 @@ export {
|
|
|
11429
11459
|
stripModelNoise,
|
|
11430
11460
|
stripModelPrefix,
|
|
11431
11461
|
stripTrailingCommas,
|
|
11462
|
+
summarizeOutput,
|
|
11432
11463
|
summarizeToolCall,
|
|
11433
11464
|
taskOpsRejectedPrompt,
|
|
11434
11465
|
textHasTaskOps,
|