@dxos/plugin-native 0.8.4-main.67995b8 → 0.8.4-main.f5c0578

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-native",
3
- "version": "0.8.4-main.67995b8",
3
+ "version": "0.8.4-main.f5c0578",
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",
@@ -10,9 +10,9 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
- "browser": "./dist/lib/browser/index.mjs",
15
- "source": "./src/index.ts"
15
+ "browser": "./dist/lib/browser/index.mjs"
16
16
  }
17
17
  },
18
18
  "types": "dist/types/src/index.d.ts",
@@ -24,23 +24,27 @@
24
24
  "src"
25
25
  ],
26
26
  "dependencies": {
27
+ "@effect/platform": "^0.90.2",
27
28
  "@tauri-apps/plugin-os": "^2.3.0",
28
29
  "@tauri-apps/plugin-process": "^2.3.0",
30
+ "@tauri-apps/plugin-shell": "^2.3.0",
29
31
  "@tauri-apps/plugin-updater": "^2.9.0",
30
- "effect": "3.17.0",
31
- "@dxos/app-framework": "0.8.4-main.67995b8",
32
- "@dxos/log": "0.8.4-main.67995b8",
33
- "@dxos/plugin-help": "0.8.4-main.67995b8",
34
- "@dxos/plugin-navtree": "0.8.4-main.67995b8",
35
- "@dxos/util": "0.8.4-main.67995b8"
32
+ "effect": "3.17.7",
33
+ "@dxos/ai": "0.8.4-main.f5c0578",
34
+ "@dxos/app-framework": "0.8.4-main.f5c0578",
35
+ "@dxos/log": "0.8.4-main.f5c0578",
36
+ "@dxos/plugin-navtree": "0.8.4-main.f5c0578",
37
+ "@dxos/util": "0.8.4-main.f5c0578",
38
+ "@dxos/plugin-assistant": "0.8.4-main.f5c0578",
39
+ "@dxos/plugin-help": "0.8.4-main.f5c0578"
36
40
  },
37
41
  "devDependencies": {
38
42
  "vite": "5.4.7",
39
- "@dxos/react-ui": "0.8.4-main.67995b8"
43
+ "@dxos/react-ui": "0.8.4-main.f5c0578"
40
44
  },
41
45
  "peerDependencies": {
42
46
  "effect": "^3.13.3",
43
- "@dxos/react-ui": "0.8.4-main.67995b8"
47
+ "@dxos/react-ui": "0.8.4-main.f5c0578"
44
48
  },
45
49
  "publishConfig": {
46
50
  "access": "public"
@@ -2,9 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { definePlugin, Events, defineModule, contributes, Capabilities } from '@dxos/app-framework';
5
+ import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
+ import { AssistantEvents } from '@dxos/plugin-assistant';
6
7
 
7
- import { Updater } from './capabilities';
8
+ import { Ollama, Updater } from './capabilities';
8
9
  import { meta } from './meta';
9
10
  import { translations } from './translations';
10
11
 
@@ -20,4 +21,9 @@ export const NativePlugin = () =>
20
21
  activatesOn: Events.DispatcherReady,
21
22
  activate: Updater,
22
23
  }),
24
+ defineModule({
25
+ id: `${meta.id}/module/ollama`,
26
+ activatesOn: AssistantEvents.SetupAiServiceProviders,
27
+ activate: Ollama,
28
+ }),
23
29
  ]);
@@ -5,3 +5,4 @@
5
5
  import { lazy } from '@dxos/app-framework';
6
6
 
7
7
  export const Updater = lazy(() => import('./updater'));
8
+ export const Ollama = lazy(() => import('./ollama'));
@@ -0,0 +1,79 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { FetchHttpClient, HttpClient } from '@effect/platform';
6
+ import { Command } from '@tauri-apps/plugin-shell';
7
+ import { Context, Effect, Layer, ManagedRuntime } from 'effect';
8
+
9
+ import { AiServiceRouter } from '@dxos/ai';
10
+ import { type PluginContext, contributes } from '@dxos/app-framework';
11
+ import { log } from '@dxos/log';
12
+ import { AssistantCapabilities } from '@dxos/plugin-assistant';
13
+
14
+ // Running ollama on non-standard port.
15
+ const OLLAMA_HOST = 'http://localhost:21434';
16
+
17
+ export default (_context: PluginContext) => {
18
+ const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
19
+
20
+ // Layer for the sidecar but the lifecycle is managed by the runtime.
21
+ const sidecarLayer = Layer.effectContext(
22
+ runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),
23
+ );
24
+
25
+ return contributes(
26
+ AssistantCapabilities.AiModelResolver,
27
+ OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
28
+ async () => {
29
+ await runtime.dispose();
30
+ },
31
+ );
32
+ };
33
+
34
+ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
35
+ OllamaSidecar,
36
+ {
37
+ endpoint: string;
38
+ }
39
+ >() {
40
+ static layerLive = Layer.scoped(
41
+ OllamaSidecar,
42
+ Effect.gen(function* () {
43
+ const command = Command.sidecar('sidecar/ollama', ['serve'], {
44
+ env: {
45
+ OLLAMA_HOST,
46
+ OLLAMA_ORIGINS: '*', // CORS
47
+ },
48
+ });
49
+
50
+ // NOTE: Keeping those as console.log for consistent formatting.
51
+ command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
52
+ command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
53
+ command.on('close', (code) => log.info('Ollama process exited', { code }));
54
+ command.on('error', (error) => log.error('Ollama error', { error }));
55
+ const child = yield* Effect.promise(() => command.spawn());
56
+ yield* Effect.addFinalizer(
57
+ Effect.fn(function* () {
58
+ yield* Effect.promise(() => child.kill());
59
+ }),
60
+ );
61
+ log.info('Running ollama', { pid: child.pid });
62
+
63
+ return {
64
+ endpoint: OLLAMA_HOST,
65
+ };
66
+ }),
67
+ );
68
+ }
69
+
70
+ const OllamaSidecarModelResolver: Layer.Layer<AiServiceRouter.AiModelResolver, never, OllamaSidecar> =
71
+ Layer.unwrapEffect(
72
+ Effect.gen(function* () {
73
+ const { endpoint } = yield* OllamaSidecar;
74
+ return AiServiceRouter.OllamaResolver({
75
+ host: endpoint,
76
+ transformClient: HttpClient.withTracerPropagation(false),
77
+ });
78
+ }),
79
+ ).pipe(Layer.provide(FetchHttpClient.layer));
@@ -4,10 +4,10 @@
4
4
 
5
5
  import { type } from '@tauri-apps/plugin-os';
6
6
  import { relaunch } from '@tauri-apps/plugin-process';
7
- import { check, type DownloadEvent } from '@tauri-apps/plugin-updater';
8
- import { Duration, Effect, Fiber, Match, pipe, Schedule } from 'effect';
7
+ import { type DownloadEvent, check } from '@tauri-apps/plugin-updater';
8
+ import { Duration, Effect, Fiber, Match, Schedule, pipe } from 'effect';
9
9
 
10
- import { Capabilities, contributes, createIntent, LayoutAction, type PluginContext } from '@dxos/app-framework';
10
+ import { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
11
11
  import { log } from '@dxos/log';
12
12
 
13
13
  import { NATIVE_PLUGIN } from '../meta';