@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,82 @@
|
|
|
1
|
+
import type { AgentToolResult } from "../../../agent/src/index.js";
|
|
2
|
+
export declare const hookEvents: readonly ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "PostToolUseFailure", "Stop", "InputAccepted", "RunStart", "RunEnd", "Notification"];
|
|
3
|
+
export type HookEvent = (typeof hookEvents)[number];
|
|
4
|
+
export type HookInput = {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
invocationId: string;
|
|
8
|
+
} & ({
|
|
9
|
+
event: "SessionStart";
|
|
10
|
+
source: "startup" | "resume";
|
|
11
|
+
} | {
|
|
12
|
+
event: "UserPromptSubmit";
|
|
13
|
+
prompt: string;
|
|
14
|
+
} | {
|
|
15
|
+
event: "PreToolUse" | "PostToolUse" | "PostToolUseFailure";
|
|
16
|
+
toolCallId: string;
|
|
17
|
+
toolName: string;
|
|
18
|
+
toolInput: unknown;
|
|
19
|
+
toolResult?: AgentToolResult;
|
|
20
|
+
} | {
|
|
21
|
+
event: "Stop";
|
|
22
|
+
response: string;
|
|
23
|
+
stopHookActive: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
event: "InputAccepted";
|
|
26
|
+
prompt: string;
|
|
27
|
+
} | {
|
|
28
|
+
event: "RunStart";
|
|
29
|
+
runId: string;
|
|
30
|
+
prompt: string;
|
|
31
|
+
sessionCreated: boolean;
|
|
32
|
+
userInitiated: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
event: "RunEnd";
|
|
35
|
+
runId: string;
|
|
36
|
+
status: "completed" | "aborted" | "error";
|
|
37
|
+
} | {
|
|
38
|
+
event: "Notification";
|
|
39
|
+
runId: string;
|
|
40
|
+
notificationType: "task_completed" | "task_failed";
|
|
41
|
+
message: string;
|
|
42
|
+
});
|
|
43
|
+
type WithoutInvocation<T> = T extends unknown ? Omit<T, "invocationId"> : never;
|
|
44
|
+
export type HookInvocation = WithoutInvocation<HookInput>;
|
|
45
|
+
export interface HookOutput {
|
|
46
|
+
block?: boolean;
|
|
47
|
+
reason?: string;
|
|
48
|
+
updatedInput?: unknown;
|
|
49
|
+
additionalContext?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface HookRegistration {
|
|
52
|
+
event: HookEvent;
|
|
53
|
+
matcher?: string;
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
onError?: "continue" | "block";
|
|
56
|
+
handler(input: HookInput, signal: AbortSignal): HookOutput | undefined | Promise<HookOutput | undefined>;
|
|
57
|
+
}
|
|
58
|
+
export interface HookExecution {
|
|
59
|
+
invocationId: string;
|
|
60
|
+
pluginId?: string;
|
|
61
|
+
event: HookEvent;
|
|
62
|
+
index: number;
|
|
63
|
+
status: "completed" | "blocked" | "error" | "cancelled" | "timeout";
|
|
64
|
+
durationMs: number;
|
|
65
|
+
}
|
|
66
|
+
export declare const maxHookContextChars = 24000;
|
|
67
|
+
export declare function validateHookRegistration(hook: HookRegistration): void;
|
|
68
|
+
export declare class HookRunner {
|
|
69
|
+
private hooks;
|
|
70
|
+
private observe;
|
|
71
|
+
constructor(hooks: readonly (HookRegistration & {
|
|
72
|
+
pluginId?: string;
|
|
73
|
+
})[], observe?: (event: HookExecution) => void);
|
|
74
|
+
get hasToolHooks(): boolean;
|
|
75
|
+
run(input: HookInvocation, signal?: AbortSignal, validateInput?: (input: unknown) => unknown): Promise<{
|
|
76
|
+
block: boolean;
|
|
77
|
+
reason?: string;
|
|
78
|
+
updatedInput?: unknown;
|
|
79
|
+
additionalContexts: string[];
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceLoader } from "../core/types.js";
|
|
2
|
+
import type { PluginSkill } from "./types.js";
|
|
3
|
+
/** Adds explicit frozen plugin skills without changing filesystem discovery. */
|
|
4
|
+
export declare function withPluginResources(loader: ResourceLoader, skills: readonly PluginSkill[]): ResourceLoader;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentLoopConfig, AgentMessage } from "../../../agent/src/index.js";
|
|
2
|
+
import { type HookExecution, type HookRegistration, HookRunner } from "./hooks.js";
|
|
3
|
+
/** Bridges lifecycle decisions to the loop; the runner never owns session history. */
|
|
4
|
+
export declare class SessionHooks {
|
|
5
|
+
readonly runner: HookRunner;
|
|
6
|
+
private started;
|
|
7
|
+
private startMessages;
|
|
8
|
+
private pending;
|
|
9
|
+
private callOrder;
|
|
10
|
+
private continuations;
|
|
11
|
+
private context;
|
|
12
|
+
constructor(context: {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
cwd: string;
|
|
15
|
+
source: "startup" | "resume";
|
|
16
|
+
}, hooks: readonly (HookRegistration & {
|
|
17
|
+
pluginId?: string;
|
|
18
|
+
})[], observe: (event: HookExecution) => void);
|
|
19
|
+
beginRun(): void;
|
|
20
|
+
preparePrompt(prompt: string, signal?: AbortSignal): Promise<AgentMessage[]>;
|
|
21
|
+
drainMessages(): AgentMessage[];
|
|
22
|
+
beforeToolCall: NonNullable<AgentLoopConfig["beforeToolCall"]>;
|
|
23
|
+
afterToolCall: NonNullable<AgentLoopConfig["afterToolCall"]>;
|
|
24
|
+
beforeStop: NonNullable<AgentLoopConfig["beforeStop"]>;
|
|
25
|
+
private enqueue;
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { JsonObject } from "../../../ai/src/index.js";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
3
|
+
import type { ToolDefinition } from "../core/types.js";
|
|
4
|
+
import type { HookRegistration } from "./hooks.js";
|
|
5
|
+
export interface PluginCommand {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
/** Literal prompt template; only {{cwd}} and {{arguments}} are expanded once. */
|
|
9
|
+
prompt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginSkill {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
path: string;
|
|
15
|
+
baseDir: string;
|
|
16
|
+
body: string;
|
|
17
|
+
}
|
|
18
|
+
/** Serializable contributions frozen by a host at first-send admission. */
|
|
19
|
+
export interface PluginSnapshot {
|
|
20
|
+
id: string;
|
|
21
|
+
version: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
instructions?: readonly string[];
|
|
25
|
+
commands?: readonly PluginCommand[];
|
|
26
|
+
skills?: readonly PluginSkill[];
|
|
27
|
+
/** Host-resolved runtime identity, never an import path. */
|
|
28
|
+
runtime?: string;
|
|
29
|
+
options?: JsonObject;
|
|
30
|
+
}
|
|
31
|
+
export type PluginMetadata = Pick<PluginSnapshot, "id" | "version" | "name" | "description">;
|
|
32
|
+
/** Explicit native registration. Discovery never imports arbitrary workspace code. */
|
|
33
|
+
export interface SessionPlugin extends PluginSnapshot {
|
|
34
|
+
tools?: readonly ToolDefinition<TSchema, unknown>[];
|
|
35
|
+
/** Explicitly replace an existing built-in; collisions are rejected during assembly. */
|
|
36
|
+
toolOverrides?: readonly ToolDefinition<TSchema, unknown>[];
|
|
37
|
+
/** Pure synchronous context reader, evaluated for previews and after prompt hooks/resource refresh. */
|
|
38
|
+
contextInstructions?: () => readonly string[];
|
|
39
|
+
hooks?: readonly HookRegistration[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { type HookInput, type HookOutput, type HookRegistration } from "../../coding-agent/src/index.js";
|
|
2
|
+
export interface CommandHook {
|
|
3
|
+
event: string;
|
|
4
|
+
matcher?: string;
|
|
5
|
+
type: "command" | "process";
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CommandHookContext {
|
|
11
|
+
root: string;
|
|
12
|
+
dataDirectory: string;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
transcriptPath?: string;
|
|
16
|
+
env?: Record<string, string | undefined>;
|
|
17
|
+
validate?: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function parseCommandHook(hook: unknown, event: string, match: unknown): CommandHook;
|
|
20
|
+
export declare function decodeHookOutput(value: unknown, event: HookInput["event"]): HookOutput | undefined;
|
|
21
|
+
export declare function hookInputPayload(input: HookInput, transcriptPath?: string): {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
cwd: string;
|
|
24
|
+
invocationId: string;
|
|
25
|
+
event: "SessionStart";
|
|
26
|
+
source: "startup" | "resume";
|
|
27
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
28
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
29
|
+
session_id: string;
|
|
30
|
+
transcriptPath?: string | undefined;
|
|
31
|
+
transcript_path?: string | undefined;
|
|
32
|
+
tool_name?: string | undefined;
|
|
33
|
+
tool_input?: unknown;
|
|
34
|
+
tool_use_id?: string | undefined;
|
|
35
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
36
|
+
error?: string | undefined;
|
|
37
|
+
stop_hook_active?: boolean | undefined;
|
|
38
|
+
last_assistant_message?: string | undefined;
|
|
39
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
40
|
+
} | {
|
|
41
|
+
sessionId: string;
|
|
42
|
+
cwd: string;
|
|
43
|
+
invocationId: string;
|
|
44
|
+
event: "UserPromptSubmit";
|
|
45
|
+
prompt: string;
|
|
46
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
47
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
48
|
+
session_id: string;
|
|
49
|
+
transcriptPath?: string | undefined;
|
|
50
|
+
transcript_path?: string | undefined;
|
|
51
|
+
tool_name?: string | undefined;
|
|
52
|
+
tool_input?: unknown;
|
|
53
|
+
tool_use_id?: string | undefined;
|
|
54
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
55
|
+
error?: string | undefined;
|
|
56
|
+
stop_hook_active?: boolean | undefined;
|
|
57
|
+
last_assistant_message?: string | undefined;
|
|
58
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
59
|
+
} | {
|
|
60
|
+
sessionId: string;
|
|
61
|
+
cwd: string;
|
|
62
|
+
invocationId: string;
|
|
63
|
+
event: "PreToolUse" | "PostToolUse" | "PostToolUseFailure";
|
|
64
|
+
toolCallId: string;
|
|
65
|
+
toolName: string;
|
|
66
|
+
toolInput: unknown;
|
|
67
|
+
toolResult?: import("../../agent/src/index.js").AgentToolResult;
|
|
68
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
69
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
70
|
+
session_id: string;
|
|
71
|
+
transcriptPath?: string | undefined;
|
|
72
|
+
transcript_path?: string | undefined;
|
|
73
|
+
tool_name?: string | undefined;
|
|
74
|
+
tool_input?: unknown;
|
|
75
|
+
tool_use_id?: string | undefined;
|
|
76
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
77
|
+
error?: string | undefined;
|
|
78
|
+
stop_hook_active?: boolean | undefined;
|
|
79
|
+
last_assistant_message?: string | undefined;
|
|
80
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
81
|
+
} | {
|
|
82
|
+
sessionId: string;
|
|
83
|
+
cwd: string;
|
|
84
|
+
invocationId: string;
|
|
85
|
+
event: "Stop";
|
|
86
|
+
response: string;
|
|
87
|
+
stopHookActive: boolean;
|
|
88
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
89
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
90
|
+
session_id: string;
|
|
91
|
+
transcriptPath?: string | undefined;
|
|
92
|
+
transcript_path?: string | undefined;
|
|
93
|
+
tool_name?: string | undefined;
|
|
94
|
+
tool_input?: unknown;
|
|
95
|
+
tool_use_id?: string | undefined;
|
|
96
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
97
|
+
error?: string | undefined;
|
|
98
|
+
stop_hook_active?: boolean | undefined;
|
|
99
|
+
last_assistant_message?: string | undefined;
|
|
100
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
101
|
+
} | {
|
|
102
|
+
sessionId: string;
|
|
103
|
+
cwd: string;
|
|
104
|
+
invocationId: string;
|
|
105
|
+
event: "InputAccepted";
|
|
106
|
+
prompt: string;
|
|
107
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
108
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
109
|
+
session_id: string;
|
|
110
|
+
transcriptPath?: string | undefined;
|
|
111
|
+
transcript_path?: string | undefined;
|
|
112
|
+
tool_name?: string | undefined;
|
|
113
|
+
tool_input?: unknown;
|
|
114
|
+
tool_use_id?: string | undefined;
|
|
115
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
116
|
+
error?: string | undefined;
|
|
117
|
+
stop_hook_active?: boolean | undefined;
|
|
118
|
+
last_assistant_message?: string | undefined;
|
|
119
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
120
|
+
} | {
|
|
121
|
+
sessionId: string;
|
|
122
|
+
cwd: string;
|
|
123
|
+
invocationId: string;
|
|
124
|
+
event: "RunStart";
|
|
125
|
+
runId: string;
|
|
126
|
+
prompt: string;
|
|
127
|
+
sessionCreated: boolean;
|
|
128
|
+
userInitiated: boolean;
|
|
129
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
130
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
131
|
+
session_id: string;
|
|
132
|
+
transcriptPath?: string | undefined;
|
|
133
|
+
transcript_path?: string | undefined;
|
|
134
|
+
tool_name?: string | undefined;
|
|
135
|
+
tool_input?: unknown;
|
|
136
|
+
tool_use_id?: string | undefined;
|
|
137
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
138
|
+
error?: string | undefined;
|
|
139
|
+
stop_hook_active?: boolean | undefined;
|
|
140
|
+
last_assistant_message?: string | undefined;
|
|
141
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
142
|
+
} | {
|
|
143
|
+
sessionId: string;
|
|
144
|
+
cwd: string;
|
|
145
|
+
invocationId: string;
|
|
146
|
+
event: "RunEnd";
|
|
147
|
+
runId: string;
|
|
148
|
+
status: "completed" | "aborted" | "error";
|
|
149
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
150
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
151
|
+
session_id: string;
|
|
152
|
+
transcriptPath?: string | undefined;
|
|
153
|
+
transcript_path?: string | undefined;
|
|
154
|
+
tool_name?: string | undefined;
|
|
155
|
+
tool_input?: unknown;
|
|
156
|
+
tool_use_id?: string | undefined;
|
|
157
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
158
|
+
error?: string | undefined;
|
|
159
|
+
stop_hook_active?: boolean | undefined;
|
|
160
|
+
last_assistant_message?: string | undefined;
|
|
161
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
162
|
+
} | {
|
|
163
|
+
sessionId: string;
|
|
164
|
+
cwd: string;
|
|
165
|
+
invocationId: string;
|
|
166
|
+
event: "Notification";
|
|
167
|
+
runId: string;
|
|
168
|
+
notificationType: "task_completed" | "task_failed";
|
|
169
|
+
message: string;
|
|
170
|
+
hookEventName: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
171
|
+
hook_event_name: "InputAccepted" | "Notification" | "PostToolUse" | "PostToolUseFailure" | "PreToolUse" | "RunEnd" | "RunStart" | "SessionStart" | "Stop" | "UserPromptSubmit";
|
|
172
|
+
session_id: string;
|
|
173
|
+
transcriptPath?: string | undefined;
|
|
174
|
+
transcript_path?: string | undefined;
|
|
175
|
+
tool_name?: string | undefined;
|
|
176
|
+
tool_input?: unknown;
|
|
177
|
+
tool_use_id?: string | undefined;
|
|
178
|
+
tool_response?: import("../../agent/src/index.js").AgentToolResult<import("../../ai/src/index.js").JsonValue | undefined> | undefined;
|
|
179
|
+
error?: string | undefined;
|
|
180
|
+
stop_hook_active?: boolean | undefined;
|
|
181
|
+
last_assistant_message?: string | undefined;
|
|
182
|
+
notification_type?: "task_completed" | "task_failed" | undefined;
|
|
183
|
+
};
|
|
184
|
+
export declare function bindCommandHooks(hooks: readonly CommandHook[], context: CommandHookContext): HookRegistration[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PluginSnapshot, type SessionPlugin } from "../../coding-agent/src/index.js";
|
|
2
|
+
export { bindCommandHooks, type CommandHook, decodeHookOutput, hookInputPayload, parseCommandHook, } from "./command-hooks.js";
|
|
3
|
+
/** Import reads data only. No module import, installation scripts or hooks run here. */
|
|
4
|
+
export declare function importLocalPlugin(source: string, storage: string): Promise<PluginSnapshot>;
|
|
5
|
+
export declare function isExternalPlugin(snapshot: PluginSnapshot): boolean;
|
|
6
|
+
export declare function assertExternalPlugin(snapshot: PluginSnapshot, storage: string, verifyFiles?: boolean): void;
|
|
7
|
+
export declare function bindExternalPlugin(snapshot: PluginSnapshot, options: {
|
|
8
|
+
storage: string;
|
|
9
|
+
transcriptPath?: string;
|
|
10
|
+
env?: Record<string, string | undefined>;
|
|
11
|
+
}): SessionPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zpi-dev/agent-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.60",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "TypeScript Agent SDK for ZPI with a Claude-compatible public API",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"development": "./src/index.ts",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./host": {
|
|
13
|
+
"development": "./src/host.ts",
|
|
14
|
+
"types": "./dist/host.d.ts",
|
|
15
|
+
"import": "./dist/host.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"NOTICE"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=24 <25"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node ../../scripts/build-agent-sdk.mjs",
|
|
30
|
+
"prepack": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"sharp": "0.35.5",
|
|
34
|
+
"typebox": "1.3.27",
|
|
35
|
+
"openai": "7.19.0",
|
|
36
|
+
"@anthropic-ai/sdk": "0.124.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@zpi-dev/ai": "0.1.60",
|
|
40
|
+
"@zpi-dev/agent": "0.1.60",
|
|
41
|
+
"@zpi-dev/coding-agent": "0.1.60",
|
|
42
|
+
"@zpi-dev/plugin-compat": "0.1.60",
|
|
43
|
+
"yaml": "2.9.1"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/1316151417/zpi.git",
|
|
48
|
+
"directory": "packages/agent-sdk"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "http://101.200.240.206/zpi/docs/features/sdk",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
}
|
|
55
|
+
}
|