@dxos/edge-compute 0.0.0 → 0.11.0
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/bundler.mjs +195 -0
- package/dist/lib/bundler.mjs.map +1 -0
- package/dist/lib/chunk-http-plugin-esbuild.mjs +52 -0
- package/dist/lib/chunk-http-plugin-esbuild.mjs.map +1 -0
- package/dist/lib/index.mjs +444 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/native.mjs +148 -0
- package/dist/lib/native.mjs.map +1 -0
- package/dist/lib/testing.mjs +40 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/EdgeProcessManager.d.ts +10 -4
- package/dist/types/src/EdgeProcessManager.d.ts.map +1 -1
- package/dist/types/src/EdgeProcessManager.test.d.ts +2 -0
- package/dist/types/src/EdgeProcessManager.test.d.ts.map +1 -0
- package/dist/types/src/EdgeTriggerManager.d.ts +11 -3
- package/dist/types/src/EdgeTriggerManager.d.ts.map +1 -1
- package/dist/types/src/native/bundler.d.ts.map +1 -1
- package/dist/types/src/testing/services.d.ts +7 -4
- package/dist/types/src/testing/services.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -22
- package/src/EdgeProcessManager.test.ts +59 -0
- package/src/EdgeProcessManager.ts +65 -16
- package/src/EdgeTriggerManager.ts +105 -31
- package/src/native/bundler.ts +8 -1
- package/src/testing/services.ts +22 -16
- package/dist/lib/neutral/bundler/index.mjs +0 -213
- package/dist/lib/neutral/bundler/index.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RN6KVGN4.mjs +0 -63
- package/dist/lib/neutral/chunk-RN6KVGN4.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -343
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/native/index.mjs +0 -186
- package/dist/lib/neutral/native/index.mjs.map +0 -7
- package/dist/lib/neutral/testing/index.mjs +0 -41
- package/dist/lib/neutral/testing/index.mjs.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.mjs","names":[],"sources":["../../src/native/bundler.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport * as Array from 'effect/Array';\nimport * as Function from 'effect/Function';\nimport * as Order from 'effect/Order';\nimport * as Record from 'effect/Record';\nimport { type Message, build } from 'esbuild';\nimport { statSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport * as fs from 'node:fs/promises';\nimport { basename, dirname, join, relative, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { BaseError } from '@dxos/errors';\nimport { PublicKey } from '@dxos/keys';\nimport { Unit, trim } from '@dxos/util';\n\nimport { httpPlugin } from '../bundler/plugins/http-plugin-esbuild';\n\ntype BundleOptions = {\n entryPoint: string;\n verbose?: boolean;\n};\n\nexport type BundleResult = {\n entryPoint: string;\n assets: Record<string, Uint8Array>;\n};\n\n/**\n * Bundles a function.\n * Pulls in node_modules and wasm files.\n */\nexport const bundleFunction = async (options: BundleOptions): Promise<BundleResult> => {\n const outdir = `/tmp/dxos-functions-bundle-${new Date().toISOString()}-${PublicKey.random().toHex()}`;\n const gitDir = findGitDir(dirname(options.entryPoint));\n\n const result = await build({\n entryPoints: {\n // Gets mapped to `index.js` by esbuild.\n index: 'dxos:entrypoint',\n },\n bundle: true,\n format: 'esm',\n platform: 'browser',\n conditions: ['workerd', 'worker', 'browser'],\n outdir,\n metafile: true,\n treeShaking: true,\n sourcemap: true,\n splitting: true,\n logOverride: {\n 'ignored-bare-import': 'silent',\n },\n loader: {\n '.wasm': 'copy',\n },\n external: ['node:*', 'cloudflare:workers', 'functions-service:user-script'],\n plugins: [\n httpPlugin,\n {\n name: 'entrypoint',\n setup: (build) => {\n build.onResolve({ filter: /^dxos:entrypoint$/ }, () => ({\n path: 'dxos:entrypoint',\n namespace: 'dxos:entrypoint',\n }));\n build.onLoad({ filter: /^dxos:entrypoint$/, namespace: 'dxos:entrypoint' }, () => ({\n contents: trim`\n export default {\n fetch: async (...args) => {\n const { wrapFunctionHandler } = await import('@dxos/compute-runtime');\n const { wrapHandlerForCloudflare, setupFunctionsLogger } = await import('@dxos/functions-runtime-cloudflare');\n const { default: handler } = await import('${options.entryPoint}');\n\n setupFunctionsLogger();\n\n //\n // Wrapper to make the function cloudflare-compatible.\n //\n return wrapHandlerForCloudflare(wrapFunctionHandler(handler))(...args);\n },\n };\n `,\n // NOTE: Compute the module directory via `fileURLToPath`, not\n // `new URL('.', import.meta.url)`. Vite's library-mode build treats the latter as an\n // asset reference and base64-inlines the resolved `.ts` module as a\n // `data:video/mp2t;base64,…` data URL, so `resolveDir` becomes garbage in `dist` and\n // the bundler can no longer resolve `@dxos/compute-runtime` /\n // `@dxos/functions-runtime-cloudflare`.\n resolveDir: dirname(fileURLToPath(import.meta.url)),\n }));\n },\n },\n {\n name: 'metafile',\n setup: (build) => {\n build.onEnd(async (result) => {\n await writeFile(\n join(build.initialOptions.outdir!, 'metafile.json'),\n JSON.stringify(result.metafile, null, 2),\n );\n await writeFile(\n join(build.initialOptions.outdir!, 'manifest.json'),\n JSON.stringify(\n {\n files: Object.keys(result.metafile!.outputs).map((path) => ({\n name: relative(build.initialOptions.outdir!, path),\n })),\n },\n null,\n 2,\n ),\n );\n });\n },\n },\n ],\n });\n\n if (result.errors.length > 0) {\n throw new BundleCreationError(result.errors);\n }\n\n const assetPaths = Object.keys(result.metafile!.outputs).map((path) => relative(outdir, path));\n const assets = Function.pipe(\n await Promise.all(assetPaths.map((path) => fs.readFile(join(outdir, path)))),\n Array.zipWith(assetPaths, (content, path) => [path, content] as const),\n Record.fromEntries,\n );\n\n if (options.verbose) {\n console.log('Function compiled');\n console.log('Metafile path:', `${outdir}/metafile.json`);\n console.log('Assets:\\n');\n console.log(\n Object.entries(result.metafile!.outputs)\n .sort((a, b) => b[1].bytes - a[1].bytes)\n .map(\n ([path, desc]) =>\n `${formatBytes(desc.bytes).padEnd(10)} - ${relative(outdir, path)} ${basename(path) === 'index.js' ? ' (entry point)' : ''}`,\n )\n .join('\\n'),\n );\n\n const filesInOutput = Function.pipe(\n result.metafile.outputs,\n Record.values,\n Array.flatMap((_) => Record.toEntries(_.inputs)),\n );\n\n const moduleInOutput = Function.pipe(\n result.metafile.inputs,\n Record.values,\n Array.flatMap((_) => _.imports),\n Array.filter((_) => !!_.original?.match(/^@[a-zA-Z]+/)),\n Array.filter((_) => !!filesInOutput.find(([name]) => name === _.path)),\n Array.map((_) => _.original!),\n Array.dedupe,\n Array.sort(Order.string),\n );\n console.log(`Modules in output:\\n${moduleInOutput.map((_) => ` - ${_}`).join('\\n')}`);\n }\n\n for (const path of Object.keys(assets)) {\n if (path.endsWith('.map')) {\n const content = assets[path];\n const map = JSON.parse(new TextDecoder().decode(content));\n const processedMap = postprocessSourceMap(map, outdir, gitDir);\n assets[path] = Buffer.from(JSON.stringify(processedMap));\n }\n }\n\n // Must match esbuild entry point.\n return { entryPoint: 'index.js', assets };\n};\n\nclass BundleCreationError extends BaseError.extend('BundleCreationError', 'Bundle creation failed') {\n constructor(errors: Message[]) {\n super({ context: { errors } });\n }\n}\n\nconst formatBytes = (bytes: number) => {\n if (bytes < Unit.Kilobyte(1).unit.quotient) {\n return Unit.Byte(bytes).toString();\n }\n if (bytes < Unit.Megabyte(1).unit.quotient) {\n return Unit.Kilobyte(bytes).toString();\n }\n if (bytes < Unit.Gigabyte(1).unit.quotient) {\n return Unit.Megabyte(bytes).toString();\n }\n return Unit.Gigabyte(bytes).toString();\n};\n\nconst findGitDir = (startPath: string): string | null => {\n let current = startPath;\n while (current !== '/') {\n const gitPath = join(current, '.git');\n try {\n if (statSync(gitPath).isDirectory()) {\n return gitPath;\n }\n } catch {\n // ignore\n }\n current = dirname(current);\n }\n return null;\n};\n\n/**\n * Adjust source paths to be relative to the repo root.\n */\nconst postprocessSourceMap = (map: any, outDir: string, gitDir: string | null) => {\n if (!gitDir) {\n return map;\n }\n\n // Update source paths to be relative to the output directory\n if (map.sources && Array.isArray(map.sources)) {\n map.sources = map.sources.map((source: string) => {\n const resolved = resolve(outDir, source);\n if (resolved.startsWith(dirname(gitDir))) {\n const rel = relative(dirname(gitDir), resolved);\n return rel;\n }\n return source;\n });\n }\n\n return map;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAa,iBAAiB,OAAO,YAAkD;CACrF,MAAM,SAAS,+CAA8B,IAAI,KAAK,EAAA,CAAE,YAAY,EAAE,GAAG,UAAU,OAAO,CAAC,CAAC,MAAM;CAClG,MAAM,SAAS,WAAW,QAAQ,QAAQ,UAAU,CAAC;CAErD,MAAM,SAAS,MAAM,MAAM;EACzB,aAAa,EAEX,OAAO,kBACT;EACA,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,YAAY;GAAC;GAAW;GAAU;EAAS;EAC3C;EACA,UAAU;EACV,aAAa;EACb,WAAW;EACX,WAAW;EACX,aAAa,EACX,uBAAuB,SACzB;EACA,QAAQ,EACN,SAAS,OACX;EACA,UAAU;GAAC;GAAU;GAAsB;EAA+B;EAC1E,SAAS;GACP;GACA;IACE,MAAM;IACN,QAAQ,UAAU;KAChB,MAAM,UAAU,EAAE,QAAQ,oBAAoB,UAAU;MACtD,MAAM;MACN,WAAW;KACb,EAAE;KACF,MAAM,OAAO;MAAE,QAAQ;MAAqB,WAAW;KAAkB,UAAU;MACjF,UAAU,IAAI;;;;;+DAKqC,QAAQ,WAAW;;;;;;;;;;;MAiBtE,YAAY,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;KACpD,EAAE;IACJ;GACF;GACA;IACE,MAAM;IACN,QAAQ,UAAU;KAChB,MAAM,MAAM,OAAO,WAAW;MAC5B,MAAM,UACJ,KAAK,MAAM,eAAe,QAAS,eAAe,GA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,CAAC,CAAC,SAAS;AACvC;AAEA,IAAM,cAAc,cAAqC;CACvD,IAAI,UAAU;CACd,OAAO,YAAY,KAAK;EACtB,MAAM,UAAU,KAAK,SAAS,MAAM;EACpC,IAAI;GACF,IAAI,SAAS,OAAO,CAAC,CAAC,YAAY,GAChC,OAAO;EAEX,QAAQ,CAER;EACA,UAAU,QAAQ,OAAO;CAC3B;CACA,OAAO;AACT;;;;AAKA,IAAM,wBAAwB,KAAU,QAAgB,WAA0B;CAChF,IAAI,CAAC,QACH,OAAO;CAIT,IAAI,IAAI,WAAW,MAAM,QAAQ,IAAI,OAAO,GAC1C,IAAI,UAAU,IAAI,QAAQ,KAAK,WAAmB;EAChD,MAAM,WAAW,QAAQ,QAAQ,MAAM;EACvC,IAAI,SAAS,WAAW,QAAQ,MAAM,CAAC,GAErC,OADY,SAAS,QAAQ,MAAM,GAAG,QAC/B;EAET,OAAO;CACT,CAAC;CAGH,OAAO;AACT"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { assertArgument } from "@dxos/invariant";
|
|
2
|
+
import { Credential, Trace } from "@dxos/compute";
|
|
3
|
+
import { ConfiguredCredentialsService } from "@dxos/compute-runtime";
|
|
4
|
+
import { Database } from "@dxos/echo";
|
|
5
|
+
import { log } from "@dxos/log";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
//#region src/testing/logger.ts
|
|
8
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/edge-compute/src/testing/logger.ts";
|
|
9
|
+
var noopTraceWriter = Trace.noopWriter;
|
|
10
|
+
var consoleTraceWriter = { write: (event, payload) => {
|
|
11
|
+
log.info(event.key, payload, {
|
|
12
|
+
"~LogMeta": "~LogMeta",
|
|
13
|
+
F: __dxlog_file,
|
|
14
|
+
L: 12,
|
|
15
|
+
S: void 0
|
|
16
|
+
});
|
|
17
|
+
} };
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/testing/services.ts
|
|
20
|
+
/**
|
|
21
|
+
* Composes the foundational Effect layers available to compute nodes and operations in tests:
|
|
22
|
+
* credentials, database (from a space or standalone database), and trace. Callers layer AI,
|
|
23
|
+
* `Operation.Service`, and registry on top as needed for the code under test.
|
|
24
|
+
*/
|
|
25
|
+
var createTestServices = ({ credentials, db, logging, space } = {}) => {
|
|
26
|
+
assertArgument(!(!!space && !!db), "space", "space can be provided only if db is not");
|
|
27
|
+
const credentialsLayer = Layer.succeed(Credential.CredentialsService, createCredentialsService(credentials) ?? new ConfiguredCredentialsService());
|
|
28
|
+
const database = space?.db ?? db;
|
|
29
|
+
const databaseLayer = database ? Database.layer(database) : Database.notAvailable;
|
|
30
|
+
const traceLayer = Layer.succeed(Trace.TraceService, logging?.trace ?? (logging?.enabled ? consoleTraceWriter : noopTraceWriter));
|
|
31
|
+
return Layer.mergeAll(credentialsLayer, databaseLayer, traceLayer);
|
|
32
|
+
};
|
|
33
|
+
var createCredentialsService = (credentials) => {
|
|
34
|
+
if (credentials?.services) return new ConfiguredCredentialsService(credentials.services);
|
|
35
|
+
if (credentials?.service) return credentials.service;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createTestServices };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing/logger.ts","../../src/testing/services.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Trace } from '@dxos/compute';\nimport { log } from '@dxos/log';\n\nexport const noopTraceWriter: Trace.TraceWriter = Trace.noopWriter;\n\nexport const consoleTraceWriter: Trace.TraceWriter = {\n write: (event, payload) => {\n log.info(event.key, payload as object);\n },\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Layer from 'effect/Layer';\n\nimport type { Space } from '@dxos/client/echo';\nimport { Credential, Trace } from '@dxos/compute';\nimport { ConfiguredCredentialsService } from '@dxos/compute-runtime';\nimport { Database } from '@dxos/echo';\nimport { type EchoDatabase } from '@dxos/echo-client';\nimport { assertArgument } from '@dxos/invariant';\n\nimport { consoleTraceWriter, noopTraceWriter } from './logger';\n\n// TODO(burdon): Factor out.\nexport type OneOf<T> = {\n [K in keyof T]: { [P in K]: T[P] } & { [P in Exclude<keyof T, K>]?: never };\n}[keyof T];\n\nexport type AiServiceProvider = 'dev' | 'edge' | 'ollama' | 'lmstudio';\n\nexport type TestServiceOptions = {\n /**\n * AI service configuration.\n */\n ai?: any;\n\n /**\n * Credentials service configuration.\n */\n credentials?: OneOf<{\n /**\n * Predefined credentials list.\n */\n services?: Credential.ServiceCredential[];\n\n /**\n * Custom credentials service.\n */\n service?: Context.Tag.Service<Credential.CredentialsService>;\n }>;\n\n /**\n * Database configuration.\n */\n db?: EchoDatabase;\n\n /**\n * Gets database service from the space.\n * Exclusive with: `db`\n */\n space?: Space;\n\n /**\n * Trace writer configuration.\n */\n logging?: {\n enabled?: boolean;\n trace?: Context.Tag.Service<Trace.TraceService>;\n };\n};\n\n/**\n * Composes the foundational Effect layers available to compute nodes and operations in tests:\n * credentials, database (from a space or standalone database), and trace. Callers layer AI,\n * `Operation.Service`, and registry on top as needed for the code under test.\n */\nexport const createTestServices = ({ credentials, db, logging, space }: TestServiceOptions = {}): Layer.Layer<\n Credential.CredentialsService | Database.Service | Trace.TraceService\n> => {\n assertArgument(!(!!space && !!db), 'space', 'space can be provided only if db is not');\n\n const credentialsLayer = Layer.succeed(\n Credential.CredentialsService,\n createCredentialsService(credentials) ?? new ConfiguredCredentialsService(),\n );\n\n const database = space?.db ?? db;\n const databaseLayer = database ? Database.layer(database) : Database.notAvailable;\n\n const traceLayer = Layer.succeed(\n Trace.TraceService,\n logging?.trace ?? (logging?.enabled ? consoleTraceWriter : noopTraceWriter),\n );\n\n return Layer.mergeAll(credentialsLayer, databaseLayer, traceLayer);\n};\n\nconst createCredentialsService = (\n credentials: TestServiceOptions['credentials'] | undefined,\n): Context.Tag.Service<Credential.CredentialsService> | undefined => {\n if (credentials?.services) {\n return new ConfiguredCredentialsService(credentials.services);\n }\n\n if (credentials?.service) {\n return credentials.service;\n }\n};\n"],"mappings":";;;;;;;;AAOA,IAAa,kBAAqC,MAAM;AAExD,IAAa,qBAAwC,EACnD,QAAQ,OAAO,YAAY;CACzB,IAAI,KAAK,MAAM,KAAK,SAAgB;EAAA,YAAA;EAAA,GAAA;EAAA,GAAA;EAAA,GAAA,KAAA;CAAA,CAAC;AACvC,EACF;;;;;;;;ACwDA,IAAa,sBAAsB,EAAE,aAAa,IAAI,SAAS,UAA8B,CAAC,MAEzF;CACH,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,yCAAyC;CAErF,MAAM,mBAAmB,MAAM,QAC7B,WAAW,oBACX,yBAAyB,WAAW,KAAK,IAAI,6BAA6B,CAC5E;CAEA,MAAM,WAAW,OAAO,MAAM;CAC9B,MAAM,gBAAgB,WAAW,SAAS,MAAM,QAAQ,IAAI,SAAS;CAErE,MAAM,aAAa,MAAM,QACvB,MAAM,cACN,SAAS,UAAU,SAAS,UAAU,qBAAqB,gBAC7D;CAEA,OAAO,MAAM,SAAS,kBAAkB,eAAe,UAAU;AACnE;AAEA,IAAM,4BACJ,gBACmE;CACnE,IAAI,aAAa,UACf,OAAO,IAAI,6BAA6B,YAAY,QAAQ;CAG9D,IAAI,aAAa,SACf,OAAO,YAAY;AAEvB"}
|
|
@@ -2,13 +2,19 @@ import { Registry } from '@effect-atom/atom';
|
|
|
2
2
|
import * as Layer from 'effect/Layer';
|
|
3
3
|
import { type Client } from '@dxos/client';
|
|
4
4
|
import { RemoteProcessManager } from '@dxos/compute-runtime';
|
|
5
|
+
import { type EdgeHttpClient } from '@dxos/edge-client';
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
* process-tree endpoint exists.
|
|
7
|
+
* For tests: provide a pre-built edge client.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const fromEdgeClient: (edgeClient: EdgeHttpClient) => Layer.Layer<RemoteProcessManager.Service, never, Registry.AtomRegistry>;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Build from a `Client`, deferring edge-client creation until the first cancel
|
|
12
|
+
* (identity / edge config may be absent at boot).
|
|
13
|
+
*/
|
|
14
|
+
export declare const fromClient: (client: Client) => Layer.Layer<RemoteProcessManager.Service, never, Registry.AtomRegistry>;
|
|
15
|
+
/**
|
|
16
|
+
* EDGE process manager with no client — empty process tree and no cancel control.
|
|
17
|
+
* Used where edge is not configured.
|
|
12
18
|
*/
|
|
13
19
|
export declare const layer: Layer.Layer<RemoteProcessManager.Service, never, Registry.AtomRegistry>;
|
|
14
20
|
//# sourceMappingURL=EdgeProcessManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgeProcessManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeProcessManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"EdgeProcessManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeProcessManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA6DxD;;GAEG;AACH,eAAO,MAAM,cAAc,eACb,cAAc,KACzB,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAA2B,CAAC;AAErG;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAGjH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeProcessManager.test.d.ts","sourceRoot":"","sources":["../../../src/EdgeProcessManager.test.ts"],"names":[],"mappings":""}
|
|
@@ -3,12 +3,20 @@ import * as Layer from 'effect/Layer';
|
|
|
3
3
|
import { type Client, ClientService } from '@dxos/client';
|
|
4
4
|
import { RemoteTriggerManager } from '@dxos/compute-runtime';
|
|
5
5
|
import { type SpaceId } from '@dxos/keys';
|
|
6
|
+
import { createEdgeClient } from './edge-client';
|
|
7
|
+
type EdgeClient = ReturnType<typeof createEdgeClient>;
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* For tests: provide a pre-built edge client.
|
|
8
10
|
*/
|
|
9
|
-
export declare const
|
|
11
|
+
export declare const fromEdgeClient: (edgeClient: EdgeClient, spaceId: SpaceId) => Layer.Layer<RemoteTriggerManager.Service, never, Registry.AtomRegistry>;
|
|
12
|
+
/**
|
|
13
|
+
* Build from a `Client`, deferring edge-client creation until first use
|
|
14
|
+
* (identity may be absent at boot).
|
|
15
|
+
*/
|
|
16
|
+
export declare const fromClient: (client: Client, spaceId: SpaceId) => Layer.Layer<RemoteTriggerManager.Service, never, Registry.AtomRegistry>;
|
|
10
17
|
/**
|
|
11
18
|
* Build from the ambient `ClientService`.
|
|
12
19
|
*/
|
|
13
|
-
export declare const layer: (spaceId
|
|
20
|
+
export declare const layer: (spaceId: SpaceId) => Layer.Layer<RemoteTriggerManager.Service, never, Registry.AtomRegistry | ClientService>;
|
|
21
|
+
export {};
|
|
14
22
|
//# sourceMappingURL=EdgeTriggerManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgeTriggerManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeTriggerManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"EdgeTriggerManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeTriggerManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,KAAK,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAO,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAyEtD;;GAEG;AACH,eAAO,MAAM,cAAc,eACb,UAAU,WACb,OAAO,KACf,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAOtE,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,WACL,OAAO,KACf,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAQtE,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,KAAK,YACP,OAAO,KACf,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,GAAG,aAAa,CAStF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/native/bundler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/native/bundler.ts"],"names":[],"mappings":"AAuBA,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAmB,aAAa,KAAG,OAAO,CAAC,YAAY,CA8IjF,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type * as Context from 'effect/Context';
|
|
2
|
+
import * as Layer from 'effect/Layer';
|
|
2
3
|
import type { Space } from '@dxos/client/echo';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { Credential, Trace } from '@dxos/compute';
|
|
5
|
+
import { Database } from '@dxos/echo';
|
|
5
6
|
import { type EchoDatabase } from '@dxos/echo-client';
|
|
6
7
|
export type OneOf<T> = {
|
|
7
8
|
[K in keyof T]: {
|
|
@@ -47,7 +48,9 @@ export type TestServiceOptions = {
|
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* Composes the foundational Effect layers available to compute nodes and operations in tests:
|
|
52
|
+
* credentials, database (from a space or standalone database), and trace. Callers layer AI,
|
|
53
|
+
* `Operation.Service`, and registry on top as needed for the code under test.
|
|
51
54
|
*/
|
|
52
|
-
export declare const createTestServices: ({
|
|
55
|
+
export declare const createTestServices: ({ credentials, db, logging, space }?: TestServiceOptions) => Layer.Layer<Credential.CredentialsService | Database.Service | Trace.TraceService>;
|
|
53
56
|
//# sourceMappingURL=services.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/testing/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/testing/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,GAAG;SAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAAE,GAAG;SAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;KAAE;CAC5E,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,EAAE,CAAC,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB;;WAEG;QACH,QAAQ,CAAC,EAAE,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAE1C;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,OA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