veryfront 0.1.261 → 0.1.263
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.map +1 -1
- package/esm/cli/commands/knowledge/command.js +19 -26
- package/esm/cli/templates/manifest.d.ts +470 -470
- package/esm/cli/templates/manifest.js +519 -519
- package/esm/deno.js +1 -1
- package/esm/src/agent/ag-ui-detached-start.d.ts +1 -4
- package/esm/src/agent/ag-ui-detached-start.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-detached-start.js +4 -67
- package/esm/src/agent/ag-ui-handler.d.ts +1 -4
- package/esm/src/agent/ag-ui-handler.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-handler.js +3 -61
- package/esm/src/agent/ag-ui-host-support.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-host-support.js +2 -21
- package/esm/src/agent/ag-ui-request-shared.d.ts +4 -0
- package/esm/src/agent/ag-ui-request-shared.d.ts.map +1 -0
- package/esm/src/agent/ag-ui-request-shared.js +47 -0
- package/esm/src/agent/ag-ui-run-control.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-run-control.js +1 -23
- package/esm/src/agent/ag-ui-runtime-handler.d.ts +1 -5
- package/esm/src/agent/ag-ui-runtime-handler.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-runtime-handler.js +3 -67
- package/esm/src/agent/ag-ui-tool-shared.d.ts +15 -0
- package/esm/src/agent/ag-ui-tool-shared.d.ts.map +1 -0
- package/esm/src/agent/ag-ui-tool-shared.js +47 -0
- package/esm/src/agent/conversation-run-event-preparation.d.ts +3 -1
- package/esm/src/agent/conversation-run-event-preparation.d.ts.map +1 -1
- package/esm/src/agent/conversation-run-event-preparation.js +40 -0
- package/esm/src/agent/index.d.ts +3 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -1
- package/esm/src/agent/runtime-ag-ui-contract.d.ts.map +1 -1
- package/esm/src/agent/runtime-ag-ui-contract.js +2 -21
- package/esm/src/chat/chat-ui-message-helpers.d.ts +20 -0
- package/esm/src/chat/chat-ui-message-helpers.d.ts.map +1 -0
- package/esm/src/chat/chat-ui-message-helpers.js +167 -0
- package/esm/src/chat/index.d.ts +2 -0
- package/esm/src/chat/index.d.ts.map +1 -1
- package/esm/src/chat/index.js +1 -0
- package/esm/src/chat/protocol.d.ts +109 -0
- package/esm/src/chat/protocol.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader/provider-http.d.ts +47 -0
- package/esm/src/provider/runtime-loader/provider-http.d.ts.map +1 -0
- package/esm/src/provider/runtime-loader/provider-http.js +171 -0
- package/esm/src/provider/runtime-loader/provider-records.d.ts +2 -0
- package/esm/src/provider/runtime-loader/provider-records.d.ts.map +1 -0
- package/esm/src/provider/runtime-loader/provider-records.js +6 -0
- package/esm/src/provider/runtime-loader.d.ts +2 -32
- package/esm/src/provider/runtime-loader.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader.js +3 -176
- package/esm/src/routing/api/module-loader/external-import-rewriter.d.ts +27 -0
- package/esm/src/routing/api/module-loader/external-import-rewriter.d.ts.map +1 -0
- package/esm/src/routing/api/module-loader/external-import-rewriter.js +339 -0
- package/esm/src/routing/api/module-loader/loader.d.ts +1 -22
- package/esm/src/routing/api/module-loader/loader.d.ts.map +1 -1
- package/esm/src/routing/api/module-loader/loader.js +4 -336
- package/esm/src/server/dev-ui/manifest.d.ts +17 -17
- package/esm/src/server/dev-ui/manifest.js +17 -17
- 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 +27 -32
- package/src/cli/templates/manifest.js +519 -519
- package/src/deno.js +1 -1
- package/src/src/agent/ag-ui-detached-start.ts +4 -92
- package/src/src/agent/ag-ui-handler.ts +3 -81
- package/src/src/agent/ag-ui-host-support.ts +5 -28
- package/src/src/agent/ag-ui-request-shared.ts +62 -0
- package/src/src/agent/ag-ui-run-control.ts +1 -27
- package/src/src/agent/ag-ui-runtime-handler.ts +3 -86
- package/src/src/agent/ag-ui-tool-shared.ts +77 -0
- package/src/src/agent/conversation-run-event-preparation.ts +57 -1
- package/src/src/agent/index.ts +19 -0
- package/src/src/agent/runtime-ag-ui-contract.ts +5 -28
- package/src/src/chat/chat-ui-message-helpers.ts +232 -0
- package/src/src/chat/index.ts +19 -0
- package/src/src/chat/protocol.ts +148 -0
- package/src/src/provider/runtime-loader/provider-http.ts +207 -0
- package/src/src/provider/runtime-loader/provider-records.ts +7 -0
- package/src/src/provider/runtime-loader.ts +10 -214
- package/src/src/routing/api/module-loader/external-import-rewriter.ts +461 -0
- package/src/src/routing/api/module-loader/loader.ts +19 -462
- package/src/src/server/dev-ui/manifest.js +17 -17
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -13,11 +13,21 @@ import {
|
|
|
13
13
|
createGoogleRequestInit,
|
|
14
14
|
createOpenAIRequestInit,
|
|
15
15
|
} from "./runtime-loader/provider-request-init.js";
|
|
16
|
+
import type { ProviderKind } from "./runtime-loader/provider-http.js";
|
|
17
|
+
import { requestJson, requestStream } from "./runtime-loader/provider-http.js";
|
|
18
|
+
import { readRecord } from "./runtime-loader/provider-records.js";
|
|
16
19
|
import {
|
|
17
20
|
TOOL_INPUT_PENDING_THRESHOLD_MS,
|
|
18
21
|
withToolInputStatusTransitions,
|
|
19
22
|
} from "./runtime-loader/tool-input-status.js";
|
|
20
23
|
|
|
24
|
+
export {
|
|
25
|
+
ProviderError,
|
|
26
|
+
ProviderOverloadedError,
|
|
27
|
+
ProviderQuotaError,
|
|
28
|
+
ProviderRateLimitError,
|
|
29
|
+
ProviderRequestError,
|
|
30
|
+
} from "./runtime-loader/provider-http.js";
|
|
21
31
|
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions };
|
|
22
32
|
|
|
23
33
|
export interface OpenAIRuntimeConfig {
|
|
@@ -401,14 +411,6 @@ function isNumberArray(value: unknown): value is number[] {
|
|
|
401
411
|
return Array.isArray(value) && value.every((entry) => typeof entry === "number");
|
|
402
412
|
}
|
|
403
413
|
|
|
404
|
-
function readRecord(value: unknown): Record<string, unknown> | undefined {
|
|
405
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
406
|
-
return undefined;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return Object.fromEntries(Object.entries(value));
|
|
410
|
-
}
|
|
411
|
-
|
|
412
414
|
function extractOpenAIEmbeddings(payload: unknown): number[][] {
|
|
413
415
|
const record = readRecord(payload);
|
|
414
416
|
const data = record?.data;
|
|
@@ -465,8 +467,6 @@ function extractGoogleUsageTokens(payload: unknown): number | undefined {
|
|
|
465
467
|
return typeof promptTokenCount === "number" ? promptTokenCount : undefined;
|
|
466
468
|
}
|
|
467
469
|
|
|
468
|
-
type ProviderKind = "anthropic" | "openai" | "google";
|
|
469
|
-
|
|
470
470
|
/**
|
|
471
471
|
* Structured warning emitted when a provider runtime drops or rewrites a
|
|
472
472
|
* caller-provided option. Mirrors the AI ecosystem convention (Vercel AI
|
|
@@ -503,210 +503,6 @@ function createWarningCollector(): WarningCollector {
|
|
|
503
503
|
};
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
/**
|
|
507
|
-
* Base class for typed provider errors. The `retryable` flag is the
|
|
508
|
-
* primary signal for callers (or a retry wrapper) to decide whether to
|
|
509
|
-
* re-issue the request. `retryAfterMs` is set when the provider gave an
|
|
510
|
-
* explicit delay hint (Retry-After header, Retry-Info trailer).
|
|
511
|
-
*/
|
|
512
|
-
export class ProviderError extends Error {
|
|
513
|
-
readonly provider: ProviderKind;
|
|
514
|
-
readonly status: number;
|
|
515
|
-
readonly retryable: boolean;
|
|
516
|
-
readonly retryAfterMs?: number;
|
|
517
|
-
|
|
518
|
-
constructor(options: {
|
|
519
|
-
provider: ProviderKind;
|
|
520
|
-
status: number;
|
|
521
|
-
message: string;
|
|
522
|
-
retryable: boolean;
|
|
523
|
-
retryAfterMs?: number;
|
|
524
|
-
}) {
|
|
525
|
-
super(options.message);
|
|
526
|
-
this.name = new.target.name;
|
|
527
|
-
this.provider = options.provider;
|
|
528
|
-
this.status = options.status;
|
|
529
|
-
this.retryable = options.retryable;
|
|
530
|
-
if (options.retryAfterMs !== undefined) {
|
|
531
|
-
this.retryAfterMs = options.retryAfterMs;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/** Provider reports it is overloaded (Anthropic 529, OpenAI/Google 503). */
|
|
537
|
-
export class ProviderOverloadedError extends ProviderError {}
|
|
538
|
-
|
|
539
|
-
/** Provider is rate limiting this API key (OpenAI/Google 429 with Retry-After). */
|
|
540
|
-
export class ProviderRateLimitError extends ProviderError {}
|
|
541
|
-
|
|
542
|
-
/** Provider account quota is exhausted — non-retryable. */
|
|
543
|
-
export class ProviderQuotaError extends ProviderError {}
|
|
544
|
-
|
|
545
|
-
/** Non-retryable 4xx/5xx that doesn't fit another bucket. */
|
|
546
|
-
export class ProviderRequestError extends ProviderError {}
|
|
547
|
-
|
|
548
|
-
function parseRetryAfterMs(header: string | null): number | undefined {
|
|
549
|
-
if (!header) return undefined;
|
|
550
|
-
const asNumber = Number(header);
|
|
551
|
-
if (Number.isFinite(asNumber) && asNumber >= 0) {
|
|
552
|
-
return Math.round(asNumber * 1000);
|
|
553
|
-
}
|
|
554
|
-
// HTTP-date form (rare in practice for LLM providers).
|
|
555
|
-
const parsed = Date.parse(header);
|
|
556
|
-
if (!Number.isNaN(parsed)) {
|
|
557
|
-
return Math.max(0, parsed - Date.now());
|
|
558
|
-
}
|
|
559
|
-
return undefined;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Inspect a non-2xx response and build the most specific ProviderError
|
|
564
|
-
* subclass we can. Reads the response body as text (it's already dead
|
|
565
|
-
* on the wire by this point). Body classification handles the cases
|
|
566
|
-
* where HTTP status alone is ambiguous — notably OpenAI
|
|
567
|
-
* `insufficient_quota` vs `rate_limit_exceeded` both arriving as 429.
|
|
568
|
-
*/
|
|
569
|
-
async function buildProviderError(
|
|
570
|
-
provider: ProviderKind,
|
|
571
|
-
response: Response,
|
|
572
|
-
): Promise<ProviderError> {
|
|
573
|
-
const rawBody = await response.text();
|
|
574
|
-
const message = rawBody.trim() || `${response.status} ${response.statusText}`.trim();
|
|
575
|
-
const status = response.status;
|
|
576
|
-
const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after"));
|
|
577
|
-
|
|
578
|
-
const parsedBody = (() => {
|
|
579
|
-
try {
|
|
580
|
-
return JSON.parse(rawBody) as Record<string, unknown>;
|
|
581
|
-
} catch {
|
|
582
|
-
return undefined;
|
|
583
|
-
}
|
|
584
|
-
})();
|
|
585
|
-
const errorRecord = readRecord(parsedBody?.error);
|
|
586
|
-
const errorCode = typeof errorRecord?.code === "string"
|
|
587
|
-
? errorRecord.code
|
|
588
|
-
: typeof errorRecord?.type === "string"
|
|
589
|
-
? errorRecord.type
|
|
590
|
-
: typeof errorRecord?.status === "string"
|
|
591
|
-
? errorRecord.status
|
|
592
|
-
: undefined;
|
|
593
|
-
|
|
594
|
-
// Anthropic 529 = overloaded. Anthropic surfaces this with
|
|
595
|
-
// { error: { type: "overloaded_error" } } in the body.
|
|
596
|
-
if (provider === "anthropic" && status === 529) {
|
|
597
|
-
return new ProviderOverloadedError({
|
|
598
|
-
provider,
|
|
599
|
-
status,
|
|
600
|
-
message,
|
|
601
|
-
retryable: true,
|
|
602
|
-
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
// OpenAI / Google 503 = overloaded.
|
|
607
|
-
if ((provider === "openai" || provider === "google") && status === 503) {
|
|
608
|
-
return new ProviderOverloadedError({
|
|
609
|
-
provider,
|
|
610
|
-
status,
|
|
611
|
-
message,
|
|
612
|
-
retryable: true,
|
|
613
|
-
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
// OpenAI 429 splits based on the error code in the body:
|
|
618
|
-
// - insufficient_quota → hard quota, non-retryable
|
|
619
|
-
// - rate_limit_exceeded / tokens_per_min_exceeded → retry with Retry-After
|
|
620
|
-
if (provider === "openai" && status === 429) {
|
|
621
|
-
if (errorCode === "insufficient_quota") {
|
|
622
|
-
return new ProviderQuotaError({
|
|
623
|
-
provider,
|
|
624
|
-
status,
|
|
625
|
-
message,
|
|
626
|
-
retryable: false,
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
return new ProviderRateLimitError({
|
|
630
|
-
provider,
|
|
631
|
-
status,
|
|
632
|
-
message,
|
|
633
|
-
retryable: true,
|
|
634
|
-
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
// Google 429 RESOURCE_EXHAUSTED is almost always the daily free-tier
|
|
639
|
-
// quota — surface as a hard quota error so callers don't hot-loop on
|
|
640
|
-
// retries that can't possibly succeed until midnight UTC.
|
|
641
|
-
if (provider === "google" && status === 429) {
|
|
642
|
-
if (errorCode === "RESOURCE_EXHAUSTED") {
|
|
643
|
-
return new ProviderQuotaError({
|
|
644
|
-
provider,
|
|
645
|
-
status,
|
|
646
|
-
message,
|
|
647
|
-
retryable: false,
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
return new ProviderRateLimitError({
|
|
651
|
-
provider,
|
|
652
|
-
status,
|
|
653
|
-
message,
|
|
654
|
-
retryable: true,
|
|
655
|
-
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
return new ProviderRequestError({
|
|
660
|
-
provider,
|
|
661
|
-
status,
|
|
662
|
-
message,
|
|
663
|
-
retryable: false,
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
async function requestJson(options: {
|
|
668
|
-
url: string;
|
|
669
|
-
fetchImpl: typeof globalThis.fetch;
|
|
670
|
-
init: RequestInit;
|
|
671
|
-
providerLabel: string;
|
|
672
|
-
providerKind: ProviderKind;
|
|
673
|
-
}): Promise<unknown> {
|
|
674
|
-
const response = await options.fetchImpl(options.url, options.init);
|
|
675
|
-
if (!response.ok) {
|
|
676
|
-
const err = await buildProviderError(options.providerKind, response);
|
|
677
|
-
err.message = `${options.providerLabel} request failed: ${err.message}`;
|
|
678
|
-
throw err;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
return response.json();
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
async function requestStream(options: {
|
|
685
|
-
url: string;
|
|
686
|
-
fetchImpl: typeof globalThis.fetch;
|
|
687
|
-
init: RequestInit;
|
|
688
|
-
providerLabel: string;
|
|
689
|
-
providerKind: ProviderKind;
|
|
690
|
-
}): Promise<ReadableStream<Uint8Array>> {
|
|
691
|
-
const response = await options.fetchImpl(options.url, options.init);
|
|
692
|
-
if (!response.ok) {
|
|
693
|
-
const err = await buildProviderError(options.providerKind, response);
|
|
694
|
-
err.message = `${options.providerLabel} request failed: ${err.message}`;
|
|
695
|
-
throw err;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
if (!response.body) {
|
|
699
|
-
throw new ProviderRequestError({
|
|
700
|
-
provider: options.providerKind,
|
|
701
|
-
status: response.status,
|
|
702
|
-
message: `${options.providerLabel} request failed: stream body missing`,
|
|
703
|
-
retryable: false,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
return response.body;
|
|
708
|
-
}
|
|
709
|
-
|
|
710
506
|
function stringifyJsonValue(value: unknown): string {
|
|
711
507
|
if (typeof value === "string") {
|
|
712
508
|
return value;
|