@happyvertical/smrt-chat 0.39.6 → 0.39.7
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/AGENTS.md +1 -0
- package/dist/chat-stream.d.ts +16 -1
- package/dist/chat-stream.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2413 -2413
- package/dist/smrt-knowledge.json +184 -184
- package/package.json +11 -11
package/AGENTS.md
CHANGED
|
@@ -66,6 +66,7 @@ The gateway bearer token proves only "this request came from the gateway"; it ne
|
|
|
66
66
|
- **`runChatConversationStream({ context, messages })`** — the transport-agnostic engine (an `AsyncGenerator<ChatStreamEvent>`). Dispatches on `context.binding`: **persona-bound** runs the full `runPersonaConversationTurn` with a token sink wired through the tool loop (`onToken` → `ai.chat({ stream: true, onProgress })`), then persists via `ChatService` and emits the persisted message as `done`; **plain/unbound** streams `ai.stream()` directly and emits a synthesized (unpersisted) `done`. Streamed tokens are a live PREVIEW (a tool-call round may narrate before acting); the `done` message is authoritative. Failures surface as an in-band `error` event, never a throw (the 200 has already committed once streaming starts).
|
|
67
67
|
- **`createChatStreamHandler({ authorize, allowedOrigins?, allowCredentials? })`** — a Fetch-compatible handler returning `text/event-stream` (mirrors `createVoiceGatewayTurnHandler`). `authorize(request, body)` is the SOLE trust boundary and works exactly like the voice gateway: this module NEVER authorizes from the request's `session` metadata — the app validates the caller (bearer session id / cookie / same-origin) and the claimed ids against the authenticated principal, and returns an already-authorized `ChatStreamContext`. Generation caps (`model`/`maxTokens`/`maxSteps`) live on the context (server-resolved), never on the request. Cross-origin embedding uses the same fail-closed CORS posture as core `_events` (#1861): the `Origin` is echoed only when allow-listed (never `*`), credentials only when opted in.
|
|
68
68
|
- **Persona path reuses the harness's own gates unchanged** — persona principal, fail-closed `allowedTools` offer+execution gates, tenant binding. `onToken` is best-effort telemetry threaded through `runToolLoop`; it never changes what the loop persists or authorizes.
|
|
69
|
+
- **Custom tools stream via `binding.extraTools`** — the persona binding threads an optional `extraTools?: PrincipalTool[]` down to `runPersonaConversationTurn`, so a *streamed* persona chat can offer non-manifest, service-backed tools (the persona messaging tool `messages.send`, or an assistance-request/lead-ticket tool wrapping a `@smrt({ api:false, mcp:false })` service) and thus *act*, not only answer — matching the non-streaming persona path. It is resolved server-side by `authorize` (trusted), never from request input, and stays fully gated: each tool is filtered by the persona's `allowedTools` (offer gate) and re-asserts the bound principal's authority in `execute` (execution gate). Offering a tool is not authorizing it.
|
|
69
70
|
|
|
70
71
|
## Gotchas
|
|
71
72
|
|
package/dist/chat-stream.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AIInterface } from '@happyvertical/ai';
|
|
2
|
-
import { PrincipalAuditSink } from '@happyvertical/smrt-agents';
|
|
2
|
+
import { PrincipalAuditSink, PrincipalTool } from '@happyvertical/smrt-agents';
|
|
3
3
|
import { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
4
4
|
import { AgentSession } from './models/AgentSession.js';
|
|
5
5
|
import { ConversationPersona, PersonaRecallOptions } from './persona-conversation.js';
|
|
@@ -99,6 +99,21 @@ export interface ChatStreamPersonaBinding {
|
|
|
99
99
|
onBehalfOfUserId?: string | null;
|
|
100
100
|
/** Recall configuration, or `false` to skip memory recall. */
|
|
101
101
|
recall?: PersonaRecallOptions | false;
|
|
102
|
+
/**
|
|
103
|
+
* Non-manifest custom tools to offer this streamed turn — e.g. the persona
|
|
104
|
+
* messaging tool (`messages.send`) or an assistance-request/lead-ticket tool
|
|
105
|
+
* backed by a `@smrt({ api:false, mcp:false })` service, which can only reach
|
|
106
|
+
* the loop as `extraTools` (never as a generated manifest tool). Forwarded to
|
|
107
|
+
* {@link runPersonaConversationTurn} exactly like the non-streaming persona
|
|
108
|
+
* path, so a streamed persona chat can *act*, not just answer.
|
|
109
|
+
*
|
|
110
|
+
* This is resolved by the app's server-side `authorize` callback (trusted),
|
|
111
|
+
* never taken from untrusted request input. Offering a tool is NOT authorizing
|
|
112
|
+
* it: each entry is still filtered by the persona's `allowedTools` (the offer
|
|
113
|
+
* gate) and its `execute` re-asserts the bound principal's RBAC + the
|
|
114
|
+
* fail-closed `assertToolAllowed` (the execution gate), unchanged.
|
|
115
|
+
*/
|
|
116
|
+
extraTools?: PrincipalTool[];
|
|
102
117
|
/** Audit sink forwarded to the principal execution. */
|
|
103
118
|
audit?: PrincipalAuditSink;
|
|
104
119
|
/** Opt into Postgres RLS transaction wrapping. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-stream.d.ts","sourceRoot":"","sources":["../src/chat-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"chat-stream.d.ts","sourceRoot":"","sources":["../src/chat-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,uEAAuE;AACvE,eAAO,MAAM,8BAA8B,QAAS,CAAC;AACrD;;;;;;;GAOG;AACH,eAAO,MAA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