@zpi-dev/agent-sdk 0.0.0-stage → 0.1.61
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-GPIEWH3K.js +24368 -0
- package/dist/chunk-GPIEWH3K.js.map +1 -0
- package/dist/chunk-YPFTXFZL.js +29655 -0
- package/dist/chunk-YPFTXFZL.js.map +1 -0
- package/dist/host.d.ts +1 -0
- package/dist/host.js +32 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/src-GYA4LFM7.js +126 -0
- package/dist/src-GYA4LFM7.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 +395 -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 +5 -0
- package/dist/types/ai/src/utils/transcript.d.ts +28 -0
- package/dist/types/coding-agent/src/core/agent-session.d.ts +175 -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/dynamic-context.d.ts +3 -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 +48 -0
- package/dist/types/coding-agent/src/core/session-manager.d.ts +138 -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 +32 -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 +36 -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 +41 -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,138 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../../../agent/src/index.js";
|
|
2
|
+
import type { JsonValue, Message, SystemMessage, Usage } from "../../../ai/src/index.js";
|
|
3
|
+
import type { SessionCurrentState, TranscriptSnapshot, TranscriptState, TranscriptStore } from "./transcript-store.js";
|
|
4
|
+
export interface SessionHeader {
|
|
5
|
+
type: "session";
|
|
6
|
+
version: 1 | 2;
|
|
7
|
+
format: "zpi";
|
|
8
|
+
id: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
cwd: string;
|
|
11
|
+
}
|
|
12
|
+
interface EntryBase {
|
|
13
|
+
id: string;
|
|
14
|
+
parentId: string | null;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}
|
|
17
|
+
export type SessionEntry = EntryBase & ({
|
|
18
|
+
type: "message";
|
|
19
|
+
message: Message;
|
|
20
|
+
} | {
|
|
21
|
+
type: "model_change";
|
|
22
|
+
provider: string;
|
|
23
|
+
modelId: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "thinking_level_change";
|
|
26
|
+
thinkingLevel: ThinkingLevel;
|
|
27
|
+
} | {
|
|
28
|
+
type: "session_info";
|
|
29
|
+
name: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "custom";
|
|
32
|
+
customType: string;
|
|
33
|
+
data?: JsonValue;
|
|
34
|
+
} | {
|
|
35
|
+
type: "microcompact";
|
|
36
|
+
data: import("./microcompact.js").MicrocompactBoundary;
|
|
37
|
+
} | {
|
|
38
|
+
type: "compaction";
|
|
39
|
+
summary: string;
|
|
40
|
+
firstKeptEntryId: string;
|
|
41
|
+
tokensBefore?: number;
|
|
42
|
+
details?: {
|
|
43
|
+
readFiles: string[];
|
|
44
|
+
modifiedFiles: string[];
|
|
45
|
+
};
|
|
46
|
+
usage?: Usage;
|
|
47
|
+
systemMessage?: SystemMessage;
|
|
48
|
+
contextMessage?: SystemMessage;
|
|
49
|
+
});
|
|
50
|
+
export interface SessionContext {
|
|
51
|
+
messages: Message[];
|
|
52
|
+
thinkingLevel: ThinkingLevel;
|
|
53
|
+
model: {
|
|
54
|
+
provider: string;
|
|
55
|
+
modelId: string;
|
|
56
|
+
} | null;
|
|
57
|
+
lastThinkingLevel: ThinkingLevel;
|
|
58
|
+
}
|
|
59
|
+
export type SessionEntryInput = SessionEntry extends infer Entry ? Entry extends SessionEntry ? Omit<Entry, keyof EntryBase> : never : never;
|
|
60
|
+
export declare class SessionManager {
|
|
61
|
+
private header;
|
|
62
|
+
private store?;
|
|
63
|
+
private currentState?;
|
|
64
|
+
private contextCache?;
|
|
65
|
+
private entries;
|
|
66
|
+
private file?;
|
|
67
|
+
private storageError?;
|
|
68
|
+
private appendQueue;
|
|
69
|
+
private lastEntry?;
|
|
70
|
+
private appendListeners;
|
|
71
|
+
subscribeEntries(listener: (entry: SessionEntry) => void): () => void;
|
|
72
|
+
private constructor();
|
|
73
|
+
/** Open an already validated indexed store without reading historical message bodies. */
|
|
74
|
+
static fromStore(store: TranscriptStore, currentState?: SessionCurrentState): SessionManager;
|
|
75
|
+
static openAsync(store: TranscriptStore, currentState?: SessionCurrentState): Promise<SessionManager>;
|
|
76
|
+
hasCurrentState(): boolean;
|
|
77
|
+
getCurrentState(): Pick<TranscriptState, "model" | "thinkingLevel" | "lastThinkingLevel" | "name">;
|
|
78
|
+
getStateAt(snapshot?: TranscriptSnapshot): TranscriptState;
|
|
79
|
+
iterateEntries(): Iterable<SessionEntry>;
|
|
80
|
+
readEntryById(id: string): SessionEntry | undefined;
|
|
81
|
+
unresolvedToolJournals(): Iterable<SessionEntry[]>;
|
|
82
|
+
/** Only effective retained entries, suitable for compaction and current usage. */
|
|
83
|
+
getContextEntries(): SessionEntry[];
|
|
84
|
+
precedesCompaction(message: Message): boolean;
|
|
85
|
+
materializeContext(snapshot?: TranscriptSnapshot): Promise<SessionContext>;
|
|
86
|
+
static create(cwd: string, sessionDir?: string, options?: {
|
|
87
|
+
id?: string;
|
|
88
|
+
}): SessionManager;
|
|
89
|
+
static inMemory(cwd?: string, options?: {
|
|
90
|
+
id?: string;
|
|
91
|
+
}, entries?: SessionEntry[]): SessionManager;
|
|
92
|
+
static open(path: string, _sessionDir?: string, cwdOverride?: string): SessionManager;
|
|
93
|
+
getSessionId(): string;
|
|
94
|
+
getSessionFile(): string | undefined;
|
|
95
|
+
getCwd(): string;
|
|
96
|
+
/** Move a draft into its worktree before any model messages are committed. */
|
|
97
|
+
setCwd(cwd: string): void;
|
|
98
|
+
getEntries(): SessionEntry[];
|
|
99
|
+
getLastEntry(): SessionEntry | undefined;
|
|
100
|
+
/** Serialize durable appends, including concurrently finishing tools, before notifying readers. */
|
|
101
|
+
appendEntryAsync(fields: SessionEntryInput): Promise<string>;
|
|
102
|
+
private enqueueWrite;
|
|
103
|
+
private persistEntry;
|
|
104
|
+
flushAsync(): Promise<void>;
|
|
105
|
+
appendMessageAsync(message: Message): Promise<string>;
|
|
106
|
+
appendCustomEntryAsync(customType: string, data?: JsonValue): Promise<string>;
|
|
107
|
+
setCwdAsync(cwd: string): Promise<void>;
|
|
108
|
+
replaceEntriesAsync(source: Iterable<SessionEntry>): Promise<void>;
|
|
109
|
+
/** Atomically replace a transcript after a stable fork or conversation rewind. */
|
|
110
|
+
replaceEntries(source: Iterable<SessionEntry>): void;
|
|
111
|
+
private writeTranscript;
|
|
112
|
+
getMicrocompactClearedIds(): string[];
|
|
113
|
+
buildSessionContext(snapshot?: TranscriptSnapshot): SessionContext;
|
|
114
|
+
appendMessage(message: Message): string;
|
|
115
|
+
appendModelChange(provider: string, modelId: string): string;
|
|
116
|
+
appendThinkingLevelChange(thinkingLevel: ThinkingLevel): string;
|
|
117
|
+
appendSessionInfo(name: string): string;
|
|
118
|
+
appendMicrocompact(data: import("./microcompact.js").MicrocompactBoundary): string;
|
|
119
|
+
appendCustomEntry(customType: string, data?: JsonValue): string;
|
|
120
|
+
appendCompaction(summary: string, firstKeptEntryId: string, tokensBefore?: number, details?: {
|
|
121
|
+
readFiles: string[];
|
|
122
|
+
modifiedFiles: string[];
|
|
123
|
+
}, usage?: Usage): string;
|
|
124
|
+
appendCompactionAsync(...args: Parameters<SessionManager["appendCompaction"]>): Promise<string>;
|
|
125
|
+
private compactionInput;
|
|
126
|
+
private createEntry;
|
|
127
|
+
private publishEntry;
|
|
128
|
+
private append;
|
|
129
|
+
}
|
|
130
|
+
export type CompactionEntry = Extract<SessionEntry, {
|
|
131
|
+
type: "compaction";
|
|
132
|
+
}>;
|
|
133
|
+
/** Entries are append-only. Like Pi, context projection shares immutable message records. */
|
|
134
|
+
export declare function sessionEntryToContextMessages(entry: SessionEntry): Message[];
|
|
135
|
+
export declare function buildSessionContext(entries: SessionEntry[]): SessionContext;
|
|
136
|
+
/** Stream ID remapping without retaining the whole transcript. */
|
|
137
|
+
export declare function remapSessionEntries(source: Iterable<SessionEntry>): Iterable<SessionEntry>;
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../../../agent/src/index.js";
|
|
2
|
+
import type { ContextBreakdownItem, Model } from "../../../ai/src/index.js";
|
|
3
|
+
import type { SessionEntry } from "./session-manager.js";
|
|
4
|
+
export interface ContextUsage {
|
|
5
|
+
contextWindow: number;
|
|
6
|
+
inputTokens: number | null;
|
|
7
|
+
percent: number | null;
|
|
8
|
+
timestamp: number | null;
|
|
9
|
+
source: "server usage" | "unknown";
|
|
10
|
+
breakdown?: ContextBreakdownItem[];
|
|
11
|
+
averageCacheHitRate?: number | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function contextUsage(entries: SessionEntry[], model: Model): ContextUsage;
|
|
14
|
+
export declare function supportedThinkingLevels(model: Model): ThinkingLevel[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../../../agent/src/index.js";
|
|
2
|
+
import { type Model, type RetryPolicy } from "../../../ai/src/index.js";
|
|
3
|
+
import { type CompactionOptions, type CompactionSettings } from "./compaction.js";
|
|
4
|
+
export interface ProviderRetrySettings {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
maxRetryDelayMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RetrySettings extends Partial<RetryPolicy> {
|
|
10
|
+
provider?: ProviderRetrySettings;
|
|
11
|
+
}
|
|
12
|
+
export interface Settings {
|
|
13
|
+
defaultThinkingLevel?: ThinkingLevel;
|
|
14
|
+
modelThinkingLevels?: Record<string, ThinkingLevel>;
|
|
15
|
+
compaction?: CompactionOptions;
|
|
16
|
+
retry?: RetrySettings;
|
|
17
|
+
httpIdleTimeoutMs?: number | string;
|
|
18
|
+
streamIdleTimeoutMs?: number;
|
|
19
|
+
streamFirstResponseTimeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class SettingsManager {
|
|
22
|
+
private settings;
|
|
23
|
+
private errors;
|
|
24
|
+
constructor(settings?: Settings);
|
|
25
|
+
static inMemory(settings?: Settings): SettingsManager;
|
|
26
|
+
static create(cwd?: string, agentDir?: string): SettingsManager;
|
|
27
|
+
getErrors(): {
|
|
28
|
+
path: string;
|
|
29
|
+
error: Error;
|
|
30
|
+
}[];
|
|
31
|
+
applyOverrides(overrides: Settings): void;
|
|
32
|
+
getDefaultThinkingLevel(): ThinkingLevel | undefined;
|
|
33
|
+
getModelThinkingLevel(provider: string, id: string): ThinkingLevel | undefined;
|
|
34
|
+
getCompactionSettings(model?: Pick<Model, "provider" | "id">): CompactionSettings;
|
|
35
|
+
getMicrocompactSettings(): import("./microcompact.js").MicrocompactConfig;
|
|
36
|
+
getRetrySettings(): RetryPolicy;
|
|
37
|
+
getProviderRetrySettings(): ProviderRetrySettings;
|
|
38
|
+
getStreamIdleTimeoutMs(): number;
|
|
39
|
+
getStreamFirstResponseTimeoutMs(): number;
|
|
40
|
+
getHttpIdleTimeoutMs(): number;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AgentEvent } from "../../../agent/src/index.js";
|
|
2
|
+
import type { Message } from "../../../ai/src/index.js";
|
|
3
|
+
import type { SessionEntry, SessionManager } from "./session-manager.js";
|
|
4
|
+
/** Calls are durable before execute; results are durable before the batch settles. */
|
|
5
|
+
export declare class StreamingToolJournal {
|
|
6
|
+
private partial?;
|
|
7
|
+
private journal?;
|
|
8
|
+
private manager;
|
|
9
|
+
private notify;
|
|
10
|
+
constructor(manager: SessionManager, notify: () => void);
|
|
11
|
+
private save;
|
|
12
|
+
observe(event: AgentEvent): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function recoverStreamedToolJournal(manager: SessionManager): void;
|
|
15
|
+
/** History rendering also works before the writable SDK session is opened. */
|
|
16
|
+
export declare function projectStreamedToolJournal(entries: SessionEntry[]): SessionEntry[];
|
|
17
|
+
export declare function recoverCanonicalToolCallsAsync(manager: SessionManager, messages: Message[]): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentTool } from "../../../agent/src/index.js";
|
|
2
|
+
import { type ResourceLoader } from "./types.js";
|
|
3
|
+
export interface PromptTemplate {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
preamble: string;
|
|
7
|
+
rules: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const piTemplate: PromptTemplate;
|
|
10
|
+
export declare function validateTemplate(template: PromptTemplate): void;
|
|
11
|
+
export declare function renderTemplate(text: string, context: {
|
|
12
|
+
cwd: string;
|
|
13
|
+
project_name: string;
|
|
14
|
+
platform: string;
|
|
15
|
+
}): string;
|
|
16
|
+
export interface SystemContext {
|
|
17
|
+
base: string;
|
|
18
|
+
sections: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildSystemContext(options: {
|
|
21
|
+
cwd: string;
|
|
22
|
+
projectName?: string;
|
|
23
|
+
platform?: string;
|
|
24
|
+
template?: PromptTemplate;
|
|
25
|
+
tools: readonly Pick<AgentTool, "name" | "description" | "promptSnippet" | "promptGuidelines">[];
|
|
26
|
+
loader?: ResourceLoader;
|
|
27
|
+
/** Literal instructions appended after resources, before the skill catalog and working directory. */
|
|
28
|
+
customInstructions?: readonly string[];
|
|
29
|
+
baseInstructions?: string;
|
|
30
|
+
}): SystemContext;
|
|
31
|
+
/** Human-readable preview; model requests use the independently managed blocks. */
|
|
32
|
+
export declare function buildSystemPrompt(options: Parameters<typeof buildSystemContext>[0]): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface FileChange {
|
|
2
|
+
path: string;
|
|
3
|
+
operation: "created" | "modified";
|
|
4
|
+
toolCallId: string;
|
|
5
|
+
beforeHash: string | null;
|
|
6
|
+
afterHash: string;
|
|
7
|
+
patch?: string;
|
|
8
|
+
patchFile?: string;
|
|
9
|
+
beforeFile?: string;
|
|
10
|
+
afterFile?: string;
|
|
11
|
+
reason?: string;
|
|
12
|
+
failed?: boolean;
|
|
13
|
+
additions?: number;
|
|
14
|
+
deletions?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function beforeFile(path: string): Promise<Buffer | null>;
|
|
17
|
+
export declare function recordFileChange(path: string, toolCallId: string, before: Buffer | null, outputDir?: string, failed?: boolean): Promise<FileChange | undefined>;
|
|
18
|
+
export declare function patchLineCounts(patch: string): {
|
|
19
|
+
additions: number;
|
|
20
|
+
deletions: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentTool } from "../../../../agent/src/index.js";
|
|
2
|
+
import type { Model } from "../../../../ai/src/index.js";
|
|
3
|
+
import type { ToolContext } from "../types.js";
|
|
4
|
+
import { type BashToolOptions } from "./pi/bash.js";
|
|
5
|
+
import { type EditToolOptions } from "./pi/edit.js";
|
|
6
|
+
import { FileReadState } from "./pi/file-read-state.js";
|
|
7
|
+
import { type ReadToolOptions } from "./pi/read.js";
|
|
8
|
+
import { type WriteToolOptions } from "./pi/write.js";
|
|
9
|
+
export { createBashToolDefinition, createLocalBashOperations } from "./pi/bash.js";
|
|
10
|
+
export { createEditToolDefinition } from "./pi/edit.js";
|
|
11
|
+
export { FileReadState } from "./pi/file-read-state.js";
|
|
12
|
+
export { createReadToolDefinition } from "./pi/read.js";
|
|
13
|
+
export { createWriteToolDefinition } from "./pi/write.js";
|
|
14
|
+
export type { BashToolOptions, EditToolOptions, ReadToolOptions, WriteToolOptions };
|
|
15
|
+
export type ToolContextFactory = () => Partial<ToolContext> | undefined;
|
|
16
|
+
export declare function createReadTool(cwd: string, options?: ReadToolOptions | (() => Model), context?: ToolContextFactory): AgentTool;
|
|
17
|
+
export declare function createBashTool(cwd: string, options?: BashToolOptions, context?: ToolContextFactory): AgentTool;
|
|
18
|
+
export declare function createWriteTool(cwd: string, options?: WriteToolOptions | string, context?: ToolContextFactory): AgentTool;
|
|
19
|
+
export declare function createEditTool(cwd: string, options?: EditToolOptions | string, context?: ToolContextFactory): AgentTool;
|
|
20
|
+
export declare function createCodingTools(cwd: string, outputDir?: string, getModel?: () => Model, context?: ToolContextFactory, fileReadState?: FileReadState): AgentTool[];
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import type { ToolContext } from "../../types.js";
|
|
3
|
+
import { type TruncationResult } from "./truncate.js";
|
|
4
|
+
import { type ShellConfig } from "./utils/shell.js";
|
|
5
|
+
export declare const bashToolSystemPromptContribution: {
|
|
6
|
+
readonly snippet: "Execute bash commands (ls, grep, find, etc.)";
|
|
7
|
+
readonly guidelines: readonly ["You can inspect ZPI_* environment variables for current model and session details."];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.
|
|
11
|
+
* `output` is not limited like the model-facing output: callers decide how much of it reaches the model.
|
|
12
|
+
*/
|
|
13
|
+
declare const bashOutputSchema: Type.TObject<{
|
|
14
|
+
output: Type.TString;
|
|
15
|
+
truncated: Type.TBoolean;
|
|
16
|
+
full_output_path: Type.TOptional<Type.TString>;
|
|
17
|
+
exit_code: Type.TNumber;
|
|
18
|
+
wall_time_seconds: Type.TNumber;
|
|
19
|
+
}>;
|
|
20
|
+
export type BashToolOutput = Static<typeof bashOutputSchema>;
|
|
21
|
+
export interface BashToolDetails {
|
|
22
|
+
truncation?: TruncationResult;
|
|
23
|
+
fullOutputPath?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Pluggable operations for the bash tool.
|
|
27
|
+
* Override these to delegate command execution to remote systems (for example SSH).
|
|
28
|
+
*/
|
|
29
|
+
export interface BashOperations {
|
|
30
|
+
/**
|
|
31
|
+
* Execute a command and stream output.
|
|
32
|
+
* @param command The command to execute
|
|
33
|
+
* @param cwd Working directory
|
|
34
|
+
* @param options Execution options
|
|
35
|
+
* @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;
|
|
36
|
+
* a null exit code is treated as a failed command.
|
|
37
|
+
*/
|
|
38
|
+
exec: (command: string, cwd: string, options: {
|
|
39
|
+
/**
|
|
40
|
+
* Await returned promises before delivering another chunk to bound pending output writes.
|
|
41
|
+
* Other return values are ignored, as with the original synchronous callback.
|
|
42
|
+
*/
|
|
43
|
+
onData: (data: Buffer, stream?: "stdout" | "stderr") => unknown;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
timeout?: number;
|
|
46
|
+
env?: NodeJS.ProcessEnv;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
exitCode: number | null;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
/** Shared process execution used by the built-in shell tools. */
|
|
52
|
+
export declare function createLocalShellOperations(shellName: string, resolveShellConfig: () => ShellConfig): BashOperations;
|
|
53
|
+
/**
|
|
54
|
+
* Create bash operations using the local shell execution backend.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createLocalBashOperations(options?: {
|
|
57
|
+
shellPath?: string;
|
|
58
|
+
}): BashOperations;
|
|
59
|
+
export interface BashSpawnContext {
|
|
60
|
+
command: string;
|
|
61
|
+
cwd: string;
|
|
62
|
+
env: NodeJS.ProcessEnv;
|
|
63
|
+
}
|
|
64
|
+
export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;
|
|
65
|
+
export interface BashToolOptions {
|
|
66
|
+
/** Custom operations for command execution. Default: local shell */
|
|
67
|
+
operations?: BashOperations;
|
|
68
|
+
/** Command prefix prepended to every command (for example shell setup commands) */
|
|
69
|
+
commandPrefix?: string;
|
|
70
|
+
/** Optional explicit shell path from settings */
|
|
71
|
+
shellPath?: string;
|
|
72
|
+
/** Expose current ZPI session metadata as ZPI_* environment variables. Default: true */
|
|
73
|
+
exposeSessionEnvironment?: boolean;
|
|
74
|
+
/** Hook to adjust command, cwd, or env before execution */
|
|
75
|
+
spawnHook?: BashSpawnHook;
|
|
76
|
+
}
|
|
77
|
+
export interface ShellToolConfig {
|
|
78
|
+
name: string;
|
|
79
|
+
label: string;
|
|
80
|
+
shellName: string;
|
|
81
|
+
promptSnippet: string;
|
|
82
|
+
promptGuidelines?: readonly string[];
|
|
83
|
+
tempFilePrefix: string;
|
|
84
|
+
}
|
|
85
|
+
export declare function createShellToolDefinition(cwd: string, config: ShellToolConfig, options?: BashToolOptions): {
|
|
86
|
+
name: string;
|
|
87
|
+
label: string;
|
|
88
|
+
description: string;
|
|
89
|
+
promptSnippet: string;
|
|
90
|
+
promptGuidelines: string[] | undefined;
|
|
91
|
+
parameters: Type.TObject<{
|
|
92
|
+
command: Type.TString;
|
|
93
|
+
timeout: Type.TOptional<Type.TNumber>;
|
|
94
|
+
}>;
|
|
95
|
+
outputSchema: Type.TObject<{
|
|
96
|
+
output: Type.TString;
|
|
97
|
+
truncated: Type.TBoolean;
|
|
98
|
+
full_output_path: Type.TOptional<Type.TString>;
|
|
99
|
+
exit_code: Type.TNumber;
|
|
100
|
+
wall_time_seconds: Type.TNumber;
|
|
101
|
+
}>;
|
|
102
|
+
execute(_toolCallId: string, { command, timeout }: {
|
|
103
|
+
command: string;
|
|
104
|
+
timeout?: number;
|
|
105
|
+
}, signal?: AbortSignal, onUpdate?: import("../../../../../agent/src/index.js").AgentToolUpdateCallback<BashToolDetails | undefined> | undefined, ctx?: Partial<ToolContext>): Promise<{
|
|
106
|
+
content: {
|
|
107
|
+
type: "text";
|
|
108
|
+
text: string;
|
|
109
|
+
}[];
|
|
110
|
+
details: BashToolDetails | undefined;
|
|
111
|
+
structuredContent: {
|
|
112
|
+
output: string;
|
|
113
|
+
truncated: boolean;
|
|
114
|
+
full_output_path?: string | undefined;
|
|
115
|
+
exit_code: number;
|
|
116
|
+
wall_time_seconds: number;
|
|
117
|
+
};
|
|
118
|
+
isError: true;
|
|
119
|
+
} | {
|
|
120
|
+
isError?: undefined;
|
|
121
|
+
content: {
|
|
122
|
+
type: "text";
|
|
123
|
+
text: string;
|
|
124
|
+
}[];
|
|
125
|
+
details: BashToolDetails | undefined;
|
|
126
|
+
structuredContent: {
|
|
127
|
+
output: string;
|
|
128
|
+
truncated: boolean;
|
|
129
|
+
full_output_path?: string | undefined;
|
|
130
|
+
exit_code: number;
|
|
131
|
+
wall_time_seconds: number;
|
|
132
|
+
};
|
|
133
|
+
}>;
|
|
134
|
+
};
|
|
135
|
+
export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): {
|
|
136
|
+
name: string;
|
|
137
|
+
label: string;
|
|
138
|
+
description: string;
|
|
139
|
+
promptSnippet: string;
|
|
140
|
+
promptGuidelines: string[] | undefined;
|
|
141
|
+
parameters: Type.TObject<{
|
|
142
|
+
command: Type.TString;
|
|
143
|
+
timeout: Type.TOptional<Type.TNumber>;
|
|
144
|
+
}>;
|
|
145
|
+
outputSchema: Type.TObject<{
|
|
146
|
+
output: Type.TString;
|
|
147
|
+
truncated: Type.TBoolean;
|
|
148
|
+
full_output_path: Type.TOptional<Type.TString>;
|
|
149
|
+
exit_code: Type.TNumber;
|
|
150
|
+
wall_time_seconds: Type.TNumber;
|
|
151
|
+
}>;
|
|
152
|
+
execute(_toolCallId: string, { command, timeout }: {
|
|
153
|
+
command: string;
|
|
154
|
+
timeout?: number;
|
|
155
|
+
}, signal?: AbortSignal, onUpdate?: import("../../../../../agent/src/index.js").AgentToolUpdateCallback<BashToolDetails | undefined> | undefined, ctx?: Partial<ToolContext>): Promise<{
|
|
156
|
+
content: {
|
|
157
|
+
type: "text";
|
|
158
|
+
text: string;
|
|
159
|
+
}[];
|
|
160
|
+
details: BashToolDetails | undefined;
|
|
161
|
+
structuredContent: {
|
|
162
|
+
output: string;
|
|
163
|
+
truncated: boolean;
|
|
164
|
+
full_output_path?: string | undefined;
|
|
165
|
+
exit_code: number;
|
|
166
|
+
wall_time_seconds: number;
|
|
167
|
+
};
|
|
168
|
+
isError: true;
|
|
169
|
+
} | {
|
|
170
|
+
isError?: undefined;
|
|
171
|
+
content: {
|
|
172
|
+
type: "text";
|
|
173
|
+
text: string;
|
|
174
|
+
}[];
|
|
175
|
+
details: BashToolDetails | undefined;
|
|
176
|
+
structuredContent: {
|
|
177
|
+
output: string;
|
|
178
|
+
truncated: boolean;
|
|
179
|
+
full_output_path?: string | undefined;
|
|
180
|
+
exit_code: number;
|
|
181
|
+
wall_time_seconds: number;
|
|
182
|
+
};
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared diff computation utilities for the edit and similar tools.
|
|
3
|
+
*/
|
|
4
|
+
export declare function detectLineEnding(content: string): "\r\n" | "\r" | "\n";
|
|
5
|
+
export declare function normalizeToLF(text: string): string;
|
|
6
|
+
export declare function restoreLineEndings(text: string, ending: "\r\n" | "\r" | "\n"): string;
|
|
7
|
+
/**
|
|
8
|
+
* Normalize text for fuzzy matching. Applies progressive transformations:
|
|
9
|
+
* - Strip trailing whitespace from each line
|
|
10
|
+
* - Normalize smart quotes to ASCII equivalents
|
|
11
|
+
* - Normalize Unicode dashes/hyphens to ASCII hyphen
|
|
12
|
+
* - Normalize special Unicode spaces to regular space
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeForFuzzyMatch(text: string): string;
|
|
15
|
+
interface MatchedEdit {
|
|
16
|
+
editIndex: number;
|
|
17
|
+
matchIndex: number;
|
|
18
|
+
matchLength: number;
|
|
19
|
+
newText: string;
|
|
20
|
+
}
|
|
21
|
+
type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
|
|
22
|
+
/**
|
|
23
|
+
* Apply replacements matched against `baseContent` to `originalContent` while
|
|
24
|
+
* preserving unchanged line blocks from the original.
|
|
25
|
+
*
|
|
26
|
+
* This is useful when `baseContent` is a normalized view of the original. Each
|
|
27
|
+
* replacement is widened to the lines it actually touches, those touched lines
|
|
28
|
+
* are rewritten from the normalized base, and all other lines are copied back
|
|
29
|
+
* from `originalContent`. The actual replacement ranges drive preservation so
|
|
30
|
+
* duplicate normalized lines cannot be aligned to the wrong occurrence.
|
|
31
|
+
*/
|
|
32
|
+
export declare function applyReplacementsPreservingUnchangedLines(originalContent: string, baseContent: string, replacements: TextReplacement[]): string;
|
|
33
|
+
export interface FuzzyMatchResult {
|
|
34
|
+
/** Whether a match was found */
|
|
35
|
+
found: boolean;
|
|
36
|
+
/** The index where the match starts (in the content that should be used for replacement) */
|
|
37
|
+
index: number;
|
|
38
|
+
/** Length of the matched text */
|
|
39
|
+
matchLength: number;
|
|
40
|
+
/** Whether fuzzy matching was used (false = exact match) */
|
|
41
|
+
usedFuzzyMatch: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The content to use for replacement operations.
|
|
44
|
+
* When exact match: original content. When fuzzy match: normalized content.
|
|
45
|
+
*/
|
|
46
|
+
contentForReplacement: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Edit {
|
|
49
|
+
oldText: string;
|
|
50
|
+
newText: string;
|
|
51
|
+
}
|
|
52
|
+
export interface AppliedEditsResult {
|
|
53
|
+
baseContent: string;
|
|
54
|
+
newContent: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Find oldText in content, trying exact match first, then fuzzy match.
|
|
58
|
+
* When fuzzy matching is used, the returned contentForReplacement is the
|
|
59
|
+
* fuzzy-normalized version of the content (trailing whitespace stripped,
|
|
60
|
+
* Unicode quotes/dashes normalized to ASCII).
|
|
61
|
+
*/
|
|
62
|
+
export declare function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult;
|
|
63
|
+
/**
|
|
64
|
+
* Apply one or more exact-text replacements to LF-normalized content.
|
|
65
|
+
*
|
|
66
|
+
* All edits are matched against the same original content. Replacements are
|
|
67
|
+
* then applied in reverse order so offsets remain stable. If any edit needs
|
|
68
|
+
* fuzzy matching, the operation runs in fuzzy-normalized content space and then
|
|
69
|
+
* overlays those line-level changes onto the original content so unchanged line
|
|
70
|
+
* blocks keep their original bytes. Supply originalContent to also preserve its
|
|
71
|
+
* line endings; changed blocks use the ending of their first original line.
|
|
72
|
+
*/
|
|
73
|
+
export declare function applyEditsToNormalizedContent(normalizedContent: string, edits: Edit[], path: string, originalContent?: string): AppliedEditsResult;
|
|
74
|
+
/** Generate a standard unified patch, or omit it when the computation budget is exceeded. */
|
|
75
|
+
export declare function generateUnifiedPatch(path: string, oldContent: string, newContent: string, contextLines?: number): string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Generate a display-oriented diff string with line numbers and context.
|
|
78
|
+
* Returns both the diff string and the first changed line number (in the new file).
|
|
79
|
+
*/
|
|
80
|
+
export declare function generateDiffString(oldContent: string, newContent: string, contextLines?: number): {
|
|
81
|
+
diff: string | undefined;
|
|
82
|
+
firstChangedLine: number | undefined;
|
|
83
|
+
};
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import type { ToolContext } from "../../types.js";
|
|
3
|
+
import type { FileReadState } from "./file-read-state.js";
|
|
4
|
+
declare const editSchema: Type.TObject<{
|
|
5
|
+
path: Type.TString;
|
|
6
|
+
edits: Type.TArray<Type.TObject<{
|
|
7
|
+
oldText: Type.TString;
|
|
8
|
+
newText: Type.TString;
|
|
9
|
+
}>>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const editToolSystemPromptContribution: {
|
|
12
|
+
readonly snippet: "Make precise file edits with exact text replacement, including multiple disjoint edits in one call";
|
|
13
|
+
readonly guidelines: readonly ["Use edit for precise changes (edits[].oldText must match exactly)", "When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls", "Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit.", "Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions."];
|
|
14
|
+
};
|
|
15
|
+
export type EditToolInput = Static<typeof editSchema>;
|
|
16
|
+
export interface EditToolDetails {
|
|
17
|
+
/** Display-oriented diff of the changes made */
|
|
18
|
+
diff: string;
|
|
19
|
+
/** Standard unified patch of the changes made */
|
|
20
|
+
patch: string;
|
|
21
|
+
/** Line number of the first change in the new file (for editor navigation) */
|
|
22
|
+
firstChangedLine?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Pluggable operations for the edit tool.
|
|
26
|
+
* Override these to delegate file editing to remote systems (for example SSH).
|
|
27
|
+
*/
|
|
28
|
+
export interface EditOperations {
|
|
29
|
+
/** Read file contents as a Buffer */
|
|
30
|
+
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
31
|
+
/** Write content to a file */
|
|
32
|
+
writeFile: (absolutePath: string, content: string) => Promise<void>;
|
|
33
|
+
/** Check if file is readable and writable (throw if not) */
|
|
34
|
+
access: (absolutePath: string) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface EditToolOptions {
|
|
37
|
+
/** Shared knowledge of file contents in the current model context. */
|
|
38
|
+
fileReadState?: FileReadState;
|
|
39
|
+
/** Custom operations for file editing. Default: local filesystem */
|
|
40
|
+
operations?: EditOperations;
|
|
41
|
+
}
|
|
42
|
+
declare function prepareEditArguments(input: unknown): EditToolInput;
|
|
43
|
+
export declare function createEditToolDefinition(cwd: string, options?: EditToolOptions): {
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
description: string;
|
|
47
|
+
promptSnippet: "Make precise file edits with exact text replacement, including multiple disjoint edits in one call";
|
|
48
|
+
promptGuidelines: ("Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit." | "Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions." | "Use edit for precise changes (edits[].oldText must match exactly)" | "When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls")[];
|
|
49
|
+
parameters: Type.TObject<{
|
|
50
|
+
path: Type.TString;
|
|
51
|
+
edits: Type.TArray<Type.TObject<{
|
|
52
|
+
oldText: Type.TString;
|
|
53
|
+
newText: Type.TString;
|
|
54
|
+
}>>;
|
|
55
|
+
}>;
|
|
56
|
+
prepareArguments: typeof prepareEditArguments;
|
|
57
|
+
execute(_toolCallId: string, input: EditToolInput, signal?: AbortSignal, _onUpdate?: import("../../../../../agent/src/index.js").AgentToolUpdateCallback<EditToolDetails | undefined> | undefined, ctx?: Partial<ToolContext>): Promise<{
|
|
58
|
+
content: {
|
|
59
|
+
type: "text";
|
|
60
|
+
text: string;
|
|
61
|
+
}[];
|
|
62
|
+
details: {
|
|
63
|
+
diff: string;
|
|
64
|
+
patch: string;
|
|
65
|
+
firstChangedLine: number | undefined;
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** File contents known to the model in one live context; no transcript or disk cache. */
|
|
2
|
+
export declare class FileReadState {
|
|
3
|
+
private files;
|
|
4
|
+
clear(): void;
|
|
5
|
+
isUnchanged(path: string, content: string, offset?: number, limit?: number): boolean;
|
|
6
|
+
/** Reuse an incremental decoded-text hash without retaining the full file. */
|
|
7
|
+
isHashUnchanged(path: string, hash: string, offset?: number, limit?: number): boolean;
|
|
8
|
+
recordRead(path: string, content: string, offset?: number, limit?: number, truncated?: boolean): void;
|
|
9
|
+
recordReadHash(path: string, hash: string, offset?: number, limit?: number, truncated?: boolean): void;
|
|
10
|
+
recordWrite(path: string, content: string): void;
|
|
11
|
+
recordEdit(path: string, before: string, after: string): void;
|
|
12
|
+
}
|