@oyasmi/pipiclaw 0.9.1 → 0.9.2-beta.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/agent/channel-runner.d.ts +2 -1
- package/dist/agent/channel-runner.js +9 -5
- package/dist/agent/effect-ledger.js +9 -2
- package/dist/agent/job-manager.d.ts +4 -0
- package/dist/agent/job-manager.js +17 -2
- package/dist/agent/prompt/manifest.d.ts +1 -1
- package/dist/agent/prompt/manifest.js +1 -1
- package/dist/agent/prompt/sections.js +8 -5
- package/dist/agent/session-events.d.ts +2 -0
- package/dist/agent/session-events.js +29 -14
- package/dist/agent/turn-recovery.js +2 -2
- package/dist/agent/type-guards.js +5 -1
- package/dist/agent/workspace-resources.d.ts +2 -2
- package/dist/agent/workspace-resources.js +41 -3
- package/dist/executor.d.ts +14 -0
- package/dist/executor.js +96 -24
- package/dist/file-store.d.ts +96 -0
- package/dist/file-store.js +189 -0
- package/dist/memory/consolidation.js +2 -26
- package/dist/memory/files.js +7 -7
- package/dist/memory/maintenance-jobs.js +2 -34
- package/dist/memory/maintenance-state.js +2 -1
- package/dist/memory/recall.d.ts +10 -0
- package/dist/memory/recall.js +15 -7
- package/dist/memory/session-search.js +6 -22
- package/dist/memory/transcript.d.ts +10 -0
- package/dist/memory/transcript.js +39 -0
- package/dist/playbooks/agent-delegation.md +6 -4
- package/dist/playbooks/background-jobs.md +1 -1
- package/dist/playbooks/catalog.d.ts +1 -1
- package/dist/playbooks/catalog.js +1 -1
- package/dist/playbooks/event-scheduling.md +2 -0
- package/dist/playbooks/memory-and-learning.md +11 -11
- package/dist/playbooks/runtime-orientation.md +3 -3
- package/dist/playbooks/task-driving.md +5 -5
- package/dist/playbooks/task-planning.md +5 -5
- package/dist/runtime/app-home.js +1 -1
- package/dist/runtime/bootstrap.js +10 -0
- package/dist/runtime/dingtalk.js +3 -2
- package/dist/runtime/durable-dispatch.d.ts +26 -1
- package/dist/runtime/durable-dispatch.js +51 -5
- package/dist/runtime/event-commands.js +7 -16
- package/dist/runtime/events.d.ts +4 -2
- package/dist/runtime/events.js +15 -20
- package/dist/runtime/subagent-commands.js +1 -1
- package/dist/runtime/task-commands.d.ts +1 -1
- package/dist/runtime/task-commands.js +10 -10
- package/dist/runtime/task-driver.js +2 -2
- package/dist/security/block-message.d.ts +11 -0
- package/dist/security/block-message.js +12 -0
- package/dist/security/path-guard-check.d.ts +13 -0
- package/dist/security/path-guard-check.js +39 -0
- package/dist/security/path-guard.js +32 -14
- package/dist/settings.js +3 -2
- package/dist/shared/atomic-file.d.ts +17 -1
- package/dist/shared/atomic-file.js +50 -3
- package/dist/shared/duration.d.ts +2 -0
- package/dist/shared/duration.js +7 -0
- package/dist/shared/safe-id.d.ts +19 -0
- package/dist/shared/safe-id.js +24 -0
- package/dist/shared/text-utils.d.ts +1 -1
- package/dist/shared/text-utils.js +3 -8
- package/dist/shared/type-guards.d.ts +2 -0
- package/dist/shared/type-guards.js +4 -0
- package/dist/subagents/discovery.d.ts +44 -17
- package/dist/subagents/discovery.js +82 -111
- package/dist/subagents/external/claude-code.js +1 -3
- package/dist/subagents/external/harness.d.ts +1 -1
- package/dist/subagents/format.d.ts +3 -2
- package/dist/subagents/format.js +3 -7
- package/dist/subagents/runs.d.ts +1 -1
- package/dist/subagents/runs.js +4 -9
- package/dist/subagents/tool.d.ts +31 -19
- package/dist/subagents/tool.js +582 -561
- package/dist/subagents/workspace-lease.js +1 -1
- package/dist/tasks/control.js +7 -9
- package/dist/tasks/ledger.d.ts +2 -2
- package/dist/tasks/ledger.js +3 -7
- package/dist/tasks/transitions.d.ts +5 -1
- package/dist/tasks/transitions.js +2 -2
- package/dist/tools/bash.d.ts +0 -1
- package/dist/tools/bash.js +45 -40
- package/dist/tools/config.d.ts +6 -1
- package/dist/tools/config.js +9 -0
- package/dist/tools/edit.d.ts +2 -3
- package/dist/tools/edit.js +274 -86
- package/dist/tools/event-manage.d.ts +13 -7
- package/dist/tools/event-manage.js +52 -14
- package/dist/tools/glob-match.d.ts +11 -0
- package/dist/tools/glob-match.js +75 -0
- package/dist/tools/glob.d.ts +15 -0
- package/dist/tools/glob.js +113 -0
- package/dist/tools/grep.d.ts +0 -1
- package/dist/tools/grep.js +57 -42
- package/dist/tools/ignore-dirs.d.ts +6 -0
- package/dist/tools/ignore-dirs.js +15 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +50 -40
- package/dist/tools/job.d.ts +0 -1
- package/dist/tools/job.js +1 -8
- package/dist/tools/line-index.d.ts +16 -0
- package/dist/tools/line-index.js +76 -0
- package/dist/tools/memory-manage.d.ts +20 -8
- package/dist/tools/memory-manage.js +65 -92
- package/dist/tools/presentation.d.ts +2 -0
- package/dist/tools/presentation.js +109 -0
- package/dist/tools/read.d.ts +2 -2
- package/dist/tools/read.js +97 -133
- package/dist/tools/registry.d.ts +4 -1
- package/dist/tools/registry.js +89 -22
- package/dist/tools/send-media.d.ts +6 -6
- package/dist/tools/send-media.js +16 -49
- package/dist/tools/session-search.d.ts +0 -1
- package/dist/tools/session-search.js +0 -1
- package/dist/tools/skill-security.d.ts +0 -2
- package/dist/tools/skill-security.js +0 -24
- package/dist/tools/skill.d.ts +31 -0
- package/dist/tools/skill.js +153 -0
- package/dist/tools/subagent-manage.d.ts +6 -5
- package/dist/tools/subagent-manage.js +47 -47
- package/dist/tools/task-manage/create.d.ts +2 -2
- package/dist/tools/task-manage/create.js +1 -3
- package/dist/tools/task-manage/lifecycle.d.ts +9 -6
- package/dist/tools/task-manage/lifecycle.js +49 -56
- package/dist/tools/task-manage/schema.d.ts +27 -15
- package/dist/tools/task-manage/schema.js +58 -74
- package/dist/tools/task-manage/shared.d.ts +11 -6
- package/dist/tools/task-manage/shared.js +30 -21
- package/dist/tools/task-manage/types.d.ts +14 -15
- package/dist/tools/task-manage/verification.d.ts +4 -4
- package/dist/tools/task-manage/verification.js +6 -8
- package/dist/tools/task-manage.d.ts +8 -11
- package/dist/tools/task-manage.js +63 -50
- package/dist/tools/tool-details.d.ts +17 -1
- package/dist/tools/tool-details.js +24 -0
- package/dist/tools/truncate.d.ts +5 -5
- package/dist/tools/truncate.js +5 -5
- package/dist/tools/web-fetch.d.ts +0 -1
- package/dist/tools/web-fetch.js +0 -1
- package/dist/tools/web-search.d.ts +0 -1
- package/dist/tools/web-search.js +0 -1
- package/dist/tools/write-content.d.ts +3 -3
- package/dist/tools/write-content.js +12 -51
- package/dist/tools/write.d.ts +2 -3
- package/dist/tools/write.js +3 -4
- package/dist/usage/ledger.js +7 -4
- package/package.json +1 -1
- package/dist/tools/skill-manage.d.ts +0 -41
- package/dist/tools/skill-manage.js +0 -232
|
@@ -8,6 +8,7 @@ import type { RunnerFactoryPaths } from "./runner-factory.js";
|
|
|
8
8
|
import { type AgentRunner, type RunnerStatusSnapshot, type TurnStatus } from "./types.js";
|
|
9
9
|
export declare class ChannelRunner implements AgentRunner {
|
|
10
10
|
private readonly executor;
|
|
11
|
+
private readonly fileStore;
|
|
11
12
|
private readonly channelId;
|
|
12
13
|
private readonly channelDir;
|
|
13
14
|
private readonly appHomeDir;
|
|
@@ -213,7 +214,7 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
213
214
|
*/
|
|
214
215
|
private setSessionBaseToolsOverride;
|
|
215
216
|
private subscribeToSessionEvents;
|
|
216
|
-
/** Gated by the same master autonomy switch as
|
|
217
|
+
/** Gated by the same master autonomy switch as the task_* tools and the TaskDriver. */
|
|
217
218
|
private buildTaskDigestForTurn;
|
|
218
219
|
private buildFirstTurnMemoryBootstrap;
|
|
219
220
|
}
|
|
@@ -4,6 +4,7 @@ import { AgentSession, AgentSessionRuntime, convertToLlm, createExtensionRuntime
|
|
|
4
4
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
5
5
|
import { dirname, join, resolve } from "path";
|
|
6
6
|
import { createExecutor } from "../executor.js";
|
|
7
|
+
import { createFileStore } from "../file-store.js";
|
|
7
8
|
import * as log from "../log.js";
|
|
8
9
|
import { buildFirstTurnMemoryBootstrapResult, FIRST_TURN_BOOTSTRAP_MAX_UNITS, } from "../memory/bootstrap.js";
|
|
9
10
|
import { createMemoryCandidateStore } from "../memory/candidates.js";
|
|
@@ -21,7 +22,7 @@ import { resolveProjectScope } from "../runtime/project-scope-store.js";
|
|
|
21
22
|
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
22
23
|
import { resolveProjectAccessPolicy } from "../security/project-scope.js";
|
|
23
24
|
import { formatConfigDiagnostic } from "../shared/config-diagnostic.js";
|
|
24
|
-
import { formatLocalTime, localStampForFilename } from "../shared/local-time.js";
|
|
25
|
+
import { formatLocalTime, localStampForFilename, parseLocalTime } from "../shared/local-time.js";
|
|
25
26
|
import { countPromptUnits } from "../shared/prompt-units.js";
|
|
26
27
|
import { errorMessage } from "../shared/text-utils.js";
|
|
27
28
|
import { isRecord } from "../shared/type-guards.js";
|
|
@@ -111,6 +112,7 @@ export class ChannelRunner {
|
|
|
111
112
|
this.mediaSender = paths.mediaSender;
|
|
112
113
|
const executor = createExecutor();
|
|
113
114
|
this.executor = executor;
|
|
115
|
+
this.fileStore = createFileStore();
|
|
114
116
|
this.workspaceDir = resolve(dirname(channelDir));
|
|
115
117
|
// Resolve and freeze this generation's ProjectScope (spec 043, D2/D3/D4.2). A channel with
|
|
116
118
|
// no persisted selection gets the app default, materialized as its first selection right
|
|
@@ -815,9 +817,9 @@ export class ChannelRunner {
|
|
|
815
817
|
*/
|
|
816
818
|
recordMemoryActivity(event) {
|
|
817
819
|
const maintenanceSettings = this.settingsManager.getMemoryMaintenanceSettings();
|
|
818
|
-
const eventTime =
|
|
819
|
-
const eligibleAfter =
|
|
820
|
-
? new Date(eventTime + Math.max(0, maintenanceSettings.minIdleMinutesBeforeLlmWork) * 60_000)
|
|
820
|
+
const eventTime = parseLocalTime(event.timestamp);
|
|
821
|
+
const eligibleAfter = eventTime !== undefined
|
|
822
|
+
? formatLocalTime(new Date(eventTime + Math.max(0, maintenanceSettings.minIdleMinutesBeforeLlmWork) * 60_000))
|
|
821
823
|
: undefined;
|
|
822
824
|
this.memoryActivityRecorder.record({ ...event, eligibleAfter });
|
|
823
825
|
}
|
|
@@ -1274,6 +1276,7 @@ export class ChannelRunner {
|
|
|
1274
1276
|
this.tasksEnabled = toolsLoad.config.tools.tasks.enabled;
|
|
1275
1277
|
const tools = createPipiclawTools({
|
|
1276
1278
|
executor: this.executor,
|
|
1279
|
+
fileStore: this.fileStore,
|
|
1277
1280
|
getCurrentModel: () => this.activeModel,
|
|
1278
1281
|
getAvailableModels: () => this.modelRegistry.getAvailable(),
|
|
1279
1282
|
resolveApiKey: async (model) => getApiKeyForModel(this.modelRegistry, model),
|
|
@@ -1357,12 +1360,13 @@ export class ChannelRunner {
|
|
|
1357
1360
|
refreshSessionResources: async () => {
|
|
1358
1361
|
await this.refreshSessionResources();
|
|
1359
1362
|
},
|
|
1363
|
+
skillsDir: join(this.workspaceDir, "skills"),
|
|
1360
1364
|
}).catch((err) => {
|
|
1361
1365
|
log.logWarning(`[${this.channelId}] session event handler failed`, errorMessage(err));
|
|
1362
1366
|
});
|
|
1363
1367
|
});
|
|
1364
1368
|
}
|
|
1365
|
-
/** Gated by the same master autonomy switch as
|
|
1369
|
+
/** Gated by the same master autonomy switch as the task_* tools and the TaskDriver. */
|
|
1366
1370
|
buildTaskDigestForTurn() {
|
|
1367
1371
|
const taskDigestSettings = this.settingsManager.getTaskDigestSettings();
|
|
1368
1372
|
return buildTaskDigest({
|
|
@@ -9,7 +9,7 @@ import { isRecord } from "../shared/type-guards.js";
|
|
|
9
9
|
*
|
|
10
10
|
* Effects are counted here instead, and only for things that change the world outside the task
|
|
11
11
|
* ledger: writes, outbound media, sub-agent runs, background job launches, and a user-visible
|
|
12
|
-
* reply. Self-report tools (`
|
|
12
|
+
* reply. Self-report tools (`task_create`/`task_update`/`task_close`/`task_verify`, `memory_save`/`memory_search`/`memory_forget`) and read-only tools deliberately do
|
|
13
13
|
* not count — a claim of progress is not evidence of it.
|
|
14
14
|
*
|
|
15
15
|
* The tally lives in process memory, exactly like the driver's futile counter it feeds; a restart
|
|
@@ -21,7 +21,7 @@ import { isRecord } from "../shared/type-guards.js";
|
|
|
21
21
|
const counts = new Map();
|
|
22
22
|
const taskCounts = new Map();
|
|
23
23
|
/** Tools whose successful completion is, by itself, a visible change to the world. */
|
|
24
|
-
const EFFECT_TOOLS = new Set(["write", "edit", "send_media", "subagent"]);
|
|
24
|
+
const EFFECT_TOOLS = new Set(["write", "edit", "send_media", "subagent", "subagent_inline"]);
|
|
25
25
|
export function noteChannelEffect(channelId) {
|
|
26
26
|
counts.set(channelId, (counts.get(channelId) ?? 0) + 1);
|
|
27
27
|
}
|
|
@@ -71,6 +71,13 @@ export function resetChannelEffects() {
|
|
|
71
71
|
* claims to look. What "futile" now means is the honest thing: a wake that executed nothing at all.
|
|
72
72
|
*/
|
|
73
73
|
export function isEffectfulTool(toolName, details) {
|
|
74
|
+
if (toolName === "subagent_run") {
|
|
75
|
+
// Spec 047, F6/D3.2: op=follow_up dispatches a new external run — as much a visible change
|
|
76
|
+
// to the world as `subagent` itself. show/cancel are not. The discriminator is `resumedFrom`
|
|
77
|
+
// in `details` rather than `op`, because only a successful dispatch sets it: every follow_up
|
|
78
|
+
// failure path throws or returns a RecoverableToolError, so a rejection can never count.
|
|
79
|
+
return isRecord(details) && typeof details.resumedFrom === "string";
|
|
80
|
+
}
|
|
74
81
|
if (toolName === "bash") {
|
|
75
82
|
if (!isRecord(details))
|
|
76
83
|
return false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Executor } from "../executor.js";
|
|
2
|
+
import { type FileStore } from "../file-store.js";
|
|
2
3
|
import type { ChannelEvent } from "../runtime/channel-event.js";
|
|
3
4
|
/**
|
|
4
5
|
* Per-channel manager for background bash jobs. A long command that ran synchronously would hold
|
|
@@ -59,6 +60,8 @@ export interface JobManagerOptions {
|
|
|
59
60
|
/** Delivers the completion wake. Omit to disable waking (sub-agent and test paths). */
|
|
60
61
|
dispatch?: (event: ChannelEvent) => boolean | Promise<boolean>;
|
|
61
62
|
sweepIntervalMs?: number;
|
|
63
|
+
/** File-content port for reading a job's spill file (spec 044, D8). Defaults to `createFileStore()`. */
|
|
64
|
+
fileStore?: FileStore;
|
|
62
65
|
}
|
|
63
66
|
/** Cap on concurrently running jobs per channel, so a runaway model can't spawn unbounded processes. */
|
|
64
67
|
export declare const MAX_RUNNING_JOBS = 5;
|
|
@@ -88,6 +91,7 @@ export declare class ChannelJobManager {
|
|
|
88
91
|
private sweeping;
|
|
89
92
|
private readonly options;
|
|
90
93
|
private readonly sweepIntervalMs;
|
|
94
|
+
private readonly fileStore;
|
|
91
95
|
constructor(channelId: string, executor: Executor, options?: JobManagerOptions | number);
|
|
92
96
|
private recordPath;
|
|
93
97
|
/** Mirror a record to disk. Persistence is best-effort: it must never fail a job operation. */
|
|
@@ -2,6 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { chmod, mkdir, readdir, readFile, unlink } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { createFileStore } from "../file-store.js";
|
|
5
6
|
import * as log from "../log.js";
|
|
6
7
|
import { writeFileAtomically } from "../shared/atomic-file.js";
|
|
7
8
|
import { createSerialQueue } from "../shared/serial-queue.js";
|
|
@@ -30,6 +31,8 @@ export const SWEEP_INTERVAL_MS = 10_000;
|
|
|
30
31
|
export const FINISHED_JOB_RETENTION_MS = 24 * 60 * 60_000;
|
|
31
32
|
/** Bytes of captured output carried inline in the completion wake. */
|
|
32
33
|
const WAKE_OUTPUT_TAIL_BYTES = 2_000;
|
|
34
|
+
/** Upper bound on how much of a spill file's tail `readOutput` reads (spec 044, D8). */
|
|
35
|
+
const JOB_OUTPUT_READ_MAX_BYTES = 512 * 1024;
|
|
33
36
|
function jobSpillPath(id) {
|
|
34
37
|
return join(tmpdir(), `pipiclaw-job-${id}.log`);
|
|
35
38
|
}
|
|
@@ -82,6 +85,7 @@ export class ChannelJobManager {
|
|
|
82
85
|
// A bare number keeps the original `sweepIntervalMs` positional form working for tests.
|
|
83
86
|
this.options = typeof options === "number" ? { sweepIntervalMs: options } : options;
|
|
84
87
|
this.sweepIntervalMs = this.options.sweepIntervalMs ?? SWEEP_INTERVAL_MS;
|
|
88
|
+
this.fileStore = this.options.fileStore ?? createFileStore();
|
|
85
89
|
}
|
|
86
90
|
recordPath(id) {
|
|
87
91
|
return this.options.stateDir ? join(this.options.stateDir, `${id}.json`) : undefined;
|
|
@@ -531,8 +535,19 @@ export class ChannelJobManager {
|
|
|
531
535
|
if (!record) {
|
|
532
536
|
return undefined;
|
|
533
537
|
}
|
|
534
|
-
|
|
535
|
-
|
|
538
|
+
// Both callers (the completion wake and the `job` tool) only ever want the *tail* of a job's
|
|
539
|
+
// output, so read it via `FileStore` straight from the end of the file rather than shelling
|
|
540
|
+
// out to `cat` (spec 044, D8) -- no 10MB shell-capture cap silently eating the head of a long
|
|
541
|
+
// job's output before the tail-truncation logic even runs, and no subprocess for what's a
|
|
542
|
+
// plain local-file read.
|
|
543
|
+
const stat = await this.fileStore.stat(record.spillFile);
|
|
544
|
+
if (!stat) {
|
|
545
|
+
return { spillFile: record.spillFile, text: "" };
|
|
546
|
+
}
|
|
547
|
+
const start = Math.max(0, stat.size - JOB_OUTPUT_READ_MAX_BYTES);
|
|
548
|
+
const { data } = await this.fileStore.readBytes(record.spillFile, { start, signal });
|
|
549
|
+
const text = start > 0 ? `[...output truncated...]\n${data.toString("utf-8")}` : data.toString("utf-8");
|
|
550
|
+
return { spillFile: record.spillFile, text };
|
|
536
551
|
}
|
|
537
552
|
}
|
|
538
553
|
// One manager per channel, shared across tool rebuilds so job records survive a resource reload —
|
|
@@ -18,7 +18,7 @@ export declare const AUTOMATIC_TURN_CONTEXT_BUDGET_UNITS = 3000;
|
|
|
18
18
|
* Tool schemas are the larger half of the fixed per-turn cost and were the only part of it with
|
|
19
19
|
* no budget at all: the runtime-authored prompt is capped at 700 units while the schemas beside it
|
|
20
20
|
* run several thousand. They sit in the provider's cache prefix, so the steady-state price is low —
|
|
21
|
-
* but every `rebuildSessionTools` (a
|
|
21
|
+
* but every `rebuildSessionTools` (a workspace skill write, `/reload`, any resource reload) swaps
|
|
22
22
|
* that prefix and pays for all of it again.
|
|
23
23
|
*
|
|
24
24
|
* There is no hard cap on purpose. A schema cannot be auto-trimmed the way a prompt section can:
|
|
@@ -19,7 +19,7 @@ export const AUTOMATIC_TURN_CONTEXT_BUDGET_UNITS = 3_000;
|
|
|
19
19
|
* Tool schemas are the larger half of the fixed per-turn cost and were the only part of it with
|
|
20
20
|
* no budget at all: the runtime-authored prompt is capped at 700 units while the schemas beside it
|
|
21
21
|
* run several thousand. They sit in the provider's cache prefix, so the steady-state price is low —
|
|
22
|
-
* but every `rebuildSessionTools` (a
|
|
22
|
+
* but every `rebuildSessionTools` (a workspace skill write, `/reload`, any resource reload) swaps
|
|
23
23
|
* that prefix and pays for all of it again.
|
|
24
24
|
*
|
|
25
25
|
* There is no hard cap on purpose. A schema cannot be auto-trimmed the way a prompt section can:
|
|
@@ -72,8 +72,8 @@ export const INVARIANTS_SECTION = {
|
|
|
72
72
|
maxChars: 900,
|
|
73
73
|
overflow: "error",
|
|
74
74
|
render: (context) => {
|
|
75
|
-
const memoryLine = hasTool(context, "
|
|
76
|
-
? "- SESSION.md, MEMORY.md and HISTORY.md are runtime-managed; do not edit them with file tools. Use `
|
|
75
|
+
const memoryLine = hasTool(context, "memory_save")
|
|
76
|
+
? "- SESSION.md, MEMORY.md and HISTORY.md are runtime-managed; do not edit them with file tools. Use `memory_save` / `memory_forget` in the same turn when the user explicitly asks to remember or forget something."
|
|
77
77
|
: "- SESSION.md, MEMORY.md and HISTORY.md are runtime-managed; do not edit them with file tools.";
|
|
78
78
|
return [
|
|
79
79
|
"## Runtime Boundaries",
|
|
@@ -90,12 +90,12 @@ export const TASK_CORE_SECTION = {
|
|
|
90
90
|
source: "runtime/tasks",
|
|
91
91
|
authority: "runtime-hard",
|
|
92
92
|
cacheClass: "runtime-stable",
|
|
93
|
-
requiresAllTools: ["
|
|
93
|
+
requiresAllTools: ["task_create", "task_update", "task_close"],
|
|
94
94
|
maxChars: 600,
|
|
95
95
|
overflow: "error",
|
|
96
96
|
render: () => [
|
|
97
97
|
"## Persistent Work",
|
|
98
|
-
"Use a task only when work must survive this turn. Follow the exact task file and runtime guide named by a task wake; use `
|
|
98
|
+
"Use a task only when work must survive this turn. Follow the exact task file and runtime guide named by a task wake; use `task_update`/`task_close` for lifecycle state and never expand the task's stated scope or bypass its verification gate.",
|
|
99
99
|
].join("\n"),
|
|
100
100
|
};
|
|
101
101
|
export const PLAYBOOKS_SECTION = {
|
|
@@ -129,9 +129,12 @@ export const SUBAGENTS_SECTION = {
|
|
|
129
129
|
// (it does not count toward the 700/1200 unit budget — see builder.ts's
|
|
130
130
|
// RUNTIME_AUTHORED_SECTION_IDS — so it must not be padded just because it is "free").
|
|
131
131
|
if (context.subAgents.length === 0) {
|
|
132
|
+
const hasInline = context.tools.some((tool) => tool.name === "subagent_inline");
|
|
132
133
|
return [
|
|
133
134
|
"## Sub-Agents",
|
|
134
|
-
|
|
135
|
+
hasInline
|
|
136
|
+
? "No configured agent exists yet: delegate with `subagent_inline`, passing a `systemPrompt` (no configured agent is required)."
|
|
137
|
+
: "No configured agent exists and `subagent_inline` is off; ask the deployer to add a role or enable it.",
|
|
135
138
|
"A sub-agent starts blank — state goal, scope, paths, constraints, acceptance criteria in `task`.",
|
|
136
139
|
"Read agent-delegation.md before non-trivial delegation.",
|
|
137
140
|
].join("\n");
|
|
@@ -14,5 +14,7 @@ export interface SessionEventHandlerContext {
|
|
|
14
14
|
ledger: UsageLedger;
|
|
15
15
|
isModelCostKnown?: (modelReference: string) => boolean;
|
|
16
16
|
refreshSessionResources?: () => Promise<void>;
|
|
17
|
+
/** Absolute path to `<workspaceDir>/skills` — see `isWorkspaceSkillWrite`. */
|
|
18
|
+
skillsDir?: string;
|
|
17
19
|
}
|
|
18
20
|
export declare function handleSessionEvent(event: unknown, context: SessionEventHandlerContext): Promise<void>;
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import * as log from "../log.js";
|
|
2
|
-
import {
|
|
2
|
+
import { truncate } from "../shared/text-utils.js";
|
|
3
3
|
import { isRecord } from "../shared/type-guards.js";
|
|
4
|
-
import {
|
|
4
|
+
import { describeToolCall } from "../tools/presentation.js";
|
|
5
|
+
import { isArgumentValidationFailure, isRecoverableRejection, toolResultDetails, } from "../tools/tool-details.js";
|
|
5
6
|
import { isEffectfulTool, noteChannelEffect } from "./effect-ledger.js";
|
|
6
7
|
import { extractToolResultText, formatProgressEntry } from "./progress-formatter.js";
|
|
7
8
|
import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, } from "./type-guards.js";
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A `write`/`edit` result whose resolved target landed inside the workspace `skills/` tree. The
|
|
11
|
+
* `skill` tool is read-only (spec 045); authoring a workspace skill goes through the generic file
|
|
12
|
+
* tools, so this is the only way the runtime learns "the skill catalog may have changed" — no
|
|
13
|
+
* per-tool `requiresResourceRefresh` flag to keep in sync any more.
|
|
14
|
+
*/
|
|
15
|
+
function isWorkspaceSkillWrite(toolName, details, skillsDir) {
|
|
16
|
+
if (toolName !== "write" && toolName !== "edit") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (!isRecord(details) || typeof details.path !== "string") {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return details.path === skillsDir || details.path.startsWith(`${skillsDir}/`);
|
|
10
23
|
}
|
|
11
24
|
function mergeSubAgentUsage(totalUsage, details) {
|
|
12
25
|
totalUsage.input += details.usage.input;
|
|
@@ -43,7 +56,7 @@ export async function handleSessionEvent(event, context) {
|
|
|
43
56
|
const showProgress = ctx.progressStyle !== "none";
|
|
44
57
|
const finalToCard = ctx.finalDelivery === "card";
|
|
45
58
|
if (isToolExecutionStartEvent(event)) {
|
|
46
|
-
const label =
|
|
59
|
+
const label = describeToolCall(event.toolName, event.args);
|
|
47
60
|
pendingTools.set(event.toolCallId, {
|
|
48
61
|
toolName: event.toolName,
|
|
49
62
|
args: event.args,
|
|
@@ -93,21 +106,23 @@ export async function handleSessionEvent(event, context) {
|
|
|
93
106
|
subAgentDetails.usage.cost.total > 0 || (context.isModelCostKnown?.(subAgentDetails.model) ?? false);
|
|
94
107
|
}
|
|
95
108
|
const details = toolResultDetails(event.result);
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
queue.enqueue(() => ctx.respondInThread(details.notice ?? ""), "skill notice");
|
|
102
|
-
}
|
|
109
|
+
if (context.skillsDir &&
|
|
110
|
+
context.refreshSessionResources &&
|
|
111
|
+
isWorkspaceSkillWrite(event.toolName, details, context.skillsDir)) {
|
|
112
|
+
queue.enqueue(() => context.refreshSessionResources?.() ?? Promise.resolve(), "refresh skills");
|
|
113
|
+
queue.enqueue(() => ctx.respondInThread("已沉淀:workspace skill 已更新,下一轮生效。"), "skill notice");
|
|
103
114
|
}
|
|
104
115
|
// A recoverable rejection (bad arguments, unmet precondition the model can fix) is not a
|
|
105
116
|
// fault: the model normally corrects it on the next call. It is logged so the retry is
|
|
106
117
|
// still diagnosable, but never rendered to the user — a red bubble would report a failure
|
|
107
118
|
// that never happened and make the assistant look broken mid-turn. Rejections the *user*
|
|
108
119
|
// must resolve (a security guard refusal or an external decision) stay plain errors and remain visible.
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
// Spec 047, D4.2: a schema-validation failure is rejected by the SDK before `execute`, so it
|
|
121
|
+
// never passes through `withToolDetails` and carries no `recoverable` flag — but it is still
|
|
122
|
+
// something the model fixes by re-issuing correct arguments, so it must not surface as a
|
|
123
|
+
// user-visible error. `event.isError` is true for it, so it has to win over `treatAsError`.
|
|
124
|
+
const rejected = isRecoverableRejection(event.result) || isArgumentValidationFailure(event.result, event.isError === true);
|
|
125
|
+
const treatAsError = (event.isError || Boolean(subAgentDetails?.failed)) && !rejected;
|
|
111
126
|
if (treatAsError) {
|
|
112
127
|
log.logToolError(logCtx, event.toolName, durationMs, resultStr);
|
|
113
128
|
}
|
|
@@ -17,8 +17,8 @@ const SYNTHETIC_TOOL_RESULT_HEADER = "Error: Pipiclaw restarted before a durable
|
|
|
17
17
|
"do not repeat the operation blindly.";
|
|
18
18
|
const SYNTHETIC_ABORTED_ASSISTANT_TEXT = "Error: Pipiclaw restarted before a response was generated. Re-send the request if it is still needed.";
|
|
19
19
|
function toolGuidance(toolName) {
|
|
20
|
-
if (toolName === "subagent" || toolName === "
|
|
21
|
-
return "先用 `
|
|
20
|
+
if (toolName === "subagent" || toolName === "subagent_list" || toolName === "subagent_run") {
|
|
21
|
+
return "先用 `subagent_list` / `subagent_run op=show` 查询这次委派是否已经作为一个 durable run 存在。";
|
|
22
22
|
}
|
|
23
23
|
if (toolName === "job" || toolName === "bash") {
|
|
24
24
|
return "若这是一次异步操作(后台 job 或已启动的进程),先用 job `list` / `poll` 查记录,再决定是否需要重跑。";
|
|
@@ -78,7 +78,11 @@ export function isAutoRetryStartEvent(value) {
|
|
|
78
78
|
typeof value.errorMessage === "string");
|
|
79
79
|
}
|
|
80
80
|
export function isSubAgentToolDetails(value) {
|
|
81
|
-
if (!value || typeof value !== "object" || !("kind" in value)
|
|
81
|
+
if (!value || typeof value !== "object" || !("kind" in value)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const kind = value.kind;
|
|
85
|
+
if (kind !== "subagent" && kind !== "subagent_inline") {
|
|
82
86
|
return false;
|
|
83
87
|
}
|
|
84
88
|
if (!("usage" in value)) {
|
|
@@ -12,8 +12,8 @@ export interface PipiclawSkillsResult {
|
|
|
12
12
|
/**
|
|
13
13
|
* Load skills from the workspace-level skill directory.
|
|
14
14
|
*
|
|
15
|
-
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name
|
|
16
|
-
* previously dropped on the floor, so a broken workspace skill silently vanished
|
|
15
|
+
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
|
|
16
|
+
* scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
|
|
17
17
|
* from the prompt. They are returned now and surfaced by the runner.
|
|
18
18
|
*/
|
|
19
19
|
export declare function loadPipiclawSkills(channelDir: string): PipiclawSkillsResult;
|
|
@@ -4,19 +4,57 @@
|
|
|
4
4
|
* SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
|
|
5
5
|
* (`agent/prompt/resources.ts`), which owns their budgets and framing.
|
|
6
6
|
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
7
8
|
import { loadSkillsFromDir } from "@earendil-works/pi-coding-agent";
|
|
8
9
|
import { join } from "path";
|
|
10
|
+
import { scanSkillContent } from "../tools/skill-security.js";
|
|
11
|
+
/**
|
|
12
|
+
* Content scanning moved here from the old `skill_manage` write path (spec 045): `skill` is now
|
|
13
|
+
* read-only and workspace skills are authored through the generic `write`/`edit` tools, which have
|
|
14
|
+
* no reason to know about skill-specific content rules. `Skill` (from pi's resource loader) carries
|
|
15
|
+
* only catalog metadata, not the file body, so this reads each candidate's `SKILL.md` itself --
|
|
16
|
+
* that read is also what keeps a scan-failing skill out of the `<available_skills>` catalog
|
|
17
|
+
* entirely, not just out of the (optional) `skill read` tool: the catalog is what tells the model
|
|
18
|
+
* the skill exists in the first place. An unreadable file is treated as "keep it" here -- a race or
|
|
19
|
+
* permission glitch should not itself become a silent content-policy rejection.
|
|
20
|
+
*/
|
|
21
|
+
function filterScannedSkills(skills) {
|
|
22
|
+
const kept = [];
|
|
23
|
+
const diagnostics = [];
|
|
24
|
+
for (const skill of skills) {
|
|
25
|
+
let content;
|
|
26
|
+
try {
|
|
27
|
+
content = readFileSync(skill.filePath, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
kept.push(skill);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const scan = scanSkillContent(content);
|
|
34
|
+
if (scan.ok) {
|
|
35
|
+
kept.push(skill);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
diagnostics.push({
|
|
39
|
+
type: "warning",
|
|
40
|
+
message: `Skill "${skill.name}" was not loaded: ${scan.error}.`,
|
|
41
|
+
path: skill.filePath,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { skills: kept, diagnostics };
|
|
45
|
+
}
|
|
9
46
|
/**
|
|
10
47
|
* Load skills from the workspace-level skill directory.
|
|
11
48
|
*
|
|
12
|
-
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name
|
|
13
|
-
* previously dropped on the floor, so a broken workspace skill silently vanished
|
|
49
|
+
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
|
|
50
|
+
* scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
|
|
14
51
|
* from the prompt. They are returned now and surfaced by the runner.
|
|
15
52
|
*/
|
|
16
53
|
export function loadPipiclawSkills(channelDir) {
|
|
17
54
|
const workspaceSkillsDir = join(channelDir, "..", "skills");
|
|
18
55
|
const loaded = loadSkillsFromDir({ dir: workspaceSkillsDir, source: "workspace" });
|
|
19
|
-
|
|
56
|
+
const scanned = filterScannedSkills(loaded.skills);
|
|
57
|
+
return { skills: scanned.skills, diagnostics: [...loaded.diagnostics, ...scanned.diagnostics] };
|
|
20
58
|
}
|
|
21
59
|
/**
|
|
22
60
|
* Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
|
package/dist/executor.d.ts
CHANGED
|
@@ -28,9 +28,23 @@ export interface ExecOptions {
|
|
|
28
28
|
stdin?: string;
|
|
29
29
|
/** Directory to run the command in. Defaults to the daemon's own working directory. */
|
|
30
30
|
cwd?: string;
|
|
31
|
+
/** Override the default 10MB in-memory capture cap for this call (spec 044, D6.2). */
|
|
32
|
+
maxCaptureBytes?: number;
|
|
33
|
+
/**
|
|
34
|
+
* When set, every stdout/stderr byte is also streamed to this path as it arrives, independent
|
|
35
|
+
* of `maxCaptureBytes` -- so a caller (e.g. `bash`) can offer a genuinely complete "full output"
|
|
36
|
+
* file even for a command whose captured `ExecResult.stdout`/`stderr` was truncated (spec 044,
|
|
37
|
+
* D6.3). Best-effort: a stream failure is swallowed, since the capped in-memory result is still
|
|
38
|
+
* returned either way. Interleaves stdout and stderr in arrival order.
|
|
39
|
+
*/
|
|
40
|
+
spillTo?: string;
|
|
31
41
|
}
|
|
32
42
|
export interface ExecResult {
|
|
33
43
|
stdout: string;
|
|
34
44
|
stderr: string;
|
|
35
45
|
code: number;
|
|
46
|
+
/** True when `stdout` was cut at the capture cap and does not hold the command's full output. */
|
|
47
|
+
stdoutTruncated?: boolean;
|
|
48
|
+
/** True when `stderr` was cut at the capture cap and does not hold the command's full output. */
|
|
49
|
+
stderrTruncated?: boolean;
|
|
36
50
|
}
|
package/dist/executor.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { createWriteStream } from "node:fs";
|
|
1
2
|
import { spawn } from "child_process";
|
|
3
|
+
/**
|
|
4
|
+
* Default in-memory capture cap for a command's stdout/stderr, in bytes (spec 044, D6.1/D6.2).
|
|
5
|
+
* This is `Executor`'s own bound for *command output* -- file content never goes through it (see
|
|
6
|
+
* `src/file-store.ts`). A caller that needs a different bound (e.g. `grep`) can override it with
|
|
7
|
+
* `ExecOptions.maxCaptureBytes`.
|
|
8
|
+
*/
|
|
2
9
|
const MAX_CAPTURE_BYTES = 10 * 1024 * 1024;
|
|
3
10
|
/**
|
|
4
11
|
* Create an executor that runs commands on the host machine.
|
|
@@ -23,6 +30,41 @@ export class CommandTerminatedError extends Error {
|
|
|
23
30
|
this.timeoutSeconds = timeoutSeconds;
|
|
24
31
|
}
|
|
25
32
|
}
|
|
33
|
+
/** Accumulates raw chunks up to a byte cap without re-copying already-capped data on every event. */
|
|
34
|
+
class CappedByteAccumulator {
|
|
35
|
+
constructor(maxBytes) {
|
|
36
|
+
this.maxBytes = maxBytes;
|
|
37
|
+
this.chunks = [];
|
|
38
|
+
this.bytes = 0;
|
|
39
|
+
this.capped = false;
|
|
40
|
+
}
|
|
41
|
+
push(chunk) {
|
|
42
|
+
if (this.capped)
|
|
43
|
+
return;
|
|
44
|
+
const room = this.maxBytes - this.bytes;
|
|
45
|
+
if (chunk.length <= room) {
|
|
46
|
+
this.chunks.push(chunk);
|
|
47
|
+
this.bytes += chunk.length;
|
|
48
|
+
if (this.bytes >= this.maxBytes) {
|
|
49
|
+
this.capped = true;
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (room > 0) {
|
|
54
|
+
this.chunks.push(chunk.subarray(0, room));
|
|
55
|
+
this.bytes += room;
|
|
56
|
+
}
|
|
57
|
+
this.capped = true;
|
|
58
|
+
}
|
|
59
|
+
get truncated() {
|
|
60
|
+
return this.capped;
|
|
61
|
+
}
|
|
62
|
+
/** Decode once, at close, rather than per-chunk -- see D6.1: per-chunk `toString()` can split a
|
|
63
|
+
* multi-byte UTF-8 sequence across chunk boundaries and mint U+FFFD in the middle of valid text. */
|
|
64
|
+
toText() {
|
|
65
|
+
return Buffer.concat(this.chunks).toString("utf-8");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
26
68
|
class HostExecutor {
|
|
27
69
|
async exec(command, options) {
|
|
28
70
|
return new Promise((resolve, reject) => {
|
|
@@ -42,32 +84,64 @@ class HostExecutor {
|
|
|
42
84
|
if (!child) {
|
|
43
85
|
return;
|
|
44
86
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let stderrCapped = false;
|
|
87
|
+
const maxCaptureBytes = options?.maxCaptureBytes ?? MAX_CAPTURE_BYTES;
|
|
88
|
+
const stdoutAcc = new CappedByteAccumulator(maxCaptureBytes);
|
|
89
|
+
const stderrAcc = new CappedByteAccumulator(maxCaptureBytes);
|
|
49
90
|
let timedOut = false;
|
|
50
91
|
let settled = false;
|
|
51
|
-
|
|
92
|
+
let spillStream;
|
|
93
|
+
let spillFailed = false;
|
|
94
|
+
if (options?.spillTo) {
|
|
95
|
+
try {
|
|
96
|
+
spillStream = createWriteStream(options.spillTo, { mode: 0o600 });
|
|
97
|
+
spillStream.on("error", () => {
|
|
98
|
+
spillFailed = true;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
spillFailed = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const spill = (chunk) => {
|
|
106
|
+
if (spillStream && !spillFailed) {
|
|
107
|
+
spillStream.write(chunk);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
// Waits for the spill file to actually finish flushing to disk before settling the promise
|
|
111
|
+
// -- `spillStream.end()` alone only *starts* the flush, so a caller that reads the spill
|
|
112
|
+
// path immediately after `exec()` resolves could otherwise race an incomplete write.
|
|
113
|
+
const finalize = (action) => {
|
|
52
114
|
if (timeoutHandle)
|
|
53
115
|
clearTimeout(timeoutHandle);
|
|
54
116
|
if (options?.signal) {
|
|
55
117
|
options.signal.removeEventListener("abort", onAbort);
|
|
56
118
|
}
|
|
119
|
+
if (!spillStream) {
|
|
120
|
+
action();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const stream = spillStream;
|
|
124
|
+
let settledSpill = false;
|
|
125
|
+
const done = () => {
|
|
126
|
+
if (settledSpill)
|
|
127
|
+
return;
|
|
128
|
+
settledSpill = true;
|
|
129
|
+
action();
|
|
130
|
+
};
|
|
131
|
+
stream.once("error", done);
|
|
132
|
+
stream.end(done);
|
|
57
133
|
};
|
|
58
134
|
const rejectOnce = (err) => {
|
|
59
135
|
if (settled)
|
|
60
136
|
return;
|
|
61
137
|
settled = true;
|
|
62
|
-
|
|
63
|
-
reject(err);
|
|
138
|
+
finalize(() => reject(err));
|
|
64
139
|
};
|
|
65
140
|
const resolveOnce = (result) => {
|
|
66
141
|
if (settled)
|
|
67
142
|
return;
|
|
68
143
|
settled = true;
|
|
69
|
-
|
|
70
|
-
resolve(result);
|
|
144
|
+
finalize(() => resolve(result));
|
|
71
145
|
};
|
|
72
146
|
const timeoutHandle = options?.timeout && options.timeout > 0
|
|
73
147
|
? setTimeout(() => {
|
|
@@ -92,27 +166,19 @@ class HostExecutor {
|
|
|
92
166
|
// at the cap, which for a high-output command is many GB of memcpy that blocks the event
|
|
93
167
|
// loop for the whole daemon (fix plan §2.2).
|
|
94
168
|
child.stdout?.on("data", (data) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
stdout += data.toString();
|
|
98
|
-
if (stdout.length > MAX_CAPTURE_BYTES) {
|
|
99
|
-
stdout = stdout.slice(0, MAX_CAPTURE_BYTES);
|
|
100
|
-
stdoutCapped = true;
|
|
101
|
-
}
|
|
169
|
+
stdoutAcc.push(data);
|
|
170
|
+
spill(data);
|
|
102
171
|
});
|
|
103
172
|
child.stderr?.on("data", (data) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
stderr += data.toString();
|
|
107
|
-
if (stderr.length > MAX_CAPTURE_BYTES) {
|
|
108
|
-
stderr = stderr.slice(0, MAX_CAPTURE_BYTES);
|
|
109
|
-
stderrCapped = true;
|
|
110
|
-
}
|
|
173
|
+
stderrAcc.push(data);
|
|
174
|
+
spill(data);
|
|
111
175
|
});
|
|
112
176
|
child.on("error", (err) => {
|
|
113
177
|
rejectOnce(err instanceof Error ? err : new Error(String(err)));
|
|
114
178
|
});
|
|
115
179
|
child.on("close", (code) => {
|
|
180
|
+
const stdout = stdoutAcc.toText();
|
|
181
|
+
const stderr = stderrAcc.toText();
|
|
116
182
|
if (options?.signal?.aborted) {
|
|
117
183
|
rejectOnce(new CommandTerminatedError("aborted", stdout, stderr));
|
|
118
184
|
return;
|
|
@@ -121,7 +187,13 @@ class HostExecutor {
|
|
|
121
187
|
rejectOnce(new CommandTerminatedError("timeout", stdout, stderr, options?.timeout));
|
|
122
188
|
return;
|
|
123
189
|
}
|
|
124
|
-
resolveOnce({
|
|
190
|
+
resolveOnce({
|
|
191
|
+
stdout,
|
|
192
|
+
stderr,
|
|
193
|
+
code: code ?? 0,
|
|
194
|
+
...(stdoutAcc.truncated ? { stdoutTruncated: true } : {}),
|
|
195
|
+
...(stderrAcc.truncated ? { stderrTruncated: true } : {}),
|
|
196
|
+
});
|
|
125
197
|
});
|
|
126
198
|
if (options?.stdin !== undefined) {
|
|
127
199
|
child.stdin?.on("error", (err) => {
|