@dxos/plugin-native 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/dist/lib/browser/chunk-6374DBU4.mjs +15 -0
- package/dist/lib/browser/chunk-6374DBU4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +33 -30
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/ollama-QOB3EVAJ.mjs +75 -0
- package/dist/lib/browser/ollama-QOB3EVAJ.mjs.map +7 -0
- package/dist/lib/browser/updater-AR27PYM4.mjs +190 -0
- package/dist/lib/browser/updater-AR27PYM4.mjs.map +7 -0
- package/dist/lib/browser/window-GKYYTCEI.mjs +38 -0
- package/dist/lib/browser/window-GKYYTCEI.mjs.map +7 -0
- package/dist/types/src/NativePlugin.d.ts +2 -1
- package/dist/types/src/NativePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ollama/index.d.ts +3 -0
- package/dist/types/src/capabilities/ollama/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ollama/ollama.d.ts +7 -0
- package/dist/types/src/capabilities/ollama/ollama.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater/index.d.ts +3 -0
- package/dist/types/src/capabilities/updater/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater/updater.d.ts +5 -0
- package/dist/types/src/capabilities/updater/updater.d.ts.map +1 -0
- package/dist/types/src/capabilities/window/index.d.ts +3 -0
- package/dist/types/src/capabilities/window/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/window/window.d.ts +11 -0
- package/dist/types/src/capabilities/window/window.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -14
- package/src/NativePlugin.tsx +14 -16
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/ollama/index.ts +7 -0
- package/src/capabilities/{ollama.ts → ollama/ollama.ts} +26 -20
- package/src/capabilities/updater/index.ts +7 -0
- package/src/capabilities/updater/updater.ts +120 -0
- package/src/capabilities/window/index.ts +7 -0
- package/src/capabilities/window/window.ts +72 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +7 -2
- package/dist/lib/browser/chunk-HFW3KCZU.mjs +0 -10
- package/dist/lib/browser/chunk-HFW3KCZU.mjs.map +0 -7
- package/dist/lib/browser/ollama-FWIW4XTL.mjs +0 -90
- package/dist/lib/browser/ollama-FWIW4XTL.mjs.map +0 -7
- package/dist/lib/browser/updater-3XUIXC4F.mjs +0 -138
- package/dist/lib/browser/updater-3XUIXC4F.mjs.map +0 -7
- package/dist/lib/browser/window-6G542FZL.mjs +0 -34
- package/dist/lib/browser/window-6G542FZL.mjs.map +0 -7
- package/dist/types/src/capabilities/ollama.d.ts +0 -4
- package/dist/types/src/capabilities/ollama.d.ts.map +0 -1
- package/dist/types/src/capabilities/updater.d.ts +0 -4
- package/dist/types/src/capabilities/updater.d.ts.map +0 -1
- package/dist/types/src/capabilities/window.d.ts +0 -4
- package/dist/types/src/capabilities/window.d.ts.map +0 -1
- package/src/capabilities/updater.ts +0 -85
- 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.
|
|
3
|
+
"version": "0.8.4-main.c85a9c8dae",
|
|
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": "
|
|
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.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/plugin-
|
|
37
|
+
"effect": "3.19.16",
|
|
38
|
+
"@dxos/ai": "0.8.4-main.c85a9c8dae",
|
|
39
|
+
"@dxos/app-toolkit": "0.8.4-main.c85a9c8dae",
|
|
40
|
+
"@dxos/app-framework": "0.8.4-main.c85a9c8dae",
|
|
41
|
+
"@dxos/log": "0.8.4-main.c85a9c8dae",
|
|
42
|
+
"@dxos/plugin-assistant": "0.8.4-main.c85a9c8dae",
|
|
43
|
+
"@dxos/operation": "0.8.4-main.c85a9c8dae",
|
|
44
|
+
"@dxos/plugin-help": "0.8.4-main.c85a9c8dae",
|
|
45
|
+
"@dxos/util": "0.8.4-main.c85a9c8dae",
|
|
46
|
+
"@dxos/plugin-navtree": "0.8.4-main.c85a9c8dae"
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"vite": "7.1.
|
|
44
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
49
|
+
"vite": "^7.1.11",
|
|
50
|
+
"@dxos/react-ui": "0.8.4-main.c85a9c8dae"
|
|
45
51
|
},
|
|
46
52
|
"peerDependencies": {
|
|
47
|
-
"effect": "
|
|
48
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
53
|
+
"effect": "3.19.16",
|
|
54
|
+
"@dxos/react-ui": "0.8.4-main.c85a9c8dae"
|
|
49
55
|
},
|
|
50
56
|
"publishConfig": {
|
|
51
57
|
"access": "public"
|
package/src/NativePlugin.tsx
CHANGED
|
@@ -2,32 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
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
9
|
import { Ollama, Updater, Window } from './capabilities';
|
|
9
10
|
import { meta } from './meta';
|
|
10
11
|
import { translations } from './translations';
|
|
11
12
|
|
|
12
|
-
export const NativePlugin =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
defineModule({
|
|
19
|
-
id: `${meta.id}/module/updater`,
|
|
20
|
-
activatesOn: Events.DispatcherReady,
|
|
13
|
+
export const NativePlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
15
|
+
Plugin.addModule({
|
|
16
|
+
id: 'updater',
|
|
17
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
21
18
|
activate: Updater,
|
|
22
19
|
}),
|
|
23
|
-
|
|
24
|
-
id:
|
|
25
|
-
activatesOn:
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
id: 'window',
|
|
22
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
26
23
|
activate: Window,
|
|
27
24
|
}),
|
|
28
|
-
|
|
29
|
-
id:
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export const Updater = lazy(() => import('./updater'));
|
|
9
|
-
export const Window = lazy(() => import('./window'));
|
|
5
|
+
export * from './ollama';
|
|
6
|
+
export * from './updater';
|
|
7
|
+
export * from './window';
|
|
@@ -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
|
|
14
|
-
import {
|
|
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
|
|
21
|
-
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
22
|
+
export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
runtime
|
|
26
|
-
);
|
|
24
|
+
export default Capability.makeModule<[], OllamaCapabilities>(() =>
|
|
25
|
+
Effect.sync(() => {
|
|
26
|
+
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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<
|
|
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
|
|
78
|
-
|
|
83
|
+
return OllamaResolver.make({
|
|
84
|
+
endpoint,
|
|
79
85
|
transformClient: HttpClient.withTracerPropagation(false),
|
|
80
86
|
});
|
|
81
87
|
}),
|
|
@@ -0,0 +1,120 @@
|
|
|
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 { meta } from '../../meta';
|
|
19
|
+
|
|
20
|
+
const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Safely check for updates with error logging.
|
|
24
|
+
*/
|
|
25
|
+
const check = async (): Promise<Updater.Update | null> => {
|
|
26
|
+
try {
|
|
27
|
+
return await Updater.check();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
log.error('failed to check for updates', { error });
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Safely download and install update with error logging.
|
|
36
|
+
*/
|
|
37
|
+
const downloadAndInstall = async (
|
|
38
|
+
update: Updater.Update,
|
|
39
|
+
handleDownload: (event: Updater.DownloadEvent) => void,
|
|
40
|
+
): Promise<boolean> => {
|
|
41
|
+
try {
|
|
42
|
+
await update.downloadAndInstall(handleDownload);
|
|
43
|
+
return true;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
log.error('failed to download and install update', { error });
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default Capability.makeModule(
|
|
51
|
+
Effect.fnUntraced(function* () {
|
|
52
|
+
// Skip updates if not supported or in dev mode.
|
|
53
|
+
const platform = type();
|
|
54
|
+
if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === 'localhost') {
|
|
55
|
+
log.info('skipping updater', { platform, hostname: window.location.hostname });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
60
|
+
|
|
61
|
+
// https://tauri.app/plugin/updater/#checking-for-updates
|
|
62
|
+
const action = Effect.gen(function* () {
|
|
63
|
+
log.info('checking for updates');
|
|
64
|
+
const update = yield* Effect.promise(() => check());
|
|
65
|
+
if (!update) {
|
|
66
|
+
log.info('no update available');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
log.info('update check complete', {
|
|
70
|
+
available: update.available,
|
|
71
|
+
currentVersion: update.currentVersion,
|
|
72
|
+
version: update.version,
|
|
73
|
+
date: update.date,
|
|
74
|
+
body: update.body,
|
|
75
|
+
});
|
|
76
|
+
if (update.available) {
|
|
77
|
+
log.info('update available, starting download', { version: update.version });
|
|
78
|
+
let downloaded = 0;
|
|
79
|
+
let contentLength = 0;
|
|
80
|
+
|
|
81
|
+
const handleDownload = Match.type<Updater.DownloadEvent>().pipe(
|
|
82
|
+
Match.when({ event: 'Started' }, (event) => {
|
|
83
|
+
contentLength = event.data.contentLength ?? 0;
|
|
84
|
+
log.info('download started', { contentLength });
|
|
85
|
+
}),
|
|
86
|
+
Match.when({ event: 'Progress' }, (event) => {
|
|
87
|
+
downloaded += event.data.chunkLength;
|
|
88
|
+
log.verbose('download progress', { downloaded, contentLength });
|
|
89
|
+
}),
|
|
90
|
+
Match.when({ event: 'Finished' }, () => {
|
|
91
|
+
log.info('download completed');
|
|
92
|
+
}),
|
|
93
|
+
Match.exhaustive,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const downloadSuccess = yield* Effect.promise(() => downloadAndInstall(update, handleDownload));
|
|
97
|
+
|
|
98
|
+
if (downloadSuccess) {
|
|
99
|
+
yield* invoke(LayoutOperation.AddToast, {
|
|
100
|
+
id: `${meta.id}/update-ready`,
|
|
101
|
+
title: ['update ready label', { ns: meta.id }],
|
|
102
|
+
description: ['update ready description', { ns: meta.id }],
|
|
103
|
+
duration: Infinity,
|
|
104
|
+
actionLabel: ['update label', { ns: meta.id }],
|
|
105
|
+
actionAlt: ['update alt', { ns: meta.id }],
|
|
106
|
+
onAction: () => relaunch(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Run immediately on startup, then repeat every hour.
|
|
113
|
+
const fiber = yield* action.pipe(Effect.repeat(Schedule.fixed(Duration.hours(1))), Effect.forkDaemon);
|
|
114
|
+
log.info('updater module initialized, update check scheduled');
|
|
115
|
+
|
|
116
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
117
|
+
Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
|
|
118
|
+
);
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Window capability module.
|
|
12
|
+
* Sets up window drag regions for Tauri windows.
|
|
13
|
+
* Note: Window state persistence (size/position) is handled on the Rust side
|
|
14
|
+
* in src-tauri/src/window_state.rs for instant restoration on startup.
|
|
15
|
+
*/
|
|
16
|
+
export default Capability.makeModule(
|
|
17
|
+
Effect.fnUntraced(function* () {
|
|
18
|
+
const appWindow = getCurrentWindow();
|
|
19
|
+
|
|
20
|
+
// Set up drag regions for window dragging.
|
|
21
|
+
const cleanupDragRegions = setupWindowDrag(appWindow);
|
|
22
|
+
|
|
23
|
+
return Capability.contributes(
|
|
24
|
+
Capabilities.Null,
|
|
25
|
+
null,
|
|
26
|
+
Effect.fnUntraced(function* () {
|
|
27
|
+
cleanupDragRegions();
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Interactive element selectors that should not trigger window dragging.
|
|
35
|
+
*/
|
|
36
|
+
const INTERACTIVE_SELECTORS = '.dx-app-no-drag, button, a, input, select, textarea, [role="button"], [role="menuitem"]';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets up window drag regions.
|
|
40
|
+
*
|
|
41
|
+
* Tauri 2.0 does not support the `-webkit-app-region` CSS property with overlay titlebars.
|
|
42
|
+
* This uses the Tauri window API to enable dragging on elements with the `dx-app-drag` class.
|
|
43
|
+
*/
|
|
44
|
+
const setupWindowDrag = (appWindow: ReturnType<typeof getCurrentWindow>): (() => void) => {
|
|
45
|
+
const handleMouseDown = (event: MouseEvent) => {
|
|
46
|
+
const target = event.target as Element | null;
|
|
47
|
+
if (!target) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check if the click target or any ancestor has the dx-app-drag class.
|
|
52
|
+
const dragElement = target.closest('.dx-app-drag');
|
|
53
|
+
if (!dragElement) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Don't trigger drag on interactive elements within the drag region.
|
|
58
|
+
const interactiveElement = target.closest(INTERACTIVE_SELECTORS);
|
|
59
|
+
if (interactiveElement && dragElement.contains(interactiveElement)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
void appWindow.startDragging();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
document.addEventListener('mousedown', handleMouseDown);
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
document.removeEventListener('mousedown', handleMouseDown);
|
|
71
|
+
};
|
|
72
|
+
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
8
9
|
id: 'dxos.org/plugin/native',
|
|
9
10
|
name: 'Native',
|
|
11
|
+
description: trim`
|
|
12
|
+
Native platform integration providing desktop-specific features and system-level capabilities.
|
|
13
|
+
Access native file dialogs, notifications, and OS integrations.
|
|
14
|
+
`,
|
|
10
15
|
};
|
|
@@ -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';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/native',\n name: 'Native',\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;AACR;",
|
|
6
|
-
"names": ["meta", "id", "name"]
|
|
7
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// src/capabilities/ollama.ts
|
|
2
|
-
import * as FetchHttpClient from "@effect/platform/FetchHttpClient";
|
|
3
|
-
import * as HttpClient from "@effect/platform/HttpClient";
|
|
4
|
-
import { Command } from "@tauri-apps/plugin-shell";
|
|
5
|
-
import * as Context from "effect/Context";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
import * as Layer from "effect/Layer";
|
|
8
|
-
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
9
|
-
import * as AiServiceRouter from "@dxos/ai/AiServiceRouter";
|
|
10
|
-
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
11
|
-
import { log } from "@dxos/log";
|
|
12
|
-
function _define_property(obj, key, value) {
|
|
13
|
-
if (key in obj) {
|
|
14
|
-
Object.defineProperty(obj, key, {
|
|
15
|
-
value,
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
obj[key] = value;
|
|
22
|
-
}
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-native/src/capabilities/ollama.ts";
|
|
26
|
-
var OLLAMA_HOST = "http://localhost:21434";
|
|
27
|
-
var ollama_default = ((_context) => {
|
|
28
|
-
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
29
|
-
const sidecarLayer = Layer.effectContext(runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))));
|
|
30
|
-
return contributes(Capabilities.AiModelResolver, OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)), async () => {
|
|
31
|
-
await runtime.dispose();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
var _Context_Tag;
|
|
35
|
-
var OllamaSidecar = class extends (_Context_Tag = Context.Tag("@dxos/plugin-native/OllamaSidecar")()) {
|
|
36
|
-
};
|
|
37
|
-
_define_property(OllamaSidecar, "layerLive", Layer.scoped(OllamaSidecar, Effect.gen(function* () {
|
|
38
|
-
const command = Command.sidecar("sidecar/ollama", [
|
|
39
|
-
"serve"
|
|
40
|
-
], {
|
|
41
|
-
env: {
|
|
42
|
-
OLLAMA_HOST,
|
|
43
|
-
OLLAMA_ORIGINS: "*"
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
command.stdout.on("data", (data) => console.log("[ollama]", data.toString()));
|
|
47
|
-
command.stderr.on("data", (data) => console.error("[ollama]", data.toString()));
|
|
48
|
-
command.on("close", (code) => log.info("Ollama process exited", {
|
|
49
|
-
code
|
|
50
|
-
}, {
|
|
51
|
-
F: __dxlog_file,
|
|
52
|
-
L: 56,
|
|
53
|
-
S: this,
|
|
54
|
-
C: (f, a) => f(...a)
|
|
55
|
-
}));
|
|
56
|
-
command.on("error", (error) => log.error("Ollama error", {
|
|
57
|
-
error
|
|
58
|
-
}, {
|
|
59
|
-
F: __dxlog_file,
|
|
60
|
-
L: 57,
|
|
61
|
-
S: this,
|
|
62
|
-
C: (f, a) => f(...a)
|
|
63
|
-
}));
|
|
64
|
-
const child = yield* Effect.promise(() => command.spawn());
|
|
65
|
-
yield* Effect.addFinalizer(Effect.fn(function* () {
|
|
66
|
-
yield* Effect.promise(() => child.kill());
|
|
67
|
-
}));
|
|
68
|
-
log.info("Running ollama", {
|
|
69
|
-
pid: child.pid
|
|
70
|
-
}, {
|
|
71
|
-
F: __dxlog_file,
|
|
72
|
-
L: 64,
|
|
73
|
-
S: this,
|
|
74
|
-
C: (f, a) => f(...a)
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
endpoint: OLLAMA_HOST
|
|
78
|
-
};
|
|
79
|
-
})));
|
|
80
|
-
var OllamaSidecarModelResolver = Layer.unwrapEffect(Effect.gen(function* () {
|
|
81
|
-
const { endpoint } = yield* OllamaSidecar;
|
|
82
|
-
return AiServiceRouter.OllamaResolver({
|
|
83
|
-
host: endpoint,
|
|
84
|
-
transformClient: HttpClient.withTracerPropagation(false)
|
|
85
|
-
});
|
|
86
|
-
})).pipe(Layer.provide(FetchHttpClient.layer));
|
|
87
|
-
export {
|
|
88
|
-
ollama_default as default
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=ollama-FWIW4XTL.mjs.map
|
|
@@ -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;IAE4BzB;AAA5B,IAAMY,gBAAN,eAA4BZ,eAAQ0B,YAAI,mCAAA,EAAA,GAKtC;AA6BF;AA5BE,iBANId,eAMGC,aAAkBc,aACvBf,eACOgB,WAAI,aAAA;AACT,QAAMC,UAAU9B,QAAQ+B,QAAQ,kBAAkB;IAAC;KAAU;IAC3DC,KAAK;MACHvB;MACAwB,gBAAgB;IAClB;EACF,CAAA;AAGAH,UAAQI,OAAOC,GAAG,QAAQ,CAACC,SAASC,QAAQ7B,IAAI,YAAY4B,KAAKE,SAAQ,CAAA,CAAA;AACzER,UAAQS,OAAOJ,GAAG,QAAQ,CAACC,SAASC,QAAQG,MAAM,YAAYJ,KAAKE,SAAQ,CAAA,CAAA;AAC3ER,UAAQK,GAAG,SAAS,CAACM,SAASjC,IAAIkC,KAAK,yBAAyB;IAAED;EAAK,GAAA;;;;;;AACvEX,UAAQK,GAAG,SAAS,CAACK,UAAUhC,IAAIgC,MAAM,gBAAgB;IAAEA;EAAM,GAAA;;;;;;AACjE,QAAMG,QAAQ,OAAcC,eAAQ,MAAMd,QAAQe,MAAK,CAAA;AACvD,SAAcC,oBACLC,UAAG,aAAA;AACR,WAAcH,eAAQ,MAAMD,MAAMK,KAAI,CAAA;EACxC,CAAA,CAAA;AAEFxC,MAAIkC,KAAK,kBAAkB;IAAEO,KAAKN,MAAMM;EAAI,GAAA;;;;;;AAE5C,SAAO;IACLC,UAAUzC;EACZ;AACF,CAAA,CAAA,CAAA;AAIJ,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
|
-
}
|