veryfront 0.1.200 → 0.1.202
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/esm/cli/commands/knowledge/command.d.ts +13 -0
- package/esm/cli/commands/knowledge/command.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/command.js +52 -19
- package/esm/deno.js +1 -1
- package/esm/src/agent/runtime/default-provider-options.d.ts +11 -0
- package/esm/src/agent/runtime/default-provider-options.d.ts.map +1 -0
- package/esm/src/agent/runtime/default-provider-options.js +45 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +2 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/cli/commands/knowledge/command.ts +77 -21
- package/src/deno.js +1 -1
- package/src/src/agent/runtime/default-provider-options.ts +52 -0
- package/src/src/agent/runtime/index.ts +5 -1
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -6,6 +6,7 @@ type SafeParseResult<T> = {
|
|
|
6
6
|
success: false;
|
|
7
7
|
error: z.ZodError;
|
|
8
8
|
};
|
|
9
|
+
import { type CommandResult } from "../../../src/platform/compat/process.js";
|
|
9
10
|
import { type ApiClient } from "../../shared/config.js";
|
|
10
11
|
import type { ParsedArgs } from "../../shared/types.js";
|
|
11
12
|
import { type Logger } from "../../../src/utils/index.js";
|
|
@@ -89,6 +90,18 @@ export declare function runKnowledgeParser(input: {
|
|
|
89
90
|
sourceReference?: string;
|
|
90
91
|
env?: Record<string, string>;
|
|
91
92
|
}): Promise<KnowledgeParserResult>;
|
|
93
|
+
export declare function executeKnowledgeParserCommand(input: {
|
|
94
|
+
scriptPath: string;
|
|
95
|
+
inputJsonPath: string;
|
|
96
|
+
outputJsonPath: string;
|
|
97
|
+
env?: Record<string, string>;
|
|
98
|
+
}, deps?: {
|
|
99
|
+
runCommandFn?: (cmd: string, options: {
|
|
100
|
+
args: string[];
|
|
101
|
+
env?: Record<string, string>;
|
|
102
|
+
capture: true;
|
|
103
|
+
}) => Promise<CommandResult>;
|
|
104
|
+
}): Promise<void>;
|
|
92
105
|
export declare function runKnowledgeParsers(input: {
|
|
93
106
|
files: KnowledgeParserInput[];
|
|
94
107
|
outputDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAA;CAAE,CAAC;AAG7F,OAAO,EAAE,KAAK,aAAa,EAAc,MAAM,yCAAyC,CAAC;AAGzF,OAAO,EAAE,KAAK,SAAS,EAA0C,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKxD,OAAO,EAAuB,KAAK,MAAM,EAAgB,MAAM,6BAA6B,CAAC;AAG7F,OAAO,EAEL,KAAK,+BAA+B,EAEpC,KAAK,yBAAyB,EAC9B,KAAK,gCAAgC,EACtC,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,qBAAqB;IACpC,OA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AE,eAAe,EAAE,EAC1B,OAAO,EAAE,sBAAsB,EAC/B,IAAI,EAAE;IACJ,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,kBAAkB,CAAC;IACrC,mBAAmB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1F,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GACA,OAAO,CAAC;IACT,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,MAAM,EAAE,+BAA+B,EAAE,CAAC;CAC3C,CAAC,CAsGD;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwItE"}
|
|
@@ -2,6 +2,7 @@ import * as dntShim from "../../../_dnt.shims.js";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createFileSystem, getEnv } from "../../../src/platform/index.js";
|
|
4
4
|
import { basename, extname, join, normalize, relative } from "../../../src/platform/compat/path/index.js";
|
|
5
|
+
import { runCommand } from "../../../src/platform/compat/process.js";
|
|
5
6
|
import { withSpan } from "../../../src/observability/tracing/otlp-setup.js";
|
|
6
7
|
import { cliLogger } from "../../utils/index.js";
|
|
7
8
|
import { createApiClient, resolveConfigWithAuth } from "../../shared/config.js";
|
|
@@ -356,6 +357,51 @@ export async function runKnowledgeParser(input) {
|
|
|
356
357
|
}
|
|
357
358
|
return result;
|
|
358
359
|
}
|
|
360
|
+
function isMissingPythonExecutableError(error) {
|
|
361
|
+
if (!(error instanceof Error)) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
const errorWithCode = error;
|
|
365
|
+
if (errorWithCode.code === "ENOENT") {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
return error.name === "NotFound" ||
|
|
369
|
+
/\bENOENT\b/i.test(error.message) ||
|
|
370
|
+
/not found/i.test(error.message) ||
|
|
371
|
+
/no such file or directory/i.test(error.message);
|
|
372
|
+
}
|
|
373
|
+
export async function executeKnowledgeParserCommand(input, deps = {}) {
|
|
374
|
+
const runCommandFn = deps.runCommandFn ?? runCommand;
|
|
375
|
+
let result;
|
|
376
|
+
try {
|
|
377
|
+
result = await runCommandFn("python3", {
|
|
378
|
+
args: [
|
|
379
|
+
input.scriptPath,
|
|
380
|
+
"--input-json",
|
|
381
|
+
input.inputJsonPath,
|
|
382
|
+
"--output-json",
|
|
383
|
+
input.outputJsonPath,
|
|
384
|
+
],
|
|
385
|
+
...(input.env ? { env: input.env } : {}),
|
|
386
|
+
capture: true,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
if (isMissingPythonExecutableError(error)) {
|
|
391
|
+
throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
|
|
392
|
+
}
|
|
393
|
+
throw error;
|
|
394
|
+
}
|
|
395
|
+
if (result.success) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const stderr = result.stderr?.trim();
|
|
399
|
+
const stdout = result.stdout?.trim();
|
|
400
|
+
if (result.code === 1 && !stderr && !stdout) {
|
|
401
|
+
throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
|
|
402
|
+
}
|
|
403
|
+
throw new Error(stderr || stdout || "parser exited unsuccessfully");
|
|
404
|
+
}
|
|
359
405
|
export async function runKnowledgeParsers(input) {
|
|
360
406
|
if (!input.files.length) {
|
|
361
407
|
return [];
|
|
@@ -376,25 +422,12 @@ export async function runKnowledgeParsers(input) {
|
|
|
376
422
|
output_dir: input.outputDir,
|
|
377
423
|
}));
|
|
378
424
|
await dntShim.Deno.writeTextFile(scriptPath, knowledgeIngestPythonSource);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
stderr: "piped",
|
|
386
|
-
}).output();
|
|
387
|
-
}
|
|
388
|
-
catch (error) {
|
|
389
|
-
if (error instanceof dntShim.Deno.errors.NotFound) {
|
|
390
|
-
throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
|
|
391
|
-
}
|
|
392
|
-
throw error;
|
|
393
|
-
}
|
|
394
|
-
if (result.code !== 0) {
|
|
395
|
-
const stderr = new TextDecoder().decode(result.stderr).trim();
|
|
396
|
-
throw new Error(stderr || "parser exited unsuccessfully");
|
|
397
|
-
}
|
|
425
|
+
await executeKnowledgeParserCommand({
|
|
426
|
+
scriptPath,
|
|
427
|
+
inputJsonPath,
|
|
428
|
+
outputJsonPath,
|
|
429
|
+
env: input.env,
|
|
430
|
+
});
|
|
398
431
|
const raw = await dntShim.Deno.readTextFile(outputJsonPath);
|
|
399
432
|
const parsed = JSON.parse(raw);
|
|
400
433
|
return Array.isArray(parsed) ? parsed : [parsed];
|
package/esm/deno.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-default `providerOptions` for known providers.
|
|
3
|
+
*
|
|
4
|
+
* Currently: enable Anthropic extended thinking by default for any
|
|
5
|
+
* Anthropic model, since the `reasoning-*` event surface in this framework
|
|
6
|
+
* relies on the provider-side feature being on. Apps can override or opt
|
|
7
|
+
* out by returning their own `providerOptions.anthropic.thinking` from
|
|
8
|
+
* `AgentConfig.resolveModelTransport`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveProviderOptionsWithDefaults(modelString: string, existing: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
11
|
+
//# sourceMappingURL=default-provider-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-provider-options.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/default-provider-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAoBrC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-default `providerOptions` for known providers.
|
|
3
|
+
*
|
|
4
|
+
* Currently: enable Anthropic extended thinking by default for any
|
|
5
|
+
* Anthropic model, since the `reasoning-*` event surface in this framework
|
|
6
|
+
* relies on the provider-side feature being on. Apps can override or opt
|
|
7
|
+
* out by returning their own `providerOptions.anthropic.thinking` from
|
|
8
|
+
* `AgentConfig.resolveModelTransport`.
|
|
9
|
+
*/
|
|
10
|
+
const VERYFRONT_CLOUD_PREFIX = "veryfront-cloud/";
|
|
11
|
+
const ANTHROPIC_PREFIX = "anthropic/";
|
|
12
|
+
const DEFAULT_ANTHROPIC_THINKING_BUDGET_TOKENS = 2048;
|
|
13
|
+
function isAnthropicModel(modelString) {
|
|
14
|
+
const normalized = modelString.startsWith(VERYFRONT_CLOUD_PREFIX)
|
|
15
|
+
? modelString.slice(VERYFRONT_CLOUD_PREFIX.length)
|
|
16
|
+
: modelString;
|
|
17
|
+
return normalized.startsWith(ANTHROPIC_PREFIX);
|
|
18
|
+
}
|
|
19
|
+
function hasAnthropicThinkingConfig(existing) {
|
|
20
|
+
if (!existing || typeof existing !== "object")
|
|
21
|
+
return false;
|
|
22
|
+
const anthropic = existing.anthropic;
|
|
23
|
+
if (!anthropic || typeof anthropic !== "object")
|
|
24
|
+
return false;
|
|
25
|
+
return "thinking" in anthropic;
|
|
26
|
+
}
|
|
27
|
+
export function resolveProviderOptionsWithDefaults(modelString, existing) {
|
|
28
|
+
if (!isAnthropicModel(modelString)) {
|
|
29
|
+
return existing;
|
|
30
|
+
}
|
|
31
|
+
if (hasAnthropicThinkingConfig(existing)) {
|
|
32
|
+
return existing;
|
|
33
|
+
}
|
|
34
|
+
const existingAnthropic = (existing?.anthropic ?? {});
|
|
35
|
+
return {
|
|
36
|
+
...(existing ?? {}),
|
|
37
|
+
anthropic: {
|
|
38
|
+
// Defaults first; host-supplied fields (e.g. temperature) override them.
|
|
39
|
+
// Only `thinking` is forced because we already confirmed it isn't set.
|
|
40
|
+
temperature: 1,
|
|
41
|
+
...existingAnthropic,
|
|
42
|
+
thinking: { type: "enabled", budget_tokens: DEFAULT_ANTHROPIC_THINKING_BUDGET_TOKENS },
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EAGZ,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EAGZ,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAU/D,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EAC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7B;;OAEG;YACW,mBAAmB;IAOjC;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC;IAI5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAIF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
|
@@ -19,6 +19,7 @@ import { serverLogger } from "../../utils/index.js";
|
|
|
19
19
|
import { addSpanEvent, setSpanAttributes, withSpan, } from "../../observability/tracing/index.js";
|
|
20
20
|
import { convertToModelMessages } from "./model-message-converter.js";
|
|
21
21
|
import { convertToolsToRuntimeTools } from "./model-tool-converter.js";
|
|
22
|
+
import { resolveProviderOptionsWithDefaults } from "./default-provider-options.js";
|
|
22
23
|
import { createStreamState, processStream, } from "./chat-stream-handler.js";
|
|
23
24
|
import { repairToolCall } from "./repair-tool-call.js";
|
|
24
25
|
import { MiddlewareChain } from "../middleware/chain.js";
|
|
@@ -178,7 +179,7 @@ export class AgentRuntime {
|
|
|
178
179
|
resolvedModelString,
|
|
179
180
|
languageModel: transport?.model ?? resolveModel(resolvedModelString),
|
|
180
181
|
headers: transport?.headers,
|
|
181
|
-
providerOptions: transport?.providerOptions,
|
|
182
|
+
providerOptions: resolveProviderOptionsWithDefaults(resolvedModelString, transport?.providerOptions),
|
|
182
183
|
};
|
|
183
184
|
}
|
|
184
185
|
async resolveRuntimeState(messages, context, mode, step, systemPrompt) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.202";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
type SafeParseResult<T> = { success: true; data: T } | { success: false; error: z.ZodError };
|
|
4
4
|
import { createFileSystem, getEnv } from "../../../src/platform/index.js";
|
|
5
5
|
import { basename, extname, join, normalize, relative } from "../../../src/platform/compat/path/index.js";
|
|
6
|
+
import { type CommandResult, runCommand } from "../../../src/platform/compat/process.js";
|
|
6
7
|
import { withSpan } from "../../../src/observability/tracing/otlp-setup.js";
|
|
7
8
|
import { cliLogger } from "../../utils/index.js";
|
|
8
9
|
import { type ApiClient, createApiClient, resolveConfigWithAuth } from "../../shared/config.js";
|
|
@@ -485,6 +486,76 @@ export async function runKnowledgeParser(input: {
|
|
|
485
486
|
return result;
|
|
486
487
|
}
|
|
487
488
|
|
|
489
|
+
function isMissingPythonExecutableError(error: unknown): boolean {
|
|
490
|
+
if (!(error instanceof Error)) {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const errorWithCode = error as Error & { code?: unknown };
|
|
495
|
+
if (errorWithCode.code === "ENOENT") {
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return error.name === "NotFound" ||
|
|
500
|
+
/\bENOENT\b/i.test(error.message) ||
|
|
501
|
+
/not found/i.test(error.message) ||
|
|
502
|
+
/no such file or directory/i.test(error.message);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export async function executeKnowledgeParserCommand(input: {
|
|
506
|
+
scriptPath: string;
|
|
507
|
+
inputJsonPath: string;
|
|
508
|
+
outputJsonPath: string;
|
|
509
|
+
env?: Record<string, string>;
|
|
510
|
+
}, deps: {
|
|
511
|
+
runCommandFn?: (
|
|
512
|
+
cmd: string,
|
|
513
|
+
options: {
|
|
514
|
+
args: string[];
|
|
515
|
+
env?: Record<string, string>;
|
|
516
|
+
capture: true;
|
|
517
|
+
},
|
|
518
|
+
) => Promise<CommandResult>;
|
|
519
|
+
} = {}): Promise<void> {
|
|
520
|
+
const runCommandFn = deps.runCommandFn ?? runCommand;
|
|
521
|
+
let result: CommandResult;
|
|
522
|
+
try {
|
|
523
|
+
result = await runCommandFn("python3", {
|
|
524
|
+
args: [
|
|
525
|
+
input.scriptPath,
|
|
526
|
+
"--input-json",
|
|
527
|
+
input.inputJsonPath,
|
|
528
|
+
"--output-json",
|
|
529
|
+
input.outputJsonPath,
|
|
530
|
+
],
|
|
531
|
+
...(input.env ? { env: input.env } : {}),
|
|
532
|
+
capture: true,
|
|
533
|
+
});
|
|
534
|
+
} catch (error) {
|
|
535
|
+
if (isMissingPythonExecutableError(error)) {
|
|
536
|
+
throw new Error(
|
|
537
|
+
"python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
throw error;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (result.success) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const stderr = result.stderr?.trim();
|
|
548
|
+
const stdout = result.stdout?.trim();
|
|
549
|
+
|
|
550
|
+
if (result.code === 1 && !stderr && !stdout) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
"python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
throw new Error(stderr || stdout || "parser exited unsuccessfully");
|
|
557
|
+
}
|
|
558
|
+
|
|
488
559
|
export async function runKnowledgeParsers(input: {
|
|
489
560
|
files: KnowledgeParserInput[];
|
|
490
561
|
outputDir: string;
|
|
@@ -515,27 +586,12 @@ export async function runKnowledgeParsers(input: {
|
|
|
515
586
|
);
|
|
516
587
|
await dntShim.Deno.writeTextFile(scriptPath, knowledgeIngestPythonSource);
|
|
517
588
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
stderr: "piped",
|
|
525
|
-
}).output();
|
|
526
|
-
} catch (error) {
|
|
527
|
-
if (error instanceof dntShim.Deno.errors.NotFound) {
|
|
528
|
-
throw new Error(
|
|
529
|
-
"python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
throw error;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
if (result.code !== 0) {
|
|
536
|
-
const stderr = new TextDecoder().decode(result.stderr).trim();
|
|
537
|
-
throw new Error(stderr || "parser exited unsuccessfully");
|
|
538
|
-
}
|
|
589
|
+
await executeKnowledgeParserCommand({
|
|
590
|
+
scriptPath,
|
|
591
|
+
inputJsonPath,
|
|
592
|
+
outputJsonPath,
|
|
593
|
+
env: input.env,
|
|
594
|
+
});
|
|
539
595
|
|
|
540
596
|
const raw = await dntShim.Deno.readTextFile(outputJsonPath);
|
|
541
597
|
const parsed = JSON.parse(raw) as KnowledgeParserResult | KnowledgeParserResult[];
|
package/src/deno.js
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-default `providerOptions` for known providers.
|
|
3
|
+
*
|
|
4
|
+
* Currently: enable Anthropic extended thinking by default for any
|
|
5
|
+
* Anthropic model, since the `reasoning-*` event surface in this framework
|
|
6
|
+
* relies on the provider-side feature being on. Apps can override or opt
|
|
7
|
+
* out by returning their own `providerOptions.anthropic.thinking` from
|
|
8
|
+
* `AgentConfig.resolveModelTransport`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const VERYFRONT_CLOUD_PREFIX = "veryfront-cloud/";
|
|
12
|
+
const ANTHROPIC_PREFIX = "anthropic/";
|
|
13
|
+
const DEFAULT_ANTHROPIC_THINKING_BUDGET_TOKENS = 2048;
|
|
14
|
+
|
|
15
|
+
function isAnthropicModel(modelString: string): boolean {
|
|
16
|
+
const normalized = modelString.startsWith(VERYFRONT_CLOUD_PREFIX)
|
|
17
|
+
? modelString.slice(VERYFRONT_CLOUD_PREFIX.length)
|
|
18
|
+
: modelString;
|
|
19
|
+
return normalized.startsWith(ANTHROPIC_PREFIX);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function hasAnthropicThinkingConfig(existing: Record<string, unknown> | undefined): boolean {
|
|
23
|
+
if (!existing || typeof existing !== "object") return false;
|
|
24
|
+
const anthropic = (existing as { anthropic?: unknown }).anthropic;
|
|
25
|
+
if (!anthropic || typeof anthropic !== "object") return false;
|
|
26
|
+
return "thinking" in (anthropic as Record<string, unknown>);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function resolveProviderOptionsWithDefaults(
|
|
30
|
+
modelString: string,
|
|
31
|
+
existing: Record<string, unknown> | undefined,
|
|
32
|
+
): Record<string, unknown> | undefined {
|
|
33
|
+
if (!isAnthropicModel(modelString)) {
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (hasAnthropicThinkingConfig(existing)) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const existingAnthropic = (existing?.anthropic ?? {}) as Record<string, unknown>;
|
|
42
|
+
return {
|
|
43
|
+
...(existing ?? {}),
|
|
44
|
+
anthropic: {
|
|
45
|
+
// Defaults first; host-supplied fields (e.g. temperature) override them.
|
|
46
|
+
// Only `thinking` is forced because we already confirmed it isn't set.
|
|
47
|
+
temperature: 1,
|
|
48
|
+
...existingAnthropic,
|
|
49
|
+
thinking: { type: "enabled", budget_tokens: DEFAULT_ANTHROPIC_THINKING_BUDGET_TOKENS },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
} from "../../observability/tracing/index.js";
|
|
36
36
|
import { convertToModelMessages } from "./model-message-converter.js";
|
|
37
37
|
import { convertToolsToRuntimeTools } from "./model-tool-converter.js";
|
|
38
|
+
import { resolveProviderOptionsWithDefaults } from "./default-provider-options.js";
|
|
38
39
|
import {
|
|
39
40
|
type ChatStreamState,
|
|
40
41
|
createStreamState,
|
|
@@ -313,7 +314,10 @@ export class AgentRuntime {
|
|
|
313
314
|
resolvedModelString,
|
|
314
315
|
languageModel: transport?.model ?? resolveModel(resolvedModelString),
|
|
315
316
|
headers: transport?.headers,
|
|
316
|
-
providerOptions:
|
|
317
|
+
providerOptions: resolveProviderOptionsWithDefaults(
|
|
318
|
+
resolvedModelString,
|
|
319
|
+
transport?.providerOptions,
|
|
320
|
+
),
|
|
317
321
|
};
|
|
318
322
|
}
|
|
319
323
|
|