@yaag/runtime 0.23.0 → 0.24.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/package.json +1 -1
- package/src/agent/fork.ts +7 -0
- package/src/agent/spawn-open.ts +24 -5
- package/src/agent/spawn-request.ts +123 -3
- package/src/agent/spawn.ts +3 -0
- package/src/ask/ask-hash.ts +7 -0
- package/src/contract/agent-policy.ts +15 -4
- package/src/contract/error-codes.ts +1 -1
- package/src/contract/index.ts +10 -0
- package/src/contract/spawn-options.ts +7 -1
- package/src/contract/system-prompt.ts +88 -0
- package/src/index.ts +13 -0
- package/src/public-api.ts +11 -0
- package/src/run/run.ts +3 -0
- package/src/system-prompt/agent-prompt-extension.ts +337 -0
- package/src/system-prompt/agent-prompt.ts +15 -0
- package/src/system-prompt/agent-system-prompt.ts +90 -0
- package/src/system-prompt/append-channel.ts +69 -0
- package/src/system-prompt/define-system-prompt.ts +112 -0
- package/src/system-prompt/index.ts +48 -0
- package/src/system-prompt/prompt-guards.ts +60 -0
- package/src/system-prompt/render-sentinel.ts +75 -0
- package/src/transport/append-env.ts +69 -0
- package/src/transport/index.ts +2 -0
- package/src/transport/live-transport.ts +50 -26
- package/src/transport/pi-state.ts +38 -4
- package/src/transport/transport.ts +4 -1
- package/src/types.ts +8 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three spawn-time prompt guards (ADR-0060, ADR-0063).
|
|
3
|
+
*
|
|
4
|
+
* They run in the Orchestrator, at the spawn-request seam, before any Agent
|
|
5
|
+
* process starts. Two of them reject the spawn; the third writes one warning
|
|
6
|
+
* and lets the spawn proceed.
|
|
7
|
+
*/
|
|
8
|
+
import { YaagError } from "../errors.ts";
|
|
9
|
+
import { isPromptVariable, renderSentinel, sentinelPattern } from "./render-sentinel.ts";
|
|
10
|
+
|
|
11
|
+
/** Every marker name a text holds, known or not, in the order they appear. */
|
|
12
|
+
function markerNames(text: string): readonly string[] {
|
|
13
|
+
const names: string[] = [];
|
|
14
|
+
for (const match of text.matchAll(sentinelPattern())) {
|
|
15
|
+
const name = match[1];
|
|
16
|
+
if (name !== undefined && !names.includes(name)) names.push(name);
|
|
17
|
+
}
|
|
18
|
+
return names;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Rejects a plain-string `systemPrompt` that holds a Render Sentinel.
|
|
23
|
+
*
|
|
24
|
+
* This is what a program hits when it writes `systemPrompt: yaagSystemPrompt()`
|
|
25
|
+
* without the `defineSystemPrompt` wrapper (ADR-0060).
|
|
26
|
+
*/
|
|
27
|
+
export function assertNoLeakedSentinel(text: string, agent: string): void {
|
|
28
|
+
const names = markerNames(text);
|
|
29
|
+
if (names.length === 0) return;
|
|
30
|
+
throw new YaagError(
|
|
31
|
+
"SPAWN_FAILED",
|
|
32
|
+
`agent "${agent}": systemPrompt is a plain string that holds a render marker (${names.join(", ")}). Render Sentinels are expanded inside a defineSystemPrompt definition only.`,
|
|
33
|
+
agent,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Rejects a rendered prompt that holds a marker yaag did not generate
|
|
39
|
+
* (ADR-0063). A typo in a hand-written marker is a program fault, and it is
|
|
40
|
+
* cheapest to learn about it before the Agent is up.
|
|
41
|
+
*/
|
|
42
|
+
export function assertKnownSentinels(text: string, agent: string): void {
|
|
43
|
+
const unknown = markerNames(text).filter((name) => !isPromptVariable(name));
|
|
44
|
+
if (unknown.length === 0) return;
|
|
45
|
+
throw new YaagError(
|
|
46
|
+
"SPAWN_FAILED",
|
|
47
|
+
`agent "${agent}": the system prompt holds an unknown render marker (${unknown.join(", ")}). Only a ctx.render*() call of this yaag version writes a marker.`,
|
|
48
|
+
agent,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** True when the program's append text would be dropped (spec decision 19). */
|
|
53
|
+
export function dropsProgramAppend(text: string): boolean {
|
|
54
|
+
return !text.includes(renderSentinel("programAppend"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The one line a dropped append text writes; the seam owns who calls it. */
|
|
58
|
+
export function programAppendWarning(agent: string): string {
|
|
59
|
+
return `[yaag] agent "${agent}": appendSystemPrompt is set, and the system prompt calls no ctx.renderProgramAppend(), so that text is dropped.`;
|
|
60
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Render Sentinel vocabulary: one opaque marker per Prompt Variable
|
|
3
|
+
* (ADR-0056, ADR-0058).
|
|
4
|
+
*
|
|
5
|
+
* This file has no imports at all, by design. The Orchestrator side and the
|
|
6
|
+
* private pi extension both read it, and the extension is loaded by jiti inside
|
|
7
|
+
* the Agent process, where yaag's dependency graph does not exist.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** One Prompt Variable of the Agent System Prompt (ADR-0056, ADR-0058). */
|
|
11
|
+
export type PromptVariable =
|
|
12
|
+
| "model"
|
|
13
|
+
| "pid"
|
|
14
|
+
| "startedAt"
|
|
15
|
+
| "currentDateTime"
|
|
16
|
+
| "cwd"
|
|
17
|
+
| "tools"
|
|
18
|
+
| "appendSystem"
|
|
19
|
+
| "programAppend"
|
|
20
|
+
| "contextFiles"
|
|
21
|
+
| "skills"
|
|
22
|
+
| "piDefaultPrompt";
|
|
23
|
+
|
|
24
|
+
/** Every Prompt Variable, in the order the default text mentions them. */
|
|
25
|
+
export const PROMPT_VARIABLES: readonly PromptVariable[] = [
|
|
26
|
+
"model",
|
|
27
|
+
"pid",
|
|
28
|
+
"startedAt",
|
|
29
|
+
"currentDateTime",
|
|
30
|
+
"cwd",
|
|
31
|
+
"tools",
|
|
32
|
+
"appendSystem",
|
|
33
|
+
"programAppend",
|
|
34
|
+
"contextFiles",
|
|
35
|
+
"skills",
|
|
36
|
+
"piDefaultPrompt",
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The opaque marker one Prompt Variable travels as.
|
|
41
|
+
*
|
|
42
|
+
* The form survives argv, JSON, `prompt` interpolation and a regex sweep, and
|
|
43
|
+
* it is private to yaag: no program can build one yet.
|
|
44
|
+
*/
|
|
45
|
+
export function renderSentinel(variable: PromptVariable): string {
|
|
46
|
+
return `<<<yaag:render:${variable}:1>>>`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A fresh global pattern that matches every well-formed marker, known or not.
|
|
51
|
+
*
|
|
52
|
+
* A fresh regex per call, so no caller inherits another caller's `lastIndex`.
|
|
53
|
+
*/
|
|
54
|
+
export function sentinelPattern(): RegExp {
|
|
55
|
+
return /<<<yaag:render:([a-zA-Z]+):1>>>/g;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The environment variable that carries the system prompt to an Agent whose
|
|
60
|
+
* prompt needs pi's own default text (ADR-0063 amendment 2).
|
|
61
|
+
*
|
|
62
|
+
* yaag then spends no `--system-prompt`, so pi builds its default prompt and
|
|
63
|
+
* the prompt extension receives it as `event.systemPrompt`.
|
|
64
|
+
*/
|
|
65
|
+
export const SYSTEM_PROMPT_ENV = "YAAG_SYSTEM_PROMPT";
|
|
66
|
+
|
|
67
|
+
/** Whether a prompt asks for pi's own default prompt, and so needs the env channel. */
|
|
68
|
+
export function promptNeedsPiDefault(text: string): boolean {
|
|
69
|
+
return text.includes(renderSentinel("piDefaultPrompt"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Whether a marker name is a Prompt Variable this version knows. */
|
|
73
|
+
export function isPromptVariable(name: string): name is PromptVariable {
|
|
74
|
+
return (PROMPT_VARIABLES as readonly string[]).includes(name);
|
|
75
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The writer half of the Append Channel: it decides the child's environment
|
|
3
|
+
* variable for one spawn (ADR-0061).
|
|
4
|
+
*
|
|
5
|
+
* A small text travels inline. A text past the platform-safe limit travels as a
|
|
6
|
+
* temp file the Agent reads. The channel owns that file and removes it when the
|
|
7
|
+
* Agent is gone — the prompt extension re-reads it on every turn, so it may not
|
|
8
|
+
* be removed after startup.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import {
|
|
15
|
+
APPEND_SYSTEM_PROMPT_ENV,
|
|
16
|
+
fileAppendValue,
|
|
17
|
+
inlineAppendValue,
|
|
18
|
+
} from "../system-prompt/index.ts";
|
|
19
|
+
|
|
20
|
+
/** One spawn's Append Channel: the child environment, plus the temp file it may own. */
|
|
21
|
+
export interface AppendChannel {
|
|
22
|
+
/** The child's full environment, with the append variable set or removed. */
|
|
23
|
+
readonly env: Record<string, string>;
|
|
24
|
+
/** Removes the temp file, if this channel made one. Idempotent, never throws. */
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds the child environment for one spawn.
|
|
30
|
+
*
|
|
31
|
+
* When the spawn sets no append text the variable is *removed* rather than
|
|
32
|
+
* inherited: an Orchestrator that itself runs under a stale value would
|
|
33
|
+
* otherwise feed it to every Agent it starts.
|
|
34
|
+
*/
|
|
35
|
+
export function openAppendChannel(
|
|
36
|
+
appendSystemPrompt: string | undefined,
|
|
37
|
+
base: NodeJS.ProcessEnv = process.env,
|
|
38
|
+
): AppendChannel {
|
|
39
|
+
const env: Record<string, string> = {};
|
|
40
|
+
for (const [key, value] of Object.entries(base)) {
|
|
41
|
+
if (value !== undefined) env[key] = value;
|
|
42
|
+
}
|
|
43
|
+
if (appendSystemPrompt === undefined) {
|
|
44
|
+
delete env[APPEND_SYSTEM_PROMPT_ENV];
|
|
45
|
+
return { env, dispose: () => {} };
|
|
46
|
+
}
|
|
47
|
+
const inline = inlineAppendValue(appendSystemPrompt);
|
|
48
|
+
if (inline !== null) {
|
|
49
|
+
env[APPEND_SYSTEM_PROMPT_ENV] = inline;
|
|
50
|
+
return { env, dispose: () => {} };
|
|
51
|
+
}
|
|
52
|
+
const dir = mkdtempSync(join(tmpdir(), "yaag-append-"));
|
|
53
|
+
const path = join(dir, "append-system.md");
|
|
54
|
+
writeFileSync(path, appendSystemPrompt, "utf8");
|
|
55
|
+
env[APPEND_SYSTEM_PROMPT_ENV] = fileAppendValue(path);
|
|
56
|
+
let disposed = false;
|
|
57
|
+
return {
|
|
58
|
+
env,
|
|
59
|
+
dispose: () => {
|
|
60
|
+
if (disposed) return;
|
|
61
|
+
disposed = true;
|
|
62
|
+
try {
|
|
63
|
+
rmSync(dir, { recursive: true, force: true });
|
|
64
|
+
} catch {
|
|
65
|
+
// A leftover file in the temp directory is not worth failing a shutdown.
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
package/src/transport/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// One name for one concept: the recorded selection type lives in `model/`,
|
|
7
7
|
// which `transport/` already depends on (ADR-0039).
|
|
8
8
|
export type { RecordedSpawnSelection } from "../model/index.ts";
|
|
9
|
+
export { type AppendChannel, openAppendChannel } from "./append-env.ts";
|
|
9
10
|
export { type CommandResponse, Connection } from "./connection.ts";
|
|
10
11
|
export {
|
|
11
12
|
FakeTransport,
|
|
@@ -20,6 +21,7 @@ export { liveTransport } from "./live-transport.ts";
|
|
|
20
21
|
export {
|
|
21
22
|
type AgentProgress,
|
|
22
23
|
piCommand,
|
|
24
|
+
piEnv,
|
|
23
25
|
readAgentProgress,
|
|
24
26
|
readCompaction,
|
|
25
27
|
} from "./pi-state.ts";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { YaagError } from "../errors.ts";
|
|
2
|
+
import { type AppendChannel, openAppendChannel } from "./append-env.ts";
|
|
2
3
|
import { FrameQueue } from "./frame-queue.ts";
|
|
3
4
|
import { decodeFrames } from "./jsonl.ts";
|
|
4
|
-
import { piCommand, readModel, readStartup, readStats } from "./pi-state.ts";
|
|
5
|
+
import { piCommand, piEnv, readModel, readStartup, readStats } from "./pi-state.ts";
|
|
5
6
|
import { reap } from "./reap.ts";
|
|
6
7
|
import { appendStderrTail, stderrDiagnostic } from "./stderr-tail.ts";
|
|
7
8
|
import {
|
|
@@ -55,6 +56,12 @@ class LiveTransport implements AgentTransport {
|
|
|
55
56
|
/** Both halves of tool verification, or null when the spawn promised nothing. */
|
|
56
57
|
readonly #verification: { readonly contract: ToolContract; readonly probe: ToolProbe } | null;
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The Append Channel of this Agent (ADR-0061). It is disposed at exit, not
|
|
61
|
+
* after startup: the prompt extension re-reads its temp file on every turn.
|
|
62
|
+
*/
|
|
63
|
+
readonly #append: AppendChannel;
|
|
64
|
+
|
|
58
65
|
#nextId = 0;
|
|
59
66
|
#closing: Promise<AgentStats> | null = null;
|
|
60
67
|
|
|
@@ -62,19 +69,31 @@ class LiveTransport implements AgentTransport {
|
|
|
62
69
|
this.#name = options.name;
|
|
63
70
|
const contract = toolContract(options);
|
|
64
71
|
this.#verification = contract === null ? null : { contract, probe: createToolProbe() };
|
|
65
|
-
this.#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
this.#append = openAppendChannel(options.appendSystemPrompt);
|
|
73
|
+
try {
|
|
74
|
+
this.#process = Bun.spawn({
|
|
75
|
+
cmd: piCommand(options, this.#verification ? TOOL_PROBE_EXTENSION_PATH : undefined),
|
|
76
|
+
cwd: options.cwd,
|
|
77
|
+
// The Append Channel builds the base environment (ADR-0061); the prompt
|
|
78
|
+
// channel of ADR-0063 adds its own variable, always written, so no
|
|
79
|
+
// nested pi inherits a stale one.
|
|
80
|
+
env: { ...this.#append.env, ...piEnv(options) },
|
|
81
|
+
stdin: "pipe",
|
|
82
|
+
stdout: "pipe",
|
|
83
|
+
// pi prints model and startup diagnostics to stderr and exits 1 (main() →
|
|
84
|
+
// reportDiagnostics → process.exit(1)), so stderr carries the only reason
|
|
85
|
+
// yaag can classify. The reader below drains it so pi never blocks.
|
|
86
|
+
stderr: "pipe",
|
|
87
|
+
// Its own process group, so the Agent sees stdin EOF rather than a signal
|
|
88
|
+
// when the Orchestrator dies — EOF is the path that reaps grandchildren.
|
|
89
|
+
detached: true,
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
// No Agent exists to dispose the channel later: a missing `pi` or a bad
|
|
93
|
+
// cwd would otherwise leave its temp directory behind forever.
|
|
94
|
+
this.#append.dispose();
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
78
97
|
void this.#read();
|
|
79
98
|
// A stream error must not surface as an unhandled rejection: the tail is a
|
|
80
99
|
// best-effort diagnostic, never a reason to fail an Agent that started.
|
|
@@ -157,18 +176,23 @@ class LiveTransport implements AgentTransport {
|
|
|
157
176
|
// Stats first: they are unavailable once the process is gone (ticket 02).
|
|
158
177
|
const stats = await this.#readStats();
|
|
159
178
|
const pid = this.#process.pid;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
179
|
+
try {
|
|
180
|
+
await reap({
|
|
181
|
+
exited: this.#process.exited,
|
|
182
|
+
endStdin: () => this.#process.stdin.end(),
|
|
183
|
+
terminate: () => this.#process.kill("SIGTERM"),
|
|
184
|
+
destroyGroup: () => {
|
|
185
|
+
try {
|
|
186
|
+
process.kill(-pid, "SIGKILL");
|
|
187
|
+
} catch {
|
|
188
|
+
this.#process.kill("SIGKILL");
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
} finally {
|
|
193
|
+
// A reap that throws must still release the Append Channel's temp file.
|
|
194
|
+
this.#append.dispose();
|
|
195
|
+
}
|
|
172
196
|
this.#queue.end();
|
|
173
197
|
this.#verification?.probe.fail(
|
|
174
198
|
new Error(`agent "${this.#name}" exited before tool verification completed`),
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { REPORT_RESULT_EXTENSION_PATH, REPORT_RESULT_TOOL_NAME } from "../ask-contract/index.ts";
|
|
2
2
|
import type { AgentProgress } from "../contract/index.ts";
|
|
3
3
|
import { isThinkingLevel, type ThinkingLevel } from "../model/index.ts";
|
|
4
|
+
import {
|
|
5
|
+
AGENT_PROMPT_EXTENSION_PATH,
|
|
6
|
+
promptNeedsPiDefault,
|
|
7
|
+
SYSTEM_PROMPT_ENV,
|
|
8
|
+
} from "../system-prompt/index.ts";
|
|
4
9
|
import { SYSTEM_PROMPT_RECORDER_EXTENSION_PATH } from "./system-prompt-recorder.ts";
|
|
5
10
|
import type {
|
|
6
11
|
AgentStats,
|
|
@@ -17,11 +22,17 @@ export type { AgentProgress } from "../contract/index.ts";
|
|
|
17
22
|
export function piCommand(options: OpenOptions, toolProbeExtensionPath?: string): string[] {
|
|
18
23
|
const cmd = ["pi", "--mode", "rpc"];
|
|
19
24
|
if (options.model) cmd.push("--model", options.model);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
// A prompt that asks for pi's own default text travels in the environment
|
|
26
|
+
// instead: with no `--system-prompt`, pi builds its default prompt and the
|
|
27
|
+
// prompt extension receives it as `event.systemPrompt` (ADR-0063).
|
|
28
|
+
if (options.systemPrompt && !promptNeedsPiDefault(options.systemPrompt)) {
|
|
29
|
+
cmd.push("--system-prompt", options.systemPrompt);
|
|
24
30
|
}
|
|
31
|
+
if (options.thinking !== undefined) cmd.push("--thinking", options.thinking);
|
|
32
|
+
// No `--append-system-prompt`: the program's text no longer travels in argv.
|
|
33
|
+
// `append-env.ts` puts it in `YAAG_APPEND_SYSTEM_PROMPT` instead, so pi's
|
|
34
|
+
// flag precedence leaves its own `APPEND_SYSTEM.md` discovery alone and both
|
|
35
|
+
// texts reach the prompt in their own slots (ADR-0059, ADR-0061).
|
|
25
36
|
appendCapabilities(cmd, options, toolProbeExtensionPath);
|
|
26
37
|
if (options.sessionDir) cmd.push("--session-dir", options.sessionDir);
|
|
27
38
|
// `--session` and `--fork` are mutually exclusive in pi, and a resume is the
|
|
@@ -32,6 +43,18 @@ export function piCommand(options: OpenOptions, toolProbeExtensionPath?: string)
|
|
|
32
43
|
return cmd;
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The environment yaag adds to one Agent process.
|
|
48
|
+
*
|
|
49
|
+
* `YAAG_SYSTEM_PROMPT` is always written, empty when the prompt travels on the
|
|
50
|
+
* flag, so a nested pi can never inherit a stale prompt from its parent.
|
|
51
|
+
*/
|
|
52
|
+
export function piEnv(options: OpenOptions): Record<string, string> {
|
|
53
|
+
const prompt = options.systemPrompt;
|
|
54
|
+
const needsEnv = typeof prompt === "string" && prompt !== "" && promptNeedsPiDefault(prompt);
|
|
55
|
+
return { [SYSTEM_PROMPT_ENV]: needsEnv ? prompt : "" };
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
function appendCapabilities(
|
|
36
59
|
cmd: string[],
|
|
37
60
|
options: OpenOptions,
|
|
@@ -48,6 +71,17 @@ function appendCapabilities(
|
|
|
48
71
|
if (hermetic) {
|
|
49
72
|
cmd.push("--no-extensions", "--no-context-files", "--no-prompt-templates");
|
|
50
73
|
}
|
|
74
|
+
// Load order is fixed (ADR-0063): the prompt extension first, then the
|
|
75
|
+
// program extensions, `report_result`, the tool probe, and the recorder last.
|
|
76
|
+
// `before_agent_start` handlers chain in load order, so first means a program
|
|
77
|
+
// extension appends to the already assembled Agent System Prompt.
|
|
78
|
+
//
|
|
79
|
+
// It means the extension receives pi's own default prompt only on the
|
|
80
|
+
// environment channel above: with `--system-prompt` pi takes its
|
|
81
|
+
// `customPrompt` branch, which never builds the guideline prompt (pi
|
|
82
|
+
// `dist/core/system-prompt.js:15-33`). See the header of
|
|
83
|
+
// `agent-prompt-extension.ts` for both channels.
|
|
84
|
+
cmd.push("-e", AGENT_PROMPT_EXTENSION_PATH);
|
|
51
85
|
for (const path of options.resolvedExtensionPaths ?? []) cmd.push("-e", path);
|
|
52
86
|
// Every Agent carries the report-result tool, because an Ask declares its
|
|
53
87
|
// output schema long after the process started and pi loads extensions only
|
|
@@ -201,7 +201,10 @@ export interface OpenOptions {
|
|
|
201
201
|
readonly inherit?: boolean;
|
|
202
202
|
/** Deterministic process-start thinking level; omission preserves pi's default. */
|
|
203
203
|
readonly thinking?: ThinkingLevel;
|
|
204
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* The text the `programAppend` slot of the Agent System Prompt prints,
|
|
206
|
+
* delivered to the Agent through the environment (ADR-0061).
|
|
207
|
+
*/
|
|
205
208
|
readonly appendSystemPrompt?: string;
|
|
206
209
|
/** Tool allowlist; an empty list disables all tools. */
|
|
207
210
|
readonly tools?: readonly string[];
|
package/src/types.ts
CHANGED
|
@@ -11,10 +11,18 @@ export type {
|
|
|
11
11
|
CompactionResult,
|
|
12
12
|
ForkOptions,
|
|
13
13
|
Handle,
|
|
14
|
+
LiteralPromptText,
|
|
14
15
|
ModelError,
|
|
16
|
+
PromptAudience,
|
|
17
|
+
PromptText,
|
|
15
18
|
ResolvedSpawnOptions,
|
|
16
19
|
SpawnOptions,
|
|
17
20
|
SpawnOverrides,
|
|
18
21
|
StructuredAskOptions,
|
|
22
|
+
SystemPromptAgent,
|
|
23
|
+
SystemPromptBuilder,
|
|
24
|
+
SystemPromptContext,
|
|
25
|
+
SystemPromptDefinition,
|
|
26
|
+
SystemPromptInput,
|
|
19
27
|
ThinkingLevel,
|
|
20
28
|
} from "./contract/index.ts";
|