@dxos/plugin-native 0.8.4-main.70d3990 → 0.8.4-main.7996785055

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 (60) hide show
  1. package/dist/lib/browser/{chunk-SP3MEGKI.mjs → chunk-C7OU2UF6.mjs} +2 -2
  2. package/dist/lib/browser/chunk-C7OU2UF6.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +33 -30
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{ollama-CQE7ZIWL.mjs → ollama-QOB3EVAJ.mjs} +14 -15
  7. package/dist/lib/browser/ollama-QOB3EVAJ.mjs.map +7 -0
  8. package/dist/lib/browser/spotlight-listener-YWC4SLQK.mjs +61 -0
  9. package/dist/lib/browser/spotlight-listener-YWC4SLQK.mjs.map +7 -0
  10. package/dist/lib/browser/updater-FDID3Y6C.mjs +199 -0
  11. package/dist/lib/browser/updater-FDID3Y6C.mjs.map +7 -0
  12. package/dist/types/src/NativePlugin.d.ts +2 -1
  13. package/dist/types/src/NativePlugin.d.ts.map +1 -1
  14. package/dist/types/src/capabilities/index.d.ts +3 -3
  15. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/ollama/index.d.ts +3 -0
  17. package/dist/types/src/capabilities/ollama/index.d.ts.map +1 -0
  18. package/dist/types/src/capabilities/ollama/ollama.d.ts +7 -0
  19. package/dist/types/src/capabilities/ollama/ollama.d.ts.map +1 -0
  20. package/dist/types/src/capabilities/spotlight-listener/index.d.ts +3 -0
  21. package/dist/types/src/capabilities/spotlight-listener/index.d.ts.map +1 -0
  22. package/dist/types/src/capabilities/spotlight-listener/spotlight-listener.d.ts +8 -0
  23. package/dist/types/src/capabilities/spotlight-listener/spotlight-listener.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/updater/index.d.ts +3 -0
  25. package/dist/types/src/capabilities/updater/index.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/updater/updater.d.ts +5 -0
  27. package/dist/types/src/capabilities/updater/updater.d.ts.map +1 -0
  28. package/dist/types/src/constants.d.ts +2 -0
  29. package/dist/types/src/constants.d.ts.map +1 -0
  30. package/dist/types/src/index.d.ts +1 -0
  31. package/dist/types/src/index.d.ts.map +1 -1
  32. package/dist/types/src/meta.d.ts +2 -2
  33. package/dist/types/src/meta.d.ts.map +1 -1
  34. package/dist/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +20 -14
  36. package/src/NativePlugin.tsx +16 -18
  37. package/src/capabilities/index.ts +3 -5
  38. package/src/capabilities/ollama/index.ts +7 -0
  39. package/src/capabilities/{ollama.ts → ollama/ollama.ts} +26 -20
  40. package/src/capabilities/spotlight-listener/index.ts +7 -0
  41. package/src/capabilities/spotlight-listener/spotlight-listener.ts +58 -0
  42. package/src/capabilities/updater/index.ts +7 -0
  43. package/src/capabilities/updater/updater.ts +128 -0
  44. package/src/constants.ts +7 -0
  45. package/src/index.ts +1 -0
  46. package/src/meta.ts +3 -3
  47. package/dist/lib/browser/chunk-SP3MEGKI.mjs.map +0 -7
  48. package/dist/lib/browser/ollama-CQE7ZIWL.mjs.map +0 -7
  49. package/dist/lib/browser/updater-SDBPTCXA.mjs +0 -138
  50. package/dist/lib/browser/updater-SDBPTCXA.mjs.map +0 -7
  51. package/dist/lib/browser/window-6G542FZL.mjs +0 -34
  52. package/dist/lib/browser/window-6G542FZL.mjs.map +0 -7
  53. package/dist/types/src/capabilities/ollama.d.ts +0 -4
  54. package/dist/types/src/capabilities/ollama.d.ts.map +0 -1
  55. package/dist/types/src/capabilities/updater.d.ts +0 -4
  56. package/dist/types/src/capabilities/updater.d.ts.map +0 -1
  57. package/dist/types/src/capabilities/window.d.ts +0 -4
  58. package/dist/types/src/capabilities/window.d.ts.map +0 -1
  59. package/src/capabilities/updater.ts +0 -85
  60. package/src/capabilities/window.ts +0 -49
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@dxos/plugin-native",
3
- "version": "0.8.4-main.70d3990",
3
+ "version": "0.8.4-main.7996785055",
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",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
@@ -24,28 +28,30 @@
24
28
  "src"
25
29
  ],
26
30
  "dependencies": {
27
- "@effect/platform": "^0.92.1",
31
+ "@effect/platform": "0.94.4",
28
32
  "@tauri-apps/api": "^2.8.0",
29
33
  "@tauri-apps/plugin-os": "^2.3.1",
30
34
  "@tauri-apps/plugin-process": "^2.3.0",
31
35
  "@tauri-apps/plugin-shell": "^2.3.1",
32
36
  "@tauri-apps/plugin-updater": "^2.9.0",
33
- "effect": "3.18.3",
34
- "@dxos/app-framework": "0.8.4-main.70d3990",
35
- "@dxos/log": "0.8.4-main.70d3990",
36
- "@dxos/plugin-assistant": "0.8.4-main.70d3990",
37
- "@dxos/ai": "0.8.4-main.70d3990",
38
- "@dxos/plugin-navtree": "0.8.4-main.70d3990",
39
- "@dxos/util": "0.8.4-main.70d3990",
40
- "@dxos/plugin-help": "0.8.4-main.70d3990"
37
+ "effect": "3.20.0",
38
+ "@dxos/app-toolkit": "0.8.4-main.7996785055",
39
+ "@dxos/ai": "0.8.4-main.7996785055",
40
+ "@dxos/log": "0.8.4-main.7996785055",
41
+ "@dxos/plugin-assistant": "0.8.4-main.7996785055",
42
+ "@dxos/operation": "0.8.4-main.7996785055",
43
+ "@dxos/plugin-help": "0.8.4-main.7996785055",
44
+ "@dxos/plugin-navtree": "0.8.4-main.7996785055",
45
+ "@dxos/app-framework": "0.8.4-main.7996785055",
46
+ "@dxos/util": "0.8.4-main.7996785055"
41
47
  },
42
48
  "devDependencies": {
43
- "vite": "7.1.9",
44
- "@dxos/react-ui": "0.8.4-main.70d3990"
49
+ "vite": "^7.1.11",
50
+ "@dxos/react-ui": "0.8.4-main.7996785055"
45
51
  },
46
52
  "peerDependencies": {
47
- "effect": "^3.13.3",
48
- "@dxos/react-ui": "0.8.4-main.70d3990"
53
+ "effect": "3.20.0",
54
+ "@dxos/react-ui": "0.8.4-main.7996785055"
49
55
  },
50
56
  "publishConfig": {
51
57
  "access": "public"
@@ -2,32 +2,30 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
5
+ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
6
7
  import { AssistantEvents } from '@dxos/plugin-assistant';
7
8
 
8
- import { Ollama, Updater, Window } from './capabilities';
9
+ import { Ollama, SpotlightListener, Updater } from './capabilities';
9
10
  import { meta } from './meta';
10
11
  import { translations } from './translations';
11
12
 
12
- export const NativePlugin = definePlugin(meta, () => [
13
- defineModule({
14
- id: `${meta.id}/module/translations`,
15
- activatesOn: Events.SetupTranslations,
16
- activate: () => contributes(Capabilities.Translations, translations),
13
+ export const NativePlugin = Plugin.define(meta).pipe(
14
+ AppPlugin.addTranslationsModule({ translations }),
15
+ Plugin.addModule({
16
+ id: 'spotlight-listener',
17
+ activatesOn: ActivationEvents.OperationInvokerReady,
18
+ activate: SpotlightListener,
17
19
  }),
18
- defineModule({
19
- id: `${meta.id}/module/updater`,
20
- activatesOn: Events.DispatcherReady,
20
+ Plugin.addModule({
21
+ id: 'updater',
22
+ activatesOn: ActivationEvents.OperationInvokerReady,
21
23
  activate: Updater,
22
24
  }),
23
- defineModule({
24
- id: `${meta.id}/module/window`,
25
- activatesOn: Events.DispatcherReady,
26
- activate: Window,
27
- }),
28
- defineModule({
29
- id: `${meta.id}/module/ollama`,
25
+ Plugin.addModule({
26
+ id: 'ollama',
30
27
  activatesOn: AssistantEvents.SetupAiServiceProviders,
31
28
  activate: Ollama,
32
29
  }),
33
- ]);
30
+ Plugin.make,
31
+ );
@@ -2,8 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
6
-
7
- export const Ollama = lazy(() => import('./ollama'));
8
- export const Updater = lazy(() => import('./updater'));
9
- export const Window = lazy(() => import('./window'));
5
+ export * from './ollama';
6
+ export * from './spotlight-listener';
7
+ export * from './updater';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const Ollama = Capability.lazy('Ollama', () => import('./ollama'));
@@ -10,29 +10,33 @@ import * as Effect from 'effect/Effect';
10
10
  import * as Layer from 'effect/Layer';
11
11
  import * as ManagedRuntime from 'effect/ManagedRuntime';
12
12
 
13
- import * as AiServiceRouter from '@dxos/ai/AiServiceRouter';
14
- import { Capabilities, type Capability, type PluginContext, contributes } from '@dxos/app-framework';
13
+ import { type AiModelResolver } from '@dxos/ai';
14
+ import { OllamaResolver } from '@dxos/ai/resolvers';
15
+ import { Capability } from '@dxos/app-framework';
16
+ import { AppCapabilities } from '@dxos/app-toolkit';
15
17
  import { log } from '@dxos/log';
16
18
 
17
- // Running ollama on non-standard port.
19
+ // NOTE: Running ollama on non-standard port (config Tauri).
18
20
  const OLLAMA_HOST = 'http://localhost:21434';
19
21
 
20
- export default (_context: PluginContext): Capability<any> => {
21
- const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
22
+ export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
22
23
 
23
- // Layer for the sidecar but the lifecycle is managed by the runtime.
24
- const sidecarLayer = Layer.effectContext(
25
- runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),
26
- );
24
+ export default Capability.makeModule<[], OllamaCapabilities>(() =>
25
+ Effect.sync(() => {
26
+ const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
27
27
 
28
- return contributes(
29
- Capabilities.AiModelResolver,
30
- OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
31
- async () => {
32
- await runtime.dispose();
33
- },
34
- );
35
- };
28
+ // Layer for the sidecar but the lifecycle is managed by the runtime.
29
+ const sidecarLayer = Layer.effectContext(
30
+ runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),
31
+ );
32
+
33
+ return Capability.contributes(
34
+ AppCapabilities.AiModelResolver,
35
+ OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
36
+ () => Effect.tryPromise(() => runtime.dispose()),
37
+ );
38
+ }),
39
+ );
36
40
 
37
41
  class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
38
42
  OllamaSidecar,
@@ -51,7 +55,9 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
51
55
  });
52
56
 
53
57
  // NOTE: Keeping those as console.log for consistent formatting.
58
+ // eslint-disable-next-line no-console
54
59
  command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
60
+ // eslint-disable-next-line no-console
55
61
  command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
56
62
  command.on('close', (code) => log.info('Ollama process exited', { code }));
57
63
  command.on('error', (error) => log.error('Ollama error', { error }));
@@ -70,12 +76,12 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
70
76
  );
71
77
  }
72
78
 
73
- const OllamaSidecarModelResolver: Layer.Layer<AiServiceRouter.AiModelResolver, never, OllamaSidecar> =
79
+ const OllamaSidecarModelResolver: Layer.Layer<AiModelResolver.AiModelResolver, never, OllamaSidecar> =
74
80
  Layer.unwrapEffect(
75
81
  Effect.gen(function* () {
76
82
  const { endpoint } = yield* OllamaSidecar;
77
- return AiServiceRouter.OllamaResolver({
78
- host: endpoint,
83
+ return OllamaResolver.make({
84
+ endpoint,
79
85
  transformClient: HttpClient.withTracerPropagation(false),
80
86
  });
81
87
  }),
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const SpotlightListener = Capability.lazy('SpotlightListener', () => import('./spotlight-listener'));
@@ -0,0 +1,58 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import { LayoutOperation } from '@dxos/app-toolkit';
9
+ import { log } from '@dxos/log';
10
+
11
+ // TODO(wittjosiah): Formalize with a stricter schema if we evolve this protocol.
12
+ type SpotlightInvokePayload = {
13
+ operation: string;
14
+ payload?: Record<string, any>;
15
+ };
16
+
17
+ /**
18
+ * Listens for spotlight:invoke events from the popover window and dispatches the corresponding operation.
19
+ */
20
+ export default Capability.makeModule(
21
+ Effect.fnUntraced(function* () {
22
+ const { invokePromise } = yield* Capability.get(Capabilities.OperationInvoker);
23
+
24
+ const unlisten = yield* Effect.promise(async () => {
25
+ const { listen } = await import('@tauri-apps/api/event');
26
+ const { getCurrentWindow } = await import('@tauri-apps/api/window');
27
+
28
+ return listen<SpotlightInvokePayload>('spotlight:invoke', async (event) => {
29
+ const { operation, payload } = event.payload;
30
+ log.info('Received spotlight invoke event', { operation, payload });
31
+ try {
32
+ switch (operation) {
33
+ case 'open':
34
+ await invokePromise(LayoutOperation.Open, payload as any);
35
+ break;
36
+ case 'switch-workspace':
37
+ await invokePromise(LayoutOperation.SwitchWorkspace, payload as any);
38
+ break;
39
+ default:
40
+ log.warn('Unknown spotlight operation', { operation });
41
+ }
42
+
43
+ const mainWindow = getCurrentWindow();
44
+ await mainWindow.show();
45
+ await mainWindow.setFocus();
46
+ } catch (err) {
47
+ log.catch(err);
48
+ }
49
+ });
50
+ });
51
+
52
+ return Capability.contributes(Capabilities.Null, null, () =>
53
+ Effect.sync(() => {
54
+ unlisten();
55
+ }),
56
+ );
57
+ }),
58
+ );
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const Updater = Capability.lazy('Updater', () => import('./updater'));
@@ -0,0 +1,128 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type } from '@tauri-apps/plugin-os';
6
+ import { relaunch } from '@tauri-apps/plugin-process';
7
+ import * as Updater from '@tauri-apps/plugin-updater';
8
+ import * as Duration from 'effect/Duration';
9
+ import * as Effect from 'effect/Effect';
10
+ import * as Fiber from 'effect/Fiber';
11
+ import * as Match from 'effect/Match';
12
+ import * as Schedule from 'effect/Schedule';
13
+
14
+ import { Capabilities, Capability } from '@dxos/app-framework';
15
+ import { LayoutOperation } from '@dxos/app-toolkit';
16
+ import { log } from '@dxos/log';
17
+
18
+ import { TAURI_LOCALHOST_PORT } from '../../constants';
19
+ import { meta } from '../../meta';
20
+
21
+ const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
22
+
23
+ /**
24
+ * Safely check for updates with error logging.
25
+ */
26
+ const check = async (): Promise<Updater.Update | null> => {
27
+ try {
28
+ return await Updater.check();
29
+ } catch (error) {
30
+ log.error('failed to check for updates', { error });
31
+ return null;
32
+ }
33
+ };
34
+
35
+ /**
36
+ * Safely download and install update with error logging.
37
+ */
38
+ const downloadAndInstall = async (
39
+ update: Updater.Update,
40
+ handleDownload: (event: Updater.DownloadEvent) => void,
41
+ ): Promise<boolean> => {
42
+ try {
43
+ await update.downloadAndInstall(handleDownload);
44
+ return true;
45
+ } catch (error) {
46
+ log.error('failed to download and install update', { error });
47
+ return false;
48
+ }
49
+ };
50
+
51
+ export default Capability.makeModule(
52
+ Effect.fnUntraced(function* () {
53
+ // Skip updates if not supported or in dev mode.
54
+ const platform = type();
55
+ const isDevServer = window.location.port !== TAURI_LOCALHOST_PORT;
56
+ if (!SUPPORTS_OTA.includes(platform) || isDevServer) {
57
+ log.info('skipping updater', { platform, port: window.location.port });
58
+ return;
59
+ }
60
+
61
+ const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
62
+
63
+ // https://tauri.app/plugin/updater/#checking-for-updates
64
+ // Returns true to keep checking, false to stop.
65
+ const action = Effect.gen(function* () {
66
+ log.info('checking for updates');
67
+ const update = yield* Effect.promise(() => check());
68
+ if (!update) {
69
+ log.info('no update available');
70
+ return true;
71
+ }
72
+ log.info('update check complete', {
73
+ available: update.available,
74
+ currentVersion: update.currentVersion,
75
+ version: update.version,
76
+ date: update.date,
77
+ body: update.body,
78
+ });
79
+ if (update.available) {
80
+ log.info('update available, starting download', { version: update.version });
81
+ let downloaded = 0;
82
+ let contentLength = 0;
83
+
84
+ const handleDownload = Match.type<Updater.DownloadEvent>().pipe(
85
+ Match.when({ event: 'Started' }, (event) => {
86
+ contentLength = event.data.contentLength ?? 0;
87
+ log.info('download started', { contentLength });
88
+ }),
89
+ Match.when({ event: 'Progress' }, (event) => {
90
+ downloaded += event.data.chunkLength;
91
+ log.verbose('download progress', { downloaded, contentLength });
92
+ }),
93
+ Match.when({ event: 'Finished' }, () => {
94
+ log.info('download completed');
95
+ }),
96
+ Match.exhaustive,
97
+ );
98
+
99
+ const downloadSuccess = yield* Effect.promise(() => downloadAndInstall(update, handleDownload));
100
+
101
+ if (downloadSuccess) {
102
+ yield* invoke(LayoutOperation.AddToast, {
103
+ id: `${meta.id}.update-ready`,
104
+ title: ['update ready label', { ns: meta.id }],
105
+ description: ['update ready description', { ns: meta.id }],
106
+ duration: Infinity,
107
+ actionLabel: ['update label', { ns: meta.id }],
108
+ actionAlt: ['update alt', { ns: meta.id }],
109
+ onAction: () => relaunch(),
110
+ });
111
+ return false;
112
+ }
113
+ }
114
+ return true;
115
+ });
116
+
117
+ // Run immediately on startup, then repeat every hour. Stop once an update is found.
118
+ const schedule = Schedule.fixed(Duration.hours(1)).pipe(
119
+ Schedule.whileInput((keepChecking: boolean) => keepChecking),
120
+ );
121
+ const fiber = yield* action.pipe(Effect.repeat(schedule), Effect.forkDaemon);
122
+ log.info('updater module initialized, update check scheduled');
123
+
124
+ return Capability.contributes(Capabilities.Null, null, () =>
125
+ Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
126
+ );
127
+ }),
128
+ );
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ /// Stable port for the Tauri localhost asset server in production builds.
6
+ /// Must match LOCALHOST_PORT in src-tauri/src/lib.rs.
7
+ export const TAURI_LOCALHOST_PORT = '26777';
package/src/index.ts CHANGED
@@ -2,5 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './capabilities';
5
6
  export * from './meta';
6
7
  export * from './NativePlugin';
package/src/meta.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
6
  import { trim } from '@dxos/util';
7
7
 
8
- export const meta: PluginMeta = {
9
- id: 'dxos.org/plugin/native',
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.native',
10
10
  name: 'Native',
11
11
  description: trim`
12
12
  Native platform integration providing desktop-specific features and system-level capabilities.
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/native',\n name: 'Native',\n description: trim`\n Native platform integration providing desktop-specific features and system-level capabilities.\n Access native file dialogs, notifications, and OS integrations.\n `,\n};\n"],
5
- "mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;AAIf;",
6
- "names": ["trim", "meta", "id", "name", "description", "trim"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/ollama.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport { Command } from '@tauri-apps/plugin-shell';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport * as AiServiceRouter from '@dxos/ai/AiServiceRouter';\nimport { Capabilities, type Capability, type PluginContext, contributes } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\n// Running ollama on non-standard port.\nconst OLLAMA_HOST = 'http://localhost:21434';\n\nexport default (_context: PluginContext): Capability<any> => {\n const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);\n\n // Layer for the sidecar but the lifecycle is managed by the runtime.\n const sidecarLayer = Layer.effectContext(\n runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),\n );\n\n return contributes(\n Capabilities.AiModelResolver,\n OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),\n async () => {\n await runtime.dispose();\n },\n );\n};\n\nclass OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<\n OllamaSidecar,\n {\n endpoint: string;\n }\n>() {\n static layerLive = Layer.scoped(\n OllamaSidecar,\n Effect.gen(function* () {\n const command = Command.sidecar('sidecar/ollama', ['serve'], {\n env: {\n OLLAMA_HOST,\n OLLAMA_ORIGINS: '*', // CORS\n },\n });\n\n // NOTE: Keeping those as console.log for consistent formatting.\n command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));\n command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));\n command.on('close', (code) => log.info('Ollama process exited', { code }));\n command.on('error', (error) => log.error('Ollama error', { error }));\n const child = yield* Effect.promise(() => command.spawn());\n yield* Effect.addFinalizer(\n Effect.fn(function* () {\n yield* Effect.promise(() => child.kill());\n }),\n );\n log.info('Running ollama', { pid: child.pid });\n\n return {\n endpoint: OLLAMA_HOST,\n };\n }),\n );\n}\n\nconst OllamaSidecarModelResolver: Layer.Layer<AiServiceRouter.AiModelResolver, never, OllamaSidecar> =\n Layer.unwrapEffect(\n Effect.gen(function* () {\n const { endpoint } = yield* OllamaSidecar;\n return AiServiceRouter.OllamaResolver({\n host: endpoint,\n transformClient: HttpClient.withTracerPropagation(false),\n });\n }),\n ).pipe(Layer.provide(FetchHttpClient.layer));\n"],
5
- "mappings": ";AAIA,YAAYA,qBAAqB;AACjC,YAAYC,gBAAgB;AAC5B,SAASC,eAAe;AACxB,YAAYC,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,YAAYC,qBAAqB;AACjC,SAASC,cAAmDC,mBAAmB;AAC/E,SAASC,WAAW;;AAGpB,IAAMC,cAAc;AAEpB,IAAA,kBAAe,CAACC,aAAAA;AACd,QAAMC,UAAyBC,oBAAKC,cAAcC,SAAS;AAG3D,QAAMC,eAAqBC,oBACzBL,QAAQM,cAAcC,KAAYC,WAAI,CAACC,OAAOA,GAAGC,QAAQH,KAAaI,aAAKT,aAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAG7E,SAAON,YACLD,aAAaiB,iBACbC,2BAA2BN,KAAWO,cAAQV,YAAAA,CAAAA,GAC9C,YAAA;AACE,UAAMJ,QAAQe,QAAO;EACvB,CAAA;AAEJ;AAEA,IAAMb,gBAAN,MAAMA,uBAA8Bc,YAAI,mCAAA,EAAA,EAAA;EAMtC,OAAOb,YAAkBc,aACvBf,gBACOgB,WAAI,aAAA;AACT,UAAMC,UAAU9B,QAAQ+B,QAAQ,kBAAkB;MAAC;OAAU;MAC3DC,KAAK;QACHvB;QACAwB,gBAAgB;MAClB;IACF,CAAA;AAGAH,YAAQI,OAAOC,GAAG,QAAQ,CAACC,SAASC,QAAQ7B,IAAI,YAAY4B,KAAKE,SAAQ,CAAA,CAAA;AACzER,YAAQS,OAAOJ,GAAG,QAAQ,CAACC,SAASC,QAAQG,MAAM,YAAYJ,KAAKE,SAAQ,CAAA,CAAA;AAC3ER,YAAQK,GAAG,SAAS,CAACM,SAASjC,IAAIkC,KAAK,yBAAyB;MAAED;IAAK,GAAA;;;;;;AACvEX,YAAQK,GAAG,SAAS,CAACK,UAAUhC,IAAIgC,MAAM,gBAAgB;MAAEA;IAAM,GAAA;;;;;;AACjE,UAAMG,QAAQ,OAAcC,eAAQ,MAAMd,QAAQe,MAAK,CAAA;AACvD,WAAcC,oBACLC,UAAG,aAAA;AACR,aAAcH,eAAQ,MAAMD,MAAMK,KAAI,CAAA;IACxC,CAAA,CAAA;AAEFxC,QAAIkC,KAAK,kBAAkB;MAAEO,KAAKN,MAAMM;IAAI,GAAA;;;;;;AAE5C,WAAO;MACLC,UAAUzC;IACZ;EACF,CAAA,CAAA;AAEJ;AAEA,IAAMe,6BACE2B,mBACGtB,WAAI,aAAA;AACT,QAAM,EAAEqB,SAAQ,IAAK,OAAOrC;AAC5B,SAAuBuC,+BAAe;IACpCC,MAAMH;IACNI,iBAA4BC,iCAAsB,KAAA;EACpD,CAAA;AACF,CAAA,CAAA,EACArC,KAAWO,cAAwB+B,qBAAK,CAAA;",
6
- "names": ["FetchHttpClient", "HttpClient", "Command", "Context", "Effect", "Layer", "ManagedRuntime", "AiServiceRouter", "Capabilities", "contributes", "log", "OLLAMA_HOST", "_context", "runtime", "make", "OllamaSidecar", "layerLive", "sidecarLayer", "effectContext", "runtimeEffect", "pipe", "map", "rt", "context", "pick", "AiModelResolver", "OllamaSidecarModelResolver", "provide", "dispose", "Tag", "scoped", "gen", "command", "sidecar", "env", "OLLAMA_ORIGINS", "stdout", "on", "data", "console", "toString", "stderr", "error", "code", "info", "child", "promise", "spawn", "addFinalizer", "fn", "kill", "pid", "endpoint", "unwrapEffect", "OllamaResolver", "host", "transformClient", "withTracerPropagation", "layer"]
7
- }
@@ -1,138 +0,0 @@
1
- import {
2
- meta
3
- } from "./chunk-SP3MEGKI.mjs";
4
-
5
- // src/capabilities/updater.ts
6
- import { type } from "@tauri-apps/plugin-os";
7
- import { relaunch } from "@tauri-apps/plugin-process";
8
- import { check } from "@tauri-apps/plugin-updater";
9
- import * as Duration from "effect/Duration";
10
- import * as Effect from "effect/Effect";
11
- import * as Fiber from "effect/Fiber";
12
- import * as Function from "effect/Function";
13
- import * as Match from "effect/Match";
14
- import * as Schedule from "effect/Schedule";
15
- import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
16
- import { log } from "@dxos/log";
17
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-native/src/capabilities/updater.ts";
18
- var SUPPORTS_OTA = [
19
- "linux",
20
- "macos",
21
- "windows"
22
- ];
23
- var updater_default = ((context) => {
24
- const platform = type();
25
- if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === "localhost") {
26
- return contributes(Capabilities.Null, null);
27
- }
28
- const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
29
- const action = Effect.gen(function* () {
30
- log.info("checking for updates", void 0, {
31
- F: __dxlog_file,
32
- L: 33,
33
- S: this,
34
- C: (f, a) => f(...a)
35
- });
36
- const update = yield* Effect.tryPromise(() => check());
37
- log.info("checked for updates", {
38
- version: update?.version,
39
- currentVersion: update?.currentVersion
40
- }, {
41
- F: __dxlog_file,
42
- L: 35,
43
- S: this,
44
- C: (f, a) => f(...a)
45
- });
46
- if (update) {
47
- log.info("update available", update, {
48
- F: __dxlog_file,
49
- L: 37,
50
- S: this,
51
- C: (f, a) => f(...a)
52
- });
53
- let downloaded = 0;
54
- let contentLength = 0;
55
- const handleDownload = Match.type().pipe(Match.when({
56
- event: "Started"
57
- }, (event) => {
58
- contentLength = event.data.contentLength ?? 0;
59
- log.info("download started", {
60
- contentLength
61
- }, {
62
- F: __dxlog_file,
63
- L: 44,
64
- S: this,
65
- C: (f, a) => f(...a)
66
- });
67
- }), Match.when({
68
- event: "Progress"
69
- }, (event) => {
70
- downloaded += event.data.chunkLength;
71
- log.verbose("download progress", {
72
- downloaded,
73
- contentLength
74
- }, {
75
- F: __dxlog_file,
76
- L: 48,
77
- S: this,
78
- C: (f, a) => f(...a)
79
- });
80
- }), Match.when({
81
- event: "Finished"
82
- }, () => {
83
- log.info("download completed", void 0, {
84
- F: __dxlog_file,
85
- L: 51,
86
- S: this,
87
- C: (f, a) => f(...a)
88
- });
89
- }), Match.exhaustive);
90
- yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));
91
- yield* dispatch(createIntent(LayoutAction.AddToast, {
92
- part: "toast",
93
- subject: {
94
- id: `${meta.id}/update-ready`,
95
- title: [
96
- "update ready label",
97
- {
98
- ns: meta.id
99
- }
100
- ],
101
- description: [
102
- "update ready description",
103
- {
104
- ns: meta.id
105
- }
106
- ],
107
- duration: Infinity,
108
- actionLabel: [
109
- "update label",
110
- {
111
- ns: meta.id
112
- }
113
- ],
114
- actionAlt: [
115
- "update alt",
116
- {
117
- ns: meta.id
118
- }
119
- ],
120
- onAction: () => relaunch()
121
- }
122
- }));
123
- }
124
- });
125
- const fiber = Function.pipe(
126
- // prettier-ignore
127
- action,
128
- Effect.repeat(Schedule.fixed(Duration.hours(1))),
129
- Effect.runFork
130
- );
131
- return contributes(Capabilities.Null, null, () => {
132
- Effect.runSync(Fiber.interrupt(fiber));
133
- });
134
- });
135
- export {
136
- updater_default as default
137
- };
138
- //# sourceMappingURL=updater-SDBPTCXA.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/updater.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type } from '@tauri-apps/plugin-os';\nimport { relaunch } from '@tauri-apps/plugin-process';\nimport { type DownloadEvent, check } from '@tauri-apps/plugin-updater';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as Function from 'effect/Function';\nimport * as Match from 'effect/Match';\nimport * as Schedule from 'effect/Schedule';\n\nimport { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\nimport { meta } from '../meta';\n\nconst SUPPORTS_OTA = ['linux', 'macos', 'windows'];\n\nexport default (context: PluginContext) => {\n // Skip updates if not supported or in dev mode.\n const platform = type();\n if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === 'localhost') {\n return contributes(Capabilities.Null, null);\n }\n\n const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n\n // https://tauri.app/plugin/updater/#checking-for-updates\n const action = Effect.gen(function* () {\n log.info('checking for updates');\n const update = yield* Effect.tryPromise(() => check());\n log.info('checked for updates', { version: update?.version, currentVersion: update?.currentVersion });\n if (update) {\n log.info('update available', update);\n let downloaded = 0;\n let contentLength = 0;\n\n const handleDownload = Match.type<DownloadEvent>().pipe(\n Match.when({ event: 'Started' }, (event) => {\n contentLength = event.data.contentLength ?? 0;\n log.info('download started', { contentLength });\n }),\n Match.when({ event: 'Progress' }, (event) => {\n downloaded += event.data.chunkLength;\n log.verbose('download progress', { downloaded, contentLength });\n }),\n Match.when({ event: 'Finished' }, () => {\n log.info('download completed');\n }),\n Match.exhaustive,\n );\n\n yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));\n\n yield* dispatch(\n createIntent(LayoutAction.AddToast, {\n part: 'toast',\n subject: {\n id: `${meta.id}/update-ready`,\n title: ['update ready label', { ns: meta.id }],\n description: ['update ready description', { ns: meta.id }],\n duration: Infinity,\n actionLabel: ['update label', { ns: meta.id }],\n actionAlt: ['update alt', { ns: meta.id }],\n onAction: () => relaunch(),\n },\n }),\n );\n }\n });\n\n const fiber = Function.pipe(\n // prettier-ignore\n action,\n Effect.repeat(Schedule.fixed(Duration.hours(1))),\n Effect.runFork,\n );\n\n return contributes(Capabilities.Null, null, () => {\n Effect.runSync(Fiber.interrupt(fiber));\n });\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,YAAY;AACrB,SAASC,gBAAgB;AACzB,SAA6BC,aAAa;AAC1C,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,SAASC,WAAW;;AAIpB,IAAMC,eAAe;EAAC;EAAS;EAAS;;AAExC,IAAA,mBAAe,CAACC,YAAAA;AAEd,QAAMC,WAAWC,KAAAA;AACjB,MAAI,CAACH,aAAaI,SAASF,QAAAA,KAAaG,OAAOC,SAASC,aAAa,aAAa;AAChF,WAAOC,YAAYC,aAAaC,MAAM,IAAA;EACxC;AAEA,QAAM,EAAEC,SAAQ,IAAKV,QAAQW,cAAcH,aAAaI,gBAAgB;AAGxE,QAAMC,SAAgBC,WAAI,aAAA;AACxBC,QAAIC,KAAK,wBAAA,QAAA;;;;;;AACT,UAAMC,SAAS,OAAcC,kBAAW,MAAMC,MAAAA,CAAAA;AAC9CJ,QAAIC,KAAK,uBAAuB;MAAEI,SAASH,QAAQG;MAASC,gBAAgBJ,QAAQI;IAAe,GAAA;;;;;;AACnG,QAAIJ,QAAQ;AACVF,UAAIC,KAAK,oBAAoBC,QAAAA;;;;;;AAC7B,UAAIK,aAAa;AACjB,UAAIC,gBAAgB;AAEpB,YAAMC,iBAAuBtB,WAAI,EAAkBuB,KAC3CC,WAAK;QAAEC,OAAO;MAAU,GAAG,CAACA,UAAAA;AAChCJ,wBAAgBI,MAAMC,KAAKL,iBAAiB;AAC5CR,YAAIC,KAAK,oBAAoB;UAAEO;QAAc,GAAA;;;;;;MAC/C,CAAA,GACMG,WAAK;QAAEC,OAAO;MAAW,GAAG,CAACA,UAAAA;AACjCL,sBAAcK,MAAMC,KAAKC;AACzBd,YAAIe,QAAQ,qBAAqB;UAAER;UAAYC;QAAc,GAAA;;;;;;MAC/D,CAAA,GACMG,WAAK;QAAEC,OAAO;MAAW,GAAG,MAAA;AAChCZ,YAAIC,KAAK,sBAAA,QAAA;;;;;;MACX,CAAA,GACMe,gBAAU;AAGlB,aAAcb,kBAAW,MAAMD,OAAOe,mBAAmBR,cAAAA,CAAAA;AAEzD,aAAOd,SACLuB,aAAaC,aAAaC,UAAU;QAClCC,MAAM;QACNC,SAAS;UACPC,IAAI,GAAGC,KAAKD,EAAE;UACdE,OAAO;YAAC;YAAsB;cAAEC,IAAIF,KAAKD;YAAG;;UAC5CI,aAAa;YAAC;YAA4B;cAAED,IAAIF,KAAKD;YAAG;;UACxDK,UAAUC;UACVC,aAAa;YAAC;YAAgB;cAAEJ,IAAIF,KAAKD;YAAG;;UAC5CQ,WAAW;YAAC;YAAc;cAAEL,IAAIF,KAAKD;YAAG;;UACxCS,UAAU,MAAMC,SAAAA;QAClB;MACF,CAAA,CAAA;IAEJ;EACF,CAAA;AAEA,QAAMC,QAAiBxB;;IAErBZ;IACOqC,cAAgBC,eAAeC,eAAM,CAAA,CAAA,CAAA;IACrCC;EAAO;AAGhB,SAAO9C,YAAYC,aAAaC,MAAM,MAAM,MAAA;AAC1C6C,IAAOC,eAAcC,gBAAUP,KAAAA,CAAAA;EACjC,CAAA;AACF;",
6
- "names": ["type", "relaunch", "check", "Duration", "Effect", "Fiber", "Function", "Match", "Schedule", "Capabilities", "LayoutAction", "contributes", "createIntent", "log", "SUPPORTS_OTA", "context", "platform", "type", "includes", "window", "location", "hostname", "contributes", "Capabilities", "Null", "dispatch", "getCapability", "IntentDispatcher", "action", "gen", "log", "info", "update", "tryPromise", "check", "version", "currentVersion", "downloaded", "contentLength", "handleDownload", "pipe", "when", "event", "data", "chunkLength", "verbose", "exhaustive", "downloadAndInstall", "createIntent", "LayoutAction", "AddToast", "part", "subject", "id", "meta", "title", "ns", "description", "duration", "Infinity", "actionLabel", "actionAlt", "onAction", "relaunch", "fiber", "repeat", "fixed", "hours", "runFork", "Effect", "runSync", "interrupt"]
7
- }