@zpi-dev/agent-sdk 0.1.60 → 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/README.md +1 -1
- package/dist/{chunk-AR5RMMMN.js → chunk-GPIEWH3K.js} +324 -309
- package/dist/chunk-GPIEWH3K.js.map +1 -0
- package/dist/{chunk-4WFFCN2C.js → chunk-YPFTXFZL.js} +527 -479
- package/dist/chunk-YPFTXFZL.js.map +1 -0
- package/dist/host.js +3 -5
- package/dist/host.js.map +1 -1
- package/dist/index.js +2 -4
- package/dist/{src-7WDJXP5P.js → src-GYA4LFM7.js} +2 -4
- package/dist/types/ai/src/types.d.ts +2 -1
- package/dist/types/ai/src/utils/text.d.ts +1 -5
- package/dist/types/ai/src/utils/transcript.d.ts +0 -13
- package/dist/types/coding-agent/src/core/agent-session.d.ts +3 -2
- package/dist/types/coding-agent/src/core/dynamic-context.d.ts +3 -0
- package/dist/types/coding-agent/src/core/resources.d.ts +1 -1
- package/dist/types/coding-agent/src/core/sdk.d.ts +1 -3
- package/dist/types/coding-agent/src/core/session-manager.d.ts +1 -0
- package/dist/types/coding-agent/src/core/system-prompt.d.ts +9 -2
- package/dist/types/coding-agent/src/plugins/assembly.d.ts +1 -2
- package/dist/types/coding-agent/src/plugins/types.d.ts +3 -2
- package/package.json +5 -5
- package/dist/chunk-4WFFCN2C.js.map +0 -1
- package/dist/chunk-AR5RMMMN.js.map +0 -1
- package/dist/chunk-RAZL7ZAW.js +0 -13451
- package/dist/chunk-RAZL7ZAW.js.map +0 -1
- package/dist/chunk-TUOZKHGN.js +0 -21
- package/dist/chunk-TUOZKHGN.js.map +0 -1
- package/dist/chunk-YBW5XDR7.js +0 -48
- package/dist/node-WXHENNL2.js +0 -21
- package/dist/node-WXHENNL2.js.map +0 -1
- package/dist/node-XSTAMDFW.js +0 -2225
- package/dist/node-XSTAMDFW.js.map +0 -1
- package/dist/src-7WDJXP5P.js.map +0 -1
- /package/dist/{chunk-YBW5XDR7.js.map → src-GYA4LFM7.js.map} +0 -0
package/dist/host.js
CHANGED
|
@@ -4,12 +4,10 @@ import {
|
|
|
4
4
|
SettingsManager,
|
|
5
5
|
createAgentSession,
|
|
6
6
|
query
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-RAZL7ZAW.js";
|
|
10
|
-
import "./chunk-YBW5XDR7.js";
|
|
7
|
+
} from "./chunk-YPFTXFZL.js";
|
|
8
|
+
import "./chunk-GPIEWH3K.js";
|
|
11
9
|
|
|
12
|
-
//
|
|
10
|
+
// src/query-result.ts
|
|
13
11
|
async function queryResult(params, observe) {
|
|
14
12
|
let result;
|
|
15
13
|
for await (const message of query(params)) {
|
package/dist/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query-result.ts"],"sourcesContent":["import { type QueryParams, query } from \"./query.ts\";\nimport type { SDKMessage, SDKResultMessage } from \"./types.ts\";\n\n/** Consume a query and return its successful terminal result. */\nexport async function queryResult(\n params: QueryParams,\n observe?: (message: SDKMessage) => void,\n): Promise<Extract<SDKResultMessage, { subtype: \"success\" }>> {\n let result: SDKResultMessage | undefined;\n for await (const message of query(params)) {\n observe?.(message);\n if (message.type === \"result\") result = message;\n }\n if (!result) throw new Error(\"Agent SDK returned no result\");\n if (result.subtype !== \"success\")\n throw Object.assign(new Error(result.errors.join(\"\\n\")), { sdkResult: result });\n return result;\n}\n\nexport function nativeStopReason(reason: string | null): string {\n return reason === \"end_turn\"\n ? \"stop\"\n : reason === \"tool_use\"\n ? \"toolUse\"\n : reason === \"max_tokens\"\n ? \"length\"\n : (reason ?? \"error\");\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/query-result.ts"],"sourcesContent":["import { type QueryParams, query } from \"./query.ts\";\nimport type { SDKMessage, SDKResultMessage } from \"./types.ts\";\n\n/** Consume a query and return its successful terminal result. */\nexport async function queryResult(\n params: QueryParams,\n observe?: (message: SDKMessage) => void,\n): Promise<Extract<SDKResultMessage, { subtype: \"success\" }>> {\n let result: SDKResultMessage | undefined;\n for await (const message of query(params)) {\n observe?.(message);\n if (message.type === \"result\") result = message;\n }\n if (!result) throw new Error(\"Agent SDK returned no result\");\n if (result.subtype !== \"success\")\n throw Object.assign(new Error(result.errors.join(\"\\n\")), { sdkResult: result });\n return result;\n}\n\nexport function nativeStopReason(reason: string | null): string {\n return reason === \"end_turn\"\n ? \"stop\"\n : reason === \"tool_use\"\n ? \"toolUse\"\n : reason === \"max_tokens\"\n ? \"length\"\n : (reason ?? \"error\");\n}\n"],"mappings":";;;;;;;;;;AAIA,eAAsB,YACpB,QACA,SAC4D;AAC5D,MAAI;AACJ,mBAAiB,WAAW,MAAM,MAAM,GAAG;AACzC,cAAU,OAAO;AACjB,QAAI,QAAQ,SAAS,SAAU,UAAS;AAAA,EAC1C;AACA,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,8BAA8B;AAC3D,MAAI,OAAO,YAAY;AACrB,UAAM,OAAO,OAAO,IAAI,MAAM,OAAO,OAAO,KAAK,IAAI,CAAC,GAAG,EAAE,WAAW,OAAO,CAAC;AAChF,SAAO;AACT;AAEO,SAAS,iBAAiB,QAA+B;AAC9D,SAAO,WAAW,aACd,SACA,WAAW,aACT,YACA,WAAW,eACT,WACC,UAAU;AACrB;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,8 @@ import {
|
|
|
8
8
|
query,
|
|
9
9
|
renameSession,
|
|
10
10
|
tagSession
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-RAZL7ZAW.js";
|
|
14
|
-
import "./chunk-YBW5XDR7.js";
|
|
11
|
+
} from "./chunk-YPFTXFZL.js";
|
|
12
|
+
import "./chunk-GPIEWH3K.js";
|
|
15
13
|
export {
|
|
16
14
|
ModelRuntime,
|
|
17
15
|
forkSession,
|
|
@@ -60,9 +60,7 @@ import {
|
|
|
60
60
|
usesChatGPTAuth,
|
|
61
61
|
validateReasoningConfig,
|
|
62
62
|
validateThinkingMap
|
|
63
|
-
} from "./chunk-
|
|
64
|
-
import "./chunk-RAZL7ZAW.js";
|
|
65
|
-
import "./chunk-YBW5XDR7.js";
|
|
63
|
+
} from "./chunk-GPIEWH3K.js";
|
|
66
64
|
export {
|
|
67
65
|
AssistantMessageEventStream,
|
|
68
66
|
DEFAULT_MAX_AGENT_RETRY_DELAY_MS,
|
|
@@ -125,4 +123,4 @@ export {
|
|
|
125
123
|
validateReasoningConfig,
|
|
126
124
|
validateThinkingMap
|
|
127
125
|
};
|
|
128
|
-
//# sourceMappingURL=src-
|
|
126
|
+
//# sourceMappingURL=src-GYA4LFM7.js.map
|
|
@@ -83,7 +83,7 @@ export interface AnthropicMessagesCompat {
|
|
|
83
83
|
supportsStrictTools?: boolean;
|
|
84
84
|
/** Whether the exact model transport supports effort-only system messages and thinking binding controls. Default: false. */
|
|
85
85
|
supportsMidConvoEffort?: boolean;
|
|
86
|
-
/** Whether the exact model accepts system-role messages inside the conversation. When false,
|
|
86
|
+
/** Whether the exact model accepts system-role messages inside the conversation. When false, updates remain in place as user messages. Default: false. */
|
|
87
87
|
supportsMidConvoSystemMessages?: boolean;
|
|
88
88
|
/** Whether the exact model accepts mid-conversation `tool_addition` and `tool_removal` blocks. Requires `supportsMidConvoSystemMessages`. Default: false. */
|
|
89
89
|
supportsMidConvoToolChanges?: boolean;
|
|
@@ -176,6 +176,7 @@ export interface SystemMessage {
|
|
|
176
176
|
role: "system";
|
|
177
177
|
content: string | TextContent[];
|
|
178
178
|
timestamp: number;
|
|
179
|
+
/** Named context patches: a string replaces the entire block; null withdraws every earlier version. */
|
|
179
180
|
sections?: Record<string, string | null>;
|
|
180
181
|
toolsAdded?: Tool[];
|
|
181
182
|
toolsRemoved?: {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { SystemMessage } from "../types.js";
|
|
2
|
-
/** Render a system message as a complete prompt: its content followed by its sections. */
|
|
3
|
-
export declare function getSystemMessageText(message: SystemMessage): string;
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Section changes are framed by name so the model can relate them to the leading prompt.
|
|
7
|
-
* This framing is request-time only and may change between versions.
|
|
3
|
+
* Shared wire representation of named context changes, regardless of provider role.
|
|
8
4
|
*/
|
|
9
5
|
export declare function renderSystemMessageUpdate(message: SystemMessage): string;
|
|
@@ -20,19 +20,6 @@ export type TranscriptMessages = readonly {
|
|
|
20
20
|
}[];
|
|
21
21
|
/** Return the leading system message, if the transcript starts with one. */
|
|
22
22
|
export declare function getInitialSystemMessage(messages: TranscriptMessages): SystemMessage | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Replay every system message into one leading system message holding the current
|
|
25
|
-
* prompt and tools. Later `content` is appended to the base prompt, `sections` are
|
|
26
|
-
* patched by name, and tools are resolved with {@link getCurrentTools}.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getCurrentSystemMessage(messages: TranscriptMessages): SystemMessage | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Rebuild the transcript for APIs without mid-conversation system messages: the replayed
|
|
31
|
-
* system message leads, and every later system message is dropped.
|
|
32
|
-
*/
|
|
33
|
-
export declare function collapseSystemMessages(context: TranscriptContext): TranscriptContext;
|
|
34
|
-
/** Keep later system messages in place when the model accepts them; otherwise collapse them. */
|
|
35
|
-
export declare function resolveTranscript(context: TranscriptContext, supportsMidConvoSystemMessages: boolean | undefined): TranscriptContext;
|
|
36
23
|
export declare function getDeclaredTools(messages: TranscriptMessages): Tool[];
|
|
37
24
|
/**
|
|
38
25
|
* Whether a tool name was declared twice with different definitions. Transports that
|
|
@@ -9,6 +9,7 @@ import type { LoadedSkill, SkillList } from "./resources.js";
|
|
|
9
9
|
import type { SessionEntry, SessionManager } from "./session-manager.js";
|
|
10
10
|
import type { ContextUsage } from "./session-state.js";
|
|
11
11
|
import { SettingsManager } from "./settings-manager.js";
|
|
12
|
+
import type { SystemContext } from "./system-prompt.js";
|
|
12
13
|
import type { ResourceDiagnostic, ResourceLoader } from "./types.js";
|
|
13
14
|
export interface InputContext {
|
|
14
15
|
images?: ImageContent[];
|
|
@@ -88,7 +89,7 @@ export declare class AgentSession {
|
|
|
88
89
|
get modelPerformance(): ModelPerformance;
|
|
89
90
|
constructor(model: Model, runtime: ModelRuntime, manager: SessionManager, allTools: AgentTool[], activeTools: AgentTool[], systemPrompt: string, thinkingLevel: ThinkingLevel, resources?: {
|
|
90
91
|
loader: ResourceLoader;
|
|
91
|
-
|
|
92
|
+
buildContext: () => SystemContext;
|
|
92
93
|
settingsManager?: SettingsManager;
|
|
93
94
|
}, performanceTotals?: ModelPerformanceTotals, extensions?: {
|
|
94
95
|
modelRequestOptions?: () => SimpleStreamOptions;
|
|
@@ -122,7 +123,7 @@ export declare class AgentSession {
|
|
|
122
123
|
}[];
|
|
123
124
|
submit(text: string): Promise<void>;
|
|
124
125
|
executeInput(input: ParsedInput, context?: InputContext): Promise<void>;
|
|
125
|
-
private
|
|
126
|
+
private syncContext;
|
|
126
127
|
private refreshInstructions;
|
|
127
128
|
private compactionBoundary;
|
|
128
129
|
private estimateTokens;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Message, SystemMessage } from "../../../ai/src/index.js";
|
|
2
|
+
/** Full desired SDK state in, only changed blocks out. Foreign system state is never withdrawn. */
|
|
3
|
+
export declare function contextUpdate(messages: readonly Message[], current: Readonly<Record<string, string>>): SystemMessage | undefined;
|
|
@@ -48,4 +48,4 @@ export declare class FileResourceLoader implements ResourceLoader {
|
|
|
48
48
|
loadSkill(name: string): Promise<LoadedSkill>;
|
|
49
49
|
getDiagnostics(): ResourceDiagnostic[];
|
|
50
50
|
}
|
|
51
|
-
export declare function formatSkillsForPrompt(skills: SkillMetadata[], tool?: "read" | "bash"): string;
|
|
51
|
+
export declare function formatSkillsForPrompt(skills: SkillMetadata[], tool?: "read" | "bash" | "Read" | "Bash" | "Skill"): string;
|
|
@@ -12,8 +12,6 @@ import { type PromptTemplate } from "./system-prompt.js";
|
|
|
12
12
|
import type { ResourceLoader } from "./types.js";
|
|
13
13
|
export interface SystemPromptContext {
|
|
14
14
|
tools: readonly AgentTool[];
|
|
15
|
-
pluginInstructions: readonly string[];
|
|
16
|
-
resourceLoader: ResourceLoader;
|
|
17
15
|
}
|
|
18
16
|
export interface CreateAgentSessionOptions extends SessionContributions {
|
|
19
17
|
/** Build tool definitions and selection once the shared resource catalog is loaded. */
|
|
@@ -23,7 +21,7 @@ export interface CreateAgentSessionOptions extends SessionContributions {
|
|
|
23
21
|
manual: boolean;
|
|
24
22
|
instructions: string;
|
|
25
23
|
}, signal?: AbortSignal) => Promise<void>;
|
|
26
|
-
/**
|
|
24
|
+
/** Base instructions only. SDK resources and plugin context remain independently managed. */
|
|
27
25
|
systemPrompt?: string | ((context: SystemPromptContext) => string);
|
|
28
26
|
/** Host policy checked at each foreground model request, including continuation requests. */
|
|
29
27
|
beforeModelRequest?: (model: Model, context: Context) => void;
|
|
@@ -13,7 +13,11 @@ export declare function renderTemplate(text: string, context: {
|
|
|
13
13
|
project_name: string;
|
|
14
14
|
platform: string;
|
|
15
15
|
}): string;
|
|
16
|
-
export
|
|
16
|
+
export interface SystemContext {
|
|
17
|
+
base: string;
|
|
18
|
+
sections: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildSystemContext(options: {
|
|
17
21
|
cwd: string;
|
|
18
22
|
projectName?: string;
|
|
19
23
|
platform?: string;
|
|
@@ -22,4 +26,7 @@ export declare function buildSystemPrompt(options: {
|
|
|
22
26
|
loader?: ResourceLoader;
|
|
23
27
|
/** Literal instructions appended after resources, before the skill catalog and working directory. */
|
|
24
28
|
customInstructions?: readonly string[];
|
|
25
|
-
|
|
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;
|
|
@@ -23,8 +23,7 @@ export declare function assembleSession(options: SessionContributions & {
|
|
|
23
23
|
activeTools: AgentTool<TSchema, import("../../../ai/src/index.js").JsonValue | undefined>[];
|
|
24
24
|
commands: PluginCommand[];
|
|
25
25
|
skills: import("./types.js").PluginSkill[];
|
|
26
|
-
|
|
27
|
-
getInstructions: () => any[];
|
|
26
|
+
getContextSections: () => Record<string, string>;
|
|
28
27
|
hooks: {
|
|
29
28
|
event: import("./hooks.js").HookEvent;
|
|
30
29
|
matcher?: string;
|
|
@@ -34,7 +34,8 @@ export interface SessionPlugin extends PluginSnapshot {
|
|
|
34
34
|
tools?: readonly ToolDefinition<TSchema, unknown>[];
|
|
35
35
|
/** Explicitly replace an existing built-in; collisions are rejected during assembly. */
|
|
36
36
|
toolOverrides?: readonly ToolDefinition<TSchema, unknown>[];
|
|
37
|
-
/** Pure
|
|
38
|
-
|
|
37
|
+
/** Pure current-state reader. Local block names are scoped to this plugin by the SDK.
|
|
38
|
+
* Omitted/empty blocks withdraw prior versions; no plugin-owned diffing or history writes. */
|
|
39
|
+
contextInstructions?: () => Readonly<Record<string, string>>;
|
|
39
40
|
hooks?: readonly HookRegistration[];
|
|
40
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zpi-dev/agent-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript Agent SDK for ZPI with a Claude-compatible public API",
|
|
6
6
|
"exports": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@anthropic-ai/sdk": "0.124.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@zpi-dev/ai": "0.1.
|
|
40
|
-
"@zpi-dev/agent": "0.1.
|
|
41
|
-
"@zpi-dev/coding-agent": "0.1.
|
|
42
|
-
"@zpi-dev/plugin-compat": "0.1.
|
|
39
|
+
"@zpi-dev/ai": "0.1.61",
|
|
40
|
+
"@zpi-dev/agent": "0.1.61",
|
|
41
|
+
"@zpi-dev/coding-agent": "0.1.61",
|
|
42
|
+
"@zpi-dev/plugin-compat": "0.1.61",
|
|
43
43
|
"yaml": "2.9.1"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|