@zpi-dev/agent-sdk 0.0.0-stage → 0.1.60
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/NOTICE +1206 -0
- package/README.md +54 -2
- package/dist/chunk-4WFFCN2C.js +29607 -0
- package/dist/chunk-4WFFCN2C.js.map +1 -0
- package/dist/chunk-AR5RMMMN.js +24353 -0
- package/dist/chunk-AR5RMMMN.js.map +1 -0
- package/dist/chunk-RAZL7ZAW.js +13451 -0
- package/dist/chunk-RAZL7ZAW.js.map +1 -0
- package/dist/chunk-TUOZKHGN.js +21 -0
- package/dist/chunk-TUOZKHGN.js.map +1 -0
- package/dist/chunk-YBW5XDR7.js +48 -0
- package/dist/chunk-YBW5XDR7.js.map +1 -0
- package/dist/host.d.ts +1 -0
- package/dist/host.js +34 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/node-WXHENNL2.js +21 -0
- package/dist/node-WXHENNL2.js.map +1 -0
- package/dist/node-XSTAMDFW.js +2225 -0
- package/dist/node-XSTAMDFW.js.map +1 -0
- package/dist/src-7WDJXP5P.js +128 -0
- package/dist/src-7WDJXP5P.js.map +1 -0
- package/dist/types/agent/src/agent-loop.d.ts +3 -0
- package/dist/types/agent/src/agent.d.ts +21 -0
- package/dist/types/agent/src/index.d.ts +3 -0
- package/dist/types/agent/src/streaming-tool-coordinator.d.ts +10 -0
- package/dist/types/agent/src/tool-execution.d.ts +9 -0
- package/dist/types/agent/src/types.d.ts +144 -0
- package/dist/types/agent-sdk/src/hooks.d.ts +12 -0
- package/dist/types/agent-sdk/src/host.d.ts +4 -0
- package/dist/types/agent-sdk/src/index.d.ts +4 -0
- package/dist/types/agent-sdk/src/messages.d.ts +12 -0
- package/dist/types/agent-sdk/src/permissions.d.ts +10 -0
- package/dist/types/agent-sdk/src/query-result.d.ts +7 -0
- package/dist/types/agent-sdk/src/query.d.ts +6 -0
- package/dist/types/agent-sdk/src/resources.d.ts +16 -0
- package/dist/types/agent-sdk/src/runtime.d.ts +7 -0
- package/dist/types/agent-sdk/src/sessions.d.ts +48 -0
- package/dist/types/agent-sdk/src/tasks.d.ts +8 -0
- package/dist/types/agent-sdk/src/tools.d.ts +5 -0
- package/dist/types/agent-sdk/src/types.d.ts +428 -0
- package/dist/types/ai/src/api/anthropic-messages.d.ts +70 -0
- package/dist/types/ai/src/api/constrained-sampling.d.ts +5 -0
- package/dist/types/ai/src/api/github-copilot-headers.d.ts +7 -0
- package/dist/types/ai/src/api/openai-completions.d.ts +10 -0
- package/dist/types/ai/src/api/openai-responses.d.ts +5 -0
- package/dist/types/ai/src/api/responses-cache.d.ts +6 -0
- package/dist/types/ai/src/api/responses-events.d.ts +3 -0
- package/dist/types/ai/src/api/responses-session.d.ts +56 -0
- package/dist/types/ai/src/api/simple-options.d.ts +14 -0
- package/dist/types/ai/src/api/transform-messages.d.ts +3 -0
- package/dist/types/ai/src/auth/openai-chatgpt.d.ts +32 -0
- package/dist/types/ai/src/index.d.ts +20 -0
- package/dist/types/ai/src/providers/discovery.d.ts +14 -0
- package/dist/types/ai/src/providers/registry.d.ts +155 -0
- package/dist/types/ai/src/stream.d.ts +5 -0
- package/dist/types/ai/src/types.d.ts +394 -0
- package/dist/types/ai/src/utils/abort.d.ts +2 -0
- package/dist/types/ai/src/utils/context-breakdown.d.ts +3 -0
- package/dist/types/ai/src/utils/cost.d.ts +2 -0
- package/dist/types/ai/src/utils/diagnostics.d.ts +16 -0
- package/dist/types/ai/src/utils/error-body.d.ts +24 -0
- package/dist/types/ai/src/utils/estimate.d.ts +16 -0
- package/dist/types/ai/src/utils/event-stream.d.ts +15 -0
- package/dist/types/ai/src/utils/guard-model-stream.d.ts +3 -0
- package/dist/types/ai/src/utils/headers.d.ts +1 -0
- package/dist/types/ai/src/utils/json-parse.d.ts +7 -0
- package/dist/types/ai/src/utils/media-policy.d.ts +68 -0
- package/dist/types/ai/src/utils/model-performance.d.ts +23 -0
- package/dist/types/ai/src/utils/model-retry.d.ts +3 -0
- package/dist/types/ai/src/utils/option-map/compiler.d.ts +2 -0
- package/dist/types/ai/src/utils/option-map/evaluator.d.ts +3 -0
- package/dist/types/ai/src/utils/option-map/parser.d.ts +40 -0
- package/dist/types/ai/src/utils/option-map/tokenizer.d.ts +8 -0
- package/dist/types/ai/src/utils/option-map/types.d.ts +15 -0
- package/dist/types/ai/src/utils/overflow.d.ts +68 -0
- package/dist/types/ai/src/utils/provider-cache.d.ts +11 -0
- package/dist/types/ai/src/utils/provider-env.d.ts +2 -0
- package/dist/types/ai/src/utils/provider-retry.d.ts +17 -0
- package/dist/types/ai/src/utils/reasoning.d.ts +14 -0
- package/dist/types/ai/src/utils/redact-error.d.ts +2 -0
- package/dist/types/ai/src/utils/retry.d.ts +62 -0
- package/dist/types/ai/src/utils/sanitize-unicode.d.ts +21 -0
- package/dist/types/ai/src/utils/stream-idle-timeout.d.ts +36 -0
- package/dist/types/ai/src/utils/text.d.ts +9 -0
- package/dist/types/ai/src/utils/transcript.d.ts +41 -0
- package/dist/types/coding-agent/src/core/agent-session.d.ts +174 -0
- package/dist/types/coding-agent/src/core/commands.d.ts +19 -0
- package/dist/types/coding-agent/src/core/compaction-utils.d.ts +37 -0
- package/dist/types/coding-agent/src/core/compaction.d.ts +139 -0
- package/dist/types/coding-agent/src/core/file-rewind.d.ts +24 -0
- package/dist/types/coding-agent/src/core/fs.d.ts +1 -0
- package/dist/types/coding-agent/src/core/http-idle-timeout.d.ts +2 -0
- package/dist/types/coding-agent/src/core/image-limits.d.ts +19 -0
- package/dist/types/coding-agent/src/core/images.d.ts +18 -0
- package/dist/types/coding-agent/src/core/input.d.ts +3 -0
- package/dist/types/coding-agent/src/core/markdown-code.d.ts +7 -0
- package/dist/types/coding-agent/src/core/markdown.d.ts +13 -0
- package/dist/types/coding-agent/src/core/mentions.d.ts +12 -0
- package/dist/types/coding-agent/src/core/microcompact.d.ts +40 -0
- package/dist/types/coding-agent/src/core/model-performance.d.ts +57 -0
- package/dist/types/coding-agent/src/core/model-runtime.d.ts +51 -0
- package/dist/types/coding-agent/src/core/read-file-bounded.d.ts +2 -0
- package/dist/types/coding-agent/src/core/record-validation.d.ts +6 -0
- package/dist/types/coding-agent/src/core/resources.d.ts +51 -0
- package/dist/types/coding-agent/src/core/sdk.d.ts +50 -0
- package/dist/types/coding-agent/src/core/session-manager.d.ts +137 -0
- package/dist/types/coding-agent/src/core/session-state.d.ts +14 -0
- package/dist/types/coding-agent/src/core/settings-manager.d.ts +41 -0
- package/dist/types/coding-agent/src/core/streaming-tool-journal.d.ts +17 -0
- package/dist/types/coding-agent/src/core/system-prompt.d.ts +25 -0
- package/dist/types/coding-agent/src/core/tools/file-change.d.ts +21 -0
- package/dist/types/coding-agent/src/core/tools/index.d.ts +20 -0
- package/dist/types/coding-agent/src/core/tools/pi/bash.d.ts +185 -0
- package/dist/types/coding-agent/src/core/tools/pi/edit-diff.d.ts +84 -0
- package/dist/types/coding-agent/src/core/tools/pi/edit.d.ts +69 -0
- package/dist/types/coding-agent/src/core/tools/pi/file-mutation-queue.d.ts +5 -0
- package/dist/types/coding-agent/src/core/tools/pi/file-read-state.d.ts +12 -0
- package/dist/types/coding-agent/src/core/tools/pi/output-accumulator.d.ts +68 -0
- package/dist/types/coding-agent/src/core/tools/pi/path-utils.d.ts +7 -0
- package/dist/types/coding-agent/src/core/tools/pi/read.d.ts +63 -0
- package/dist/types/coding-agent/src/core/tools/pi/text-range-reader.d.ts +22 -0
- package/dist/types/coding-agent/src/core/tools/pi/tool-definition-wrapper.d.ts +4 -0
- package/dist/types/coding-agent/src/core/tools/pi/truncate.d.ts +60 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/bmp-source.d.ts +2 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/child-process.d.ts +13 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/image-budget.d.ts +16 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/image-process.d.ts +18 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/image-resize-core.d.ts +26 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/image-resize.d.ts +3 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/image-source.d.ts +11 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/mime.d.ts +3 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/paths.d.ts +16 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/read-file.d.ts +2 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/shell.d.ts +18 -0
- package/dist/types/coding-agent/src/core/tools/pi/utils/text.d.ts +5 -0
- package/dist/types/coding-agent/src/core/tools/pi/write.d.ts +44 -0
- package/dist/types/coding-agent/src/core/transcript-store.d.ts +71 -0
- package/dist/types/coding-agent/src/core/types.d.ts +60 -0
- package/dist/types/coding-agent/src/index.d.ts +42 -0
- package/dist/types/coding-agent/src/plugins/assembly.d.ts +37 -0
- package/dist/types/coding-agent/src/plugins/hooks.d.ts +82 -0
- package/dist/types/coding-agent/src/plugins/resources.d.ts +4 -0
- package/dist/types/coding-agent/src/plugins/session-hooks.d.ts +26 -0
- package/dist/types/coding-agent/src/plugins/types.d.ts +40 -0
- package/dist/types/plugin-compat/src/command-hooks.d.ts +184 -0
- package/dist/types/plugin-compat/src/index.d.ts +11 -0
- package/package.json +53 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type TruncationResult } from "./truncate.js";
|
|
2
|
+
export interface OutputAccumulatorOptions {
|
|
3
|
+
maxLines?: number;
|
|
4
|
+
maxBytes?: number;
|
|
5
|
+
tempFilePrefix?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OutputSnapshot {
|
|
8
|
+
content: string;
|
|
9
|
+
truncation: TruncationResult;
|
|
10
|
+
fullOutputPath?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface FullOutput {
|
|
13
|
+
content: string;
|
|
14
|
+
/** Whether `content` omits part of the output. */
|
|
15
|
+
truncated: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Keep recent output available to read, and prune expired logs on the next bash invocation. */
|
|
18
|
+
export declare function cleanupOutputFiles(prefix: string, directory?: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Incrementally tracks streaming output with bounded memory when producers await `append`.
|
|
21
|
+
*
|
|
22
|
+
* Appends decode chunks with a streaming UTF-8 decoder, keeps only a decoded
|
|
23
|
+
* tail for display snapshots, and opens a temp file when the full output needs
|
|
24
|
+
* to be preserved.
|
|
25
|
+
*/
|
|
26
|
+
export declare class OutputAccumulator {
|
|
27
|
+
private readonly maxLines;
|
|
28
|
+
private readonly maxBytes;
|
|
29
|
+
private readonly maxRollingBytes;
|
|
30
|
+
private readonly tempFilePrefix;
|
|
31
|
+
private readonly decoder;
|
|
32
|
+
private rawChunks;
|
|
33
|
+
private tailText;
|
|
34
|
+
private tailBytes;
|
|
35
|
+
private tailStartsAtLineBoundary;
|
|
36
|
+
private totalRawBytes;
|
|
37
|
+
private totalDecodedBytes;
|
|
38
|
+
private completedLines;
|
|
39
|
+
private totalLines;
|
|
40
|
+
private currentLineBytes;
|
|
41
|
+
private hasOpenLine;
|
|
42
|
+
private finished;
|
|
43
|
+
private tempFilePath;
|
|
44
|
+
private tempFileStream;
|
|
45
|
+
private tempFileError;
|
|
46
|
+
private tempFileDrain;
|
|
47
|
+
constructor(options?: OutputAccumulatorOptions);
|
|
48
|
+
/** Await the returned promise, when present, before appending another chunk. */
|
|
49
|
+
append(data: Buffer): void | Promise<void>;
|
|
50
|
+
finish(): void;
|
|
51
|
+
snapshot(options?: {
|
|
52
|
+
persistIfTruncated?: boolean;
|
|
53
|
+
}): OutputSnapshot;
|
|
54
|
+
closeTempFile(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* The complete output, for callers that can take more than the display snapshot. Call after
|
|
57
|
+
* `finish()` and `closeTempFile()`. Output longer than `maxBytes` raw bytes keeps its first and
|
|
58
|
+
* last `maxBytes / 2` bytes around an omission marker.
|
|
59
|
+
*/
|
|
60
|
+
readFullOutput(maxBytes: number): Promise<FullOutput>;
|
|
61
|
+
getLastLineBytes(): number;
|
|
62
|
+
private appendDecodedText;
|
|
63
|
+
private trimTail;
|
|
64
|
+
private getSnapshotText;
|
|
65
|
+
private shouldUseTempFile;
|
|
66
|
+
private waitForTempFileDrain;
|
|
67
|
+
private ensureTempFile;
|
|
68
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a path relative to the given cwd.
|
|
4
|
+
* Handles ~ expansion and absolute paths.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveToCwd(filePath: string, cwd: string): string;
|
|
7
|
+
export declare function resolveReadPathAsync(filePath: string, cwd: string): Promise<string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ImageContent, TextContent } from "../../../../../ai/src/index.js";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { ToolContext } from "../../types.js";
|
|
4
|
+
import { FileReadState } from "./file-read-state.js";
|
|
5
|
+
import { type TruncationResult } from "./truncate.js";
|
|
6
|
+
import type { ImageResizeOptions as ModelImageResizeOptions } from "./utils/image-resize-core.js";
|
|
7
|
+
export declare const readToolSystemPromptContribution: {
|
|
8
|
+
readonly snippet: "Read file contents";
|
|
9
|
+
readonly guidelines: readonly ["Use read to examine files instead of cat or sed."];
|
|
10
|
+
};
|
|
11
|
+
export interface ReadToolDetails {
|
|
12
|
+
truncation?: TruncationResult;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pluggable operations for the read tool.
|
|
16
|
+
* Override these to delegate file reading to remote systems (for example SSH).
|
|
17
|
+
*/
|
|
18
|
+
export interface ReadOperations {
|
|
19
|
+
/** Read file contents as a Buffer. Bound source I/O to maxBytes + 1 when a limit is supplied. */
|
|
20
|
+
readFile: (absolutePath: string, maxBytes?: number) => Promise<Buffer>;
|
|
21
|
+
/** Check if file is readable (throw if not) */
|
|
22
|
+
access: (absolutePath: string) => Promise<void>;
|
|
23
|
+
/** Detect image MIME type, return null or undefined for non-images */
|
|
24
|
+
detectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;
|
|
25
|
+
}
|
|
26
|
+
export interface ReadToolOptions {
|
|
27
|
+
/** Shared knowledge of file contents in the current model context. */
|
|
28
|
+
fileReadState?: FileReadState;
|
|
29
|
+
/** Whether to auto-resize images. Default: true */
|
|
30
|
+
autoResizeImages?: boolean;
|
|
31
|
+
/** Fallback resize profile when the execution context has no model metadata. */
|
|
32
|
+
resizeOptions?: ModelImageResizeOptions;
|
|
33
|
+
/** Custom operations for file reading. Default: local filesystem */
|
|
34
|
+
operations?: ReadOperations;
|
|
35
|
+
}
|
|
36
|
+
export declare function createReadToolDefinition(cwd: string, options?: ReadToolOptions): {
|
|
37
|
+
name: string;
|
|
38
|
+
metadata: {
|
|
39
|
+
readOnly: true;
|
|
40
|
+
concurrentSafe: true;
|
|
41
|
+
destructive: false;
|
|
42
|
+
needsApproval: false;
|
|
43
|
+
requiresUserInteraction: false;
|
|
44
|
+
sideEffectScope: "none";
|
|
45
|
+
};
|
|
46
|
+
label: string;
|
|
47
|
+
description: string;
|
|
48
|
+
promptSnippet: "Read file contents";
|
|
49
|
+
promptGuidelines: "Use read to examine files instead of cat or sed."[];
|
|
50
|
+
parameters: Type.TObject<{
|
|
51
|
+
path: Type.TString;
|
|
52
|
+
offset: Type.TOptional<Type.TInteger>;
|
|
53
|
+
limit: Type.TOptional<Type.TInteger>;
|
|
54
|
+
}>;
|
|
55
|
+
execute(_toolCallId: string, { path, offset, limit }: {
|
|
56
|
+
path: string;
|
|
57
|
+
offset?: number;
|
|
58
|
+
limit?: number;
|
|
59
|
+
}, signal?: AbortSignal, _onUpdate?: import("../../../../../agent/src/index.js").AgentToolUpdateCallback<ReadToolDetails | undefined> | undefined, ctx?: Partial<ToolContext>): Promise<{
|
|
60
|
+
content: (TextContent | ImageContent)[];
|
|
61
|
+
details: ReadToolDetails | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count and hash the entire decoded file, but retain only a bounded prefix of the
|
|
3
|
+
* requested range. Never buffer a whole line: a single line can be arbitrarily large.
|
|
4
|
+
*/
|
|
5
|
+
export declare function readTextRange(chunks: AsyncIterable<string> | Iterable<string>, offset?: number, limit?: number): Promise<{
|
|
6
|
+
hash: string;
|
|
7
|
+
totalFileLines: number;
|
|
8
|
+
firstLineBytes: number;
|
|
9
|
+
truncation: {
|
|
10
|
+
content: string;
|
|
11
|
+
truncated: boolean;
|
|
12
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
13
|
+
outputLines: number;
|
|
14
|
+
outputBytes: number;
|
|
15
|
+
lastLinePartial: boolean;
|
|
16
|
+
firstLineExceedsLimit: boolean;
|
|
17
|
+
maxLines: number;
|
|
18
|
+
maxBytes: number;
|
|
19
|
+
totalLines: number;
|
|
20
|
+
totalBytes: number;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentTool } from "../../../../../agent/src/index.js";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
3
|
+
import type { ToolDefinition } from "../../types.js";
|
|
4
|
+
export declare function wrapToolDefinition<T extends TSchema, D, C>(definition: ToolDefinition<T, D, C>, context: (signal?: AbortSignal) => C, serializeDetails?: boolean): AgentTool<T>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared truncation utilities for tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Truncation is based on two independent limits - whichever is hit first wins:
|
|
5
|
+
* - Line limit (default: 2000 lines)
|
|
6
|
+
* - Byte limit (default: 50KB)
|
|
7
|
+
*
|
|
8
|
+
* Never returns partial lines (except bash tail truncation edge case).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_MAX_LINES = 2000;
|
|
11
|
+
export declare const DEFAULT_MAX_BYTES: number;
|
|
12
|
+
export interface TruncationResult {
|
|
13
|
+
/** The truncated content */
|
|
14
|
+
content: string;
|
|
15
|
+
/** Whether truncation occurred */
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
/** Which limit was hit: "lines", "bytes", or null if not truncated */
|
|
18
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
19
|
+
/** Total number of lines in the original content */
|
|
20
|
+
totalLines: number;
|
|
21
|
+
/** Total number of bytes in the original content */
|
|
22
|
+
totalBytes: number;
|
|
23
|
+
/** Number of complete lines in the truncated output */
|
|
24
|
+
outputLines: number;
|
|
25
|
+
/** Number of bytes in the truncated output */
|
|
26
|
+
outputBytes: number;
|
|
27
|
+
/** Whether the last line was partially truncated (only for tail truncation edge case) */
|
|
28
|
+
lastLinePartial: boolean;
|
|
29
|
+
/** Whether the first line exceeded the byte limit (for head truncation) */
|
|
30
|
+
firstLineExceedsLimit: boolean;
|
|
31
|
+
/** The max lines limit that was applied */
|
|
32
|
+
maxLines: number;
|
|
33
|
+
/** The max bytes limit that was applied */
|
|
34
|
+
maxBytes: number;
|
|
35
|
+
}
|
|
36
|
+
export interface TruncationOptions {
|
|
37
|
+
/** Maximum number of lines (default: 2000) */
|
|
38
|
+
maxLines?: number;
|
|
39
|
+
/** Maximum number of bytes (default: 50KB) */
|
|
40
|
+
maxBytes?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Format bytes as human-readable size.
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatSize(bytes: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Truncate content from the head (keep first N lines/bytes).
|
|
48
|
+
* Suitable for file reads where you want to see the beginning.
|
|
49
|
+
*
|
|
50
|
+
* Never returns partial lines. If first line exceeds byte limit,
|
|
51
|
+
* returns empty content with firstLineExceedsLimit=true.
|
|
52
|
+
*/
|
|
53
|
+
export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
|
|
54
|
+
/**
|
|
55
|
+
* Truncate content from the tail (keep last N lines/bytes).
|
|
56
|
+
* Suitable for bash output where you want to see the end (errors, final results).
|
|
57
|
+
*
|
|
58
|
+
* May return partial first line if the last line of original content exceeds byte limit.
|
|
59
|
+
*/
|
|
60
|
+
export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Wait for a child process to terminate without hanging on inherited stdio handles.
|
|
4
|
+
*
|
|
5
|
+
* A short-lived child can `exit` while a detached descendant keeps its stdout/stderr
|
|
6
|
+
* pipe open. We must not resolve and destroy the streams on a fixed deadline measured
|
|
7
|
+
* from `exit`, or output still being written past that deadline is silently lost
|
|
8
|
+
* (earendil-works/pi#5303). Instead, after `exit` we wait for the pipes to fall idle:
|
|
9
|
+
* the grace timer is re-armed on every chunk, so an actively writing descendant keeps
|
|
10
|
+
* us reading, while a quiet inherited handle (e.g. a Windows daemonized descendant
|
|
11
|
+
* that never lets `close` fire) still releases us after the grace elapses.
|
|
12
|
+
*/
|
|
13
|
+
export declare function waitForChildProcess(child: ChildProcess): Promise<number | null>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ImageResizeOptions } from "./image-resize-core.js";
|
|
2
|
+
export interface ImageBudget {
|
|
3
|
+
maxRawBytes: number;
|
|
4
|
+
maxBase64Bytes: number;
|
|
5
|
+
maxTokens?: number;
|
|
6
|
+
tokenToBase64CharRatio: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function imageBudget(options?: ImageResizeOptions): ImageBudget;
|
|
9
|
+
export declare function fitsImageBudget(bytes: Uint8Array, budget: ImageBudget): boolean;
|
|
10
|
+
/** Model profiles can tighten Read's limits, never relax its independent 25K image-token budget. */
|
|
11
|
+
export declare function readImageResizeOptions(options?: ImageResizeOptions): ImageResizeOptions;
|
|
12
|
+
export type ImageProcessorErrorCode = "invalid_request" | "empty" | "processing_failed" | "too_large" | "unsupported";
|
|
13
|
+
export declare class ImageProcessorError extends Error {
|
|
14
|
+
readonly code: ImageProcessorErrorCode;
|
|
15
|
+
constructor(code: ImageProcessorErrorCode, message: string);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ImageResizeOptions } from "./image-resize.js";
|
|
2
|
+
export interface ProcessImageOptions {
|
|
3
|
+
autoResizeImages?: boolean;
|
|
4
|
+
resizeOptions?: ImageResizeOptions;
|
|
5
|
+
}
|
|
6
|
+
export type ProcessImageResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
data: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
hints: string[];
|
|
11
|
+
strategy?: string;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
message: string;
|
|
15
|
+
code?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Attachments deliberately omit maxTokens: 5 MiB base64, unlike Read's 200,000 bytes. */
|
|
18
|
+
export declare function processImage(bytes: Uint8Array, mimeType: string, options?: ProcessImageOptions): Promise<ProcessImageResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ImageResizeOptions {
|
|
2
|
+
maxWidth?: number;
|
|
3
|
+
maxHeight?: number;
|
|
4
|
+
/** Encoded base64 bytes, excluding the data URL prefix. Attachments default to 5 MiB. */
|
|
5
|
+
maxBytes?: number;
|
|
6
|
+
maxRawBytes?: number;
|
|
7
|
+
/** Image input tokens, never the model's output limit. Omitted deliberately for user attachments. */
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
tokenToBase64CharRatio?: number;
|
|
10
|
+
/** Optional stricter starting quality; the default ladder is 80, 60, 40, 20. */
|
|
11
|
+
jpegQuality?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ResizedImage {
|
|
14
|
+
data: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
originalWidth: number;
|
|
17
|
+
originalHeight: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
wasResized: boolean;
|
|
21
|
+
originalMimeType?: string;
|
|
22
|
+
animated?: boolean;
|
|
23
|
+
strategy: "original" | "png-optimized" | "preserve-format" | "resized" | "jpeg-quality" | "jpeg-fallback";
|
|
24
|
+
}
|
|
25
|
+
/** First fitting candidate wins. Compression can reach quality 20 / 200px: small text may be unreadable. */
|
|
26
|
+
export declare function resizeImageInProcess(inputBytes: Uint8Array, mimeType: string, options?: ImageResizeOptions, autoResizeImages?: boolean): Promise<ResizedImage>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Sharp } from "sharp";
|
|
2
|
+
export declare function imageFormat(bytes: Uint8Array): string | undefined;
|
|
3
|
+
/** Decode the first frame with the same pixel guard for attachments and the read tool. */
|
|
4
|
+
export declare function openImage(bytes: Uint8Array): Promise<{
|
|
5
|
+
pipeline: Sharp;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
orientation: number;
|
|
10
|
+
animated: boolean;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PathInputOptions {
|
|
2
|
+
/** Trim leading/trailing whitespace before normalization. */
|
|
3
|
+
trim?: boolean;
|
|
4
|
+
/** Expand leading `~` to a home directory. Defaults to true. */
|
|
5
|
+
expandTilde?: boolean;
|
|
6
|
+
/** Home directory used for `~` expansion. Defaults to `os.homedir()`. */
|
|
7
|
+
homeDir?: string;
|
|
8
|
+
/** Strip a leading `@`, used for CLI @file paths. */
|
|
9
|
+
stripAtPrefix?: boolean;
|
|
10
|
+
/** Normalize unicode space variants to regular spaces. */
|
|
11
|
+
normalizeUnicodeSpaces?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Convert Git Bash, MSYS, Cygwin, and WSL drive paths to a form native Windows APIs accept. */
|
|
14
|
+
export declare function normalizeWindowsShellPath(filePath: string): string;
|
|
15
|
+
export declare function normalizePath(input: string, options?: PathInputOptions): string;
|
|
16
|
+
export declare function resolvePath(input: string, baseDir?: string, options?: PathInputOptions): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ShellConfig {
|
|
2
|
+
shell: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
commandTransport?: "argv" | "stdin";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Resolve shell configuration based on platform and an optional explicit shell path.
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. User-specified shellPath
|
|
10
|
+
* 2. On Windows: Git Bash in known locations, then bash on PATH
|
|
11
|
+
* 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh
|
|
12
|
+
*/
|
|
13
|
+
export declare function getShellConfig(customShellPath?: string): ShellConfig;
|
|
14
|
+
export declare function getShellEnv(): NodeJS.ProcessEnv;
|
|
15
|
+
/**
|
|
16
|
+
* Kill a process and all its children (cross-platform)
|
|
17
|
+
*/
|
|
18
|
+
export declare function killProcessTree(pid: number): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { ToolContext } from "../../types.js";
|
|
3
|
+
import type { FileReadState } from "./file-read-state.js";
|
|
4
|
+
export declare const writeToolSystemPromptContribution: {
|
|
5
|
+
readonly snippet: "Create or overwrite files";
|
|
6
|
+
readonly guidelines: readonly ["Use write only for new files or complete rewrites."];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Pluggable operations for the write tool.
|
|
10
|
+
* Override these to delegate file writing to remote systems (for example SSH).
|
|
11
|
+
*/
|
|
12
|
+
export interface WriteOperations {
|
|
13
|
+
/** Write content to a file */
|
|
14
|
+
writeFile: (absolutePath: string, content: string) => Promise<void>;
|
|
15
|
+
/** Create directory recursively */
|
|
16
|
+
mkdir: (dir: string) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface WriteToolOptions {
|
|
19
|
+
/** Shared knowledge of file contents in the current model context. */
|
|
20
|
+
fileReadState?: FileReadState;
|
|
21
|
+
/** Custom operations for file writing. Default: local filesystem */
|
|
22
|
+
operations?: WriteOperations;
|
|
23
|
+
}
|
|
24
|
+
export declare function createWriteToolDefinition(cwd: string, options?: WriteToolOptions): {
|
|
25
|
+
name: string;
|
|
26
|
+
label: string;
|
|
27
|
+
description: string;
|
|
28
|
+
promptSnippet: "Create or overwrite files";
|
|
29
|
+
promptGuidelines: "Use write only for new files or complete rewrites."[];
|
|
30
|
+
parameters: Type.TObject<{
|
|
31
|
+
path: Type.TString;
|
|
32
|
+
content: Type.TString;
|
|
33
|
+
}>;
|
|
34
|
+
execute(_toolCallId: string, { path, content }: {
|
|
35
|
+
path: string;
|
|
36
|
+
content: string;
|
|
37
|
+
}, signal?: AbortSignal, _onUpdate?: import("../../../../../agent/src/index.js").AgentToolUpdateCallback<undefined> | undefined, ctx?: Partial<ToolContext>): Promise<{
|
|
38
|
+
content: {
|
|
39
|
+
type: "text";
|
|
40
|
+
text: string;
|
|
41
|
+
}[];
|
|
42
|
+
details: undefined;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../../../agent/src/index.js";
|
|
2
|
+
import type { Message } from "../../../ai/src/index.js";
|
|
3
|
+
import type { SessionEntry, SessionHeader } from "./session-manager.js";
|
|
4
|
+
/** A fixed generation and inclusive sequence watermark. Sequences start at 1. */
|
|
5
|
+
export interface TranscriptSnapshot {
|
|
6
|
+
generation: string;
|
|
7
|
+
endSeq: number;
|
|
8
|
+
}
|
|
9
|
+
export interface IndexedSessionEntry {
|
|
10
|
+
seq: number;
|
|
11
|
+
entry: SessionEntry;
|
|
12
|
+
}
|
|
13
|
+
export interface TranscriptState {
|
|
14
|
+
model: {
|
|
15
|
+
provider: string;
|
|
16
|
+
modelId: string;
|
|
17
|
+
} | null;
|
|
18
|
+
thinkingLevel: ThinkingLevel;
|
|
19
|
+
lastThinkingLevel: ThinkingLevel;
|
|
20
|
+
hasThinkingEntry: boolean;
|
|
21
|
+
lastMessageSeq: number;
|
|
22
|
+
lastCompactionSeq: number;
|
|
23
|
+
name?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TranscriptContextPlan {
|
|
26
|
+
snapshot: TranscriptSnapshot;
|
|
27
|
+
/** Latest compaction at the snapshot watermark, if any. */
|
|
28
|
+
compaction?: IndexedSessionEntry;
|
|
29
|
+
/** Inclusive sequence of first retained entry; 1 when there is no compaction. */
|
|
30
|
+
firstKeptSeq: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* SDK-neutral, indexed transcript access. Implementations own all writes and recovery.
|
|
34
|
+
* Readers MUST honor the snapshot generation and watermark, rejecting stale generations.
|
|
35
|
+
* Ranges are inclusive, ordered, lazy iterators; no implicit whole-transcript materialization.
|
|
36
|
+
* Append must durably persist the record before publishing its index/watermark.
|
|
37
|
+
*/
|
|
38
|
+
export interface TranscriptStore {
|
|
39
|
+
getHeader(): SessionHeader;
|
|
40
|
+
getFile(): string | undefined;
|
|
41
|
+
snapshot(): TranscriptSnapshot;
|
|
42
|
+
getStateAt(snapshot: TranscriptSnapshot): TranscriptState;
|
|
43
|
+
getTail(snapshot: TranscriptSnapshot): IndexedSessionEntry | undefined;
|
|
44
|
+
readEntryById(id: string, snapshot: TranscriptSnapshot): IndexedSessionEntry | undefined;
|
|
45
|
+
readRange(startSeq: number, endSeq: number, snapshot: TranscriptSnapshot, types?: readonly SessionEntry["type"][]): Iterable<IndexedSessionEntry>;
|
|
46
|
+
getContextPlan(snapshot: TranscriptSnapshot): TranscriptContextPlan;
|
|
47
|
+
/** Each group contains only an unresolved journal's updates, anchor and canonical turn. */
|
|
48
|
+
readUnresolvedToolJournals(snapshot: TranscriptSnapshot): Iterable<SessionEntry[]>;
|
|
49
|
+
append(entry: SessionEntry): void;
|
|
50
|
+
/** Optional asynchronous persistence; completion has the same durability/publication contract. */
|
|
51
|
+
appendAsync?(entry: SessionEntry): Promise<void>;
|
|
52
|
+
/** Implementations stage a fresh generation; preserve the old one on any failure. */
|
|
53
|
+
replace(header: SessionHeader, entries: Iterable<SessionEntry>): void;
|
|
54
|
+
replaceAsync?(header: SessionHeader, entries: Iterable<SessionEntry>, options?: {
|
|
55
|
+
remapIds?: boolean;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export interface MessageProvenance {
|
|
59
|
+
entryId: string;
|
|
60
|
+
seq: number;
|
|
61
|
+
kind: "message" | "compaction-system" | "compaction-summary";
|
|
62
|
+
}
|
|
63
|
+
export declare function setMessageProvenance(message: Message, source: MessageProvenance): void;
|
|
64
|
+
export declare function getMessageProvenance(message: Message): MessageProvenance | undefined;
|
|
65
|
+
/** Current product choices are separate from historical transcript checkpoints. */
|
|
66
|
+
export interface SessionCurrentState {
|
|
67
|
+
get(): Pick<TranscriptState, "model" | "thinkingLevel" | "lastThinkingLevel" | "name">;
|
|
68
|
+
setModel(provider: string, modelId: string): void;
|
|
69
|
+
setThinkingLevel(level: ThinkingLevel): void;
|
|
70
|
+
setName(name: string): void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolResult, AgentToolUpdateCallback, ThinkingLevel } from "../../../agent/src/index.js";
|
|
2
|
+
import type { JsonValue, Model } from "../../../ai/src/index.js";
|
|
3
|
+
import type { Static, TSchema } from "typebox";
|
|
4
|
+
import type { LoadedSkill, SkillList } from "./resources.js";
|
|
5
|
+
import type { SessionManager } from "./session-manager.js";
|
|
6
|
+
import type { ImageResizeOptions } from "./tools/pi/utils/image-resize-core.js";
|
|
7
|
+
/** Resource discovery is separate from explicit customInstructions. */
|
|
8
|
+
export interface ResourceLoader {
|
|
9
|
+
getBaseInstructions?(): string | undefined;
|
|
10
|
+
getInstructions?(): readonly string[];
|
|
11
|
+
reload?(): Promise<void>;
|
|
12
|
+
listSkills?(): SkillList;
|
|
13
|
+
loadSkill?(name: string): Promise<LoadedSkill>;
|
|
14
|
+
getDiagnostics?(): ResourceDiagnostic[];
|
|
15
|
+
}
|
|
16
|
+
export interface ResourceDiagnostic {
|
|
17
|
+
path: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function resourceInstructions(loader?: ResourceLoader): readonly string[];
|
|
21
|
+
export declare function resourceBaseInstructions(loader?: ResourceLoader): string | undefined;
|
|
22
|
+
export declare class StaticResourceLoader implements ResourceLoader {
|
|
23
|
+
private baseInstructions?;
|
|
24
|
+
private instructions;
|
|
25
|
+
constructor(options?: {
|
|
26
|
+
baseInstructions?: string;
|
|
27
|
+
instructions?: readonly string[];
|
|
28
|
+
});
|
|
29
|
+
getBaseInstructions(): string | undefined;
|
|
30
|
+
getInstructions(): string[];
|
|
31
|
+
}
|
|
32
|
+
/** Session context supplied to custom tools and built-in overrides. */
|
|
33
|
+
export interface ToolContext {
|
|
34
|
+
cwd: string;
|
|
35
|
+
model: Model & {
|
|
36
|
+
inputLimits?: {
|
|
37
|
+
images?: {
|
|
38
|
+
resize?: ImageResizeOptions;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
sessionManager: SessionManager;
|
|
43
|
+
thinkingLevel?: ThinkingLevel;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
isIdle(): boolean;
|
|
46
|
+
getSystemPrompt(): string;
|
|
47
|
+
getToolNames?(): string[];
|
|
48
|
+
}
|
|
49
|
+
export interface ToolDefinition<TParameters extends TSchema = TSchema, TDetails = JsonValue | undefined, TContext = ToolContext> extends Pick<AgentTool, "executionMode" | "metadata" | "permission" | "requiresUserInteraction"> {
|
|
50
|
+
name: string;
|
|
51
|
+
label: string;
|
|
52
|
+
description: string;
|
|
53
|
+
parameters: TParameters;
|
|
54
|
+
promptSnippet?: string;
|
|
55
|
+
promptGuidelines?: string[];
|
|
56
|
+
/** Optional result schema metadata; tool results retain their existing runtime validation. */
|
|
57
|
+
outputSchema?: TSchema;
|
|
58
|
+
prepareArguments?: (args: unknown) => Static<TParameters>;
|
|
59
|
+
execute(toolCallId: string, params: Static<TParameters>, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<TDetails> | undefined, context: TContext): Promise<AgentToolResult<TDetails>>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type { AgentSessionEvent, InputContext } from "./core/agent-session.js";
|
|
2
|
+
export { AgentSession } from "./core/agent-session.js";
|
|
3
|
+
export type { ParsedInput } from "./core/commands.js";
|
|
4
|
+
export { listCommands, parseInput } from "./core/commands.js";
|
|
5
|
+
export type { CompactionOptions } from "./core/compaction.js";
|
|
6
|
+
export { applyFileRewind, type FileRewindConflict, type FileRewindOptions, type FileRewindPlan, planFileRewind, } from "./core/file-rewind.js";
|
|
7
|
+
export { syncDirectory } from "./core/fs.js";
|
|
8
|
+
export * from "./core/image-limits.js";
|
|
9
|
+
export * from "./core/images.js";
|
|
10
|
+
export { type MarkdownFrontmatter, parseMarkdownFrontmatter } from "./core/markdown.js";
|
|
11
|
+
export * from "./core/mentions.js";
|
|
12
|
+
export type { ModelPerformance, ModelPerformanceTotals } from "./core/model-performance.js";
|
|
13
|
+
export { modelPerformance, SessionPerformance, validPerformanceTotals } from "./core/model-performance.js";
|
|
14
|
+
export type { MediaProjectionContext, ModelRuntimeOptions, ProviderChatModelConfig, ProviderConfigInput, } from "./core/model-runtime.js";
|
|
15
|
+
export { ModelRuntime } from "./core/model-runtime.js";
|
|
16
|
+
export { readFileBounded } from "./core/read-file-bounded.js";
|
|
17
|
+
export { isSessionEntry, isSessionHeader, maxSessionEntryBytes } from "./core/record-validation.js";
|
|
18
|
+
export type { DiscoveredSkill, LoadedSkill, SkillList, SkillMetadata } from "./core/resources.js";
|
|
19
|
+
export { FileResourceLoader, SkillCatalog } from "./core/resources.js";
|
|
20
|
+
export type { CreateAgentSessionOptions, CreateAgentSessionResult } from "./core/sdk.js";
|
|
21
|
+
export { createAgentSession } from "./core/sdk.js";
|
|
22
|
+
export type { SessionContext, SessionEntry, SessionHeader } from "./core/session-manager.js";
|
|
23
|
+
export { SessionManager } from "./core/session-manager.js";
|
|
24
|
+
export type { ContextUsage } from "./core/session-state.js";
|
|
25
|
+
export { contextUsage, supportedThinkingLevels } from "./core/session-state.js";
|
|
26
|
+
export type { ProviderRetrySettings, RetrySettings, Settings } from "./core/settings-manager.js";
|
|
27
|
+
export { SettingsManager } from "./core/settings-manager.js";
|
|
28
|
+
export { projectStreamedToolJournal } from "./core/streaming-tool-journal.js";
|
|
29
|
+
export * from "./core/system-prompt.js";
|
|
30
|
+
export * from "./core/tools/file-change.js";
|
|
31
|
+
export type { BashToolOptions, EditToolOptions, ReadToolOptions, ToolContextFactory, WriteToolOptions, } from "./core/tools/index.js";
|
|
32
|
+
export { createBashTool, createBashToolDefinition, createCodingTools, createEditTool, createEditToolDefinition, createLocalBashOperations, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, FileReadState, } from "./core/tools/index.js";
|
|
33
|
+
export { getShellConfig, getShellEnv, killProcessTree } from "./core/tools/pi/utils/shell.js";
|
|
34
|
+
export * from "./core/transcript-store.js";
|
|
35
|
+
export type { ResourceDiagnostic, ResourceLoader, ToolContext, ToolDefinition, } from "./core/types.js";
|
|
36
|
+
export { StaticResourceLoader } from "./core/types.js";
|
|
37
|
+
export type { SessionContributions } from "./plugins/assembly.js";
|
|
38
|
+
export { assembleSession, expandPluginCommand, pluginSnapshotData, snapshotPlugins, validatePluginSnapshot, } from "./plugins/assembly.js";
|
|
39
|
+
export type { HookEvent, HookExecution, HookInput, HookInvocation, HookOutput, HookRegistration, } from "./plugins/hooks.js";
|
|
40
|
+
export { HookRunner, hookEvents } from "./plugins/hooks.js";
|
|
41
|
+
export { withPluginResources } from "./plugins/resources.js";
|
|
42
|
+
export type { PluginCommand, PluginMetadata, PluginSkill, PluginSnapshot, SessionPlugin, } from "./plugins/types.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AgentTool } from "../../../agent/src/index.js";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
3
|
+
import type { ToolContext, ToolDefinition } from "../core/types.js";
|
|
4
|
+
import type { PluginCommand, PluginSnapshot, SessionPlugin } from "./types.js";
|
|
5
|
+
export interface SessionContributions {
|
|
6
|
+
plugins?: readonly SessionPlugin[];
|
|
7
|
+
customTools?: readonly ToolDefinition<TSchema, unknown>[];
|
|
8
|
+
toolOverrides?: readonly ToolDefinition<TSchema, unknown>[];
|
|
9
|
+
noTools?: "all" | "builtin";
|
|
10
|
+
tools?: readonly string[];
|
|
11
|
+
excludeTools?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function validatePluginSnapshot(value: unknown): asserts value is PluginSnapshot;
|
|
14
|
+
/** Serializable field projection; snapshotPlugins also validates and copies the data. */
|
|
15
|
+
export declare function pluginSnapshotData(plugin: PluginSnapshot): PluginSnapshot;
|
|
16
|
+
export declare function snapshotPlugins(plugins: readonly SessionPlugin[]): PluginSnapshot[];
|
|
17
|
+
/** Pure assembly: validate contributions and select tools without executing plugin code. */
|
|
18
|
+
export declare function assembleSession(options: SessionContributions & {
|
|
19
|
+
builtinTools: readonly AgentTool[];
|
|
20
|
+
context?: (signal?: AbortSignal) => ToolContext;
|
|
21
|
+
}): {
|
|
22
|
+
allTools: AgentTool<TSchema, import("../../../ai/src/index.js").JsonValue | undefined>[];
|
|
23
|
+
activeTools: AgentTool<TSchema, import("../../../ai/src/index.js").JsonValue | undefined>[];
|
|
24
|
+
commands: PluginCommand[];
|
|
25
|
+
skills: import("./types.js").PluginSkill[];
|
|
26
|
+
instructions: string[];
|
|
27
|
+
getInstructions: () => any[];
|
|
28
|
+
hooks: {
|
|
29
|
+
event: import("./hooks.js").HookEvent;
|
|
30
|
+
matcher?: string;
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
onError?: "continue" | "block";
|
|
33
|
+
handler(input: import("./hooks.js").HookInput, signal: AbortSignal): import("./hooks.js").HookOutput | undefined | Promise<import("./hooks.js").HookOutput | undefined>;
|
|
34
|
+
pluginId: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
export declare function expandPluginCommand(command: PluginCommand, args: string, cwd: string): string;
|