@howaboua/pi-durable-gippity-voice 0.10.0 → 0.13.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/NOTICE +5 -0
- package/README.md +4 -2
- package/dist/activation.js +2108 -989
- package/dist/index.js +2115 -996
- package/dist/internal/voice/agent-observation.d.ts +13 -0
- package/dist/internal/voice/browser-provider.d.ts +65 -0
- package/dist/internal/voice/browser-settings.d.ts +24 -0
- package/dist/internal/voice/handoff-contract.d.ts +28 -0
- package/dist/internal/voice/lan-client-sdk.d.ts +1 -0
- package/dist/internal/voice/lan-listener-proof.d.ts +2 -0
- package/dist/packages/execution/src/invocation-state.d.ts +1 -1
- package/dist/packages/execution/src/invocation.d.ts +79 -2
- package/dist/packages/execution/src/native-tools.d.ts +18 -7
- package/dist/packages/execution/src/nested-call.d.ts +11 -3
- package/dist/packages/execution/src/nested-park.d.ts +9 -0
- package/dist/packages/execution/src/nested-result.d.ts +1 -1
- package/dist/packages/execution/src/tool-contract.d.ts +10 -3
- package/dist/packages/execution/src/tool-namespaces.d.ts +31 -0
- package/dist/packages/execution/src/tool-origin.d.ts +9 -1
- package/dist/packages/gippity-voice/src/controller.d.ts +10 -3
- package/dist/packages/gippity-voice/src/host.d.ts +6 -0
- package/dist/packages/gippity-voice/src/index.d.ts +2 -1
- package/dist/packages/gippity-voice/src/voice/browser-reservation.d.ts +30 -0
- package/dist/packages/gippity-voice/src/voice/conversation/peer.d.ts +6 -0
- package/dist/packages/gippity-voice/src/voice/conversation/public-turns.d.ts +2 -1
- package/dist/packages/gippity-voice/src/voice/conversation/session.d.ts +2 -0
- package/dist/packages/gippity-voice/src/voice/handoff-departure.d.ts +5 -0
- package/dist/packages/gippity-voice/src/voice/handoff-peer.d.ts +12 -0
- package/dist/packages/gippity-voice/src/voice/handoff-wire.d.ts +1 -1
- package/dist/packages/gippity-voice/src/voice/helper-protocol.d.ts +35 -0
- package/dist/packages/gippity-voice/src/voice/lan/browser-clients.d.ts +2 -1
- package/dist/packages/gippity-voice/src/voice/lan/browser-connections.d.ts +17 -0
- package/dist/packages/gippity-voice/src/voice/lan/browser-peer.d.ts +4 -0
- package/dist/packages/gippity-voice/src/voice/lan/browser-session.d.ts +10 -4
- package/dist/packages/gippity-voice/src/voice/lan/pcm-bridge.d.ts +25 -0
- package/dist/packages/gippity-voice/src/voice/lan/playback-drain.d.ts +8 -0
- package/dist/packages/gippity-voice/src/voice/lan/protocol.d.ts +4 -0
- package/dist/packages/gippity-voice/src/voice/lan/server.d.ts +5 -3
- package/dist/packages/gippity-voice/src/voice/lan/takeover.d.ts +2 -3
- package/dist/packages/gippity-voice/src/voice/lan/unified-settings.d.ts +3 -0
- package/dist/packages/gippity-voice/src/voice/realtime-auth.d.ts +3 -2
- package/dist/packages/gippity-voice/src/voice/turns.d.ts +2 -1
- package/dist/voice/bin/darwin-arm64/pi-codex-voice +0 -0
- package/dist/voice/bin/darwin-x64/pi-codex-voice +0 -0
- package/dist/voice/bin/linux-arm64/pi-codex-voice +0 -0
- package/dist/voice/bin/linux-x64/pi-codex-voice +0 -0
- package/dist/voice/bin/win32-arm64/pi-codex-voice.exe +0 -0
- package/dist/voice/bin/win32-x64/pi-codex-voice.exe +0 -0
- package/package.json +10 -9
- package/src/voice/rust/src/audio.rs +2 -2
- package/src/voice/rust/src/playout.rs +68 -8
- package/src/voice/rust/src/protocol.rs +43 -1
- package/src/voice/rust/src/v3_media.rs +138 -31
- /package/dist/{packages/gippity-voice/src → internal/voice}/deferred.d.ts +0 -0
- /package/dist/{packages/gippity-voice/src/voice/lan/activity.d.ts → internal/voice/lan-activity.d.ts} +0 -0
- /package/dist/{packages/gippity-voice/src/voice/lan/draft.d.ts → internal/voice/lan-draft.d.ts} +0 -0
- /package/dist/{packages/gippity-voice/src/voice/lan → internal/voice}/remote-json.d.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import { type Conversation, type ConversationView, type EntryRecord } from "@earendil-works/pi-durable";
|
|
3
|
+
/** Call-local observation, never replayed as conversation input. */
|
|
4
|
+
export declare function observeVoiceAgent(conversation: Pick<Conversation, "watch" | "entries">, context: Context, callbacks: {
|
|
5
|
+
state(working: boolean): void;
|
|
6
|
+
entry(entry: EntryRecord): void;
|
|
7
|
+
partial(delta: string, working: boolean): void;
|
|
8
|
+
compacting(reason: "overflow" | "threshold"): void;
|
|
9
|
+
failed(error: unknown): void;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
readonly view: ConversationView;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { ConversationId, Harness } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { Pcm24Audio } from "@howaboua/pi-durable-components";
|
|
4
|
+
import type { BrowserVoiceSettings, BrowserVoiceSettingsScope } from "./browser-settings.ts";
|
|
5
|
+
import type { VoiceHandoffChannel } from "./handoff-contract.ts";
|
|
6
|
+
export type BrowserVoiceMode = "voice" | "dictation";
|
|
7
|
+
export type BrowserVoiceProviderId = "openai" | "gemini" | "grok";
|
|
8
|
+
export interface BrowserVoiceAudio extends Pcm24Audio {
|
|
9
|
+
/** Reserve this browser's playout receipt before irreversibly stopping its producer. */
|
|
10
|
+
finishPlayback?(signal: AbortSignal, seal: () => Promise<void>): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface BrowserVoiceSession {
|
|
13
|
+
state(): {
|
|
14
|
+
status: string;
|
|
15
|
+
muted: boolean;
|
|
16
|
+
transcript?: string;
|
|
17
|
+
error?: string;
|
|
18
|
+
};
|
|
19
|
+
mute(muted: boolean): void;
|
|
20
|
+
send(text: string): Promise<void>;
|
|
21
|
+
finish(): Promise<string>;
|
|
22
|
+
depart?(channel: VoiceHandoffChannel): Promise<void>;
|
|
23
|
+
departBrowser?(channel: VoiceHandoffChannel, context: Context, transfer: BrowserDeparture): Promise<void>;
|
|
24
|
+
/** Release this session only, including any retained media after a handoff. */
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export interface BrowserDeparture {
|
|
28
|
+
authorize(identity: unknown, issue: (proof: {
|
|
29
|
+
port: number;
|
|
30
|
+
token: string;
|
|
31
|
+
}) => Promise<unknown>): Promise<{
|
|
32
|
+
path: string;
|
|
33
|
+
claim: string;
|
|
34
|
+
}>;
|
|
35
|
+
acknowledge(offer: {
|
|
36
|
+
path: string;
|
|
37
|
+
claim: string;
|
|
38
|
+
}, signal: AbortSignal): Promise<void>;
|
|
39
|
+
releaseListener(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface BrowserVoiceProvider {
|
|
42
|
+
/** Claim a provider-owned, single-use prepared arrival, never an ordinary open. */
|
|
43
|
+
resume?(input: Parameters<BrowserVoiceProvider["open"]>[0], arrival: object): Promise<BrowserVoiceSession>;
|
|
44
|
+
arrive?(input: {
|
|
45
|
+
harness: Harness;
|
|
46
|
+
conversationId: ConversationId;
|
|
47
|
+
environmentId: string;
|
|
48
|
+
context: Context;
|
|
49
|
+
audio: BrowserVoiceAudio;
|
|
50
|
+
channel: VoiceHandoffChannel;
|
|
51
|
+
continuity: string;
|
|
52
|
+
}): Promise<BrowserVoiceSession>;
|
|
53
|
+
settings?: {
|
|
54
|
+
read(scope: BrowserVoiceSettingsScope): Promise<BrowserVoiceSettings>;
|
|
55
|
+
write(scope: BrowserVoiceSettingsScope, patch: Record<string, unknown>): Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
open(input: {
|
|
58
|
+
harness: Harness;
|
|
59
|
+
conversationId: ConversationId;
|
|
60
|
+
environmentId: string;
|
|
61
|
+
context: Context;
|
|
62
|
+
mode: BrowserVoiceMode;
|
|
63
|
+
audio: BrowserVoiceAudio;
|
|
64
|
+
}): Promise<BrowserVoiceSession>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Models } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { ExecutionEnv } from "@earendil-works/pi-durable/env";
|
|
3
|
+
type Scalar = string | number | boolean | null;
|
|
4
|
+
export interface BrowserVoiceSetting {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly value: Scalar;
|
|
8
|
+
readonly choices?: readonly {
|
|
9
|
+
value: Scalar;
|
|
10
|
+
label: string;
|
|
11
|
+
}[];
|
|
12
|
+
readonly min?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface BrowserVoiceSettings {
|
|
15
|
+
readonly scope: string;
|
|
16
|
+
readonly fields: readonly BrowserVoiceSetting[];
|
|
17
|
+
}
|
|
18
|
+
export interface BrowserVoiceSettingsScope {
|
|
19
|
+
readonly models: Models;
|
|
20
|
+
readonly environment: ExecutionEnv;
|
|
21
|
+
readonly signal: AbortSignal;
|
|
22
|
+
}
|
|
23
|
+
export declare function setting(name: string, label: string, value: Scalar, list?: readonly Scalar[]): BrowserVoiceSetting;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Pcm24Audio } from "@howaboua/pi-durable-components";
|
|
2
|
+
export type AudioCallbacks = Parameters<Pcm24Audio["start"]>[0];
|
|
3
|
+
/** Host-authenticated, ordered, bounded frames. No transport is silently created. */
|
|
4
|
+
export interface VoiceHandoffChannel {
|
|
5
|
+
send(message: unknown): void;
|
|
6
|
+
onMessage(listener: (message: unknown) => void): () => void;
|
|
7
|
+
onClose(listener: (error: Error) => void): () => void;
|
|
8
|
+
close(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface TransferredVoiceControls {
|
|
11
|
+
readonly inputMuted: boolean;
|
|
12
|
+
setInputMuted(muted: boolean): void;
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
/** Stop/start the selected call without discarding the audio-host binding. */
|
|
15
|
+
stopCall(): Promise<void>;
|
|
16
|
+
startCall(): Promise<void>;
|
|
17
|
+
sendText(text: string): Promise<void>;
|
|
18
|
+
rpc(body: Record<string, unknown>): Promise<unknown>;
|
|
19
|
+
onSessionEvent(listener: (event: string, data: unknown) => void): () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface CapturedHandoff {
|
|
22
|
+
audio: Pcm24Audio;
|
|
23
|
+
inputMuted: boolean;
|
|
24
|
+
alternateVoice: boolean;
|
|
25
|
+
sourceActive(): boolean;
|
|
26
|
+
closed(): void;
|
|
27
|
+
release(callbacks: AudioCallbacks, controls: TransferredVoiceControls): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const lanClientScript: (audioScript: string, listenerPath?: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type JsonRepresentation, type JsonValue } from "@earendil-works/chord";
|
|
1
|
+
import { type JsonRepresentation, type JsonValue } from "@earendil-works/chord/json";
|
|
2
2
|
import { type TaskId, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { ForwardedToolCalls } from "./forwarded-tools.ts";
|
|
4
4
|
type StoredResult = JsonRepresentation<ToolExecutionResult>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Context } from "@earendil-works/chord";
|
|
1
|
+
import { type Context } from "@earendil-works/chord/context";
|
|
2
|
+
import { type JsonValue } from "@earendil-works/chord/json";
|
|
2
3
|
import type { TextContent } from "@earendil-works/pi-ai";
|
|
3
4
|
import { type TaskRuntime, type ToolDiagnostic, type ToolExecutionApi, type ToolExecutionResult, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
5
|
import { OutputBuffer, type OutputLimits } from "./output.ts";
|
|
@@ -6,7 +7,9 @@ import { Progress } from "./progress.ts";
|
|
|
6
7
|
export declare function executionError(code: string, message: string): ToolExecutionResult;
|
|
7
8
|
export declare function errorText(error: unknown): string;
|
|
8
9
|
/** One invocation owns its output, progress commits, environment and child-task API. */
|
|
9
|
-
export declare function createInvocation<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, tool: Pick<ToolRegistration, "outputLimits" | "replay">, context: Context
|
|
10
|
+
export declare function createInvocation<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, tool: Pick<ToolRegistration, "outputLimits" | "replay">, context: Context, resume?: Pick<ToolExecutionApi, "wake" | "checkpoint"> & {
|
|
11
|
+
progress?: Pick<ToolExecutionResult, "details" | "diagnostics">;
|
|
12
|
+
}): {
|
|
10
13
|
/** Resolve the environment after the tracker exists, so environment failures still settle bounded hook results. */
|
|
11
14
|
executionApi(): Promise<ToolExecutionApi>;
|
|
12
15
|
finish(result: ToolExecutionResult): Promise<{
|
|
@@ -24,6 +27,80 @@ export declare function createInvocation<I, S, R, H extends object>(runtime: Tas
|
|
|
24
27
|
content: (import("@earendil-works/pi-ai").ImageContent | TextContent)[];
|
|
25
28
|
}>;
|
|
26
29
|
stop(error: unknown): Promise<void>;
|
|
30
|
+
park(): Promise<{
|
|
31
|
+
progress: {
|
|
32
|
+
readonly output?: ({
|
|
33
|
+
type: "image";
|
|
34
|
+
data: string;
|
|
35
|
+
mimeType: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
textSignature?: string;
|
|
40
|
+
})[];
|
|
41
|
+
readonly structuredOutput?: JsonValue;
|
|
42
|
+
readonly isError?: boolean;
|
|
43
|
+
readonly details?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
44
|
+
[x: string]: string | number | boolean | /*elided*/ any | /*elided*/ any | null;
|
|
45
|
+
} | null)[] | {
|
|
46
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
47
|
+
} | null)[] | {
|
|
48
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
49
|
+
} | null)[] | {
|
|
50
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
51
|
+
} | null)[] | {
|
|
52
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
53
|
+
} | null)[] | {
|
|
54
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
55
|
+
} | null)[] | {
|
|
56
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
57
|
+
} | null)[] | {
|
|
58
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
59
|
+
} | null)[] | {
|
|
60
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
61
|
+
} | null)[] | {
|
|
62
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
63
|
+
} | null)[] | {
|
|
64
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
65
|
+
} | null)[] | {
|
|
66
|
+
[x: string]: string | number | boolean | any | any | null;
|
|
67
|
+
} | null;
|
|
68
|
+
readonly diagnostics?: {
|
|
69
|
+
readonly severity: "info" | "warn" | "error";
|
|
70
|
+
readonly message: string;
|
|
71
|
+
readonly code?: string;
|
|
72
|
+
}[];
|
|
73
|
+
readonly usage?: {
|
|
74
|
+
input: number;
|
|
75
|
+
output: number;
|
|
76
|
+
cacheRead: number;
|
|
77
|
+
cacheWrite: number;
|
|
78
|
+
cacheWrite1h?: number;
|
|
79
|
+
reasoning?: number;
|
|
80
|
+
imageOutput?: number;
|
|
81
|
+
totalTokens: number;
|
|
82
|
+
cost: {
|
|
83
|
+
input: number;
|
|
84
|
+
output: number;
|
|
85
|
+
cacheRead: number;
|
|
86
|
+
cacheWrite: number;
|
|
87
|
+
total: number;
|
|
88
|
+
totalFromProvider?: boolean;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
readonly control?: {
|
|
92
|
+
readonly addTools?: string[];
|
|
93
|
+
readonly terminate?: boolean;
|
|
94
|
+
readonly handoff?: string;
|
|
95
|
+
};
|
|
96
|
+
readonly kind?: never;
|
|
97
|
+
};
|
|
98
|
+
pending: {
|
|
99
|
+
promise: Promise<void>;
|
|
100
|
+
resolve(): void;
|
|
101
|
+
reject(error: unknown): void;
|
|
102
|
+
}[];
|
|
103
|
+
}>;
|
|
27
104
|
limits: OutputLimits;
|
|
28
105
|
output: OutputBuffer;
|
|
29
106
|
progress: Progress;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { type Context } from "@earendil-works/chord";
|
|
2
|
-
import { type JsonObject, type NestedToolExecutionResult, type TaskRuntime } from "@earendil-works/pi-durable";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type Context } from "@earendil-works/chord/context";
|
|
2
|
+
import { type JsonObject, type NestedToolCall, type NestedToolExecutionResult, type TaskRuntime } from "@earendil-works/pi-durable";
|
|
3
|
+
type CallOptions = {
|
|
4
|
+
readonly key?: string;
|
|
5
|
+
readonly progress?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function assertNestedKey(key: string): void;
|
|
8
|
+
export declare function nativeToolCalls<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, callId: string, replay: "safe" | "unsafe" | undefined, resumed: boolean, assertLive: () => void, context: Context): {
|
|
9
|
+
execute: {
|
|
10
|
+
(name: string, args: JsonObject, callContext: Context, options?: CallOptions & {
|
|
11
|
+
readonly wait?: true;
|
|
12
|
+
}): Promise<NestedToolExecutionResult>;
|
|
13
|
+
(name: string, args: JsonObject, callContext: Context, options: CallOptions & {
|
|
14
|
+
readonly wait: false;
|
|
15
|
+
}): Promise<NestedToolCall>;
|
|
16
|
+
};
|
|
17
|
+
drain(): Promise<void>;
|
|
8
18
|
finish(): Promise<void>;
|
|
9
19
|
};
|
|
10
20
|
/** Custom cell callers own native nested slots too, including after recovery. */
|
|
11
21
|
export declare function cleanupNativeCalls<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, context: Context): Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { JsonValue } from "@earendil-works/chord";
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord/json";
|
|
2
2
|
import type { ToolCall } from "@earendil-works/pi-ai";
|
|
3
|
-
import { type Agent, type HookApi, type JsonObject, type TaskId, type TaskRuntime, type ToolExecutionResult, type ToolHookCall, type ToolHooks, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import { type Agent, type HookApi, type JsonObject, type TaskId, type TaskRuntime, type ToolExecutionResult, type ToolHookCall, type ToolHooks, type ToolRegistration, type WakeReason } from "@earendil-works/pi-durable";
|
|
4
4
|
export type NestedInput = {
|
|
5
5
|
name: string;
|
|
6
6
|
arguments: JsonValue;
|
|
@@ -9,10 +9,18 @@ export type NestedInput = {
|
|
|
9
9
|
};
|
|
10
10
|
export type Checkpoint = {
|
|
11
11
|
phase: "call";
|
|
12
|
-
} | {
|
|
12
|
+
} | (NestedIntent & {
|
|
13
13
|
phase: "execute";
|
|
14
|
+
resume?: {
|
|
15
|
+
wake: WakeReason;
|
|
16
|
+
};
|
|
17
|
+
}) | (NestedIntent & {
|
|
18
|
+
phase: "parked";
|
|
19
|
+
});
|
|
20
|
+
export type NestedIntent = {
|
|
14
21
|
arguments: JsonObject;
|
|
15
22
|
replay: "safe" | "unsafe";
|
|
23
|
+
checkpoint?: JsonValue;
|
|
16
24
|
};
|
|
17
25
|
export type Runtime = TaskRuntime<NestedInput, Checkpoint, ToolExecutionResult, Record<string, never>>;
|
|
18
26
|
export declare function nestedCall(runtime: Runtime, input: NestedInput): ToolHookCall;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { JsonObject, ToolHooks, ToolPark, ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import { createInvocation } from "./invocation.ts";
|
|
4
|
+
import type { NestedIntent, Runtime } from "./nested-call.ts";
|
|
5
|
+
export type GateSleep = NonNullable<NonNullable<Awaited<ReturnType<ToolHooks["beforeTool"]>>>["sleep"]>;
|
|
6
|
+
export declare function parkGate(runtime: Runtime, sleep: GateSleep, context: Context): Promise<string | undefined>;
|
|
7
|
+
/** A parked child releases its phase, not its parent cell or its owned work. */
|
|
8
|
+
export declare function parkTool(runtime: Runtime, invocation: ReturnType<typeof createInvocation>, tool: ToolRegistration, args: JsonObject, park: ToolPark, context: Context): Promise<string | undefined>;
|
|
9
|
+
export declare function cancelParkedTool(runtime: Runtime, tool: ToolRegistration | undefined, intent: NestedIntent, context: Context): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ToolCall } from "@earendil-works/pi-ai";
|
|
3
3
|
import { type JsonObject, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
4
4
|
import type { Runtime } from "./nested-call.ts";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type JsonValue } from "@earendil-works/chord";
|
|
2
|
-
import type { TSchema } from "@earendil-works/pi-ai";
|
|
1
|
+
import { type JsonValue } from "@earendil-works/chord/json";
|
|
3
2
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import { type JsToolNamespace } from "./tool-namespaces.ts";
|
|
4
|
+
export declare const nestedToolDiscoveryGuidance = "Tools without a shown call signature: help is required only while their current arguments are unknown. Call with no arguments and read the result before composing an operation. Reuse known arguments without repeating help. Structured discovery uses {}";
|
|
4
5
|
/** Optional runtime presentation and observation policy on an ordinary registration. */
|
|
5
6
|
export interface ExecutionToolHints {
|
|
6
7
|
readonly usage?: string;
|
|
@@ -12,9 +13,13 @@ export interface ExecutionToolHints {
|
|
|
12
13
|
readonly discovery?: "help";
|
|
13
14
|
/** Keep the tool on the provider surface and prohibit calls from execution cells. */
|
|
14
15
|
readonly nativeOnly?: boolean;
|
|
16
|
+
/** Show the native schema; allow named cell calls without listing them in cell discovery. */
|
|
17
|
+
readonly nestedHidden?: boolean;
|
|
15
18
|
}
|
|
16
|
-
export type ExecutionToolRegistration<T extends
|
|
19
|
+
export type ExecutionToolRegistration<T extends object = object, D extends JsonValue = JsonValue> = ToolRegistration<T, D> & {
|
|
17
20
|
readonly executionHints?: ExecutionToolHints;
|
|
21
|
+
/** Older runtimes still invoke the registration by name without this projection. */
|
|
22
|
+
readonly jsNamespace?: JsToolNamespace;
|
|
18
23
|
};
|
|
19
24
|
interface ExecutionToolContract {
|
|
20
25
|
readonly name: string;
|
|
@@ -24,6 +29,8 @@ interface ExecutionToolContract {
|
|
|
24
29
|
readonly inputSchema: JsonValue;
|
|
25
30
|
readonly deferLoading: boolean;
|
|
26
31
|
readonly nativeOnly: boolean;
|
|
32
|
+
readonly nestedHidden: boolean;
|
|
33
|
+
readonly jsNamespace?: JsToolNamespace;
|
|
27
34
|
readonly discovery?: "help";
|
|
28
35
|
readonly yieldTimeMs?: number;
|
|
29
36
|
readonly help: string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { JsonObject } from "@earendil-works/pi-durable";
|
|
2
|
+
interface NamespaceMethod {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
/** Expose this method on a reference-bound namespace and pass it in this argument. */
|
|
5
|
+
readonly bind?: string;
|
|
6
|
+
readonly defaults?: JsonObject;
|
|
7
|
+
}
|
|
8
|
+
export interface JsToolNamespace {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly methods: readonly NamespaceMethod[];
|
|
11
|
+
readonly prompt: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function validateJsToolNamespace(tool: string, namespace: JsToolNamespace): void;
|
|
14
|
+
export declare function jsToolPrompt(contract: {
|
|
15
|
+
readonly nativeOnly: boolean;
|
|
16
|
+
readonly nestedHidden: boolean;
|
|
17
|
+
readonly deferLoading: boolean;
|
|
18
|
+
readonly jsNamespace?: JsToolNamespace;
|
|
19
|
+
readonly prompt: string;
|
|
20
|
+
}): string[];
|
|
21
|
+
export declare function namespaceDefinitions(tools: readonly {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly jsNamespace?: JsToolNamespace;
|
|
24
|
+
}[]): {
|
|
25
|
+
tool: string;
|
|
26
|
+
name: string;
|
|
27
|
+
methods: readonly NamespaceMethod[];
|
|
28
|
+
}[];
|
|
29
|
+
/** Shared guest bootstrap. Aliases are data; only the ordinary tool dispatcher is callable. */
|
|
30
|
+
export declare const installToolNamespacesSource = "(tools, definitions) => {\n const namespaces = Object.create(null);\n const binders = Object.create(null);\n let active = true;\n const add = (target, key, value) => {\n if (Object.hasOwn(target, key)) throw new Error(\"Duplicate tool namespace member: \" + key);\n target[key] = value;\n };\n const object = (value) => value !== null && typeof value === \"object\" && !Array.isArray(value);\n for (const { tool, name, methods } of definitions) {\n const namespace = namespaces[name] ??= Object.create(null);\n const bound = binders[name] ??= Object.create(null);\n for (const { name: method, bind, defaults } of methods) {\n const invoke = (args, ref) => {\n if (!active)\n throw new Error(\"Tool namespace binding expired; bind the server reference again in this cell\");\n if (args !== undefined && !object(args))\n throw new TypeError(\"Tool namespace arguments must be an object\");\n return tools[tool]({ ...args, ...defaults, ...(bind === undefined ? {} : { [bind]: ref }) });\n };\n if (bind === undefined) {\n add(namespace, method, (args) => invoke(args));\n continue;\n }\n if (!Object.hasOwn(bound, bind)) {\n const members = bound[bind] = Object.create(null);\n add(namespace, bind, (ref) => {\n if (!object(ref)) throw new TypeError(\"Supply a discovered namespace reference\");\n const reference = { ...ref };\n const result = Object.create(null);\n for (const [key, call] of Object.entries(members))\n result[key] = (args) => call(args, reference);\n return Object.freeze(result);\n });\n }\n add(bound[bind], method, invoke);\n }\n }\n for (const namespace of Object.values(namespaces)) Object.freeze(namespace);\n globalThis.toolNamespaces = Object.freeze(namespaces);\n return () => {\n active = false;\n if (globalThis.toolNamespaces === namespaces)\n globalThis.toolNamespaces = Object.freeze(Object.create(null));\n };\n}";
|
|
31
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConversationId, type TaskId } from "@earendil-works/pi-durable";
|
|
1
|
+
import { type ConversationId, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
2
2
|
/** Admission provenance, not authorization: consumers must still verify the live originating slot. */
|
|
3
3
|
export type ToolOrigin = {
|
|
4
4
|
conversationId: ConversationId;
|
|
@@ -9,3 +9,11 @@ export type ToolOrigin = {
|
|
|
9
9
|
export declare const ToolOriginDoc: import("@earendil-works/pi-durable").TaskDocToken<{
|
|
10
10
|
origin?: ToolOrigin;
|
|
11
11
|
}>;
|
|
12
|
+
/** A direct execution invocation has an independently settled result and an admission snapshot. */
|
|
13
|
+
export declare function admittedExecutionCall(tx: Tx, conversation: ConversationId, child: TaskId): Promise<{
|
|
14
|
+
cell: TaskId<import("@earendil-works/chord/json").JsonValue>;
|
|
15
|
+
tool: TaskId<import("@earendil-works/chord/json").JsonValue>;
|
|
16
|
+
call: string;
|
|
17
|
+
} | undefined>;
|
|
18
|
+
/** Resolve immutable admission, never the latest observed assistant entry. */
|
|
19
|
+
export declare function admittedToolRound(tx: Tx, conversation: ConversationId, child: TaskId): Promise<import("@earendil-works/pi-durable").EntryId | undefined>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type ContextView, type ConversationId, type Harness } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type SettingsStorage } from "../../../internal/settings/index.ts";
|
|
4
|
+
import type { BrowserDeparture, BrowserVoiceProvider } from "../../../internal/voice/browser-provider.ts";
|
|
4
5
|
import { type GippityControlConfig } from "./config.ts";
|
|
5
6
|
import type { AudioLease, GippityAppFiles, GippityAudioHost, GippityLanPermission, GippityPresentation, GippitySettingsStore } from "./host.ts";
|
|
7
|
+
import { type BrowserReservation } from "./voice/browser-reservation.ts";
|
|
6
8
|
import type { CodexRealtimePeer } from "./voice/conversation/peer.ts";
|
|
7
9
|
import { type VoiceHandoffChannel } from "./voice/handoff-contract.ts";
|
|
10
|
+
import { GippityBrowserAudio } from "./voice/lan/pcm-bridge.ts";
|
|
8
11
|
import { type GippityRemoteAppProvider } from "./voice/lan/remote-app.ts";
|
|
9
12
|
interface GippityVoiceBaseOptions {
|
|
10
13
|
/** Host-owned browser automation, e.g. Browser's public startBrowserVoice API. */
|
|
@@ -154,11 +157,15 @@ export declare function createGippityVoice(options: GippityVoiceOptions): {
|
|
|
154
157
|
close(context: Context): Promise<void>;
|
|
155
158
|
readonly summary: string | undefined;
|
|
156
159
|
/** Source owns physical audio throughout the transfer. No microphone release/reacquire race. */
|
|
157
|
-
depart(channel: VoiceHandoffChannel, context: Context, transport?: "pcm24" | "webrtc"
|
|
160
|
+
depart(channel: VoiceHandoffChannel, context: Context, transport?: "pcm24" | "webrtc", browser?: {
|
|
161
|
+
owner: GippityBrowserAudio;
|
|
162
|
+
transfer: BrowserDeparture;
|
|
163
|
+
}): Promise<void>;
|
|
158
164
|
/** Destination gets a channel grant, never the source microphone's lease. */
|
|
159
|
-
arrive(channel: VoiceHandoffChannel, continuity: string, context: Context, transport?: "pcm24" | "webrtc"): Promise<void>;
|
|
165
|
+
arrive(channel: VoiceHandoffChannel, continuity: string, context: Context, transport?: "pcm24" | "webrtc", reservation?: BrowserReservation): Promise<void>;
|
|
160
166
|
};
|
|
161
167
|
settingsContribution: import("../../../internal/settings/index.ts").SettingsContribution<GippityControlConfig> | undefined;
|
|
168
|
+
browserProvider: BrowserVoiceProvider;
|
|
162
169
|
};
|
|
163
170
|
export type GippityVoiceControls = ReturnType<typeof createGippityVoice>["controls"];
|
|
164
171
|
export {};
|
|
@@ -40,6 +40,12 @@ export interface GippityLanPermission {
|
|
|
40
40
|
export type GippityPresentation = {
|
|
41
41
|
type: "voice-event";
|
|
42
42
|
event: RealtimeVoiceEventDetails;
|
|
43
|
+
} | {
|
|
44
|
+
type: "audio-diagnostics";
|
|
45
|
+
diagnostics: import("./voice/helper-protocol.ts").VoiceAudioDiagnostics;
|
|
46
|
+
} | {
|
|
47
|
+
type: "lan-playback-diagnostics";
|
|
48
|
+
diagnostics: import("./voice/lan/browser-connections.ts").LanPlaybackDiagnostics;
|
|
43
49
|
} | {
|
|
44
50
|
type: "status";
|
|
45
51
|
status: string;
|
|
@@ -9,5 +9,6 @@ export { createNativeGippityAppFiles, createNativeGippityAudioHost, } from "./na
|
|
|
9
9
|
export type { GippityPreferences } from "./preferences.ts";
|
|
10
10
|
export type { RealtimeVoiceEventDetails } from "./voice/conversation/wire.ts";
|
|
11
11
|
export type { TransferredVoiceControls, VoiceHandoffChannel, } from "./voice/handoff-contract.ts";
|
|
12
|
-
export type { VoiceDevice } from "./voice/helper-protocol.ts";
|
|
12
|
+
export type { VoiceAudioDiagnostics, VoiceDevice, } from "./voice/helper-protocol.ts";
|
|
13
|
+
export type { LanPlaybackDiagnostics } from "./voice/lan/browser-connections.ts";
|
|
13
14
|
export type { GippityRemoteAppMessage, GippityRemoteAppProvider, } from "./voice/lan/remote-app.ts";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { ConversationId, Harness } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { BrowserVoiceProvider } from "../../../../internal/voice/browser-provider.ts";
|
|
4
|
+
/** A host-owned reservation from the unified LAN destination, not a standalone SSE listener. */
|
|
5
|
+
export interface BrowserReservation {
|
|
6
|
+
identity: {
|
|
7
|
+
port: number;
|
|
8
|
+
certificate: string;
|
|
9
|
+
browserRealm?: string;
|
|
10
|
+
origins: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
ownsBrowserProvider(owner: Harness, conversationId: ConversationId, adapter: BrowserVoiceProvider): boolean;
|
|
13
|
+
offerBrowserArrival(proof: {
|
|
14
|
+
port: number;
|
|
15
|
+
token: string;
|
|
16
|
+
}, prepared: object, context: Context): Promise<{
|
|
17
|
+
path: string;
|
|
18
|
+
claim: string;
|
|
19
|
+
}>;
|
|
20
|
+
activate(context: Context): Promise<string[]>;
|
|
21
|
+
cancel(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare function prepareBrowserReservation(reservation: BrowserReservation, context: Context): {
|
|
24
|
+
handle: {};
|
|
25
|
+
verify(proof: unknown): Promise<{
|
|
26
|
+
path: string;
|
|
27
|
+
claim: string;
|
|
28
|
+
}>;
|
|
29
|
+
activate(value: unknown): Promise<void>;
|
|
30
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GippityControlConfig } from "../../config.ts";
|
|
2
|
+
import type { VoiceAudioDiagnostics } from "../helper-protocol.ts";
|
|
2
3
|
export declare const MAX_REALTIME_SDP_BYTES: number;
|
|
3
4
|
export type CodexRealtimePeerEvent = {
|
|
4
5
|
type: "state";
|
|
@@ -8,6 +9,9 @@ export type CodexRealtimePeerEvent = {
|
|
|
8
9
|
message: unknown;
|
|
9
10
|
} | {
|
|
10
11
|
type: "playback_activity";
|
|
12
|
+
} | {
|
|
13
|
+
type: "audio_diagnostics";
|
|
14
|
+
diagnostics: VoiceAudioDiagnostics;
|
|
11
15
|
} | {
|
|
12
16
|
type: "error";
|
|
13
17
|
message: string;
|
|
@@ -18,6 +22,8 @@ interface CodexRealtimePeerBase {
|
|
|
18
22
|
sendData(message: unknown): void;
|
|
19
23
|
setInputMuted(muted: boolean): void;
|
|
20
24
|
setSpeakerSuppressed(suppressed: boolean): void;
|
|
25
|
+
readonly playbackSealed?: boolean;
|
|
26
|
+
finishPlayback?(signal: AbortSignal): Promise<void>;
|
|
21
27
|
close(): Promise<void>;
|
|
22
28
|
}
|
|
23
29
|
export interface CodexRealtimeWebRtcPeer extends CodexRealtimePeerBase {
|
|
@@ -19,7 +19,7 @@ export declare const SEND_TASK_TOOL: {
|
|
|
19
19
|
additionalProperties: boolean;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
export declare const PUBLIC_REALTIME_INSTRUCTIONS = "This call has tools.
|
|
22
|
+
export declare const PUBLIC_REALTIME_INSTRUCTIONS = "This call has tools. Delegate without narrating the routing. Other listed tools run directly. Tool availability supersedes earlier statements that voice has no tools. Agent updates describe work already underway, not new user instructions. Speak useful progress and results, then wait for the user";
|
|
23
23
|
/** Public Realtime wire, independent from Codex delegation/transcript semantics. */
|
|
24
24
|
export declare class PublicRealtimeTurns {
|
|
25
25
|
readonly handoff: RealtimeDelegationHandoff;
|
|
@@ -33,6 +33,7 @@ export declare class PublicRealtimeTurns {
|
|
|
33
33
|
private activeResponse;
|
|
34
34
|
private awaitingResponse;
|
|
35
35
|
private speech;
|
|
36
|
+
private taskInputAvailable;
|
|
36
37
|
private pendingTools;
|
|
37
38
|
private readonly pendingWork;
|
|
38
39
|
private ending;
|
|
@@ -18,6 +18,7 @@ export interface CodexConversationCallbacks {
|
|
|
18
18
|
onUserTranscript(transcript: string): void;
|
|
19
19
|
onTranscriptTail(transcriptDelta: string): void;
|
|
20
20
|
onEvent?(event: RealtimeVoiceEventDetails): void;
|
|
21
|
+
onAudioDiagnostics?(diagnostics: import("../helper-protocol.ts").VoiceAudioDiagnostics): void;
|
|
21
22
|
}
|
|
22
23
|
export declare class CodexRealtimeConversation {
|
|
23
24
|
private readonly callbacks;
|
|
@@ -55,6 +56,7 @@ export declare class CodexRealtimeConversation {
|
|
|
55
56
|
settleAgentTurn(): void;
|
|
56
57
|
private failDeferredEnding;
|
|
57
58
|
private beginEnding;
|
|
59
|
+
get playbackSealed(): boolean;
|
|
58
60
|
get isEndingCall(): boolean;
|
|
59
61
|
/** Require the closing response observed since delegation, not an initially idle call. */
|
|
60
62
|
waitForFinalPlayback(): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BrowserDeparture } from "../../../../internal/voice/browser-provider.ts";
|
|
1
2
|
import type { TransferredVoiceControls, VoiceHandoffChannel } from "./handoff-contract.ts";
|
|
2
3
|
import { type CapturedHandoffAudio } from "./handoff-peer.ts";
|
|
3
4
|
import { type LanTakeoverOffer } from "./lan/takeover.ts";
|
|
@@ -8,6 +9,10 @@ export declare function startVoiceDeparture(options: {
|
|
|
8
9
|
onReleased(controls: TransferredVoiceControls): void;
|
|
9
10
|
onClosed(error: Error): void;
|
|
10
11
|
signal?: AbortSignal;
|
|
12
|
+
browser?: {
|
|
13
|
+
transfer: BrowserDeparture;
|
|
14
|
+
release(): Promise<void>;
|
|
15
|
+
};
|
|
11
16
|
lanTakeover?(offer: LanTakeoverOffer | undefined, releaseAudio: (beforeStop?: () => Promise<void>) => Promise<void>, verify: (value: unknown) => Promise<unknown>): Promise<number | undefined>;
|
|
12
17
|
}): {
|
|
13
18
|
completion: Promise<void>;
|
|
@@ -34,8 +34,16 @@ export declare class HandoffAudioHost {
|
|
|
34
34
|
start(): Promise<{
|
|
35
35
|
generation: number;
|
|
36
36
|
sdp: string;
|
|
37
|
+
finishPlayback: boolean;
|
|
37
38
|
}>;
|
|
38
39
|
closePeer(value: unknown): Promise<void>;
|
|
40
|
+
finishPlayback(value: unknown): Promise<{
|
|
41
|
+
error?: never;
|
|
42
|
+
sealed: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
sealed: boolean;
|
|
45
|
+
error: string;
|
|
46
|
+
}>;
|
|
39
47
|
command(message: Extract<HandoffNotification, {
|
|
40
48
|
type: "peer.command";
|
|
41
49
|
}>): void;
|
|
@@ -48,6 +56,8 @@ export declare class HandoffRemotePeer implements CodexRealtimePeer {
|
|
|
48
56
|
private readonly listeners;
|
|
49
57
|
private readonly exitListeners;
|
|
50
58
|
private generation;
|
|
59
|
+
private sealed;
|
|
60
|
+
private canFinishPlayback;
|
|
51
61
|
private starting;
|
|
52
62
|
private closed;
|
|
53
63
|
private readonly link;
|
|
@@ -60,6 +70,8 @@ export declare class HandoffRemotePeer implements CodexRealtimePeer {
|
|
|
60
70
|
sendData(message: unknown): void;
|
|
61
71
|
setInputMuted(muted: boolean): void;
|
|
62
72
|
setSpeakerSuppressed(suppressed: boolean): void;
|
|
73
|
+
get playbackSealed(): boolean;
|
|
74
|
+
finishPlayback(signal: AbortSignal): Promise<void>;
|
|
63
75
|
private command;
|
|
64
76
|
receive(generation: number, value: unknown): void;
|
|
65
77
|
disconnected(error: Error): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VoiceHandoffChannel } from "./handoff-contract.ts";
|
|
2
2
|
type Stage = "prepared" | "activate" | "active";
|
|
3
|
-
type RequestMethod = "session.stop" | "session.start" | "lan.verify" | "peer.start" | "peer.close" | "session.send" | "session.rpc";
|
|
3
|
+
type RequestMethod = "session.stop" | "session.start" | "lan.verify" | "browser.verify" | "peer.start" | "peer.close" | "peer.finish" | "session.send" | "session.rpc";
|
|
4
4
|
export type HandoffNotification = {
|
|
5
5
|
type: "peer.command";
|
|
6
6
|
generation: number;
|