@happyvertical/smrt-chat 0.60.13 → 0.60.15
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 +6 -2
- package/agents/ai-unavailable.md +42 -0
- package/dist/ai-unavailable.d.ts +33 -0
- package/dist/ai-unavailable.d.ts.map +1 -0
- package/dist/chat-stream.d.ts +5 -0
- package/dist/chat-stream.d.ts.map +1 -1
- package/dist/chunks/{chat-stream-DQ7857j8.js → chat-stream-FDF9I30Z.js} +45 -14
- package/dist/chunks/chat-stream-FDF9I30Z.js.map +1 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +59 -4
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +11 -5
- package/dist/smrt-knowledge.okf.md +11 -7
- package/dist/svelte/components/assistant/AssistantDock.svelte +34 -2
- package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts +4 -0
- package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts.map +1 -1
- package/dist/svelte/components/assistant/assistant-http-client.d.ts +6 -1
- package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
- package/dist/svelte/components/assistant/assistant-http-client.js +21 -2
- package/dist/svelte/components/shared/AiUnavailableNotice.svelte +66 -0
- package/dist/svelte/components/shared/AiUnavailableNotice.svelte.d.ts +13 -0
- package/dist/svelte/components/shared/AiUnavailableNotice.svelte.d.ts.map +1 -0
- package/dist/svelte/i18n.d.ts +5 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +6 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +1 -0
- package/dist/sveltekit.d.ts +11 -5
- package/dist/sveltekit.d.ts.map +1 -1
- package/dist/sveltekit.js +45 -6
- package/dist/sveltekit.js.map +1 -1
- package/package.json +17 -17
- package/dist/chunks/chat-stream-DQ7857j8.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -31,7 +31,7 @@ principals, tenancy, and authorization to the owning services.
|
|
|
31
31
|
## Models
|
|
32
32
|
|
|
33
33
|
All seven models expose only generated REST/MCP `list`/`get`; structural tests
|
|
34
|
-
check the registry for
|
|
34
|
+
check the registry for mutating operations. Writes go through
|
|
35
35
|
membership/owner-checked `ChatService` or the binding-checked voice adapter.
|
|
36
36
|
|
|
37
37
|
`ChatService` is a closed facade. Its collections and security-sensitive
|
|
@@ -203,11 +203,15 @@ dock from one `[...path]` route; `createAssistantHttp{Transport,ActionClient}`
|
|
|
203
203
|
`resolvePrincipal`; threads only from the actor's keyed session room in that
|
|
204
204
|
tenant (else 404). `allowedTools` is fail-closed; without `tools` it offers
|
|
205
205
|
those manifest ops (an unprovided name is an error, #3414). `ai` defaults to
|
|
206
|
-
the
|
|
206
|
+
the principal's stored inference binding over the config `ai` block (#4756,
|
|
207
|
+
[core inference.md](../core/agents/inference.md#raw-clients-and-binding-source-4756)). Pass `runtime`: a turn never keeps the RLS request tx
|
|
207
208
|
(own `runAsPrincipal` tx). `clientRequestId` makes the row id a UUIDv5
|
|
208
209
|
(`clientRequestMessageId`): the PK is the retry reservation. See
|
|
209
210
|
[docs](../../docs/assistant-dock.md).
|
|
210
211
|
|
|
212
|
+
AI off / not set up (#4757): routes answer a structured `ai_unavailable` 503;
|
|
213
|
+
dock `aiSettingsHref` ([agents/ai-unavailable.md](agents/ai-unavailable.md)).
|
|
214
|
+
|
|
211
215
|
#4505: `messageFormat="markdown"` / `renderMessage` ([docs](../../docs/assistant-dock.md));
|
|
212
216
|
`collapseRecoveredFailures` ([tool-loop](agents/tool-loop.md#failed-calls-are-persisted-4383)).
|
|
213
217
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# AI unavailable answers (#4757)
|
|
2
|
+
|
|
3
|
+
When core throws `InferenceUnavailableError` (`AI_UNAVAILABLE`: the
|
|
4
|
+
principal's mode is `off`, nothing is configured, ...; see
|
|
5
|
+
[core inference.md](../../core/agents/inference.md#inference-mode-and-ai_unavailable-4757)),
|
|
6
|
+
chat answers a structured message instead of a 500. Source:
|
|
7
|
+
`src/ai-unavailable.ts` (server), `src/client.ts` (browser parsing).
|
|
8
|
+
|
|
9
|
+
## Wire shape
|
|
10
|
+
|
|
11
|
+
`503` with `{ type: 'unavailable', code: 'ai_unavailable', error, unavailable }`:
|
|
12
|
+
`error` is a user-safe sentence for the reason, `unavailable` is core's
|
|
13
|
+
`InferenceStatus` (`available: false`, `mode`, `reason`, `tier?`). No stack,
|
|
14
|
+
no provider detail, never a key. `chatUnavailableBody(error)` builds it from
|
|
15
|
+
the typed error (matched by code, so another core copy's error counts);
|
|
16
|
+
`chatUnconfiguredBody()` is the `unconfigured` body.
|
|
17
|
+
|
|
18
|
+
- `mountAssistantRoutes()`: the AI factory's `AI_UNAVAILABLE`, and the default
|
|
19
|
+
factory's `AIProviderNotConfiguredError` (as `unconfigured`), answer this
|
|
20
|
+
instead of `assistant_unavailable`, before anything is stored. The
|
|
21
|
+
not-configured error still reaches `onError` (it names the config to
|
|
22
|
+
add); a chosen mode `off` is not logged.
|
|
23
|
+
- `createChatStreamHandler()`: `authorize` throwing it answers the 503; a
|
|
24
|
+
mid-turn one is the in-band `error` event with `code: 'ai_unavailable'`
|
|
25
|
+
and `unavailable`.
|
|
26
|
+
- Dev routes: `/api/dev-chat` and `/api/dev-character-conversation` answer
|
|
27
|
+
the 503; `/api/dev-chat-stream` lets it reach the handler. Unconfigured dev
|
|
28
|
+
routes keep their local fallback (dev-chat, dev-chat-stream).
|
|
29
|
+
|
|
30
|
+
## Browser
|
|
31
|
+
|
|
32
|
+
`./client`: `SmrtChatBackend` raises `ChatUnavailableError` (`unavailable`
|
|
33
|
+
status) for both shapes; `readChatUnavailableStatus(body)` parses one
|
|
34
|
+
(dependency-free, mirrors core's status type). The dock's HTTP transport sets
|
|
35
|
+
`AssistantHttpError.unavailable`. `AssistantDock`'s `aiSettingsHref` renders
|
|
36
|
+
`AiUnavailableNotice` ("AI is off" plus an "Open AI settings" link to the
|
|
37
|
+
host's page) in place of the error banner until a send succeeds; hosts render
|
|
38
|
+
the notice on their own surfaces from `./svelte`.
|
|
39
|
+
|
|
40
|
+
Tests: `src/ai-unavailable.test.ts`, `src/sveltekit-defaults.test.ts`,
|
|
41
|
+
`src/svelte/components/shared/__tests__/AiUnavailableNotice.test.ts`,
|
|
42
|
+
`src/svelte/components/assistant/__tests__/assistant-dock-ai-unavailable.test.ts`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structured "AI unavailable" answer chat sends instead of a 500 (#4757).
|
|
3
|
+
*
|
|
4
|
+
* When core throws `InferenceUnavailableError` (`AI_UNAVAILABLE`: mode
|
|
5
|
+
* `off`, nothing configured, ...), the assistant routes, the chat stream
|
|
6
|
+
* handler and the dev routes answer `503` with
|
|
7
|
+
* `{ type: 'unavailable', code: 'ai_unavailable', error, unavailable }`,
|
|
8
|
+
* where `unavailable` is core's `InferenceStatus` (`available: false`, mode,
|
|
9
|
+
* reason, tier). No stack, no provider detail, never a key. Svelte surfaces
|
|
10
|
+
* render it as "AI is off" with a host-supplied settings link.
|
|
11
|
+
*
|
|
12
|
+
* Browser-safe: imports core's light `./inference-availability` subpath only.
|
|
13
|
+
*/
|
|
14
|
+
import { type InferenceStatus } from '@happyvertical/smrt-core/inference-availability';
|
|
15
|
+
/** `code` of a chat answer for unavailable AI. */
|
|
16
|
+
export declare const CHAT_AI_UNAVAILABLE_CODE = "ai_unavailable";
|
|
17
|
+
/** The JSON body (and in-band stream event fields) for unavailable AI. */
|
|
18
|
+
export interface ChatUnavailableBody {
|
|
19
|
+
type: 'unavailable';
|
|
20
|
+
code: typeof CHAT_AI_UNAVAILABLE_CODE;
|
|
21
|
+
/** User-safe sentence for the reason. */
|
|
22
|
+
error: string;
|
|
23
|
+
unavailable: InferenceStatus;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The structured body for an `AI_UNAVAILABLE` error, or `undefined` for any
|
|
27
|
+
* other error. `unconfigured` is also accepted for callers that map their
|
|
28
|
+
* own "no provider" error (smrt-config's `AIProviderNotConfiguredError`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function chatUnavailableBody(error: unknown): ChatUnavailableBody | undefined;
|
|
31
|
+
/** The body for nothing configured (no binding and no provider). */
|
|
32
|
+
export declare function chatUnconfiguredBody(): ChatUnavailableBody;
|
|
33
|
+
//# sourceMappingURL=ai-unavailable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-unavailable.d.ts","sourceRoot":"","sources":["../src/ai-unavailable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,iDAAiD,CAAC;AAEzD,kDAAkD;AAClD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,OAAO,wBAAwB,CAAC;IACtC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,eAAe,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,mBAAmB,GAAG,SAAS,CAajC;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,IAAI,mBAAmB,CAO1D"}
|
package/dist/chat-stream.d.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import type { AIInterface } from '@happyvertical/ai';
|
|
30
30
|
import type { PrincipalAuditSink, PrincipalTool } from '@happyvertical/smrt-agents';
|
|
31
31
|
import type { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
32
|
+
import type { ChatUnavailableStatus } from './client.js';
|
|
32
33
|
import type { AgentSession } from './models/AgentSession.js';
|
|
33
34
|
import { type ConversationPersona, type PersonaRecallOptions } from './persona-conversation.js';
|
|
34
35
|
import type { ChatService } from './services/index.js';
|
|
@@ -101,6 +102,10 @@ export type ChatStreamEvent = {
|
|
|
101
102
|
} | {
|
|
102
103
|
type: 'error';
|
|
103
104
|
error: string;
|
|
105
|
+
/** `ai_unavailable` when AI is off or not set up (#4757). */
|
|
106
|
+
code?: string;
|
|
107
|
+
/** Core's `InferenceStatus` for an `ai_unavailable` error. */
|
|
108
|
+
unavailable?: ChatUnavailableStatus;
|
|
104
109
|
};
|
|
105
110
|
/** The JSON body of a streaming request. */
|
|
106
111
|
export interface ChatStreamRequestBody {
|
|
@@ -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,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
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;AAEjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,KAAK,mBAAmB,EACxB,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