arcane-os 0.1.2 → 0.2.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 +17 -0
- package/NOTICE +5 -3
- package/README.md +73 -24
- package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +67 -18
- package/browser-runtime/ai/ARCANE_AI_BROWSER_WASM_COMPONENTS.json +16 -5
- package/browser-runtime/ai/browser-kokoro-worker.mjs +3 -0
- package/browser-runtime/ai/browser-speech-artifacts.mjs +1108 -0
- package/browser-runtime/ai/browser-speech-providers.mjs +475 -0
- package/browser-runtime/ai/browser-speech.mjs +9 -0
- package/browser-runtime/ai/browser-wasm-llm-provider.mjs +1537 -167
- package/browser-runtime/ai/browser-wasm.mjs +46 -1
- package/browser-runtime/ai/browser-whisper-worker.mjs +3 -0
- package/browser-runtime/ai/browser-wllama-runtime.mjs +677 -132
- package/browser-runtime/ai/model-controller.mjs +138 -12
- package/browser-runtime/ai/speech-worker-client.mjs +207 -0
- package/browser-runtime/ai/speech-worker-runtime.mjs +516 -0
- package/browser-runtime/ai/wllama/index.mjs +389 -0
- package/docs/architecture.md +132 -22
- package/docs/reference/README.md +1 -1
- package/docs/reference/ai/browser-wasm.md +101 -42
- package/docs/reference/availability-and-normalization.md +19 -5
- package/docs/reference/behavioral-testing.md +18 -5
- package/docs/reference/cli.md +2 -2
- package/docs/reference/inventory/package-api.json +14 -14
- package/docs/reference/protocols.md +4 -4
- package/docs/reference/sdk-api.md +68 -38
- package/docs/work-amplification.md +8 -4
- package/package.json +7 -3
- package/runtime/ARCANE_RUNTIME_RELEASE.json +50 -20
- package/runtime/arcane/components/chat.html +280 -62
- package/runtime/arcane/components/speech.html +1113 -265
- package/runtime/arcane/entities/Chat.js +246 -43
- package/runtime/arcane/modules/AI.js +713 -162
- package/runtime/arcane/modules/AIProviderRuntime.js +2289 -0
- package/runtime/arcane/modules/AIRuntimeState.js +872 -0
- package/runtime/arcane/modules/ConfiguredAIChatSession.js +293 -27
- package/runtime/arcane/modules/DBOPFSDocumentLibrary.js +682 -0
- package/runtime/arcane/modules/DocumentLexicalSearch.js +292 -0
- package/runtime/arcane/modules/PersistentAIChatSession.js +268 -0
- package/runtime/arcane/modules/StaticDocumentCatalog.js +25 -206
- package/schemas/arcane-lock.schema.json +6 -4
- package/src/cli/main.mjs +14 -2
- package/src/constants.mjs +1 -1
- package/src/dev-server.mjs +244 -13
- package/src/import-map.mjs +59 -1
- package/src/packager/core.mjs +2 -2
- package/src/runtime.mjs +14 -4
- package/src/sdk-browser-runtime.mjs +28 -75
- package/src/templates/workspace-template.mjs +4 -4
- package/src/toolchain.mjs +3 -0
- package/src/workspace-runtime.mjs +1 -1
- package/src/workspace.mjs +1 -1
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { createModelController, ModelController } from "./model-controller.mjs";
|
|
2
2
|
import {
|
|
3
|
+
adaptV1LlmProvider,
|
|
3
4
|
createBrowserModelSource,
|
|
4
5
|
createBrowserWasmLlmProvider,
|
|
5
6
|
createDbopfsModelStore,
|
|
6
7
|
} from "./browser-wasm-llm-provider.mjs";
|
|
7
8
|
import { BROWSER_WASM_RUNTIME_AUTHORITY } from "./browser-wllama-runtime.mjs";
|
|
8
9
|
|
|
10
|
+
function chatSessionResponse(response) {
|
|
11
|
+
if (response?.message && typeof response.message === "object") return response;
|
|
12
|
+
const choice = Array.isArray(response?.choices) ? response.choices[0] : null;
|
|
13
|
+
if (!choice?.message || typeof choice.message !== "object") return response;
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
message: choice.message,
|
|
16
|
+
provider: response.provider ?? null,
|
|
17
|
+
model: response.model ?? null,
|
|
18
|
+
done: response.done ?? true,
|
|
19
|
+
doneReason: response.doneReason ?? choice.finish_reason ?? null,
|
|
20
|
+
promptEvalCount: response.promptEvalCount ?? response.usage?.prompt_tokens ?? null,
|
|
21
|
+
evalCount: response.evalCount ?? response.usage?.completion_tokens ?? null,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
/**
|
|
10
26
|
* Creates the generic Arcane browser-local AI facade. The SDK owns lifecycle,
|
|
11
27
|
* integrity, cache, streaming, and structural tool visibility; applications
|
|
@@ -15,16 +31,44 @@ function createArcaneAI({
|
|
|
15
31
|
llm = null,
|
|
16
32
|
provider = null,
|
|
17
33
|
loadPolicy = "on-demand",
|
|
34
|
+
security,
|
|
18
35
|
} = {}) {
|
|
19
36
|
const selected = llm ?? provider;
|
|
20
37
|
if (!selected) throw new TypeError("createArcaneAI requires an llm provider.");
|
|
38
|
+
if (selected instanceof ModelController && security !== undefined) {
|
|
39
|
+
throw new TypeError(
|
|
40
|
+
"createArcaneAI security must be configured when the existing ModelController is created.",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
21
43
|
const controller = selected instanceof ModelController
|
|
22
44
|
? selected
|
|
23
|
-
: createModelController({ provider: selected, loadPolicy });
|
|
45
|
+
: createModelController({ provider: selected, loadPolicy, security });
|
|
46
|
+
|
|
47
|
+
async function createChatSession(options = {}) {
|
|
48
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
49
|
+
throw new TypeError("createChatSession options must be a plain object.");
|
|
50
|
+
}
|
|
51
|
+
if (Object.getPrototypeOf(options) !== Object.prototype) {
|
|
52
|
+
throw new TypeError("createChatSession options must be a plain object.");
|
|
53
|
+
}
|
|
54
|
+
if (Object.hasOwn(options, "chat")) {
|
|
55
|
+
throw new TypeError("createChatSession always uses this Arcane AI controller.");
|
|
56
|
+
}
|
|
57
|
+
const { createPersistentAIChatSession } = await import(
|
|
58
|
+
"#arcane/persistent-ai-chat-session"
|
|
59
|
+
);
|
|
60
|
+
return createPersistentAIChatSession({
|
|
61
|
+
...options,
|
|
62
|
+
chat: async (request) => chatSessionResponse(
|
|
63
|
+
await controller.fetchRequest(request)
|
|
64
|
+
),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
24
67
|
|
|
25
68
|
return Object.freeze({
|
|
26
69
|
llm: controller,
|
|
27
70
|
runtime: BROWSER_WASM_RUNTIME_AUTHORITY,
|
|
71
|
+
createChatSession,
|
|
28
72
|
status: () => Object.freeze({ llm: controller.status() }),
|
|
29
73
|
load: (options) => controller.load(options),
|
|
30
74
|
unload: (options) => controller.unload(options),
|
|
@@ -37,6 +81,7 @@ function createArcaneAI({
|
|
|
37
81
|
|
|
38
82
|
export {
|
|
39
83
|
BROWSER_WASM_RUNTIME_AUTHORITY,
|
|
84
|
+
adaptV1LlmProvider,
|
|
40
85
|
createArcaneAI,
|
|
41
86
|
createBrowserModelSource,
|
|
42
87
|
createBrowserWasmLlmProvider,
|