@promptev/context-engine 0.0.1 → 0.0.2
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/README.md +23 -0
- package/dist/cli.js +142 -58
- package/dist/cli.js.map +1 -1
- package/dist/{config-CdlSkKgV.d.ts → config-BODDdXJ7.d.ts} +33 -11
- package/dist/{config-CNnASw5X.d.cts → config-C5RZ00W6.d.cts} +33 -11
- package/dist/express.d.cts +3 -3
- package/dist/express.d.ts +3 -3
- package/dist/fastify.d.cts +3 -3
- package/dist/fastify.d.ts +3 -3
- package/dist/{governance-XFVgtEdV.d.ts → governance-BLPK7NMe.d.ts} +1 -1
- package/dist/{governance-D8g6Wyvb.d.cts → governance-P9pRb4Ol.d.cts} +1 -1
- package/dist/graph/index.cjs +51 -18
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +2 -2
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +51 -18
- package/dist/graph/index.js.map +1 -1
- package/dist/hono.d.cts +3 -3
- package/dist/hono.d.ts +3 -3
- package/dist/index.cjs +142 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -7
- package/dist/index.d.ts +62 -7
- package/dist/index.js +142 -58
- package/dist/index.js.map +1 -1
- package/dist/{router-Dsv3fv0R.d.cts → router-CiFwC-EN.d.cts} +1 -1
- package/dist/{router-B_DTkQgU.d.ts → router-D8gBzwLd.d.ts} +1 -1
- package/dist/skills/context-engine/SKILL.md +5 -1
- package/dist/{storage-DU1JRno5.d.cts → storage-CJrKgJeJ.d.ts} +5 -2
- package/dist/{storage-Dvt2ZxsV.d.ts → storage-Dvpq2xAC.d.cts} +5 -2
- package/package.json +1 -1
- package/src/skills/context-engine/SKILL.md +5 -1
package/dist/hono.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h as handleIngestJson, c as createToolsHandlers } from './router-
|
|
2
|
-
import './governance-
|
|
1
|
+
import { h as handleIngestJson, c as createToolsHandlers } from './router-CiFwC-EN.cjs';
|
|
2
|
+
import './governance-P9pRb4Ol.cjs';
|
|
3
3
|
import 'pg';
|
|
4
|
-
import './config-
|
|
4
|
+
import './config-C5RZ00W6.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import './redaction-BqD_DEUQ.cjs';
|
|
7
7
|
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h as handleIngestJson, c as createToolsHandlers } from './router-
|
|
2
|
-
import './governance-
|
|
1
|
+
import { h as handleIngestJson, c as createToolsHandlers } from './router-D8gBzwLd.js';
|
|
2
|
+
import './governance-BLPK7NMe.js';
|
|
3
3
|
import 'pg';
|
|
4
|
-
import './config-
|
|
4
|
+
import './config-BODDdXJ7.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import './redaction-BqD_DEUQ.js';
|
|
7
7
|
|
package/dist/index.cjs
CHANGED
|
@@ -814,6 +814,47 @@ var init_hooks = __esm({
|
|
|
814
814
|
}
|
|
815
815
|
});
|
|
816
816
|
|
|
817
|
+
// src/providers/google.ts
|
|
818
|
+
async function buildGenaiClient(cfg2, timeoutMs, purpose) {
|
|
819
|
+
const specifier = "@google/genai";
|
|
820
|
+
let mod;
|
|
821
|
+
try {
|
|
822
|
+
mod = await import(specifier);
|
|
823
|
+
} catch {
|
|
824
|
+
throw new exports.ExtraMissingError("gemini", specifier, purpose);
|
|
825
|
+
}
|
|
826
|
+
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
827
|
+
if (!Ctor) {
|
|
828
|
+
throw new exports.ExtraMissingError("gemini", specifier, purpose);
|
|
829
|
+
}
|
|
830
|
+
const opts = { httpOptions: { timeout: timeoutMs } };
|
|
831
|
+
if (cfg2.provider === "vertex_ai") {
|
|
832
|
+
opts.vertexai = true;
|
|
833
|
+
if (cfg2.project || cfg2.location) {
|
|
834
|
+
if (cfg2.project) opts.project = cfg2.project;
|
|
835
|
+
if (cfg2.location) opts.location = cfg2.location;
|
|
836
|
+
} else if (cfg2.apiKey) {
|
|
837
|
+
opts.apiKey = cfg2.apiKey;
|
|
838
|
+
}
|
|
839
|
+
} else {
|
|
840
|
+
opts.apiKey = cfg2.apiKey ?? null;
|
|
841
|
+
}
|
|
842
|
+
try {
|
|
843
|
+
return new Ctor(opts);
|
|
844
|
+
} catch (err) {
|
|
845
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
846
|
+
if (!message.includes("Authentication is not set up")) throw err;
|
|
847
|
+
throw new Error(
|
|
848
|
+
`${message} Set \`project\` on the provider config, or export GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION. Credentials themselves come from Application Default Credentials.`
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
var init_google = __esm({
|
|
853
|
+
"src/providers/google.ts"() {
|
|
854
|
+
init_errors();
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
|
|
817
858
|
// src/providers/llm.ts
|
|
818
859
|
var llm_exports = {};
|
|
819
860
|
__export(llm_exports, {
|
|
@@ -849,20 +890,6 @@ function buildOpenAIChatClient(cfg2) {
|
|
|
849
890
|
maxRetries: 0
|
|
850
891
|
});
|
|
851
892
|
}
|
|
852
|
-
async function loadGeminiChatClient(apiKey) {
|
|
853
|
-
const specifier = "@google/genai";
|
|
854
|
-
let mod;
|
|
855
|
-
try {
|
|
856
|
-
mod = await import(specifier);
|
|
857
|
-
} catch {
|
|
858
|
-
throw new exports.ExtraMissingError("gemini", specifier, "gemini llm");
|
|
859
|
-
}
|
|
860
|
-
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
861
|
-
if (!Ctor) {
|
|
862
|
-
throw new exports.ExtraMissingError("gemini", specifier, "gemini llm");
|
|
863
|
-
}
|
|
864
|
-
return new Ctor({ apiKey: apiKey ?? null, httpOptions: { timeout: GEMINI_CALL_TIMEOUT_MS } });
|
|
865
|
-
}
|
|
866
893
|
async function loadBedrockSdk() {
|
|
867
894
|
const specifier = "@aws-sdk/client-bedrock-runtime";
|
|
868
895
|
try {
|
|
@@ -881,7 +908,7 @@ function buildLlmClient(cfg2, opts) {
|
|
|
881
908
|
if (OPENAI_FAMILY.has(cfg2.provider)) {
|
|
882
909
|
return new exports.LLMClient(cfg2, { client: buildOpenAIChatClient(cfg2) });
|
|
883
910
|
}
|
|
884
|
-
if (cfg2.provider
|
|
911
|
+
if (GOOGLE_FAMILY.has(cfg2.provider) || cfg2.provider === "bedrock") {
|
|
885
912
|
return new exports.LLMClient(cfg2);
|
|
886
913
|
}
|
|
887
914
|
throw new Error(`unknown llm provider: ${JSON.stringify(cfg2.provider)}`);
|
|
@@ -898,16 +925,18 @@ async function callLlm(cfg2, opts) {
|
|
|
898
925
|
await owned.aclose();
|
|
899
926
|
}
|
|
900
927
|
}
|
|
901
|
-
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY; exports.LLMClient = void 0;
|
|
928
|
+
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY, GOOGLE_FAMILY; exports.LLMClient = void 0;
|
|
902
929
|
var init_llm = __esm({
|
|
903
930
|
"src/providers/llm.ts"() {
|
|
904
931
|
init_errors();
|
|
932
|
+
init_google();
|
|
905
933
|
CALL_TIMEOUT_MS = 24e4;
|
|
906
934
|
TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
907
935
|
GEMINI_CALL_TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
908
936
|
ANTHROPIC_VERSION = "2023-06-01";
|
|
909
937
|
ANTHROPIC_MAX_TOKENS = 4096;
|
|
910
938
|
OPENAI_FAMILY = /* @__PURE__ */ new Set(["openai", "azure_openai", "custom"]);
|
|
939
|
+
GOOGLE_FAMILY = /* @__PURE__ */ new Set(["gemini", "vertex_ai"]);
|
|
911
940
|
exports.LLMClient = class {
|
|
912
941
|
cfg;
|
|
913
942
|
provider;
|
|
@@ -947,7 +976,7 @@ var init_llm = __esm({
|
|
|
947
976
|
if (OPENAI_FAMILY.has(this.provider)) {
|
|
948
977
|
return this.callOpenAI(system, user, jsonMode, images, maxTokens, temperature);
|
|
949
978
|
}
|
|
950
|
-
if (this.provider
|
|
979
|
+
if (GOOGLE_FAMILY.has(this.provider)) {
|
|
951
980
|
return this.callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget, temperature);
|
|
952
981
|
}
|
|
953
982
|
if (this.provider === "bedrock") {
|
|
@@ -1030,7 +1059,11 @@ Respond with valid JSON only.`;
|
|
|
1030
1059
|
}
|
|
1031
1060
|
async callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget = null, temperature = null) {
|
|
1032
1061
|
if (!this.genaiClient) {
|
|
1033
|
-
this.genaiClient = await
|
|
1062
|
+
this.genaiClient = await buildGenaiClient(
|
|
1063
|
+
this.cfg,
|
|
1064
|
+
GEMINI_CALL_TIMEOUT_MS,
|
|
1065
|
+
"gemini llm"
|
|
1066
|
+
);
|
|
1034
1067
|
}
|
|
1035
1068
|
const parts = [];
|
|
1036
1069
|
for (const img of images ?? []) {
|
|
@@ -1909,17 +1942,30 @@ var init_config = __esm({
|
|
|
1909
1942
|
"src/config.ts"() {
|
|
1910
1943
|
init_redaction();
|
|
1911
1944
|
embeddingSchema = zod.z.object({
|
|
1912
|
-
provider: zod.z.enum(["openai", "azure_openai", "gemini", "voyage", "cohere", "custom"]),
|
|
1945
|
+
provider: zod.z.enum(["openai", "azure_openai", "gemini", "vertex_ai", "voyage", "cohere", "custom"]),
|
|
1913
1946
|
model: zod.z.string(),
|
|
1914
1947
|
dim: zod.z.number().int().positive().nullable().optional().default(null),
|
|
1915
1948
|
apiKey: zod.z.string().nullable().optional().default(null),
|
|
1916
|
-
baseUrl: zod.z.string().nullable().optional().default(null)
|
|
1949
|
+
baseUrl: zod.z.string().nullable().optional().default(null),
|
|
1950
|
+
// `vertex_ai` only. Left optional on purpose: the Google SDK resolves both
|
|
1951
|
+
// from GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION, which is how a GCP
|
|
1952
|
+
// deployment is already wired, and requiring them here would break it.
|
|
1953
|
+
//
|
|
1954
|
+
// No `.default(null)`, unlike the fields above — these types come from
|
|
1955
|
+
// `z.infer`, so a default would make them REQUIRED on the output type and
|
|
1956
|
+
// break every hand-written `EmbeddingConfig` literal already compiled
|
|
1957
|
+
// against 0.0.1. Optional keeps the addition additive.
|
|
1958
|
+
project: zod.z.string().nullable().optional(),
|
|
1959
|
+
location: zod.z.string().nullable().optional()
|
|
1917
1960
|
});
|
|
1918
1961
|
llmSchema = zod.z.object({
|
|
1919
|
-
provider: zod.z.enum(["anthropic", "openai", "azure_openai", "gemini", "bedrock", "custom"]),
|
|
1962
|
+
provider: zod.z.enum(["anthropic", "openai", "azure_openai", "gemini", "vertex_ai", "bedrock", "custom"]),
|
|
1920
1963
|
model: zod.z.string(),
|
|
1921
1964
|
apiKey: zod.z.string().nullable().optional().default(null),
|
|
1922
|
-
baseUrl: zod.z.string().nullable().optional().default(null)
|
|
1965
|
+
baseUrl: zod.z.string().nullable().optional().default(null),
|
|
1966
|
+
// `vertex_ai` only — see the note on embeddingSchema.
|
|
1967
|
+
project: zod.z.string().nullable().optional(),
|
|
1968
|
+
location: zod.z.string().nullable().optional()
|
|
1923
1969
|
});
|
|
1924
1970
|
graphSchema = zod.z.object({
|
|
1925
1971
|
enabled: zod.z.boolean().default(false),
|
|
@@ -7578,20 +7624,8 @@ function parseSpreadsheetText(dfd, text) {
|
|
|
7578
7624
|
return out;
|
|
7579
7625
|
}
|
|
7580
7626
|
async function compute(instruction, opts) {
|
|
7581
|
-
|
|
7582
|
-
throw new exports.EngineActionError(
|
|
7583
|
-
"compute() executes generated code and is disabled by default; set enableCodeExecution=true only in a deployment with out-of-process/container isolation."
|
|
7584
|
-
);
|
|
7585
|
-
}
|
|
7586
|
-
const llmCfg = opts.modelCfg ?? opts.config.llm;
|
|
7587
|
-
if (llmCfg == null) {
|
|
7588
|
-
throw new Error("compute() requires an LLM: pass modelCfg= or configure ContextEngineConfig.llm");
|
|
7589
|
-
}
|
|
7590
|
-
if (!instruction?.trim()) {
|
|
7591
|
-
throw new exports.EngineActionError("instruction must not be empty");
|
|
7592
|
-
}
|
|
7627
|
+
checkComputePreconditions(opts.config, opts.modelCfg, instruction);
|
|
7593
7628
|
const dfd = await requireDanfo();
|
|
7594
|
-
const timeout = Math.max(1, Math.min(Math.trunc(opts.timeout || DEFAULT_COMPUTE_TIMEOUT), 300));
|
|
7595
7629
|
const principals = opts.principals ?? null;
|
|
7596
7630
|
const params = [];
|
|
7597
7631
|
let where = scopeSql(opts.sourceIds ?? null, principals, params);
|
|
@@ -7661,6 +7695,69 @@ async function compute(instruction, opts) {
|
|
|
7661
7695
|
if (!Object.keys(dfs).length) {
|
|
7662
7696
|
throw new exports.EngineActionError("in-scope documents did not parse into any usable dataframe");
|
|
7663
7697
|
}
|
|
7698
|
+
return computeOverFrames(dfs, instruction, {
|
|
7699
|
+
config: opts.config,
|
|
7700
|
+
modelCfg: opts.modelCfg,
|
|
7701
|
+
timeout: opts.timeout,
|
|
7702
|
+
hooks: opts.hooks,
|
|
7703
|
+
principals,
|
|
7704
|
+
documents
|
|
7705
|
+
});
|
|
7706
|
+
}
|
|
7707
|
+
function checkComputePreconditions(config, modelCfg, instruction) {
|
|
7708
|
+
if (!config.enableCodeExecution) {
|
|
7709
|
+
throw new exports.EngineActionError(
|
|
7710
|
+
"compute() executes generated code and is disabled by default; set enableCodeExecution=true only in a deployment with out-of-process/container isolation."
|
|
7711
|
+
);
|
|
7712
|
+
}
|
|
7713
|
+
const llmCfg = modelCfg ?? config.llm;
|
|
7714
|
+
if (llmCfg == null) {
|
|
7715
|
+
throw new Error("compute() requires an LLM: pass modelCfg= or configure ContextEngineConfig.llm");
|
|
7716
|
+
}
|
|
7717
|
+
if (!instruction?.trim()) {
|
|
7718
|
+
throw new exports.EngineActionError("instruction must not be empty");
|
|
7719
|
+
}
|
|
7720
|
+
return llmCfg;
|
|
7721
|
+
}
|
|
7722
|
+
function maskFrames(frames, policy, opts) {
|
|
7723
|
+
if (policy == null || policy.isEmpty()) return frames;
|
|
7724
|
+
const mask = (text) => redactValueRecursive(text, policy, opts);
|
|
7725
|
+
const masked = {};
|
|
7726
|
+
for (const [name, rows] of Object.entries(frames)) {
|
|
7727
|
+
const labels = /* @__PURE__ */ new Map();
|
|
7728
|
+
const taken = /* @__PURE__ */ new Set();
|
|
7729
|
+
for (const row of rows) {
|
|
7730
|
+
for (const column of Object.keys(row)) {
|
|
7731
|
+
if (labels.has(column)) continue;
|
|
7732
|
+
const base = mask(column);
|
|
7733
|
+
let label = base;
|
|
7734
|
+
for (let n = 2; taken.has(label); n++) label = `${base}_${n}`;
|
|
7735
|
+
taken.add(label);
|
|
7736
|
+
labels.set(column, label);
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7739
|
+
masked[name] = rows.map(
|
|
7740
|
+
(row) => Object.fromEntries(
|
|
7741
|
+
Object.entries(row).map(([column, value]) => [
|
|
7742
|
+
labels.get(column) ?? column,
|
|
7743
|
+
typeof value === "string" ? mask(value) : value
|
|
7744
|
+
])
|
|
7745
|
+
)
|
|
7746
|
+
);
|
|
7747
|
+
}
|
|
7748
|
+
return masked;
|
|
7749
|
+
}
|
|
7750
|
+
async function computeOverFrames(frames, instruction, opts) {
|
|
7751
|
+
const llmCfg = checkComputePreconditions(opts.config, opts.modelCfg, instruction);
|
|
7752
|
+
if (!frames || !Object.keys(frames).length) {
|
|
7753
|
+
throw new exports.EngineActionError("no tabular data to compute over");
|
|
7754
|
+
}
|
|
7755
|
+
const hooks = opts.hooks ?? {};
|
|
7756
|
+
const principals = opts.principals ?? null;
|
|
7757
|
+
const documents = [...opts.documents ?? []];
|
|
7758
|
+
const timeout = Math.max(1, Math.min(Math.trunc(opts.timeout || DEFAULT_COMPUTE_TIMEOUT), 300));
|
|
7759
|
+
const redactOpts = { principals, secretKey: opts.config.secretKey, hooks };
|
|
7760
|
+
const dfs = maskFrames(frames, opts.config.redaction, redactOpts);
|
|
7664
7761
|
const schemaLines = Object.entries(dfs).map(
|
|
7665
7762
|
([name, table]) => `- ${name}: columns=${JSON.stringify(Object.keys(table[0] ?? {}))}, rows=${table.length}`
|
|
7666
7763
|
);
|
|
@@ -7677,7 +7774,7 @@ ${schemaLines.join("\n")}`;
|
|
|
7677
7774
|
jsonMode: false
|
|
7678
7775
|
});
|
|
7679
7776
|
} catch (exc) {
|
|
7680
|
-
emitError(
|
|
7777
|
+
emitError(hooks, exc, { stage: "compute_codegen", instruction: instruction.slice(0, 200) });
|
|
7681
7778
|
throw exc;
|
|
7682
7779
|
}
|
|
7683
7780
|
const code = stripCodeFences(rawCode);
|
|
@@ -7688,12 +7785,12 @@ ${schemaLines.join("\n")}`;
|
|
|
7688
7785
|
maskedCode = redactValueRecursive(code.slice(0, 500), opts.config.redaction, {
|
|
7689
7786
|
principals,
|
|
7690
7787
|
secretKey: opts.config.secretKey,
|
|
7691
|
-
hooks
|
|
7788
|
+
hooks
|
|
7692
7789
|
});
|
|
7693
7790
|
} catch {
|
|
7694
7791
|
maskedCode = "<redaction failed: code omitted>";
|
|
7695
7792
|
}
|
|
7696
|
-
emitError(
|
|
7793
|
+
emitError(hooks, new Error(execResult.error || "compute execution failed"), {
|
|
7697
7794
|
stage: "compute_exec",
|
|
7698
7795
|
code: maskedCode
|
|
7699
7796
|
});
|
|
@@ -7714,7 +7811,7 @@ ${schemaLines.join("\n")}`;
|
|
|
7714
7811
|
return redactValueRecursive(result, opts.config.redaction, {
|
|
7715
7812
|
principals,
|
|
7716
7813
|
secretKey: opts.config.secretKey,
|
|
7717
|
-
hooks
|
|
7814
|
+
hooks
|
|
7718
7815
|
});
|
|
7719
7816
|
}
|
|
7720
7817
|
|
|
@@ -7829,10 +7926,11 @@ init_errors();
|
|
|
7829
7926
|
init_hooks();
|
|
7830
7927
|
|
|
7831
7928
|
// src/providers/embeddings.ts
|
|
7832
|
-
init_errors();
|
|
7833
7929
|
init_text();
|
|
7930
|
+
init_google();
|
|
7834
7931
|
var TIMEOUT_MS3 = 3e4;
|
|
7835
7932
|
var OPENAI_FAMILY2 = /* @__PURE__ */ new Set(["openai", "azure_openai", "custom"]);
|
|
7933
|
+
var GOOGLE_FAMILY2 = /* @__PURE__ */ new Set(["gemini", "vertex_ai"]);
|
|
7836
7934
|
function estimatedTokens(texts) {
|
|
7837
7935
|
return texts.reduce((n, t) => n + tokenCount(t), 0);
|
|
7838
7936
|
}
|
|
@@ -7904,7 +8002,7 @@ var Embedder = class {
|
|
|
7904
8002
|
/** Provider dispatch. Overridable per-instance (tests stub this). */
|
|
7905
8003
|
async rawEmbed(texts, kind = "document") {
|
|
7906
8004
|
if (OPENAI_FAMILY2.has(this.provider)) return this.embedOpenAI(texts);
|
|
7907
|
-
if (this.provider
|
|
8005
|
+
if (GOOGLE_FAMILY2.has(this.provider)) return this.embedGemini(texts);
|
|
7908
8006
|
if (this.provider === "voyage") return this.embedVoyage(texts, kind);
|
|
7909
8007
|
if (this.provider === "cohere") return this.embedCohere(texts, kind);
|
|
7910
8008
|
throw new Error(`unknown embedding provider: ${JSON.stringify(this.provider)}`);
|
|
@@ -7920,7 +8018,7 @@ var Embedder = class {
|
|
|
7920
8018
|
}
|
|
7921
8019
|
async embedGemini(texts) {
|
|
7922
8020
|
if (!this.genaiClient) {
|
|
7923
|
-
this.genaiClient = await
|
|
8021
|
+
this.genaiClient = await buildGenaiClient(this.cfg, TIMEOUT_MS3, "gemini embeddings");
|
|
7924
8022
|
}
|
|
7925
8023
|
const resp = await this.genaiClient.models.embedContent({
|
|
7926
8024
|
model: this.model,
|
|
@@ -7969,20 +8067,6 @@ var Embedder = class {
|
|
|
7969
8067
|
return this.fetchImpl;
|
|
7970
8068
|
}
|
|
7971
8069
|
};
|
|
7972
|
-
async function loadGeminiEmbedClient(apiKey) {
|
|
7973
|
-
const specifier = "@google/genai";
|
|
7974
|
-
let mod;
|
|
7975
|
-
try {
|
|
7976
|
-
mod = await import(specifier);
|
|
7977
|
-
} catch {
|
|
7978
|
-
throw new exports.ExtraMissingError("gemini", specifier, "gemini embeddings");
|
|
7979
|
-
}
|
|
7980
|
-
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
7981
|
-
if (!Ctor) {
|
|
7982
|
-
throw new exports.ExtraMissingError("gemini", specifier, "gemini embeddings");
|
|
7983
|
-
}
|
|
7984
|
-
return new Ctor({ apiKey: apiKey ?? null, httpOptions: { timeout: TIMEOUT_MS3 } });
|
|
7985
|
-
}
|
|
7986
8070
|
function buildEmbedder(cfg2, opts) {
|
|
7987
8071
|
if (opts?.client || opts?.fetch || opts?.fetchImpl) {
|
|
7988
8072
|
return new Embedder(cfg2, opts);
|
|
@@ -7993,7 +8077,7 @@ function buildEmbedder(cfg2, opts) {
|
|
|
7993
8077
|
if (cfg2.provider === "voyage" || cfg2.provider === "cohere") {
|
|
7994
8078
|
return new Embedder(cfg2, { fetch: globalThis.fetch });
|
|
7995
8079
|
}
|
|
7996
|
-
if (cfg2.provider
|
|
8080
|
+
if (GOOGLE_FAMILY2.has(cfg2.provider)) {
|
|
7997
8081
|
return new Embedder(cfg2);
|
|
7998
8082
|
}
|
|
7999
8083
|
throw new Error(`unknown embedding provider: ${JSON.stringify(cfg2.provider)}`);
|
|
@@ -12976,6 +13060,7 @@ exports.buildEmbedder = buildEmbedder;
|
|
|
12976
13060
|
exports.buildLlmClient = buildLlmClient;
|
|
12977
13061
|
exports.callLlm = callLlm;
|
|
12978
13062
|
exports.compute = compute;
|
|
13063
|
+
exports.computeOverFrames = computeOverFrames;
|
|
12979
13064
|
exports.configSchema = configSchema;
|
|
12980
13065
|
exports.createMcpApp = createMcpApp;
|
|
12981
13066
|
exports.decryptDict = decryptDict;
|