@pi-oxide/pi-host-web 0.5.0 → 0.7.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.
Files changed (61) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +2535 -0
  3. package/dist/sdk/agent.d.ts +21 -0
  4. package/dist/sdk/agent.d.ts.map +1 -0
  5. package/dist/sdk/artifacts.d.ts +29 -0
  6. package/dist/sdk/artifacts.d.ts.map +1 -0
  7. package/dist/sdk/context.d.ts +2 -0
  8. package/dist/sdk/context.d.ts.map +1 -0
  9. package/dist/sdk/errors.d.ts +8 -0
  10. package/dist/sdk/errors.d.ts.map +1 -0
  11. package/dist/sdk/events.d.ts +9 -0
  12. package/dist/sdk/events.d.ts.map +1 -0
  13. package/dist/sdk/index.d.ts +16 -0
  14. package/dist/sdk/index.d.ts.map +1 -0
  15. package/dist/sdk/init.d.ts +30 -0
  16. package/dist/sdk/init.d.ts.map +1 -0
  17. package/dist/sdk/internal/engine.d.ts +91 -0
  18. package/dist/sdk/internal/engine.d.ts.map +1 -0
  19. package/dist/sdk/internal/events.d.ts +30 -0
  20. package/dist/sdk/internal/events.d.ts.map +1 -0
  21. package/dist/sdk/internal/logger.d.ts +51 -0
  22. package/dist/sdk/internal/logger.d.ts.map +1 -0
  23. package/dist/sdk/internal/providers/anthropic.d.ts +75 -0
  24. package/dist/sdk/internal/providers/anthropic.d.ts.map +1 -0
  25. package/dist/sdk/internal/providers/openai.d.ts +13 -0
  26. package/dist/sdk/internal/providers/openai.d.ts.map +1 -0
  27. package/dist/sdk/internal/providers/types.d.ts +57 -0
  28. package/dist/sdk/internal/providers/types.d.ts.map +1 -0
  29. package/dist/sdk/internal/stores/indexedDb.d.ts +3 -0
  30. package/dist/sdk/internal/stores/indexedDb.d.ts.map +1 -0
  31. package/dist/sdk/internal/stores/persistence.d.ts +13 -0
  32. package/dist/sdk/internal/stores/persistence.d.ts.map +1 -0
  33. package/dist/sdk/internal/tools/artifact.d.ts +3 -0
  34. package/dist/sdk/internal/tools/artifact.d.ts.map +1 -0
  35. package/dist/sdk/internal/tools/browser.d.ts +19 -0
  36. package/dist/sdk/internal/tools/browser.d.ts.map +1 -0
  37. package/dist/sdk/internal/tools/browserRuntime.d.ts +47 -0
  38. package/dist/sdk/internal/tools/browserRuntime.d.ts.map +1 -0
  39. package/dist/sdk/internal/tools/liveRuntime.d.ts +12 -0
  40. package/dist/sdk/internal/tools/liveRuntime.d.ts.map +1 -0
  41. package/dist/sdk/internal/tools/registry.d.ts +17 -0
  42. package/dist/sdk/internal/tools/registry.d.ts.map +1 -0
  43. package/dist/sdk/internal/tools/service.d.ts +15 -0
  44. package/dist/sdk/internal/tools/service.d.ts.map +1 -0
  45. package/dist/sdk/internal/util/types.d.ts +6 -0
  46. package/dist/sdk/internal/util/types.d.ts.map +1 -0
  47. package/dist/sdk/model.d.ts +16 -0
  48. package/dist/sdk/model.d.ts.map +1 -0
  49. package/dist/sdk/snapshot.d.ts +7 -0
  50. package/dist/sdk/snapshot.d.ts.map +1 -0
  51. package/dist/sdk/stores.d.ts +22 -0
  52. package/dist/sdk/stores.d.ts.map +1 -0
  53. package/dist/sdk/tools.d.ts +32 -0
  54. package/dist/sdk/tools.d.ts.map +1 -0
  55. package/dist/sdk/types.d.ts +200 -0
  56. package/dist/sdk/types.d.ts.map +1 -0
  57. package/package.json +79 -5
  58. package/pi_host_web.d.ts +4 -17
  59. package/pi_host_web.js +1 -13
  60. package/pi_host_web_bg.wasm +0 -0
  61. package/pi_host_web_bg.wasm.d.ts +36 -0
@@ -0,0 +1,12 @@
1
+ import { BrowserConsoleEntry, BrowserElementSnapshot, BrowserPageSnapshot, BrowserRuntime, BrowserToolResult } from './browserRuntime';
2
+ export declare class LiveBrowserRuntime implements BrowserRuntime {
3
+ private logger;
4
+ getPage(): BrowserPageSnapshot;
5
+ evalJs(source: string): unknown;
6
+ querySelector(selector: string): BrowserElementSnapshot | null;
7
+ querySelectorAll(selector: string): BrowserElementSnapshot[];
8
+ click(selector: string): BrowserToolResult;
9
+ type(selector: string, text: string): BrowserToolResult;
10
+ getConsole(): BrowserConsoleEntry[];
11
+ }
12
+ //# sourceMappingURL=liveRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveRuntime.d.ts","sourceRoot":"","sources":["../../../../sdk/internal/tools/liveRuntime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACX,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,MAAM,qBAAqB,CAAC;AAuD7B,qBAAa,kBAAmB,YAAW,cAAc;IACxD,OAAO,CAAC,MAAM,CAAgC;IAE9C,OAAO,IAAI,mBAAmB;IAY9B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK/B,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAM9D,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,EAAE;IAM5D,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB;IAiB1C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB;IA4BvD,UAAU,IAAI,mBAAmB,EAAE;CAKnC"}
@@ -0,0 +1,17 @@
1
+ import { ToolCall, ToolDefinition, ToolResult } from '../../../../pi_host_web.js';
2
+ import { AgentTools } from '../../types';
3
+ import { ArtifactStore } from '../engine';
4
+ export type ToolMap = Record<string, (call: ToolCall) => Promise<ToolResult> | ToolResult>;
5
+ export declare class ToolRegistryBuilder {
6
+ /**
7
+ * Build a WASM ToolMap from AgentTools packs.
8
+ * Artifact tools are wired with the store at build time.
9
+ */
10
+ build(tools: AgentTools[], artifactStore?: ArtifactStore, sessionId?: string): ToolMap;
11
+ /**
12
+ * Convert AgentToolDefinition[] to WASM ToolDefinition[] for the LLM.
13
+ * Uses zod-to-json-schema for Zod schemas; passes plain objects through.
14
+ */
15
+ getLlmTools(tools: AgentTools[]): ToolDefinition[];
16
+ }
17
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../sdk/internal/tools/registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;AAE3F,qBAAa,mBAAmB;IAC/B;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,aAAa,CAAC,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAuEtF;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE;CAiClD"}
@@ -0,0 +1,15 @@
1
+ import { ToolCall, ToolDefinition, ToolResult } from '../../../../pi_host_web.js';
2
+ import { ArtifactStore } from '../engine';
3
+ import { BROWSER_TOOLS } from './browser';
4
+ import { BrowserRuntime } from './browserRuntime';
5
+ /** All artifact tools exposed by the host. */
6
+ export declare const ARTIFACT_TOOLS: ToolDefinition[];
7
+ export type ToolMap = Record<string, (call: ToolCall) => Promise<ToolResult> | ToolResult>;
8
+ export declare function createToolRegistry(runtime: BrowserRuntime): ToolMap;
9
+ /**
10
+ * Create artifact tool handlers that read from the agent store.
11
+ * No host handles required — operates on AgentStore directly.
12
+ */
13
+ export declare function createArtifactToolRegistry(_getHandle: () => number, artifactStore?: ArtifactStore, getSessionId?: () => string | undefined): ToolMap;
14
+ export { BROWSER_TOOLS };
15
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../sdk/internal/tools/service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAuC,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAuD1D,8CAA8C;AAC9C,eAAO,MAAM,cAAc,EAAE,cAAc,EAAqC,CAAC;AAMjF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;AAE3F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAInE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,UAAU,EAAE,MAAM,MAAM,EACxB,aAAa,CAAC,EAAE,aAAa,EAC7B,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GACrC,OAAO,CAyDT;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Type-safe runtime helpers for narrowing `unknown` values. */
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
3
+ export declare function getString(value: unknown, key: string): string | undefined;
4
+ export declare function getNumber(value: unknown, key: string): number | undefined;
5
+ export declare function getBoolean(value: unknown, key: string): boolean | undefined;
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/internal/util/types.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMzE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAM3E"}
@@ -0,0 +1,16 @@
1
+ import { AgentModel } from './types';
2
+ export type { AgentModel } from './types';
3
+ /**
4
+ * Create a custom AgentModel from a user-provided generate function.
5
+ * Useful for wrapping arbitrary LLM providers or mocking in tests.
6
+ */
7
+ export declare function defineModel(config: {
8
+ id?: string;
9
+ contextWindow?: number;
10
+ maxTokens?: number;
11
+ capabilities?: AgentModel["capabilities"];
12
+ generate: AgentModel["generate"];
13
+ generateStream?: AgentModel["generateStream"];
14
+ summarize?: AgentModel["summarize"];
15
+ }): AgentModel;
16
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../sdk/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC1C,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC9C,SAAS,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACpC,GAAG,UAAU,CAeb"}
@@ -0,0 +1,7 @@
1
+ import { AgentSnapshot } from './types';
2
+ export declare class SnapshotSerializer {
3
+ private logger;
4
+ serialize(data: unknown): AgentSnapshot;
5
+ deserialize(snapshot: AgentSnapshot): unknown | null;
6
+ }
7
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../sdk/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,MAAM,CAAyB;IAEvC,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa;IAOvC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;CAUpD"}
@@ -0,0 +1,22 @@
1
+ import { AgentStore } from './types';
2
+ export type { AgentSnapshot, AgentStore } from './types';
3
+ /**
4
+ * Store backed by IndexedDB. Durable across page reloads.
5
+ */
6
+ export declare function indexedDbStore(): AgentStore;
7
+ /**
8
+ * In-memory store. Session data is lost when the page reloads.
9
+ */
10
+ export declare function memoryStore(): AgentStore;
11
+ /**
12
+ * Store backed by localStorage. Simple but limited by storage quotas.
13
+ */
14
+ export declare function localStorageStore(): AgentStore;
15
+ /**
16
+ * Store backed by an HTTP API.
17
+ * Expects endpoints at `${baseUrl}/sessions/${sessionId}`.
18
+ */
19
+ export declare function httpStore(config: {
20
+ baseUrl: string;
21
+ }): AgentStore;
22
+ //# sourceMappingURL=stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../sdk/stores.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAE3C;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAYxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,CAY9C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAkBjE"}
@@ -0,0 +1,32 @@
1
+ import { AgentToolDefinition, AgentTools } from './types';
2
+ /** Structural interface for Zod-compatible schemas without exporting Zod types. */
3
+ export interface ToolInputSchema<Input> {
4
+ parse(data: unknown): Input;
5
+ safeParse(data: unknown): {
6
+ success: true;
7
+ data: Input;
8
+ } | {
9
+ success: false;
10
+ error: unknown;
11
+ };
12
+ _def: {
13
+ typeName?: string;
14
+ };
15
+ }
16
+ export interface ToolConfig<Input, Output> {
17
+ description: string;
18
+ input: ToolInputSchema<Input>;
19
+ run: (input: Input) => Promise<Output> | Output;
20
+ details?: (output: Output) => Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Declare a single tool definition with a Zod schema for input validation.
24
+ * The `name` is filled in by `defineTools()`.
25
+ */
26
+ export declare function tool<Input, Output>(config: ToolConfig<Input, Output>): AgentToolDefinition;
27
+ /**
28
+ * Build a mergeable AgentTools pack from a record of tool definitions.
29
+ * Multiple packs can be composed as an array in AgentConfig.tools.
30
+ */
31
+ export declare function defineTools(tools: Record<string, AgentToolDefinition>): AgentTools;
32
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../sdk/tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElE,mFAAmF;AACnF,MAAM,WAAW,eAAe,CAAC,KAAK;IACrC,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IAC5B,SAAS,CAAC,IAAI,EAAE,OAAO,GACpB;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,KAAK,CAAA;KAAE,GAC9B;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IACtC,IAAI,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACF;AAED,MAAM,WAAW,UAAU,CAAC,KAAK,EAAE,MAAM;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,mBAAmB,CAQ1F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,UAAU,CAalF"}
@@ -0,0 +1,200 @@
1
+ import { AgentArtifact, AgentArtifactRef, ArtifactPolicy, ArtifactSearchQuery, ArtifactSearchResult } from './artifacts';
2
+ export type { AgentArtifact, AgentArtifactRef, ArtifactPolicy, ArtifactSearchQuery, ArtifactSearchResult, } from './artifacts';
3
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
4
+ export interface Logger {
5
+ trace(message: string, context?: Record<string, unknown>): void;
6
+ debug(message: string, context?: Record<string, unknown>): void;
7
+ info(message: string, context?: Record<string, unknown>): void;
8
+ warn(message: string, context?: Record<string, unknown>): void;
9
+ error(message: string, context?: Record<string, unknown>): void;
10
+ }
11
+ export interface AgentConfig {
12
+ sessionId: string;
13
+ model: AgentModel;
14
+ tools?: AgentTools | AgentTools[];
15
+ store?: AgentStore;
16
+ instructions?: string;
17
+ context?: AgentContextPolicy;
18
+ artifacts?: ArtifactPolicy;
19
+ telemetry?: AgentTelemetry;
20
+ logger?: Logger;
21
+ logLevel?: LogLevel;
22
+ prepareToolCalls?: {
23
+ transform?: (call: AgentToolCall) => {
24
+ type: "none";
25
+ } | {
26
+ type: "rewrite_args";
27
+ arguments: unknown;
28
+ } | Promise<{
29
+ type: "none";
30
+ } | {
31
+ type: "rewrite_args";
32
+ arguments: unknown;
33
+ }>;
34
+ permission?: (call: AgentToolCall) => {
35
+ type: "allow";
36
+ } | {
37
+ type: "block";
38
+ reason: string;
39
+ } | Promise<{
40
+ type: "allow";
41
+ } | {
42
+ type: "block";
43
+ reason: string;
44
+ }>;
45
+ };
46
+ }
47
+ export type AgentInput = string | {
48
+ text: string;
49
+ attachments?: AgentAttachment[];
50
+ metadata?: Record<string, unknown>;
51
+ };
52
+ export interface AgentAttachment {
53
+ type: string;
54
+ content: string | Uint8Array;
55
+ mimeType?: string;
56
+ }
57
+ export interface AgentRunOptions {
58
+ signal?: AbortSignal;
59
+ metadata?: Record<string, unknown>;
60
+ }
61
+ export interface AgentRunResult {
62
+ status: "completed" | "aborted" | "failed";
63
+ message?: AgentMessage;
64
+ text: string;
65
+ toolCalls: AgentToolRun[];
66
+ artifacts: AgentArtifactRef[];
67
+ usage?: TokenUsage;
68
+ error?: AgentError;
69
+ }
70
+ export type AgentEventName = "messageStart" | "text" | "messageEnd" | "toolStart" | "toolUpdate" | "toolEnd" | "artifact" | "status" | "done" | "error" | "debug";
71
+ export type AgentEventHandler<E extends AgentEventName> = E extends "messageStart" ? (message: AgentMessage) => void : E extends "text" ? (delta: string) => void : E extends "messageEnd" ? (message: AgentMessage) => void : E extends "toolStart" ? (tool: AgentToolRun) => void : E extends "toolUpdate" ? (tool: AgentToolRun) => void : E extends "toolEnd" ? (tool: AgentToolRun) => void : E extends "artifact" ? (artifact: AgentArtifactRef) => void : E extends "status" ? (status: AgentStatus) => void : E extends "done" ? (result: AgentRunResult) => void : E extends "error" ? (error: AgentError) => void : E extends "debug" ? (event: unknown) => void : never;
72
+ export interface AgentMessage {
73
+ id: string;
74
+ role: "user" | "assistant" | "tool_result";
75
+ content: AgentContentBlock[];
76
+ timestamp?: number;
77
+ tool_call_id?: string;
78
+ }
79
+ export type AgentContentBlock = {
80
+ type: "text";
81
+ text: string;
82
+ } | {
83
+ type: "tool_call";
84
+ id: string;
85
+ name: string;
86
+ arguments: unknown;
87
+ } | {
88
+ type: "image";
89
+ mimeType: string;
90
+ data: string;
91
+ } | {
92
+ type: "file";
93
+ mimeType: string;
94
+ data: string;
95
+ };
96
+ export interface AgentToolRun {
97
+ id: string;
98
+ name: string;
99
+ title?: string;
100
+ input: unknown;
101
+ output?: unknown;
102
+ status: "running" | "completed" | "failed" | "cancelled";
103
+ startedAt: number;
104
+ endedAt?: number;
105
+ error?: AgentError;
106
+ }
107
+ export type AgentToolCall = {
108
+ id: string;
109
+ name: string;
110
+ arguments: unknown;
111
+ };
112
+ export interface AgentStatus {
113
+ state: "idle" | "loading" | "thinking" | "calling_model" | "running_tool" | "saving" | "completed" | "aborted" | "failed";
114
+ message?: string;
115
+ }
116
+ export interface AgentModel {
117
+ id?: string;
118
+ contextWindow?: number;
119
+ maxTokens?: number;
120
+ capabilities?: {
121
+ vision?: boolean;
122
+ jsonMode?: boolean;
123
+ functionCalling?: boolean;
124
+ streaming?: boolean;
125
+ };
126
+ generate(request: ModelRequest): Promise<ModelResponse>;
127
+ generateStream?(request: ModelRequest, signal?: AbortSignal): AsyncIterable<ModelEvent>;
128
+ summarize?(messages: AgentMessage[], signal?: AbortSignal): Promise<string>;
129
+ }
130
+ export interface ModelRequest {
131
+ instructions: string;
132
+ messages: AgentMessage[];
133
+ tools: AgentToolDefinition[];
134
+ signal?: AbortSignal;
135
+ metadata?: Record<string, unknown>;
136
+ }
137
+ export interface ModelResponse {
138
+ content: AgentContentBlock[];
139
+ stopReason: "end" | "tool_call" | "length" | "error";
140
+ usage?: TokenUsage;
141
+ model?: string;
142
+ raw?: unknown;
143
+ }
144
+ export interface ModelEvent {
145
+ type: "start" | "text_delta" | "tool_call_delta" | "done";
146
+ payload: unknown;
147
+ }
148
+ export interface AgentTools {
149
+ definitions: AgentToolDefinition[];
150
+ getHandler(name: string): ((input: unknown) => Promise<unknown> | unknown) | null;
151
+ }
152
+ export interface AgentToolDefinition {
153
+ name: string;
154
+ description: string;
155
+ inputSchema: unknown;
156
+ run: (input: unknown) => Promise<unknown> | unknown;
157
+ details?: (output: unknown) => Record<string, unknown>;
158
+ }
159
+ export interface AgentStore {
160
+ loadSession(sessionId: string): Promise<AgentSnapshot | null>;
161
+ saveSession(sessionId: string, snapshot: AgentSnapshot): Promise<void>;
162
+ saveArtifact?(sessionId: string, artifact: AgentArtifact): Promise<void>;
163
+ loadArtifact?(sessionId: string, artifactId: string): Promise<AgentArtifact | null>;
164
+ searchArtifacts?(sessionId: string, query: ArtifactSearchQuery): Promise<ArtifactSearchResult[]>;
165
+ }
166
+ export interface AgentSnapshot {
167
+ version: number;
168
+ data: unknown;
169
+ }
170
+ export interface AgentContextPolicy {
171
+ maxTokens?: number;
172
+ toolResultLimit?: number;
173
+ summarize?: boolean | AgentSummarizer;
174
+ }
175
+ export interface AgentSummarizer {
176
+ summarize(messages: AgentMessage[]): Promise<string>;
177
+ }
178
+ export interface AgentTelemetry {
179
+ onEvent?(event: {
180
+ type: string;
181
+ payload: unknown;
182
+ }): void;
183
+ onMetric?(name: string, value: number, metadata?: Record<string, unknown>): void;
184
+ }
185
+ export interface AgentError {
186
+ code: "model_auth_failed" | "model_rate_limited" | "model_unavailable" | "tool_input_invalid" | "tool_failed" | "tool_duplicate" | "store_load_failed" | "store_save_failed" | "store_artifact_unsupported" | "snapshot_invalid" | "aborted" | "internal_error" | "agent_disposed" | "agent_busy" | "agent_not_initialized";
187
+ message: string;
188
+ cause?: unknown;
189
+ recoverable: boolean;
190
+ metadata?: Record<string, unknown>;
191
+ }
192
+ export interface TokenUsage {
193
+ input: number;
194
+ output: number;
195
+ cache_read: number;
196
+ cache_write: number;
197
+ total_tokens: number;
198
+ }
199
+ export type Unsubscribe = () => void;
200
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../sdk/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,MAAM;IACtB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAChE;AA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AAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC"}
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.5.0",
8
+ "version": "0.7.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -13,12 +13,86 @@
13
13
  },
14
14
  "files": [
15
15
  "pi_host_web_bg.wasm",
16
+ "pi_host_web_bg.wasm.d.ts",
16
17
  "pi_host_web.js",
17
- "pi_host_web.d.ts"
18
+ "pi_host_web.d.ts",
19
+ "README.md",
20
+ "LICENSE",
21
+ "dist/index.d.ts",
22
+ "dist/index.js",
23
+ "dist/sdk/agent.d.ts",
24
+ "dist/sdk/agent.d.ts.map",
25
+ "dist/sdk/artifacts.d.ts",
26
+ "dist/sdk/artifacts.d.ts.map",
27
+ "dist/sdk/context.d.ts",
28
+ "dist/sdk/context.d.ts.map",
29
+ "dist/sdk/errors.d.ts",
30
+ "dist/sdk/errors.d.ts.map",
31
+ "dist/sdk/events.d.ts",
32
+ "dist/sdk/events.d.ts.map",
33
+ "dist/sdk/index.d.ts",
34
+ "dist/sdk/index.d.ts.map",
35
+ "dist/sdk/init.d.ts",
36
+ "dist/sdk/init.d.ts.map",
37
+ "dist/sdk/internal/engine.d.ts",
38
+ "dist/sdk/internal/engine.d.ts.map",
39
+ "dist/sdk/internal/events.d.ts",
40
+ "dist/sdk/internal/events.d.ts.map",
41
+ "dist/sdk/internal/logger.d.ts",
42
+ "dist/sdk/internal/logger.d.ts.map",
43
+ "dist/sdk/internal/providers/anthropic.d.ts",
44
+ "dist/sdk/internal/providers/anthropic.d.ts.map",
45
+ "dist/sdk/internal/providers/openai.d.ts",
46
+ "dist/sdk/internal/providers/openai.d.ts.map",
47
+ "dist/sdk/internal/providers/types.d.ts",
48
+ "dist/sdk/internal/providers/types.d.ts.map",
49
+ "dist/sdk/internal/stores/indexedDb.d.ts",
50
+ "dist/sdk/internal/stores/indexedDb.d.ts.map",
51
+ "dist/sdk/internal/stores/persistence.d.ts",
52
+ "dist/sdk/internal/stores/persistence.d.ts.map",
53
+ "dist/sdk/internal/tools/artifact.d.ts",
54
+ "dist/sdk/internal/tools/artifact.d.ts.map",
55
+ "dist/sdk/internal/tools/browser.d.ts",
56
+ "dist/sdk/internal/tools/browser.d.ts.map",
57
+ "dist/sdk/internal/tools/browserRuntime.d.ts",
58
+ "dist/sdk/internal/tools/browserRuntime.d.ts.map",
59
+ "dist/sdk/internal/tools/liveRuntime.d.ts",
60
+ "dist/sdk/internal/tools/liveRuntime.d.ts.map",
61
+ "dist/sdk/internal/tools/registry.d.ts",
62
+ "dist/sdk/internal/tools/registry.d.ts.map",
63
+ "dist/sdk/internal/tools/service.d.ts",
64
+ "dist/sdk/internal/tools/service.d.ts.map",
65
+ "dist/sdk/internal/util/types.d.ts",
66
+ "dist/sdk/internal/util/types.d.ts.map",
67
+ "dist/sdk/model.d.ts",
68
+ "dist/sdk/model.d.ts.map",
69
+ "dist/sdk/snapshot.d.ts",
70
+ "dist/sdk/snapshot.d.ts.map",
71
+ "dist/sdk/stores.d.ts",
72
+ "dist/sdk/stores.d.ts.map",
73
+ "dist/sdk/tools.d.ts",
74
+ "dist/sdk/tools.d.ts.map",
75
+ "dist/sdk/types.d.ts",
76
+ "dist/sdk/types.d.ts.map"
18
77
  ],
19
- "main": "pi_host_web.js",
20
- "types": "pi_host_web.d.ts",
78
+ "main": "dist/index.js",
79
+ "types": "dist/index.d.ts",
21
80
  "sideEffects": [
22
81
  "./snippets/*"
23
- ]
82
+ ],
83
+ "exports": {
84
+ ".": {
85
+ "import": "./dist/index.js",
86
+ "types": "./dist/index.d.ts"
87
+ },
88
+ "./raw": {
89
+ "import": "./pi_host_web.js",
90
+ "types": "./pi_host_web.d.ts"
91
+ },
92
+ "./package.json": "./package.json"
93
+ },
94
+ "dependencies": {
95
+ "zod": "^3.24.0",
96
+ "zod-to-json-schema": "^3.24.0"
97
+ }
24
98
  }
package/pi_host_web.d.ts CHANGED
@@ -176,12 +176,6 @@ 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
-
185
179
  export interface ToolDefinition {
186
180
  name: ToolName;
187
181
  label: string;
@@ -237,7 +231,7 @@ export interface UserMessage {
237
231
  timestamp: number;
238
232
  }
239
233
 
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" };
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" };
241
235
 
242
236
  export type AgentMessage = ({ role: "user" } & UserMessage) | ({ role: "assistant" } & AssistantMessage) | ({ role: "tool_result" } & ToolResultMessage);
243
237
 
@@ -253,7 +247,7 @@ export type ContentDelta = { kind: "text_start" } | { kind: "text_delta"; text:
253
247
 
254
248
  export type ExecutionMode = "parallel" | "sequential";
255
249
 
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 };
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 };
257
251
 
258
252
  export type JsonSchema = Value;
259
253
 
@@ -281,10 +275,6 @@ export type ToolArguments = Value;
281
275
 
282
276
  export type ToolCallId = string;
283
277
 
284
- export type ToolCallPermission = { type: "allow" } | { type: "block"; reason: string };
285
-
286
- export type ToolCallTransform = { type: "none" } | { type: "rewrite_args"; arguments: ToolArguments };
287
-
288
278
  export type ToolDetails = Value;
289
279
 
290
280
  export type ToolName = string;
@@ -322,8 +312,6 @@ export function hostFeedLlmChunk(handle: number, chunk: LlmChunk): TurnResultRes
322
312
 
323
313
  export function hostLlmDone(handle: number, result: LlmResult): TurnResultResult;
324
314
 
325
- export function hostPrepareToolCalls(handle: number, preparations_json: string): TurnResultResult;
326
-
327
315
  export function hostReadArtifact(handle: number, artifact_id: string): string;
328
316
 
329
317
  export function hostReset(handle: number): EmptyResult;
@@ -357,11 +345,11 @@ export interface InitOutput {
357
345
  readonly estimateTokens: (a: any) => any;
358
346
  readonly estimateTokensForText: (a: number, b: number) => any;
359
347
  readonly getHostStatePersistData: (a: number) => any;
348
+ readonly hostReadArtifact: (a: number, b: number, c: number) => [number, number, number, number];
349
+ readonly hostSearchArtifacts: (a: number, b: number, c: number) => [number, number, number];
360
350
  readonly restoreHostState: (a: any) => any;
361
351
  readonly restoreHostStateFromJson: (a: number, b: number) => any;
362
352
  readonly setLogLevel: (a: number, b: number) => void;
363
- readonly hostReadArtifact: (a: number, b: number, c: number) => [number, number, number, number];
364
- readonly hostSearchArtifacts: (a: number, b: number, c: number) => [number, number, number];
365
353
  readonly createHostAgent: (a: any, b: any) => any;
366
354
  readonly destroyHostAgent: (a: number) => any;
367
355
  readonly getHostAgentPersistData: (a: number) => any;
@@ -370,7 +358,6 @@ export interface InitOutput {
370
358
  readonly hostContinueTurn: (a: number) => any;
371
359
  readonly hostFeedLlmChunk: (a: number, b: any) => any;
372
360
  readonly hostLlmDone: (a: number, b: any) => any;
373
- readonly hostPrepareToolCalls: (a: number, b: number, c: number) => any;
374
361
  readonly hostReset: (a: number) => any;
375
362
  readonly hostSteer: (a: number, b: any) => any;
376
363
  readonly hostToolCancelled: (a: number, b: number, c: number, d: any) => any;
package/pi_host_web.js CHANGED
@@ -128,18 +128,6 @@ 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
-
143
131
  /**
144
132
  * @param {number} handle
145
133
  * @param {string} artifact_id
@@ -685,4 +673,4 @@ async function __wbg_init(module_or_path) {
685
673
  return __wbg_finalize_init(instance, module);
686
674
  }
687
675
 
688
- export { __wbg_init as default, initSync };
676
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const createHostState: (a: any) => any;
5
+ export const destroyHostState: (a: number) => any;
6
+ export const estimateTokens: (a: any) => any;
7
+ export const estimateTokensForText: (a: number, b: number) => any;
8
+ export const getHostStatePersistData: (a: number) => any;
9
+ export const hostReadArtifact: (a: number, b: number, c: number) => [number, number, number, number];
10
+ export const hostSearchArtifacts: (a: number, b: number, c: number) => [number, number, number];
11
+ export const restoreHostState: (a: any) => any;
12
+ export const restoreHostStateFromJson: (a: number, b: number) => any;
13
+ export const setLogLevel: (a: number, b: number) => void;
14
+ export const createHostAgent: (a: any, b: any) => any;
15
+ export const destroyHostAgent: (a: number) => any;
16
+ export const getHostAgentPersistData: (a: number) => any;
17
+ export const hostAbort: (a: number) => any;
18
+ export const hostAcceptCompaction: (a: number, b: number, c: number, d: number, e: number) => any;
19
+ export const hostContinueTurn: (a: number) => any;
20
+ export const hostFeedLlmChunk: (a: number, b: any) => any;
21
+ export const hostLlmDone: (a: number, b: any) => any;
22
+ export const hostReset: (a: number) => any;
23
+ export const hostSteer: (a: number, b: any) => any;
24
+ export const hostToolCancelled: (a: number, b: number, c: number, d: any) => any;
25
+ export const hostToolDone: (a: number, b: any, c: any) => any;
26
+ export const hostToolFailed: (a: number, b: any, c: any) => any;
27
+ export const restoreHostAgent: (a: any, b: any) => any;
28
+ export const startTurn: (a: number, b: any) => any;
29
+ export const __wbindgen_malloc: (a: number, b: number) => number;
30
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
32
+ export const __wbindgen_exn_store: (a: number) => void;
33
+ export const __externref_table_alloc: () => number;
34
+ export const __wbindgen_externrefs: WebAssembly.Table;
35
+ export const __externref_table_dealloc: (a: number) => void;
36
+ export const __wbindgen_start: () => void;