@dxos/plugin-native 0.8.4-main.f5c0578 → 0.8.4-main.fcc0d83b33
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/index.mjs +31 -45
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +18 -0
- package/dist/lib/browser/translations.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 +4 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ollama.d.ts +5 -4
- package/dist/types/src/capabilities/ollama.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-listener.d.ts +8 -0
- package/dist/types/src/capabilities/spotlight-listener.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater.d.ts +3 -2
- package/dist/types/src/capabilities/updater.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +5 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -19
- package/src/NativePlugin.tsx +25 -23
- package/src/capabilities/index.ts +4 -3
- package/src/capabilities/ollama.ts +32 -23
- package/src/capabilities/spotlight-listener.ts +58 -0
- package/src/capabilities/updater.ts +107 -57
- package/src/constants.ts +7 -0
- package/src/meta.ts +8 -5
- package/src/translations.ts +5 -5
- package/dist/lib/browser/chunk-E2JDGVJI.mjs +0 -12
- package/dist/lib/browser/chunk-E2JDGVJI.mjs.map +0 -7
- package/dist/lib/browser/ollama-MF7YNEDS.mjs +0 -73
- package/dist/lib/browser/ollama-MF7YNEDS.mjs.map +0 -7
- package/dist/lib/browser/updater-MCAQYHED.mjs +0 -133
- package/dist/lib/browser/updater-MCAQYHED.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,50 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-native",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcc0d83b33",
|
|
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,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
17
|
+
"#meta": "./src/meta.ts",
|
|
18
|
+
"#translations": "./src/translations.ts"
|
|
19
|
+
},
|
|
11
20
|
"exports": {
|
|
12
21
|
".": {
|
|
13
22
|
"source": "./src/index.ts",
|
|
14
23
|
"types": "./dist/types/src/index.d.ts",
|
|
15
24
|
"browser": "./dist/lib/browser/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./translations": {
|
|
27
|
+
"source": "./src/translations.ts",
|
|
28
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
29
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
30
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
16
31
|
}
|
|
17
32
|
},
|
|
18
33
|
"types": "dist/types/src/index.d.ts",
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {}
|
|
21
|
-
},
|
|
22
34
|
"files": [
|
|
23
35
|
"dist",
|
|
24
36
|
"src"
|
|
25
37
|
],
|
|
26
38
|
"dependencies": {
|
|
27
|
-
"@effect/platform": "
|
|
28
|
-
"@tauri-apps/
|
|
39
|
+
"@effect/platform": "0.94.4",
|
|
40
|
+
"@tauri-apps/api": "^2.8.0",
|
|
41
|
+
"@tauri-apps/plugin-os": "^2.3.1",
|
|
29
42
|
"@tauri-apps/plugin-process": "^2.3.0",
|
|
30
|
-
"@tauri-apps/plugin-shell": "^2.3.
|
|
43
|
+
"@tauri-apps/plugin-shell": "^2.3.1",
|
|
31
44
|
"@tauri-apps/plugin-updater": "^2.9.0",
|
|
32
|
-
"effect": "3.
|
|
33
|
-
"@dxos/ai": "0.8.4-main.
|
|
34
|
-
"@dxos/app-
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/plugin-assistant": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
45
|
+
"effect": "3.20.0",
|
|
46
|
+
"@dxos/ai": "0.8.4-main.fcc0d83b33",
|
|
47
|
+
"@dxos/app-toolkit": "0.8.4-main.fcc0d83b33",
|
|
48
|
+
"@dxos/operation": "0.8.4-main.fcc0d83b33",
|
|
49
|
+
"@dxos/log": "0.8.4-main.fcc0d83b33",
|
|
50
|
+
"@dxos/plugin-help": "0.8.4-main.fcc0d83b33",
|
|
51
|
+
"@dxos/plugin-assistant": "0.8.4-main.fcc0d83b33",
|
|
52
|
+
"@dxos/util": "0.8.4-main.fcc0d83b33",
|
|
53
|
+
"@dxos/plugin-navtree": "0.8.4-main.fcc0d83b33",
|
|
54
|
+
"@dxos/app-framework": "0.8.4-main.fcc0d83b33"
|
|
40
55
|
},
|
|
41
56
|
"devDependencies": {
|
|
42
|
-
"vite": "
|
|
43
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
57
|
+
"vite": "^8.0.10",
|
|
58
|
+
"@dxos/react-ui": "0.8.4-main.fcc0d83b33"
|
|
44
59
|
},
|
|
45
60
|
"peerDependencies": {
|
|
46
|
-
"effect": "
|
|
47
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
61
|
+
"effect": "3.20.0",
|
|
62
|
+
"@dxos/react-ui": "0.8.4-main.fcc0d83b33"
|
|
48
63
|
},
|
|
49
64
|
"publishConfig": {
|
|
50
65
|
"access": "public"
|
package/src/NativePlugin.tsx
CHANGED
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
import { AssistantEvents } from '@dxos/plugin-assistant/types';
|
|
7
8
|
|
|
8
|
-
import { Ollama, Updater } from '
|
|
9
|
-
import { meta } from '
|
|
10
|
-
import { translations } from '
|
|
9
|
+
import { Ollama, SpotlightListener, Updater } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
import { translations } from '#translations';
|
|
11
12
|
|
|
12
|
-
export const NativePlugin = ()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
19
|
+
}),
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
id: 'updater',
|
|
22
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
23
|
+
activate: Updater,
|
|
24
|
+
}),
|
|
25
|
+
Plugin.addModule({
|
|
26
|
+
id: 'ollama',
|
|
27
|
+
activatesOn: AssistantEvents.SetupAiServiceProviders,
|
|
28
|
+
activate: Ollama,
|
|
29
|
+
}),
|
|
30
|
+
Plugin.make,
|
|
31
|
+
);
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
7
|
+
export const Ollama = Capability.lazy('Ollama', () => import('./ollama'));
|
|
8
|
+
export const SpotlightListener = Capability.lazy('SpotlightListener', () => import('./spotlight-listener'));
|
|
9
|
+
export const Updater = Capability.lazy('Updater', () => import('./updater'));
|
|
@@ -2,34 +2,41 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
|
|
6
|
+
import * as HttpClient from '@effect/platform/HttpClient';
|
|
6
7
|
import { Command } from '@tauri-apps/plugin-shell';
|
|
7
|
-
import
|
|
8
|
+
import * as Context from 'effect/Context';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as Layer from 'effect/Layer';
|
|
11
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
8
12
|
|
|
9
|
-
import {
|
|
10
|
-
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';
|
|
11
17
|
import { log } from '@dxos/log';
|
|
12
|
-
import { AssistantCapabilities } from '@dxos/plugin-assistant';
|
|
13
18
|
|
|
14
|
-
// Running ollama on non-standard port.
|
|
19
|
+
// NOTE: Running ollama on non-standard port (config Tauri).
|
|
15
20
|
const OLLAMA_HOST = 'http://localhost:21434';
|
|
16
21
|
|
|
17
|
-
export
|
|
18
|
-
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
22
|
+
export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
runtime
|
|
23
|
-
);
|
|
24
|
+
export default Capability.makeModule<[], OllamaCapabilities>(() =>
|
|
25
|
+
Effect.sync(() => {
|
|
26
|
+
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
);
|
|
33
40
|
|
|
34
41
|
class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
35
42
|
OllamaSidecar,
|
|
@@ -48,7 +55,9 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
|
48
55
|
});
|
|
49
56
|
|
|
50
57
|
// NOTE: Keeping those as console.log for consistent formatting.
|
|
58
|
+
// eslint-disable-next-line no-console
|
|
51
59
|
command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
52
61
|
command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
|
|
53
62
|
command.on('close', (code) => log.info('Ollama process exited', { code }));
|
|
54
63
|
command.on('error', (error) => log.error('Ollama error', { error }));
|
|
@@ -67,12 +76,12 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
|
67
76
|
);
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
const OllamaSidecarModelResolver: Layer.Layer<
|
|
79
|
+
const OllamaSidecarModelResolver: Layer.Layer<AiModelResolver.AiModelResolver, never, OllamaSidecar> =
|
|
71
80
|
Layer.unwrapEffect(
|
|
72
81
|
Effect.gen(function* () {
|
|
73
82
|
const { endpoint } = yield* OllamaSidecar;
|
|
74
|
-
return
|
|
75
|
-
|
|
83
|
+
return OllamaResolver.make({
|
|
84
|
+
endpoint,
|
|
76
85
|
transformClient: HttpClient.withTracerPropagation(false),
|
|
77
86
|
});
|
|
78
87
|
}),
|
|
@@ -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
|
+
);
|
|
@@ -4,76 +4,126 @@
|
|
|
4
4
|
|
|
5
5
|
import { type } from '@tauri-apps/plugin-os';
|
|
6
6
|
import { relaunch } from '@tauri-apps/plugin-process';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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';
|
|
9
13
|
|
|
10
|
-
import { Capabilities,
|
|
14
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
15
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
11
16
|
import { log } from '@dxos/log';
|
|
12
17
|
|
|
13
|
-
import {
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
|
|
20
|
+
import { TAURI_LOCALHOST_PORT } from '../constants';
|
|
14
21
|
|
|
15
22
|
const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Safely check for updates with error logging.
|
|
26
|
+
*/
|
|
27
|
+
const check = async (): Promise<Updater.Update | null> => {
|
|
28
|
+
try {
|
|
29
|
+
return await Updater.check();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
log.error('failed to check for updates', { error });
|
|
32
|
+
return null;
|
|
21
33
|
}
|
|
34
|
+
};
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Safely download and install update with error logging.
|
|
38
|
+
*/
|
|
39
|
+
const downloadAndInstall = async (
|
|
40
|
+
update: Updater.Update,
|
|
41
|
+
handleDownload: (event: Updater.DownloadEvent) => void,
|
|
42
|
+
): Promise<boolean> => {
|
|
43
|
+
try {
|
|
44
|
+
await update.downloadAndInstall(handleDownload);
|
|
45
|
+
return true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
log.error('failed to download and install update', { error });
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
24
51
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
log.info('
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
export default Capability.makeModule(
|
|
53
|
+
Effect.fnUntraced(function* () {
|
|
54
|
+
// Skip updates if not supported or in dev mode.
|
|
55
|
+
const platform = type();
|
|
56
|
+
const isDevServer = window.location.port !== TAURI_LOCALHOST_PORT;
|
|
57
|
+
if (!SUPPORTS_OTA.includes(platform) || isDevServer) {
|
|
58
|
+
log.info('skipping updater', { platform, port: window.location.port });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
34
61
|
|
|
35
|
-
|
|
36
|
-
Match.when({ event: 'Started' }, (event) => {
|
|
37
|
-
contentLength = event.data.contentLength ?? 0;
|
|
38
|
-
log.info('download started', { contentLength });
|
|
39
|
-
}),
|
|
40
|
-
Match.when({ event: 'Progress' }, (event) => {
|
|
41
|
-
downloaded += event.data.chunkLength;
|
|
42
|
-
log.info('download progress', { downloaded, contentLength });
|
|
43
|
-
}),
|
|
44
|
-
Match.when({ event: 'Finished' }, () => {
|
|
45
|
-
log.info('download completed');
|
|
46
|
-
}),
|
|
47
|
-
Match.exhaustive,
|
|
48
|
-
);
|
|
62
|
+
const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
// https://tauri.app/plugin/updater/#checking-for-updates
|
|
65
|
+
// Returns true to keep checking, false to stop.
|
|
66
|
+
const action = Effect.gen(function* () {
|
|
67
|
+
log.info('checking for updates');
|
|
68
|
+
const update = yield* Effect.promise(() => check());
|
|
69
|
+
if (!update) {
|
|
70
|
+
log.info('no update available');
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
log.info('update check complete', {
|
|
74
|
+
available: update.available,
|
|
75
|
+
currentVersion: update.currentVersion,
|
|
76
|
+
version: update.version,
|
|
77
|
+
date: update.date,
|
|
78
|
+
body: update.body,
|
|
79
|
+
});
|
|
80
|
+
if (update.available) {
|
|
81
|
+
log.info('update available, starting download', { version: update.version });
|
|
82
|
+
let downloaded = 0;
|
|
83
|
+
let contentLength = 0;
|
|
51
84
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
const handleDownload = Match.type<Updater.DownloadEvent>().pipe(
|
|
86
|
+
Match.when({ event: 'Started' }, (event) => {
|
|
87
|
+
contentLength = event.data.contentLength ?? 0;
|
|
88
|
+
log.info('download started', { contentLength });
|
|
89
|
+
}),
|
|
90
|
+
Match.when({ event: 'Progress' }, (event) => {
|
|
91
|
+
downloaded += event.data.chunkLength;
|
|
92
|
+
log.verbose('download progress', { downloaded, contentLength });
|
|
93
|
+
}),
|
|
94
|
+
Match.when({ event: 'Finished' }, () => {
|
|
95
|
+
log.info('download completed');
|
|
96
|
+
}),
|
|
97
|
+
Match.exhaustive,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const downloadSuccess = yield* Effect.promise(() => downloadAndInstall(update, handleDownload));
|
|
101
|
+
|
|
102
|
+
if (downloadSuccess) {
|
|
103
|
+
yield* invoke(LayoutOperation.AddToast, {
|
|
104
|
+
id: `${meta.id}.update-ready`,
|
|
105
|
+
title: ['update-ready.label', { ns: meta.id }],
|
|
106
|
+
description: ['update-ready.description', { ns: meta.id }],
|
|
59
107
|
duration: Infinity,
|
|
60
|
-
actionLabel: ['update
|
|
61
|
-
actionAlt: ['update
|
|
108
|
+
actionLabel: ['update.label', { ns: meta.id }],
|
|
109
|
+
actionAlt: ['update.alt', { ns: meta.id }],
|
|
62
110
|
onAction: () => relaunch(),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
111
|
+
});
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
68
117
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Effect.
|
|
74
|
-
|
|
118
|
+
// Run immediately on startup, then repeat every hour. Stop once an update is found.
|
|
119
|
+
const schedule = Schedule.fixed(Duration.hours(1)).pipe(
|
|
120
|
+
Schedule.whileInput((keepChecking: boolean) => keepChecking),
|
|
121
|
+
);
|
|
122
|
+
const fiber = yield* action.pipe(Effect.repeat(schedule), Effect.forkDaemon);
|
|
123
|
+
log.info('updater module initialized, update check scheduled');
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
125
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
126
|
+
Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
|
|
127
|
+
);
|
|
128
|
+
}),
|
|
129
|
+
);
|
package/src/constants.ts
ADDED
package/src/meta.ts
CHANGED
|
@@ -2,11 +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
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: NATIVE_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.native',
|
|
11
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
|
+
`,
|
|
12
15
|
};
|
package/src/translations.ts
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[meta.id]: {
|
|
13
|
-
'update
|
|
14
|
-
'update
|
|
15
|
-
'update
|
|
16
|
-
'update
|
|
13
|
+
'update-ready.label': 'Ready to update',
|
|
14
|
+
'update-ready.description': 'A new version of Composer is available.',
|
|
15
|
+
'update.label': 'Update',
|
|
16
|
+
'update.alt': 'Relaunch the app to update',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
@@ -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 NATIVE_PLUGIN = 'dxos.org/plugin/native';\n\nexport const meta: PluginMeta = {\n id: NATIVE_PLUGIN,\n name: 'Native',\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,gBAAgB;AAEtB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;",
|
|
6
|
-
"names": ["NATIVE_PLUGIN", "meta", "id", "name"]
|
|
7
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// src/capabilities/ollama.ts
|
|
2
|
-
import { FetchHttpClient, HttpClient } from "@effect/platform";
|
|
3
|
-
import { Command } from "@tauri-apps/plugin-shell";
|
|
4
|
-
import { Context, Effect, Layer, ManagedRuntime } from "effect";
|
|
5
|
-
import { AiServiceRouter } from "@dxos/ai";
|
|
6
|
-
import { contributes } from "@dxos/app-framework";
|
|
7
|
-
import { log } from "@dxos/log";
|
|
8
|
-
import { AssistantCapabilities } from "@dxos/plugin-assistant";
|
|
9
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-native/src/capabilities/ollama.ts";
|
|
10
|
-
var OLLAMA_HOST = "http://localhost:21434";
|
|
11
|
-
var ollama_default = (_context) => {
|
|
12
|
-
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
13
|
-
const sidecarLayer = Layer.effectContext(runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))));
|
|
14
|
-
return contributes(AssistantCapabilities.AiModelResolver, OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)), async () => {
|
|
15
|
-
await runtime.dispose();
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
var OllamaSidecar = class _OllamaSidecar extends Context.Tag("@dxos/plugin-native/OllamaSidecar")() {
|
|
19
|
-
static layerLive = Layer.scoped(_OllamaSidecar, Effect.gen(function* () {
|
|
20
|
-
const command = Command.sidecar("sidecar/ollama", [
|
|
21
|
-
"serve"
|
|
22
|
-
], {
|
|
23
|
-
env: {
|
|
24
|
-
OLLAMA_HOST,
|
|
25
|
-
OLLAMA_ORIGINS: "*"
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
command.stdout.on("data", (data) => console.log("[ollama]", data.toString()));
|
|
29
|
-
command.stderr.on("data", (data) => console.error("[ollama]", data.toString()));
|
|
30
|
-
command.on("close", (code) => log.info("Ollama process exited", {
|
|
31
|
-
code
|
|
32
|
-
}, {
|
|
33
|
-
F: __dxlog_file,
|
|
34
|
-
L: 53,
|
|
35
|
-
S: this,
|
|
36
|
-
C: (f, a) => f(...a)
|
|
37
|
-
}));
|
|
38
|
-
command.on("error", (error) => log.error("Ollama error", {
|
|
39
|
-
error
|
|
40
|
-
}, {
|
|
41
|
-
F: __dxlog_file,
|
|
42
|
-
L: 54,
|
|
43
|
-
S: this,
|
|
44
|
-
C: (f, a) => f(...a)
|
|
45
|
-
}));
|
|
46
|
-
const child = yield* Effect.promise(() => command.spawn());
|
|
47
|
-
yield* Effect.addFinalizer(Effect.fn(function* () {
|
|
48
|
-
yield* Effect.promise(() => child.kill());
|
|
49
|
-
}));
|
|
50
|
-
log.info("Running ollama", {
|
|
51
|
-
pid: child.pid
|
|
52
|
-
}, {
|
|
53
|
-
F: __dxlog_file,
|
|
54
|
-
L: 61,
|
|
55
|
-
S: this,
|
|
56
|
-
C: (f, a) => f(...a)
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
endpoint: OLLAMA_HOST
|
|
60
|
-
};
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
63
|
-
var OllamaSidecarModelResolver = Layer.unwrapEffect(Effect.gen(function* () {
|
|
64
|
-
const { endpoint } = yield* OllamaSidecar;
|
|
65
|
-
return AiServiceRouter.OllamaResolver({
|
|
66
|
-
host: endpoint,
|
|
67
|
-
transformClient: HttpClient.withTracerPropagation(false)
|
|
68
|
-
});
|
|
69
|
-
})).pipe(Layer.provide(FetchHttpClient.layer));
|
|
70
|
-
export {
|
|
71
|
-
ollama_default as default
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=ollama-MF7YNEDS.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 { FetchHttpClient, HttpClient } from '@effect/platform';\nimport { Command } from '@tauri-apps/plugin-shell';\nimport { Context, Effect, Layer, ManagedRuntime } from 'effect';\n\nimport { AiServiceRouter } from '@dxos/ai';\nimport { type PluginContext, contributes } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\nimport { AssistantCapabilities } from '@dxos/plugin-assistant';\n\n// Running ollama on non-standard port.\nconst OLLAMA_HOST = 'http://localhost:21434';\n\nexport default (_context: PluginContext) => {\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 AssistantCapabilities.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,SAASA,iBAAiBC,kBAAkB;AAC5C,SAASC,eAAe;AACxB,SAASC,SAASC,QAAQC,OAAOC,sBAAsB;AAEvD,SAASC,uBAAuB;AAChC,SAA6BC,mBAAmB;AAChD,SAASC,WAAW;AACpB,SAASC,6BAA6B;;AAGtC,IAAMC,cAAc;AAEpB,IAAA,iBAAe,CAACC,aAAAA;AACd,QAAMC,UAAUP,eAAeQ,KAAKC,cAAcC,SAAS;AAG3D,QAAMC,eAAeZ,MAAMa,cACzBL,QAAQM,cAAcC,KAAKhB,OAAOiB,IAAI,CAACC,OAAOA,GAAGC,QAAQH,KAAKjB,QAAQqB,KAAKT,aAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAG7E,SAAOP,YACLE,sBAAsBe,iBACtBC,2BAA2BN,KAAKf,MAAMsB,QAAQV,YAAAA,CAAAA,GAC9C,YAAA;AACE,UAAMJ,QAAQe,QAAO;EACvB,CAAA;AAEJ;AAEA,IAAMb,gBAAN,MAAMA,uBAAsBZ,QAAQ0B,IAAI,mCAAA,EAAA,EAAA;EAMtC,OAAOb,YAAYX,MAAMyB,OACvBf,gBACAX,OAAO2B,IAAI,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,QAAQ9B,IAAI,YAAY6B,KAAKE,SAAQ,CAAA,CAAA;AACzER,YAAQS,OAAOJ,GAAG,QAAQ,CAACC,SAASC,QAAQG,MAAM,YAAYJ,KAAKE,SAAQ,CAAA,CAAA;AAC3ER,YAAQK,GAAG,SAAS,CAACM,SAASlC,IAAImC,KAAK,yBAAyB;MAAED;IAAK,GAAA;;;;;;AACvEX,YAAQK,GAAG,SAAS,CAACK,UAAUjC,IAAIiC,MAAM,gBAAgB;MAAEA;IAAM,GAAA;;;;;;AACjE,UAAMG,QAAQ,OAAOzC,OAAO0C,QAAQ,MAAMd,QAAQe,MAAK,CAAA;AACvD,WAAO3C,OAAO4C,aACZ5C,OAAO6C,GAAG,aAAA;AACR,aAAO7C,OAAO0C,QAAQ,MAAMD,MAAMK,KAAI,CAAA;IACxC,CAAA,CAAA;AAEFzC,QAAImC,KAAK,kBAAkB;MAAEO,KAAKN,MAAMM;IAAI,GAAA;;;;;;AAE5C,WAAO;MACLC,UAAUzC;IACZ;EACF,CAAA,CAAA;AAEJ;AAEA,IAAMe,6BACJrB,MAAMgD,aACJjD,OAAO2B,IAAI,aAAA;AACT,QAAM,EAAEqB,SAAQ,IAAK,OAAOrC;AAC5B,SAAOR,gBAAgB+C,eAAe;IACpCC,MAAMH;IACNI,iBAAiBvD,WAAWwD,sBAAsB,KAAA;EACpD,CAAA;AACF,CAAA,CAAA,EACArC,KAAKf,MAAMsB,QAAQ3B,gBAAgB0D,KAAK,CAAA;",
|
|
6
|
-
"names": ["FetchHttpClient", "HttpClient", "Command", "Context", "Effect", "Layer", "ManagedRuntime", "AiServiceRouter", "contributes", "log", "AssistantCapabilities", "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
|
-
}
|