@ponythewhite/base-context 1.0.0 → 1.0.1
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/CHANGELOG.md +33 -0
- package/NOTICE +0 -5
- package/README.md +44 -27
- package/dist/NOTICE +0 -5
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/src/rlm/__init__.py +7 -5
- package/dist/base-context-runtime/test/test_subagent_registry.py +28 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/amazon-bedrock.js +21 -0
- package/dist/bundle/{anthropic-YY4S534V.js → anthropic-UV5GZDGU.js} +5 -5
- package/dist/bundle/{azure-openai-responses-JRP6MIM3.js → azure-openai-responses-WSNPXLYC.js} +6 -6
- package/dist/bundle/{bundled-modules-P5HARVZA.js → bundled-modules-TXUMJ2XQ.js} +71 -16
- package/dist/bundle/chunk-27QCJ2AZ.js +2578 -0
- package/dist/bundle/{chunk-MZHTNNVA.js → chunk-4GXPNXOJ.js} +8 -0
- package/dist/bundle/{chunk-SC5KG5R4.js → chunk-DGNX7HQ3.js} +1 -7
- package/dist/bundle/{chunk-A53O363M.js → chunk-GRJFXLBM.js} +0 -1
- package/dist/bundle/chunk-HKINIBP4.js +29 -0
- package/dist/bundle/{chunk-UDSW6FNG.js → chunk-KTNETTHI.js} +1 -1
- package/dist/bundle/{chunk-BYVP7LWV.js → chunk-S3INFPZZ.js} +1861 -4662
- package/dist/bundle/{chunk-73DCPU3D.js → chunk-V3L54UD6.js} +1019 -3427
- package/dist/bundle/{chunk-U7AUVG3B.js → chunk-VSIYFWYI.js} +24 -6
- package/dist/bundle/{chunk-IW77OXFS.js → chunk-W46VZFI6.js} +0 -2099
- package/dist/bundle/{cli-main-O4X7GFGY.js → cli-main-BYMSRPH6.js} +8 -6
- package/dist/bundle/cli.js +2 -2
- package/dist/bundle/{google-AUTVGDGZ.js → google-T32FMD4G.js} +6 -6
- package/dist/bundle/{google-vertex-Q75D7RKS.js → google-vertex-56KP6I3B.js} +3 -3
- package/dist/bundle/{main-XKOW2BV6.js → main-ODOYCEQC.js} +7 -5
- package/dist/bundle/{mistral-7ESB7QUD.js → mistral-WGBMYIVU.js} +5 -5
- package/dist/bundle/{openai-codex-responses-LV3QRPN4.js → openai-codex-responses-PIV2RQ3G.js} +6 -6
- package/dist/bundle/{openai-completions-OJECLPXJ.js → openai-completions-64C3JPR4.js} +11 -22
- package/dist/bundle/{openai-responses-FN6HZMBC.js → openai-responses-UI7RSTDV.js} +6 -6
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +108 -59
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/daemon-ps.d.ts +4 -3
- package/dist/cli/daemon-ps.d.ts.map +1 -1
- package/dist/cli/daemon-ps.js +6 -1
- package/dist/cli/daemon-ps.js.map +1 -1
- package/dist/cli/product-doctor.d.ts +0 -1
- package/dist/cli/product-doctor.d.ts.map +1 -1
- package/dist/cli/product-doctor.js +6 -3
- package/dist/cli/product-doctor.js.map +1 -1
- package/dist/config.d.ts +0 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-config.d.ts +1 -2
- package/dist/core/agent-session-config.d.ts.map +1 -1
- package/dist/core/agent-session-config.js +0 -3
- package/dist/core/agent-session-config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +5 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -3
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -27
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +107 -107
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +8 -35
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +33 -243
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cron-jobs.d.ts.map +1 -1
- package/dist/core/cron-jobs.js +7 -1
- package/dist/core/cron-jobs.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts +6 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +18 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/kernel/bootstrap.d.ts.map +1 -1
- package/dist/core/kernel/bootstrap.js +2 -2
- package/dist/core/kernel/bootstrap.js.map +1 -1
- package/dist/core/kernel/repl-manager.d.ts +2 -0
- package/dist/core/kernel/repl-manager.d.ts.map +1 -1
- package/dist/core/kernel/repl-manager.js +44 -1
- package/dist/core/kernel/repl-manager.js.map +1 -1
- package/dist/core/logging.d.ts +4 -3
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/logging.js +6 -6
- package/dist/core/logging.js.map +1 -1
- package/dist/core/mcp/mcp-manager.d.ts.map +1 -1
- package/dist/core/mcp/mcp-manager.js +3 -3
- package/dist/core/mcp/mcp-manager.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -16
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +88 -196
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -19
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +36 -266
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-contracts.d.ts +5 -6
- package/dist/core/provider-contracts.d.ts.map +1 -1
- package/dist/core/provider-contracts.js +25 -36
- package/dist/core/provider-contracts.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +0 -2
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/rlm-max-subagents.d.ts +32 -0
- package/dist/core/rlm-max-subagents.d.ts.map +1 -0
- package/dist/core/rlm-max-subagents.js +50 -0
- package/dist/core/rlm-max-subagents.js.map +1 -0
- package/dist/core/rlm-runtime.d.ts +3 -3
- package/dist/core/rlm-runtime.d.ts.map +1 -1
- package/dist/core/rlm-runtime.js.map +1 -1
- package/dist/core/sdk.d.ts +4 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -14
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +12 -44
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +6 -6
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.mjs +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +39 -34
- package/dist/main.js.map +1 -1
- package/dist/modes/acp/acp-mode.d.ts.map +1 -1
- package/dist/modes/acp/acp-mode.js +1 -1
- package/dist/modes/acp/acp-mode.js.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts +6 -2
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.js +13 -2
- package/dist/modes/agent-connection/daemon-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts +2 -0
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.js +6 -0
- package/dist/modes/agent-connection/in-process-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/types.d.ts +3 -0
- package/dist/modes/agent-connection/types.d.ts.map +1 -1
- package/dist/modes/agent-connection/types.js.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.d.ts.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.js +2 -19
- package/dist/modes/agents-view/agents-view-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-mode.d.ts +5 -0
- package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-mode.js +107 -12
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-protocol.d.ts +194 -165
- package/dist/modes/daemon/daemon-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-protocol.js +16 -11
- package/dist/modes/daemon/daemon-protocol.js.map +1 -1
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js +74 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js +85 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js.map +1 -0
- package/dist/modes/daemon/daemon-session-summarizer.d.ts +2 -3
- package/dist/modes/daemon/daemon-session-summarizer.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-session-summarizer.js +32 -23
- package/dist/modes/daemon/daemon-session-summarizer.js.map +1 -1
- package/dist/modes/daemon/daemon-state-root.d.ts +15 -0
- package/dist/modes/daemon/daemon-state-root.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-state-root.js +40 -0
- package/dist/modes/daemon/daemon-state-root.js.map +1 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts +2 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor-ownership.js +27 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.js.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts +10 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.js +213 -20
- package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts +28 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.js +16 -2
- package/dist/modes/daemon/daemon-worker-protocol.js.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.d.ts.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.js +2 -0
- package/dist/modes/daemon/saved-session-catalog.js.map +1 -1
- package/dist/modes/interactive/auth-flows.d.ts +0 -6
- package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
- package/dist/modes/interactive/auth-flows.js +6 -126
- package/dist/modes/interactive/auth-flows.js.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.d.ts +3 -0
- package/dist/modes/interactive/components/configuration-menu.d.ts.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.js +13 -2
- package/dist/modes/interactive/components/configuration-menu.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +0 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -40
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +13 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +2 -11
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/feature-hints.d.ts.map +1 -1
- package/dist/modes/interactive/feature-hints.js +0 -4
- package/dist/modes/interactive/feature-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -12
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +81 -507
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/onboarding.d.ts +0 -3
- package/dist/modes/interactive/onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/onboarding.js +0 -17
- package/dist/modes/interactive/onboarding.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +24 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/node/amazon-bedrock.d.ts +2 -0
- package/dist/node/amazon-bedrock.d.ts.map +1 -0
- package/dist/node/amazon-bedrock.js +6 -0
- package/dist/node/amazon-bedrock.js.map +1 -0
- package/dist/product-identity.d.ts +0 -1
- package/dist/product-identity.d.ts.map +1 -1
- package/dist/product-identity.js +0 -1
- package/dist/product-identity.js.map +1 -1
- package/docs/development.md +1 -1
- package/docs/fork-philosophy.md +4 -8
- package/docs/installation.md +83 -62
- package/docs/providers.md +23 -25
- package/docs/quickstart.md +19 -10
- package/docs/rlm-runtime.md +13 -5
- package/docs/rpc.md +4 -4
- package/docs/sdk.md +20 -11
- package/docs/sessions.md +0 -1
- package/docs/settings.md +9 -42
- package/docs/skills.md +0 -1
- package/docs/upstream-0.9.5.md +171 -0
- package/docs/usage.md +14 -10
- package/package.json +4 -4
- package/dist/core/agent-traces.d.ts +0 -149
- package/dist/core/agent-traces.d.ts.map +0 -1
- package/dist/core/agent-traces.js +0 -904
- package/dist/core/agent-traces.js.map +0 -1
- package/dist/core/prime-inference-auth.d.ts +0 -70
- package/dist/core/prime-inference-auth.d.ts.map +0 -1
- package/dist/core/prime-inference-auth.js +0 -352
- package/dist/core/prime-inference-auth.js.map +0 -1
- package/dist/core/prime-inference-model-selection.d.ts +0 -16
- package/dist/core/prime-inference-model-selection.d.ts.map +0 -1
- package/dist/core/prime-inference-model-selection.js +0 -16
- package/dist/core/prime-inference-model-selection.js.map +0 -1
- package/dist/core/prime-inference-models.d.ts +0 -6
- package/dist/core/prime-inference-models.d.ts.map +0 -1
- package/dist/core/prime-inference-models.js +0 -62
- package/dist/core/prime-inference-models.js.map +0 -1
- package/dist/core/telemetry.d.ts +0 -95
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js +0 -637
- package/dist/core/telemetry.js.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts +0 -39
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.js +0 -286
- package/dist/modes/interactive/components/prime-onboarding-splash.js.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.d.ts +0 -30
- package/dist/modes/interactive/components/prime-team-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.js +0 -166
- package/dist/modes/interactive/components/prime-team-selector.js.map +0 -1
- package/dist/skills/prime-intellect/SKILL.md +0 -87
- package/dist/skills/prime-intellect/references/compute.md +0 -45
- package/dist/skills/prime-intellect/references/environments.md +0 -73
- package/dist/skills/prime-intellect/references/inference.md +0 -47
- package/dist/skills/prime-intellect/references/sandboxes.md +0 -75
- package/skills/prime-intellect/SKILL.md +0 -87
- package/skills/prime-intellect/references/compute.md +0 -45
- package/skills/prime-intellect/references/environments.md +0 -73
- package/skills/prime-intellect/references/inference.md +0 -47
- package/skills/prime-intellect/references/sandboxes.md +0 -75
|
@@ -0,0 +1,2578 @@
|
|
|
1
|
+
import { createRequire as __piBundleCreateRequire } from 'node:module'; const require = __piBundleCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
cleanupSessionResources,
|
|
4
|
+
registerSessionResourceCleanup
|
|
5
|
+
} from "./chunk-5QCJ5DQU.js";
|
|
6
|
+
import {
|
|
7
|
+
AddImmutable,
|
|
8
|
+
AddImmutableDeferred,
|
|
9
|
+
AddOptional,
|
|
10
|
+
AddOptionalDeferred,
|
|
11
|
+
AddReadonly,
|
|
12
|
+
AddReadonlyDeferred,
|
|
13
|
+
Any,
|
|
14
|
+
ArrayOptions,
|
|
15
|
+
BigInt,
|
|
16
|
+
BigIntPattern,
|
|
17
|
+
Boolean,
|
|
18
|
+
Broaden,
|
|
19
|
+
Call,
|
|
20
|
+
CallConstruct,
|
|
21
|
+
Capitalize,
|
|
22
|
+
CapitalizeAction,
|
|
23
|
+
CapitalizeDeferred,
|
|
24
|
+
CapitalizeInstantiate,
|
|
25
|
+
Codec,
|
|
26
|
+
CollapseToObject,
|
|
27
|
+
Compare,
|
|
28
|
+
Compile,
|
|
29
|
+
Composite,
|
|
30
|
+
Conditional,
|
|
31
|
+
ConditionalAction,
|
|
32
|
+
ConditionalDeferred,
|
|
33
|
+
ConditionalInstantiate,
|
|
34
|
+
Constructor,
|
|
35
|
+
ConstructorOptions,
|
|
36
|
+
ConstructorParameters,
|
|
37
|
+
ConstructorParametersAction,
|
|
38
|
+
ConstructorParametersDeferred,
|
|
39
|
+
ConstructorParametersInstantiate,
|
|
40
|
+
ConvertToIntegerKey,
|
|
41
|
+
Cyclic,
|
|
42
|
+
CyclicCandidates,
|
|
43
|
+
CyclicCheck,
|
|
44
|
+
CyclicDependencies,
|
|
45
|
+
CyclicExtends,
|
|
46
|
+
CyclicOptions,
|
|
47
|
+
CyclicTarget,
|
|
48
|
+
Decode,
|
|
49
|
+
DecodeBuilder,
|
|
50
|
+
Deferred,
|
|
51
|
+
Dependent,
|
|
52
|
+
DependentOptions,
|
|
53
|
+
Distribute,
|
|
54
|
+
Encode,
|
|
55
|
+
EncodeBuilder,
|
|
56
|
+
Enum,
|
|
57
|
+
Evaluate,
|
|
58
|
+
EvaluateAction,
|
|
59
|
+
EvaluateDeferred,
|
|
60
|
+
EvaluateDependent,
|
|
61
|
+
EvaluateEnum,
|
|
62
|
+
EvaluateInstantiate,
|
|
63
|
+
EvaluateIntersect,
|
|
64
|
+
EvaluateTemplateLiteral,
|
|
65
|
+
EvaluateType,
|
|
66
|
+
EvaluateUnion,
|
|
67
|
+
EvaluateUnionFast,
|
|
68
|
+
Exclude,
|
|
69
|
+
ExcludeAction,
|
|
70
|
+
ExcludeDeferred,
|
|
71
|
+
ExcludeInstantiate,
|
|
72
|
+
Extends,
|
|
73
|
+
Extract,
|
|
74
|
+
ExtractAction,
|
|
75
|
+
ExtractDeferred,
|
|
76
|
+
ExtractInstantiate,
|
|
77
|
+
Flatten,
|
|
78
|
+
FunctionOptions,
|
|
79
|
+
Generic,
|
|
80
|
+
Identifier,
|
|
81
|
+
Immutable,
|
|
82
|
+
Index,
|
|
83
|
+
IndexAction,
|
|
84
|
+
IndexDeferred,
|
|
85
|
+
IndexInstantiate,
|
|
86
|
+
Infer,
|
|
87
|
+
InstanceType,
|
|
88
|
+
InstanceTypeAction,
|
|
89
|
+
InstanceTypeDeferred,
|
|
90
|
+
InstanceTypeInstantiate,
|
|
91
|
+
Instantiate,
|
|
92
|
+
InstantiateCyclic,
|
|
93
|
+
Integer,
|
|
94
|
+
IntegerKey,
|
|
95
|
+
IntegerPattern,
|
|
96
|
+
Interface,
|
|
97
|
+
InterfaceAction,
|
|
98
|
+
InterfaceDeferred,
|
|
99
|
+
InterfaceInstantiate,
|
|
100
|
+
Intersect,
|
|
101
|
+
IntersectOptions,
|
|
102
|
+
InvalidLiteralValue,
|
|
103
|
+
IsAny,
|
|
104
|
+
IsArray,
|
|
105
|
+
IsBigInt,
|
|
106
|
+
IsBoolean,
|
|
107
|
+
IsCall,
|
|
108
|
+
IsCodec,
|
|
109
|
+
IsConstructor,
|
|
110
|
+
IsCyclic,
|
|
111
|
+
IsDeferred,
|
|
112
|
+
IsDependent,
|
|
113
|
+
IsEnum,
|
|
114
|
+
IsEnumValue,
|
|
115
|
+
IsFunction,
|
|
116
|
+
IsGeneric,
|
|
117
|
+
IsIdentifier,
|
|
118
|
+
IsImmutable,
|
|
119
|
+
IsInfer,
|
|
120
|
+
IsInteger,
|
|
121
|
+
IsInterfaceDeferred,
|
|
122
|
+
IsIntersect,
|
|
123
|
+
IsKind,
|
|
124
|
+
IsLiteral,
|
|
125
|
+
IsLiteralBigInt,
|
|
126
|
+
IsLiteralBoolean,
|
|
127
|
+
IsLiteralNumber,
|
|
128
|
+
IsLiteralString,
|
|
129
|
+
IsLiteralValue,
|
|
130
|
+
IsNever,
|
|
131
|
+
IsNull,
|
|
132
|
+
IsNumber,
|
|
133
|
+
IsObject,
|
|
134
|
+
IsOptional,
|
|
135
|
+
IsParameter,
|
|
136
|
+
IsReadonly,
|
|
137
|
+
IsRecord,
|
|
138
|
+
IsRef,
|
|
139
|
+
IsRefine,
|
|
140
|
+
IsRefinement,
|
|
141
|
+
IsRest,
|
|
142
|
+
IsSchema,
|
|
143
|
+
IsString,
|
|
144
|
+
IsSymbol,
|
|
145
|
+
IsTemplateLiteral,
|
|
146
|
+
IsTemplateLiteralDeferred,
|
|
147
|
+
IsTemplateLiteralFinite,
|
|
148
|
+
IsTemplateLiteralPattern,
|
|
149
|
+
IsThis,
|
|
150
|
+
IsTuple,
|
|
151
|
+
IsTypeScriptEnumLike,
|
|
152
|
+
IsUndefined,
|
|
153
|
+
IsUnion,
|
|
154
|
+
IsUnknown,
|
|
155
|
+
IsUnsafe,
|
|
156
|
+
IsVoid,
|
|
157
|
+
KeyOf,
|
|
158
|
+
KeyOfAction,
|
|
159
|
+
KeyOfDeferred,
|
|
160
|
+
KeyOfInstantiate,
|
|
161
|
+
KeysToIndexer,
|
|
162
|
+
Literal,
|
|
163
|
+
LiteralTypeName,
|
|
164
|
+
Lowercase,
|
|
165
|
+
LowercaseAction,
|
|
166
|
+
LowercaseDeferred,
|
|
167
|
+
LowercaseInstantiate,
|
|
168
|
+
Mapped,
|
|
169
|
+
MappedAction,
|
|
170
|
+
MappedDeferred,
|
|
171
|
+
MappedInstantiate,
|
|
172
|
+
Module,
|
|
173
|
+
ModuleDeferred,
|
|
174
|
+
ModuleInstantiate,
|
|
175
|
+
Narrow,
|
|
176
|
+
Never,
|
|
177
|
+
NeverPattern,
|
|
178
|
+
NonNullable,
|
|
179
|
+
NonNullableAction,
|
|
180
|
+
NonNullableDeferred,
|
|
181
|
+
NonNullableInstantiate,
|
|
182
|
+
Null,
|
|
183
|
+
Number as Number2,
|
|
184
|
+
NumberKey,
|
|
185
|
+
NumberPattern,
|
|
186
|
+
ObjectOptions,
|
|
187
|
+
Omit,
|
|
188
|
+
OmitAction,
|
|
189
|
+
OmitDeferred,
|
|
190
|
+
OmitInstantiate,
|
|
191
|
+
Optional,
|
|
192
|
+
Parameter,
|
|
193
|
+
Parameters,
|
|
194
|
+
ParametersAction,
|
|
195
|
+
ParametersDeferred,
|
|
196
|
+
ParametersInstantiate,
|
|
197
|
+
ParsePatternIntoTypes,
|
|
198
|
+
ParseTemplateIntoTypes,
|
|
199
|
+
Partial,
|
|
200
|
+
PartialAction,
|
|
201
|
+
PartialDeferred,
|
|
202
|
+
PartialInstantiate,
|
|
203
|
+
Pick,
|
|
204
|
+
PickAction,
|
|
205
|
+
PickDeferred,
|
|
206
|
+
PickInstantiate,
|
|
207
|
+
Priority,
|
|
208
|
+
PropertyKeys,
|
|
209
|
+
PropertyValues,
|
|
210
|
+
Readonly,
|
|
211
|
+
ReadonlyObject,
|
|
212
|
+
ReadonlyObjectAction,
|
|
213
|
+
ReadonlyObjectDeferred,
|
|
214
|
+
ReadonlyObjectInstantiate,
|
|
215
|
+
ReadonlyType,
|
|
216
|
+
Record,
|
|
217
|
+
RecordAction,
|
|
218
|
+
RecordDeferred,
|
|
219
|
+
RecordFromPattern,
|
|
220
|
+
RecordInstantiate,
|
|
221
|
+
RecordKey,
|
|
222
|
+
RecordOptions,
|
|
223
|
+
RecordPattern,
|
|
224
|
+
RecordPatternToType,
|
|
225
|
+
RecordValue,
|
|
226
|
+
Ref,
|
|
227
|
+
RefInstantiate,
|
|
228
|
+
Refine,
|
|
229
|
+
RefineAdd,
|
|
230
|
+
RemoveImmutable,
|
|
231
|
+
RemoveImmutableDeferred,
|
|
232
|
+
RemoveOptional,
|
|
233
|
+
RemoveOptionalDeferred,
|
|
234
|
+
RemoveReadonly,
|
|
235
|
+
RemoveReadonlyDeferred,
|
|
236
|
+
Required,
|
|
237
|
+
RequiredAction,
|
|
238
|
+
RequiredArray,
|
|
239
|
+
RequiredDeferred,
|
|
240
|
+
RequiredInstantiate,
|
|
241
|
+
Rest,
|
|
242
|
+
ResultDisjoint,
|
|
243
|
+
ResultEqual,
|
|
244
|
+
ResultLeftInside,
|
|
245
|
+
ResultRightInside,
|
|
246
|
+
ReturnType,
|
|
247
|
+
ReturnTypeAction,
|
|
248
|
+
ReturnTypeDeferred,
|
|
249
|
+
ReturnTypeInstantiate,
|
|
250
|
+
Script,
|
|
251
|
+
String as String2,
|
|
252
|
+
StringKey,
|
|
253
|
+
StringPattern,
|
|
254
|
+
Symbol as Symbol2,
|
|
255
|
+
TemplateLiteral,
|
|
256
|
+
TemplateLiteralCreate,
|
|
257
|
+
TemplateLiteralDecode,
|
|
258
|
+
TemplateLiteralDecodeUnsafe,
|
|
259
|
+
TemplateLiteralDeferred,
|
|
260
|
+
TemplateLiteralEncode,
|
|
261
|
+
TemplateLiteralFromString,
|
|
262
|
+
TemplateLiteralFromTypes,
|
|
263
|
+
This,
|
|
264
|
+
Tuple,
|
|
265
|
+
TupleOptions,
|
|
266
|
+
TypeScriptEnumToEnumValues,
|
|
267
|
+
Uncapitalize,
|
|
268
|
+
UncapitalizeAction,
|
|
269
|
+
UncapitalizeDeferred,
|
|
270
|
+
UncapitalizeInstantiate,
|
|
271
|
+
Undefined,
|
|
272
|
+
Union,
|
|
273
|
+
UnionOptions,
|
|
274
|
+
Unknown,
|
|
275
|
+
Unsafe,
|
|
276
|
+
Uppercase,
|
|
277
|
+
UppercaseAction,
|
|
278
|
+
UppercaseDeferred,
|
|
279
|
+
UppercaseInstantiate,
|
|
280
|
+
Void,
|
|
281
|
+
With,
|
|
282
|
+
WithAction,
|
|
283
|
+
WithDeferred,
|
|
284
|
+
WithInstantiate,
|
|
285
|
+
_Array_,
|
|
286
|
+
_Function_,
|
|
287
|
+
_Object_,
|
|
288
|
+
result_exports,
|
|
289
|
+
value_exports
|
|
290
|
+
} from "./chunk-CRBVRZBV.js";
|
|
291
|
+
import {
|
|
292
|
+
PRODUCT,
|
|
293
|
+
PRODUCT_ENV
|
|
294
|
+
} from "./chunk-GRJFXLBM.js";
|
|
295
|
+
import {
|
|
296
|
+
parseJsonWithRepair,
|
|
297
|
+
parseStreamingJson,
|
|
298
|
+
repairJson
|
|
299
|
+
} from "./chunk-2T7M7VJ4.js";
|
|
300
|
+
import {
|
|
301
|
+
findEnvKeys,
|
|
302
|
+
getEnvApiKey
|
|
303
|
+
} from "./chunk-DGNX7HQ3.js";
|
|
304
|
+
import {
|
|
305
|
+
AssistantMessageEventStream,
|
|
306
|
+
EventStream,
|
|
307
|
+
RequestTokenBudget,
|
|
308
|
+
RequestTokenBudgetError,
|
|
309
|
+
StreamFailureError,
|
|
310
|
+
appendAssistantMessageDiagnostic,
|
|
311
|
+
calculateCost,
|
|
312
|
+
clampThinkingLevel,
|
|
313
|
+
classifyStreamFailure,
|
|
314
|
+
createAssistantMessageDiagnostic,
|
|
315
|
+
createAssistantMessageEventStream,
|
|
316
|
+
extractDiagnosticError,
|
|
317
|
+
extractStreamFailureInfo,
|
|
318
|
+
formatStreamFailureMessage,
|
|
319
|
+
formatThrownValue,
|
|
320
|
+
getLogger,
|
|
321
|
+
getModel,
|
|
322
|
+
getModels,
|
|
323
|
+
getProviders,
|
|
324
|
+
getSupportedThinkingLevels,
|
|
325
|
+
invokeRequestMeasurement,
|
|
326
|
+
isLocalRequestPreparationError,
|
|
327
|
+
isTransientProviderFailure,
|
|
328
|
+
markLocalRequestPreparationError,
|
|
329
|
+
modelsAreEqual,
|
|
330
|
+
recordStreamFailure,
|
|
331
|
+
requestTokenRouteIdentity,
|
|
332
|
+
setLogSink,
|
|
333
|
+
streamFailureFromStopReason,
|
|
334
|
+
streamFailureMessage,
|
|
335
|
+
stringifyLogEntry,
|
|
336
|
+
supportsFastMode,
|
|
337
|
+
truncateRawPayload,
|
|
338
|
+
withRequestBody
|
|
339
|
+
} from "./chunk-W46VZFI6.js";
|
|
340
|
+
import {
|
|
341
|
+
__export
|
|
342
|
+
} from "./chunk-BAWSWWEU.js";
|
|
343
|
+
|
|
344
|
+
// dist/runtime-paths.js
|
|
345
|
+
import { lstatSync, readlinkSync, realpathSync } from "fs";
|
|
346
|
+
import { homedir } from "os";
|
|
347
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
348
|
+
function expandHomePath(path, home = homedir()) {
|
|
349
|
+
if (path === "~")
|
|
350
|
+
return home;
|
|
351
|
+
if (path.startsWith("~/"))
|
|
352
|
+
return join(home, path.slice(2));
|
|
353
|
+
return path;
|
|
354
|
+
}
|
|
355
|
+
function readAbsolutePathEnv(name, env = process.env, home = homedir()) {
|
|
356
|
+
const value = env[name];
|
|
357
|
+
if (value === void 0)
|
|
358
|
+
return void 0;
|
|
359
|
+
const expanded = expandHomePath(value, home);
|
|
360
|
+
if (!value.trim() || !isAbsolute(expanded)) {
|
|
361
|
+
throw new Error(`${name} must be a non-empty absolute path (~/ is supported).`);
|
|
362
|
+
}
|
|
363
|
+
return resolve(expanded);
|
|
364
|
+
}
|
|
365
|
+
function canonicalPath(path) {
|
|
366
|
+
try {
|
|
367
|
+
return realpathSync(path);
|
|
368
|
+
} catch (error) {
|
|
369
|
+
if (error.code !== "ENOENT")
|
|
370
|
+
throw error;
|
|
371
|
+
}
|
|
372
|
+
try {
|
|
373
|
+
if (lstatSync(path).isSymbolicLink())
|
|
374
|
+
return canonicalPath(resolve(dirname(path), readlinkSync(path)));
|
|
375
|
+
} catch (error) {
|
|
376
|
+
if (error.code !== "ENOENT")
|
|
377
|
+
throw error;
|
|
378
|
+
}
|
|
379
|
+
const parent = dirname(path);
|
|
380
|
+
return parent === path ? path : join(canonicalPath(parent), relative(parent, path));
|
|
381
|
+
}
|
|
382
|
+
function assertProductStatePath(path, home = homedir()) {
|
|
383
|
+
const canonical = canonicalPath(resolve(path));
|
|
384
|
+
for (const directory of [".prime", ".pi", ".prime-context"]) {
|
|
385
|
+
const legacy = canonicalPath(join(home, directory));
|
|
386
|
+
const rel = relative(legacy, canonical);
|
|
387
|
+
if (resolve(path).split(sep).includes(directory) || canonical.split(sep).includes(directory) || rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)) {
|
|
388
|
+
throw new Error(`Base Context cannot write legacy state at ${path}. Choose a separate BASE_CONTEXT_HOME; use explicit import for legacy data.`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return resolve(path);
|
|
392
|
+
}
|
|
393
|
+
function resolveRuntimePaths(env = process.env, home = homedir(), cwd = process.cwd()) {
|
|
394
|
+
const root = assertProductStatePath(readAbsolutePathEnv(PRODUCT_ENV.home, env, home) ?? join(home, PRODUCT.configDirectory), home);
|
|
395
|
+
const sessions = assertProductStatePath(readAbsolutePathEnv(PRODUCT_ENV.sessions, env, home) ?? join(root, "sessions"), home);
|
|
396
|
+
return Object.freeze({
|
|
397
|
+
home: root,
|
|
398
|
+
project: assertProductStatePath(join(cwd, PRODUCT.configDirectory), home),
|
|
399
|
+
sessions,
|
|
400
|
+
runtime: assertProductStatePath(join(root, "runtime"), home),
|
|
401
|
+
auth: assertProductStatePath(join(root, "auth.json"), home),
|
|
402
|
+
daemonRegistry: assertProductStatePath(join(root, "daemon-supervisors"), home)
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// dist/utils/daemon-socket-path.js
|
|
407
|
+
import { resolve as resolve2 } from "node:path";
|
|
408
|
+
function normalizeSocketPath(socketPath, baseDir) {
|
|
409
|
+
if (process.platform === "win32") {
|
|
410
|
+
return socketPath.toLowerCase();
|
|
411
|
+
}
|
|
412
|
+
return baseDir ? resolve2(baseDir, socketPath) : resolve2(socketPath);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// dist/config.js
|
|
416
|
+
import { spawnSync } from "child_process";
|
|
417
|
+
import { createHash } from "crypto";
|
|
418
|
+
import { accessSync, appendFileSync, constants as constants2, existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, renameSync, rmSync, statSync } from "fs";
|
|
419
|
+
import { homedir as homedir2 } from "os";
|
|
420
|
+
import { basename as basename2, dirname as dirname2, join as join2, resolve as resolve3, sep as sep2, win32 } from "path";
|
|
421
|
+
import { fileURLToPath } from "url";
|
|
422
|
+
|
|
423
|
+
// dist/utils/child-process.js
|
|
424
|
+
import { execFileSync } from "node:child_process";
|
|
425
|
+
import { readFileSync } from "node:fs";
|
|
426
|
+
import { constants } from "node:os";
|
|
427
|
+
import { basename } from "node:path";
|
|
428
|
+
var EXIT_STDIO_GRACE_MS = 100;
|
|
429
|
+
var WINDOWS_SHELL_COMMANDS = /* @__PURE__ */ new Set(["npm", "npx", "pnpm", "yarn", "yarnpkg", "corepack"]);
|
|
430
|
+
function shouldUseWindowsShell(command) {
|
|
431
|
+
if (process.platform !== "win32")
|
|
432
|
+
return false;
|
|
433
|
+
const commandName = basename(command).toLowerCase();
|
|
434
|
+
return commandName.endsWith(".cmd") || commandName.endsWith(".bat") || WINDOWS_SHELL_COMMANDS.has(commandName);
|
|
435
|
+
}
|
|
436
|
+
function processIdExists(pid) {
|
|
437
|
+
try {
|
|
438
|
+
process.kill(pid, 0);
|
|
439
|
+
return true;
|
|
440
|
+
} catch (error) {
|
|
441
|
+
return error.code === "EPERM";
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function isZombieProcess(pid) {
|
|
445
|
+
if (process.platform === "win32") {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
try {
|
|
449
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
450
|
+
const state = stat.slice(stat.lastIndexOf(")") + 2).trimStart().charAt(0);
|
|
451
|
+
return state === "Z";
|
|
452
|
+
} catch {
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
const state = execFileSync("ps", ["-p", String(pid), "-o", "stat="], { encoding: "utf8" }).trim();
|
|
456
|
+
return state.startsWith("Z");
|
|
457
|
+
} catch {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function isProcessAlive(pid) {
|
|
462
|
+
return processIdExists(pid) && !isZombieProcess(pid);
|
|
463
|
+
}
|
|
464
|
+
function signalProcessGroupOrProcess(pid, signal) {
|
|
465
|
+
try {
|
|
466
|
+
process.kill(-pid, signal);
|
|
467
|
+
return;
|
|
468
|
+
} catch {
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
process.kill(pid, signal);
|
|
472
|
+
} catch {
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function signalExitCode(signal) {
|
|
476
|
+
if (!signal)
|
|
477
|
+
return null;
|
|
478
|
+
const signalNumber = constants.signals[signal];
|
|
479
|
+
return signalNumber === void 0 ? 1 : 128 + signalNumber;
|
|
480
|
+
}
|
|
481
|
+
function normalizedExitCode(code, signal) {
|
|
482
|
+
return code ?? signalExitCode(signal);
|
|
483
|
+
}
|
|
484
|
+
function waitForChildProcess(child) {
|
|
485
|
+
return new Promise((resolve4, reject) => {
|
|
486
|
+
let settled = false;
|
|
487
|
+
let exited = false;
|
|
488
|
+
let exitCode = null;
|
|
489
|
+
let exitSignal = null;
|
|
490
|
+
let postExitTimer;
|
|
491
|
+
let stdoutEnded = child.stdout === null || child.stdout.readableEnded;
|
|
492
|
+
let stderrEnded = child.stderr === null || child.stderr.readableEnded;
|
|
493
|
+
const cleanup = () => {
|
|
494
|
+
if (postExitTimer) {
|
|
495
|
+
clearTimeout(postExitTimer);
|
|
496
|
+
postExitTimer = void 0;
|
|
497
|
+
}
|
|
498
|
+
child.removeListener("error", onError);
|
|
499
|
+
child.removeListener("exit", onExit);
|
|
500
|
+
child.removeListener("close", onClose);
|
|
501
|
+
child.stdout?.removeListener("end", onStdoutEnd);
|
|
502
|
+
child.stderr?.removeListener("end", onStderrEnd);
|
|
503
|
+
};
|
|
504
|
+
const finalize = (code) => {
|
|
505
|
+
if (settled)
|
|
506
|
+
return;
|
|
507
|
+
settled = true;
|
|
508
|
+
cleanup();
|
|
509
|
+
child.stdout?.destroy();
|
|
510
|
+
child.stderr?.destroy();
|
|
511
|
+
resolve4(code);
|
|
512
|
+
};
|
|
513
|
+
const maybeFinalizeAfterExit = () => {
|
|
514
|
+
if (!exited || settled)
|
|
515
|
+
return;
|
|
516
|
+
if (stdoutEnded && stderrEnded) {
|
|
517
|
+
finalize(normalizedExitCode(exitCode, exitSignal));
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
const onStdoutEnd = () => {
|
|
521
|
+
stdoutEnded = true;
|
|
522
|
+
maybeFinalizeAfterExit();
|
|
523
|
+
};
|
|
524
|
+
const onStderrEnd = () => {
|
|
525
|
+
stderrEnded = true;
|
|
526
|
+
maybeFinalizeAfterExit();
|
|
527
|
+
};
|
|
528
|
+
const onError = (err) => {
|
|
529
|
+
if (settled)
|
|
530
|
+
return;
|
|
531
|
+
settled = true;
|
|
532
|
+
cleanup();
|
|
533
|
+
reject(err);
|
|
534
|
+
};
|
|
535
|
+
const onExit = (code, signal = null) => {
|
|
536
|
+
exited = true;
|
|
537
|
+
exitCode = code;
|
|
538
|
+
exitSignal = signal;
|
|
539
|
+
maybeFinalizeAfterExit();
|
|
540
|
+
if (!settled) {
|
|
541
|
+
postExitTimer = setTimeout(() => finalize(normalizedExitCode(code, signal)), EXIT_STDIO_GRACE_MS);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const onClose = (code, signal = null) => {
|
|
545
|
+
finalize(normalizedExitCode(code, signal));
|
|
546
|
+
};
|
|
547
|
+
child.stdout?.once("end", onStdoutEnd);
|
|
548
|
+
child.stderr?.once("end", onStderrEnd);
|
|
549
|
+
child.once("error", onError);
|
|
550
|
+
child.once("exit", onExit);
|
|
551
|
+
child.once("close", onClose);
|
|
552
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
553
|
+
onExit(child.exitCode, child.signalCode);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// dist/config.js
|
|
559
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
560
|
+
var __dirname = dirname2(__filename);
|
|
561
|
+
var isBunBinary = import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
|
|
562
|
+
var isBunRuntime = !!process.versions.bun;
|
|
563
|
+
var SELF_UPDATE_INTERACTIVE_CHILD_ENV = PRODUCT_ENV.interactiveSelfUpdate;
|
|
564
|
+
var SELF_UPDATE_NOT_ATTEMPTED_EXIT_CODE = 75;
|
|
565
|
+
function makeSelfUpdateCommand(installStep, uninstallStep, options = {}) {
|
|
566
|
+
if (!uninstallStep)
|
|
567
|
+
return installStep;
|
|
568
|
+
if (options.uninstallAfterInstall) {
|
|
569
|
+
return {
|
|
570
|
+
...installStep,
|
|
571
|
+
display: `${installStep.display} && ${uninstallStep.display}`,
|
|
572
|
+
steps: [installStep, uninstallStep]
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
...installStep,
|
|
577
|
+
display: `${uninstallStep.display} && ${installStep.display}`,
|
|
578
|
+
steps: [uninstallStep, installStep]
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function makeSelfUpdateCommandStep(command, args) {
|
|
582
|
+
return {
|
|
583
|
+
command,
|
|
584
|
+
args,
|
|
585
|
+
display: [command, ...args].map((arg) => /\s/.test(arg) ? `"${arg}"` : arg).join(" ")
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function detectInstallMethod() {
|
|
589
|
+
if (isBunBinary) {
|
|
590
|
+
return "bun-binary";
|
|
591
|
+
}
|
|
592
|
+
if (isHomebrewInstall()) {
|
|
593
|
+
return "homebrew";
|
|
594
|
+
}
|
|
595
|
+
const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase().replace(/\\/g, "/");
|
|
596
|
+
if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/")) {
|
|
597
|
+
return "pnpm";
|
|
598
|
+
}
|
|
599
|
+
if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/")) {
|
|
600
|
+
return "yarn";
|
|
601
|
+
}
|
|
602
|
+
if (isBunRuntime || resolvedPath.includes("/install/global/node_modules/")) {
|
|
603
|
+
return "bun";
|
|
604
|
+
}
|
|
605
|
+
if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/")) {
|
|
606
|
+
return "npm";
|
|
607
|
+
}
|
|
608
|
+
return "unknown";
|
|
609
|
+
}
|
|
610
|
+
function isHomebrewInstall() {
|
|
611
|
+
const packageDir = getPackageDir().toLowerCase().replace(/\\/g, "/");
|
|
612
|
+
return packageDir.includes("/cellar/") && packageDir.includes("/libexec/lib/node_modules/");
|
|
613
|
+
}
|
|
614
|
+
function getInferredNpmInstall() {
|
|
615
|
+
const packageDir = getPackageDir();
|
|
616
|
+
const path = process.platform === "win32" || packageDir.includes("\\") ? win32 : { basename: basename2, dirname: dirname2 };
|
|
617
|
+
const parent = path.dirname(packageDir);
|
|
618
|
+
let root;
|
|
619
|
+
if (path.basename(parent).startsWith("@") && path.basename(path.dirname(parent)) === "node_modules") {
|
|
620
|
+
root = path.dirname(parent);
|
|
621
|
+
} else if (path.basename(parent) === "node_modules") {
|
|
622
|
+
root = parent;
|
|
623
|
+
}
|
|
624
|
+
if (!root)
|
|
625
|
+
return void 0;
|
|
626
|
+
const rootParent = path.dirname(root);
|
|
627
|
+
if (path.basename(rootParent) === "lib")
|
|
628
|
+
return { root, prefix: path.dirname(rootParent) };
|
|
629
|
+
return void 0;
|
|
630
|
+
}
|
|
631
|
+
function isDirectPackageArtifactSpec(updateSpec) {
|
|
632
|
+
const spec = updateSpec.trim().toLowerCase();
|
|
633
|
+
return spec.startsWith("http://") || spec.startsWith("https://") || spec.startsWith("file:") || spec.endsWith(".tgz") || spec.endsWith(".tar.gz");
|
|
634
|
+
}
|
|
635
|
+
function getDefaultUpdatePackageName(installedPackageName, updateSpec) {
|
|
636
|
+
if (isDirectPackageArtifactSpec(updateSpec)) {
|
|
637
|
+
return installedPackageName;
|
|
638
|
+
}
|
|
639
|
+
return updateSpec;
|
|
640
|
+
}
|
|
641
|
+
function getSelfUpdateCommandForMethod(method, installedPackageName, updateSpec = installedPackageName, npmCommand, updatePackageName = getDefaultUpdatePackageName(installedPackageName, updateSpec)) {
|
|
642
|
+
const uninstallAfterInstall = isDirectPackageArtifactSpec(updateSpec);
|
|
643
|
+
switch (method) {
|
|
644
|
+
case "bun-binary":
|
|
645
|
+
case "homebrew":
|
|
646
|
+
return void 0;
|
|
647
|
+
case "pnpm":
|
|
648
|
+
return makeSelfUpdateCommand(makeSelfUpdateCommandStep("pnpm", ["install", "-g", updateSpec]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("pnpm", ["remove", "-g", installedPackageName]), { uninstallAfterInstall });
|
|
649
|
+
case "yarn":
|
|
650
|
+
return makeSelfUpdateCommand(makeSelfUpdateCommandStep("yarn", ["global", "add", updateSpec]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("yarn", ["global", "remove", installedPackageName]), { uninstallAfterInstall });
|
|
651
|
+
case "bun":
|
|
652
|
+
return makeSelfUpdateCommand(makeSelfUpdateCommandStep("bun", ["install", "-g", updateSpec]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("bun", ["uninstall", "-g", installedPackageName]), { uninstallAfterInstall });
|
|
653
|
+
case "npm": {
|
|
654
|
+
const [command = "npm", ...npmArgs] = npmCommand ?? [];
|
|
655
|
+
const inferred = npmCommand?.length ? void 0 : getInferredNpmInstall();
|
|
656
|
+
const prefixArgs = [...npmArgs, ...inferred ? ["--prefix", inferred.prefix] : []];
|
|
657
|
+
const installStep = makeSelfUpdateCommandStep(command, [...prefixArgs, "install", "-g", updateSpec]);
|
|
658
|
+
const uninstallStep = updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep(command, [...prefixArgs, "uninstall", "-g", installedPackageName]);
|
|
659
|
+
return makeSelfUpdateCommand(installStep, uninstallStep, { uninstallAfterInstall });
|
|
660
|
+
}
|
|
661
|
+
case "unknown":
|
|
662
|
+
return void 0;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
function readCommandOutput(command, args, options = {}) {
|
|
666
|
+
const result = spawnSync(command, args, {
|
|
667
|
+
encoding: "utf-8",
|
|
668
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
669
|
+
shell: shouldUseWindowsShell(command)
|
|
670
|
+
});
|
|
671
|
+
if (result.status === 0)
|
|
672
|
+
return result.stdout.trim() || void 0;
|
|
673
|
+
if (options.requireSuccess) {
|
|
674
|
+
const reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? "unknown"}`;
|
|
675
|
+
throw new Error(`Failed to run ${[command, ...args].join(" ")}: ${reason}`);
|
|
676
|
+
}
|
|
677
|
+
return void 0;
|
|
678
|
+
}
|
|
679
|
+
function getGlobalPackageRoots(method, _packageName, npmCommand) {
|
|
680
|
+
switch (method) {
|
|
681
|
+
case "npm": {
|
|
682
|
+
const configured = !!npmCommand?.length;
|
|
683
|
+
const [command = "npm", ...npmArgs] = npmCommand ?? [];
|
|
684
|
+
if (configured && command === "bun") {
|
|
685
|
+
const bunBin = readCommandOutput(command, [...npmArgs, "pm", "bin", "-g"], {
|
|
686
|
+
requireSuccess: true
|
|
687
|
+
});
|
|
688
|
+
const roots = [join2(homedir2(), ".bun", "install", "global", "node_modules")];
|
|
689
|
+
if (bunBin) {
|
|
690
|
+
roots.push(join2(dirname2(bunBin), "install", "global", "node_modules"));
|
|
691
|
+
}
|
|
692
|
+
return roots;
|
|
693
|
+
}
|
|
694
|
+
const root = readCommandOutput(command, [...npmArgs, "root", "-g"], {
|
|
695
|
+
requireSuccess: configured
|
|
696
|
+
});
|
|
697
|
+
const inferred = configured ? void 0 : getInferredNpmInstall();
|
|
698
|
+
return [root, inferred?.root].filter((x) => !!x);
|
|
699
|
+
}
|
|
700
|
+
case "pnpm": {
|
|
701
|
+
const root = readCommandOutput("pnpm", ["root", "-g"]);
|
|
702
|
+
return root ? [root, dirname2(root)] : [];
|
|
703
|
+
}
|
|
704
|
+
case "yarn": {
|
|
705
|
+
const dir = readCommandOutput("yarn", ["global", "dir"]);
|
|
706
|
+
return dir ? [dir, join2(dir, "node_modules")] : [];
|
|
707
|
+
}
|
|
708
|
+
case "bun": {
|
|
709
|
+
const bunBin = readCommandOutput("bun", ["pm", "bin", "-g"]);
|
|
710
|
+
const roots = [join2(homedir2(), ".bun", "install", "global", "node_modules")];
|
|
711
|
+
if (bunBin) {
|
|
712
|
+
roots.push(join2(dirname2(bunBin), "install", "global", "node_modules"));
|
|
713
|
+
}
|
|
714
|
+
return roots;
|
|
715
|
+
}
|
|
716
|
+
case "bun-binary":
|
|
717
|
+
case "homebrew":
|
|
718
|
+
case "unknown":
|
|
719
|
+
return [];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function normalizeExistingPathForComparison(path) {
|
|
723
|
+
const resolvedPath = resolve3(path);
|
|
724
|
+
if (!existsSync(resolvedPath)) {
|
|
725
|
+
return void 0;
|
|
726
|
+
}
|
|
727
|
+
let normalizedPath;
|
|
728
|
+
try {
|
|
729
|
+
normalizedPath = realpathSync2(resolvedPath);
|
|
730
|
+
} catch {
|
|
731
|
+
return void 0;
|
|
732
|
+
}
|
|
733
|
+
if (process.platform === "win32") {
|
|
734
|
+
normalizedPath = normalizedPath.toLowerCase();
|
|
735
|
+
}
|
|
736
|
+
return normalizedPath;
|
|
737
|
+
}
|
|
738
|
+
function isSelfUpdatePathWritable() {
|
|
739
|
+
const packageDir = getPackageDir();
|
|
740
|
+
try {
|
|
741
|
+
accessSync(packageDir, constants2.W_OK);
|
|
742
|
+
accessSync(dirname2(packageDir), constants2.W_OK);
|
|
743
|
+
return true;
|
|
744
|
+
} catch {
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function isManagedByGlobalPackageManager(method, packageName, npmCommand) {
|
|
749
|
+
const packageDir = normalizeExistingPathForComparison(getPackageDir());
|
|
750
|
+
return !!packageDir && getGlobalPackageRoots(method, packageName, npmCommand).some((root) => {
|
|
751
|
+
const normalizedRoot = normalizeExistingPathForComparison(root);
|
|
752
|
+
return !!normalizedRoot && packageDir.startsWith(normalizedRoot.endsWith(sep2) ? normalizedRoot : `${normalizedRoot}${sep2}`);
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
function getSelfUpdateCommand(packageName, npmCommand, updateSpec = packageName, updatePackageName = getDefaultUpdatePackageName(packageName, updateSpec)) {
|
|
756
|
+
const method = detectInstallMethod();
|
|
757
|
+
const command = getSelfUpdateCommandForMethod(method, packageName, updateSpec, npmCommand, updatePackageName);
|
|
758
|
+
if (!command || !isManagedByGlobalPackageManager(method, packageName, npmCommand) || !isSelfUpdatePathWritable()) {
|
|
759
|
+
return void 0;
|
|
760
|
+
}
|
|
761
|
+
return command;
|
|
762
|
+
}
|
|
763
|
+
function getSelfUpdateUnavailableInstruction(packageName, npmCommand, updateSpec = packageName, updatePackageName = getDefaultUpdatePackageName(packageName, updateSpec)) {
|
|
764
|
+
const method = detectInstallMethod();
|
|
765
|
+
if (method === "bun-binary") {
|
|
766
|
+
return `Download from: ${PRODUCT.repository}/releases/latest`;
|
|
767
|
+
}
|
|
768
|
+
if (method === "homebrew") {
|
|
769
|
+
return `Update with: brew upgrade ${APP_NAME}`;
|
|
770
|
+
}
|
|
771
|
+
const command = getSelfUpdateCommandForMethod(method, packageName, updateSpec, npmCommand, updatePackageName);
|
|
772
|
+
if (command) {
|
|
773
|
+
if (isManagedByGlobalPackageManager(method, packageName, npmCommand) && !isSelfUpdatePathWritable()) {
|
|
774
|
+
return `This installation is managed by a global ${method} install, but the install path is not writable. Update it yourself with: ${command.display}`;
|
|
775
|
+
}
|
|
776
|
+
return `This installation is not managed by a global ${method} install. Update it with the package manager, wrapper, or source checkout that provides it.`;
|
|
777
|
+
}
|
|
778
|
+
return `Update ${updateSpec} using the package manager, wrapper, or source checkout that provides this installation.`;
|
|
779
|
+
}
|
|
780
|
+
function getPackageDir() {
|
|
781
|
+
const envDir = process.env[PRODUCT_ENV.packageDirectory];
|
|
782
|
+
if (envDir) {
|
|
783
|
+
if (envDir === "~")
|
|
784
|
+
return homedir2();
|
|
785
|
+
if (envDir.startsWith("~/"))
|
|
786
|
+
return homedir2() + envDir.slice(1);
|
|
787
|
+
return envDir;
|
|
788
|
+
}
|
|
789
|
+
return getPhysicalPackageDir();
|
|
790
|
+
}
|
|
791
|
+
function getPhysicalPackageDir() {
|
|
792
|
+
if (isBunBinary) {
|
|
793
|
+
return dirname2(process.execPath);
|
|
794
|
+
}
|
|
795
|
+
let dir = __dirname;
|
|
796
|
+
while (dir !== dirname2(dir)) {
|
|
797
|
+
if (existsSync(join2(dir, "package.json"))) {
|
|
798
|
+
return dir;
|
|
799
|
+
}
|
|
800
|
+
dir = dirname2(dir);
|
|
801
|
+
}
|
|
802
|
+
return __dirname;
|
|
803
|
+
}
|
|
804
|
+
function getThemesDir() {
|
|
805
|
+
if (isBunBinary) {
|
|
806
|
+
return join2(getPackageDir(), "theme");
|
|
807
|
+
}
|
|
808
|
+
const packageDir = getPackageDir();
|
|
809
|
+
const srcOrDist = existsSync(join2(packageDir, "src")) ? "src" : "dist";
|
|
810
|
+
return join2(packageDir, srcOrDist, "modes", "interactive", "theme");
|
|
811
|
+
}
|
|
812
|
+
function getExportTemplateDir() {
|
|
813
|
+
if (isBunBinary) {
|
|
814
|
+
return join2(getPackageDir(), "export-html");
|
|
815
|
+
}
|
|
816
|
+
const packageDir = getPackageDir();
|
|
817
|
+
const srcOrDist = existsSync(join2(packageDir, "src")) ? "src" : "dist";
|
|
818
|
+
return join2(packageDir, srcOrDist, "core", "export-html");
|
|
819
|
+
}
|
|
820
|
+
function getPackageJsonPath() {
|
|
821
|
+
return join2(getPackageDir(), "package.json");
|
|
822
|
+
}
|
|
823
|
+
function getDocsPath() {
|
|
824
|
+
return resolve3(join2(getPackageDir(), "docs"));
|
|
825
|
+
}
|
|
826
|
+
function getChangelogPath() {
|
|
827
|
+
return resolve3(join2(getPackageDir(), "CHANGELOG.md"));
|
|
828
|
+
}
|
|
829
|
+
function getInteractiveAssetsDir() {
|
|
830
|
+
if (isBunBinary) {
|
|
831
|
+
return join2(getPackageDir(), "assets");
|
|
832
|
+
}
|
|
833
|
+
const packageDir = getPackageDir();
|
|
834
|
+
const srcOrDist = existsSync(join2(packageDir, "src")) ? "src" : "dist";
|
|
835
|
+
return join2(packageDir, srcOrDist, "modes", "interactive", "assets");
|
|
836
|
+
}
|
|
837
|
+
function getBundledInteractiveAssetPath(name) {
|
|
838
|
+
return join2(getInteractiveAssetsDir(), name);
|
|
839
|
+
}
|
|
840
|
+
function getBundledSkillsDir() {
|
|
841
|
+
if (isBunBinary) {
|
|
842
|
+
return join2(getPackageDir(), "skills");
|
|
843
|
+
}
|
|
844
|
+
const packageDir = getPackageDir();
|
|
845
|
+
const isSourceCheckout = existsSync(join2(packageDir, "src"));
|
|
846
|
+
return isSourceCheckout ? join2(packageDir, "skills") : join2(packageDir, "dist", "skills");
|
|
847
|
+
}
|
|
848
|
+
var pkg = JSON.parse(readFileSync2(getPackageJsonPath(), "utf-8"));
|
|
849
|
+
var PACKAGE_NAME = PRODUCT.packageName;
|
|
850
|
+
var APP_NAME = PRODUCT.command;
|
|
851
|
+
var APP_TITLE = PRODUCT.name;
|
|
852
|
+
var CONFIG_DIR_NAME = PRODUCT.configDirectory;
|
|
853
|
+
var VERSION = pkg.version || "0.0.0";
|
|
854
|
+
var ENV_AGENT_DIR = PRODUCT_ENV.home;
|
|
855
|
+
var ENV_SESSION_DIR = PRODUCT_ENV.sessions;
|
|
856
|
+
function expandTildePath(path) {
|
|
857
|
+
return expandHomePath(path);
|
|
858
|
+
}
|
|
859
|
+
function getAgentDir() {
|
|
860
|
+
return resolveRuntimePaths().home;
|
|
861
|
+
}
|
|
862
|
+
function getCustomThemesDir() {
|
|
863
|
+
return join2(getAgentDir(), "themes");
|
|
864
|
+
}
|
|
865
|
+
function getLogsDir() {
|
|
866
|
+
return join2(getAgentDir(), "logs");
|
|
867
|
+
}
|
|
868
|
+
function getClientErrorLogPath() {
|
|
869
|
+
return join2(getLogsDir(), "client-errors.log");
|
|
870
|
+
}
|
|
871
|
+
function getAgentLogPath() {
|
|
872
|
+
return join2(getLogsDir(), "agent.jsonl");
|
|
873
|
+
}
|
|
874
|
+
function getDaemonLogPath(socketPath) {
|
|
875
|
+
const normalized = normalizeSocketPath(socketPath);
|
|
876
|
+
const hash = createHash("sha256").update(normalized).digest("hex").slice(0, 8);
|
|
877
|
+
return join2(getLogsDir(), `${basename2(normalized)}.${hash}.log`);
|
|
878
|
+
}
|
|
879
|
+
function getDaemonUpdateRestartManifestPath(socketPath, agentDir = getAgentDir()) {
|
|
880
|
+
const normalizedSocketPath = normalizeSocketPath(socketPath);
|
|
881
|
+
const socketHash = createHash("sha256").update(normalizedSocketPath).digest("hex");
|
|
882
|
+
return join2(agentDir, "daemon-update-restarts", `${socketHash}.json`);
|
|
883
|
+
}
|
|
884
|
+
function getLegacyDaemonUpdateRestartManifestPath(agentDir = getAgentDir()) {
|
|
885
|
+
return join2(agentDir, "daemon-update-restart.json");
|
|
886
|
+
}
|
|
887
|
+
var MAX_LOG_BYTES = 5 * 1024 * 1024;
|
|
888
|
+
function appendRotatingLog(logPath, message, maxBytes = MAX_LOG_BYTES) {
|
|
889
|
+
try {
|
|
890
|
+
mkdirSync(dirname2(logPath), { recursive: true });
|
|
891
|
+
try {
|
|
892
|
+
if (existsSync(logPath) && statSync(logPath).size > maxBytes) {
|
|
893
|
+
rmSync(`${logPath}.old`, { force: true });
|
|
894
|
+
renameSync(logPath, `${logPath}.old`);
|
|
895
|
+
}
|
|
896
|
+
} catch {
|
|
897
|
+
}
|
|
898
|
+
appendFileSync(logPath, `${message}
|
|
899
|
+
`);
|
|
900
|
+
} catch {
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
function getAuthPath() {
|
|
904
|
+
return resolveRuntimePaths().auth;
|
|
905
|
+
}
|
|
906
|
+
function getCronJobsPath(agentDir = getAgentDir()) {
|
|
907
|
+
return join2(agentDir, "cron-jobs.json");
|
|
908
|
+
}
|
|
909
|
+
function getBinDir() {
|
|
910
|
+
return join2(getAgentDir(), "bin");
|
|
911
|
+
}
|
|
912
|
+
function getSessionsDir(agentDir = getAgentDir()) {
|
|
913
|
+
const envDir = getSessionDirEnvOverride();
|
|
914
|
+
if (envDir) {
|
|
915
|
+
return envDir;
|
|
916
|
+
}
|
|
917
|
+
return join2(agentDir, "sessions");
|
|
918
|
+
}
|
|
919
|
+
function getSessionDirEnvOverride() {
|
|
920
|
+
const envDir = readAbsolutePathEnv(PRODUCT_ENV.sessions);
|
|
921
|
+
return envDir ? assertProductStatePath(envDir) : void 0;
|
|
922
|
+
}
|
|
923
|
+
function getDebugLogPath() {
|
|
924
|
+
return join2(getAgentDir(), `${APP_NAME}-debug.log`);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// ../../node_modules/typebox/build/index.mjs
|
|
928
|
+
var build_exports = {};
|
|
929
|
+
__export(build_exports, {
|
|
930
|
+
AddImmutable: () => AddImmutable,
|
|
931
|
+
AddImmutableDeferred: () => AddImmutableDeferred,
|
|
932
|
+
AddOptional: () => AddOptional,
|
|
933
|
+
AddOptionalDeferred: () => AddOptionalDeferred,
|
|
934
|
+
AddReadonly: () => AddReadonly,
|
|
935
|
+
AddReadonlyDeferred: () => AddReadonlyDeferred,
|
|
936
|
+
Any: () => Any,
|
|
937
|
+
Array: () => _Array_,
|
|
938
|
+
ArrayOptions: () => ArrayOptions,
|
|
939
|
+
BigInt: () => BigInt,
|
|
940
|
+
BigIntPattern: () => BigIntPattern,
|
|
941
|
+
Boolean: () => Boolean,
|
|
942
|
+
Broaden: () => Broaden,
|
|
943
|
+
Call: () => Call,
|
|
944
|
+
CallConstruct: () => CallConstruct,
|
|
945
|
+
Capitalize: () => Capitalize,
|
|
946
|
+
CapitalizeAction: () => CapitalizeAction,
|
|
947
|
+
CapitalizeDeferred: () => CapitalizeDeferred,
|
|
948
|
+
CapitalizeInstantiate: () => CapitalizeInstantiate,
|
|
949
|
+
Codec: () => Codec,
|
|
950
|
+
CollapseToObject: () => CollapseToObject,
|
|
951
|
+
Compare: () => Compare,
|
|
952
|
+
Composite: () => Composite,
|
|
953
|
+
Conditional: () => Conditional,
|
|
954
|
+
ConditionalAction: () => ConditionalAction,
|
|
955
|
+
ConditionalDeferred: () => ConditionalDeferred,
|
|
956
|
+
ConditionalInstantiate: () => ConditionalInstantiate,
|
|
957
|
+
Constructor: () => Constructor,
|
|
958
|
+
ConstructorOptions: () => ConstructorOptions,
|
|
959
|
+
ConstructorParameters: () => ConstructorParameters,
|
|
960
|
+
ConstructorParametersAction: () => ConstructorParametersAction,
|
|
961
|
+
ConstructorParametersDeferred: () => ConstructorParametersDeferred,
|
|
962
|
+
ConstructorParametersInstantiate: () => ConstructorParametersInstantiate,
|
|
963
|
+
ConvertToIntegerKey: () => ConvertToIntegerKey,
|
|
964
|
+
Cyclic: () => Cyclic,
|
|
965
|
+
CyclicCandidates: () => CyclicCandidates,
|
|
966
|
+
CyclicCheck: () => CyclicCheck,
|
|
967
|
+
CyclicDependencies: () => CyclicDependencies,
|
|
968
|
+
CyclicExtends: () => CyclicExtends,
|
|
969
|
+
CyclicOptions: () => CyclicOptions,
|
|
970
|
+
CyclicTarget: () => CyclicTarget,
|
|
971
|
+
Decode: () => Decode,
|
|
972
|
+
DecodeBuilder: () => DecodeBuilder,
|
|
973
|
+
Deferred: () => Deferred,
|
|
974
|
+
Dependent: () => Dependent,
|
|
975
|
+
DependentOptions: () => DependentOptions,
|
|
976
|
+
Distribute: () => Distribute,
|
|
977
|
+
Encode: () => Encode,
|
|
978
|
+
EncodeBuilder: () => EncodeBuilder,
|
|
979
|
+
Enum: () => Enum,
|
|
980
|
+
Evaluate: () => Evaluate,
|
|
981
|
+
EvaluateAction: () => EvaluateAction,
|
|
982
|
+
EvaluateDeferred: () => EvaluateDeferred,
|
|
983
|
+
EvaluateDependent: () => EvaluateDependent,
|
|
984
|
+
EvaluateEnum: () => EvaluateEnum,
|
|
985
|
+
EvaluateInstantiate: () => EvaluateInstantiate,
|
|
986
|
+
EvaluateIntersect: () => EvaluateIntersect,
|
|
987
|
+
EvaluateTemplateLiteral: () => EvaluateTemplateLiteral,
|
|
988
|
+
EvaluateType: () => EvaluateType,
|
|
989
|
+
EvaluateUnion: () => EvaluateUnion,
|
|
990
|
+
EvaluateUnionFast: () => EvaluateUnionFast,
|
|
991
|
+
Exclude: () => Exclude,
|
|
992
|
+
ExcludeAction: () => ExcludeAction,
|
|
993
|
+
ExcludeDeferred: () => ExcludeDeferred,
|
|
994
|
+
ExcludeInstantiate: () => ExcludeInstantiate,
|
|
995
|
+
Extends: () => Extends,
|
|
996
|
+
ExtendsResult: () => result_exports,
|
|
997
|
+
Extract: () => Extract,
|
|
998
|
+
ExtractAction: () => ExtractAction,
|
|
999
|
+
ExtractDeferred: () => ExtractDeferred,
|
|
1000
|
+
ExtractInstantiate: () => ExtractInstantiate,
|
|
1001
|
+
Flatten: () => Flatten,
|
|
1002
|
+
Function: () => _Function_,
|
|
1003
|
+
FunctionOptions: () => FunctionOptions,
|
|
1004
|
+
Generic: () => Generic,
|
|
1005
|
+
Identifier: () => Identifier,
|
|
1006
|
+
Immutable: () => Immutable,
|
|
1007
|
+
Index: () => Index,
|
|
1008
|
+
IndexAction: () => IndexAction,
|
|
1009
|
+
IndexDeferred: () => IndexDeferred,
|
|
1010
|
+
IndexInstantiate: () => IndexInstantiate,
|
|
1011
|
+
Infer: () => Infer,
|
|
1012
|
+
InstanceType: () => InstanceType,
|
|
1013
|
+
InstanceTypeAction: () => InstanceTypeAction,
|
|
1014
|
+
InstanceTypeDeferred: () => InstanceTypeDeferred,
|
|
1015
|
+
InstanceTypeInstantiate: () => InstanceTypeInstantiate,
|
|
1016
|
+
Instantiate: () => Instantiate,
|
|
1017
|
+
InstantiateCyclic: () => InstantiateCyclic,
|
|
1018
|
+
Integer: () => Integer,
|
|
1019
|
+
IntegerKey: () => IntegerKey,
|
|
1020
|
+
IntegerPattern: () => IntegerPattern,
|
|
1021
|
+
Interface: () => Interface,
|
|
1022
|
+
InterfaceAction: () => InterfaceAction,
|
|
1023
|
+
InterfaceDeferred: () => InterfaceDeferred,
|
|
1024
|
+
InterfaceInstantiate: () => InterfaceInstantiate,
|
|
1025
|
+
Intersect: () => Intersect,
|
|
1026
|
+
IntersectOptions: () => IntersectOptions,
|
|
1027
|
+
InvalidLiteralValue: () => InvalidLiteralValue,
|
|
1028
|
+
IsAny: () => IsAny,
|
|
1029
|
+
IsArray: () => IsArray,
|
|
1030
|
+
IsBigInt: () => IsBigInt,
|
|
1031
|
+
IsBoolean: () => IsBoolean,
|
|
1032
|
+
IsCall: () => IsCall,
|
|
1033
|
+
IsCodec: () => IsCodec,
|
|
1034
|
+
IsConstructor: () => IsConstructor,
|
|
1035
|
+
IsCyclic: () => IsCyclic,
|
|
1036
|
+
IsDeferred: () => IsDeferred,
|
|
1037
|
+
IsDependent: () => IsDependent,
|
|
1038
|
+
IsEnum: () => IsEnum,
|
|
1039
|
+
IsEnumValue: () => IsEnumValue,
|
|
1040
|
+
IsFunction: () => IsFunction,
|
|
1041
|
+
IsGeneric: () => IsGeneric,
|
|
1042
|
+
IsIdentifier: () => IsIdentifier,
|
|
1043
|
+
IsImmutable: () => IsImmutable,
|
|
1044
|
+
IsInfer: () => IsInfer,
|
|
1045
|
+
IsInteger: () => IsInteger,
|
|
1046
|
+
IsInterfaceDeferred: () => IsInterfaceDeferred,
|
|
1047
|
+
IsIntersect: () => IsIntersect,
|
|
1048
|
+
IsKind: () => IsKind,
|
|
1049
|
+
IsLiteral: () => IsLiteral,
|
|
1050
|
+
IsLiteralBigInt: () => IsLiteralBigInt,
|
|
1051
|
+
IsLiteralBoolean: () => IsLiteralBoolean,
|
|
1052
|
+
IsLiteralNumber: () => IsLiteralNumber,
|
|
1053
|
+
IsLiteralString: () => IsLiteralString,
|
|
1054
|
+
IsLiteralValue: () => IsLiteralValue,
|
|
1055
|
+
IsNever: () => IsNever,
|
|
1056
|
+
IsNull: () => IsNull,
|
|
1057
|
+
IsNumber: () => IsNumber,
|
|
1058
|
+
IsObject: () => IsObject,
|
|
1059
|
+
IsOptional: () => IsOptional,
|
|
1060
|
+
IsParameter: () => IsParameter,
|
|
1061
|
+
IsReadonly: () => IsReadonly,
|
|
1062
|
+
IsRecord: () => IsRecord,
|
|
1063
|
+
IsRef: () => IsRef,
|
|
1064
|
+
IsRefine: () => IsRefine,
|
|
1065
|
+
IsRefinement: () => IsRefinement,
|
|
1066
|
+
IsRest: () => IsRest,
|
|
1067
|
+
IsSchema: () => IsSchema,
|
|
1068
|
+
IsString: () => IsString,
|
|
1069
|
+
IsSymbol: () => IsSymbol,
|
|
1070
|
+
IsTemplateLiteral: () => IsTemplateLiteral,
|
|
1071
|
+
IsTemplateLiteralDeferred: () => IsTemplateLiteralDeferred,
|
|
1072
|
+
IsTemplateLiteralFinite: () => IsTemplateLiteralFinite,
|
|
1073
|
+
IsTemplateLiteralPattern: () => IsTemplateLiteralPattern,
|
|
1074
|
+
IsThis: () => IsThis,
|
|
1075
|
+
IsTuple: () => IsTuple,
|
|
1076
|
+
IsTypeScriptEnumLike: () => IsTypeScriptEnumLike,
|
|
1077
|
+
IsUndefined: () => IsUndefined,
|
|
1078
|
+
IsUnion: () => IsUnion,
|
|
1079
|
+
IsUnknown: () => IsUnknown,
|
|
1080
|
+
IsUnsafe: () => IsUnsafe,
|
|
1081
|
+
IsVoid: () => IsVoid,
|
|
1082
|
+
KeyOf: () => KeyOf,
|
|
1083
|
+
KeyOfAction: () => KeyOfAction,
|
|
1084
|
+
KeyOfDeferred: () => KeyOfDeferred,
|
|
1085
|
+
KeyOfInstantiate: () => KeyOfInstantiate,
|
|
1086
|
+
KeysToIndexer: () => KeysToIndexer,
|
|
1087
|
+
Literal: () => Literal,
|
|
1088
|
+
LiteralTypeName: () => LiteralTypeName,
|
|
1089
|
+
Lowercase: () => Lowercase,
|
|
1090
|
+
LowercaseAction: () => LowercaseAction,
|
|
1091
|
+
LowercaseDeferred: () => LowercaseDeferred,
|
|
1092
|
+
LowercaseInstantiate: () => LowercaseInstantiate,
|
|
1093
|
+
Mapped: () => Mapped,
|
|
1094
|
+
MappedAction: () => MappedAction,
|
|
1095
|
+
MappedDeferred: () => MappedDeferred,
|
|
1096
|
+
MappedInstantiate: () => MappedInstantiate,
|
|
1097
|
+
Module: () => Module,
|
|
1098
|
+
ModuleDeferred: () => ModuleDeferred,
|
|
1099
|
+
ModuleInstantiate: () => ModuleInstantiate,
|
|
1100
|
+
Narrow: () => Narrow,
|
|
1101
|
+
Never: () => Never,
|
|
1102
|
+
NeverPattern: () => NeverPattern,
|
|
1103
|
+
NonNullable: () => NonNullable,
|
|
1104
|
+
NonNullableAction: () => NonNullableAction,
|
|
1105
|
+
NonNullableDeferred: () => NonNullableDeferred,
|
|
1106
|
+
NonNullableInstantiate: () => NonNullableInstantiate,
|
|
1107
|
+
Null: () => Null,
|
|
1108
|
+
Number: () => Number2,
|
|
1109
|
+
NumberKey: () => NumberKey,
|
|
1110
|
+
NumberPattern: () => NumberPattern,
|
|
1111
|
+
Object: () => _Object_,
|
|
1112
|
+
ObjectOptions: () => ObjectOptions,
|
|
1113
|
+
Omit: () => Omit,
|
|
1114
|
+
OmitAction: () => OmitAction,
|
|
1115
|
+
OmitDeferred: () => OmitDeferred,
|
|
1116
|
+
OmitInstantiate: () => OmitInstantiate,
|
|
1117
|
+
Optional: () => Optional,
|
|
1118
|
+
Parameter: () => Parameter,
|
|
1119
|
+
Parameters: () => Parameters,
|
|
1120
|
+
ParametersAction: () => ParametersAction,
|
|
1121
|
+
ParametersDeferred: () => ParametersDeferred,
|
|
1122
|
+
ParametersInstantiate: () => ParametersInstantiate,
|
|
1123
|
+
ParsePatternIntoTypes: () => ParsePatternIntoTypes,
|
|
1124
|
+
ParseTemplateIntoTypes: () => ParseTemplateIntoTypes,
|
|
1125
|
+
Partial: () => Partial,
|
|
1126
|
+
PartialAction: () => PartialAction,
|
|
1127
|
+
PartialDeferred: () => PartialDeferred,
|
|
1128
|
+
PartialInstantiate: () => PartialInstantiate,
|
|
1129
|
+
Pick: () => Pick,
|
|
1130
|
+
PickAction: () => PickAction,
|
|
1131
|
+
PickDeferred: () => PickDeferred,
|
|
1132
|
+
PickInstantiate: () => PickInstantiate,
|
|
1133
|
+
Priority: () => Priority,
|
|
1134
|
+
PropertyKeys: () => PropertyKeys,
|
|
1135
|
+
PropertyValues: () => PropertyValues,
|
|
1136
|
+
Readonly: () => Readonly,
|
|
1137
|
+
ReadonlyObject: () => ReadonlyObject,
|
|
1138
|
+
ReadonlyObjectAction: () => ReadonlyObjectAction,
|
|
1139
|
+
ReadonlyObjectDeferred: () => ReadonlyObjectDeferred,
|
|
1140
|
+
ReadonlyObjectInstantiate: () => ReadonlyObjectInstantiate,
|
|
1141
|
+
ReadonlyType: () => ReadonlyType,
|
|
1142
|
+
Record: () => Record,
|
|
1143
|
+
RecordAction: () => RecordAction,
|
|
1144
|
+
RecordDeferred: () => RecordDeferred,
|
|
1145
|
+
RecordFromPattern: () => RecordFromPattern,
|
|
1146
|
+
RecordInstantiate: () => RecordInstantiate,
|
|
1147
|
+
RecordKey: () => RecordKey,
|
|
1148
|
+
RecordOptions: () => RecordOptions,
|
|
1149
|
+
RecordPattern: () => RecordPattern,
|
|
1150
|
+
RecordPatternToType: () => RecordPatternToType,
|
|
1151
|
+
RecordValue: () => RecordValue,
|
|
1152
|
+
Ref: () => Ref,
|
|
1153
|
+
RefInstantiate: () => RefInstantiate,
|
|
1154
|
+
Refine: () => Refine,
|
|
1155
|
+
RefineAdd: () => RefineAdd,
|
|
1156
|
+
RemoveImmutable: () => RemoveImmutable,
|
|
1157
|
+
RemoveImmutableDeferred: () => RemoveImmutableDeferred,
|
|
1158
|
+
RemoveOptional: () => RemoveOptional,
|
|
1159
|
+
RemoveOptionalDeferred: () => RemoveOptionalDeferred,
|
|
1160
|
+
RemoveReadonly: () => RemoveReadonly,
|
|
1161
|
+
RemoveReadonlyDeferred: () => RemoveReadonlyDeferred,
|
|
1162
|
+
Required: () => Required,
|
|
1163
|
+
RequiredAction: () => RequiredAction,
|
|
1164
|
+
RequiredArray: () => RequiredArray,
|
|
1165
|
+
RequiredDeferred: () => RequiredDeferred,
|
|
1166
|
+
RequiredInstantiate: () => RequiredInstantiate,
|
|
1167
|
+
Rest: () => Rest,
|
|
1168
|
+
ResultDisjoint: () => ResultDisjoint,
|
|
1169
|
+
ResultEqual: () => ResultEqual,
|
|
1170
|
+
ResultLeftInside: () => ResultLeftInside,
|
|
1171
|
+
ResultRightInside: () => ResultRightInside,
|
|
1172
|
+
ReturnType: () => ReturnType,
|
|
1173
|
+
ReturnTypeAction: () => ReturnTypeAction,
|
|
1174
|
+
ReturnTypeDeferred: () => ReturnTypeDeferred,
|
|
1175
|
+
ReturnTypeInstantiate: () => ReturnTypeInstantiate,
|
|
1176
|
+
Script: () => Script,
|
|
1177
|
+
String: () => String2,
|
|
1178
|
+
StringKey: () => StringKey,
|
|
1179
|
+
StringPattern: () => StringPattern,
|
|
1180
|
+
Symbol: () => Symbol2,
|
|
1181
|
+
TemplateLiteral: () => TemplateLiteral,
|
|
1182
|
+
TemplateLiteralCreate: () => TemplateLiteralCreate,
|
|
1183
|
+
TemplateLiteralDecode: () => TemplateLiteralDecode,
|
|
1184
|
+
TemplateLiteralDecodeUnsafe: () => TemplateLiteralDecodeUnsafe,
|
|
1185
|
+
TemplateLiteralDeferred: () => TemplateLiteralDeferred,
|
|
1186
|
+
TemplateLiteralEncode: () => TemplateLiteralEncode,
|
|
1187
|
+
TemplateLiteralFromString: () => TemplateLiteralFromString,
|
|
1188
|
+
TemplateLiteralFromTypes: () => TemplateLiteralFromTypes,
|
|
1189
|
+
This: () => This,
|
|
1190
|
+
Tuple: () => Tuple,
|
|
1191
|
+
TupleOptions: () => TupleOptions,
|
|
1192
|
+
Type: () => typebox_exports,
|
|
1193
|
+
TypeScriptEnumToEnumValues: () => TypeScriptEnumToEnumValues,
|
|
1194
|
+
Uncapitalize: () => Uncapitalize,
|
|
1195
|
+
UncapitalizeAction: () => UncapitalizeAction,
|
|
1196
|
+
UncapitalizeDeferred: () => UncapitalizeDeferred,
|
|
1197
|
+
UncapitalizeInstantiate: () => UncapitalizeInstantiate,
|
|
1198
|
+
Undefined: () => Undefined,
|
|
1199
|
+
Union: () => Union,
|
|
1200
|
+
UnionOptions: () => UnionOptions,
|
|
1201
|
+
Unknown: () => Unknown,
|
|
1202
|
+
Unsafe: () => Unsafe,
|
|
1203
|
+
Uppercase: () => Uppercase,
|
|
1204
|
+
UppercaseAction: () => UppercaseAction,
|
|
1205
|
+
UppercaseDeferred: () => UppercaseDeferred,
|
|
1206
|
+
UppercaseInstantiate: () => UppercaseInstantiate,
|
|
1207
|
+
Void: () => Void,
|
|
1208
|
+
With: () => With,
|
|
1209
|
+
WithAction: () => WithAction,
|
|
1210
|
+
WithDeferred: () => WithDeferred,
|
|
1211
|
+
WithInstantiate: () => WithInstantiate,
|
|
1212
|
+
_Array_: () => _Array_,
|
|
1213
|
+
_Function_: () => _Function_,
|
|
1214
|
+
_Object_: () => _Object_,
|
|
1215
|
+
default: () => build_default
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
// ../../node_modules/typebox/build/typebox.mjs
|
|
1219
|
+
var typebox_exports = {};
|
|
1220
|
+
__export(typebox_exports, {
|
|
1221
|
+
Any: () => Any,
|
|
1222
|
+
Array: () => _Array_,
|
|
1223
|
+
BigInt: () => BigInt,
|
|
1224
|
+
Boolean: () => Boolean,
|
|
1225
|
+
Call: () => Call,
|
|
1226
|
+
Capitalize: () => Capitalize,
|
|
1227
|
+
Codec: () => Codec,
|
|
1228
|
+
Conditional: () => Conditional,
|
|
1229
|
+
Constructor: () => Constructor,
|
|
1230
|
+
ConstructorParameters: () => ConstructorParameters,
|
|
1231
|
+
Cyclic: () => Cyclic,
|
|
1232
|
+
Decode: () => Decode,
|
|
1233
|
+
DecodeBuilder: () => DecodeBuilder,
|
|
1234
|
+
Dependent: () => Dependent,
|
|
1235
|
+
Encode: () => Encode,
|
|
1236
|
+
EncodeBuilder: () => EncodeBuilder,
|
|
1237
|
+
Enum: () => Enum,
|
|
1238
|
+
Evaluate: () => Evaluate,
|
|
1239
|
+
Exclude: () => Exclude,
|
|
1240
|
+
Extends: () => Extends,
|
|
1241
|
+
ExtendsResult: () => result_exports,
|
|
1242
|
+
Extract: () => Extract,
|
|
1243
|
+
Function: () => _Function_,
|
|
1244
|
+
Generic: () => Generic,
|
|
1245
|
+
Identifier: () => Identifier,
|
|
1246
|
+
Immutable: () => Immutable,
|
|
1247
|
+
Index: () => Index,
|
|
1248
|
+
Infer: () => Infer,
|
|
1249
|
+
InstanceType: () => InstanceType,
|
|
1250
|
+
Instantiate: () => Instantiate,
|
|
1251
|
+
Integer: () => Integer,
|
|
1252
|
+
Interface: () => Interface,
|
|
1253
|
+
Intersect: () => Intersect,
|
|
1254
|
+
IsAny: () => IsAny,
|
|
1255
|
+
IsArray: () => IsArray,
|
|
1256
|
+
IsBigInt: () => IsBigInt,
|
|
1257
|
+
IsBoolean: () => IsBoolean,
|
|
1258
|
+
IsCall: () => IsCall,
|
|
1259
|
+
IsCodec: () => IsCodec,
|
|
1260
|
+
IsConstructor: () => IsConstructor,
|
|
1261
|
+
IsCyclic: () => IsCyclic,
|
|
1262
|
+
IsDependent: () => IsDependent,
|
|
1263
|
+
IsEnum: () => IsEnum,
|
|
1264
|
+
IsEnumValue: () => IsEnumValue,
|
|
1265
|
+
IsFunction: () => IsFunction,
|
|
1266
|
+
IsGeneric: () => IsGeneric,
|
|
1267
|
+
IsIdentifier: () => IsIdentifier,
|
|
1268
|
+
IsImmutable: () => IsImmutable,
|
|
1269
|
+
IsInfer: () => IsInfer,
|
|
1270
|
+
IsInteger: () => IsInteger,
|
|
1271
|
+
IsIntersect: () => IsIntersect,
|
|
1272
|
+
IsKind: () => IsKind,
|
|
1273
|
+
IsLiteral: () => IsLiteral,
|
|
1274
|
+
IsNever: () => IsNever,
|
|
1275
|
+
IsNull: () => IsNull,
|
|
1276
|
+
IsNumber: () => IsNumber,
|
|
1277
|
+
IsObject: () => IsObject,
|
|
1278
|
+
IsOptional: () => IsOptional,
|
|
1279
|
+
IsParameter: () => IsParameter,
|
|
1280
|
+
IsReadonly: () => IsReadonly,
|
|
1281
|
+
IsRecord: () => IsRecord,
|
|
1282
|
+
IsRef: () => IsRef,
|
|
1283
|
+
IsRefine: () => IsRefine,
|
|
1284
|
+
IsRest: () => IsRest,
|
|
1285
|
+
IsSchema: () => IsSchema,
|
|
1286
|
+
IsString: () => IsString,
|
|
1287
|
+
IsSymbol: () => IsSymbol,
|
|
1288
|
+
IsTemplateLiteral: () => IsTemplateLiteral,
|
|
1289
|
+
IsThis: () => IsThis,
|
|
1290
|
+
IsTuple: () => IsTuple,
|
|
1291
|
+
IsUndefined: () => IsUndefined,
|
|
1292
|
+
IsUnion: () => IsUnion,
|
|
1293
|
+
IsUnknown: () => IsUnknown,
|
|
1294
|
+
IsUnsafe: () => IsUnsafe,
|
|
1295
|
+
IsVoid: () => IsVoid,
|
|
1296
|
+
KeyOf: () => KeyOf,
|
|
1297
|
+
Literal: () => Literal,
|
|
1298
|
+
Lowercase: () => Lowercase,
|
|
1299
|
+
Mapped: () => Mapped,
|
|
1300
|
+
Module: () => Module,
|
|
1301
|
+
Never: () => Never,
|
|
1302
|
+
NonNullable: () => NonNullable,
|
|
1303
|
+
Null: () => Null,
|
|
1304
|
+
Number: () => Number2,
|
|
1305
|
+
Object: () => _Object_,
|
|
1306
|
+
Omit: () => Omit,
|
|
1307
|
+
Optional: () => Optional,
|
|
1308
|
+
Parameter: () => Parameter,
|
|
1309
|
+
Parameters: () => Parameters,
|
|
1310
|
+
Partial: () => Partial,
|
|
1311
|
+
Pick: () => Pick,
|
|
1312
|
+
Readonly: () => Readonly,
|
|
1313
|
+
ReadonlyObject: () => ReadonlyObject,
|
|
1314
|
+
ReadonlyType: () => ReadonlyType,
|
|
1315
|
+
Record: () => Record,
|
|
1316
|
+
RecordKey: () => RecordKey,
|
|
1317
|
+
RecordPattern: () => RecordPattern,
|
|
1318
|
+
RecordValue: () => RecordValue,
|
|
1319
|
+
Ref: () => Ref,
|
|
1320
|
+
Refine: () => Refine,
|
|
1321
|
+
Required: () => Required,
|
|
1322
|
+
Rest: () => Rest,
|
|
1323
|
+
ReturnType: () => ReturnType,
|
|
1324
|
+
Script: () => Script,
|
|
1325
|
+
String: () => String2,
|
|
1326
|
+
Symbol: () => Symbol2,
|
|
1327
|
+
TemplateLiteral: () => TemplateLiteral,
|
|
1328
|
+
This: () => This,
|
|
1329
|
+
Tuple: () => Tuple,
|
|
1330
|
+
Uncapitalize: () => Uncapitalize,
|
|
1331
|
+
Undefined: () => Undefined,
|
|
1332
|
+
Union: () => Union,
|
|
1333
|
+
Unknown: () => Unknown,
|
|
1334
|
+
Unsafe: () => Unsafe,
|
|
1335
|
+
Uppercase: () => Uppercase,
|
|
1336
|
+
Void: () => Void,
|
|
1337
|
+
With: () => With
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
// ../../node_modules/typebox/build/index.mjs
|
|
1341
|
+
var build_default = typebox_exports;
|
|
1342
|
+
|
|
1343
|
+
// ../ai/src/index.ts
|
|
1344
|
+
var src_exports = {};
|
|
1345
|
+
__export(src_exports, {
|
|
1346
|
+
AssistantMessageEventStream: () => AssistantMessageEventStream,
|
|
1347
|
+
EventStream: () => EventStream,
|
|
1348
|
+
RequestTokenBudget: () => RequestTokenBudget,
|
|
1349
|
+
RequestTokenBudgetError: () => RequestTokenBudgetError,
|
|
1350
|
+
StreamFailureError: () => StreamFailureError,
|
|
1351
|
+
StringEnum: () => StringEnum,
|
|
1352
|
+
Type: () => typebox_exports,
|
|
1353
|
+
appendAssistantMessageDiagnostic: () => appendAssistantMessageDiagnostic,
|
|
1354
|
+
assertBuiltInAttemptSupport: () => assertBuiltInAttemptSupport,
|
|
1355
|
+
calculateCost: () => calculateCost,
|
|
1356
|
+
clampThinkingLevel: () => clampThinkingLevel,
|
|
1357
|
+
classifyStreamFailure: () => classifyStreamFailure,
|
|
1358
|
+
cleanupSessionResources: () => cleanupSessionResources,
|
|
1359
|
+
clearApiProviders: () => clearApiProviders,
|
|
1360
|
+
complete: () => complete,
|
|
1361
|
+
completeSimple: () => completeSimple,
|
|
1362
|
+
createAssistantMessageDiagnostic: () => createAssistantMessageDiagnostic,
|
|
1363
|
+
createAssistantMessageEventStream: () => createAssistantMessageEventStream,
|
|
1364
|
+
extractDiagnosticError: () => extractDiagnosticError,
|
|
1365
|
+
extractStreamFailureInfo: () => extractStreamFailureInfo,
|
|
1366
|
+
fauxAssistantMessage: () => fauxAssistantMessage,
|
|
1367
|
+
fauxText: () => fauxText,
|
|
1368
|
+
fauxThinking: () => fauxThinking,
|
|
1369
|
+
fauxToolCall: () => fauxToolCall,
|
|
1370
|
+
findEnvKeys: () => findEnvKeys,
|
|
1371
|
+
formatStreamFailureMessage: () => formatStreamFailureMessage,
|
|
1372
|
+
formatThrownValue: () => formatThrownValue,
|
|
1373
|
+
getApiProvider: () => getApiProvider,
|
|
1374
|
+
getApiProviders: () => getApiProviders,
|
|
1375
|
+
getEnvApiKey: () => getEnvApiKey,
|
|
1376
|
+
getLogger: () => getLogger,
|
|
1377
|
+
getModel: () => getModel,
|
|
1378
|
+
getModels: () => getModels,
|
|
1379
|
+
getProviders: () => getProviders,
|
|
1380
|
+
getSupportedThinkingLevels: () => getSupportedThinkingLevels,
|
|
1381
|
+
invokeRequestMeasurement: () => invokeRequestMeasurement,
|
|
1382
|
+
isContextOverflow: () => isContextOverflow,
|
|
1383
|
+
isLocalFauxProvider: () => isLocalFauxProvider,
|
|
1384
|
+
isLocalFauxStream: () => isLocalFauxStream,
|
|
1385
|
+
isLocalRequestPreparationError: () => isLocalRequestPreparationError,
|
|
1386
|
+
isTransientProviderFailure: () => isTransientProviderFailure,
|
|
1387
|
+
markLocalRequestPreparationError: () => markLocalRequestPreparationError,
|
|
1388
|
+
matchesApiProvider: () => matchesApiProvider,
|
|
1389
|
+
modelsAreEqual: () => modelsAreEqual,
|
|
1390
|
+
parseJsonWithRepair: () => parseJsonWithRepair,
|
|
1391
|
+
parseStreamingJson: () => parseStreamingJson,
|
|
1392
|
+
recordStreamFailure: () => recordStreamFailure,
|
|
1393
|
+
registerApiProvider: () => registerApiProvider,
|
|
1394
|
+
registerBuiltInApiProviders: () => registerBuiltInApiProviders,
|
|
1395
|
+
registerFauxProvider: () => registerFauxProvider,
|
|
1396
|
+
registerSessionResourceCleanup: () => registerSessionResourceCleanup,
|
|
1397
|
+
repairJson: () => repairJson,
|
|
1398
|
+
requestTokenRouteIdentity: () => requestTokenRouteIdentity,
|
|
1399
|
+
resetApiProviders: () => resetApiProviders,
|
|
1400
|
+
setBedrockProviderModule: () => setBedrockProviderModule,
|
|
1401
|
+
setLogSink: () => setLogSink,
|
|
1402
|
+
stream: () => stream,
|
|
1403
|
+
streamAnthropic: () => streamAnthropic,
|
|
1404
|
+
streamAzureOpenAIResponses: () => streamAzureOpenAIResponses,
|
|
1405
|
+
streamFailureFromStopReason: () => streamFailureFromStopReason,
|
|
1406
|
+
streamFailureMessage: () => streamFailureMessage,
|
|
1407
|
+
streamGoogle: () => streamGoogle,
|
|
1408
|
+
streamGoogleVertex: () => streamGoogleVertex,
|
|
1409
|
+
streamMistral: () => streamMistral,
|
|
1410
|
+
streamOpenAICodexResponses: () => streamOpenAICodexResponses,
|
|
1411
|
+
streamOpenAICompletions: () => streamOpenAICompletions,
|
|
1412
|
+
streamOpenAIResponses: () => streamOpenAIResponses,
|
|
1413
|
+
streamSimple: () => streamSimple,
|
|
1414
|
+
streamSimpleAnthropic: () => streamSimpleAnthropic,
|
|
1415
|
+
streamSimpleAzureOpenAIResponses: () => streamSimpleAzureOpenAIResponses,
|
|
1416
|
+
streamSimpleGoogle: () => streamSimpleGoogle,
|
|
1417
|
+
streamSimpleGoogleVertex: () => streamSimpleGoogleVertex,
|
|
1418
|
+
streamSimpleMistral: () => streamSimpleMistral,
|
|
1419
|
+
streamSimpleOpenAICodexResponses: () => streamSimpleOpenAICodexResponses,
|
|
1420
|
+
streamSimpleOpenAICompletions: () => streamSimpleOpenAICompletions,
|
|
1421
|
+
streamSimpleOpenAIResponses: () => streamSimpleOpenAIResponses,
|
|
1422
|
+
stringifyLogEntry: () => stringifyLogEntry,
|
|
1423
|
+
supportsFastMode: () => supportsFastMode,
|
|
1424
|
+
truncateRawPayload: () => truncateRawPayload,
|
|
1425
|
+
unregisterApiProviders: () => unregisterApiProviders,
|
|
1426
|
+
validateToolArguments: () => validateToolArguments,
|
|
1427
|
+
validateToolCall: () => validateToolCall,
|
|
1428
|
+
withRequestBody: () => withRequestBody
|
|
1429
|
+
});
|
|
1430
|
+
|
|
1431
|
+
// ../ai/src/api-registry.ts
|
|
1432
|
+
var apiProviderRegistry = /* @__PURE__ */ new Map();
|
|
1433
|
+
function wrapStream(api, stream2) {
|
|
1434
|
+
return (model, context, options) => {
|
|
1435
|
+
if (model.api !== api) {
|
|
1436
|
+
throw new Error(`Mismatched api: ${model.api} expected ${api}`);
|
|
1437
|
+
}
|
|
1438
|
+
return stream2(model, context, options);
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
function wrapStreamSimple(api, streamSimple2) {
|
|
1442
|
+
return (model, context, options) => {
|
|
1443
|
+
if (model.api !== api) {
|
|
1444
|
+
throw new Error(`Mismatched api: ${model.api} expected ${api}`);
|
|
1445
|
+
}
|
|
1446
|
+
return streamSimple2(model, context, options);
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
function registerApiProvider(provider, sourceId) {
|
|
1450
|
+
const stream2 = wrapStream(provider.api, provider.stream);
|
|
1451
|
+
const streamSimple2 = wrapStreamSimple(provider.api, provider.streamSimple);
|
|
1452
|
+
apiProviderRegistry.set(provider.api, {
|
|
1453
|
+
provider: { api: provider.api, stream: stream2, streamSimple: streamSimple2 },
|
|
1454
|
+
sourceId,
|
|
1455
|
+
originalStream: provider.stream,
|
|
1456
|
+
originalStreamSimple: provider.streamSimple,
|
|
1457
|
+
registeredStream: stream2,
|
|
1458
|
+
registeredStreamSimple: streamSimple2
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
function getApiProvider(api) {
|
|
1462
|
+
return apiProviderRegistry.get(api)?.provider;
|
|
1463
|
+
}
|
|
1464
|
+
function matchesApiProvider(api, stream2, streamSimple2) {
|
|
1465
|
+
const entry = apiProviderRegistry.get(api);
|
|
1466
|
+
return !!entry && entry.originalStream === stream2 && entry.originalStreamSimple === streamSimple2 && entry.provider.stream === entry.registeredStream && entry.provider.streamSimple === entry.registeredStreamSimple;
|
|
1467
|
+
}
|
|
1468
|
+
function getApiProviders() {
|
|
1469
|
+
return Array.from(apiProviderRegistry.values(), (entry) => entry.provider);
|
|
1470
|
+
}
|
|
1471
|
+
function unregisterApiProviders(sourceId) {
|
|
1472
|
+
for (const [api, entry] of apiProviderRegistry.entries()) {
|
|
1473
|
+
if (entry.sourceId === sourceId) {
|
|
1474
|
+
apiProviderRegistry.delete(api);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function clearApiProviders() {
|
|
1479
|
+
apiProviderRegistry.clear();
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
// ../ai/src/providers/faux.ts
|
|
1483
|
+
var DEFAULT_API = "faux";
|
|
1484
|
+
var DEFAULT_PROVIDER = "faux";
|
|
1485
|
+
var DEFAULT_MODEL_ID = "faux-1";
|
|
1486
|
+
var DEFAULT_MODEL_NAME = "Faux Model";
|
|
1487
|
+
var DEFAULT_BASE_URL = "http://localhost:0";
|
|
1488
|
+
var DEFAULT_MIN_TOKEN_SIZE = 3;
|
|
1489
|
+
var DEFAULT_MAX_TOKEN_SIZE = 5;
|
|
1490
|
+
var localImplementations = /* @__PURE__ */ new Map();
|
|
1491
|
+
var localStreams = /* @__PURE__ */ new WeakSet();
|
|
1492
|
+
function isLocalFauxProvider(api) {
|
|
1493
|
+
const implementation = localImplementations.get(api);
|
|
1494
|
+
return !!implementation && matchesApiProvider(api, implementation.stream, implementation.streamSimple);
|
|
1495
|
+
}
|
|
1496
|
+
function isLocalFauxStream(stream2) {
|
|
1497
|
+
return localStreams.has(stream2);
|
|
1498
|
+
}
|
|
1499
|
+
var DEFAULT_USAGE = {
|
|
1500
|
+
input: 0,
|
|
1501
|
+
output: 0,
|
|
1502
|
+
cacheRead: 0,
|
|
1503
|
+
cacheWrite: 0,
|
|
1504
|
+
totalTokens: 0,
|
|
1505
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
1506
|
+
};
|
|
1507
|
+
function fauxText(text) {
|
|
1508
|
+
return { type: "text", text };
|
|
1509
|
+
}
|
|
1510
|
+
function fauxThinking(thinking) {
|
|
1511
|
+
return { type: "thinking", thinking };
|
|
1512
|
+
}
|
|
1513
|
+
function fauxToolCall(name, arguments_, options = {}) {
|
|
1514
|
+
return {
|
|
1515
|
+
type: "toolCall",
|
|
1516
|
+
id: options.id ?? randomId("tool"),
|
|
1517
|
+
name,
|
|
1518
|
+
arguments: arguments_
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
function normalizeFauxAssistantContent(content) {
|
|
1522
|
+
if (typeof content === "string") {
|
|
1523
|
+
return [fauxText(content)];
|
|
1524
|
+
}
|
|
1525
|
+
return Array.isArray(content) ? content : [content];
|
|
1526
|
+
}
|
|
1527
|
+
function fauxAssistantMessage(content, options = {}) {
|
|
1528
|
+
return {
|
|
1529
|
+
role: "assistant",
|
|
1530
|
+
content: normalizeFauxAssistantContent(content),
|
|
1531
|
+
api: DEFAULT_API,
|
|
1532
|
+
provider: DEFAULT_PROVIDER,
|
|
1533
|
+
model: DEFAULT_MODEL_ID,
|
|
1534
|
+
usage: DEFAULT_USAGE,
|
|
1535
|
+
stopReason: options.stopReason ?? "stop",
|
|
1536
|
+
errorMessage: options.errorMessage,
|
|
1537
|
+
responseId: options.responseId,
|
|
1538
|
+
timestamp: options.timestamp ?? Date.now()
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
function estimateTokens(text) {
|
|
1542
|
+
return Math.ceil(text.length / 4);
|
|
1543
|
+
}
|
|
1544
|
+
function randomId(prefix) {
|
|
1545
|
+
return `${prefix}:${Date.now()}:${Math.random().toString(36).slice(2)}`;
|
|
1546
|
+
}
|
|
1547
|
+
function contentToText(content) {
|
|
1548
|
+
if (typeof content === "string") {
|
|
1549
|
+
return content;
|
|
1550
|
+
}
|
|
1551
|
+
return content.map((block) => {
|
|
1552
|
+
if (block.type === "text") {
|
|
1553
|
+
return block.text;
|
|
1554
|
+
}
|
|
1555
|
+
return `[image:${block.mimeType}:${block.data.length}]`;
|
|
1556
|
+
}).join("\n");
|
|
1557
|
+
}
|
|
1558
|
+
function assistantContentToText(content) {
|
|
1559
|
+
return content.map((block) => {
|
|
1560
|
+
if (block.type === "text") {
|
|
1561
|
+
return block.text;
|
|
1562
|
+
}
|
|
1563
|
+
if (block.type === "thinking") {
|
|
1564
|
+
return block.thinking;
|
|
1565
|
+
}
|
|
1566
|
+
return `${block.name}:${JSON.stringify(block.arguments)}`;
|
|
1567
|
+
}).join("\n");
|
|
1568
|
+
}
|
|
1569
|
+
function toolResultToText(message) {
|
|
1570
|
+
return [message.toolName, ...message.content.map((block) => contentToText([block]))].join("\n");
|
|
1571
|
+
}
|
|
1572
|
+
function messageToText(message) {
|
|
1573
|
+
if (message.role === "user") {
|
|
1574
|
+
return contentToText(message.content);
|
|
1575
|
+
}
|
|
1576
|
+
if (message.role === "assistant") {
|
|
1577
|
+
return assistantContentToText(message.content);
|
|
1578
|
+
}
|
|
1579
|
+
return toolResultToText(message);
|
|
1580
|
+
}
|
|
1581
|
+
function serializeContext(context) {
|
|
1582
|
+
const parts = [];
|
|
1583
|
+
if (context.systemPrompt) {
|
|
1584
|
+
parts.push(`system:${context.systemPrompt}`);
|
|
1585
|
+
}
|
|
1586
|
+
for (const message of context.messages) {
|
|
1587
|
+
parts.push(`${message.role}:${messageToText(message)}`);
|
|
1588
|
+
}
|
|
1589
|
+
if (context.tools?.length) {
|
|
1590
|
+
parts.push(`tools:${JSON.stringify(context.tools)}`);
|
|
1591
|
+
}
|
|
1592
|
+
return parts.join("\n\n");
|
|
1593
|
+
}
|
|
1594
|
+
function commonPrefixLength(a, b) {
|
|
1595
|
+
const length = Math.min(a.length, b.length);
|
|
1596
|
+
let index = 0;
|
|
1597
|
+
while (index < length && a[index] === b[index]) {
|
|
1598
|
+
index++;
|
|
1599
|
+
}
|
|
1600
|
+
return index;
|
|
1601
|
+
}
|
|
1602
|
+
function withUsageEstimate(message, context, options, promptCache) {
|
|
1603
|
+
const promptText = serializeContext(context);
|
|
1604
|
+
const promptTokens = estimateTokens(promptText);
|
|
1605
|
+
const outputTokens = estimateTokens(assistantContentToText(message.content));
|
|
1606
|
+
let input = promptTokens;
|
|
1607
|
+
let cacheRead = 0;
|
|
1608
|
+
let cacheWrite = 0;
|
|
1609
|
+
const sessionId = options?.sessionId;
|
|
1610
|
+
if (sessionId && options?.cacheRetention !== "none") {
|
|
1611
|
+
const previousPrompt = promptCache.get(sessionId);
|
|
1612
|
+
if (previousPrompt) {
|
|
1613
|
+
const cachedChars = commonPrefixLength(previousPrompt, promptText);
|
|
1614
|
+
cacheRead = estimateTokens(previousPrompt.slice(0, cachedChars));
|
|
1615
|
+
cacheWrite = estimateTokens(promptText.slice(cachedChars));
|
|
1616
|
+
input = Math.max(0, promptTokens - cacheRead);
|
|
1617
|
+
} else {
|
|
1618
|
+
cacheWrite = promptTokens;
|
|
1619
|
+
}
|
|
1620
|
+
promptCache.set(sessionId, promptText);
|
|
1621
|
+
}
|
|
1622
|
+
return {
|
|
1623
|
+
...message,
|
|
1624
|
+
usage: {
|
|
1625
|
+
input,
|
|
1626
|
+
output: outputTokens,
|
|
1627
|
+
cacheRead,
|
|
1628
|
+
cacheWrite,
|
|
1629
|
+
totalTokens: input + outputTokens + cacheRead + cacheWrite,
|
|
1630
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
function splitStringByTokenSize(text, minTokenSize, maxTokenSize) {
|
|
1635
|
+
const chunks = [];
|
|
1636
|
+
let index = 0;
|
|
1637
|
+
while (index < text.length) {
|
|
1638
|
+
const tokenSize = minTokenSize + Math.floor(Math.random() * (maxTokenSize - minTokenSize + 1));
|
|
1639
|
+
const charSize = Math.max(1, tokenSize * 4);
|
|
1640
|
+
chunks.push(text.slice(index, index + charSize));
|
|
1641
|
+
index += charSize;
|
|
1642
|
+
}
|
|
1643
|
+
return chunks.length > 0 ? chunks : [""];
|
|
1644
|
+
}
|
|
1645
|
+
function cloneMessage(message, api, provider, modelId) {
|
|
1646
|
+
const cloned = structuredClone(message);
|
|
1647
|
+
return {
|
|
1648
|
+
...cloned,
|
|
1649
|
+
api,
|
|
1650
|
+
provider,
|
|
1651
|
+
model: modelId,
|
|
1652
|
+
timestamp: cloned.timestamp ?? Date.now(),
|
|
1653
|
+
usage: cloned.usage ?? DEFAULT_USAGE
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
function createErrorMessage(error, api, provider, modelId) {
|
|
1657
|
+
return {
|
|
1658
|
+
role: "assistant",
|
|
1659
|
+
content: [],
|
|
1660
|
+
api,
|
|
1661
|
+
provider,
|
|
1662
|
+
model: modelId,
|
|
1663
|
+
usage: DEFAULT_USAGE,
|
|
1664
|
+
stopReason: "error",
|
|
1665
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
1666
|
+
timestamp: Date.now()
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
function createAbortedMessage(partial) {
|
|
1670
|
+
return {
|
|
1671
|
+
...partial,
|
|
1672
|
+
stopReason: "aborted",
|
|
1673
|
+
errorMessage: "Request was aborted",
|
|
1674
|
+
timestamp: Date.now()
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
function scheduleChunk(chunk, tokensPerSecond) {
|
|
1678
|
+
if (!tokensPerSecond || tokensPerSecond <= 0) {
|
|
1679
|
+
return new Promise((resolve4) => queueMicrotask(resolve4));
|
|
1680
|
+
}
|
|
1681
|
+
const delayMs = estimateTokens(chunk) / tokensPerSecond * 1e3;
|
|
1682
|
+
return new Promise((resolve4) => setTimeout(resolve4, delayMs));
|
|
1683
|
+
}
|
|
1684
|
+
async function streamWithDeltas(stream2, message, minTokenSize, maxTokenSize, tokensPerSecond, signal) {
|
|
1685
|
+
const partial = { ...message, content: [] };
|
|
1686
|
+
if (signal?.aborted) {
|
|
1687
|
+
const aborted = createAbortedMessage(partial);
|
|
1688
|
+
stream2.push({ type: "error", reason: "aborted", error: aborted });
|
|
1689
|
+
stream2.end(aborted);
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
stream2.push({ type: "start", partial: { ...partial } });
|
|
1693
|
+
for (let index = 0; index < message.content.length; index++) {
|
|
1694
|
+
if (signal?.aborted) {
|
|
1695
|
+
const aborted = createAbortedMessage(partial);
|
|
1696
|
+
stream2.push({ type: "error", reason: "aborted", error: aborted });
|
|
1697
|
+
stream2.end(aborted);
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
const block = message.content[index];
|
|
1701
|
+
if (block.type === "thinking") {
|
|
1702
|
+
partial.content = [...partial.content, { type: "thinking", thinking: "" }];
|
|
1703
|
+
stream2.push({ type: "thinking_start", contentIndex: index, partial: { ...partial } });
|
|
1704
|
+
for (const chunk of splitStringByTokenSize(block.thinking, minTokenSize, maxTokenSize)) {
|
|
1705
|
+
await scheduleChunk(chunk, tokensPerSecond);
|
|
1706
|
+
if (signal?.aborted) {
|
|
1707
|
+
const aborted = createAbortedMessage(partial);
|
|
1708
|
+
stream2.push({ type: "error", reason: "aborted", error: aborted });
|
|
1709
|
+
stream2.end(aborted);
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
partial.content[index].thinking += chunk;
|
|
1713
|
+
stream2.push({ type: "thinking_delta", contentIndex: index, delta: chunk, partial: { ...partial } });
|
|
1714
|
+
}
|
|
1715
|
+
stream2.push({
|
|
1716
|
+
type: "thinking_end",
|
|
1717
|
+
contentIndex: index,
|
|
1718
|
+
content: block.thinking,
|
|
1719
|
+
partial: { ...partial }
|
|
1720
|
+
});
|
|
1721
|
+
continue;
|
|
1722
|
+
}
|
|
1723
|
+
if (block.type === "text") {
|
|
1724
|
+
partial.content = [...partial.content, { type: "text", text: "" }];
|
|
1725
|
+
stream2.push({ type: "text_start", contentIndex: index, partial: { ...partial } });
|
|
1726
|
+
for (const chunk of splitStringByTokenSize(block.text, minTokenSize, maxTokenSize)) {
|
|
1727
|
+
await scheduleChunk(chunk, tokensPerSecond);
|
|
1728
|
+
if (signal?.aborted) {
|
|
1729
|
+
const aborted = createAbortedMessage(partial);
|
|
1730
|
+
stream2.push({ type: "error", reason: "aborted", error: aborted });
|
|
1731
|
+
stream2.end(aborted);
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
partial.content[index].text += chunk;
|
|
1735
|
+
stream2.push({ type: "text_delta", contentIndex: index, delta: chunk, partial: { ...partial } });
|
|
1736
|
+
}
|
|
1737
|
+
stream2.push({ type: "text_end", contentIndex: index, content: block.text, partial: { ...partial } });
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
partial.content = [...partial.content, { type: "toolCall", id: block.id, name: block.name, arguments: {} }];
|
|
1741
|
+
stream2.push({ type: "toolcall_start", contentIndex: index, partial: { ...partial } });
|
|
1742
|
+
for (const chunk of splitStringByTokenSize(JSON.stringify(block.arguments), minTokenSize, maxTokenSize)) {
|
|
1743
|
+
await scheduleChunk(chunk, tokensPerSecond);
|
|
1744
|
+
if (signal?.aborted) {
|
|
1745
|
+
const aborted = createAbortedMessage(partial);
|
|
1746
|
+
stream2.push({ type: "error", reason: "aborted", error: aborted });
|
|
1747
|
+
stream2.end(aborted);
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
stream2.push({ type: "toolcall_delta", contentIndex: index, delta: chunk, partial: { ...partial } });
|
|
1751
|
+
}
|
|
1752
|
+
partial.content[index].arguments = block.arguments;
|
|
1753
|
+
stream2.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: { ...partial } });
|
|
1754
|
+
}
|
|
1755
|
+
if (message.stopReason === "error" || message.stopReason === "aborted") {
|
|
1756
|
+
stream2.push({ type: "error", reason: message.stopReason, error: message });
|
|
1757
|
+
stream2.end(message);
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
stream2.push({ type: "done", reason: message.stopReason, message });
|
|
1761
|
+
stream2.end(message);
|
|
1762
|
+
}
|
|
1763
|
+
function registerFauxProvider(options = {}) {
|
|
1764
|
+
const api = options.api ?? randomId(DEFAULT_API);
|
|
1765
|
+
const provider = options.provider ?? DEFAULT_PROVIDER;
|
|
1766
|
+
const sourceId = randomId("faux-provider");
|
|
1767
|
+
const minTokenSize = Math.max(
|
|
1768
|
+
1,
|
|
1769
|
+
Math.min(options.tokenSize?.min ?? DEFAULT_MIN_TOKEN_SIZE, options.tokenSize?.max ?? DEFAULT_MAX_TOKEN_SIZE)
|
|
1770
|
+
);
|
|
1771
|
+
const maxTokenSize = Math.max(minTokenSize, options.tokenSize?.max ?? DEFAULT_MAX_TOKEN_SIZE);
|
|
1772
|
+
let pendingResponses = [];
|
|
1773
|
+
const tokensPerSecond = options.tokensPerSecond;
|
|
1774
|
+
const state = { callCount: 0 };
|
|
1775
|
+
const promptCache = /* @__PURE__ */ new Map();
|
|
1776
|
+
const modelDefinitions = options.models?.length ? options.models : [
|
|
1777
|
+
{
|
|
1778
|
+
id: DEFAULT_MODEL_ID,
|
|
1779
|
+
name: DEFAULT_MODEL_NAME,
|
|
1780
|
+
reasoning: false,
|
|
1781
|
+
input: ["text", "image"],
|
|
1782
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
1783
|
+
contextWindow: 128e3,
|
|
1784
|
+
maxTokens: 16384
|
|
1785
|
+
}
|
|
1786
|
+
];
|
|
1787
|
+
const models = modelDefinitions.map((definition) => ({
|
|
1788
|
+
id: definition.id,
|
|
1789
|
+
name: definition.name ?? definition.id,
|
|
1790
|
+
api,
|
|
1791
|
+
provider,
|
|
1792
|
+
baseUrl: DEFAULT_BASE_URL,
|
|
1793
|
+
reasoning: definition.reasoning ?? false,
|
|
1794
|
+
input: definition.input ?? ["text", "image"],
|
|
1795
|
+
cost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
1796
|
+
contextWindow: definition.contextWindow ?? 128e3,
|
|
1797
|
+
maxTokens: definition.maxTokens ?? 16384
|
|
1798
|
+
}));
|
|
1799
|
+
const stream2 = (requestModel, context, streamOptions) => {
|
|
1800
|
+
streamOptions = streamOptions ? { ...streamOptions, attempts: void 0 } : void 0;
|
|
1801
|
+
const outer = createAssistantMessageEventStream();
|
|
1802
|
+
localStreams.add(outer);
|
|
1803
|
+
const step = pendingResponses.shift();
|
|
1804
|
+
state.callCount++;
|
|
1805
|
+
queueMicrotask(async () => {
|
|
1806
|
+
try {
|
|
1807
|
+
await streamOptions?.onResponse?.({ status: 200, headers: {} }, requestModel);
|
|
1808
|
+
if (!step) {
|
|
1809
|
+
let message2 = createErrorMessage(
|
|
1810
|
+
new Error("No more faux responses queued"),
|
|
1811
|
+
api,
|
|
1812
|
+
provider,
|
|
1813
|
+
requestModel.id
|
|
1814
|
+
);
|
|
1815
|
+
message2 = withUsageEstimate(message2, context, streamOptions, promptCache);
|
|
1816
|
+
outer.push({ type: "error", reason: "error", error: message2 });
|
|
1817
|
+
outer.end(message2);
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
const resolved = typeof step === "function" ? await step(context, streamOptions, state, requestModel) : step;
|
|
1821
|
+
let message = cloneMessage(resolved, api, provider, requestModel.id);
|
|
1822
|
+
message = withUsageEstimate(message, context, streamOptions, promptCache);
|
|
1823
|
+
await streamWithDeltas(outer, message, minTokenSize, maxTokenSize, tokensPerSecond, streamOptions?.signal);
|
|
1824
|
+
} catch (error) {
|
|
1825
|
+
const message = createErrorMessage(error, api, provider, requestModel.id);
|
|
1826
|
+
outer.push({ type: "error", reason: "error", error: message });
|
|
1827
|
+
outer.end(message);
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
return outer;
|
|
1831
|
+
};
|
|
1832
|
+
const streamSimple2 = (streamModel, context, streamOptions) => stream2(streamModel, context, streamOptions);
|
|
1833
|
+
const implementation = { stream: stream2, streamSimple: streamSimple2 };
|
|
1834
|
+
localImplementations.set(api, implementation);
|
|
1835
|
+
registerApiProvider({ api, stream: stream2, streamSimple: streamSimple2 }, sourceId);
|
|
1836
|
+
function getModel2(requestedModelId) {
|
|
1837
|
+
if (!requestedModelId) {
|
|
1838
|
+
return models[0];
|
|
1839
|
+
}
|
|
1840
|
+
return models.find((candidate) => candidate.id === requestedModelId);
|
|
1841
|
+
}
|
|
1842
|
+
return {
|
|
1843
|
+
api,
|
|
1844
|
+
models,
|
|
1845
|
+
getModel: getModel2,
|
|
1846
|
+
state,
|
|
1847
|
+
setResponses(responses) {
|
|
1848
|
+
pendingResponses = [...responses];
|
|
1849
|
+
},
|
|
1850
|
+
appendResponses(responses) {
|
|
1851
|
+
pendingResponses.push(...responses);
|
|
1852
|
+
},
|
|
1853
|
+
getPendingResponseCount() {
|
|
1854
|
+
return pendingResponses.length;
|
|
1855
|
+
},
|
|
1856
|
+
unregister() {
|
|
1857
|
+
unregisterApiProviders(sourceId);
|
|
1858
|
+
if (localImplementations.get(api) === implementation) localImplementations.delete(api);
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
// ../ai/src/utils/native-bedrock-provider.ts
|
|
1864
|
+
var native;
|
|
1865
|
+
function isNativeBedrockProvider(stream2, streamSimple2) {
|
|
1866
|
+
return native?.stream === stream2 && native.streamSimple === streamSimple2;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
// ../ai/src/providers/register-builtins.ts
|
|
1870
|
+
var importNodeOnlyProvider = (specifier) => import(specifier);
|
|
1871
|
+
var anthropicProviderModulePromise;
|
|
1872
|
+
var azureOpenAIResponsesProviderModulePromise;
|
|
1873
|
+
var googleProviderModulePromise;
|
|
1874
|
+
var googleVertexProviderModulePromise;
|
|
1875
|
+
var mistralProviderModulePromise;
|
|
1876
|
+
var openAICodexResponsesProviderModulePromise;
|
|
1877
|
+
var openAICompletionsProviderModulePromise;
|
|
1878
|
+
var openAIResponsesProviderModulePromise;
|
|
1879
|
+
var bedrockProviderModuleOverride;
|
|
1880
|
+
var bedrockProviderModulePromise;
|
|
1881
|
+
function setBedrockProviderModule(module) {
|
|
1882
|
+
bedrockProviderModuleOverride = {
|
|
1883
|
+
stream: module.streamBedrock,
|
|
1884
|
+
streamSimple: module.streamSimpleBedrock
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
function forwardStream(target, source) {
|
|
1888
|
+
(async () => {
|
|
1889
|
+
for await (const event of source) {
|
|
1890
|
+
target.push(event);
|
|
1891
|
+
}
|
|
1892
|
+
target.end();
|
|
1893
|
+
})();
|
|
1894
|
+
}
|
|
1895
|
+
function createLazyLoadErrorMessage(model, error) {
|
|
1896
|
+
return {
|
|
1897
|
+
role: "assistant",
|
|
1898
|
+
content: [],
|
|
1899
|
+
api: model.api,
|
|
1900
|
+
provider: model.provider,
|
|
1901
|
+
model: model.id,
|
|
1902
|
+
usage: {
|
|
1903
|
+
input: 0,
|
|
1904
|
+
output: 0,
|
|
1905
|
+
cacheRead: 0,
|
|
1906
|
+
cacheWrite: 0,
|
|
1907
|
+
totalTokens: 0,
|
|
1908
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
1909
|
+
},
|
|
1910
|
+
stopReason: "error",
|
|
1911
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
1912
|
+
timestamp: Date.now()
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
function createLazyStream(loadModule) {
|
|
1916
|
+
return (model, context, options) => {
|
|
1917
|
+
const outer = new AssistantMessageEventStream();
|
|
1918
|
+
loadModule().then((module) => {
|
|
1919
|
+
if (options?.requireProviderAttempts) {
|
|
1920
|
+
assertBuiltInAttemptSupport(model.api);
|
|
1921
|
+
if (model.api === "bedrock-converse-stream" && !isNativeBedrockProvider(module.stream, module.streamSimple)) {
|
|
1922
|
+
throw new Error(
|
|
1923
|
+
"Native Bedrock inference requires the instrumented built-in provider module; custom module coverage is unestablished."
|
|
1924
|
+
);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
const inner = module.stream(model, context, options);
|
|
1928
|
+
forwardStream(outer, inner);
|
|
1929
|
+
}).catch((error) => {
|
|
1930
|
+
const message = createLazyLoadErrorMessage(model, error);
|
|
1931
|
+
outer.push({ type: "error", reason: "error", error: message });
|
|
1932
|
+
outer.end(message);
|
|
1933
|
+
});
|
|
1934
|
+
return outer;
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
function createLazySimpleStream(loadModule) {
|
|
1938
|
+
return (model, context, options) => {
|
|
1939
|
+
const outer = new AssistantMessageEventStream();
|
|
1940
|
+
loadModule().then((module) => {
|
|
1941
|
+
if (options?.requireProviderAttempts) {
|
|
1942
|
+
assertBuiltInAttemptSupport(model.api);
|
|
1943
|
+
if (model.api === "bedrock-converse-stream" && !isNativeBedrockProvider(module.stream, module.streamSimple)) {
|
|
1944
|
+
throw new Error(
|
|
1945
|
+
"Native Bedrock inference requires the instrumented built-in provider module; custom module coverage is unestablished."
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
const inner = module.streamSimple(model, context, options);
|
|
1950
|
+
forwardStream(outer, inner);
|
|
1951
|
+
}).catch((error) => {
|
|
1952
|
+
const message = createLazyLoadErrorMessage(model, error);
|
|
1953
|
+
outer.push({ type: "error", reason: "error", error: message });
|
|
1954
|
+
outer.end(message);
|
|
1955
|
+
});
|
|
1956
|
+
return outer;
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
function loadAnthropicProviderModule() {
|
|
1960
|
+
anthropicProviderModulePromise ||= import("./anthropic-UV5GZDGU.js").then((module) => {
|
|
1961
|
+
const provider = module;
|
|
1962
|
+
return {
|
|
1963
|
+
stream: provider.streamAnthropic,
|
|
1964
|
+
streamSimple: provider.streamSimpleAnthropic
|
|
1965
|
+
};
|
|
1966
|
+
});
|
|
1967
|
+
return anthropicProviderModulePromise;
|
|
1968
|
+
}
|
|
1969
|
+
function loadAzureOpenAIResponsesProviderModule() {
|
|
1970
|
+
azureOpenAIResponsesProviderModulePromise ||= import("./azure-openai-responses-WSNPXLYC.js").then((module) => {
|
|
1971
|
+
const provider = module;
|
|
1972
|
+
return {
|
|
1973
|
+
stream: provider.streamAzureOpenAIResponses,
|
|
1974
|
+
streamSimple: provider.streamSimpleAzureOpenAIResponses
|
|
1975
|
+
};
|
|
1976
|
+
});
|
|
1977
|
+
return azureOpenAIResponsesProviderModulePromise;
|
|
1978
|
+
}
|
|
1979
|
+
function loadGoogleProviderModule() {
|
|
1980
|
+
googleProviderModulePromise ||= import("./google-T32FMD4G.js").then((module) => {
|
|
1981
|
+
const provider = module;
|
|
1982
|
+
return {
|
|
1983
|
+
stream: provider.streamGoogle,
|
|
1984
|
+
streamSimple: provider.streamSimpleGoogle
|
|
1985
|
+
};
|
|
1986
|
+
});
|
|
1987
|
+
return googleProviderModulePromise;
|
|
1988
|
+
}
|
|
1989
|
+
function loadGoogleVertexProviderModule() {
|
|
1990
|
+
googleVertexProviderModulePromise ||= import("./google-vertex-56KP6I3B.js").then((module) => {
|
|
1991
|
+
const provider = module;
|
|
1992
|
+
return {
|
|
1993
|
+
stream: provider.streamGoogleVertex,
|
|
1994
|
+
streamSimple: provider.streamSimpleGoogleVertex
|
|
1995
|
+
};
|
|
1996
|
+
});
|
|
1997
|
+
return googleVertexProviderModulePromise;
|
|
1998
|
+
}
|
|
1999
|
+
function loadMistralProviderModule() {
|
|
2000
|
+
mistralProviderModulePromise ||= import("./mistral-WGBMYIVU.js").then((module) => {
|
|
2001
|
+
const provider = module;
|
|
2002
|
+
return {
|
|
2003
|
+
stream: provider.streamMistral,
|
|
2004
|
+
streamSimple: provider.streamSimpleMistral
|
|
2005
|
+
};
|
|
2006
|
+
});
|
|
2007
|
+
return mistralProviderModulePromise;
|
|
2008
|
+
}
|
|
2009
|
+
function loadOpenAICodexResponsesProviderModule() {
|
|
2010
|
+
openAICodexResponsesProviderModulePromise ||= import("./openai-codex-responses-PIV2RQ3G.js").then((module) => {
|
|
2011
|
+
const provider = module;
|
|
2012
|
+
return {
|
|
2013
|
+
stream: provider.streamOpenAICodexResponses,
|
|
2014
|
+
streamSimple: provider.streamSimpleOpenAICodexResponses
|
|
2015
|
+
};
|
|
2016
|
+
});
|
|
2017
|
+
return openAICodexResponsesProviderModulePromise;
|
|
2018
|
+
}
|
|
2019
|
+
function loadOpenAICompletionsProviderModule() {
|
|
2020
|
+
openAICompletionsProviderModulePromise ||= import("./openai-completions-64C3JPR4.js").then((module) => {
|
|
2021
|
+
const provider = module;
|
|
2022
|
+
return {
|
|
2023
|
+
stream: provider.streamOpenAICompletions,
|
|
2024
|
+
streamSimple: provider.streamSimpleOpenAICompletions
|
|
2025
|
+
};
|
|
2026
|
+
});
|
|
2027
|
+
return openAICompletionsProviderModulePromise;
|
|
2028
|
+
}
|
|
2029
|
+
function loadOpenAIResponsesProviderModule() {
|
|
2030
|
+
openAIResponsesProviderModulePromise ||= import("./openai-responses-UI7RSTDV.js").then((module) => {
|
|
2031
|
+
const provider = module;
|
|
2032
|
+
return {
|
|
2033
|
+
stream: provider.streamOpenAIResponses,
|
|
2034
|
+
streamSimple: provider.streamSimpleOpenAIResponses
|
|
2035
|
+
};
|
|
2036
|
+
});
|
|
2037
|
+
return openAIResponsesProviderModulePromise;
|
|
2038
|
+
}
|
|
2039
|
+
function loadBedrockProviderModule() {
|
|
2040
|
+
if (bedrockProviderModuleOverride) {
|
|
2041
|
+
return Promise.resolve(bedrockProviderModuleOverride);
|
|
2042
|
+
}
|
|
2043
|
+
bedrockProviderModulePromise ||= importNodeOnlyProvider("./amazon-bedrock.js").then((module) => {
|
|
2044
|
+
const provider = module;
|
|
2045
|
+
return {
|
|
2046
|
+
stream: provider.streamBedrock,
|
|
2047
|
+
streamSimple: provider.streamSimpleBedrock
|
|
2048
|
+
};
|
|
2049
|
+
});
|
|
2050
|
+
return bedrockProviderModulePromise;
|
|
2051
|
+
}
|
|
2052
|
+
var streamAnthropic = createLazyStream(loadAnthropicProviderModule);
|
|
2053
|
+
var streamSimpleAnthropic = createLazySimpleStream(loadAnthropicProviderModule);
|
|
2054
|
+
var streamAzureOpenAIResponses = createLazyStream(loadAzureOpenAIResponsesProviderModule);
|
|
2055
|
+
var streamSimpleAzureOpenAIResponses = createLazySimpleStream(loadAzureOpenAIResponsesProviderModule);
|
|
2056
|
+
var streamGoogle = createLazyStream(loadGoogleProviderModule);
|
|
2057
|
+
var streamSimpleGoogle = createLazySimpleStream(loadGoogleProviderModule);
|
|
2058
|
+
var streamGoogleVertex = createLazyStream(loadGoogleVertexProviderModule);
|
|
2059
|
+
var streamSimpleGoogleVertex = createLazySimpleStream(loadGoogleVertexProviderModule);
|
|
2060
|
+
var streamMistral = createLazyStream(loadMistralProviderModule);
|
|
2061
|
+
var streamSimpleMistral = createLazySimpleStream(loadMistralProviderModule);
|
|
2062
|
+
var streamOpenAICodexResponses = createLazyStream(loadOpenAICodexResponsesProviderModule);
|
|
2063
|
+
var streamSimpleOpenAICodexResponses = createLazySimpleStream(loadOpenAICodexResponsesProviderModule);
|
|
2064
|
+
var streamOpenAICompletions = createLazyStream(loadOpenAICompletionsProviderModule);
|
|
2065
|
+
var streamSimpleOpenAICompletions = createLazySimpleStream(loadOpenAICompletionsProviderModule);
|
|
2066
|
+
var streamOpenAIResponses = createLazyStream(loadOpenAIResponsesProviderModule);
|
|
2067
|
+
var streamSimpleOpenAIResponses = createLazySimpleStream(loadOpenAIResponsesProviderModule);
|
|
2068
|
+
var streamBedrockLazy = createLazyStream(loadBedrockProviderModule);
|
|
2069
|
+
var streamSimpleBedrockLazy = createLazySimpleStream(loadBedrockProviderModule);
|
|
2070
|
+
var builtInImplementations = /* @__PURE__ */ new Map();
|
|
2071
|
+
function registerBuiltIn(provider) {
|
|
2072
|
+
builtInImplementations.set(provider.api, { stream: provider.stream, streamSimple: provider.streamSimple });
|
|
2073
|
+
registerApiProvider(provider);
|
|
2074
|
+
}
|
|
2075
|
+
function assertBuiltInAttemptSupport(api) {
|
|
2076
|
+
if (isLocalFauxProvider(api)) return "local-faux";
|
|
2077
|
+
const known = builtInImplementations.get(api);
|
|
2078
|
+
if (!known || !matchesApiProvider(api, known.stream, known.streamSimple) || api === "bedrock-converse-stream" && bedrockProviderModuleOverride && !isNativeBedrockProvider(bedrockProviderModuleOverride.stream, bedrockProviderModuleOverride.streamSimple)) {
|
|
2079
|
+
throw new Error(
|
|
2080
|
+
"Native inference cannot admit this custom or proxy adapter: physical-attempt coverage is unestablished. Use an instrumented built-in API route such as openai-responses, openai-completions, or anthropic-messages; custom model IDs and base URLs are supported."
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
return "provider";
|
|
2084
|
+
}
|
|
2085
|
+
function registerBuiltInApiProviders() {
|
|
2086
|
+
registerBuiltIn({
|
|
2087
|
+
api: "anthropic-messages",
|
|
2088
|
+
stream: streamAnthropic,
|
|
2089
|
+
streamSimple: streamSimpleAnthropic
|
|
2090
|
+
});
|
|
2091
|
+
registerBuiltIn({
|
|
2092
|
+
api: "openai-completions",
|
|
2093
|
+
stream: streamOpenAICompletions,
|
|
2094
|
+
streamSimple: streamSimpleOpenAICompletions
|
|
2095
|
+
});
|
|
2096
|
+
registerBuiltIn({
|
|
2097
|
+
api: "mistral-conversations",
|
|
2098
|
+
stream: streamMistral,
|
|
2099
|
+
streamSimple: streamSimpleMistral
|
|
2100
|
+
});
|
|
2101
|
+
registerBuiltIn({
|
|
2102
|
+
api: "openai-responses",
|
|
2103
|
+
stream: streamOpenAIResponses,
|
|
2104
|
+
streamSimple: streamSimpleOpenAIResponses
|
|
2105
|
+
});
|
|
2106
|
+
registerBuiltIn({
|
|
2107
|
+
api: "azure-openai-responses",
|
|
2108
|
+
stream: streamAzureOpenAIResponses,
|
|
2109
|
+
streamSimple: streamSimpleAzureOpenAIResponses
|
|
2110
|
+
});
|
|
2111
|
+
registerBuiltIn({
|
|
2112
|
+
api: "openai-codex-responses",
|
|
2113
|
+
stream: streamOpenAICodexResponses,
|
|
2114
|
+
streamSimple: streamSimpleOpenAICodexResponses
|
|
2115
|
+
});
|
|
2116
|
+
registerBuiltIn({
|
|
2117
|
+
api: "google-generative-ai",
|
|
2118
|
+
stream: streamGoogle,
|
|
2119
|
+
streamSimple: streamSimpleGoogle
|
|
2120
|
+
});
|
|
2121
|
+
registerBuiltIn({
|
|
2122
|
+
api: "google-vertex",
|
|
2123
|
+
stream: streamGoogleVertex,
|
|
2124
|
+
streamSimple: streamSimpleGoogleVertex
|
|
2125
|
+
});
|
|
2126
|
+
registerBuiltIn({
|
|
2127
|
+
api: "bedrock-converse-stream",
|
|
2128
|
+
stream: streamBedrockLazy,
|
|
2129
|
+
streamSimple: streamSimpleBedrockLazy
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
function resetApiProviders() {
|
|
2133
|
+
clearApiProviders();
|
|
2134
|
+
registerBuiltInApiProviders();
|
|
2135
|
+
}
|
|
2136
|
+
registerBuiltInApiProviders();
|
|
2137
|
+
|
|
2138
|
+
// ../ai/src/stream.ts
|
|
2139
|
+
function resolveApiProvider(api, options) {
|
|
2140
|
+
let localSimulation = false;
|
|
2141
|
+
if (options?.requireProviderAttempts) {
|
|
2142
|
+
localSimulation = assertBuiltInAttemptSupport(api) === "local-faux";
|
|
2143
|
+
if (!localSimulation && !options.attempts) {
|
|
2144
|
+
throw new Error("Native inference requires physical-attempt admission and settlement");
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
const provider = getApiProvider(api);
|
|
2148
|
+
if (!provider) throw new Error(`No API provider registered for api: ${api}`);
|
|
2149
|
+
return { stream: provider.stream, streamSimple: provider.streamSimple, localSimulation };
|
|
2150
|
+
}
|
|
2151
|
+
function stream(model, context, options) {
|
|
2152
|
+
const provider = resolveApiProvider(model.api, options);
|
|
2153
|
+
const dispatchOptions = provider.localSimulation ? { ...options, attempts: void 0 } : options;
|
|
2154
|
+
return provider.stream(model, context, dispatchOptions);
|
|
2155
|
+
}
|
|
2156
|
+
async function complete(model, context, options) {
|
|
2157
|
+
const s = stream(model, context, options);
|
|
2158
|
+
return s.result();
|
|
2159
|
+
}
|
|
2160
|
+
function streamSimple(model, context, options) {
|
|
2161
|
+
const provider = resolveApiProvider(model.api, options);
|
|
2162
|
+
const dispatchOptions = provider.localSimulation ? { ...options, attempts: void 0 } : options;
|
|
2163
|
+
return provider.streamSimple(model, context, dispatchOptions);
|
|
2164
|
+
}
|
|
2165
|
+
async function completeSimple(model, context, options) {
|
|
2166
|
+
const s = streamSimple(model, context, options);
|
|
2167
|
+
return s.result();
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
// ../ai/src/utils/overflow.ts
|
|
2171
|
+
var OVERFLOW_PATTERNS = [
|
|
2172
|
+
/prompt is too long/i,
|
|
2173
|
+
// Anthropic token overflow
|
|
2174
|
+
/request_too_large/i,
|
|
2175
|
+
// Anthropic request byte-size overflow (HTTP 413)
|
|
2176
|
+
/input is too long for requested model/i,
|
|
2177
|
+
// Amazon Bedrock
|
|
2178
|
+
/exceeds the context window/i,
|
|
2179
|
+
// OpenAI (Completions & Responses API)
|
|
2180
|
+
/input token count.*exceeds the maximum/i,
|
|
2181
|
+
// Google (Gemini)
|
|
2182
|
+
/maximum prompt length is \d+/i,
|
|
2183
|
+
// xAI (Grok)
|
|
2184
|
+
/reduce the length of the messages/i,
|
|
2185
|
+
// Groq
|
|
2186
|
+
/maximum context length is \d+ tokens/i,
|
|
2187
|
+
// OpenRouter (all backends)
|
|
2188
|
+
/exceeds the model's maximum context length/i,
|
|
2189
|
+
// LiteLLM (input + requested output)
|
|
2190
|
+
/exceeds the limit of \d+/i,
|
|
2191
|
+
// GitHub Copilot
|
|
2192
|
+
/exceeds the available context size/i,
|
|
2193
|
+
// llama.cpp server
|
|
2194
|
+
/greater than the context length/i,
|
|
2195
|
+
// LM Studio
|
|
2196
|
+
/context window exceeds limit/i,
|
|
2197
|
+
// MiniMax
|
|
2198
|
+
/exceeded model token limit/i,
|
|
2199
|
+
// Kimi For Coding
|
|
2200
|
+
/too large for model with \d+ maximum context length/i,
|
|
2201
|
+
// Mistral
|
|
2202
|
+
/model_context_window_exceeded/i,
|
|
2203
|
+
// z.ai non-standard finish_reason surfaced as error text
|
|
2204
|
+
/prompt too long; exceeded (?:max )?context length/i,
|
|
2205
|
+
// Ollama explicit overflow error
|
|
2206
|
+
/context[_ ]length[_ ]exceeded/i,
|
|
2207
|
+
// Generic fallback
|
|
2208
|
+
/too many tokens/i,
|
|
2209
|
+
// Generic fallback
|
|
2210
|
+
/token limit exceeded/i,
|
|
2211
|
+
// Generic fallback
|
|
2212
|
+
/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i
|
|
2213
|
+
// Cerebras: 400/413 with no body
|
|
2214
|
+
];
|
|
2215
|
+
var NON_OVERFLOW_PATTERNS = [
|
|
2216
|
+
/^(Throttling error|Service unavailable):/i,
|
|
2217
|
+
// AWS Bedrock non-overflow errors (human-readable prefixes from formatBedrockError)
|
|
2218
|
+
/rate limit/i,
|
|
2219
|
+
// Generic rate limiting
|
|
2220
|
+
/too many requests/i
|
|
2221
|
+
// Generic HTTP 429 style
|
|
2222
|
+
];
|
|
2223
|
+
function isContextOverflow(message, contextWindow) {
|
|
2224
|
+
if (message.stopReason === "error" && message.errorMessage) {
|
|
2225
|
+
const isNonOverflow = NON_OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage));
|
|
2226
|
+
if (!isNonOverflow && OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage))) {
|
|
2227
|
+
return true;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
if (contextWindow && message.stopReason === "stop") {
|
|
2231
|
+
const inputTokens = message.usage.input + message.usage.cacheRead;
|
|
2232
|
+
if (inputTokens > contextWindow) {
|
|
2233
|
+
return true;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
if (contextWindow && message.stopReason === "length" && message.usage.output === 0) {
|
|
2237
|
+
const inputTokens = message.usage.input + message.usage.cacheRead;
|
|
2238
|
+
if (inputTokens >= contextWindow * 0.99) {
|
|
2239
|
+
return true;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
// ../ai/src/utils/typebox-helpers.ts
|
|
2246
|
+
function StringEnum(values, options) {
|
|
2247
|
+
return typebox_exports.Unsafe({
|
|
2248
|
+
type: "string",
|
|
2249
|
+
enum: values,
|
|
2250
|
+
...options?.description && { description: options.description },
|
|
2251
|
+
...options?.default && { default: options.default }
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
// ../ai/src/utils/validation.ts
|
|
2256
|
+
var validatorCache = /* @__PURE__ */ new WeakMap();
|
|
2257
|
+
var TYPEBOX_KIND = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
|
|
2258
|
+
function isRecord(value) {
|
|
2259
|
+
return typeof value === "object" && value !== null;
|
|
2260
|
+
}
|
|
2261
|
+
function isJsonSchemaObject(value) {
|
|
2262
|
+
return isRecord(value);
|
|
2263
|
+
}
|
|
2264
|
+
function hasTypeBoxMetadata(schema) {
|
|
2265
|
+
return isRecord(schema) && Object.getOwnPropertySymbols(schema).includes(TYPEBOX_KIND);
|
|
2266
|
+
}
|
|
2267
|
+
function getSchemaTypes(schema) {
|
|
2268
|
+
if (typeof schema.type === "string") {
|
|
2269
|
+
return [schema.type];
|
|
2270
|
+
}
|
|
2271
|
+
if (Array.isArray(schema.type)) {
|
|
2272
|
+
return schema.type.filter((type) => typeof type === "string");
|
|
2273
|
+
}
|
|
2274
|
+
return [];
|
|
2275
|
+
}
|
|
2276
|
+
function matchesJsonType(value, type) {
|
|
2277
|
+
switch (type) {
|
|
2278
|
+
case "number":
|
|
2279
|
+
return typeof value === "number";
|
|
2280
|
+
case "integer":
|
|
2281
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
2282
|
+
case "boolean":
|
|
2283
|
+
return typeof value === "boolean";
|
|
2284
|
+
case "string":
|
|
2285
|
+
return typeof value === "string";
|
|
2286
|
+
case "null":
|
|
2287
|
+
return value === null;
|
|
2288
|
+
case "array":
|
|
2289
|
+
return Array.isArray(value);
|
|
2290
|
+
case "object":
|
|
2291
|
+
return isRecord(value) && !Array.isArray(value);
|
|
2292
|
+
default:
|
|
2293
|
+
return false;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
function isValidatorSchema(value) {
|
|
2297
|
+
return isRecord(value);
|
|
2298
|
+
}
|
|
2299
|
+
function getSubSchemaValidator(schema) {
|
|
2300
|
+
if (!isValidatorSchema(schema)) {
|
|
2301
|
+
return void 0;
|
|
2302
|
+
}
|
|
2303
|
+
try {
|
|
2304
|
+
return getValidator(schema);
|
|
2305
|
+
} catch {
|
|
2306
|
+
return void 0;
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
function coercePrimitiveByType(value, type) {
|
|
2310
|
+
switch (type) {
|
|
2311
|
+
case "number": {
|
|
2312
|
+
if (value === null) {
|
|
2313
|
+
return 0;
|
|
2314
|
+
}
|
|
2315
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
2316
|
+
const parsed = Number(value);
|
|
2317
|
+
if (Number.isFinite(parsed)) {
|
|
2318
|
+
return parsed;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (typeof value === "boolean") {
|
|
2322
|
+
return value ? 1 : 0;
|
|
2323
|
+
}
|
|
2324
|
+
return value;
|
|
2325
|
+
}
|
|
2326
|
+
case "integer": {
|
|
2327
|
+
if (value === null) {
|
|
2328
|
+
return 0;
|
|
2329
|
+
}
|
|
2330
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
2331
|
+
const parsed = Number(value);
|
|
2332
|
+
if (Number.isInteger(parsed)) {
|
|
2333
|
+
return parsed;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
if (typeof value === "boolean") {
|
|
2337
|
+
return value ? 1 : 0;
|
|
2338
|
+
}
|
|
2339
|
+
return value;
|
|
2340
|
+
}
|
|
2341
|
+
case "boolean": {
|
|
2342
|
+
if (value === null) {
|
|
2343
|
+
return false;
|
|
2344
|
+
}
|
|
2345
|
+
if (typeof value === "string") {
|
|
2346
|
+
if (value === "true") {
|
|
2347
|
+
return true;
|
|
2348
|
+
}
|
|
2349
|
+
if (value === "false") {
|
|
2350
|
+
return false;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
if (typeof value === "number") {
|
|
2354
|
+
if (value === 1) {
|
|
2355
|
+
return true;
|
|
2356
|
+
}
|
|
2357
|
+
if (value === 0) {
|
|
2358
|
+
return false;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
return value;
|
|
2362
|
+
}
|
|
2363
|
+
case "string": {
|
|
2364
|
+
if (value === null) {
|
|
2365
|
+
return "";
|
|
2366
|
+
}
|
|
2367
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
2368
|
+
return String(value);
|
|
2369
|
+
}
|
|
2370
|
+
return value;
|
|
2371
|
+
}
|
|
2372
|
+
case "null": {
|
|
2373
|
+
if (value === "" || value === 0 || value === false) {
|
|
2374
|
+
return null;
|
|
2375
|
+
}
|
|
2376
|
+
return value;
|
|
2377
|
+
}
|
|
2378
|
+
default:
|
|
2379
|
+
return value;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
function applySchemaObjectCoercion(value, schema) {
|
|
2383
|
+
const properties = schema.properties;
|
|
2384
|
+
const definedKeys = new Set(properties ? Object.keys(properties) : []);
|
|
2385
|
+
if (properties) {
|
|
2386
|
+
for (const [key, propertySchema] of Object.entries(properties)) {
|
|
2387
|
+
if (!(key in value)) {
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
value[key] = coerceWithJsonSchema(value[key], propertySchema);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
if (schema.additionalProperties && isJsonSchemaObject(schema.additionalProperties)) {
|
|
2394
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
2395
|
+
if (definedKeys.has(key)) {
|
|
2396
|
+
continue;
|
|
2397
|
+
}
|
|
2398
|
+
value[key] = coerceWithJsonSchema(propertyValue, schema.additionalProperties);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
function applySchemaArrayCoercion(value, schema) {
|
|
2403
|
+
if (Array.isArray(schema.items)) {
|
|
2404
|
+
for (let index = 0; index < value.length; index++) {
|
|
2405
|
+
const itemSchema = schema.items[index];
|
|
2406
|
+
if (!itemSchema) {
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
value[index] = coerceWithJsonSchema(value[index], itemSchema);
|
|
2410
|
+
}
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
if (isJsonSchemaObject(schema.items)) {
|
|
2414
|
+
for (let index = 0; index < value.length; index++) {
|
|
2415
|
+
value[index] = coerceWithJsonSchema(value[index], schema.items);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
function coerceWithUnionSchema(value, schemas) {
|
|
2420
|
+
for (const schema of schemas) {
|
|
2421
|
+
const candidate = structuredClone(value);
|
|
2422
|
+
const coerced = coerceWithJsonSchema(candidate, schema);
|
|
2423
|
+
const validator = getSubSchemaValidator(schema);
|
|
2424
|
+
if (validator?.Check(coerced)) {
|
|
2425
|
+
return coerced;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
return value;
|
|
2429
|
+
}
|
|
2430
|
+
function coerceWithJsonSchema(value, schema) {
|
|
2431
|
+
let nextValue = value;
|
|
2432
|
+
if (Array.isArray(schema.allOf)) {
|
|
2433
|
+
for (const nested of schema.allOf) {
|
|
2434
|
+
nextValue = coerceWithJsonSchema(nextValue, nested);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
if (Array.isArray(schema.anyOf)) {
|
|
2438
|
+
nextValue = coerceWithUnionSchema(nextValue, schema.anyOf);
|
|
2439
|
+
}
|
|
2440
|
+
if (Array.isArray(schema.oneOf)) {
|
|
2441
|
+
nextValue = coerceWithUnionSchema(nextValue, schema.oneOf);
|
|
2442
|
+
}
|
|
2443
|
+
const schemaTypes = getSchemaTypes(schema);
|
|
2444
|
+
const matchesUnionMember = schemaTypes.length > 1 && schemaTypes.some((schemaType) => matchesJsonType(nextValue, schemaType));
|
|
2445
|
+
if (schemaTypes.length > 0 && !matchesUnionMember) {
|
|
2446
|
+
for (const schemaType of schemaTypes) {
|
|
2447
|
+
const candidate = coercePrimitiveByType(nextValue, schemaType);
|
|
2448
|
+
if (candidate !== nextValue) {
|
|
2449
|
+
nextValue = candidate;
|
|
2450
|
+
break;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
if (schemaTypes.includes("object") && isRecord(nextValue) && !Array.isArray(nextValue)) {
|
|
2455
|
+
applySchemaObjectCoercion(nextValue, schema);
|
|
2456
|
+
}
|
|
2457
|
+
if (schemaTypes.includes("array") && Array.isArray(nextValue)) {
|
|
2458
|
+
applySchemaArrayCoercion(nextValue, schema);
|
|
2459
|
+
}
|
|
2460
|
+
return nextValue;
|
|
2461
|
+
}
|
|
2462
|
+
function getValidator(schema) {
|
|
2463
|
+
const key = schema;
|
|
2464
|
+
const cached = validatorCache.get(key);
|
|
2465
|
+
if (cached) {
|
|
2466
|
+
return cached;
|
|
2467
|
+
}
|
|
2468
|
+
const validator = Compile(schema);
|
|
2469
|
+
validatorCache.set(key, validator);
|
|
2470
|
+
return validator;
|
|
2471
|
+
}
|
|
2472
|
+
function formatValidationPath(error) {
|
|
2473
|
+
if (error.keyword === "required") {
|
|
2474
|
+
const requiredProperties = error.params.requiredProperties;
|
|
2475
|
+
const requiredProperty = requiredProperties?.[0];
|
|
2476
|
+
if (requiredProperty) {
|
|
2477
|
+
const basePath = error.instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
2478
|
+
return basePath ? `${basePath}.${requiredProperty}` : requiredProperty;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
const path = error.instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
2482
|
+
return path || "root";
|
|
2483
|
+
}
|
|
2484
|
+
function validateToolCall(tools, toolCall) {
|
|
2485
|
+
const tool = tools.find((t) => t.name === toolCall.name);
|
|
2486
|
+
if (!tool) {
|
|
2487
|
+
throw new Error(`Tool "${toolCall.name}" not found`);
|
|
2488
|
+
}
|
|
2489
|
+
return validateToolArguments(tool, toolCall);
|
|
2490
|
+
}
|
|
2491
|
+
function validateToolArguments(tool, toolCall) {
|
|
2492
|
+
const args = structuredClone(toolCall.arguments);
|
|
2493
|
+
value_exports.Convert(tool.parameters, args);
|
|
2494
|
+
const validator = getValidator(tool.parameters);
|
|
2495
|
+
if (!hasTypeBoxMetadata(tool.parameters) && isJsonSchemaObject(tool.parameters)) {
|
|
2496
|
+
const coerced = coerceWithJsonSchema(args, tool.parameters);
|
|
2497
|
+
if (coerced !== args) {
|
|
2498
|
+
if (isRecord(args) && isRecord(coerced)) {
|
|
2499
|
+
for (const key of Object.keys(args)) {
|
|
2500
|
+
delete args[key];
|
|
2501
|
+
}
|
|
2502
|
+
Object.assign(args, coerced);
|
|
2503
|
+
} else {
|
|
2504
|
+
return validator.Check(coerced) ? coerced : args;
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
if (validator.Check(args)) {
|
|
2509
|
+
return args;
|
|
2510
|
+
}
|
|
2511
|
+
const errors = validator.Errors(args).map((error) => ` - ${formatValidationPath(error)}: ${error.message}`).join("\n") || "Unknown validation error";
|
|
2512
|
+
const errorMessage = `Validation failed for tool "${toolCall.name}":
|
|
2513
|
+
${errors}
|
|
2514
|
+
|
|
2515
|
+
Received arguments:
|
|
2516
|
+
${JSON.stringify(toolCall.arguments, null, 2)}`;
|
|
2517
|
+
throw new Error(errorMessage);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
export {
|
|
2521
|
+
readAbsolutePathEnv,
|
|
2522
|
+
assertProductStatePath,
|
|
2523
|
+
resolveRuntimePaths,
|
|
2524
|
+
shouldUseWindowsShell,
|
|
2525
|
+
processIdExists,
|
|
2526
|
+
isProcessAlive,
|
|
2527
|
+
signalProcessGroupOrProcess,
|
|
2528
|
+
waitForChildProcess,
|
|
2529
|
+
normalizeSocketPath,
|
|
2530
|
+
isBunBinary,
|
|
2531
|
+
SELF_UPDATE_INTERACTIVE_CHILD_ENV,
|
|
2532
|
+
SELF_UPDATE_NOT_ATTEMPTED_EXIT_CODE,
|
|
2533
|
+
getSelfUpdateCommand,
|
|
2534
|
+
getSelfUpdateUnavailableInstruction,
|
|
2535
|
+
getPackageDir,
|
|
2536
|
+
getPhysicalPackageDir,
|
|
2537
|
+
getThemesDir,
|
|
2538
|
+
getExportTemplateDir,
|
|
2539
|
+
getPackageJsonPath,
|
|
2540
|
+
getDocsPath,
|
|
2541
|
+
getChangelogPath,
|
|
2542
|
+
getBundledInteractiveAssetPath,
|
|
2543
|
+
getBundledSkillsDir,
|
|
2544
|
+
PACKAGE_NAME,
|
|
2545
|
+
APP_NAME,
|
|
2546
|
+
APP_TITLE,
|
|
2547
|
+
CONFIG_DIR_NAME,
|
|
2548
|
+
VERSION,
|
|
2549
|
+
ENV_AGENT_DIR,
|
|
2550
|
+
expandTildePath,
|
|
2551
|
+
getAgentDir,
|
|
2552
|
+
getCustomThemesDir,
|
|
2553
|
+
getLogsDir,
|
|
2554
|
+
getClientErrorLogPath,
|
|
2555
|
+
getAgentLogPath,
|
|
2556
|
+
getDaemonLogPath,
|
|
2557
|
+
getDaemonUpdateRestartManifestPath,
|
|
2558
|
+
getLegacyDaemonUpdateRestartManifestPath,
|
|
2559
|
+
appendRotatingLog,
|
|
2560
|
+
getAuthPath,
|
|
2561
|
+
getCronJobsPath,
|
|
2562
|
+
getBinDir,
|
|
2563
|
+
getSessionsDir,
|
|
2564
|
+
getSessionDirEnvOverride,
|
|
2565
|
+
getDebugLogPath,
|
|
2566
|
+
typebox_exports,
|
|
2567
|
+
build_exports,
|
|
2568
|
+
registerApiProvider,
|
|
2569
|
+
isLocalFauxStream,
|
|
2570
|
+
assertBuiltInAttemptSupport,
|
|
2571
|
+
resetApiProviders,
|
|
2572
|
+
streamSimple,
|
|
2573
|
+
completeSimple,
|
|
2574
|
+
isContextOverflow,
|
|
2575
|
+
StringEnum,
|
|
2576
|
+
validateToolArguments,
|
|
2577
|
+
src_exports
|
|
2578
|
+
};
|