@byfriends/agent-core 0.2.1 → 0.2.3
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.
|
@@ -827,6 +827,13 @@ interface McpConnectionManagerOptions {
|
|
|
827
827
|
* `session.log` so MCP events land in the session log too.
|
|
828
828
|
*/
|
|
829
829
|
readonly log?: Logger;
|
|
830
|
+
/**
|
|
831
|
+
* Custom fetch function for HTTP MCP transports. When provided, the
|
|
832
|
+
* connection manager passes it to every `HttpMcpClient` so the
|
|
833
|
+
* transport uses it for all HTTP requests — enabling proxy fallback,
|
|
834
|
+
* custom retries, or test doubles.
|
|
835
|
+
*/
|
|
836
|
+
readonly fetch?: typeof fetch;
|
|
830
837
|
}
|
|
831
838
|
/**
|
|
832
839
|
* Owns the lifecycle of every configured MCP server for a Session.
|
|
@@ -2635,6 +2642,12 @@ interface RuntimeConfig {
|
|
|
2635
2642
|
readonly osEnv: Environment;
|
|
2636
2643
|
readonly urlFetcher?: UrlFetcher | undefined;
|
|
2637
2644
|
readonly webSearcher?: WebSearchProvider | undefined;
|
|
2645
|
+
/**
|
|
2646
|
+
* ProxiedFetch — a `typeof fetch` wrapper that retries through an
|
|
2647
|
+
* HTTP/SOCKS proxy when the direct attempt fails with a retryable error.
|
|
2648
|
+
* Used by MCP HTTP connections, URL fetcher, and web search.
|
|
2649
|
+
*/
|
|
2650
|
+
readonly fetch?: typeof fetch;
|
|
2638
2651
|
}
|
|
2639
2652
|
//#endregion
|
|
2640
2653
|
//#region src/utils/types.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as AGENT_WIRE_PROTOCOL_VERSION } from "./index-DitEeLHK.mjs";
|
|
2
|
-
import { $ as CoreInfo, $n as SessionSkillConfig, $r as resolveByfHome, $t as BackgroundTaskUpdatedEvent, A as QuestionAnswers, Ai as ProviderType, An as TurnStepInterruptedEvent, Ar as LoopStepEndEvent, At as SetModelResult, B as SDKSessionAPI, Bi as LogEntry, Bn as ByfError, Br as BackgroundTaskStatus, Bt as Unsubscribe, C as SDKRPCClient, Ci as PermissionConfigSchema, Cn as ToolProgressEvent, Cr as PromptOrigin, Ct as ResumeSessionPayload, D as ApprovalResponse, Di as PermissionRuleScopeSchema, Dn as TurnEndedEvent, Dr as LoopContentPartEvent, Dt as SetActiveToolsPayload, E as ApprovalRequest, Ei as PermissionRuleSchema, En as TurnEndReason, Er as ToolStoreUpdate, Et as SessionSummary, F as QuestionResult, Fi as ThinkingConfigSchema, Fn as ByfErrorPayload, Fr as ExecutableToolSuccessResult, Ft as SkillSummary, G as AgentAPI, Gi as RootLogger, Gn as ErrorCodes, Gr as parseConfigString, Gt as AgentReplayRecord, H as ToolCallRequest, Hi as LogPayload, Hn as BYF_ERROR_INFO, Hr as OAuthTokenProviderResolver, Ht as WithAgentId, I as SDKAPI, Ii as formatConfigValidationError, In as fromByfErrorPayload, Ir as ToolInputDisplay, It as SteerPayload, J as ByfConfigPatch, Jn as SubagentHandle, Jr as writeConfigFile, Jt as AgentEvent, K as BeginCompactionPayload, Ki as SessionAttachInput, Kn as RuntimeConfig, Kr as readConfigFile, Kt as ResumeSessionResult, L as SDKAgentAPI, Li as getDefaultConfig, Ln as isByfError, Lr as BackgroundLifecycleEvent, Lt as StopBackgroundPayload, M as QuestionOption, Mi as ServicesConfig, Mn as TurnStepStartedEvent, Mr as LoopToolResultEvent, Mt as SetThinkingPayload, N as QuestionRequest, Ni as ServicesConfigSchema, Nn as UsageStatus, Nr as ExecutableToolErrorResult, Nt as ShellExecPayload, O as ApprovalScope, Oi as ProviderConfig, On as TurnStartedEvent, Or as LoopRecordedEvent, Ot as SetByfConfigPayload, P as QuestionResponse, Pi as ThinkingConfig, Pn as WarningEvent, Pr as ExecutableToolResult, Pt as ShellExecResult, Q as CoreAPI, Qn as SessionMeta, Qr as ensureByfHome, Qt as BackgroundTaskTerminatedEvent, R as SDKAgentRPC, Ri as validateConfig, Rn as makeErrorPayload, Rr as BackgroundTaskInfo, Rt as TextPromptPart, S as RPCMethods, Si as PermissionConfig, Sn as ToolListUpdatedReason, Sr as ContextMessage, St as RenameSessionPayload, T as ApprovalDecision, Ti as PermissionRuleDecisionSchema, Tn as ToolUpdate, Tr as UserPromptOrigin, Tt as SessionMetadataPatch, U as ToolCallResponse, Ui as Logger, Un as ByfErrorCode, Ur as configToTomlData, Ut as WithSessionId, V as SDKSessionRPC, Vi as LogLevel, Vn as ByfErrorOptions, Vr as BearerTokenProvider, Vt as UpdateSessionMetadataPayload, W as ActivateSkillPayload, Wi as LoggingConfig, Wn as ByfErrorInfo, Wr as ensureConfigFile, Wt as proxyWithExtraPayload, X as CancelPlanPayload, Xn as Session, Xr as parseBooleanEnv, Xt as AssistantDeltaEvent, Y as CancelPayload, Yn as AgentMeta, Yr as ResolveConfigValueInput, Yt as AgentStatusUpdatedEvent, Z as CloseSessionPayload, Zn as SessionConfig, Zr as resolveConfigValue, Zt as BackgroundTaskStartedEvent, _ as ByfCoreOptions, _i as McpServerStdioConfigSchema, _n as SubagentSpawnedEvent, _r as PermissionMode, _t as PromptPart, a as collectFilesRecursive, ai as ByfConfigSchema, an as Event, ar as redact, at as ForkSessionPayload, b as RPCCallOptions, bi as OAuthRef, bn as ToolCallStartedEvent, br as CompactionResult, bt as RegisterToolPayload, c as WIRE_PROTOCOL_VERSION, ci as HookDefConfig, cn as McpOAuthAuthorizationUrlUpdateData, cr as ToolInfo, ct as GetBackgroundPayload, d as normalizeTimestampMs, di as LoopControlSchema, dn as ObservationMaskingAppliedEvent, dr as AgentRecord, dt as JsonValue, ei as resolveConfigPath, en as CompactionBlockedEvent, er as TelemetryClient, et as CreateSessionPayload, f as scanSessionWire, fi as McpServerConfig, fn as PruningAppliedEvent, fr as AgentRecordEvents, ft as ListSessionsPayload, g as ByfCore, gi as McpServerStdioConfig, gn as SubagentFailedEvent, gr as PermissionApprovalResultRecord, gt as PromptInput, h as AgentType, hi as McpServerHttpConfigSchema, hn as SubagentCompletedEvent, hr as UsageRecordScope, ht as PlanData, i as ExtraZipEntry, ii as ByfConfigPatchSchema, in as ErrorEvent, ir as log, it as ExportSessionResult, j as QuestionItem, ji as ProviderTypeSchema, jn as TurnStepRetryingEvent, jr as LoopToolCallEvent, jt as SetPermissionPayload, k as QuestionAnswerMethod, ki as ProviderConfigSchema, kn as TurnStepCompletedEvent, kr as LoopStepBeginEvent, kt as SetModelPayload, l as buildExportManifest, li as HookDefSchema, ln as McpServerStatusEvent, lr as ToolSource, lt as JsonObject, m as AgentConfig, mi as McpServerHttpConfig, mn as SkillActivatedEvent, mr as AgentRecordPersistence, mt as McpStartupMetrics, n as ResolveLoggingInput, ni as BackgroundConfig, nn as CompactionCompletedEvent, nr as flushDiagnosticLogs, nt as ExportSessionManifest, o as writeExportZip, oi as ByfServiceConfig, on as HookResultEvent, or as resolveGlobalLogPath, ot as GetBackgroundOutputPathPayload, p as Agent, pi as McpServerConfigSchema, pn as SessionMetaUpdatedEvent, pr as AgentRecordOf, pt as McpServerInfo, q as ByfConfig, qi as SessionLogHandle, qn as SessionSubagentHost, qr as transformTomlData, qt as ResumedAgentState, r as resolveLoggingConfig, ri as BackgroundConfigSchema, rn as CompactionStartedEvent, rr as getRootLogger, rt as ExportSessionPayload, s as exportSessionDirectory, si as ByfServiceConfigSchema, sn as MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE, sr as BuiltinTool, st as GetBackgroundOutputPayload, t as buildPromptPlan, ti as mergeConfigPatch, tn as CompactionCancelledEvent, tr as TelemetryProperties, tt as EmptyPayload, u as SessionWireScan, ui as LoopControl, un as McpServerStatusPayload, ur as UserToolRegistration, ut as JsonPrimitive, v as CoreRPC, vi as ModelAlias, vn as ThinkingDeltaEvent, vr as AgentConfigUpdateData, vt as PromptPayload, w as createRPC, wi as PermissionModeSchema, wn as ToolResultEvent, wr as USER_PROMPT_ORIGIN, wt as SessionAPI, x as RPCClient, xi as OAuthRefSchema, xn as ToolListUpdatedEvent, xr as AgentContextData, xt as RemoveByfProviderPayload, y as CoreRPCClient, yi as ModelAliasSchema, yn as ToolCallDeltaEvent, yr as CompactionBeginData, yt as ReconnectMcpServerPayload, z as SDKRPC, zi as LogContext, zn as toByfErrorPayload, zr as BackgroundTaskKind, zt as UnregisterToolPayload } from "./index-
|
|
2
|
+
import { $ as CoreInfo, $n as SessionSkillConfig, $r as resolveByfHome, $t as BackgroundTaskUpdatedEvent, A as QuestionAnswers, Ai as ProviderType, An as TurnStepInterruptedEvent, Ar as LoopStepEndEvent, At as SetModelResult, B as SDKSessionAPI, Bi as LogEntry, Bn as ByfError, Br as BackgroundTaskStatus, Bt as Unsubscribe, C as SDKRPCClient, Ci as PermissionConfigSchema, Cn as ToolProgressEvent, Cr as PromptOrigin, Ct as ResumeSessionPayload, D as ApprovalResponse, Di as PermissionRuleScopeSchema, Dn as TurnEndedEvent, Dr as LoopContentPartEvent, Dt as SetActiveToolsPayload, E as ApprovalRequest, Ei as PermissionRuleSchema, En as TurnEndReason, Er as ToolStoreUpdate, Et as SessionSummary, F as QuestionResult, Fi as ThinkingConfigSchema, Fn as ByfErrorPayload, Fr as ExecutableToolSuccessResult, Ft as SkillSummary, G as AgentAPI, Gi as RootLogger, Gn as ErrorCodes, Gr as parseConfigString, Gt as AgentReplayRecord, H as ToolCallRequest, Hi as LogPayload, Hn as BYF_ERROR_INFO, Hr as OAuthTokenProviderResolver, Ht as WithAgentId, I as SDKAPI, Ii as formatConfigValidationError, In as fromByfErrorPayload, Ir as ToolInputDisplay, It as SteerPayload, J as ByfConfigPatch, Jn as SubagentHandle, Jr as writeConfigFile, Jt as AgentEvent, K as BeginCompactionPayload, Ki as SessionAttachInput, Kn as RuntimeConfig, Kr as readConfigFile, Kt as ResumeSessionResult, L as SDKAgentAPI, Li as getDefaultConfig, Ln as isByfError, Lr as BackgroundLifecycleEvent, Lt as StopBackgroundPayload, M as QuestionOption, Mi as ServicesConfig, Mn as TurnStepStartedEvent, Mr as LoopToolResultEvent, Mt as SetThinkingPayload, N as QuestionRequest, Ni as ServicesConfigSchema, Nn as UsageStatus, Nr as ExecutableToolErrorResult, Nt as ShellExecPayload, O as ApprovalScope, Oi as ProviderConfig, On as TurnStartedEvent, Or as LoopRecordedEvent, Ot as SetByfConfigPayload, P as QuestionResponse, Pi as ThinkingConfig, Pn as WarningEvent, Pr as ExecutableToolResult, Pt as ShellExecResult, Q as CoreAPI, Qn as SessionMeta, Qr as ensureByfHome, Qt as BackgroundTaskTerminatedEvent, R as SDKAgentRPC, Ri as validateConfig, Rn as makeErrorPayload, Rr as BackgroundTaskInfo, Rt as TextPromptPart, S as RPCMethods, Si as PermissionConfig, Sn as ToolListUpdatedReason, Sr as ContextMessage, St as RenameSessionPayload, T as ApprovalDecision, Ti as PermissionRuleDecisionSchema, Tn as ToolUpdate, Tr as UserPromptOrigin, Tt as SessionMetadataPatch, U as ToolCallResponse, Ui as Logger, Un as ByfErrorCode, Ur as configToTomlData, Ut as WithSessionId, V as SDKSessionRPC, Vi as LogLevel, Vn as ByfErrorOptions, Vr as BearerTokenProvider, Vt as UpdateSessionMetadataPayload, W as ActivateSkillPayload, Wi as LoggingConfig, Wn as ByfErrorInfo, Wr as ensureConfigFile, Wt as proxyWithExtraPayload, X as CancelPlanPayload, Xn as Session, Xr as parseBooleanEnv, Xt as AssistantDeltaEvent, Y as CancelPayload, Yn as AgentMeta, Yr as ResolveConfigValueInput, Yt as AgentStatusUpdatedEvent, Z as CloseSessionPayload, Zn as SessionConfig, Zr as resolveConfigValue, Zt as BackgroundTaskStartedEvent, _ as ByfCoreOptions, _i as McpServerStdioConfigSchema, _n as SubagentSpawnedEvent, _r as PermissionMode, _t as PromptPart, a as collectFilesRecursive, ai as ByfConfigSchema, an as Event, ar as redact, at as ForkSessionPayload, b as RPCCallOptions, bi as OAuthRef, bn as ToolCallStartedEvent, br as CompactionResult, bt as RegisterToolPayload, c as WIRE_PROTOCOL_VERSION, ci as HookDefConfig, cn as McpOAuthAuthorizationUrlUpdateData, cr as ToolInfo, ct as GetBackgroundPayload, d as normalizeTimestampMs, di as LoopControlSchema, dn as ObservationMaskingAppliedEvent, dr as AgentRecord, dt as JsonValue, ei as resolveConfigPath, en as CompactionBlockedEvent, er as TelemetryClient, et as CreateSessionPayload, f as scanSessionWire, fi as McpServerConfig, fn as PruningAppliedEvent, fr as AgentRecordEvents, ft as ListSessionsPayload, g as ByfCore, gi as McpServerStdioConfig, gn as SubagentFailedEvent, gr as PermissionApprovalResultRecord, gt as PromptInput, h as AgentType, hi as McpServerHttpConfigSchema, hn as SubagentCompletedEvent, hr as UsageRecordScope, ht as PlanData, i as ExtraZipEntry, ii as ByfConfigPatchSchema, in as ErrorEvent, ir as log, it as ExportSessionResult, j as QuestionItem, ji as ProviderTypeSchema, jn as TurnStepRetryingEvent, jr as LoopToolCallEvent, jt as SetPermissionPayload, k as QuestionAnswerMethod, ki as ProviderConfigSchema, kn as TurnStepCompletedEvent, kr as LoopStepBeginEvent, kt as SetModelPayload, l as buildExportManifest, li as HookDefSchema, ln as McpServerStatusEvent, lr as ToolSource, lt as JsonObject, m as AgentConfig, mi as McpServerHttpConfig, mn as SkillActivatedEvent, mr as AgentRecordPersistence, mt as McpStartupMetrics, n as ResolveLoggingInput, ni as BackgroundConfig, nn as CompactionCompletedEvent, nr as flushDiagnosticLogs, nt as ExportSessionManifest, o as writeExportZip, oi as ByfServiceConfig, on as HookResultEvent, or as resolveGlobalLogPath, ot as GetBackgroundOutputPathPayload, p as Agent, pi as McpServerConfigSchema, pn as SessionMetaUpdatedEvent, pr as AgentRecordOf, pt as McpServerInfo, q as ByfConfig, qi as SessionLogHandle, qn as SessionSubagentHost, qr as transformTomlData, qt as ResumedAgentState, r as resolveLoggingConfig, ri as BackgroundConfigSchema, rn as CompactionStartedEvent, rr as getRootLogger, rt as ExportSessionPayload, s as exportSessionDirectory, si as ByfServiceConfigSchema, sn as MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE, sr as BuiltinTool, st as GetBackgroundOutputPayload, t as buildPromptPlan, ti as mergeConfigPatch, tn as CompactionCancelledEvent, tr as TelemetryProperties, tt as EmptyPayload, u as SessionWireScan, ui as LoopControl, un as McpServerStatusPayload, ur as UserToolRegistration, ut as JsonPrimitive, v as CoreRPC, vi as ModelAlias, vn as ThinkingDeltaEvent, vr as AgentConfigUpdateData, vt as PromptPayload, w as createRPC, wi as PermissionModeSchema, wn as ToolResultEvent, wr as USER_PROMPT_ORIGIN, wt as SessionAPI, x as RPCClient, xi as OAuthRefSchema, xn as ToolListUpdatedEvent, xr as AgentContextData, xt as RemoveByfProviderPayload, y as CoreRPCClient, yi as ModelAliasSchema, yn as ToolCallDeltaEvent, yr as CompactionBeginData, yt as ReconnectMcpServerPayload, z as SDKRPC, zi as LogContext, zn as toByfErrorPayload, zr as BackgroundTaskKind, zt as UnregisterToolPayload } from "./index-C2yfSu8d.mjs";
|
|
3
3
|
export { AGENT_WIRE_PROTOCOL_VERSION, ActivateSkillPayload, Agent, AgentAPI, AgentConfig, type AgentConfigUpdateData, type AgentContextData, AgentEvent, AgentMeta, type AgentRecord, type AgentRecordEvents, type AgentRecordOf, type AgentRecordPersistence, AgentReplayRecord, AgentStatusUpdatedEvent, AgentType, ApprovalDecision, ApprovalRequest, ApprovalResponse, ApprovalScope, AssistantDeltaEvent, BYF_ERROR_INFO, BackgroundConfig, BackgroundConfigSchema, type BackgroundLifecycleEvent, type BackgroundTaskInfo, type BackgroundTaskKind, BackgroundTaskStartedEvent, type BackgroundTaskStatus, BackgroundTaskTerminatedEvent, BackgroundTaskUpdatedEvent, type BearerTokenProvider, BeginCompactionPayload, type BuiltinTool, ByfConfigPatchSchema, ByfConfigSchema, ByfCore, ByfCoreOptions, ByfError, type ByfErrorCode, type ByfErrorInfo, type ByfErrorOptions, type ByfErrorPayload, ByfServiceConfig, ByfServiceConfigSchema, CancelPayload, CancelPlanPayload, CloseSessionPayload, type CompactionBeginData, CompactionBlockedEvent, CompactionCancelledEvent, CompactionCompletedEvent, CompactionResult, CompactionStartedEvent, type ContextMessage, CoreAPI, CoreInfo, CoreRPC, CoreRPCClient, CreateSessionPayload, EmptyPayload, ErrorCodes, ErrorEvent, Event, type ExecutableToolErrorResult, type ExecutableToolResult, type ExecutableToolSuccessResult, ExportSessionManifest, ExportSessionPayload, ExportSessionResult, ExtraZipEntry, ForkSessionPayload, GetBackgroundOutputPathPayload, GetBackgroundOutputPayload, GetBackgroundPayload, HookDefConfig, HookDefSchema, HookResultEvent, JsonObject, JsonPrimitive, JsonValue, ListSessionsPayload, type LogContext, type LogEntry, type LogLevel, type LogPayload, type Logger, type LoggingConfig, type LoopContentPartEvent, LoopControl, LoopControlSchema, type LoopRecordedEvent, type LoopStepBeginEvent, type LoopStepEndEvent, type LoopToolCallEvent, type LoopToolResultEvent, MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE, McpOAuthAuthorizationUrlUpdateData, McpServerConfig, McpServerConfigSchema, McpServerHttpConfig, McpServerHttpConfigSchema, McpServerInfo, McpServerStatusEvent, McpServerStatusPayload, McpServerStdioConfig, McpServerStdioConfigSchema, McpStartupMetrics, ModelAlias, ModelAliasSchema, OAuthRef, OAuthRefSchema, type OAuthTokenProviderResolver, ObservationMaskingAppliedEvent, type PermissionApprovalResultRecord, PermissionConfig, PermissionConfigSchema, type PermissionMode, PermissionModeSchema, PermissionRuleDecisionSchema, PermissionRuleSchema, PermissionRuleScopeSchema, PlanData, PromptInput, type PromptOrigin, PromptPart, PromptPayload, ProviderConfig, ProviderConfigSchema, ProviderType, ProviderTypeSchema, PruningAppliedEvent, QuestionAnswerMethod, QuestionAnswers, QuestionItem, QuestionOption, QuestionRequest, QuestionResponse, QuestionResult, RPCCallOptions, RPCClient, RPCMethods, ReconnectMcpServerPayload, RegisterToolPayload, RemoveByfProviderPayload, RenameSessionPayload, ResolveConfigValueInput, type ResolveLoggingInput, ResumeSessionPayload, ResumeSessionResult, ResumedAgentState, type RootLogger, type RuntimeConfig, SDKAPI, SDKAgentAPI, SDKAgentRPC, SDKRPC, SDKRPCClient, SDKSessionAPI, SDKSessionRPC, ServicesConfig, ServicesConfigSchema, Session, SessionAPI, type SessionAttachInput, SessionConfig, type SessionLogHandle, SessionMeta, SessionMetaUpdatedEvent, SessionMetadataPatch, SessionSkillConfig, SessionSubagentHost, SessionSummary, SessionWireScan, SetActiveToolsPayload, SetByfConfigPayload, SetModelPayload, SetModelResult, SetPermissionPayload, SetThinkingPayload, ShellExecPayload, ShellExecResult, SkillActivatedEvent, SkillSummary, SteerPayload, StopBackgroundPayload, SubagentCompletedEvent, SubagentFailedEvent, SubagentHandle, SubagentSpawnedEvent, type TelemetryClient, type TelemetryProperties, TextPromptPart, ThinkingConfig, ThinkingConfigSchema, ThinkingDeltaEvent, ToolCallDeltaEvent, ToolCallRequest, ToolCallResponse, ToolCallStartedEvent, type ToolInfo, type ToolInputDisplay, ToolListUpdatedEvent, ToolListUpdatedReason, ToolProgressEvent, ToolResultEvent, type ToolSource, type ToolStoreUpdate, ToolUpdate, TurnEndReason, TurnEndedEvent, TurnStartedEvent, TurnStepCompletedEvent, TurnStepInterruptedEvent, TurnStepRetryingEvent, TurnStepStartedEvent, USER_PROMPT_ORIGIN, UnregisterToolPayload, Unsubscribe, UpdateSessionMetadataPayload, type UsageRecordScope, UsageStatus, type UserPromptOrigin, type UserToolRegistration, WIRE_PROTOCOL_VERSION, WarningEvent, WithAgentId, WithSessionId, buildExportManifest, buildPromptPlan, collectFilesRecursive, configToTomlData, createRPC, ensureByfHome, ensureConfigFile, exportSessionDirectory, flushDiagnosticLogs, formatConfigValidationError, fromByfErrorPayload, getDefaultConfig, getRootLogger, isByfError, log, makeErrorPayload, mergeConfigPatch, normalizeTimestampMs, parseBooleanEnv, parseConfigString, proxyWithExtraPayload, readConfigFile, redact, resolveByfHome, resolveConfigPath, resolveConfigValue, resolveGlobalLogPath, resolveLoggingConfig, scanSessionWire, toByfErrorPayload, transformTomlData, validateConfig, writeConfigFile, writeExportZip };
|
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { fromBuffer } from "yauzl";
|
|
|
23
23
|
import { StringDecoder } from "node:string_decoder";
|
|
24
24
|
import { createControlledPromise, objectMap, sleep } from "@antfu/utils";
|
|
25
25
|
import * as retry from "retry";
|
|
26
|
-
import { spawn } from "node:child_process";
|
|
26
|
+
import { execSync, spawn } from "node:child_process";
|
|
27
27
|
import Ajv from "ajv";
|
|
28
28
|
import Ajv2019 from "ajv/dist/2019.js";
|
|
29
29
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
@@ -38,6 +38,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|
|
38
38
|
import { localKaos } from "@byfriends/kaos";
|
|
39
39
|
import { Readability } from "@mozilla/readability";
|
|
40
40
|
import { parseHTML } from "linkedom";
|
|
41
|
+
import { ProxyAgent } from "undici";
|
|
41
42
|
//#region \0rolldown/runtime.js
|
|
42
43
|
var __create = Object.create;
|
|
43
44
|
var __defProp = Object.defineProperty;
|
|
@@ -1678,13 +1679,18 @@ var BackgroundProcessManager = class {
|
|
|
1678
1679
|
* restart. Active-only mode never shows ghosts (they're terminal).
|
|
1679
1680
|
*/
|
|
1680
1681
|
list(activeOnly = true, limit) {
|
|
1682
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1681
1683
|
const result = [];
|
|
1682
1684
|
for (const entry of this.processes.values()) {
|
|
1683
1685
|
if (activeOnly && TERMINAL_STATUSES.has(entry.status)) continue;
|
|
1686
|
+
if (seen.has(entry.taskId)) continue;
|
|
1687
|
+
seen.add(entry.taskId);
|
|
1684
1688
|
result.push(this.toInfo(entry));
|
|
1685
1689
|
if (limit !== void 0 && result.length >= limit) return result;
|
|
1686
1690
|
}
|
|
1687
1691
|
if (!activeOnly) for (const ghost of this.ghosts.values()) {
|
|
1692
|
+
if (seen.has(ghost.taskId)) continue;
|
|
1693
|
+
seen.add(ghost.taskId);
|
|
1688
1694
|
result.push(ghost);
|
|
1689
1695
|
if (limit !== void 0 && result.length >= limit) return result;
|
|
1690
1696
|
}
|
|
@@ -16488,7 +16494,8 @@ var McpConnectionManager = class {
|
|
|
16488
16494
|
return new HttpMcpClient(config, {
|
|
16489
16495
|
toolCallTimeoutMs,
|
|
16490
16496
|
envLookup: this.options.envLookup,
|
|
16491
|
-
oauthProvider: this.resolveOAuthProvider(config, name)
|
|
16497
|
+
oauthProvider: this.resolveOAuthProvider(config, name),
|
|
16498
|
+
fetch: this.options.fetch
|
|
16492
16499
|
});
|
|
16493
16500
|
}
|
|
16494
16501
|
resolveOAuthProvider(config, name) {
|
|
@@ -17076,7 +17083,8 @@ var Session = class {
|
|
|
17076
17083
|
this.skills = new SkillRegistry({ sessionId: config.id });
|
|
17077
17084
|
this.mcp = new McpConnectionManager({
|
|
17078
17085
|
oauthService: new McpOAuthService({ byfHomeDir: config.byfHomeDir }),
|
|
17079
|
-
log: this.log
|
|
17086
|
+
log: this.log,
|
|
17087
|
+
fetch: config.runtime.fetch
|
|
17080
17088
|
});
|
|
17081
17089
|
this.mcp.onStatusChange((entry) => {
|
|
17082
17090
|
this.onMcpServerStatusChange(entry);
|
|
@@ -17548,6 +17556,213 @@ var LocalFetchURLProvider = class {
|
|
|
17548
17556
|
}
|
|
17549
17557
|
};
|
|
17550
17558
|
//#endregion
|
|
17559
|
+
//#region src/tools/providers/proxied-fetch.ts
|
|
17560
|
+
/**
|
|
17561
|
+
* ProxiedFetch — a `typeof fetch` wrapper with automatic proxy fallback.
|
|
17562
|
+
*
|
|
17563
|
+
* Flow:
|
|
17564
|
+
* 1. Attempt the request with a 60-second timeout (via AbortController,
|
|
17565
|
+
* respecting any external AbortSignal).
|
|
17566
|
+
* 2. If the request succeeds, return the response.
|
|
17567
|
+
* 3. If the request fails with a retryable error and a proxy is detected,
|
|
17568
|
+
* retry through the proxy (also 60-second timeout).
|
|
17569
|
+
* 4. If the request fails with a non-retryable error, or no proxy is
|
|
17570
|
+
* configured, propagate the original error / response.
|
|
17571
|
+
* 5. If the proxy retry also fails, propagate the proxy error in the same
|
|
17572
|
+
* format as a normal fetch error — no special wrapping.
|
|
17573
|
+
*
|
|
17574
|
+
* Proxy detection reads environment variables only (macOS `scutil --proxy`
|
|
17575
|
+
* is added in a separate slice). Env vars take priority over system proxy.
|
|
17576
|
+
*/
|
|
17577
|
+
const REQUEST_TIMEOUT_MS = 6e4;
|
|
17578
|
+
const RETRYABLE_HTTP_STATUSES = new Set([
|
|
17579
|
+
403,
|
|
17580
|
+
429,
|
|
17581
|
+
502,
|
|
17582
|
+
503,
|
|
17583
|
+
504
|
|
17584
|
+
]);
|
|
17585
|
+
const RETRYABLE_NETWORK_CODES = new Set([
|
|
17586
|
+
"ECONNREFUSED",
|
|
17587
|
+
"ECONNRESET",
|
|
17588
|
+
"ENOTFOUND",
|
|
17589
|
+
"ETIMEDOUT",
|
|
17590
|
+
"EPIPE",
|
|
17591
|
+
"EAI_AGAIN"
|
|
17592
|
+
]);
|
|
17593
|
+
const HTTPS_PROXY_KEYS = ["HTTPS_PROXY", "https_proxy"];
|
|
17594
|
+
const HTTP_PROXY_KEYS = ["HTTP_PROXY", "http_proxy"];
|
|
17595
|
+
const ALL_PROXY_KEYS = ["ALL_PROXY", "all_proxy"];
|
|
17596
|
+
const SOCKS_PROXY_KEYS = ["SOCKS_PROXY", "socks_proxy"];
|
|
17597
|
+
const NO_PROXY_KEYS = ["NO_PROXY", "no_proxy"];
|
|
17598
|
+
/**
|
|
17599
|
+
* Determine the proxy URL for a given request URL based on environment
|
|
17600
|
+
* variables and optional system proxy settings.
|
|
17601
|
+
*
|
|
17602
|
+
* Env vars always take priority over system proxy.
|
|
17603
|
+
*
|
|
17604
|
+
* Priority for HTTPS requests:
|
|
17605
|
+
* HTTPS_PROXY → system HTTPS → ALL_PROXY → SOCKS_PROXY → system SOCKS → HTTP_PROXY → system HTTP
|
|
17606
|
+
* Priority for HTTP requests:
|
|
17607
|
+
* HTTP_PROXY → system HTTP → ALL_PROXY → SOCKS_PROXY → system SOCKS
|
|
17608
|
+
*/
|
|
17609
|
+
function getProxyForUrl(requestUrl, envLookup, systemProxy) {
|
|
17610
|
+
if (new URL(requestUrl).protocol === "https:") return firstDefined(HTTPS_PROXY_KEYS, envLookup) ?? systemProxy?.httpsProxy ?? firstDefined(ALL_PROXY_KEYS, envLookup) ?? firstDefined(SOCKS_PROXY_KEYS, envLookup) ?? systemProxy?.socksProxy ?? firstDefined(HTTP_PROXY_KEYS, envLookup) ?? systemProxy?.httpProxy;
|
|
17611
|
+
return firstDefined(HTTP_PROXY_KEYS, envLookup) ?? systemProxy?.httpProxy ?? firstDefined(ALL_PROXY_KEYS, envLookup) ?? firstDefined(SOCKS_PROXY_KEYS, envLookup) ?? systemProxy?.socksProxy;
|
|
17612
|
+
}
|
|
17613
|
+
/**
|
|
17614
|
+
* Classify an error or response as retryable (should trigger proxy fallback).
|
|
17615
|
+
*
|
|
17616
|
+
* Retryable: network-level errors (DNS failure, ECONNREFUSED, ECONNRESET,
|
|
17617
|
+
* timeout, abort) and HTTP 403, 429, 502, 503, 504.
|
|
17618
|
+
* Non-retryable: HTTP 4xx (except 403/429) and everything else.
|
|
17619
|
+
*/
|
|
17620
|
+
function isRetryableError(error) {
|
|
17621
|
+
if (error instanceof TypeError && error.cause && typeof error.cause === "object") {
|
|
17622
|
+
const code = error.cause.code;
|
|
17623
|
+
if (typeof code === "string" && RETRYABLE_NETWORK_CODES.has(code)) return true;
|
|
17624
|
+
}
|
|
17625
|
+
if (error instanceof DOMException && error.name === "AbortError") return true;
|
|
17626
|
+
if (error instanceof Response) return RETRYABLE_HTTP_STATUSES.has(error.status);
|
|
17627
|
+
return false;
|
|
17628
|
+
}
|
|
17629
|
+
/**
|
|
17630
|
+
* Check whether a hostname matches the NO_PROXY list.
|
|
17631
|
+
*
|
|
17632
|
+
* Entries can be:
|
|
17633
|
+
* - `*` → match everything
|
|
17634
|
+
* - `.example.com` → domain suffix (matches `sub.example.com` and `example.com`)
|
|
17635
|
+
* - `example.com` → exact match + suffix match (matches `sub.example.com`)
|
|
17636
|
+
* - `127.0.0.1` → exact IP/hostname match
|
|
17637
|
+
*/
|
|
17638
|
+
function isNoProxyHost(hostname, noProxyValue) {
|
|
17639
|
+
if (noProxyValue === void 0 || noProxyValue.length === 0) return false;
|
|
17640
|
+
const entries = noProxyValue.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
17641
|
+
const host = hostname.toLowerCase();
|
|
17642
|
+
for (const entry of entries) {
|
|
17643
|
+
if (entry === "*") return true;
|
|
17644
|
+
if (entry.startsWith(".")) {
|
|
17645
|
+
if (host.endsWith(entry) || host === entry.slice(1)) return true;
|
|
17646
|
+
} else if (host === entry || host.endsWith("." + entry)) return true;
|
|
17647
|
+
}
|
|
17648
|
+
return false;
|
|
17649
|
+
}
|
|
17650
|
+
/**
|
|
17651
|
+
* Create a `fetch`-compatible function that adds proxy fallback behaviour.
|
|
17652
|
+
*
|
|
17653
|
+
* - Successful requests are returned as-is.
|
|
17654
|
+
* - Retryable failures (network errors, HTTP 403/429/5xx) trigger a single
|
|
17655
|
+
* retry through the proxy detected from environment variables.
|
|
17656
|
+
* - If no proxy is configured, or the error is non-retryable, the original
|
|
17657
|
+
* error/response is propagated unchanged.
|
|
17658
|
+
*/
|
|
17659
|
+
function createProxiedFetch(deps) {
|
|
17660
|
+
const envLookup = deps.envLookup;
|
|
17661
|
+
const innerFetch = deps.innerFetch ?? globalThis.fetch.bind(globalThis);
|
|
17662
|
+
const proxiedFetch = async (input, init) => {
|
|
17663
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17664
|
+
const noProxy = firstDefined(NO_PROXY_KEYS, envLookup);
|
|
17665
|
+
const hostname = new URL(url).hostname;
|
|
17666
|
+
const sysProxy = deps.systemProxy?.();
|
|
17667
|
+
const proxyUrl = getProxyForUrl(url, envLookup, sysProxy);
|
|
17668
|
+
const noProxyMatch = noProxy !== void 0 && isNoProxyHost(hostname, noProxy);
|
|
17669
|
+
const controller = new AbortController();
|
|
17670
|
+
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
17671
|
+
if (init?.signal) if (init.signal.aborted) {
|
|
17672
|
+
clearTimeout(timeoutId);
|
|
17673
|
+
controller.abort();
|
|
17674
|
+
} else init.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
17675
|
+
const mergedInit = {
|
|
17676
|
+
...init,
|
|
17677
|
+
signal: controller.signal
|
|
17678
|
+
};
|
|
17679
|
+
try {
|
|
17680
|
+
const response = await innerFetch(input, mergedInit);
|
|
17681
|
+
clearTimeout(timeoutId);
|
|
17682
|
+
if (!response.ok && isRetryableError(response) && proxyUrl && !noProxyMatch) return await retryViaProxy(input, init, proxyUrl, innerFetch);
|
|
17683
|
+
return response;
|
|
17684
|
+
} catch (error) {
|
|
17685
|
+
clearTimeout(timeoutId);
|
|
17686
|
+
if (isRetryableError(error) && proxyUrl && !noProxyMatch) return await retryViaProxy(input, init, proxyUrl, innerFetch);
|
|
17687
|
+
throw error;
|
|
17688
|
+
}
|
|
17689
|
+
};
|
|
17690
|
+
return proxiedFetch;
|
|
17691
|
+
}
|
|
17692
|
+
async function retryViaProxy(input, init, proxyUrl, innerFetch) {
|
|
17693
|
+
const controller = new AbortController();
|
|
17694
|
+
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
17695
|
+
if (init?.signal) if (init.signal.aborted) {
|
|
17696
|
+
clearTimeout(timeoutId);
|
|
17697
|
+
controller.abort();
|
|
17698
|
+
} else init.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
17699
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
17700
|
+
const retryInit = {
|
|
17701
|
+
...init,
|
|
17702
|
+
signal: controller.signal,
|
|
17703
|
+
dispatcher
|
|
17704
|
+
};
|
|
17705
|
+
try {
|
|
17706
|
+
const response = await innerFetch(input, retryInit);
|
|
17707
|
+
clearTimeout(timeoutId);
|
|
17708
|
+
return response;
|
|
17709
|
+
} catch (error) {
|
|
17710
|
+
clearTimeout(timeoutId);
|
|
17711
|
+
throw error;
|
|
17712
|
+
}
|
|
17713
|
+
}
|
|
17714
|
+
function firstDefined(keys, lookup) {
|
|
17715
|
+
for (const key of keys) {
|
|
17716
|
+
const value = lookup(key);
|
|
17717
|
+
if (value !== void 0 && value.length > 0) return value;
|
|
17718
|
+
}
|
|
17719
|
+
}
|
|
17720
|
+
//#endregion
|
|
17721
|
+
//#region src/tools/providers/system-proxy.ts
|
|
17722
|
+
/**
|
|
17723
|
+
* macOS system proxy detection via `scutil --proxy`.
|
|
17724
|
+
*
|
|
17725
|
+
* Parses the scutil output to extract HTTP, HTTPS, and SOCKS proxy settings.
|
|
17726
|
+
* On non-darwin platforms, returns an empty object.
|
|
17727
|
+
*/
|
|
17728
|
+
/**
|
|
17729
|
+
* Detect macOS system proxy settings by running `scutil --proxy`.
|
|
17730
|
+
*
|
|
17731
|
+
* On non-darwin platforms, returns `{}` immediately.
|
|
17732
|
+
* If `scutil` fails or produces unparseable output, returns `{}`.
|
|
17733
|
+
*/
|
|
17734
|
+
function detectSystemProxy(options) {
|
|
17735
|
+
if ((options?.platform ?? process.platform) !== "darwin") return {};
|
|
17736
|
+
const runCmd = options?.execSync ?? ((cmd) => execSync(cmd, { encoding: "utf-8" }));
|
|
17737
|
+
let raw;
|
|
17738
|
+
try {
|
|
17739
|
+
raw = runCmd("scutil --proxy");
|
|
17740
|
+
} catch {
|
|
17741
|
+
return {};
|
|
17742
|
+
}
|
|
17743
|
+
return parseScutilProxy(raw);
|
|
17744
|
+
}
|
|
17745
|
+
function parseScutilProxy(raw) {
|
|
17746
|
+
const http = extractProxyEntry(raw, "HTTP");
|
|
17747
|
+
const https = extractProxyEntry(raw, "HTTPS");
|
|
17748
|
+
const socks = extractProxyEntry(raw, "SOCKS");
|
|
17749
|
+
return {
|
|
17750
|
+
...http.enabled ? { httpProxy: `http://${http.host}:${http.port}` } : void 0,
|
|
17751
|
+
...https.enabled ? { httpsProxy: `http://${https.host}:${https.port}` } : void 0,
|
|
17752
|
+
...socks.enabled ? { socksProxy: `socks5://${socks.host}:${socks.port}` } : void 0
|
|
17753
|
+
};
|
|
17754
|
+
}
|
|
17755
|
+
function extractProxyEntry(raw, prefix) {
|
|
17756
|
+
const enableMatch = raw.match(new RegExp(`${prefix}Enable\\s*:\\s*(\\d+)`));
|
|
17757
|
+
const hostMatch = raw.match(new RegExp(`${prefix}Proxy\\s*:\\s*(\\S+)`));
|
|
17758
|
+
const portMatch = raw.match(new RegExp(`${prefix}Port\\s*:\\s*(\\d+)`));
|
|
17759
|
+
return {
|
|
17760
|
+
enabled: enableMatch?.[1] === "1",
|
|
17761
|
+
host: hostMatch?.[1] ?? "",
|
|
17762
|
+
port: portMatch?.[1] ? parseInt(portMatch[1], 10) : 0
|
|
17763
|
+
};
|
|
17764
|
+
}
|
|
17765
|
+
//#endregion
|
|
17551
17766
|
//#region src/tools/providers/remote-fetch-url.ts
|
|
17552
17767
|
/**
|
|
17553
17768
|
* RemoteFetchURLProvider — host-side UrlFetcher.
|
|
@@ -19831,21 +20046,28 @@ var ByfCore = class {
|
|
|
19831
20046
|
}
|
|
19832
20047
|
};
|
|
19833
20048
|
async function createRuntimeConfig(input) {
|
|
19834
|
-
const
|
|
20049
|
+
const proxiedFetch = createProxiedFetch({
|
|
20050
|
+
envLookup: (key) => process.env[key],
|
|
20051
|
+
systemProxy: () => detectSystemProxy()
|
|
20052
|
+
});
|
|
20053
|
+
const localFetcher = new LocalFetchURLProvider({ fetchImpl: proxiedFetch });
|
|
19835
20054
|
const searchService = input.config.services?.byfSearch;
|
|
19836
20055
|
const fetchService = input.config.services?.byfFetch;
|
|
19837
20056
|
return {
|
|
19838
20057
|
kaos: localKaos,
|
|
19839
20058
|
osEnv: await detectEnvironmentFromNode(),
|
|
20059
|
+
fetch: proxiedFetch,
|
|
19840
20060
|
urlFetcher: fetchService?.baseUrl === void 0 ? localFetcher : new RemoteFetchURLProvider({
|
|
19841
20061
|
baseUrl: fetchService.baseUrl,
|
|
19842
20062
|
localFallback: localFetcher,
|
|
19843
20063
|
defaultHeaders: input.byfRequestHeaders,
|
|
20064
|
+
fetchImpl: proxiedFetch,
|
|
19844
20065
|
...serviceCredentials(fetchService, input.resolveOAuthTokenProvider)
|
|
19845
20066
|
}),
|
|
19846
20067
|
webSearcher: searchService?.baseUrl === void 0 ? void 0 : new RemoteWebSearchProvider({
|
|
19847
20068
|
baseUrl: searchService.baseUrl,
|
|
19848
20069
|
defaultHeaders: input.byfRequestHeaders,
|
|
20070
|
+
fetchImpl: proxiedFetch,
|
|
19849
20071
|
...serviceCredentials(searchService, input.resolveOAuthTokenProvider)
|
|
19850
20072
|
})
|
|
19851
20073
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Et as SessionSummary, ft as ListSessionsPayload, lt as JsonObject } from "../../index-
|
|
1
|
+
import { Et as SessionSummary, ft as ListSessionsPayload, lt as JsonObject } from "../../index-C2yfSu8d.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/session/store/session-store.d.ts
|
|
4
4
|
interface CreateSessionRecordInput {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byfriends/agent-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Unified agent engine for BYF",
|
|
5
5
|
"license": "Proprietary",
|
|
6
6
|
"author": "ByronFinn",
|
|
@@ -66,10 +66,11 @@
|
|
|
66
66
|
"retry": "0.13.1",
|
|
67
67
|
"smol-toml": "^1.6.1",
|
|
68
68
|
"tar": "^7.5.13",
|
|
69
|
+
"undici": "^8.4.1",
|
|
69
70
|
"yauzl": "^3.3.0",
|
|
70
71
|
"zod": "^4.3.6",
|
|
71
|
-
"@byfriends/
|
|
72
|
-
"@byfriends/
|
|
72
|
+
"@byfriends/kaos": "^0.2.2",
|
|
73
|
+
"@byfriends/kosong": "^0.2.2"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@types/js-yaml": "^4.0.9",
|