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.
Files changed (52) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/NOTICE +5 -3
  3. package/README.md +73 -24
  4. package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +67 -18
  5. package/browser-runtime/ai/ARCANE_AI_BROWSER_WASM_COMPONENTS.json +16 -5
  6. package/browser-runtime/ai/browser-kokoro-worker.mjs +3 -0
  7. package/browser-runtime/ai/browser-speech-artifacts.mjs +1108 -0
  8. package/browser-runtime/ai/browser-speech-providers.mjs +475 -0
  9. package/browser-runtime/ai/browser-speech.mjs +9 -0
  10. package/browser-runtime/ai/browser-wasm-llm-provider.mjs +1537 -167
  11. package/browser-runtime/ai/browser-wasm.mjs +46 -1
  12. package/browser-runtime/ai/browser-whisper-worker.mjs +3 -0
  13. package/browser-runtime/ai/browser-wllama-runtime.mjs +677 -132
  14. package/browser-runtime/ai/model-controller.mjs +138 -12
  15. package/browser-runtime/ai/speech-worker-client.mjs +207 -0
  16. package/browser-runtime/ai/speech-worker-runtime.mjs +516 -0
  17. package/browser-runtime/ai/wllama/index.mjs +389 -0
  18. package/docs/architecture.md +132 -22
  19. package/docs/reference/README.md +1 -1
  20. package/docs/reference/ai/browser-wasm.md +101 -42
  21. package/docs/reference/availability-and-normalization.md +19 -5
  22. package/docs/reference/behavioral-testing.md +18 -5
  23. package/docs/reference/cli.md +2 -2
  24. package/docs/reference/inventory/package-api.json +14 -14
  25. package/docs/reference/protocols.md +4 -4
  26. package/docs/reference/sdk-api.md +68 -38
  27. package/docs/work-amplification.md +8 -4
  28. package/package.json +7 -3
  29. package/runtime/ARCANE_RUNTIME_RELEASE.json +50 -20
  30. package/runtime/arcane/components/chat.html +280 -62
  31. package/runtime/arcane/components/speech.html +1113 -265
  32. package/runtime/arcane/entities/Chat.js +246 -43
  33. package/runtime/arcane/modules/AI.js +713 -162
  34. package/runtime/arcane/modules/AIProviderRuntime.js +2289 -0
  35. package/runtime/arcane/modules/AIRuntimeState.js +872 -0
  36. package/runtime/arcane/modules/ConfiguredAIChatSession.js +293 -27
  37. package/runtime/arcane/modules/DBOPFSDocumentLibrary.js +682 -0
  38. package/runtime/arcane/modules/DocumentLexicalSearch.js +292 -0
  39. package/runtime/arcane/modules/PersistentAIChatSession.js +268 -0
  40. package/runtime/arcane/modules/StaticDocumentCatalog.js +25 -206
  41. package/schemas/arcane-lock.schema.json +6 -4
  42. package/src/cli/main.mjs +14 -2
  43. package/src/constants.mjs +1 -1
  44. package/src/dev-server.mjs +244 -13
  45. package/src/import-map.mjs +59 -1
  46. package/src/packager/core.mjs +2 -2
  47. package/src/runtime.mjs +14 -4
  48. package/src/sdk-browser-runtime.mjs +28 -75
  49. package/src/templates/workspace-template.mjs +4 -4
  50. package/src/toolchain.mjs +3 -0
  51. package/src/workspace-runtime.mjs +1 -1
  52. 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,
@@ -0,0 +1,3 @@
1
+ import { installBrowserSpeechWorker } from "./speech-worker-runtime.mjs";
2
+
3
+ installBrowserSpeechWorker("stt");