@skein-js/runtime 0.4.0 → 0.6.3
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/index.d.ts +22 -3
- package/dist/index.js +14 -6
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProtocolDeps } from '@skein-js/agent-protocol';
|
|
2
|
-
import { ModuleImporter } from '@skein-js/config';
|
|
3
|
-
import { DevStateSnapshot } from '@skein-js/
|
|
2
|
+
import { ModuleImporter, GraphSchemas } from '@skein-js/config';
|
|
3
|
+
import { DevStateSnapshot } from '@skein-js/server-kit';
|
|
4
4
|
import { CorsOptions } from 'cors';
|
|
5
5
|
import { EmbedFunction } from '@skein-js/storage-postgres';
|
|
6
6
|
|
|
@@ -13,6 +13,11 @@ interface BuildRuntimeOptions {
|
|
|
13
13
|
configPath: string;
|
|
14
14
|
/** TS-capable importer (e.g. the CLI's vite loader). Omitted for plain JS/Node resolution. */
|
|
15
15
|
importModule?: ModuleImporter;
|
|
16
|
+
/**
|
|
17
|
+
* Precomputed graph schemas (from `skein build`) for a pre-compiled image — forwarded to
|
|
18
|
+
* `loadConfig` so schema introspection is a map lookup, never a TypeScript parse. Omitted for dev.
|
|
19
|
+
*/
|
|
20
|
+
schemas?: Record<string, GraphSchemas>;
|
|
16
21
|
/** `"memory"` (default dev) or `"postgres"` (reads `POSTGRES_URI`). */
|
|
17
22
|
store: StoreDriver;
|
|
18
23
|
/** `"memory"` (default dev) or `"redis"` (reads `REDIS_URI`). */
|
|
@@ -46,7 +51,21 @@ interface ResolveEmbedOptions {
|
|
|
46
51
|
/** TS-capable importer (the CLI's vite loader) for a custom-function `.ts` path. */
|
|
47
52
|
importModule?: ModuleImporter;
|
|
48
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether a `store.index.embed` value is a custom-function path (`"./embed.ts:fn"`) rather than a
|
|
56
|
+
* `"provider:model"` string — it looks like a path (starts with `.`/`/`) or names a source file.
|
|
57
|
+
* Exported so `skein build` knows which embed forms to bundle (paths) vs leave as provider strings.
|
|
58
|
+
*/
|
|
59
|
+
declare function isCustomFunctionPath(embed: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The npm package a `store.index.embed` value needs **installed at runtime**, or undefined. A
|
|
62
|
+
* `provider:model` embed dynamically imports `@langchain/<provider>` (see {@link resolveProviderEmbed}),
|
|
63
|
+
* but that package is never imported by graph code, so `skein build` won't discover it while bundling —
|
|
64
|
+
* it must pin this package into the production image explicitly. Custom-function paths return undefined
|
|
65
|
+
* (they are bundled), as do unknown providers.
|
|
66
|
+
*/
|
|
67
|
+
declare function embedRuntimePackage(embed: string): string | undefined;
|
|
49
68
|
/** Resolve a `store.index.embed` value to an `EmbedFunction`, honoring both LangGraph forms. */
|
|
50
69
|
declare function resolveEmbed(embed: string, options: ResolveEmbedOptions): Promise<EmbedFunction>;
|
|
51
70
|
|
|
52
|
-
export { type BuildRuntimeOptions, type QueueDriver, type ResolveEmbedOptions, RuntimeConfigError, type SkeinRuntime, type StoreDriver, buildRuntime, resolveEmbed };
|
|
71
|
+
export { type BuildRuntimeOptions, type QueueDriver, type ResolveEmbedOptions, RuntimeConfigError, type SkeinRuntime, type StoreDriver, buildRuntime, embedRuntimePackage, isCustomFunctionPath, resolveEmbed };
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
loadAuthEngine,
|
|
6
6
|
loadConfig
|
|
7
7
|
} from "@skein-js/config";
|
|
8
|
+
import { RedisRunEventBus, RedisRunQueue } from "@skein-js/redis";
|
|
8
9
|
import {
|
|
9
10
|
corsFromHttpConfig,
|
|
10
11
|
loadReloadableInMemoryRuntime
|
|
11
|
-
} from "@skein-js/
|
|
12
|
-
import { RedisRunEventBus, RedisRunQueue } from "@skein-js/redis";
|
|
12
|
+
} from "@skein-js/server-kit";
|
|
13
13
|
import { MemoryRunEventBus, MemoryRunQueue, MemorySkeinStore } from "@skein-js/storage-memory";
|
|
14
14
|
import {
|
|
15
15
|
createPostgresPool,
|
|
@@ -52,6 +52,12 @@ function isCustomFunctionPath(embed) {
|
|
|
52
52
|
const head = embed.split(":", 1)[0] ?? "";
|
|
53
53
|
return head.startsWith(".") || head.startsWith("/") || /\.([mc]?[jt]s|py)$/.test(head);
|
|
54
54
|
}
|
|
55
|
+
function embedRuntimePackage(embed) {
|
|
56
|
+
if (isCustomFunctionPath(embed)) return void 0;
|
|
57
|
+
const separator = embed.indexOf(":");
|
|
58
|
+
if (separator === -1) return void 0;
|
|
59
|
+
return PROVIDERS[embed.slice(0, separator)]?.package;
|
|
60
|
+
}
|
|
55
61
|
async function resolvePathEmbed(embed, options) {
|
|
56
62
|
const { sourceFile, exportSymbol } = parseGraphSpec(embed, options.configDir);
|
|
57
63
|
const importer = options.importModule ?? ((file) => import(pathToFileURL(file).href));
|
|
@@ -145,9 +151,9 @@ async function resolveStoreIndex(index, options) {
|
|
|
145
151
|
return { dims: index.dims, fields: index.fields, embed };
|
|
146
152
|
}
|
|
147
153
|
async function buildRuntime(options) {
|
|
148
|
-
const { configPath, importModule, store, queue } = options;
|
|
154
|
+
const { configPath, importModule, store, queue, schemas } = options;
|
|
149
155
|
if (store === "memory" && queue === "memory") {
|
|
150
|
-
const runtime = await loadReloadableInMemoryRuntime(configPath, importModule);
|
|
156
|
+
const runtime = await loadReloadableInMemoryRuntime(configPath, importModule, schemas);
|
|
151
157
|
return {
|
|
152
158
|
deps: runtime.deps,
|
|
153
159
|
cors: runtime.cors,
|
|
@@ -158,7 +164,7 @@ async function buildRuntime(options) {
|
|
|
158
164
|
hydrateState: (snapshot) => runtime.hydrateState(snapshot)
|
|
159
165
|
};
|
|
160
166
|
}
|
|
161
|
-
const first = await loadConfig({ configPath, importModule });
|
|
167
|
+
const first = await loadConfig({ configPath, importModule, staticSchemas: schemas });
|
|
162
168
|
const { resolver, reroute } = reroutableGraphResolver(first.graphs);
|
|
163
169
|
const disposers = [];
|
|
164
170
|
const disposeAll = async () => {
|
|
@@ -227,7 +233,7 @@ async function buildRuntime(options) {
|
|
|
227
233
|
deps,
|
|
228
234
|
cors: corsFromHttpConfig(first.config.http),
|
|
229
235
|
reloadGraphs: async () => {
|
|
230
|
-
reroute((await loadConfig({ configPath, importModule })).graphs);
|
|
236
|
+
reroute((await loadConfig({ configPath, importModule, staticSchemas: schemas })).graphs);
|
|
231
237
|
},
|
|
232
238
|
dispose: disposeAll
|
|
233
239
|
};
|
|
@@ -249,5 +255,7 @@ function resolveStoreTtl(raw) {
|
|
|
249
255
|
export {
|
|
250
256
|
RuntimeConfigError,
|
|
251
257
|
buildRuntime,
|
|
258
|
+
embedRuntimePackage,
|
|
259
|
+
isCustomFunctionPath,
|
|
252
260
|
resolveEmbed
|
|
253
261
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skein-js/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Assembles skein-js ProtocolDeps from langgraph.json + selected drivers (memory/Postgres/Redis).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Maina Wycliffe <wmmaina7@gmail.com>",
|
|
7
|
-
"homepage": "https://github.com/
|
|
7
|
+
"homepage": "https://github.com/skein-js/skein-js/tree/main/packages/runtime#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/skein-js/skein-js.git",
|
|
11
11
|
"directory": "packages/runtime"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/skein-js/skein-js/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"typescript",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"cors": "^2.8.5",
|
|
45
|
-
"@skein-js/agent-protocol": "0.
|
|
46
|
-
"@skein-js/
|
|
47
|
-
"@skein-js/
|
|
48
|
-
"@skein-js/
|
|
49
|
-
"@skein-js/storage-
|
|
50
|
-
"@skein-js/
|
|
45
|
+
"@skein-js/agent-protocol": "0.6.3",
|
|
46
|
+
"@skein-js/redis": "0.6.3",
|
|
47
|
+
"@skein-js/config": "0.6.3",
|
|
48
|
+
"@skein-js/server-kit": "0.6.3",
|
|
49
|
+
"@skein-js/storage-memory": "0.6.3",
|
|
50
|
+
"@skein-js/storage-postgres": "0.6.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@langchain/langgraph": "^1.4.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@langchain/langgraph": "^1.4.0",
|
|
59
59
|
"@langchain/langgraph-checkpoint-postgres": "^1.0.4",
|
|
60
60
|
"@types/cors": "^2.8.17",
|
|
61
|
-
"@skein-js/test-support": "0.
|
|
61
|
+
"@skein-js/test-support": "0.6.3"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|