@skein-js/runtime 0.4.0 → 0.5.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ProtocolDeps } from '@skein-js/agent-protocol';
2
- import { ModuleImporter } from '@skein-js/config';
2
+ import { ModuleImporter, GraphSchemas } from '@skein-js/config';
3
3
  import { DevStateSnapshot } from '@skein-js/express';
4
4
  import { CorsOptions } from 'cors';
5
5
  import { EmbedFunction } from '@skein-js/storage-postgres';
@@ -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
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@skein-js/runtime",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
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>",
@@ -42,12 +42,12 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "cors": "^2.8.5",
45
- "@skein-js/agent-protocol": "0.4.0",
46
- "@skein-js/config": "0.4.0",
47
- "@skein-js/express": "0.4.0",
48
- "@skein-js/storage-memory": "0.4.0",
49
- "@skein-js/storage-postgres": "0.4.0",
50
- "@skein-js/redis": "0.4.0"
45
+ "@skein-js/agent-protocol": "0.5.0",
46
+ "@skein-js/express": "0.5.0",
47
+ "@skein-js/config": "0.5.0",
48
+ "@skein-js/redis": "0.5.0",
49
+ "@skein-js/storage-memory": "0.5.0",
50
+ "@skein-js/storage-postgres": "0.5.0"
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.4.0"
61
+ "@skein-js/test-support": "0.5.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"