@pouchy_ai/companion-sdk 0.21.0 → 0.22.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/CHANGELOG.md +18 -0
- package/README.md +6 -0
- package/dist/client.d.ts +2 -6
- package/dist/client.js +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/protocol.d.ts +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,24 @@ a protocol bump is always called out explicitly here.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.22.0] - 2026-07-11
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Runtime protocol constants are now exported.** `PROTOCOL_VERSION`,
|
|
20
|
+
`INBOUND_TYPES`, and `OUTBOUND_TYPES` are re-exported from the package entry —
|
|
21
|
+
previously only their *types* were reachable. A host can now assert the
|
|
22
|
+
protocol version or enumerate/validate the event vocabulary at runtime without
|
|
23
|
+
hard-coding the strings.
|
|
24
|
+
- **`ToolCallPayload` type.** The `companion.tool_call` payload
|
|
25
|
+
(`{ id, name, args }`) now has a named, exported interface, so a consumer using
|
|
26
|
+
the generic `on('companion.tool_call', …)` gets a typed payload — parity with
|
|
27
|
+
`RenderInterfacePayload`, `ConfirmRequestPayload`, and the other payload types.
|
|
28
|
+
`onToolCall`'s callback is typed against it.
|
|
29
|
+
|
|
30
|
+
No wire-protocol change (`PROTOCOL_VERSION` stays `1`); this is a purely additive
|
|
31
|
+
type/export surface, hence the minor bump.
|
|
32
|
+
|
|
15
33
|
## [0.21.0] - 2026-07-11
|
|
16
34
|
|
|
17
35
|
### Added
|
package/README.md
CHANGED
|
@@ -140,6 +140,12 @@ exported: `COMPANION_MODALITIES`, `REPRESENT_SCOPES`, `DEFAULT_MODALITIES`,
|
|
|
140
140
|
`isRepresentScope()`. The list mirrors the server vocabulary and is guarded by
|
|
141
141
|
the SDK's drift test.
|
|
142
142
|
|
|
143
|
+
The wire-protocol runtime constants are exported too — `PROTOCOL_VERSION`,
|
|
144
|
+
`INBOUND_TYPES`, and `OUTBOUND_TYPES` — so you can assert the version or
|
|
145
|
+
enumerate/validate the event vocabulary without hard-coding strings. Every
|
|
146
|
+
outbound payload has a named type; `ToolCallPayload` (`{ id, name, args }`) types
|
|
147
|
+
the `companion.tool_call` event and `onToolCall`'s callback.
|
|
148
|
+
|
|
143
149
|
## Representative mode (代聊)
|
|
144
150
|
|
|
145
151
|
Pass a `visitor` and the session flips from **owner-facing** to **representative**:
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AudioClipPayload, CompanionEnvelope, ConfirmRequestPayload, ExpressionPayload, InterfaceUpdatePayload, OutboundType, PendingConfirm, RenderInterfacePayload, SocialMessagePayload, TypingPayload, UsagePayload, VoiceInjectPayload, WorldStateEvent } from './protocol.js';
|
|
1
|
+
import type { AudioClipPayload, CompanionEnvelope, ConfirmRequestPayload, ExpressionPayload, InterfaceUpdatePayload, OutboundType, PendingConfirm, RenderInterfacePayload, SocialMessagePayload, ToolCallPayload, TypingPayload, UsagePayload, VoiceInjectPayload, WorldStateEvent } from './protocol.js';
|
|
2
2
|
/** Ergonomic world-state input: a WorldStateEvent with the CloudEvents plumbing
|
|
3
3
|
* (specversion / id / source) optional — sendWorldState fills them. */
|
|
4
4
|
export type WorldStateInput<D = unknown> = Omit<WorldStateEvent<D>, 'specversion' | 'id' | 'source'> & Partial<Pick<WorldStateEvent<D>, 'specversion' | 'id' | 'source'>>;
|
|
@@ -333,11 +333,7 @@ export declare class CompanionClient {
|
|
|
333
333
|
* hang the call. */
|
|
334
334
|
private invokeVoiceTool;
|
|
335
335
|
/** Convenience: subscribe to tool-call requests from the companion. */
|
|
336
|
-
onToolCall(handler: (call:
|
|
337
|
-
id: string;
|
|
338
|
-
name: string;
|
|
339
|
-
args: string;
|
|
340
|
-
}, envelope: CompanionEnvelope) => void): () => void;
|
|
336
|
+
onToolCall(handler: (call: ToolCallPayload, envelope: CompanionEnvelope) => void): () => void;
|
|
341
337
|
/** Convenience: subscribe to errors the companion surfaces — server-side agent
|
|
342
338
|
* errors and stream failures (e.g. a permanent `stream_unauthorized`) both
|
|
343
339
|
* arrive as `control.error`. Returns an unsubscribe fn. */
|
package/dist/client.js
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
// await c.sendText('how am I doing?');
|
|
9
9
|
//
|
|
10
10
|
// Pure, dependency-free, isomorphic (browser + Node 18+ fetch). The transport is
|
|
11
|
-
// an internal detail
|
|
12
|
-
//
|
|
11
|
+
// an internal detail: the default REST/SSE plane, or an opt-in WebSocket plane
|
|
12
|
+
// (ws-transport.ts) that degrades back to SSE on failure — both sit behind this
|
|
13
|
+
// same API. Protocol types are a self-contained copy of the server's contract,
|
|
14
|
+
// kept in lockstep by protocol.drift.test.ts.
|
|
13
15
|
import { PROTOCOL_VERSION } from './protocol.js';
|
|
14
16
|
import { parseSse } from './sse.js';
|
|
15
17
|
import { openCompanionCall, HOST_CONTROL_TOOLS, HOST_CONTROL_TOOL_NAMES, AVATAR_VISUAL_TOOLS, AVATAR_VISUAL_TOOL_NAMES } from './call.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { openCompanionCall, HOST_CONTROL_TOOLS, HOST_CONTROL_TOOL_NAMES, AVATAR_
|
|
|
5
5
|
export type { CompanionCall, CompanionCallOptions, VoiceToolBridge } from './call.js';
|
|
6
6
|
export { COMPANION_SCOPES, COMPANION_MODALITIES, SENSITIVE_SCOPES, REPRESENT_SCOPES, DEFAULT_SCOPES, DEFAULT_MODALITIES, isSensitiveScope, isRepresentScope, hasScope } from './scopes.js';
|
|
7
7
|
export type { CompanionScope, CompanionModality } from './scopes.js';
|
|
8
|
-
export type { CompanionEnvelope, OutboundType, InboundType, WorldStateEvent, RenderInterfacePayload, InterfaceUpdatePayload, SocialMessagePayload, ConfirmRequestPayload, PendingConfirm, AudioClipPayload, ExpressionPayload, TypingPayload, VoiceInjectPayload, UsagePayload } from './protocol.js';
|
|
8
|
+
export type { CompanionEnvelope, OutboundType, InboundType, WorldStateEvent, RenderInterfacePayload, InterfaceUpdatePayload, SocialMessagePayload, ConfirmRequestPayload, PendingConfirm, ToolCallPayload, AudioClipPayload, ExpressionPayload, TypingPayload, VoiceInjectPayload, UsagePayload } from './protocol.js';
|
|
9
|
+
export { PROTOCOL_VERSION, INBOUND_TYPES, OUTBOUND_TYPES } from './protocol.js';
|
|
9
10
|
/** Create a companion client. */
|
|
10
11
|
export declare function createCompanion(opts: CompanionClientOptions): CompanionClient;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Companion SDK — public entry. Embed the Pouchy companion in a third-party
|
|
2
|
-
// surface (web / app / game / hardware) over the REST/SSE plane
|
|
2
|
+
// surface (web / app / game / hardware) over the REST/SSE plane (with an
|
|
3
|
+
// optional WebSocket transport that degrades to SSE).
|
|
3
4
|
//
|
|
4
5
|
// import { createCompanion } from '$lib/companion-sdk';
|
|
5
6
|
// const c = createCompanion({ baseUrl: 'https://pouchy.ai', token: PAT });
|
|
@@ -12,6 +13,9 @@ import { CompanionClient } from './client.js';
|
|
|
12
13
|
export { CompanionClient, CompanionError, pouchyBrandIconUrl } from './client.js';
|
|
13
14
|
export { openCompanionCall, HOST_CONTROL_TOOLS, HOST_CONTROL_TOOL_NAMES, AVATAR_VISUAL_TOOLS, AVATAR_VISUAL_TOOL_NAMES } from './call.js';
|
|
14
15
|
export { COMPANION_SCOPES, COMPANION_MODALITIES, SENSITIVE_SCOPES, REPRESENT_SCOPES, DEFAULT_SCOPES, DEFAULT_MODALITIES, isSensitiveScope, isRepresentScope, hasScope } from './scopes.js';
|
|
16
|
+
// Runtime protocol constants — so a host can assert PROTOCOL_VERSION or
|
|
17
|
+
// enumerate/validate the event vocabulary without hard-coding the strings.
|
|
18
|
+
export { PROTOCOL_VERSION, INBOUND_TYPES, OUTBOUND_TYPES } from './protocol.js';
|
|
15
19
|
/** Create a companion client. */
|
|
16
20
|
export function createCompanion(opts) {
|
|
17
21
|
return new CompanionClient(opts);
|
package/dist/protocol.d.ts
CHANGED
|
@@ -76,6 +76,18 @@ export interface PendingConfirm {
|
|
|
76
76
|
/** Epoch ms when the companion asked. */
|
|
77
77
|
createdAt: number;
|
|
78
78
|
}
|
|
79
|
+
/** Payload of a `companion.tool_call` event — the companion is asking the host
|
|
80
|
+
* to run one of the app-declared tools it was given at `hello`. `args` is the
|
|
81
|
+
* raw JSON string the model produced (parse it yourself); reply by posting the
|
|
82
|
+
* result back with `client.sendToolResult(id, …)`. */
|
|
83
|
+
export interface ToolCallPayload {
|
|
84
|
+
/** Correlation id — echo it back on the tool result. */
|
|
85
|
+
id: string;
|
|
86
|
+
/** The declared tool name the model chose. */
|
|
87
|
+
name: string;
|
|
88
|
+
/** The model's arguments as a raw JSON string. */
|
|
89
|
+
args: string;
|
|
90
|
+
}
|
|
79
91
|
/** Payload of a `companion.ui_update` event — a live change to an
|
|
80
92
|
* already-rendered Instant UI panel: write each `{ key, value }` into the
|
|
81
93
|
* panel's state bag (re-evaluating templates / progress / `when`), without
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pouchy_ai/companion-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Embed the Pouchy companion — chat, voice, tools, memory, live world-state, instant UI, and agent-to-agent messaging — in any app, game, or site.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|