@dxos/plugin-native 0.9.0 → 0.9.1-staging.ee54ba693a

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 (69) hide show
  1. package/dist/lib/neutral/NativePlugin.mjs +2 -2
  2. package/dist/lib/neutral/NativePlugin.mjs.map +4 -4
  3. package/dist/lib/neutral/{NativeSettings-CLYG5TJH.mjs → NativeSettings-33K63AVG.mjs} +16 -9
  4. package/dist/lib/neutral/NativeSettings-33K63AVG.mjs.map +7 -0
  5. package/dist/lib/neutral/capabilities/index.mjs +4 -4
  6. package/dist/lib/neutral/chunk-WU6IZ56J.mjs +43 -0
  7. package/dist/lib/neutral/chunk-WU6IZ56J.mjs.map +7 -0
  8. package/dist/lib/neutral/{components → containers}/index.mjs +2 -2
  9. package/dist/lib/neutral/{components → containers}/index.mjs.map +1 -1
  10. package/dist/lib/neutral/index.mjs +1 -1
  11. package/dist/lib/neutral/meta.json +1 -1
  12. package/dist/lib/neutral/meta.mjs +1 -1
  13. package/dist/lib/neutral/ollama-HZEXAT2P.mjs +312 -0
  14. package/dist/lib/neutral/ollama-HZEXAT2P.mjs.map +7 -0
  15. package/dist/lib/neutral/plugin.mjs +1 -1
  16. package/dist/lib/neutral/{react-surface-ETNGHN4X.mjs → react-surface-YST5DQA3.mjs} +3 -3
  17. package/dist/lib/neutral/{react-surface-ETNGHN4X.mjs.map → react-surface-YST5DQA3.mjs.map} +3 -3
  18. package/dist/lib/neutral/{settings-HF6TQNU4.mjs → settings-S5MFUI42.mjs} +3 -3
  19. package/dist/lib/neutral/{settings-HF6TQNU4.mjs.map → settings-S5MFUI42.mjs.map} +3 -3
  20. package/dist/lib/neutral/translations.mjs +1 -2
  21. package/dist/lib/neutral/translations.mjs.map +3 -3
  22. package/dist/lib/neutral/types/index.mjs +2 -2
  23. package/dist/lib/neutral/types/index.mjs.map +3 -3
  24. package/dist/lib/neutral/{updater-JEBXWSSK.mjs → updater-5ETKR4S3.mjs} +6 -6
  25. package/dist/lib/neutral/{updater-JEBXWSSK.mjs.map → updater-5ETKR4S3.mjs.map} +2 -2
  26. package/dist/types/dx.config.d.ts +28 -0
  27. package/dist/types/dx.config.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/index.d.ts +5 -5
  29. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/ollama.d.ts +3 -2
  31. package/dist/types/src/capabilities/ollama.d.ts.map +1 -1
  32. package/dist/types/src/capabilities/react-surface.d.ts +2 -2
  33. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  34. package/dist/types/src/capabilities/settings.d.ts +1 -3
  35. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  36. package/dist/types/src/capabilities/spotlight-listener.d.ts +1 -1
  37. package/dist/types/src/capabilities/updater.d.ts +1 -2
  38. package/dist/types/src/capabilities/updater.d.ts.map +1 -1
  39. package/dist/types/src/{components → containers}/NativeSettings/NativeSettings.d.ts +1 -1
  40. package/dist/types/src/containers/NativeSettings/NativeSettings.d.ts.map +1 -0
  41. package/dist/types/src/{components → containers}/NativeSettings/index.d.ts.map +1 -1
  42. package/dist/types/src/{components → containers}/index.d.ts.map +1 -1
  43. package/dist/types/src/meta.d.ts +32 -2
  44. package/dist/types/src/meta.d.ts.map +1 -1
  45. package/dist/types/src/translations.d.ts +0 -1
  46. package/dist/types/src/translations.d.ts.map +1 -1
  47. package/dist/types/src/types/NativeCapabilities.d.ts.map +1 -1
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/dx.config.ts +32 -0
  50. package/package.json +25 -24
  51. package/src/NativePlugin.tsx +1 -1
  52. package/src/capabilities/ollama.ts +281 -16
  53. package/src/capabilities/react-surface.tsx +2 -2
  54. package/src/capabilities/settings.ts +2 -2
  55. package/src/capabilities/updater.ts +5 -5
  56. package/src/{components → containers}/NativeSettings/NativeSettings.tsx +15 -10
  57. package/src/meta.ts +3 -25
  58. package/src/translations.ts +1 -2
  59. package/src/types/NativeCapabilities.ts +6 -2
  60. package/dist/lib/neutral/NativeSettings-CLYG5TJH.mjs.map +0 -7
  61. package/dist/lib/neutral/chunk-75E24KAJ.mjs +0 -34
  62. package/dist/lib/neutral/chunk-75E24KAJ.mjs.map +0 -7
  63. package/dist/lib/neutral/ollama-BHWFTROM.mjs +0 -62
  64. package/dist/lib/neutral/ollama-BHWFTROM.mjs.map +0 -7
  65. package/dist/types/src/components/NativeSettings/NativeSettings.d.ts.map +0 -1
  66. /package/dist/types/src/{components → containers}/NativeSettings/index.d.ts +0 -0
  67. /package/dist/types/src/{components → containers}/index.d.ts +0 -0
  68. /package/src/{components → containers}/NativeSettings/index.ts +0 -0
  69. /package/src/{components → containers}/index.ts +0 -0
package/dx.config.ts ADDED
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Config2 } from '@dxos/app-framework/config';
6
+ import { trim } from '@dxos/util';
7
+
8
+ export default Config2.make({
9
+ plugin: {
10
+ key: 'org.dxos.plugin.native',
11
+ name: 'App',
12
+ author: 'DXOS',
13
+ description: trim`
14
+ Tauri-based native platform integration for DXOS Composer on macOS, Linux, and Windows.
15
+
16
+ Provides Spotlight window integration that forwards spotlight:invoke Tauri events to
17
+ Composer operations, letting the OS-level launcher open spaces and switch workspaces
18
+ without the main window being focused first.
19
+
20
+ Manages over-the-air application updates via the Tauri updater plugin, automatically
21
+ checking for new releases in the background, streaming download progress, and surfacing
22
+ a toast notification with a one-click Relaunch action when an update is ready.
23
+
24
+ Spawns an Ollama sidecar process on localhost for local AI model inference, registering
25
+ it as an AiModelResolver so Assistant features can resolve model requests without any
26
+ external server dependency.
27
+ `,
28
+ spec: 'PLUGIN.mdl',
29
+ icon: { key: 'ph--app-window--regular' },
30
+ tags: ['system'],
31
+ },
32
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-native",
3
- "version": "0.9.0",
3
+ "version": "0.9.1-staging.ee54ba693a",
4
4
  "description": "Composer plugin that runs when on a native device.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -18,10 +18,10 @@
18
18
  "types": "./dist/types/src/capabilities/index.d.ts",
19
19
  "default": "./dist/lib/neutral/capabilities/index.mjs"
20
20
  },
21
- "#components": {
22
- "source": "./src/components/index.ts",
23
- "types": "./dist/types/src/components/index.d.ts",
24
- "default": "./dist/lib/neutral/components/index.mjs"
21
+ "#containers": {
22
+ "source": "./src/containers/index.ts",
23
+ "types": "./dist/types/src/containers/index.d.ts",
24
+ "default": "./dist/lib/neutral/containers/index.mjs"
25
25
  },
26
26
  "#meta": {
27
27
  "source": "./src/meta.ts",
@@ -65,41 +65,42 @@
65
65
  "types": "dist/types/src/index.d.ts",
66
66
  "files": [
67
67
  "dist",
68
+ "dx.config.ts",
68
69
  "src",
69
70
  "PLUGIN.mdl"
70
71
  ],
71
72
  "dependencies": {
72
73
  "@effect-atom/atom-react": "^0.5.0",
73
- "@effect/platform": "0.96.1",
74
+ "@effect/platform": "0.96.2",
74
75
  "@tauri-apps/api": "^2.11.0",
75
76
  "@tauri-apps/plugin-os": "^2.3.2",
76
77
  "@tauri-apps/plugin-process": "^2.3.1",
77
78
  "@tauri-apps/plugin-shell": "^2.3.5",
78
79
  "@tauri-apps/plugin-updater": "^2.10.1",
79
80
  "date-fns": "^3.6.0",
80
- "@dxos/app-framework": "0.9.0",
81
- "@dxos/effect": "0.9.0",
82
- "@dxos/keys": "0.9.0",
83
- "@dxos/ai": "0.9.0",
84
- "@dxos/app-toolkit": "0.9.0",
85
- "@dxos/log": "0.9.0",
86
- "@dxos/plugin-assistant": "0.9.0",
87
- "@dxos/util": "0.9.0"
81
+ "@dxos/ai": "0.9.1-staging.ee54ba693a",
82
+ "@dxos/app-toolkit": "0.9.1-staging.ee54ba693a",
83
+ "@dxos/effect": "0.9.1-staging.ee54ba693a",
84
+ "@dxos/keys": "0.9.1-staging.ee54ba693a",
85
+ "@dxos/app-framework": "0.9.1-staging.ee54ba693a",
86
+ "@dxos/plugin-assistant": "0.9.1-staging.ee54ba693a",
87
+ "@dxos/log": "0.9.1-staging.ee54ba693a",
88
+ "@dxos/util": "0.9.1-staging.ee54ba693a"
88
89
  },
89
90
  "devDependencies": {
90
- "@types/react": "~19.2.7",
91
- "effect": "3.21.3",
92
- "react": "~19.2.3",
91
+ "@types/react": "~19.2.17",
92
+ "effect": "3.21.4",
93
+ "react": "~19.2.7",
93
94
  "vite": "^8.0.16",
94
- "@dxos/react-ui-form": "0.9.0",
95
- "@dxos/plugin-testing": "0.9.0",
96
- "@dxos/react-ui": "0.9.0"
95
+ "@dxos/plugin-testing": "0.9.1-staging.ee54ba693a",
96
+ "@dxos/react-ui": "0.9.1-staging.ee54ba693a",
97
+ "@dxos/react-ui-form": "0.9.1-staging.ee54ba693a"
97
98
  },
98
99
  "peerDependencies": {
99
- "effect": "3.21.3",
100
- "react": "~19.2.3",
101
- "@dxos/react-ui": "0.9.0",
102
- "@dxos/react-ui-form": "0.9.0"
100
+ "effect": "3.21.4",
101
+ "react": "~19.2.7",
102
+ "@dxos/react-ui": "0.9.1-staging.ee54ba693a",
103
+ "@dxos/react-ui-form": "0.9.1-staging.ee54ba693a"
103
104
  },
104
105
  "publishConfig": {
105
106
  "access": "public"
@@ -33,7 +33,7 @@ export const NativePlugin = Plugin.define(meta).pipe(
33
33
  activate: Ollama,
34
34
  }),
35
35
  AppPlugin.addPluginAssetModule({
36
- asset: { pluginId: meta.id, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },
36
+ asset: { pluginId: meta.profile.key, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },
37
37
  }),
38
38
  Plugin.make,
39
39
  );
@@ -2,27 +2,40 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { Atom } from '@effect-atom/atom-react';
5
6
  import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
6
7
  import * as HttpClient from '@effect/platform/HttpClient';
7
8
  import { Command } from '@tauri-apps/plugin-shell';
9
+ import * as Cause from 'effect/Cause';
8
10
  import * as Context from 'effect/Context';
11
+ import * as Duration from 'effect/Duration';
9
12
  import * as Effect from 'effect/Effect';
13
+ import * as Either from 'effect/Either';
14
+ import * as Exit from 'effect/Exit';
15
+ import * as Fiber from 'effect/Fiber';
10
16
  import * as Layer from 'effect/Layer';
11
17
  import * as ManagedRuntime from 'effect/ManagedRuntime';
18
+ import * as Schedule from 'effect/Schedule';
19
+ import * as Stream from 'effect/Stream';
12
20
 
13
- import { type AiModelResolver } from '@dxos/ai';
14
- import { OllamaResolver } from '@dxos/ai/resolvers';
15
- import { Capability } from '@dxos/app-framework';
21
+ import { type AiModelResolver, Provider } from '@dxos/ai';
22
+ import { OllamaAdmin, OllamaResolver } from '@dxos/ai/resolvers';
23
+ import { Capabilities, Capability } from '@dxos/app-framework';
16
24
  import { AppCapabilities } from '@dxos/app-toolkit';
17
25
  import { log } from '@dxos/log';
26
+ import { AssistantCapabilities, type Ollama } from '@dxos/plugin-assistant';
18
27
 
19
28
  // NOTE: Running ollama on non-standard port (config Tauri).
20
29
  const OLLAMA_HOST = 'http://localhost:21434';
21
30
 
22
- export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
31
+ export type OllamaCapabilities =
32
+ | Capability.Capability<typeof AppCapabilities.AiModelResolver>
33
+ | Capability.Capability<typeof AssistantCapabilities.OllamaManager>;
34
+
35
+ export default Capability.makeModule(
36
+ Effect.fnUntraced(function* () {
37
+ const registry = yield* Capability.get(Capabilities.AtomRegistry);
23
38
 
24
- export default Capability.makeModule<[], OllamaCapabilities>(() =>
25
- Effect.sync(() => {
26
39
  const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
27
40
 
28
41
  // Layer for the sidecar but the lifecycle is managed by the runtime.
@@ -30,11 +43,232 @@ export default Capability.makeModule<[], OllamaCapabilities>(() =>
30
43
  runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),
31
44
  );
32
45
 
33
- return Capability.contributes(
34
- AppCapabilities.AiModelResolver,
35
- OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
36
- () => Effect.tryPromise(() => runtime.dispose()),
37
- );
46
+ const admin = OllamaAdmin.make({ endpoint: OLLAMA_HOST });
47
+ const stateAtom = Atom.make<Ollama.ModelsState>({
48
+ kind: 'idle',
49
+ models: [],
50
+ loaded: [],
51
+ pulls: {},
52
+ errors: {},
53
+ }).pipe(Atom.keepAlive);
54
+
55
+ // Read/update the reactive state atom as Effects.
56
+ const getState = Effect.sync(() => registry.get(stateAtom));
57
+ const updateState = (f: (state: Ollama.ModelsState) => Ollama.ModelsState): Effect.Effect<void> =>
58
+ Effect.sync(() => registry.set(stateAtom, f(registry.get(stateAtom))));
59
+
60
+ // Connection-level failure (reaching the service); shown at the section, not tied to a model.
61
+ const fail = (error: string): Effect.Effect<void> => updateState((state) => ({ ...state, kind: 'failed', error }));
62
+
63
+ // Per-model action error (load/unload/remove/pull); shown inline on that model's row. Pass
64
+ // `undefined` to clear.
65
+ const setError = (name: string, error: string | undefined): Effect.Effect<void> =>
66
+ updateState((state) => {
67
+ const errors = { ...state.errors };
68
+ if (error) {
69
+ errors[name] = error;
70
+ } else {
71
+ delete errors[name];
72
+ }
73
+ return { ...state, errors };
74
+ });
75
+
76
+ // Write (or clear, when `progress` is undefined) the in-flight progress for `name`.
77
+ const setProgress = (name: string, progress: OllamaAdmin.PullProgress | undefined): Effect.Effect<void> =>
78
+ updateState((state) => {
79
+ const pulls = { ...state.pulls };
80
+ if (progress) {
81
+ pulls[name] = progress;
82
+ } else {
83
+ delete pulls[name];
84
+ }
85
+ return { ...state, pulls };
86
+ });
87
+
88
+ // Force the scoped sidecar layer, spawning the process idempotently — the runtime is lazy and
89
+ // only spawns on first force, so opening settings starts Ollama rather than hitting a refused
90
+ // connection, and a chat already using the resolver does not spawn a second process. The endpoint
91
+ // is unused; forcing `OllamaSidecar` is what triggers the spawn. Failures surface as defects.
92
+ const ensureRunning: Effect.Effect<void> = Effect.asVoid(OllamaSidecar).pipe(Effect.provide(sidecarLayer));
93
+
94
+ // Run an admin effect with the HttpClient provided, folding its typed failure into an Either so
95
+ // callers branch on the result without a typed error channel.
96
+ const runAdmin = <A, E extends { readonly message: string }>(
97
+ effect: Effect.Effect<A, E, HttpClient.HttpClient>,
98
+ ): Effect.Effect<Either.Either<A, string>> =>
99
+ effect.pipe(Effect.provide(clientLayer), Effect.either, Effect.map(Either.mapLeft((error) => error.message)));
100
+
101
+ // In-flight pull fibers, so a pull can be cancelled via interruption.
102
+ const pullFibers = new Map<string, Fiber.RuntimeFiber<void>>();
103
+
104
+ // Refresh only the loaded-into-memory set (cheap; no spawn). Logs load/unload transitions so the
105
+ // console reflects which model is resident when a chat request triggers a load.
106
+ const refreshLoaded: Effect.Effect<void> = Effect.gen(function* () {
107
+ const result = yield* runAdmin(admin.ps);
108
+ if (Either.isLeft(result)) {
109
+ return;
110
+ }
111
+ const before = (yield* getState).loaded.map((model) => model.name);
112
+ const after = result.right.map((model) => model.name);
113
+ if (before.join() !== after.join()) {
114
+ yield* Effect.sync(() => log.info('ollama loaded models changed', { loaded: after }));
115
+ }
116
+ yield* updateState((state) => ({ ...state, loaded: result.right }));
117
+ });
118
+
119
+ const refresh: Effect.Effect<void> = Effect.gen(function* () {
120
+ yield* updateState((state) => ({ ...state, kind: 'loading', error: undefined }));
121
+ const started = yield* Effect.exit(ensureRunning);
122
+ if (Exit.isFailure(started)) {
123
+ return yield* fail(formatError(Cause.squash(started.cause)));
124
+ }
125
+ // The sidecar process spawns before its HTTP server is listening, so retry until the first
126
+ // `list` succeeds rather than reporting a spurious failure on startup.
127
+ const result = yield* runAdmin(
128
+ admin.list.pipe(Effect.retry({ schedule: Schedule.spaced(Duration.millis(300)), times: 29 })),
129
+ );
130
+ if (Either.isLeft(result)) {
131
+ return yield* fail(result.left);
132
+ }
133
+ yield* updateState((state) => ({ ...state, kind: 'ready', models: result.right, error: undefined }));
134
+ yield* Effect.sync(() => log.info('ollama models', { installed: result.right.map((model) => model.name) }));
135
+ yield* refreshLoaded;
136
+ });
137
+
138
+ const pull = (name: string): Effect.Effect<void> =>
139
+ Effect.gen(function* () {
140
+ const started = yield* Effect.exit(ensureRunning);
141
+ if (Exit.isFailure(started)) {
142
+ return yield* fail(formatError(Cause.squash(started.cause)));
143
+ }
144
+ yield* setError(name, undefined);
145
+ yield* Effect.sync(() => log.info('ollama pull started', { name }));
146
+ yield* setProgress(name, { status: 'starting' });
147
+
148
+ // Ollama reports `completed`/`total` per layer (digest); aggregate across layers so the
149
+ // overall percent is monotonic rather than resetting to 0 as each layer starts.
150
+ const downloaded = new Map<string, { completed: number; total: number }>();
151
+ const onProgress = (progress: OllamaAdmin.PullProgress): Effect.Effect<void> =>
152
+ Effect.suspend(() => {
153
+ if (progress.digest && progress.total) {
154
+ downloaded.set(progress.digest, { completed: progress.completed ?? 0, total: progress.total });
155
+ let completed = 0;
156
+ let total = 0;
157
+ for (const layer of downloaded.values()) {
158
+ completed += layer.completed;
159
+ total += layer.total;
160
+ }
161
+ return setProgress(name, { status: progress.status, completed, total });
162
+ }
163
+ // Non-download phase (manifest, verifying, writing): keep the status label, drop totals.
164
+ return setProgress(name, { status: progress.status });
165
+ });
166
+
167
+ // Run the pull on a daemon fiber so `cancel` can interrupt it; clear progress and drop the
168
+ // fiber on every exit path. A cancelled pull interrupts the fiber — treated as a no-op.
169
+ const work = admin.pull(name).pipe(
170
+ Stream.runForEach(onProgress),
171
+ Effect.provide(clientLayer),
172
+ Effect.matchCauseEffect({
173
+ onFailure: (cause) =>
174
+ Cause.isInterruptedOnly(cause)
175
+ ? Effect.sync(() => log.info('ollama pull finished', { name, cancelled: true }))
176
+ : Effect.gen(function* () {
177
+ const message = formatError(Cause.squash(cause));
178
+ yield* Effect.sync(() => log.warn('ollama pull failed', { name, error: message }));
179
+ yield* setError(name, message);
180
+ }),
181
+ onSuccess: () =>
182
+ Effect.gen(function* () {
183
+ yield* Effect.sync(() => log.info('ollama pull finished', { name, cancelled: false }));
184
+ yield* refresh;
185
+ }),
186
+ }),
187
+ Effect.ensuring(setProgress(name, undefined)),
188
+ Effect.ensuring(Effect.sync(() => pullFibers.delete(name))),
189
+ );
190
+
191
+ const fiber = yield* Effect.forkDaemon(work);
192
+ yield* Effect.sync(() => pullFibers.set(name, fiber));
193
+ });
194
+
195
+ const cancel = (name: string): Effect.Effect<void> =>
196
+ Effect.gen(function* () {
197
+ yield* Effect.sync(() => log.info('ollama pull cancelled', { name }));
198
+ const fiber = pullFibers.get(name);
199
+ if (fiber) {
200
+ // The pull's `ensuring` clears progress and drops the fiber on interruption.
201
+ yield* Fiber.interrupt(fiber);
202
+ }
203
+ });
204
+
205
+ const load = (name: string): Effect.Effect<void> =>
206
+ Effect.gen(function* () {
207
+ yield* setError(name, undefined);
208
+ const started = yield* Effect.exit(ensureRunning);
209
+ if (Exit.isFailure(started)) {
210
+ return yield* setError(name, formatError(Cause.squash(started.cause)));
211
+ }
212
+ yield* Effect.sync(() => log.info('ollama load', { name }));
213
+ const result = yield* runAdmin(admin.load(name));
214
+ if (Either.isLeft(result)) {
215
+ yield* Effect.sync(() => log.warn('ollama load failed', { name, error: result.left }));
216
+ return yield* setError(name, result.left);
217
+ }
218
+ yield* refreshLoaded;
219
+ });
220
+
221
+ const unload = (name: string): Effect.Effect<void> =>
222
+ Effect.gen(function* () {
223
+ yield* setError(name, undefined);
224
+ const started = yield* Effect.exit(ensureRunning);
225
+ if (Exit.isFailure(started)) {
226
+ return yield* setError(name, formatError(Cause.squash(started.cause)));
227
+ }
228
+ yield* Effect.sync(() => log.info('ollama unload', { name }));
229
+ const result = yield* runAdmin(admin.unload(name));
230
+ if (Either.isLeft(result)) {
231
+ return yield* setError(name, result.left);
232
+ }
233
+ yield* refreshLoaded;
234
+ });
235
+
236
+ const remove = (name: string): Effect.Effect<void> =>
237
+ Effect.gen(function* () {
238
+ yield* setError(name, undefined);
239
+ const started = yield* Effect.exit(ensureRunning);
240
+ if (Exit.isFailure(started)) {
241
+ return yield* setError(name, formatError(Cause.squash(started.cause)));
242
+ }
243
+ const result = yield* runAdmin(admin.remove(name));
244
+ if (Either.isLeft(result)) {
245
+ return yield* setError(name, result.left);
246
+ }
247
+ yield* refresh;
248
+ });
249
+
250
+ const manager: Ollama.Manager = {
251
+ endpoint: OLLAMA_HOST,
252
+ state: stateAtom,
253
+ refresh,
254
+ refreshLoaded,
255
+ pull,
256
+ cancel,
257
+ load,
258
+ unload,
259
+ remove,
260
+ };
261
+
262
+ return [
263
+ // The runtime-dispose finalizer lives on the resolver contribution only; the manager closes
264
+ // over the same runtime, so there is a single disposal path.
265
+ Capability.contributes(
266
+ AppCapabilities.AiModelResolver,
267
+ OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
268
+ () => Effect.tryPromise(() => runtime.dispose()),
269
+ ),
270
+ Capability.contributes(AssistantCapabilities.OllamaManager, manager),
271
+ ];
38
272
  }),
39
273
  );
40
274
 
@@ -47,6 +281,9 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
47
281
  static layerLive = Layer.scoped(
48
282
  OllamaSidecar,
49
283
  Effect.gen(function* () {
284
+ // The `ollama` launcher discovers `llama-server` + its libraries relative to its own
285
+ // executable (`<exe>/lib/ollama/`), ignoring OLLAMA_LIBRARY_PATH, so the runtime ships into
286
+ // `Contents/MacOS/lib/ollama` next to the signed sidecar (see tauri.conf bundle.macOS.files).
50
287
  const command = Command.sidecar('sidecar/ollama', ['serve'], {
51
288
  env: {
52
289
  OLLAMA_HOST,
@@ -54,11 +291,11 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
54
291
  },
55
292
  });
56
293
 
57
- // NOTE: Keeping those as console.log for consistent formatting.
58
- // eslint-disable-next-line no-console
59
- command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
60
- // eslint-disable-next-line no-console
61
- command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
294
+ // Ollama writes nearly all of its output (including normal startup/inference logs) to stderr,
295
+ // so route by the structured `level=` field rather than the stream to avoid flooding the
296
+ // console with red errors. Kept on `console.*` for Ollama's own line formatting.
297
+ command.stdout.on('data', (data) => logSidecar(data.toString()));
298
+ command.stderr.on('data', (data) => logSidecar(data.toString()));
62
299
  command.on('close', (code) => log.info('Ollama process exited', { code }));
63
300
  command.on('error', (error) => log.error('Ollama error', { error }));
64
301
  const child = yield* Effect.promise(() => command.spawn());
@@ -82,7 +319,35 @@ const OllamaSidecarModelResolver: Layer.Layer<AiModelResolver.AiModelResolver, n
82
319
  const { endpoint } = yield* OllamaSidecar;
83
320
  return OllamaResolver.make({
84
321
  endpoint,
322
+ provider: Provider.builtIn.id,
85
323
  transformClient: HttpClient.withTracerPropagation(false),
86
324
  });
87
325
  }),
88
326
  ).pipe(Layer.provide(FetchHttpClient.layer));
327
+
328
+ const formatError = (error: unknown): string =>
329
+ typeof error === 'string' ? error : error instanceof Error ? error.message : String(error);
330
+
331
+ /** Effect HttpClient layer shared by every admin call. */
332
+ const clientLayer = FetchHttpClient.layer;
333
+
334
+ /**
335
+ * Route a chunk of Ollama process output to the console by its structured log level. Ollama emits
336
+ * `INFO`/`WARN` to stderr alongside genuine errors, so only `level=ERROR` lines surface as errors.
337
+ */
338
+ const logSidecar = (chunk: string): void => {
339
+ for (const line of chunk.split('\n')) {
340
+ if (line.trim().length === 0) {
341
+ continue;
342
+ }
343
+ /* eslint-disable no-console */
344
+ if (line.includes('level=ERROR')) {
345
+ console.error('[ollama]', line);
346
+ } else if (line.includes('level=WARN')) {
347
+ console.warn('[ollama]', line);
348
+ } else {
349
+ console.log('[ollama]', line);
350
+ }
351
+ /* eslint-enable no-console */
352
+ }
353
+ };
@@ -9,7 +9,7 @@ import { Capabilities, Capability } from '@dxos/app-framework';
9
9
  import { Surface, useSettingsState } from '@dxos/app-framework/ui';
10
10
  import { AppSurface } from '@dxos/app-toolkit/ui';
11
11
 
12
- import { NativeSettings } from '#components';
12
+ import { NativeSettings } from '#containers';
13
13
  import { meta } from '#meta';
14
14
  import { type Settings } from '#types';
15
15
 
@@ -18,7 +18,7 @@ export default Capability.makeModule(() =>
18
18
  Capability.contributes(Capabilities.ReactSurface, [
19
19
  Surface.create({
20
20
  id: 'pluginSettings',
21
- filter: AppSurface.settings(AppSurface.Article, meta.id),
21
+ filter: AppSurface.settings(AppSurface.Article, meta.profile.key),
22
22
  component: ({ data: { subject } }) => {
23
23
  const { settings, updateSettings } = useSettingsState<Settings.Settings>(subject.atom);
24
24
  return <NativeSettings settings={settings} onSettingsChange={updateSettings} />;
@@ -14,7 +14,7 @@ import { NativeCapabilities, Settings } from '#types';
14
14
  export default Capability.makeModule(() =>
15
15
  Effect.sync(() => {
16
16
  const settingsAtom = createKvsStore({
17
- key: meta.id,
17
+ key: meta.profile.key,
18
18
  schema: Settings.Settings,
19
19
  defaultValue: () => ({}),
20
20
  });
@@ -22,7 +22,7 @@ export default Capability.makeModule(() =>
22
22
  return [
23
23
  Capability.contributes(NativeCapabilities.Settings, settingsAtom),
24
24
  Capability.contributes(AppCapabilities.Settings, {
25
- prefix: meta.id,
25
+ prefix: meta.profile.key,
26
26
  schema: Settings.Settings,
27
27
  atom: settingsAtom,
28
28
  }),
@@ -167,12 +167,12 @@ export default Capability.makeModule(
167
167
  return true;
168
168
  }
169
169
  yield* invoke(LayoutOperation.AddToast, {
170
- id: `${meta.id}.update-ready`,
171
- title: ['update-ready.label', { ns: meta.id }],
172
- description: ['update-ready.description', { ns: meta.id }],
170
+ id: `${meta.profile.key}.update-ready`,
171
+ title: ['update-ready.label', { ns: meta.profile.key }],
172
+ description: ['update-ready.description', { ns: meta.profile.key }],
173
173
  duration: Infinity,
174
- actionLabel: ['update.label', { ns: meta.id }],
175
- actionAlt: ['update.alt', { ns: meta.id }],
174
+ actionLabel: ['update.label', { ns: meta.profile.key }],
175
+ actionAlt: ['update.alt', { ns: meta.profile.key }],
176
176
  onAction: () => relaunch(),
177
177
  });
178
178
  return false;
@@ -5,17 +5,18 @@
5
5
  import { useAtomValue } from '@effect-atom/atom-react';
6
6
  import { formatDistanceToNow } from 'date-fns/formatDistanceToNow';
7
7
  import * as Match from 'effect/Match';
8
+ import * as Schema from 'effect/Schema';
8
9
  import React, { type ReactNode, useState } from 'react';
9
10
 
10
11
  import { useCapability } from '@dxos/app-framework/ui';
11
12
  import { type AppSurface } from '@dxos/app-toolkit/ui';
12
13
  import { Button, useTranslation } from '@dxos/react-ui';
13
- import { Settings as SettingsForm } from '@dxos/react-ui-form';
14
+ import { Form } from '@dxos/react-ui-form';
14
15
 
15
16
  import { meta } from '#meta';
16
17
  import { NativeCapabilities, type Settings, type Update } from '#types';
17
18
 
18
- export type NativeSettingsProps = AppSurface.SettingsArticleProps<Settings.Settings>;
19
+ export type NativeSettingsProps = AppSurface.SettingsProps<Settings.Settings>;
19
20
 
20
21
  type Pending = null | 'check' | 'install' | 'relaunch';
21
22
 
@@ -28,7 +29,7 @@ type UpdateActions = {
28
29
  type UpdateRow = { description: string; button: ReactNode };
29
30
 
30
31
  export const NativeSettings = (_props: NativeSettingsProps) => {
31
- const { t } = useTranslation(meta.id);
32
+ const { t } = useTranslation(meta.profile.key);
32
33
  const manager = useCapability(NativeCapabilities.UpdateManager);
33
34
  const status = useAtomValue(manager.status);
34
35
 
@@ -53,13 +54,17 @@ export const NativeSettings = (_props: NativeSettingsProps) => {
53
54
  });
54
55
 
55
56
  return (
56
- <SettingsForm.Viewport>
57
- <SettingsForm.Section title={t('settings.title')}>
58
- <SettingsForm.Item title={t('settings.updates.label')} description={description}>
59
- {button}
60
- </SettingsForm.Item>
61
- </SettingsForm.Section>
62
- </SettingsForm.Viewport>
57
+ <Form.Root schema={Schema.Struct({})} values={{}} variant='settings'>
58
+ <Form.Viewport scroll>
59
+ <Form.Content>
60
+ <Form.Section title={meta.profile.name ?? meta.profile.key}>
61
+ <Form.Row label={t('settings.updates.label')} description={description}>
62
+ {button}
63
+ </Form.Row>
64
+ </Form.Section>
65
+ </Form.Content>
66
+ </Form.Viewport>
67
+ </Form.Root>
63
68
  );
64
69
  };
65
70
 
package/src/meta.ts CHANGED
@@ -3,30 +3,8 @@
3
3
  //
4
4
 
5
5
  import { Plugin } from '@dxos/app-framework';
6
- import { DXN } from '@dxos/keys';
7
- import { trim } from '@dxos/util';
8
6
 
9
- // TODO(wittjosiah): Rename plugin (package + id) from `native` to `app` to match the user-facing name.
10
- export const meta = Plugin.makeMeta({
11
- key: DXN.make('org.dxos.plugin.native'),
12
- name: 'App',
13
- author: 'DXOS',
14
- spec: 'PLUGIN.mdl',
15
- description: trim`
16
- Tauri-based native platform integration for DXOS Composer on macOS, Linux, and Windows.
17
-
18
- Provides Spotlight window integration that forwards spotlight:invoke Tauri events to
19
- Composer operations, letting the OS-level launcher open spaces and switch workspaces
20
- without the main window being focused first.
7
+ import config from '../dx.config';
21
8
 
22
- Manages over-the-air application updates via the Tauri updater plugin, automatically
23
- checking for new releases in the background, streaming download progress, and surfacing
24
- a toast notification with a one-click Relaunch action when an update is ready.
25
-
26
- Spawns an Ollama sidecar process on localhost for local AI model inference, registering
27
- it as an AiModelResolver so Assistant features can resolve model requests without any
28
- external server dependency.
29
- `,
30
- icon: 'ph--app-window--regular',
31
- tags: ['system'],
32
- });
9
+ // TODO(wittjosiah): Rename plugin (package + id) from `native` to `app` to match the user-facing name.
10
+ export const meta = Plugin.getMetaFromConfig(config);
@@ -9,12 +9,11 @@ import { meta } from '#meta';
9
9
  export const translations = [
10
10
  {
11
11
  'en-US': {
12
- [meta.id]: {
12
+ [meta.profile.key]: {
13
13
  'update-ready.label': 'Ready to update',
14
14
  'update-ready.description': 'A new version of Composer is available.',
15
15
  'update.label': 'Update',
16
16
  'update.alt': 'Relaunch the app to update',
17
- 'settings.title': 'App',
18
17
  'settings.updates.label': 'Updates',
19
18
  'settings.updates.check.label': 'Check for updates',
20
19
  'settings.updates.checking.label': 'Checking…',
@@ -12,5 +12,9 @@ import { meta } from '#meta';
12
12
 
13
13
  // Inline imports to avoid `Settings` / `Update` namespace aliases colliding with the
14
14
  // capability constants exported below.
15
- export const Settings = Capability.make<Atom.Writable<import('./Settings').Settings>>(`${meta.id}.capability.settings`);
16
- export const UpdateManager = Capability.make<import('./Update').Manager>(`${meta.id}.capability.update-manager`);
15
+ export const Settings = Capability.make<Atom.Writable<import('./Settings').Settings>>(
16
+ `${meta.profile.key}.capability.settings`,
17
+ );
18
+ export const UpdateManager = Capability.make<import('./Update').Manager>(
19
+ `${meta.profile.key}.capability.update-manager`,
20
+ );