@adhd/agent-core-provider 2.1.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/drizzle/0000_providers_and_models.sql +23 -0
- package/drizzle/0001_model_platform_bindings.sql +8 -0
- package/drizzle/0002_provider_tool_formats.sql +10 -0
- package/drizzle/meta/0000_snapshot.json +149 -0
- package/drizzle/meta/0001_snapshot.json +190 -0
- package/drizzle/meta/0002_snapshot.json +245 -0
- package/drizzle/meta/_journal.json +27 -0
- package/package.json +53 -0
- package/src/adapter/provider-adapter.d.ts +21 -0
- package/src/adapter/provider-adapter.d.ts.map +1 -0
- package/src/adapter/provider-adapter.js +38 -0
- package/src/adapter/provider-adapter.js.map +1 -0
- package/src/db/client.d.ts +7 -0
- package/src/db/client.d.ts.map +1 -0
- package/src/db/client.js +19 -0
- package/src/db/client.js.map +1 -0
- package/src/db/migrate-runner.d.ts +30 -0
- package/src/db/migrate-runner.d.ts.map +1 -0
- package/src/db/migrate-runner.js +34 -0
- package/src/db/migrate-runner.js.map +1 -0
- package/src/db/migrate.d.ts +9 -0
- package/src/db/migrate.d.ts.map +1 -0
- package/src/db/migrate.js +13 -0
- package/src/db/migrate.js.map +1 -0
- package/src/db/schema.d.ts +475 -0
- package/src/db/schema.d.ts.map +1 -0
- package/src/db/schema.js +79 -0
- package/src/db/schema.js.map +1 -0
- package/src/index.d.ts +17 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +15 -0
- package/src/index.js.map +1 -0
- package/src/runtime/emit-tools.d.ts +91 -0
- package/src/runtime/emit-tools.d.ts.map +1 -0
- package/src/runtime/emit-tools.js +98 -0
- package/src/runtime/emit-tools.js.map +1 -0
- package/src/seed/bindings.d.ts +16 -0
- package/src/seed/bindings.d.ts.map +1 -0
- package/src/seed/bindings.js +65 -0
- package/src/seed/bindings.js.map +1 -0
- package/src/seed/index.d.ts +13 -0
- package/src/seed/index.d.ts.map +1 -0
- package/src/seed/index.js +29 -0
- package/src/seed/index.js.map +1 -0
- package/src/seed/models.d.ts +22 -0
- package/src/seed/models.d.ts.map +1 -0
- package/src/seed/models.js +68 -0
- package/src/seed/models.js.map +1 -0
- package/src/seed/providers.d.ts +11 -0
- package/src/seed/providers.d.ts.map +1 -0
- package/src/seed/providers.js +65 -0
- package/src/seed/providers.js.map +1 -0
- package/src/store/model-store.d.ts +69 -0
- package/src/store/model-store.d.ts.map +1 -0
- package/src/store/model-store.js +130 -0
- package/src/store/model-store.js.map +1 -0
- package/src/store/provider-store.d.ts +39 -0
- package/src/store/provider-store.d.ts.map +1 -0
- package/src/store/provider-store.js +88 -0
- package/src/store/provider-store.js.map +1 -0
- package/src/store/tool-format-store.d.ts +58 -0
- package/src/store/tool-format-store.d.ts.map +1 -0
- package/src/store/tool-format-store.js +93 -0
- package/src/store/tool-format-store.js.map +1 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FEAT-007 runtime tool emitter.
|
|
3
|
+
*
|
|
4
|
+
* Given a ToolDefinition and a lookup function that resolves its
|
|
5
|
+
* provider_tool_formats row, branches on emit_shape:
|
|
6
|
+
*
|
|
7
|
+
* custom → { name, description, input_schema } (standard custom def)
|
|
8
|
+
* server_side → { type: <type_tag>, name } (no input_schema — executed server-side)
|
|
9
|
+
* unsupported → throws UnsupportedNativeToolError ([inv:gate-not-noop])
|
|
10
|
+
*
|
|
11
|
+
* This is the strategic replacement for agent-mcp's toAnthropicTools(), which
|
|
12
|
+
* maps every tool to the custom shape and never emits a type-tagged server-side
|
|
13
|
+
* entry ([ref:runtime-gap]). Wiring into the live provider is agent-mcp-refactor's
|
|
14
|
+
* job (plan 6); this module delivers the emitter standalone.
|
|
15
|
+
*
|
|
16
|
+
* ([def:server-side-tool], [def:unsupported-native], [inv:server-side-shape],
|
|
17
|
+
* [inv:gate-not-noop], RUNTIME_GAPS Gap 1 + Gap 2 + Recommended Handoff #2)
|
|
18
|
+
*/
|
|
19
|
+
import type { ToolDefinition } from '@adhd/agent-base-types';
|
|
20
|
+
import type { ToolFormat } from '../store/tool-format-store.js';
|
|
21
|
+
/** Error code for unsupported native tools ([def:unsupported-native]). */
|
|
22
|
+
export type UnsupportedNativeToolErrorCode = 'UNSUPPORTED_NATIVE_TOOL';
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when the emitter encounters a provider-native tool that this package
|
|
25
|
+
* does not yet execute (e.g. Anthropic client-executed `bash`, `computer`).
|
|
26
|
+
*
|
|
27
|
+
* The message always names the tool + provider and includes the registered note
|
|
28
|
+
* so callers know exactly what is missing — never a silent no-op.
|
|
29
|
+
* ([inv:gate-not-noop])
|
|
30
|
+
*/
|
|
31
|
+
export declare class UnsupportedNativeToolError extends Error {
|
|
32
|
+
readonly code: UnsupportedNativeToolErrorCode;
|
|
33
|
+
readonly toolName: string;
|
|
34
|
+
readonly providerId: string;
|
|
35
|
+
constructor(toolName: string, providerId: string, note: string | null);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Standard custom tool definition emitted to the provider API.
|
|
39
|
+
* Matches the Anthropic / OpenAI `{name, description, input_schema}` shape.
|
|
40
|
+
*/
|
|
41
|
+
export interface EmittedCustomTool {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
input_schema: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Server-side type-tagged entry emitted to the Anthropic API.
|
|
48
|
+
* Has NO `input_schema` — the tool executes on Anthropic's servers.
|
|
49
|
+
* e.g. `{ type: "web_search_20250305", name: "web_search" }`
|
|
50
|
+
* ([def:server-side-tool], [inv:server-side-shape])
|
|
51
|
+
*/
|
|
52
|
+
export interface EmittedServerSideTool {
|
|
53
|
+
type: string;
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
56
|
+
/** Discriminated union of both emitted shapes. */
|
|
57
|
+
export type EmittedTool = EmittedCustomTool | EmittedServerSideTool;
|
|
58
|
+
/**
|
|
59
|
+
* A function that, given (providerId, canonicalTool), returns the registered
|
|
60
|
+
* ToolFormat row or null if no row exists. Callers typically pass
|
|
61
|
+
* `ToolFormatStore.getShape` bound to a store instance, but can supply any
|
|
62
|
+
* compatible lookup (e.g. an in-memory fixture in tests).
|
|
63
|
+
*/
|
|
64
|
+
export type ToolFormatLookup = (providerId: string, canonicalTool: string) => ToolFormat | null;
|
|
65
|
+
/**
|
|
66
|
+
* Emit a single tool for the given provider.
|
|
67
|
+
*
|
|
68
|
+
* Branches on `emit_shape` from the tool format lookup:
|
|
69
|
+
* - `custom` (or no registered row) → `EmittedCustomTool`
|
|
70
|
+
* - `server_side` → `EmittedServerSideTool` (no input_schema)
|
|
71
|
+
* - `unsupported` → throws `UnsupportedNativeToolError`
|
|
72
|
+
*
|
|
73
|
+
* @param tool - The canonical ToolDefinition.
|
|
74
|
+
* @param providerId - The provider id (e.g. "anthropic") used to look up the format row.
|
|
75
|
+
* @param lookup - Format lookup, typically `store.getShape.bind(store)`.
|
|
76
|
+
* @throws {UnsupportedNativeToolError} when the tool's emit_shape is "unsupported".
|
|
77
|
+
*/
|
|
78
|
+
export declare function emitTool(tool: ToolDefinition, providerId: string, lookup: ToolFormatLookup): EmittedTool;
|
|
79
|
+
/**
|
|
80
|
+
* Emit all tools for the given provider, applying `emitTool` to each.
|
|
81
|
+
*
|
|
82
|
+
* Throws on the first `unsupported` tool encountered so callers get an
|
|
83
|
+
* early, actionable error rather than a partially-built list.
|
|
84
|
+
*
|
|
85
|
+
* @param tools - Array of canonical ToolDefinitions.
|
|
86
|
+
* @param providerId - Provider id used to look up format rows.
|
|
87
|
+
* @param lookup - Format lookup, typically `store.getShape.bind(store)`.
|
|
88
|
+
* @throws {UnsupportedNativeToolError} on the first unsupported tool.
|
|
89
|
+
*/
|
|
90
|
+
export declare function emitToolsForProvider(tools: ToolDefinition[], providerId: string, lookup: ToolFormatLookup): EmittedTool[];
|
|
91
|
+
//# sourceMappingURL=emit-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-tools.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/runtime/emit-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAM3E,0EAA0E;AAC1E,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AAEvE;;;;;;;GAOG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAA6B;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAWtE;AAMD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,qBAAqB,CAAC;AAMpE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,KAClB,UAAU,GAAG,IAAI,CAAC;AAMvB;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,GACvB,WAAW,CAmCb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EAAE,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,GACvB,WAAW,EAAE,CAEf"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FEAT-007 runtime tool emitter.
|
|
3
|
+
*
|
|
4
|
+
* Given a ToolDefinition and a lookup function that resolves its
|
|
5
|
+
* provider_tool_formats row, branches on emit_shape:
|
|
6
|
+
*
|
|
7
|
+
* custom → { name, description, input_schema } (standard custom def)
|
|
8
|
+
* server_side → { type: <type_tag>, name } (no input_schema — executed server-side)
|
|
9
|
+
* unsupported → throws UnsupportedNativeToolError ([inv:gate-not-noop])
|
|
10
|
+
*
|
|
11
|
+
* This is the strategic replacement for agent-mcp's toAnthropicTools(), which
|
|
12
|
+
* maps every tool to the custom shape and never emits a type-tagged server-side
|
|
13
|
+
* entry ([ref:runtime-gap]). Wiring into the live provider is agent-mcp-refactor's
|
|
14
|
+
* job (plan 6); this module delivers the emitter standalone.
|
|
15
|
+
*
|
|
16
|
+
* ([def:server-side-tool], [def:unsupported-native], [inv:server-side-shape],
|
|
17
|
+
* [inv:gate-not-noop], RUNTIME_GAPS Gap 1 + Gap 2 + Recommended Handoff #2)
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Thrown when the emitter encounters a provider-native tool that this package
|
|
21
|
+
* does not yet execute (e.g. Anthropic client-executed `bash`, `computer`).
|
|
22
|
+
*
|
|
23
|
+
* The message always names the tool + provider and includes the registered note
|
|
24
|
+
* so callers know exactly what is missing — never a silent no-op.
|
|
25
|
+
* ([inv:gate-not-noop])
|
|
26
|
+
*/
|
|
27
|
+
export class UnsupportedNativeToolError extends Error {
|
|
28
|
+
code = 'UNSUPPORTED_NATIVE_TOOL';
|
|
29
|
+
toolName;
|
|
30
|
+
providerId;
|
|
31
|
+
constructor(toolName, providerId, note) {
|
|
32
|
+
const detail = note
|
|
33
|
+
? note
|
|
34
|
+
: `${toolName} on provider ${providerId} is not supported by @adhd/agent-provider`;
|
|
35
|
+
super(`Tool '${toolName}' on provider '${providerId}' cannot be emitted: ${detail}`);
|
|
36
|
+
this.name = 'UnsupportedNativeToolError';
|
|
37
|
+
this.toolName = toolName;
|
|
38
|
+
this.providerId = providerId;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// ──────────────────────────────────────────────
|
|
42
|
+
// Emitter
|
|
43
|
+
// ──────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* Emit a single tool for the given provider.
|
|
46
|
+
*
|
|
47
|
+
* Branches on `emit_shape` from the tool format lookup:
|
|
48
|
+
* - `custom` (or no registered row) → `EmittedCustomTool`
|
|
49
|
+
* - `server_side` → `EmittedServerSideTool` (no input_schema)
|
|
50
|
+
* - `unsupported` → throws `UnsupportedNativeToolError`
|
|
51
|
+
*
|
|
52
|
+
* @param tool - The canonical ToolDefinition.
|
|
53
|
+
* @param providerId - The provider id (e.g. "anthropic") used to look up the format row.
|
|
54
|
+
* @param lookup - Format lookup, typically `store.getShape.bind(store)`.
|
|
55
|
+
* @throws {UnsupportedNativeToolError} when the tool's emit_shape is "unsupported".
|
|
56
|
+
*/
|
|
57
|
+
export function emitTool(tool, providerId, lookup) {
|
|
58
|
+
const format = lookup(providerId, tool.name);
|
|
59
|
+
const shape = format?.emitShape ?? 'custom';
|
|
60
|
+
switch (shape) {
|
|
61
|
+
case 'server_side': {
|
|
62
|
+
// type_tag must be set for server_side rows ([inv:server-side-shape])
|
|
63
|
+
const typeTag = format?.typeTag;
|
|
64
|
+
if (!typeTag) {
|
|
65
|
+
throw new Error(`Tool format for '${tool.name}' on provider '${providerId}' is server_side but has no type_tag`);
|
|
66
|
+
}
|
|
67
|
+
// Emitted with NO input_schema — server executes it
|
|
68
|
+
return { type: typeTag, name: tool.name };
|
|
69
|
+
}
|
|
70
|
+
case 'unsupported': {
|
|
71
|
+
// Always throw — never silent no-op ([inv:gate-not-noop])
|
|
72
|
+
throw new UnsupportedNativeToolError(tool.name, providerId, format?.note ?? null);
|
|
73
|
+
}
|
|
74
|
+
default: {
|
|
75
|
+
// "custom" or no registered row → standard tool definition shape
|
|
76
|
+
return {
|
|
77
|
+
name: tool.name,
|
|
78
|
+
description: tool.description,
|
|
79
|
+
input_schema: tool.inputSchema,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Emit all tools for the given provider, applying `emitTool` to each.
|
|
86
|
+
*
|
|
87
|
+
* Throws on the first `unsupported` tool encountered so callers get an
|
|
88
|
+
* early, actionable error rather than a partially-built list.
|
|
89
|
+
*
|
|
90
|
+
* @param tools - Array of canonical ToolDefinitions.
|
|
91
|
+
* @param providerId - Provider id used to look up format rows.
|
|
92
|
+
* @param lookup - Format lookup, typically `store.getShape.bind(store)`.
|
|
93
|
+
* @throws {UnsupportedNativeToolError} on the first unsupported tool.
|
|
94
|
+
*/
|
|
95
|
+
export function emitToolsForProvider(tools, providerId, lookup) {
|
|
96
|
+
return tools.map((tool) => emitTool(tool, providerId, lookup));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=emit-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-tools.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/runtime/emit-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH;;;;;;;GAOG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAmC,yBAAyB,CAAC;IACjE,QAAQ,CAAS;IACjB,UAAU,CAAS;IAE5B,YAAY,QAAgB,EAAE,UAAkB,EAAE,IAAmB;QACnE,MAAM,MAAM,GAAG,IAAI;YACjB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,GAAG,QAAQ,gBAAgB,UAAU,2CAA2C,CAAC;QACrF,KAAK,CACH,SAAS,QAAQ,kBAAkB,UAAU,wBAAwB,MAAM,EAAE,CAC9E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AA6CD,iDAAiD;AACjD,UAAU;AACV,iDAAiD;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAoB,EACpB,UAAkB,EAClB,MAAwB;IAExB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAc,MAAM,EAAE,SAAS,IAAI,QAAQ,CAAC;IAEvD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,sEAAsE;YACtE,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,oBAAoB,IAAI,CAAC,IAAI,kBAAkB,UAAU,sCAAsC,CAChG,CAAC;YACJ,CAAC;YACD,oDAAoD;YACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAkC,CAAC;QAC5E,CAAC;QAED,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,0DAA0D;YAC1D,MAAM,IAAI,0BAA0B,CAClC,IAAI,CAAC,IAAI,EACT,UAAU,EACV,MAAM,EAAE,IAAI,IAAI,IAAI,CACrB,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,iEAAiE;YACjE,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY,EAAE,IAAI,CAAC,WAAW;aACH,CAAC;QAChC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAuB,EACvB,UAAkB,EAClB,MAAwB;IAExB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
interface BindingSeedRow {
|
|
3
|
+
modelId: string;
|
|
4
|
+
platform: string;
|
|
5
|
+
platformModelId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const BINDING_ROWS: BindingSeedRow[];
|
|
8
|
+
/**
|
|
9
|
+
* Seed model-platform binding rows.
|
|
10
|
+
*
|
|
11
|
+
* The composite PK is (model_id, platform) — INSERT OR IGNORE ensures a second
|
|
12
|
+
* call is a no-op (idempotency invariant — the negative-control test bites here).
|
|
13
|
+
*/
|
|
14
|
+
export declare function seedBindings(db: BetterSQLite3Database<Record<string, never>>): void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAoBxE,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,YAAY,EAAE,cAAc,EA4CxC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAC/C,IAAI,CAYN"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { modelPlatformBindings } from '../db/schema.js';
|
|
2
|
+
export const BINDING_ROWS = [
|
|
3
|
+
// ── claude_code aliases ───────────────────
|
|
4
|
+
{
|
|
5
|
+
modelId: 'claude_sonnet_4_6',
|
|
6
|
+
platform: 'claude_code',
|
|
7
|
+
platformModelId: 'sonnet',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
modelId: 'claude_opus_4_8',
|
|
11
|
+
platform: 'claude_code',
|
|
12
|
+
platformModelId: 'opus',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
modelId: 'claude_haiku_4_5',
|
|
16
|
+
platform: 'claude_code',
|
|
17
|
+
platformModelId: 'haiku',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
modelId: 'claude_fable_5',
|
|
21
|
+
platform: 'claude_code',
|
|
22
|
+
platformModelId: 'fable',
|
|
23
|
+
},
|
|
24
|
+
// ── claude_api full ids ───────────────────
|
|
25
|
+
{
|
|
26
|
+
modelId: 'claude_sonnet_4_6',
|
|
27
|
+
platform: 'claude_api',
|
|
28
|
+
platformModelId: 'claude-sonnet-4-6',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
modelId: 'claude_opus_4_8',
|
|
32
|
+
platform: 'claude_api',
|
|
33
|
+
platformModelId: 'claude-opus-4-8',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
modelId: 'claude_haiku_4_5',
|
|
37
|
+
platform: 'claude_api',
|
|
38
|
+
platformModelId: 'claude-haiku-4-5-20251001',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
modelId: 'claude_fable_5',
|
|
42
|
+
platform: 'claude_api',
|
|
43
|
+
platformModelId: 'claude-fable-5',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Seed model-platform binding rows.
|
|
48
|
+
*
|
|
49
|
+
* The composite PK is (model_id, platform) — INSERT OR IGNORE ensures a second
|
|
50
|
+
* call is a no-op (idempotency invariant — the negative-control test bites here).
|
|
51
|
+
*/
|
|
52
|
+
export function seedBindings(db) {
|
|
53
|
+
for (const row of BINDING_ROWS) {
|
|
54
|
+
db.insert(modelPlatformBindings)
|
|
55
|
+
.values({
|
|
56
|
+
modelId: row.modelId,
|
|
57
|
+
platform: row.platform,
|
|
58
|
+
platformModelId: row.platformModelId,
|
|
59
|
+
})
|
|
60
|
+
// Idempotency: composite PK (model_id, platform) — ignore on conflict.
|
|
61
|
+
.onConflictDoNothing()
|
|
62
|
+
.run();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/bindings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAwBxD,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,6CAA6C;IAC7C;QACE,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,QAAQ;KAC1B;IACD;QACE,OAAO,EAAE,iBAAiB;QAC1B,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,MAAM;KACxB;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,OAAO;KACzB;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,OAAO;KACzB;IAED,6CAA6C;IAC7C;QACE,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,mBAAmB;KACrC;IACD;QACE,OAAO,EAAE,iBAAiB;QAC1B,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,iBAAiB;KACnC;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,2BAA2B;KAC7C;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,gBAAgB;KAClC;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAgD;IAEhD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC;aAC7B,MAAM,CAAC;YACN,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,eAAe,EAAE,GAAG,CAAC,eAAe;SACrC,CAAC;YACF,uEAAuE;aACtE,mBAAmB,EAAE;aACrB,GAAG,EAAE,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
/**
|
|
3
|
+
* Idempotent seeder for all agent-provider lookup tables.
|
|
4
|
+
*
|
|
5
|
+
* Safe to call on every process start. Subsequent runs after the first are
|
|
6
|
+
* silent no-ops: each insert uses `onConflictDoNothing()` so duplicate rows
|
|
7
|
+
* are never written and counts never change.
|
|
8
|
+
*/
|
|
9
|
+
export declare function seed(db: BetterSQLite3Database<Record<string, never>>): void;
|
|
10
|
+
export { seedProviders, SEEDED_PROVIDER_IDS } from './providers.js';
|
|
11
|
+
export { seedModels, MODEL_ROWS, SEEDED_MODEL_IDS } from './models.js';
|
|
12
|
+
export { seedBindings, BINDING_ROWS } from './bindings.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAiBxE;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAI3E;AAED,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { seedBindings } from './bindings.js';
|
|
2
|
+
import { seedModels } from './models.js';
|
|
3
|
+
import { seedProviders } from './providers.js';
|
|
4
|
+
// ──────────────────────────────────────────────
|
|
5
|
+
// Unified seeder — providers, models, bindings
|
|
6
|
+
//
|
|
7
|
+
// Call seed(db) once to populate all lookup tables. A second call is a no-op
|
|
8
|
+
// (INSERT OR IGNORE on every table) — row counts remain identical, no version
|
|
9
|
+
// drift ([inv:reopen-proves-persistence], [dod.3]).
|
|
10
|
+
//
|
|
11
|
+
// Ordering: providers → models → bindings (logical dependency order, though
|
|
12
|
+
// there are no SQL FKs in the shared-DB topology).
|
|
13
|
+
// ──────────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Idempotent seeder for all agent-provider lookup tables.
|
|
16
|
+
*
|
|
17
|
+
* Safe to call on every process start. Subsequent runs after the first are
|
|
18
|
+
* silent no-ops: each insert uses `onConflictDoNothing()` so duplicate rows
|
|
19
|
+
* are never written and counts never change.
|
|
20
|
+
*/
|
|
21
|
+
export function seed(db) {
|
|
22
|
+
seedProviders(db);
|
|
23
|
+
seedModels(db);
|
|
24
|
+
seedBindings(db);
|
|
25
|
+
}
|
|
26
|
+
export { seedProviders, SEEDED_PROVIDER_IDS } from './providers.js';
|
|
27
|
+
export { seedModels, MODEL_ROWS, SEEDED_MODEL_IDS } from './models.js';
|
|
28
|
+
export { seedBindings, BINDING_ROWS } from './bindings.js';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,iDAAiD;AACjD,+CAA+C;AAC/C,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,4EAA4E;AAC5E,mDAAmD;AACnD,iDAAiD;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,EAAgD;IACnE,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
interface ModelSeedRow {
|
|
3
|
+
id: string;
|
|
4
|
+
contextWindow: number;
|
|
5
|
+
outputLimit: number;
|
|
6
|
+
vision: boolean;
|
|
7
|
+
promptCaching: boolean;
|
|
8
|
+
extendedThinking: boolean;
|
|
9
|
+
pricingTier: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const MODEL_ROWS: ModelSeedRow[];
|
|
12
|
+
/**
|
|
13
|
+
* Seed canonical model rows.
|
|
14
|
+
*
|
|
15
|
+
* Uses INSERT OR IGNORE so a second call is a silent no-op
|
|
16
|
+
* ([inv:reopen-proves-persistence]: counts are identical on second run).
|
|
17
|
+
*/
|
|
18
|
+
export declare function seedModels(db: BetterSQLite3Database<Record<string, never>>): void;
|
|
19
|
+
/** Canonical model ids shipped by this seed module. */
|
|
20
|
+
export declare const SEEDED_MODEL_IDS: string[];
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAUxE,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,EAAE,YAAY,EAqCpC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAC/C,IAAI,CAoBN;AAED,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,UAA8B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { models } from '../db/schema.js';
|
|
2
|
+
export const MODEL_ROWS = [
|
|
3
|
+
{
|
|
4
|
+
id: 'claude_sonnet_4_6',
|
|
5
|
+
contextWindow: 200_000,
|
|
6
|
+
outputLimit: 8_192,
|
|
7
|
+
vision: true,
|
|
8
|
+
promptCaching: true,
|
|
9
|
+
extendedThinking: false,
|
|
10
|
+
pricingTier: 'standard',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'claude_opus_4_8',
|
|
14
|
+
contextWindow: 200_000,
|
|
15
|
+
outputLimit: 32_000,
|
|
16
|
+
vision: true,
|
|
17
|
+
promptCaching: true,
|
|
18
|
+
extendedThinking: true,
|
|
19
|
+
pricingTier: 'premium',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'claude_haiku_4_5',
|
|
23
|
+
contextWindow: 200_000,
|
|
24
|
+
outputLimit: 8_192,
|
|
25
|
+
vision: true,
|
|
26
|
+
promptCaching: true,
|
|
27
|
+
extendedThinking: false,
|
|
28
|
+
pricingTier: 'economy',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'claude_fable_5',
|
|
32
|
+
contextWindow: 200_000,
|
|
33
|
+
outputLimit: 32_000,
|
|
34
|
+
vision: true,
|
|
35
|
+
promptCaching: true,
|
|
36
|
+
extendedThinking: true,
|
|
37
|
+
pricingTier: 'premium',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Seed canonical model rows.
|
|
42
|
+
*
|
|
43
|
+
* Uses INSERT OR IGNORE so a second call is a silent no-op
|
|
44
|
+
* ([inv:reopen-proves-persistence]: counts are identical on second run).
|
|
45
|
+
*/
|
|
46
|
+
export function seedModels(db) {
|
|
47
|
+
const now = new Date().toISOString();
|
|
48
|
+
for (const row of MODEL_ROWS) {
|
|
49
|
+
db.insert(models)
|
|
50
|
+
.values({
|
|
51
|
+
id: row.id,
|
|
52
|
+
contextWindow: row.contextWindow,
|
|
53
|
+
outputLimit: row.outputLimit,
|
|
54
|
+
vision: row.vision,
|
|
55
|
+
promptCaching: row.promptCaching,
|
|
56
|
+
extendedThinking: row.extendedThinking,
|
|
57
|
+
pricingTier: row.pricingTier,
|
|
58
|
+
createdAt: now,
|
|
59
|
+
updatedAt: now,
|
|
60
|
+
})
|
|
61
|
+
// Idempotency: ignore if the PK already exists.
|
|
62
|
+
.onConflictDoNothing()
|
|
63
|
+
.run();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Canonical model ids shipped by this seed module. */
|
|
67
|
+
export const SEEDED_MODEL_IDS = MODEL_ROWS.map((r) => r.id);
|
|
68
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/models.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAkBzC,MAAM,CAAC,MAAM,UAAU,GAAmB;IACxC;QACE,EAAE,EAAE,mBAAmB;QACvB,aAAa,EAAE,OAAO;QACtB,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,KAAK;QACvB,WAAW,EAAE,UAAU;KACxB;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,aAAa,EAAE,OAAO;QACtB,WAAW,EAAE,MAAM;QACnB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,WAAW,EAAE,SAAS;KACvB;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,aAAa,EAAE,OAAO;QACtB,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,KAAK;QACvB,WAAW,EAAE,SAAS;KACvB;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,aAAa,EAAE,OAAO;QACtB,WAAW,EAAE,MAAM;QACnB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,WAAW,EAAE,SAAS;KACvB;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,EAAgD;IAEhD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;aACd,MAAM,CAAC;YACN,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;SACf,CAAC;YACF,gDAAgD;aAC/C,mBAAmB,EAAE;aACrB,GAAG,EAAE,CAAC;IACX,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
/**
|
|
3
|
+
* Seed provider rows.
|
|
4
|
+
*
|
|
5
|
+
* Uses INSERT OR IGNORE so a second call is a silent no-op
|
|
6
|
+
* ([inv:reopen-proves-persistence]: counts are identical on second run).
|
|
7
|
+
*/
|
|
8
|
+
export declare function seedProviders(db: BetterSQLite3Database<Record<string, never>>): void;
|
|
9
|
+
/** Canonical provider ids shipped by this seed module. */
|
|
10
|
+
export declare const SEEDED_PROVIDER_IDS: string[];
|
|
11
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAwDxE;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAC/C,IAAI,CAkBN;AAED,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,UAAiC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { providers } from '../db/schema.js';
|
|
2
|
+
const PROVIDER_ROWS = [
|
|
3
|
+
{
|
|
4
|
+
id: 'anthropic',
|
|
5
|
+
transport: 'HTTP',
|
|
6
|
+
authPattern: 'bearer',
|
|
7
|
+
baseUrl: 'https://api.anthropic.com',
|
|
8
|
+
endpointTemplate: 'https://api.anthropic.com/v1/messages',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 'openai',
|
|
12
|
+
transport: 'HTTP',
|
|
13
|
+
authPattern: 'bearer',
|
|
14
|
+
baseUrl: 'https://api.openai.com',
|
|
15
|
+
endpointTemplate: 'https://api.openai.com/v1/chat/completions',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'bedrock',
|
|
19
|
+
transport: 'HTTP',
|
|
20
|
+
authPattern: 'aws-sigv4',
|
|
21
|
+
baseUrl: 'https://bedrock-runtime.{region}.amazonaws.com',
|
|
22
|
+
endpointTemplate: 'https://bedrock-runtime.{region}.amazonaws.com/model/{model}/converse-stream',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'lmstudio',
|
|
26
|
+
transport: 'HTTP',
|
|
27
|
+
authPattern: 'none',
|
|
28
|
+
baseUrl: 'http://localhost:1234',
|
|
29
|
+
endpointTemplate: 'http://localhost:1234/v1/chat/completions',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'claudecli',
|
|
33
|
+
transport: 'stdio',
|
|
34
|
+
authPattern: 'none',
|
|
35
|
+
baseUrl: null,
|
|
36
|
+
endpointTemplate: null,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Seed provider rows.
|
|
41
|
+
*
|
|
42
|
+
* Uses INSERT OR IGNORE so a second call is a silent no-op
|
|
43
|
+
* ([inv:reopen-proves-persistence]: counts are identical on second run).
|
|
44
|
+
*/
|
|
45
|
+
export function seedProviders(db) {
|
|
46
|
+
const now = new Date().toISOString();
|
|
47
|
+
for (const row of PROVIDER_ROWS) {
|
|
48
|
+
db.insert(providers)
|
|
49
|
+
.values({
|
|
50
|
+
id: row.id,
|
|
51
|
+
transport: row.transport,
|
|
52
|
+
authPattern: row.authPattern,
|
|
53
|
+
baseUrl: row.baseUrl,
|
|
54
|
+
endpointTemplate: row.endpointTemplate,
|
|
55
|
+
createdAt: now,
|
|
56
|
+
updatedAt: now,
|
|
57
|
+
})
|
|
58
|
+
// Idempotency: ignore if the PK already exists.
|
|
59
|
+
.onConflictDoNothing()
|
|
60
|
+
.run();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Canonical provider ids shipped by this seed module. */
|
|
64
|
+
export const SEEDED_PROVIDER_IDS = PROVIDER_ROWS.map((r) => r.id);
|
|
65
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/seed/providers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,MAAM,aAAa,GAAsB;IACvC;QACE,EAAE,EAAE,WAAW;QACf,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,2BAA2B;QACpC,gBAAgB,EAAE,uCAAuC;KAC1D;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,wBAAwB;QACjC,gBAAgB,EAAE,4CAA4C;KAC/D;IACD;QACE,EAAE,EAAE,SAAS;QACb,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,gDAAgD;QACzD,gBAAgB,EACd,8EAA8E;KACjF;IACD;QACE,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,uBAAuB;QAChC,gBAAgB,EAAE,2CAA2C;KAC9D;IACD;QACE,EAAE,EAAE,WAAW;QACf,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,IAAI;KACvB;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,EAAgD;IAEhD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;aACjB,MAAM,CAAC;YACN,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;SACf,CAAC;YACF,gDAAgD;aAC/C,mBAAmB,EAAE;aACrB,GAAG,EAAE,CAAC;IACX,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
export interface Model {
|
|
3
|
+
id: string;
|
|
4
|
+
contextWindow: number;
|
|
5
|
+
outputLimit: number;
|
|
6
|
+
vision: boolean;
|
|
7
|
+
promptCaching: boolean;
|
|
8
|
+
extendedThinking: boolean;
|
|
9
|
+
pricingTier: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ModelCreateInput {
|
|
14
|
+
id: string;
|
|
15
|
+
contextWindow: number;
|
|
16
|
+
outputLimit: number;
|
|
17
|
+
vision?: boolean;
|
|
18
|
+
promptCaching?: boolean;
|
|
19
|
+
extendedThinking?: boolean;
|
|
20
|
+
pricingTier: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ModelPlatformBinding {
|
|
23
|
+
modelId: string;
|
|
24
|
+
platform: string;
|
|
25
|
+
platformModelId: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ModelPlatformBindingCreateInput {
|
|
28
|
+
modelId: string;
|
|
29
|
+
platform: string;
|
|
30
|
+
platformModelId: string;
|
|
31
|
+
}
|
|
32
|
+
export type ModelErrorCode = 'MODEL_ALREADY_EXISTS' | 'MODEL_NOT_FOUND' | 'MODEL_BINDING_NOT_FOUND';
|
|
33
|
+
export declare class ModelStoreError extends Error {
|
|
34
|
+
readonly code: ModelErrorCode;
|
|
35
|
+
constructor(code: ModelErrorCode, message: string);
|
|
36
|
+
}
|
|
37
|
+
export declare class ModelStore {
|
|
38
|
+
private readonly db;
|
|
39
|
+
constructor(db: BetterSQLite3Database<Record<string, never>>);
|
|
40
|
+
/**
|
|
41
|
+
* Insert a new model row.
|
|
42
|
+
* Throws MODEL_ALREADY_EXISTS if the id is taken.
|
|
43
|
+
*/
|
|
44
|
+
create(input: ModelCreateInput): Model;
|
|
45
|
+
/**
|
|
46
|
+
* Read a model by id.
|
|
47
|
+
* Throws MODEL_NOT_FOUND if missing.
|
|
48
|
+
*/
|
|
49
|
+
read(id: string): Model;
|
|
50
|
+
/** Return all model rows. */
|
|
51
|
+
list(): Model[];
|
|
52
|
+
private _rowToModel;
|
|
53
|
+
/**
|
|
54
|
+
* Insert a model-platform binding row.
|
|
55
|
+
* model_id is a logical key (no SQL FK — seeding order flexibility).
|
|
56
|
+
*/
|
|
57
|
+
createBinding(input: ModelPlatformBindingCreateInput): ModelPlatformBinding;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a canonical model id + platform to the provider-specific string.
|
|
60
|
+
*
|
|
61
|
+
* The `WHERE platform = ?` clause is the single gating filter that makes the
|
|
62
|
+
* negative-control test bite: removing it collapses both platforms to the
|
|
63
|
+
* first binding row — keep the filter here and nowhere else.
|
|
64
|
+
*
|
|
65
|
+
* Throws MODEL_BINDING_NOT_FOUND if no row exists for (canonicalId, platform).
|
|
66
|
+
*/
|
|
67
|
+
resolveModelId(canonicalId: string, platform: string): string;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=model-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-core-provider/src/store/model-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQxE,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAMD,MAAM,MAAM,cAAc,GACtB,sBAAsB,GACtB,iBAAiB,GACjB,yBAAyB,CAAC;AAE9B,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;CAKlD;AAUD,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAGnE;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK;IAkCtC;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK;IAUvB,6BAA6B;IAC7B,IAAI,IAAI,KAAK,EAAE;IAQf,OAAO,CAAC,WAAW;IAoBnB;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,+BAA+B,GAAG,oBAAoB;IAiB3E;;;;;;;;OAQG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAqB9D"}
|