@pi-oxide/pi-host-web 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings.d.ts +2 -0
- package/dist/index-C8phwA2v.js +867 -0
- package/dist/index-CAp51VNq.js +867 -0
- package/dist/index-Is-rTdaY.js +867 -0
- package/dist/index.js +960 -1789
- package/dist/sdk/bindings/host-agent.d.ts +16 -0
- package/dist/sdk/bindings/host-agent.d.ts.map +1 -0
- package/dist/sdk/bindings/index.d.ts +7 -0
- package/dist/sdk/bindings/index.d.ts.map +1 -0
- package/dist/sdk/bindings/index.js +14 -0
- package/dist/sdk/bindings/init.d.ts +30 -0
- package/dist/sdk/bindings/init.d.ts.map +1 -0
- package/dist/sdk/bindings/markers.d.ts +9 -0
- package/dist/sdk/bindings/markers.d.ts.map +1 -0
- package/dist/sdk/bindings/tool-preparation.d.ts +12 -0
- package/dist/sdk/bindings/tool-preparation.d.ts.map +1 -0
- package/dist/sdk/bindings/turn-loop.d.ts +5 -0
- package/dist/sdk/bindings/turn-loop.d.ts.map +1 -0
- package/dist/sdk/bindings/types.d.ts +60 -0
- package/dist/sdk/bindings/types.d.ts.map +1 -0
- package/dist/sdk/init.d.ts +1 -29
- package/dist/sdk/init.d.ts.map +1 -1
- package/dist/sdk/internal/engine.d.ts +3 -90
- package/dist/sdk/internal/engine.d.ts.map +1 -1
- package/dist/sdk/orchestration/agent-engine.d.ts +24 -0
- package/dist/sdk/orchestration/agent-engine.d.ts.map +1 -0
- package/dist/sdk/orchestration/config-builders.d.ts +13 -0
- package/dist/sdk/orchestration/config-builders.d.ts.map +1 -0
- package/dist/sdk/orchestration/model-adapter.d.ts +10 -0
- package/dist/sdk/orchestration/model-adapter.d.ts.map +1 -0
- package/package.json +30 -1
- package/pi_host_web.d.ts +24 -11
- package/pi_host_web.js +12 -0
- package/pi_host_web_bg.wasm +0 -0
- package/pi_host_web_bg.wasm.d.ts +2 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PersistData, AgentEvent as RawAgentEvent, AgentMessage as WasmAgentMessage } from '../../../pi_host_web.js';
|
|
2
|
+
import { AgentConfig } from '../types';
|
|
3
|
+
export declare class HostAgent {
|
|
4
|
+
/** @internal */
|
|
5
|
+
readonly handle: number;
|
|
6
|
+
readonly sessionId: string | undefined;
|
|
7
|
+
constructor(handle: number, sessionId?: string);
|
|
8
|
+
getSessionId(): string | undefined;
|
|
9
|
+
steer(message: WasmAgentMessage): {
|
|
10
|
+
events: RawAgentEvent[];
|
|
11
|
+
};
|
|
12
|
+
getPersistData(): PersistData;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function createHostAgentInstance(config: AgentConfig, sessionState?: PersistData): Promise<HostAgent>;
|
|
16
|
+
//# sourceMappingURL=host-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-agent.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/host-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,WAAW,EAChB,KAAK,UAAU,IAAI,aAAa,EAEhC,KAAK,YAAY,IAAI,gBAAgB,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,qBAAa,SAAS;IACrB,gBAAgB;IAChB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE3B,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAK9C,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG;QAAE,MAAM,EAAE,aAAa,EAAE,CAAA;KAAE;IAK7D,cAAc,IAAI,WAAW;IAK7B,OAAO;CAGP;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAoBjH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ensureInit, HostError, setLogLevel, toolResult, unwrap, } from './init';
|
|
2
|
+
export { HostAgent, createHostAgentInstance } from './host-agent';
|
|
3
|
+
export { runTurnWithHostAgent } from './turn-loop';
|
|
4
|
+
export { buildToolCallPreparations, toolErrorFromUnknown } from './tool-preparation';
|
|
5
|
+
export { processStepMarkers } from './markers';
|
|
6
|
+
export type { AgentRunConfig, ArtifactStore, LlmStream, TurnResult } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,GACN,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { H as o, b as a, d as t, i as e, j as n, p as l, r as u, q as p, u as i, v as H, w as g } from "../../index-C8phwA2v.js";
|
|
2
|
+
export {
|
|
3
|
+
o as HostAgent,
|
|
4
|
+
a as HostError,
|
|
5
|
+
t as buildToolCallPreparations,
|
|
6
|
+
e as createHostAgentInstance,
|
|
7
|
+
n as ensureInit,
|
|
8
|
+
l as processStepMarkers,
|
|
9
|
+
u as runTurnWithHostAgent,
|
|
10
|
+
p as setLogLevel,
|
|
11
|
+
i as toolErrorFromUnknown,
|
|
12
|
+
H as toolResult,
|
|
13
|
+
g as unwrap
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LogLevel } from '../types';
|
|
2
|
+
/** Ensure the WASM module is loaded. Safe to call multiple times. */
|
|
3
|
+
export declare function ensureInit(): Promise<void>;
|
|
4
|
+
/** Set the log level for both JS SDK and WASM core. */
|
|
5
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
6
|
+
export declare class HostError extends Error {
|
|
7
|
+
code: string;
|
|
8
|
+
constructor(code: string, message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare function unwrap(result: {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
data?: unknown;
|
|
13
|
+
error?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
}): unknown;
|
|
18
|
+
/** Build a successful tool result payload. */
|
|
19
|
+
export declare function toolResult(text: string, opts?: {
|
|
20
|
+
terminate?: boolean;
|
|
21
|
+
details?: Record<string, unknown>;
|
|
22
|
+
}): {
|
|
23
|
+
content: Array<{
|
|
24
|
+
type: "text";
|
|
25
|
+
text: string;
|
|
26
|
+
}>;
|
|
27
|
+
terminate?: boolean;
|
|
28
|
+
details?: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/init.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,qEAAqE;AACrE,wBAAsB,UAAU,kBAU/B;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,QAO1C;AAED,qBAAa,SAAU,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAC;gBACD,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKzC;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,GAAG,OAAO,CAKV;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO;aAEnG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;gBAClC,OAAO;cACT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAWlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HostAgent } from './host-agent';
|
|
2
|
+
import { AgentRunConfig } from './types';
|
|
3
|
+
export declare function processStepMarkers(step: {
|
|
4
|
+
markers?: Array<{
|
|
5
|
+
type: string;
|
|
6
|
+
entry_ids?: string[];
|
|
7
|
+
}>;
|
|
8
|
+
}, hostAgent: HostAgent, config: AgentRunConfig): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/markers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAsB,kBAAkB,CACvC,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,EACjE,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ToolCall, ToolCallPreparation, ToolError } from '../../../pi_host_web.js';
|
|
2
|
+
import { Logger } from '../types';
|
|
3
|
+
import { AgentRunConfig } from './types';
|
|
4
|
+
export declare function toolErrorFromUnknown(e: unknown): ToolError;
|
|
5
|
+
interface ToolCallPrepResult {
|
|
6
|
+
items: ToolCallPreparation[];
|
|
7
|
+
hadError: boolean;
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildToolCallPreparations(calls: ToolCall[], hooks: AgentRunConfig["prepareToolCalls"], logger: Logger): Promise<ToolCallPrepResult>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=tool-preparation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-preparation.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/tool-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAsBjD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAQ1D;AAED,UAAU,kBAAkB;IAC3B,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,yBAAyB,CAC9C,KAAK,EAAE,QAAQ,EAAE,EACjB,KAAK,EAAE,cAAc,CAAC,kBAAkB,CAAC,EACzC,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,CA2C7B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AgentMessage as WasmAgentMessage } from '../../../pi_host_web.js';
|
|
2
|
+
import { HostAgent } from './host-agent';
|
|
3
|
+
import { AgentRunConfig, TurnResult } from './types';
|
|
4
|
+
export declare function runTurnWithHostAgent(hostAgent: HostAgent, message: WasmAgentMessage, config: AgentRunConfig): Promise<TurnResult>;
|
|
5
|
+
//# sourceMappingURL=turn-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-loop.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/turn-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAWN,KAAK,YAAY,IAAI,gBAAgB,EACrC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D,wBAAsB,oBAAoB,CACzC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,UAAU,CAAC,CA4LrB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AgentEvent as RawAgentEvent, LlmChunk, LlmContext, LlmResult, PersistData, ToolCall, ToolDefinition, AgentMessage as WasmAgentMessage } from '../../../pi_host_web.js';
|
|
2
|
+
import { Logger } from '../types';
|
|
3
|
+
export interface ArtifactStore {
|
|
4
|
+
save(sessionId: string, artifactId: string, content: string): Promise<void>;
|
|
5
|
+
load(sessionId: string, artifactId: string): Promise<string | null>;
|
|
6
|
+
search(sessionId: string, query: string): Promise<Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
snippet: string;
|
|
9
|
+
match_count: number;
|
|
10
|
+
}>>;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentRunConfig {
|
|
13
|
+
llm: {
|
|
14
|
+
call(context: LlmContext, signal?: AbortSignal): Promise<LlmStream> | LlmStream;
|
|
15
|
+
summarize?(messages: WasmAgentMessage[], signal?: AbortSignal): Promise<string>;
|
|
16
|
+
};
|
|
17
|
+
tools: Record<string, (call: ToolCall) => Promise<import('../../pi_host_web.js').ToolResult> | import('../../pi_host_web.js').ToolResult>;
|
|
18
|
+
llmTools?: ToolDefinition[];
|
|
19
|
+
onEvent?: (event: RawAgentEvent) => void;
|
|
20
|
+
onMarkers?: (markers: Array<{
|
|
21
|
+
type: string;
|
|
22
|
+
entry_ids?: string[];
|
|
23
|
+
}>) => void;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
onPersist?: (data: PersistData) => Promise<void>;
|
|
26
|
+
artifactStore?: ArtifactStore;
|
|
27
|
+
logger?: Logger;
|
|
28
|
+
prepareToolCalls?: {
|
|
29
|
+
transform?: (call: ToolCall) => {
|
|
30
|
+
type: "none";
|
|
31
|
+
} | {
|
|
32
|
+
type: "rewrite_args";
|
|
33
|
+
arguments: unknown;
|
|
34
|
+
} | Promise<{
|
|
35
|
+
type: "none";
|
|
36
|
+
} | {
|
|
37
|
+
type: "rewrite_args";
|
|
38
|
+
arguments: unknown;
|
|
39
|
+
}>;
|
|
40
|
+
permission?: (call: ToolCall) => {
|
|
41
|
+
type: "allow";
|
|
42
|
+
} | {
|
|
43
|
+
type: "block";
|
|
44
|
+
reason: string;
|
|
45
|
+
} | Promise<{
|
|
46
|
+
type: "allow";
|
|
47
|
+
} | {
|
|
48
|
+
type: "block";
|
|
49
|
+
reason: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface LlmStream {
|
|
54
|
+
chunks: AsyncIterable<LlmChunk>;
|
|
55
|
+
result: Promise<LlmResult>;
|
|
56
|
+
}
|
|
57
|
+
export interface TurnResult {
|
|
58
|
+
aborted: boolean;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../sdk/bindings/types.ts"],"names":[],"mappings":"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"}
|
package/dist/sdk/init.d.ts
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Ensure the WASM module is loaded. Safe to call multiple times. */
|
|
3
|
-
export declare function ensureInit(): Promise<void>;
|
|
4
|
-
/** Set the log level for both JS SDK and WASM core. */
|
|
5
|
-
export declare function setLogLevel(level: LogLevel): void;
|
|
6
|
-
export declare class HostError extends Error {
|
|
7
|
-
code: string;
|
|
8
|
-
constructor(code: string, message: string);
|
|
9
|
-
}
|
|
10
|
-
export declare function unwrap(result: {
|
|
11
|
-
ok: boolean;
|
|
12
|
-
data?: unknown;
|
|
13
|
-
error?: {
|
|
14
|
-
code: string;
|
|
15
|
-
message: string;
|
|
16
|
-
};
|
|
17
|
-
}): unknown;
|
|
18
|
-
/** Build a successful tool result payload. */
|
|
19
|
-
export declare function toolResult(text: string, opts?: {
|
|
20
|
-
terminate?: boolean;
|
|
21
|
-
details?: Record<string, unknown>;
|
|
22
|
-
}): {
|
|
23
|
-
content: Array<{
|
|
24
|
-
type: "text";
|
|
25
|
-
text: string;
|
|
26
|
-
}>;
|
|
27
|
-
terminate?: boolean;
|
|
28
|
-
details?: Record<string, unknown>;
|
|
29
|
-
};
|
|
1
|
+
export { ensureInit, HostError, setLogLevel, toolResult, unwrap, } from './bindings/init';
|
|
30
2
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/sdk/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../sdk/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../sdk/init.ts"],"names":[],"mappings":"AACA,OAAO,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,GACN,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,91 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
save(sessionId: string, artifactId: string, content: string): Promise<void>;
|
|
5
|
-
load(sessionId: string, artifactId: string): Promise<string | null>;
|
|
6
|
-
search(sessionId: string, query: string): Promise<Array<{
|
|
7
|
-
id: string;
|
|
8
|
-
snippet: string;
|
|
9
|
-
match_count: number;
|
|
10
|
-
}>>;
|
|
11
|
-
}
|
|
12
|
-
export interface AgentRunConfig {
|
|
13
|
-
llm: {
|
|
14
|
-
call(context: LlmContext, signal?: AbortSignal): Promise<LlmStream> | LlmStream;
|
|
15
|
-
summarize?(messages: WasmAgentMessage[], signal?: AbortSignal): Promise<string>;
|
|
16
|
-
};
|
|
17
|
-
tools: Record<string, (call: ToolCall) => Promise<ToolResult> | ToolResult>;
|
|
18
|
-
llmTools?: ToolDefinition[];
|
|
19
|
-
onEvent?: (event: RawAgentEvent) => void;
|
|
20
|
-
onMarkers?: (markers: Array<{
|
|
21
|
-
type: string;
|
|
22
|
-
entry_ids?: string[];
|
|
23
|
-
}>) => void;
|
|
24
|
-
signal?: AbortSignal;
|
|
25
|
-
onPersist?: (data: PersistData) => Promise<void>;
|
|
26
|
-
artifactStore?: ArtifactStore;
|
|
27
|
-
logger?: Logger;
|
|
28
|
-
prepareToolCalls?: {
|
|
29
|
-
transform?: (call: ToolCall) => {
|
|
30
|
-
type: "none";
|
|
31
|
-
} | {
|
|
32
|
-
type: "rewrite_args";
|
|
33
|
-
arguments: unknown;
|
|
34
|
-
} | Promise<{
|
|
35
|
-
type: "none";
|
|
36
|
-
} | {
|
|
37
|
-
type: "rewrite_args";
|
|
38
|
-
arguments: unknown;
|
|
39
|
-
}>;
|
|
40
|
-
permission?: (call: ToolCall) => {
|
|
41
|
-
type: "allow";
|
|
42
|
-
} | {
|
|
43
|
-
type: "block";
|
|
44
|
-
reason: string;
|
|
45
|
-
} | Promise<{
|
|
46
|
-
type: "allow";
|
|
47
|
-
} | {
|
|
48
|
-
type: "block";
|
|
49
|
-
reason: string;
|
|
50
|
-
}>;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export interface LlmStream {
|
|
54
|
-
chunks: AsyncIterable<LlmChunk>;
|
|
55
|
-
result: Promise<LlmResult>;
|
|
56
|
-
}
|
|
57
|
-
export interface TurnResult {
|
|
58
|
-
aborted: boolean;
|
|
59
|
-
}
|
|
60
|
-
export declare class HostAgent {
|
|
61
|
-
/** @internal */
|
|
62
|
-
readonly handle: number;
|
|
63
|
-
readonly sessionId: string | undefined;
|
|
64
|
-
constructor(handle: number, sessionId?: string);
|
|
65
|
-
getSessionId(): string | undefined;
|
|
66
|
-
steer(message: WasmAgentMessage): {
|
|
67
|
-
events: RawAgentEvent[];
|
|
68
|
-
};
|
|
69
|
-
getPersistData(): PersistData;
|
|
70
|
-
destroy(): void;
|
|
71
|
-
}
|
|
72
|
-
export declare function createHostAgentInstance(config: AgentConfig, sessionState?: PersistData): Promise<HostAgent>;
|
|
73
|
-
export declare function runTurnWithHostAgent(hostAgent: HostAgent, message: WasmAgentMessage, config: AgentRunConfig): Promise<TurnResult>;
|
|
74
|
-
export declare function createEngineAgent(config: AgentConfig, _callbacks: {
|
|
75
|
-
onEvent: (event: {
|
|
76
|
-
type: string;
|
|
77
|
-
payload: unknown;
|
|
78
|
-
}) => void;
|
|
79
|
-
onStatus: (status: AgentStatus) => void;
|
|
80
|
-
}): Promise<HostAgent>;
|
|
81
|
-
export declare function destroyEngineAgent(hostAgent: HostAgent): void;
|
|
82
|
-
export declare function runAgentTurn(hostAgent: HostAgent, config: AgentConfig, input: string | AgentInput, options: AgentRunOptions | undefined, signal: AbortSignal, callbacks: {
|
|
83
|
-
onEvent: (event: {
|
|
84
|
-
type: string;
|
|
85
|
-
payload: unknown;
|
|
86
|
-
}) => void;
|
|
87
|
-
onStatus: (status: AgentStatus) => void;
|
|
88
|
-
}): Promise<AgentRunResult>;
|
|
89
|
-
export declare function steerAgent(hostAgent: HostAgent, input: string | AgentInput): Promise<void>;
|
|
90
|
-
export declare function resetAgentState(hostAgent: HostAgent): Promise<void>;
|
|
1
|
+
/** @deprecated Import from `../orchestration/agent-engine.ts` instead. */
|
|
2
|
+
export { createEngineAgent, createHostAgentInstance, destroyEngineAgent, HostAgent, resetAgentState, runAgentTurn, runTurnWithHostAgent, steerAgent, } from '../orchestration/agent-engine';
|
|
3
|
+
export type { AgentRunConfig, LlmStream, TurnResult } from '../bindings/types';
|
|
91
4
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../sdk/internal/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../sdk/internal/engine.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,UAAU,GACV,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HostAgent } from '../bindings/host-agent';
|
|
2
|
+
import { AgentConfig, AgentInput, AgentRunOptions, AgentRunResult, AgentStatus } from '../types';
|
|
3
|
+
export type { HostAgent } from '../bindings/host-agent';
|
|
4
|
+
export type { AgentRunConfig, LlmStream, TurnResult } from '../bindings/types';
|
|
5
|
+
export { createHostAgentInstance } from '../bindings/host-agent';
|
|
6
|
+
export { runTurnWithHostAgent } from '../bindings/turn-loop';
|
|
7
|
+
export declare function createEngineAgent(config: AgentConfig, _callbacks: {
|
|
8
|
+
onEvent: (event: {
|
|
9
|
+
type: string;
|
|
10
|
+
payload: unknown;
|
|
11
|
+
}) => void;
|
|
12
|
+
onStatus: (status: AgentStatus) => void;
|
|
13
|
+
}): Promise<HostAgent>;
|
|
14
|
+
export declare function destroyEngineAgent(hostAgent: HostAgent): void;
|
|
15
|
+
export declare function runAgentTurn(hostAgent: HostAgent, config: AgentConfig, input: string | AgentInput, options: AgentRunOptions | undefined, signal: AbortSignal, callbacks: {
|
|
16
|
+
onEvent: (event: {
|
|
17
|
+
type: string;
|
|
18
|
+
payload: unknown;
|
|
19
|
+
}) => void;
|
|
20
|
+
onStatus: (status: AgentStatus) => void;
|
|
21
|
+
}): Promise<AgentRunResult>;
|
|
22
|
+
export declare function steerAgent(hostAgent: HostAgent, input: string | AgentInput): Promise<void>;
|
|
23
|
+
export declare function resetAgentState(hostAgent: HostAgent): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=agent-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-engine.d.ts","sourceRoot":"","sources":["../../../sdk/orchestration/agent-engine.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAK/E,OAAO,KAAK,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,MAAM,aAAa,CAAC;AAarB,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE;IACX,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,GACC,OAAO,CAAC,SAAS,CAAC,CAkBpB;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAE7D;AAED,wBAAsB,YAAY,CACjC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,OAAO,EAAE,eAAe,GAAG,SAAS,EACpC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE;IACV,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,GACC,OAAO,CAAC,cAAc,CAAC,CAgHzB;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhG;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContextProjectionBudget, Model, AgentMessage as WasmAgentMessage } from '../../../pi_host_web.js';
|
|
2
|
+
import { AgentConfig, AgentInput, AgentMessage, AgentModel, AgentTools } from '../types';
|
|
3
|
+
import { ArtifactStore } from '../bindings/types';
|
|
4
|
+
export declare function normalizeTools(tools: AgentTools | AgentTools[] | undefined): AgentTools[];
|
|
5
|
+
export declare function buildContextBudget(context?: import('../types.ts').AgentContextPolicy): ContextProjectionBudget;
|
|
6
|
+
export declare function buildModelOptions(model: AgentModel): Model;
|
|
7
|
+
export declare function buildArtifactStore(config: AgentConfig): ArtifactStore | undefined;
|
|
8
|
+
export declare function mergeMetadata(input: string | AgentInput, runMetadata?: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
9
|
+
export declare function buildUserMessage(input: string | AgentInput): WasmAgentMessage;
|
|
10
|
+
export declare function convertWasmMessagesToAgentMessages(messages: WasmAgentMessage[]): AgentMessage[];
|
|
11
|
+
declare function stableMessageId(msg: WasmAgentMessage): string;
|
|
12
|
+
export { stableMessageId };
|
|
13
|
+
//# sourceMappingURL=config-builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-builders.d.ts","sourceRoot":"","sources":["../../../sdk/orchestration/config-builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,uBAAuB,EAAE,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtH,OAAO,KAAK,EAEX,WAAW,EACX,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EAEV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,EAAE,CAIzF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,aAAa,EAAE,kBAAkB,GAAG,uBAAuB,CAO9G;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAiB1D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAsCjF;AAED,wBAAgB,aAAa,CAC5B,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAIrC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,CAwB7E;AAED,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,YAAY,EAAE,CAa/F;AAED,iBAAS,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAUtD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AgentMessage as WasmAgentMessage } from '../../../pi_host_web.js';
|
|
2
|
+
import { AgentModel, ModelEvent, ModelResponse, TokenUsage } from '../types';
|
|
3
|
+
import { LlmStream } from '../bindings/types';
|
|
4
|
+
export declare function toWasmStopReason(reason: ModelResponse["stopReason"]): "end_turn" | "tool_use" | "max_tokens" | "error";
|
|
5
|
+
export declare function modelStreamToLlmStream(stream: AsyncIterable<ModelEvent>, signal: AbortSignal, runState: {
|
|
6
|
+
usage?: TokenUsage;
|
|
7
|
+
}): LlmStream;
|
|
8
|
+
export declare function modelResponseToLlmStream(response: ModelResponse, signal: AbortSignal): LlmStream;
|
|
9
|
+
export declare function defaultSummarizer(model: AgentModel, messages: WasmAgentMessage[], signal?: AbortSignal): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=model-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-adapter.d.ts","sourceRoot":"","sources":["../../../sdk/orchestration/model-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgC,YAAY,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAqB,UAAU,EAAE,UAAU,EAAgB,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAiBtD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,CAWtH;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,EACjC,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE;IAAE,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GAC9B,SAAS,CAyHX;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,CA+DhG;AAED,wBAAsB,iBAAiB,CACtC,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Irving Ou <irving@pi-oxide.dev>"
|
|
6
6
|
],
|
|
7
7
|
"description": "WASM host for pi-core. Browser FileSystem Access API, fetch(), JS event loop.",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.9.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -18,12 +18,31 @@
|
|
|
18
18
|
"pi_host_web.d.ts",
|
|
19
19
|
"README.md",
|
|
20
20
|
"LICENSE",
|
|
21
|
+
"dist/bindings.d.ts",
|
|
22
|
+
"dist/index-C8phwA2v.js",
|
|
23
|
+
"dist/index-CAp51VNq.js",
|
|
24
|
+
"dist/index-Is-rTdaY.js",
|
|
21
25
|
"dist/index.d.ts",
|
|
22
26
|
"dist/index.js",
|
|
23
27
|
"dist/sdk/agent.d.ts",
|
|
24
28
|
"dist/sdk/agent.d.ts.map",
|
|
25
29
|
"dist/sdk/artifacts.d.ts",
|
|
26
30
|
"dist/sdk/artifacts.d.ts.map",
|
|
31
|
+
"dist/sdk/bindings/host-agent.d.ts",
|
|
32
|
+
"dist/sdk/bindings/host-agent.d.ts.map",
|
|
33
|
+
"dist/sdk/bindings/index.d.ts",
|
|
34
|
+
"dist/sdk/bindings/index.d.ts.map",
|
|
35
|
+
"dist/sdk/bindings/index.js",
|
|
36
|
+
"dist/sdk/bindings/init.d.ts",
|
|
37
|
+
"dist/sdk/bindings/init.d.ts.map",
|
|
38
|
+
"dist/sdk/bindings/markers.d.ts",
|
|
39
|
+
"dist/sdk/bindings/markers.d.ts.map",
|
|
40
|
+
"dist/sdk/bindings/tool-preparation.d.ts",
|
|
41
|
+
"dist/sdk/bindings/tool-preparation.d.ts.map",
|
|
42
|
+
"dist/sdk/bindings/turn-loop.d.ts",
|
|
43
|
+
"dist/sdk/bindings/turn-loop.d.ts.map",
|
|
44
|
+
"dist/sdk/bindings/types.d.ts",
|
|
45
|
+
"dist/sdk/bindings/types.d.ts.map",
|
|
27
46
|
"dist/sdk/context.d.ts",
|
|
28
47
|
"dist/sdk/context.d.ts.map",
|
|
29
48
|
"dist/sdk/errors.d.ts",
|
|
@@ -66,6 +85,12 @@
|
|
|
66
85
|
"dist/sdk/internal/util/types.d.ts.map",
|
|
67
86
|
"dist/sdk/model.d.ts",
|
|
68
87
|
"dist/sdk/model.d.ts.map",
|
|
88
|
+
"dist/sdk/orchestration/agent-engine.d.ts",
|
|
89
|
+
"dist/sdk/orchestration/agent-engine.d.ts.map",
|
|
90
|
+
"dist/sdk/orchestration/config-builders.d.ts",
|
|
91
|
+
"dist/sdk/orchestration/config-builders.d.ts.map",
|
|
92
|
+
"dist/sdk/orchestration/model-adapter.d.ts",
|
|
93
|
+
"dist/sdk/orchestration/model-adapter.d.ts.map",
|
|
69
94
|
"dist/sdk/snapshot.d.ts",
|
|
70
95
|
"dist/sdk/snapshot.d.ts.map",
|
|
71
96
|
"dist/sdk/stores.d.ts",
|
|
@@ -85,6 +110,10 @@
|
|
|
85
110
|
"import": "./dist/index.js",
|
|
86
111
|
"types": "./dist/index.d.ts"
|
|
87
112
|
},
|
|
113
|
+
"./bindings": {
|
|
114
|
+
"import": "./dist/sdk/bindings/index.js",
|
|
115
|
+
"types": "./dist/sdk/bindings/index.d.ts"
|
|
116
|
+
},
|
|
88
117
|
"./raw": {
|
|
89
118
|
"import": "./pi_host_web.js",
|
|
90
119
|
"types": "./pi_host_web.d.ts"
|
package/pi_host_web.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ export interface LlmContext {
|
|
|
113
113
|
export interface LlmError {
|
|
114
114
|
code: string;
|
|
115
115
|
message: string;
|
|
116
|
-
details?:
|
|
116
|
+
details?: unknown;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export interface Model {
|
|
@@ -144,8 +144,8 @@ export interface ModelCost {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
export interface PersistData {
|
|
147
|
-
T?:
|
|
148
|
-
A?:
|
|
147
|
+
T?: unknown[];
|
|
148
|
+
A?: Record<string, unknown>;
|
|
149
149
|
turn_number?: number;
|
|
150
150
|
host_artifacts?: [string, string][];
|
|
151
151
|
budget?: ContextProjectionBudget;
|
|
@@ -176,6 +176,12 @@ export interface ToolCall {
|
|
|
176
176
|
arguments: ToolArguments;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
export interface ToolCallPreparation {
|
|
180
|
+
tool_call_id: ToolCallId;
|
|
181
|
+
transform: ToolCallTransform;
|
|
182
|
+
permission: ToolCallPermission;
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
export interface ToolDefinition {
|
|
180
186
|
name: ToolName;
|
|
181
187
|
label: string;
|
|
@@ -231,7 +237,7 @@ export interface UserMessage {
|
|
|
231
237
|
timestamp: number;
|
|
232
238
|
}
|
|
233
239
|
|
|
234
|
-
export type AgentEvent = { type: "agent_start" } | { type: "agent_end" } | { type: "turn_start" } | { type: "turn_end"; message: AgentMessage; tool_results: ToolResultMessage[] } | { type: "message_start"; message: AgentMessage } | { type: "message_update"; message: AgentMessage; delta: ContentDelta } | { type: "message_end"; message: AgentMessage } | { type: "tool_execution_start"; tool_call_id: ToolCallId; tool_name: ToolName; args?: ToolArguments } | { type: "tool_execution_update"; tool_call_id: ToolCallId; stream: ToolOutputStream; chunk: string; sequence: number; timestamp: number } | { type: "tool_execution_end"; tool_call_id: ToolCallId; result: ToolResult; is_error: boolean } | { type: "tool_execution_cancelled"; tool_call_id: ToolCallId; reason: CancelReason } | { type: "queue_update"; steer: AgentMessage[]; follow_up: AgentMessage[] } | { type: "save_point"; had_pending_writes: boolean } | { type: "settled" };
|
|
240
|
+
export type AgentEvent = { type: "agent_start" } | { type: "agent_end" } | { type: "turn_start" } | { type: "turn_end"; message: AgentMessage; tool_results: ToolResultMessage[] } | { type: "message_start"; message: AgentMessage } | { type: "message_update"; message: AgentMessage; delta: ContentDelta } | { type: "message_end"; message: AgentMessage } | { type: "tool_execution_start"; tool_call_id: ToolCallId; tool_name: ToolName; args?: ToolArguments } | { type: "tool_execution_update"; tool_call_id: ToolCallId; stream: ToolOutputStream; chunk: string; sequence: number; timestamp: number } | { type: "tool_execution_end"; tool_call_id: ToolCallId; tool_name: ToolName; result: ToolResult; args?: ToolArguments; is_error: boolean } | { type: "tool_execution_cancelled"; tool_call_id: ToolCallId; reason: CancelReason } | { type: "queue_update"; steer: AgentMessage[]; follow_up: AgentMessage[] } | { type: "save_point"; had_pending_writes: boolean } | { type: "settled" };
|
|
235
241
|
|
|
236
242
|
export type AgentMessage = ({ role: "user" } & UserMessage) | ({ role: "assistant" } & AssistantMessage) | ({ role: "tool_result" } & ToolResultMessage);
|
|
237
243
|
|
|
@@ -243,15 +249,15 @@ export type ChangeMarkerDto = { type: "compaction_applied" } | { type: "new_arti
|
|
|
243
249
|
|
|
244
250
|
export type Content = ({ type: "text" } & TextContent) | ({ type: "image" } & ImageContent) | ({ type: "tool_call" } & ToolCall);
|
|
245
251
|
|
|
246
|
-
export type ContentDelta = { kind: "text_start" } | { kind: "text_delta"; text: string } | { kind: "text_end" } | { kind: "thinking_start" } | { kind: "thinking_delta"; text: string } | { kind: "thinking_end" } | { kind: "tool_call_start"; tool_call: ToolCall } | { kind: "tool_call_delta"; tool_call_id: ToolCallId; delta:
|
|
252
|
+
export type ContentDelta = { kind: "text_start" } | { kind: "text_delta"; text: string } | { kind: "text_end" } | { kind: "thinking_start" } | { kind: "thinking_delta"; text: string } | { kind: "thinking_end" } | { kind: "tool_call_start"; tool_call: ToolCall } | { kind: "tool_call_delta"; tool_call_id: ToolCallId; delta: Record<string, unknown> } | { kind: "tool_call_end"; tool_call_id: ToolCallId };
|
|
247
253
|
|
|
248
254
|
export type ExecutionMode = "parallel" | "sequential";
|
|
249
255
|
|
|
250
|
-
export type HostDirective = { type: "stream_llm"; context: LlmContext } | { type: "execute_tools"; calls: ToolCall[] } | { type: "cancel_tools"; tool_call_ids: ToolCallId[]; reason: CancelReason } | { type: "persist" } | { type: "summarize"; context: LlmContext } | { type: "finished" } | { type: "wait_for_input"; mode: WaitMode };
|
|
256
|
+
export type HostDirective = { type: "stream_llm"; context: LlmContext } | { type: "prepare_tool_calls"; calls: ToolCall[] } | { type: "execute_tools"; calls: ToolCall[] } | { type: "cancel_tools"; tool_call_ids: ToolCallId[]; reason: CancelReason } | { type: "persist" } | { type: "summarize"; context: LlmContext } | { type: "finished" } | { type: "wait_for_input"; mode: WaitMode };
|
|
251
257
|
|
|
252
|
-
export type JsonSchema =
|
|
258
|
+
export type JsonSchema = Record<string, unknown>;
|
|
253
259
|
|
|
254
|
-
export type LlmChunk = ({ kind: "start" } & {} & AssistantMessage) | { kind: "text_delta"; text: string } | { kind: "thinking_delta"; text: string } | { kind: "tool_call_delta"; tool_call_id: ToolCallId; delta:
|
|
260
|
+
export type LlmChunk = ({ kind: "start" } & {} & AssistantMessage) | { kind: "text_delta"; text: string } | { kind: "thinking_delta"; text: string } | { kind: "tool_call_delta"; tool_call_id: ToolCallId; delta: Record<string, unknown> } | { kind: "done" } | { kind: "error"; message: string };
|
|
255
261
|
|
|
256
262
|
export type LlmResult = { Ok: AssistantMessage } | { Err: { error: LlmError; aborted: boolean } };
|
|
257
263
|
|
|
@@ -271,11 +277,15 @@ export type StopReason = "end_turn" | "max_tokens" | "tool_use" | "aborted" | "e
|
|
|
271
277
|
|
|
272
278
|
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
273
279
|
|
|
274
|
-
export type ToolArguments =
|
|
280
|
+
export type ToolArguments = unknown;
|
|
275
281
|
|
|
276
282
|
export type ToolCallId = string;
|
|
277
283
|
|
|
278
|
-
export type
|
|
284
|
+
export type ToolCallPermission = { type: "allow" } | { type: "block"; reason: string };
|
|
285
|
+
|
|
286
|
+
export type ToolCallTransform = { type: "none" } | { type: "rewrite_args"; arguments: ToolArguments };
|
|
287
|
+
|
|
288
|
+
export type ToolDetails = Record<string, unknown>;
|
|
279
289
|
|
|
280
290
|
export type ToolName = string;
|
|
281
291
|
|
|
@@ -312,6 +322,8 @@ export function hostFeedLlmChunk(handle: number, chunk: LlmChunk): TurnResultRes
|
|
|
312
322
|
|
|
313
323
|
export function hostLlmDone(handle: number, result: LlmResult): TurnResultResult;
|
|
314
324
|
|
|
325
|
+
export function hostPrepareToolCalls(handle: number, preparations_json: string): TurnResultResult;
|
|
326
|
+
|
|
315
327
|
export function hostReadArtifact(handle: number, artifact_id: string): string;
|
|
316
328
|
|
|
317
329
|
export function hostReset(handle: number): EmptyResult;
|
|
@@ -349,7 +361,6 @@ export interface InitOutput {
|
|
|
349
361
|
readonly hostSearchArtifacts: (a: number, b: number, c: number) => [number, number, number];
|
|
350
362
|
readonly restoreHostState: (a: any) => any;
|
|
351
363
|
readonly restoreHostStateFromJson: (a: number, b: number) => any;
|
|
352
|
-
readonly setLogLevel: (a: number, b: number) => void;
|
|
353
364
|
readonly createHostAgent: (a: any, b: any) => any;
|
|
354
365
|
readonly destroyHostAgent: (a: number) => any;
|
|
355
366
|
readonly getHostAgentPersistData: (a: number) => any;
|
|
@@ -358,6 +369,7 @@ export interface InitOutput {
|
|
|
358
369
|
readonly hostContinueTurn: (a: number) => any;
|
|
359
370
|
readonly hostFeedLlmChunk: (a: number, b: any) => any;
|
|
360
371
|
readonly hostLlmDone: (a: number, b: any) => any;
|
|
372
|
+
readonly hostPrepareToolCalls: (a: number, b: number, c: number) => any;
|
|
361
373
|
readonly hostReset: (a: number) => any;
|
|
362
374
|
readonly hostSteer: (a: number, b: any) => any;
|
|
363
375
|
readonly hostToolCancelled: (a: number, b: number, c: number, d: any) => any;
|
|
@@ -365,6 +377,7 @@ export interface InitOutput {
|
|
|
365
377
|
readonly hostToolFailed: (a: number, b: any, c: any) => any;
|
|
366
378
|
readonly restoreHostAgent: (a: any, b: any) => any;
|
|
367
379
|
readonly startTurn: (a: number, b: any) => any;
|
|
380
|
+
readonly setLogLevel: (a: number, b: number) => void;
|
|
368
381
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
369
382
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
370
383
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
package/pi_host_web.js
CHANGED
|
@@ -128,6 +128,18 @@ export function hostLlmDone(handle, result) {
|
|
|
128
128
|
return ret;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @param {number} handle
|
|
133
|
+
* @param {string} preparations_json
|
|
134
|
+
* @returns {TurnResultResult}
|
|
135
|
+
*/
|
|
136
|
+
export function hostPrepareToolCalls(handle, preparations_json) {
|
|
137
|
+
const ptr0 = passStringToWasm0(preparations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len0 = WASM_VECTOR_LEN;
|
|
139
|
+
const ret = wasm.hostPrepareToolCalls(handle, ptr0, len0);
|
|
140
|
+
return ret;
|
|
141
|
+
}
|
|
142
|
+
|
|
131
143
|
/**
|
|
132
144
|
* @param {number} handle
|
|
133
145
|
* @param {string} artifact_id
|
package/pi_host_web_bg.wasm
CHANGED
|
Binary file
|