@byfriends/agent-core 0.1.0 → 0.2.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.
@@ -1,16 +1,15 @@
1
- import { ChatProvider, ContentPart, FinishReason, Message, ModelCapability, ProviderConfig, ProviderRequestAuth, TextPart, ThinkPart, ThinkingEffort, TokenUsage, Tool, ToolCall, ToolCall as ToolCall$1, generate } from "@byfriends/kosong";
1
+ import { CacheHitRate, ChatProvider, ContentPart, FinishReason, Message, ModelCapability, PromptPlan, ProviderCacheCapability, ProviderConfig, ProviderRequestAuth, TextPart, ThinkPart, ThinkingEffort, TokenUsage, Tool, ToolCall, ToolCall as ToolCall$1, generate } from "@byfriends/kosong";
2
2
  import { z } from "zod";
3
3
  import { OAuthClientProvider, OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.js";
4
4
  import { Kaos, KaosProcess } from "@byfriends/kaos";
5
5
  import { ActivateSkillPayload, AgentAPI, AgentEvent, SDKAgentRPC, SDKSessionRPC, UsageStatus } from "#/rpc";
6
6
  import { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
7
7
  import { ByfConfig, ByfConfigPatch, OAuthRef } from "#/config";
8
- import { AgentType } from "#/agent";
9
8
  import { AgentConfigData, AgentConfigUpdateData } from "#/agent/config";
10
9
  import { AgentContextData, ContextMessage } from "#/agent/context";
11
10
  import { PermissionApprovalResultRecord, PermissionData, PermissionMode } from "#/agent/permission";
12
- import { PlanData } from "#/agent/plan";
13
11
  import { ToolInfo } from "#/agent/tool";
12
+ import { AgentType } from "#/agent";
14
13
  import { SessionMeta } from "#/session";
15
14
  import { BackgroundTaskInfo } from "#/tools/builtin";
16
15
 
@@ -93,8 +92,7 @@ interface RootLogger {
93
92
  //#region src/config/schema.d.ts
94
93
  declare const ProviderTypeSchema: z.ZodEnum<{
95
94
  anthropic: "anthropic";
96
- openai: "openai";
97
- "openai-compat": "openai-compat";
95
+ "openai-completions": "openai-completions";
98
96
  "google-genai": "google-genai";
99
97
  openai_responses: "openai_responses";
100
98
  vertexai: "vertexai";
@@ -111,8 +109,7 @@ type OAuthRef$1 = z.infer<typeof OAuthRefSchema>;
111
109
  declare const ProviderConfigSchema: z.ZodObject<{
112
110
  type: z.ZodEnum<{
113
111
  anthropic: "anthropic";
114
- openai: "openai";
115
- "openai-compat": "openai-compat";
112
+ "openai-completions": "openai-completions";
116
113
  "google-genai": "google-genai";
117
114
  openai_responses: "openai_responses";
118
115
  vertexai: "vertexai";
@@ -130,6 +127,7 @@ declare const ProviderConfigSchema: z.ZodObject<{
130
127
  }, z.core.$strip>>;
131
128
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
132
129
  customHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
130
+ extraBody: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
133
131
  }, z.core.$strip>;
134
132
  type ProviderConfig$1 = z.infer<typeof ProviderConfigSchema>;
135
133
  declare const ModelAliasSchema: z.ZodObject<{
@@ -148,7 +146,13 @@ declare const ThinkingConfigSchema: z.ZodObject<{
148
146
  auto: "auto";
149
147
  on: "on";
150
148
  }>>;
151
- effort: z.ZodOptional<z.ZodString>;
149
+ effort: z.ZodOptional<z.ZodEnum<{
150
+ low: "low";
151
+ medium: "medium";
152
+ high: "high";
153
+ xhigh: "xhigh";
154
+ max: "max";
155
+ }>>;
152
156
  }, z.core.$strip>;
153
157
  type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
154
158
  declare const PermissionModeSchema: z.ZodEnum<{
@@ -337,8 +341,7 @@ declare const ByfConfigSchema: z.ZodObject<{
337
341
  providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
338
342
  type: z.ZodEnum<{
339
343
  anthropic: "anthropic";
340
- openai: "openai";
341
- "openai-compat": "openai-compat";
344
+ "openai-completions": "openai-completions";
342
345
  "google-genai": "google-genai";
343
346
  openai_responses: "openai_responses";
344
347
  vertexai: "vertexai";
@@ -356,6 +359,7 @@ declare const ByfConfigSchema: z.ZodObject<{
356
359
  }, z.core.$strip>>;
357
360
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
358
361
  customHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
362
+ extraBody: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
359
363
  }, z.core.$strip>>>;
360
364
  defaultProvider: z.ZodOptional<z.ZodString>;
361
365
  defaultModel: z.ZodOptional<z.ZodString>;
@@ -374,9 +378,14 @@ declare const ByfConfigSchema: z.ZodObject<{
374
378
  auto: "auto";
375
379
  on: "on";
376
380
  }>>;
377
- effort: z.ZodOptional<z.ZodString>;
381
+ effort: z.ZodOptional<z.ZodEnum<{
382
+ low: "low";
383
+ medium: "medium";
384
+ high: "high";
385
+ xhigh: "xhigh";
386
+ max: "max";
387
+ }>>;
378
388
  }, z.core.$strip>>;
379
- planMode: z.ZodOptional<z.ZodBoolean>;
380
389
  yolo: z.ZodOptional<z.ZodBoolean>;
381
390
  defaultThinking: z.ZodOptional<z.ZodBoolean>;
382
391
  defaultPermissionMode: z.ZodOptional<z.ZodEnum<{
@@ -384,7 +393,6 @@ declare const ByfConfigSchema: z.ZodObject<{
384
393
  yolo: "yolo";
385
394
  manual: "manual";
386
395
  }>>;
387
- defaultPlanMode: z.ZodOptional<z.ZodBoolean>;
388
396
  permission: z.ZodOptional<z.ZodObject<{
389
397
  rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
390
398
  decision: z.ZodEnum<{
@@ -464,7 +472,6 @@ declare const ByfConfigSchema: z.ZodObject<{
464
472
  agentTaskTimeoutS: z.ZodOptional<z.ZodNumber>;
465
473
  printWaitCeilingS: z.ZodOptional<z.ZodNumber>;
466
474
  }, z.core.$strip>>;
467
- telemetry: z.ZodOptional<z.ZodBoolean>;
468
475
  raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
469
476
  }, z.core.$strip>;
470
477
  type ByfConfig$1 = z.infer<typeof ByfConfigSchema>;
@@ -472,8 +479,7 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
472
479
  providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
473
480
  type: z.ZodOptional<z.ZodEnum<{
474
481
  anthropic: "anthropic";
475
- openai: "openai";
476
- "openai-compat": "openai-compat";
482
+ "openai-completions": "openai-completions";
477
483
  "google-genai": "google-genai";
478
484
  openai_responses: "openai_responses";
479
485
  vertexai: "vertexai";
@@ -491,6 +497,7 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
491
497
  }, z.core.$strip>>>;
492
498
  env: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
493
499
  customHeaders: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
500
+ extraBody: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
494
501
  }, z.core.$strip>>>;
495
502
  defaultProvider: z.ZodOptional<z.ZodString>;
496
503
  defaultModel: z.ZodOptional<z.ZodString>;
@@ -509,9 +516,14 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
509
516
  auto: "auto";
510
517
  on: "on";
511
518
  }>>>;
512
- effort: z.ZodOptional<z.ZodOptional<z.ZodString>>;
519
+ effort: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
520
+ low: "low";
521
+ medium: "medium";
522
+ high: "high";
523
+ xhigh: "xhigh";
524
+ max: "max";
525
+ }>>>;
513
526
  }, z.core.$strip>>;
514
- planMode: z.ZodOptional<z.ZodBoolean>;
515
527
  yolo: z.ZodOptional<z.ZodBoolean>;
516
528
  defaultThinking: z.ZodOptional<z.ZodBoolean>;
517
529
  defaultPermissionMode: z.ZodOptional<z.ZodEnum<{
@@ -519,7 +531,6 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
519
531
  yolo: "yolo";
520
532
  manual: "manual";
521
533
  }>>;
522
- defaultPlanMode: z.ZodOptional<z.ZodBoolean>;
523
534
  permission: z.ZodOptional<z.ZodObject<{
524
535
  rules: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
525
536
  decision: z.ZodEnum<{
@@ -599,7 +610,6 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
599
610
  agentTaskTimeoutS: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
600
611
  printWaitCeilingS: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
601
612
  }, z.core.$strip>>;
602
- telemetry: z.ZodOptional<z.ZodBoolean>;
603
613
  }, z.core.$strict>;
604
614
  type ByfConfigPatch$1 = z.infer<typeof ByfConfigPatchSchema>;
605
615
  declare function getDefaultConfig(): ByfConfig$1;
@@ -1011,8 +1021,6 @@ interface Environment {
1011
1021
  interface SystemPromptContext {
1012
1022
  readonly osEnv: Environment;
1013
1023
  readonly cwd: string;
1014
- readonly now?: string | Date;
1015
- readonly cwdListing?: string;
1016
1024
  readonly agentsMd?: string;
1017
1025
  readonly skills?: SkillRegistry | string;
1018
1026
  readonly additionalDirsInfo?: string;
@@ -1029,7 +1037,7 @@ interface ResolvedAgentProfile {
1029
1037
  }
1030
1038
  //#endregion
1031
1039
  //#region src/profile/context.d.ts
1032
- type PreparedSystemPromptContext = Pick<SystemPromptContext, 'cwd' | 'cwdListing' | 'agentsMd'>;
1040
+ type PreparedSystemPromptContext = Pick<SystemPromptContext, 'cwd' | 'agentsMd'>;
1033
1041
  //#endregion
1034
1042
  //#region src/config/merge.d.ts
1035
1043
  declare function mergeConfigPatch(config: ByfConfig$1, patch: ByfConfigPatch$1): ByfConfig$1;
@@ -1584,6 +1592,8 @@ interface LLMChatResponse {
1584
1592
  providerFinishReason?: FinishReason | undefined;
1585
1593
  rawFinishReason?: string | undefined;
1586
1594
  usage: TokenUsage;
1595
+ llmFirstTokenLatencyMs?: number | undefined;
1596
+ llmStreamDurationMs?: number | undefined;
1587
1597
  }
1588
1598
  interface LLM {
1589
1599
  readonly systemPrompt: string;
@@ -1636,6 +1646,12 @@ interface ExecutableToolErrorResult {
1636
1646
  * allowed after this tool batch.
1637
1647
  */
1638
1648
  readonly stopTurn?: boolean | undefined;
1649
+ /**
1650
+ * Set when the tool was not executed because the approval request was
1651
+ * rejected or cancelled by the user. Distinguishes "blocked by user" from
1652
+ * "tool ran but failed".
1653
+ */
1654
+ readonly blockedReason?: 'rejected' | 'cancelled' | undefined;
1639
1655
  }
1640
1656
  type ExecutableToolResult = ExecutableToolSuccessResult | ExecutableToolErrorResult;
1641
1657
  interface ToolUpdate$1 {
@@ -1689,6 +1705,7 @@ interface PrepareToolExecutionResult {
1689
1705
  readonly updatedArgs?: unknown;
1690
1706
  readonly syntheticResult?: ExecutableToolResult | undefined;
1691
1707
  readonly executionMetadata?: unknown;
1708
+ readonly blockedReason?: 'rejected' | 'cancelled' | undefined;
1692
1709
  }
1693
1710
  //#endregion
1694
1711
  //#region src/loop/events.d.ts
@@ -1711,6 +1728,8 @@ interface LoopStepEndEvent {
1711
1728
  */
1712
1729
  readonly providerFinishReason?: FinishReason | undefined;
1713
1730
  readonly rawFinishReason?: string | undefined;
1731
+ readonly llmFirstTokenLatencyMs?: number | undefined;
1732
+ readonly llmStreamDurationMs?: number | undefined;
1714
1733
  }
1715
1734
  interface LoopContentPartEvent {
1716
1735
  readonly type: 'content.part';
@@ -1752,97 +1771,195 @@ interface ToolStoreUpdate<K extends ToolStoreKey = ToolStoreKey> {
1752
1771
  readonly value: ToolStoreData[K];
1753
1772
  }
1754
1773
  //#endregion
1755
- //#region src/agent/tool/types.d.ts
1756
- type ToolSource = 'builtin' | 'user' | 'mcp';
1757
- type BuiltinTool<Input = unknown> = ExecutableTool<Input>;
1758
- interface UserToolRegistration {
1759
- readonly name: string;
1760
- readonly description: string;
1761
- readonly parameters: Record<string, unknown>;
1774
+ //#region src/agent/context/types.d.ts
1775
+ interface UserPromptOrigin {
1776
+ readonly kind: 'user';
1777
+ readonly blockedByHook?: string | undefined;
1762
1778
  }
1763
- interface ToolInfo$1 {
1779
+ declare const USER_PROMPT_ORIGIN: UserPromptOrigin;
1780
+ interface SkillActivationOrigin {
1781
+ readonly kind: 'skill_activation';
1782
+ readonly activationId: string;
1783
+ readonly skillName: string;
1784
+ readonly skillArgs?: string | undefined;
1785
+ readonly trigger: 'user-slash' | 'model-tool' | 'nested-skill';
1786
+ readonly skillType?: string | undefined;
1787
+ readonly skillPath?: string | undefined;
1788
+ readonly skillSource?: SkillSource | undefined;
1789
+ }
1790
+ interface InjectionOrigin {
1791
+ readonly kind: 'injection';
1792
+ readonly variant: string;
1793
+ }
1794
+ interface CompactionSummaryOrigin {
1795
+ readonly kind: 'compaction_summary';
1796
+ }
1797
+ interface SystemTriggerOrigin {
1798
+ readonly kind: 'system_trigger';
1764
1799
  readonly name: string;
1765
- readonly description: string;
1766
- readonly active: boolean;
1767
- readonly source: ToolSource;
1768
1800
  }
1769
- interface McpToolCollision {
1770
- readonly qualified: string;
1771
- readonly toolName: string;
1772
- readonly collidesWith: {
1773
- readonly kind: 'same_server';
1774
- readonly toolName: string;
1775
- } | {
1776
- readonly kind: 'other_server';
1777
- readonly serverName: string;
1778
- };
1801
+ interface BackgroundTaskOrigin {
1802
+ readonly kind: 'background_task';
1803
+ readonly taskId: string;
1804
+ readonly status: BackgroundTaskStatus;
1805
+ readonly notificationId: string;
1779
1806
  }
1780
- interface McpServerRegistrationResult {
1781
- readonly registered: readonly string[];
1782
- readonly collisions: readonly McpToolCollision[];
1807
+ interface HookResultOrigin {
1808
+ readonly kind: 'hook_result';
1809
+ readonly event: string;
1810
+ readonly blocked?: boolean;
1783
1811
  }
1784
- //#endregion
1785
- //#region src/agent/tool/index.d.ts
1786
- interface McpToolEntry {
1787
- readonly tool: ExecutableTool;
1788
- readonly serverName: string;
1812
+ type PromptOrigin = UserPromptOrigin | SkillActivationOrigin | InjectionOrigin | CompactionSummaryOrigin | SystemTriggerOrigin | BackgroundTaskOrigin | HookResultOrigin;
1813
+ type ContextMessage$1 = Message & {
1814
+ readonly origin?: PromptOrigin | undefined;
1815
+ readonly isError?: boolean;
1816
+ };
1817
+ interface AgentContextData$1 {
1818
+ history: readonly ContextMessage$1[];
1819
+ tokenCount: number;
1789
1820
  }
1790
- declare class ToolManager {
1791
- protected readonly agent: Agent;
1792
- protected builtinTools: Map<string, BuiltinTool>;
1793
- protected readonly userTools: Map<string, ExecutableTool>;
1794
- protected readonly mcpTools: Map<string, McpToolEntry>;
1795
- /** server name list of qualified tool names registered for that server. */
1796
- protected readonly mcpToolsByServer: Map<string, string[]>;
1797
- protected enabledTools: Set<string>;
1798
- /** Glob patterns (e.g. `mcp__*`, `mcp__github__*`) gating which MCP tools the profile exposes. */
1799
- private mcpAccessPatterns;
1800
- protected readonly store: Partial<ToolStoreData>;
1801
- private mcpToolStatusUnsubscribe;
1802
- constructor(agent: Agent);
1803
- protected get toolStore(): ToolStore;
1804
- attachMcpTools(): void;
1805
- updateStore<K extends ToolStoreKey>(key: K, value: ToolStoreData[K]): void;
1806
- registerUserTool(input: UserToolRegistration): void;
1807
- unregisterUserTool(name: string): void;
1808
- registerMcpServer(serverName: string, client: MCPClient, tools: readonly Tool[], enabledTools?: ReadonlySet<string>): McpServerRegistrationResult;
1809
- unregisterMcpServer(serverName: string): boolean;
1810
- private handleMcpServerStatusChange;
1811
- private registerNeedsAuthMcpServer;
1812
- private registerConnectedMcpServer;
1813
- private emitMcpToolCollisions;
1814
- setActiveTools(names: readonly string[]): void;
1815
- private isMcpToolEnabled;
1816
- toolInfos(): Iterable<ToolInfo$1>;
1817
- data(): readonly ToolInfo$1[];
1818
- storeData(): Readonly<Record<string, unknown>>;
1819
- initializeBuiltinTools(): void;
1820
- private createVideoUploader;
1821
- get loopTools(): readonly ExecutableTool[];
1821
+ //#endregion
1822
+ //#region src/agent/context/observation-masking.d.ts
1823
+ interface MaskingConfig {
1824
+ /** Effective capacity ratio (default 0.6 = 60% of advertised capacity) */
1825
+ effectiveCapacityRatio: number;
1826
+ /** Low priority masking threshold (default 0.60) */
1827
+ lowPriorityThreshold: number;
1828
+ /** Medium priority masking threshold (default 0.80) */
1829
+ mediumPriorityThreshold: number;
1830
+ /** High priority threshold — unmaskable, goes straight to compaction */
1831
+ highPriorityThreshold: number;
1832
+ }
1833
+ interface MaskingResult {
1834
+ masked: boolean;
1835
+ maskedCount: number;
1836
+ tokensBefore: number;
1837
+ tokensAfter: number;
1822
1838
  }
1823
1839
  //#endregion
1824
- //#region src/logging/logger.d.ts
1825
- declare function getRootLogger(): RootLogger;
1826
- declare function flushDiagnosticLogs(): Promise<boolean>;
1840
+ //#region src/agent/restore-handler.d.ts
1827
1841
  /**
1828
- * Root logger. Import and use directly for events that don't belong to any
1829
- * session (CLI startup, harness construction, etc.):
1842
+ * 记录恢复处理器接口。
1830
1843
  *
1831
- * import { log } from 'byf-sdk';
1832
- * log.info('byf starting', { version });
1844
+ * 实现此接口的子系统负责恢复特定类型的 AgentRecord。
1833
1845
  *
1834
- * For events scoped to a session or agent, use the parent's `log` field:
1846
+ * ## 契约
1835
1847
  *
1836
- * session.log.error('mcp initial load failed', error);
1837
- * agent.log.error('turn failed', { turnId, error });
1848
+ * 恢复操作必须遵循以下契约:
1838
1849
  *
1839
- * Late-binding: methods look up the current `RootLogger` on every call, so
1840
- * importing `log` at module load (before `ByfHarness` configures the root)
1841
- * is safe — calls during the pre-configure window are silent noops.
1850
+ * - **同步操作**:恢复必须是同步的,不返回 Promise。
1851
+ * 恢复是重建内存状态的过程,不应涉及 I/O、网络或其他异步操作。
1852
+ *
1853
+ * - **无副作用**:恢复时不产生任何外部副作用:
1854
+ * - 不调用 `records.logRecord()`
1855
+ * - 不调用 `agent.emitEvent()`
1856
+ * - 不调用 LLM
1857
+ * - 不执行工具
1858
+ * - 不写入文件系统(除了恢复所需的内存操作)
1859
+ *
1860
+ * - **非幂等性**:恢复操作不需要保证幂等性。
1861
+ * 实现时假设每条记录只会被恢复一次。
1862
+ *
1863
+ * - **状态恢复**:恢复操作的目的是将子系统的内存状态
1864
+ * 恢复到记录日志时的状态。
1865
+ *
1866
+ * ## 使用
1867
+ *
1868
+ * 子系统实现此接口后,通过 `AgentRecords.registerHandlers()`
1869
+ * 注册,然后在恢复时被调用。
1842
1870
  */
1843
- declare const log: Logger;
1844
- declare function redact<T>(value: T): T;
1845
- declare function resolveGlobalLogPath(homeDir: string): string;
1871
+ interface RecordRestoreHandler {
1872
+ /**
1873
+ * 恢复一条记录到子系统状态。
1874
+ *
1875
+ * @param record - 要恢复的记录(已通过迁移处理)
1876
+ *
1877
+ * @remarks
1878
+ *
1879
+ * 此方法在 `AgentRecords.replay()` 过程中被调用。
1880
+ * 实现时应根据 `record.type` 分发到相应的恢复逻辑。
1881
+ *
1882
+ * 示例:
1883
+ *
1884
+ * ```typescript
1885
+ * class ContextMemory implements RecordRestoreHandler {
1886
+ * restoreRecord(record: AgentRecord): void {
1887
+ * switch (record.type) {
1888
+ * case 'context.append_message':
1889
+ * this.appendMessage(record.message);
1890
+ * break;
1891
+ * // ...
1892
+ * }
1893
+ * }
1894
+ * }
1895
+ * ```
1896
+ */
1897
+ restoreRecord(record: AgentRecord): void;
1898
+ }
1899
+ //#endregion
1900
+ //#region src/agent/context/scratch-manager.d.ts
1901
+ interface ScratchManagerConfig {
1902
+ /** 每个 session 的最大 scratch 大小 (bytes),默认 50MB */
1903
+ maxSessionSize: number;
1904
+ /** 每个 session 的最大文件数,默认 100 */
1905
+ maxFileCount: number;
1906
+ /** scratch 目录 */
1907
+ scratchDir: string;
1908
+ }
1909
+ declare class ScratchManager {
1910
+ private readonly kaos;
1911
+ private readonly config;
1912
+ private currentSize;
1913
+ private files;
1914
+ constructor(kaos: Kaos, config: ScratchManagerConfig);
1915
+ writeOutput(toolCallId: string, output: string): Promise<string>;
1916
+ readOutput(filePath: string): Promise<string>;
1917
+ private evictIfNeeded;
1918
+ cleanup(): Promise<void>;
1919
+ }
1920
+ //#endregion
1921
+ //#region src/agent/context/index.d.ts
1922
+ declare class ContextMemory implements RecordRestoreHandler {
1923
+ protected readonly agent: Agent;
1924
+ private _history;
1925
+ private _tokenCount;
1926
+ private tokenCountCoveredMessageCount;
1927
+ private openSteps;
1928
+ private pendingToolResultIds;
1929
+ private deferredMessages;
1930
+ private toolCallInfo;
1931
+ readonly scratchManager: ScratchManager | undefined;
1932
+ constructor(agent: Agent, sessionId?: string);
1933
+ appendUserMessage(content: readonly ContentPart[], origin?: PromptOrigin): void;
1934
+ appendSystemReminder(content: string, origin: PromptOrigin): void;
1935
+ markLastUserPromptBlocked(hookEvent: string): void;
1936
+ clear(): void;
1937
+ applyCompaction(summary: CompactionResult$1): void;
1938
+ data(): AgentContextData$1;
1939
+ get tokenCount(): number;
1940
+ get tokenCountWithPending(): number;
1941
+ get history(): readonly ContextMessage$1[];
1942
+ get messages(): Message[];
1943
+ applyObservationMasking(config?: MaskingConfig): MaskingResult;
1944
+ applyPruning(config?: {
1945
+ effectiveCapacityRatio?: number;
1946
+ pruningThreshold?: number;
1947
+ }): {
1948
+ pruned: boolean;
1949
+ prunedCount: number;
1950
+ };
1951
+ appendLoopEvent(event: LoopRecordedEvent): Promise<void>;
1952
+ appendMessage(message: ContextMessage$1): void;
1953
+ private flushDeferredMessagesIfToolExchangeClosed;
1954
+ private hasOpenToolExchange;
1955
+ private pushHistory;
1956
+ restoreRecord(record: AgentRecord): void;
1957
+ private restoreClear;
1958
+ private restoreApplyCompaction;
1959
+ private restoreMarkLastUserPromptBlocked;
1960
+ private restoreAppendLoopEvent;
1961
+ private restoreObservationMasking;
1962
+ }
1846
1963
  //#endregion
1847
1964
  //#region src/agent/compaction/types.d.ts
1848
1965
  interface CompactionResult$1 {
@@ -1863,12 +1980,13 @@ interface CompactionStrategy {
1863
1980
  computeCompactCount(messages: readonly Message[], maxSize: number): number;
1864
1981
  readonly checkAfterStep: boolean;
1865
1982
  readonly maxCompactionPerTurn: number;
1983
+ readonly maskingConfig?: MaskingConfig | undefined;
1866
1984
  }
1867
1985
  interface CompactedHistory {
1868
1986
  text: string;
1869
1987
  }
1870
1988
  type CompactionTelemetryTrigger = CompactionBeginData['source'] | 'manual-with-prompt' | 'unknown';
1871
- declare class FullCompaction {
1989
+ declare class FullCompaction implements RecordRestoreHandler {
1872
1990
  protected readonly agent: Agent;
1873
1991
  protected compactionCountInTurn: number;
1874
1992
  protected compacting: {
@@ -1903,135 +2021,52 @@ declare class FullCompaction {
1903
2021
  private triggerPreCompactHook;
1904
2022
  private triggerPostCompactHook;
1905
2023
  private computeCompactableCount;
2024
+ restoreRecord(record: AgentRecord): void;
1906
2025
  }
1907
2026
  //#endregion
1908
- //#region src/agent/context/types.d.ts
1909
- interface UserPromptOrigin {
1910
- readonly kind: 'user';
1911
- readonly blockedByHook?: string | undefined;
1912
- }
1913
- declare const USER_PROMPT_ORIGIN: UserPromptOrigin;
1914
- interface SkillActivationOrigin {
1915
- readonly kind: 'skill_activation';
1916
- readonly activationId: string;
1917
- readonly skillName: string;
1918
- readonly skillArgs?: string | undefined;
1919
- readonly trigger: 'user-slash' | 'model-tool' | 'nested-skill';
1920
- readonly skillType?: string | undefined;
1921
- readonly skillPath?: string | undefined;
1922
- readonly skillSource?: SkillSource | undefined;
1923
- }
1924
- interface InjectionOrigin {
1925
- readonly kind: 'injection';
1926
- readonly variant: string;
1927
- }
1928
- interface CompactionSummaryOrigin {
1929
- readonly kind: 'compaction_summary';
1930
- }
1931
- interface SystemTriggerOrigin {
1932
- readonly kind: 'system_trigger';
1933
- readonly name: string;
1934
- }
1935
- interface BackgroundTaskOrigin {
1936
- readonly kind: 'background_task';
1937
- readonly taskId: string;
1938
- readonly status: BackgroundTaskStatus;
1939
- readonly notificationId: string;
1940
- }
1941
- interface HookResultOrigin {
1942
- readonly kind: 'hook_result';
1943
- readonly event: string;
1944
- readonly blocked?: boolean;
1945
- }
1946
- type PromptOrigin = UserPromptOrigin | SkillActivationOrigin | InjectionOrigin | CompactionSummaryOrigin | SystemTriggerOrigin | BackgroundTaskOrigin | HookResultOrigin;
1947
- type ContextMessage$1 = Message & {
1948
- readonly origin?: PromptOrigin | undefined;
1949
- readonly isError?: boolean;
1950
- };
1951
- interface AgentContextData$1 {
1952
- history: readonly ContextMessage$1[];
1953
- tokenCount: number;
2027
+ //#region src/agent/config/types.d.ts
2028
+ interface AgentConfigData$1 {
2029
+ cwd: string;
2030
+ provider?: ProviderConfig;
2031
+ modelAlias?: string;
2032
+ modelCapabilities: ModelCapability;
2033
+ profileName?: string;
2034
+ thinkingLevel: string;
2035
+ systemPrompt: string;
1954
2036
  }
2037
+ type AgentConfigUpdateData$1 = Partial<{
2038
+ cwd: string;
2039
+ modelAlias: string;
2040
+ profileName: string;
2041
+ thinkingLevel: string;
2042
+ systemPrompt: string;
2043
+ }>;
1955
2044
  //#endregion
1956
- //#region src/agent/context/index.d.ts
1957
- declare class ContextMemory {
2045
+ //#region src/agent/config/index.d.ts
2046
+ declare class ConfigState implements RecordRestoreHandler {
1958
2047
  protected readonly agent: Agent;
1959
- private _history;
1960
- private _tokenCount;
1961
- private tokenCountCoveredMessageCount;
1962
- private openSteps;
1963
- private pendingToolResultIds;
1964
- private deferredMessages;
2048
+ private _cwd;
2049
+ private _modelAlias;
2050
+ private _profileName;
2051
+ private _thinkingLevel;
2052
+ private _systemPrompt;
1965
2053
  constructor(agent: Agent);
1966
- appendUserMessage(content: readonly ContentPart[], origin?: PromptOrigin): void;
1967
- appendSystemReminder(content: string, origin: PromptOrigin): void;
1968
- markLastUserPromptBlocked(hookEvent: string): void;
1969
- clear(): void;
1970
- applyCompaction(summary: CompactionResult$1): void;
1971
- data(): AgentContextData$1;
1972
- get tokenCount(): number;
1973
- get tokenCountWithPending(): number;
1974
- get history(): readonly ContextMessage$1[];
1975
- get messages(): Message[];
1976
- appendLoopEvent(event: LoopRecordedEvent): void;
1977
- appendMessage(message: ContextMessage$1): void;
1978
- private flushDeferredMessagesIfToolExchangeClosed;
1979
- private hasOpenToolExchange;
1980
- private pushHistory;
1981
- }
1982
- //#endregion
1983
- //#region src/agent/hooks/types.d.ts
1984
- declare const HOOK_EVENT_TYPES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "UserPromptSubmit", "Stop", "StopFailure", "SessionStart", "SessionEnd", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "Notification"];
1985
- type HookEventType = (typeof HOOK_EVENT_TYPES)[number];
1986
- interface HookDef {
1987
- readonly event: HookEventType;
1988
- readonly matcher?: string;
1989
- readonly command: string;
1990
- readonly timeout?: number;
1991
- }
1992
- interface HookResult {
1993
- readonly action: 'allow' | 'block';
1994
- readonly message?: string;
1995
- readonly reason?: string;
1996
- readonly stdout?: string;
1997
- readonly stderr?: string;
1998
- readonly exitCode?: number;
1999
- readonly timedOut?: boolean;
2000
- readonly structuredOutput?: boolean;
2001
- }
2002
- interface HookBlockDecision {
2003
- readonly block: true;
2004
- readonly reason: string;
2005
- }
2006
- type HookMatcherValue = string | readonly ContentPart[];
2007
- interface HookEngineTriggerArgs {
2008
- readonly matcherValue?: HookMatcherValue;
2009
- readonly inputData?: Record<string, unknown>;
2010
- readonly signal?: AbortSignal;
2011
- }
2012
- type HookTriggeredCallback = (event: string, target: string, count: number) => void;
2013
- type HookResolvedCallback = (event: string, target: string, action: string, reason: string | undefined, durationMs: number) => void;
2014
- interface HookEngineOptions {
2015
- readonly cwd?: string;
2016
- readonly sessionId?: string;
2017
- readonly onTriggered?: HookTriggeredCallback;
2018
- readonly onResolved?: HookResolvedCallback;
2019
- }
2020
- //#endregion
2021
- //#region src/agent/hooks/engine.d.ts
2022
- declare class HookEngine {
2023
- private readonly options;
2024
- private readonly byEvent;
2025
- private readonly pendingTriggers;
2026
- constructor(hooks?: readonly HookDef[], options?: HookEngineOptions);
2027
- get summary(): Record<string, number>;
2028
- trigger(event: string, args?: HookEngineTriggerArgs): Promise<HookResult[]>;
2029
- triggerBlock(event: string, args?: HookEngineTriggerArgs): Promise<HookBlockDecision | undefined>;
2030
- fireAndForgetTrigger(event: string, args?: HookEngineTriggerArgs): Promise<HookResult[]>;
2031
- private triggerInner;
2032
- private matchingHooks;
2033
- private emitTriggered;
2034
- private emitResolved;
2054
+ update(input: AgentConfigUpdateData$1): void;
2055
+ data(): AgentConfigData$1;
2056
+ get cwd(): string;
2057
+ get hasModel(): boolean;
2058
+ get hasProvider(): boolean;
2059
+ get providerConfig(): ProviderConfig;
2060
+ get provider(): ChatProvider;
2061
+ get model(): string;
2062
+ get modelAlias(): string | undefined;
2063
+ get thinkingLevel(): ThinkingEffort;
2064
+ get profileName(): string | undefined;
2065
+ get systemPrompt(): string;
2066
+ get modelCapabilities(): ModelCapability;
2067
+ private get resolvedProviderConfig();
2068
+ private tryResolvedProviderConfig;
2069
+ restoreRecord(record: AgentRecord): void;
2035
2070
  }
2036
2071
  //#endregion
2037
2072
  //#region src/agent/permission/types.d.ts
@@ -2119,7 +2154,7 @@ interface PermissionManagerOptions {
2119
2154
  readonly policies?: readonly PermissionPolicy[] | undefined;
2120
2155
  readonly parent?: PermissionManager | undefined;
2121
2156
  }
2122
- declare class PermissionManager {
2157
+ declare class PermissionManager implements RecordRestoreHandler {
2123
2158
  protected readonly agent: Agent;
2124
2159
  rules: PermissionRule[];
2125
2160
  private modeOverride;
@@ -2148,6 +2183,259 @@ declare class PermissionManager {
2148
2183
  }): string;
2149
2184
  private pathMatchOptions;
2150
2185
  private trackToolApproved;
2186
+ restoreRecord(record: AgentRecord): void;
2187
+ }
2188
+ //#endregion
2189
+ //#region src/agent/usage/index.d.ts
2190
+ type UsageRecordScope = 'session' | 'turn';
2191
+ declare class UsageRecorder implements RecordRestoreHandler {
2192
+ protected readonly agent?: Agent | undefined;
2193
+ private readonly byModel;
2194
+ private currentTurn;
2195
+ constructor(agent?: Agent | undefined);
2196
+ beginTurn(): void;
2197
+ endTurn(): void;
2198
+ record(model: string, usage: TokenUsage, scope?: UsageRecordScope): void;
2199
+ data(): UsageStatus;
2200
+ status(): UsageStatus | undefined;
2201
+ private byModelSnapshot;
2202
+ restoreRecord(record: AgentRecord): void;
2203
+ }
2204
+ //#endregion
2205
+ //#region src/agent/records/types.d.ts
2206
+ interface AgentRecordEvents {
2207
+ metadata: {
2208
+ protocol_version: string;
2209
+ created_at: number;
2210
+ };
2211
+ 'turn.prompt': {
2212
+ input: readonly ContentPart[];
2213
+ origin: PromptOrigin;
2214
+ };
2215
+ 'turn.steer': {
2216
+ input: readonly ContentPart[];
2217
+ origin: PromptOrigin;
2218
+ };
2219
+ 'turn.cancel': {
2220
+ turnId?: number;
2221
+ };
2222
+ 'config.update': AgentConfigUpdateData$1;
2223
+ 'permission.set_mode': {
2224
+ mode: PermissionMode$1;
2225
+ };
2226
+ 'permission.record_approval_result': PermissionApprovalResultRecord$1;
2227
+ 'full_compaction.begin': CompactionBeginData;
2228
+ 'plan_mode.enter': {
2229
+ id: string;
2230
+ };
2231
+ 'plan_mode.cancel': {
2232
+ id?: string;
2233
+ };
2234
+ 'plan_mode.exit': {
2235
+ id?: string;
2236
+ };
2237
+ 'tools.register_user_tool': UserToolRegistration;
2238
+ 'tools.unregister_user_tool': {
2239
+ name: string;
2240
+ };
2241
+ 'tools.set_active_tools': {
2242
+ names: readonly string[];
2243
+ };
2244
+ 'background.stop': {
2245
+ taskId: string;
2246
+ };
2247
+ 'usage.record': {
2248
+ model: string;
2249
+ usage: TokenUsage;
2250
+ usageScope?: UsageRecordScope | undefined;
2251
+ };
2252
+ 'full_compaction.cancel': {};
2253
+ 'full_compaction.complete': CompactionResult$1;
2254
+ 'context.append_message': {
2255
+ message: ContextMessage$1;
2256
+ };
2257
+ 'context.mark_last_user_prompt_blocked': {
2258
+ hookEvent: string;
2259
+ };
2260
+ 'context.append_loop_event': {
2261
+ event: LoopRecordedEvent;
2262
+ };
2263
+ 'context.clear': {};
2264
+ 'context.apply_compaction': CompactionResult$1;
2265
+ 'context.observation_masking': {
2266
+ maskedCount: number;
2267
+ tokensBefore: number;
2268
+ tokensAfter: number;
2269
+ };
2270
+ 'context.output_offloaded': {
2271
+ toolCallId: string;
2272
+ filePath?: string | undefined;
2273
+ };
2274
+ 'context.pruning': {
2275
+ prunedCount: number;
2276
+ };
2277
+ 'tools.update_store': ToolStoreUpdate;
2278
+ }
2279
+ type AgentRecord = { [K in keyof AgentRecordEvents]: Readonly<AgentRecordEvents[K]> & {
2280
+ readonly type: K;
2281
+ readonly time?: number;
2282
+ } }[keyof AgentRecordEvents];
2283
+ type AgentRecordOf<K extends keyof AgentRecordEvents> = Extract<AgentRecord, {
2284
+ readonly type: K;
2285
+ }>;
2286
+ interface AgentRecordPersistence {
2287
+ read(): AsyncIterable<AgentRecord>;
2288
+ append(input: AgentRecord): void;
2289
+ rewrite(records: readonly AgentRecord[]): void;
2290
+ flush(): Promise<void>;
2291
+ close(): Promise<void>;
2292
+ }
2293
+ //#endregion
2294
+ //#region src/agent/tool/types.d.ts
2295
+ type ToolSource = 'builtin' | 'user' | 'mcp';
2296
+ type BuiltinTool<Input = unknown> = ExecutableTool<Input>;
2297
+ interface UserToolRegistration {
2298
+ readonly name: string;
2299
+ readonly description: string;
2300
+ readonly parameters: Record<string, unknown>;
2301
+ }
2302
+ interface ToolInfo$1 {
2303
+ readonly name: string;
2304
+ readonly description: string;
2305
+ readonly active: boolean;
2306
+ readonly source: ToolSource;
2307
+ }
2308
+ interface McpToolCollision {
2309
+ readonly qualified: string;
2310
+ readonly toolName: string;
2311
+ readonly collidesWith: {
2312
+ readonly kind: 'same_server';
2313
+ readonly toolName: string;
2314
+ } | {
2315
+ readonly kind: 'other_server';
2316
+ readonly serverName: string;
2317
+ };
2318
+ }
2319
+ interface McpServerRegistrationResult {
2320
+ readonly registered: readonly string[];
2321
+ readonly collisions: readonly McpToolCollision[];
2322
+ }
2323
+ //#endregion
2324
+ //#region src/agent/tool/index.d.ts
2325
+ interface McpToolEntry {
2326
+ readonly tool: ExecutableTool;
2327
+ readonly serverName: string;
2328
+ }
2329
+ declare class ToolManager implements RecordRestoreHandler {
2330
+ protected readonly agent: Agent;
2331
+ protected builtinTools: Map<string, BuiltinTool>;
2332
+ protected readonly userTools: Map<string, ExecutableTool>;
2333
+ protected readonly mcpTools: Map<string, McpToolEntry>;
2334
+ /** server name → list of qualified tool names registered for that server. */
2335
+ protected readonly mcpToolsByServer: Map<string, string[]>;
2336
+ protected enabledTools: Set<string>;
2337
+ /** Glob patterns (e.g. `mcp__*`, `mcp__github__*`) gating which MCP tools the profile exposes. */
2338
+ private mcpAccessPatterns;
2339
+ protected readonly store: Partial<ToolStoreData>;
2340
+ private mcpToolStatusUnsubscribe;
2341
+ constructor(agent: Agent);
2342
+ protected get toolStore(): ToolStore;
2343
+ attachMcpTools(): void;
2344
+ updateStore<K extends ToolStoreKey>(key: K, value: ToolStoreData[K]): void;
2345
+ registerUserTool(input: UserToolRegistration): void;
2346
+ unregisterUserTool(name: string): void;
2347
+ registerMcpServer(serverName: string, client: MCPClient, tools: readonly Tool[], enabledTools?: ReadonlySet<string>): McpServerRegistrationResult;
2348
+ unregisterMcpServer(serverName: string): boolean;
2349
+ private handleMcpServerStatusChange;
2350
+ private registerNeedsAuthMcpServer;
2351
+ private registerConnectedMcpServer;
2352
+ private emitMcpToolCollisions;
2353
+ setActiveTools(names: readonly string[]): void;
2354
+ private isMcpToolEnabled;
2355
+ toolInfos(): Iterable<ToolInfo$1>;
2356
+ data(): readonly ToolInfo$1[];
2357
+ storeData(): Readonly<Record<string, unknown>>;
2358
+ initializeBuiltinTools(): void;
2359
+ private createVideoUploader;
2360
+ get loopTools(): readonly ExecutableTool[];
2361
+ restoreRecord(record: AgentRecord): void;
2362
+ }
2363
+ //#endregion
2364
+ //#region src/logging/logger.d.ts
2365
+ declare function getRootLogger(): RootLogger;
2366
+ declare function flushDiagnosticLogs(): Promise<boolean>;
2367
+ /**
2368
+ * Root logger. Import and use directly for events that don't belong to any
2369
+ * session (CLI startup, harness construction, etc.):
2370
+ *
2371
+ * import { log } from 'byf-sdk';
2372
+ * log.info('byf starting', { version });
2373
+ *
2374
+ * For events scoped to a session or agent, use the parent's `log` field:
2375
+ *
2376
+ * session.log.error('mcp initial load failed', error);
2377
+ * agent.log.error('turn failed', { turnId, error });
2378
+ *
2379
+ * Late-binding: methods look up the current `RootLogger` on every call, so
2380
+ * importing `log` at module load (before `ByfHarness` configures the root)
2381
+ * is safe — calls during the pre-configure window are silent noops.
2382
+ */
2383
+ declare const log: Logger;
2384
+ declare function redact<T>(value: T): T;
2385
+ declare function resolveGlobalLogPath(homeDir: string): string;
2386
+ //#endregion
2387
+ //#region src/agent/hooks/types.d.ts
2388
+ declare const HOOK_EVENT_TYPES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "UserPromptSubmit", "Stop", "StopFailure", "SessionStart", "SessionEnd", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "Notification"];
2389
+ type HookEventType = (typeof HOOK_EVENT_TYPES)[number];
2390
+ interface HookDef {
2391
+ readonly event: HookEventType;
2392
+ readonly matcher?: string;
2393
+ readonly command: string;
2394
+ readonly timeout?: number;
2395
+ }
2396
+ interface HookResult {
2397
+ readonly action: 'allow' | 'block';
2398
+ readonly message?: string;
2399
+ readonly reason?: string;
2400
+ readonly stdout?: string;
2401
+ readonly stderr?: string;
2402
+ readonly exitCode?: number;
2403
+ readonly timedOut?: boolean;
2404
+ readonly structuredOutput?: boolean;
2405
+ }
2406
+ interface HookBlockDecision {
2407
+ readonly block: true;
2408
+ readonly reason: string;
2409
+ }
2410
+ type HookMatcherValue = string | readonly ContentPart[];
2411
+ interface HookEngineTriggerArgs {
2412
+ readonly matcherValue?: HookMatcherValue;
2413
+ readonly inputData?: Record<string, unknown>;
2414
+ readonly signal?: AbortSignal;
2415
+ }
2416
+ type HookTriggeredCallback = (event: string, target: string, count: number) => void;
2417
+ type HookResolvedCallback = (event: string, target: string, action: string, reason: string | undefined, durationMs: number) => void;
2418
+ interface HookEngineOptions {
2419
+ readonly cwd?: string;
2420
+ readonly sessionId?: string;
2421
+ readonly onTriggered?: HookTriggeredCallback;
2422
+ readonly onResolved?: HookResolvedCallback;
2423
+ }
2424
+ //#endregion
2425
+ //#region src/agent/hooks/engine.d.ts
2426
+ declare class HookEngine {
2427
+ private readonly options;
2428
+ private readonly byEvent;
2429
+ private readonly pendingTriggers;
2430
+ constructor(hooks?: readonly HookDef[], options?: HookEngineOptions);
2431
+ get summary(): Record<string, number>;
2432
+ trigger(event: string, args?: HookEngineTriggerArgs): Promise<HookResult[]>;
2433
+ triggerBlock(event: string, args?: HookEngineTriggerArgs): Promise<HookBlockDecision | undefined>;
2434
+ fireAndForgetTrigger(event: string, args?: HookEngineTriggerArgs): Promise<HookResult[]>;
2435
+ private triggerInner;
2436
+ private matchingHooks;
2437
+ private emitTriggered;
2438
+ private emitResolved;
2151
2439
  }
2152
2440
  //#endregion
2153
2441
  //#region src/telemetry.d.ts
@@ -2161,8 +2449,6 @@ interface TelemetryClient {
2161
2449
  withContext?(patch: TelemetryContextPatch): TelemetryClient;
2162
2450
  setContext?(patch: TelemetryContextPatch): void;
2163
2451
  }
2164
- declare const noopTelemetryClient: TelemetryClient;
2165
- declare function withTelemetryContext(telemetry: TelemetryClient, patch: TelemetryContextPatch): TelemetryClient;
2166
2452
  //#endregion
2167
2453
  //#region src/session/index.d.ts
2168
2454
  interface SessionConfig {
@@ -2375,50 +2661,6 @@ declare class BackgroundManager extends BackgroundProcessManager {
2375
2661
  _reset(): void;
2376
2662
  }
2377
2663
  //#endregion
2378
- //#region src/agent/config/types.d.ts
2379
- interface AgentConfigData$1 {
2380
- cwd: string;
2381
- provider?: ProviderConfig;
2382
- modelAlias?: string;
2383
- modelCapabilities: ModelCapability;
2384
- profileName?: string;
2385
- thinkingLevel: string;
2386
- systemPrompt: string;
2387
- }
2388
- type AgentConfigUpdateData$1 = Partial<{
2389
- cwd: string;
2390
- modelAlias: string;
2391
- profileName: string;
2392
- thinkingLevel: string;
2393
- systemPrompt: string;
2394
- }>;
2395
- //#endregion
2396
- //#region src/agent/config/index.d.ts
2397
- declare class ConfigState {
2398
- protected readonly agent: Agent;
2399
- private _cwd;
2400
- private _modelAlias;
2401
- private _profileName;
2402
- private _thinkingLevel;
2403
- private _systemPrompt;
2404
- constructor(agent: Agent);
2405
- update(input: AgentConfigUpdateData$1): void;
2406
- data(): AgentConfigData$1;
2407
- get cwd(): string;
2408
- get hasModel(): boolean;
2409
- get hasProvider(): boolean;
2410
- get providerConfig(): ProviderConfig;
2411
- get provider(): ChatProvider;
2412
- get model(): string;
2413
- get modelAlias(): string | undefined;
2414
- get thinkingLevel(): ThinkingEffort;
2415
- get profileName(): string | undefined;
2416
- get systemPrompt(): string;
2417
- get modelCapabilities(): ModelCapability;
2418
- private get resolvedProviderConfig();
2419
- private tryResolvedProviderConfig;
2420
- }
2421
- //#endregion
2422
2664
  //#region src/agent/injection/manager.d.ts
2423
2665
  declare class InjectionManager {
2424
2666
  protected readonly agent: Agent;
@@ -2429,143 +2671,20 @@ declare class InjectionManager {
2429
2671
  onContextCompacted(compactedCount: number): void;
2430
2672
  }
2431
2673
  //#endregion
2432
- //#region src/agent/plan/index.d.ts
2433
- type PlanData$1 = null | {
2434
- id: string;
2435
- exists: boolean;
2436
- content: string;
2437
- path: string;
2438
- };
2439
- type PlanFilePath = string | null;
2440
- declare class PlanMode {
2441
- protected readonly agent: Agent;
2442
- protected _isActive: boolean;
2443
- protected _planId: null | string;
2444
- protected _planFilePath: PlanFilePath;
2445
- constructor(agent: Agent);
2446
- createPlanId(): string;
2447
- enter(id?: string, createFile?: boolean, emitStatus?: boolean): Promise<void>;
2448
- restoreEnter({
2449
- id
2450
- }: {
2451
- readonly id: string;
2452
- }): void;
2453
- cancel(id?: string): void;
2454
- clear(): Promise<void>;
2455
- exit(id?: string): void;
2456
- get isActive(): boolean;
2457
- get planFilePath(): PlanFilePath;
2458
- data(): Promise<PlanData$1>;
2459
- materializeCurrentPlanFile(): Promise<void>;
2460
- private materializePlanFile;
2461
- private ensurePlanDirectory;
2462
- private planFilePathFor;
2463
- private planFileExists;
2464
- private trackPlanLifecycle;
2465
- }
2466
- //#endregion
2467
- //#region src/agent/usage/index.d.ts
2468
- type UsageRecordScope = 'session' | 'turn';
2469
- declare class UsageRecorder {
2470
- protected readonly agent?: Agent | undefined;
2471
- private readonly byModel;
2472
- private currentTurn;
2473
- constructor(agent?: Agent | undefined);
2474
- beginTurn(): void;
2475
- endTurn(): void;
2476
- record(model: string, usage: TokenUsage, scope?: UsageRecordScope): void;
2477
- data(): UsageStatus;
2478
- status(): UsageStatus | undefined;
2479
- private byModelSnapshot;
2480
- }
2481
- //#endregion
2482
- //#region src/agent/records/types.d.ts
2483
- interface AgentRecordEvents {
2484
- metadata: {
2485
- protocol_version: string;
2486
- created_at: number;
2487
- };
2488
- 'turn.prompt': {
2489
- input: readonly ContentPart[];
2490
- origin: PromptOrigin;
2491
- };
2492
- 'turn.steer': {
2493
- input: readonly ContentPart[];
2494
- origin: PromptOrigin;
2495
- };
2496
- 'turn.cancel': {
2497
- turnId?: number;
2498
- };
2499
- 'config.update': AgentConfigUpdateData$1;
2500
- 'permission.set_mode': {
2501
- mode: PermissionMode$1;
2502
- };
2503
- 'permission.record_approval_result': PermissionApprovalResultRecord$1;
2504
- 'full_compaction.begin': CompactionBeginData;
2505
- 'plan_mode.enter': {
2506
- id: string;
2507
- };
2508
- 'plan_mode.cancel': {
2509
- id?: string;
2510
- };
2511
- 'plan_mode.exit': {
2512
- id?: string;
2513
- };
2514
- 'tools.register_user_tool': UserToolRegistration;
2515
- 'tools.unregister_user_tool': {
2516
- name: string;
2517
- };
2518
- 'tools.set_active_tools': {
2519
- names: readonly string[];
2520
- };
2521
- 'background.stop': {
2522
- taskId: string;
2523
- };
2524
- 'usage.record': {
2525
- model: string;
2526
- usage: TokenUsage;
2527
- usageScope?: UsageRecordScope | undefined;
2528
- };
2529
- 'full_compaction.cancel': {};
2530
- 'full_compaction.complete': CompactionResult$1;
2531
- 'context.append_message': {
2532
- message: ContextMessage$1;
2533
- };
2534
- 'context.mark_last_user_prompt_blocked': {
2535
- hookEvent: string;
2536
- };
2537
- 'context.append_loop_event': {
2538
- event: LoopRecordedEvent;
2539
- };
2540
- 'context.clear': {};
2541
- 'context.apply_compaction': CompactionResult$1;
2542
- 'tools.update_store': ToolStoreUpdate;
2543
- }
2544
- type AgentRecord = { [K in keyof AgentRecordEvents]: Readonly<AgentRecordEvents[K]> & {
2545
- readonly type: K;
2546
- readonly time?: number;
2547
- } }[keyof AgentRecordEvents];
2548
- type AgentRecordOf<K extends keyof AgentRecordEvents> = Extract<AgentRecord, {
2549
- readonly type: K;
2550
- }>;
2551
- interface AgentRecordPersistence {
2552
- read(): AsyncIterable<AgentRecord>;
2553
- append(input: AgentRecord): void;
2554
- rewrite(records: readonly AgentRecord[]): void;
2555
- flush(): Promise<void>;
2556
- close(): Promise<void>;
2557
- }
2558
- //#endregion
2559
2674
  //#region src/agent/records/index.d.ts
2560
2675
  declare class AgentRecords {
2561
2676
  private readonly agent;
2562
2677
  private readonly persistence?;
2563
2678
  private _restoring;
2564
2679
  private metadataInitialized;
2680
+ private handlers;
2565
2681
  constructor(agent: Agent, persistence?: AgentRecordPersistence | undefined);
2566
2682
  get restoring(): boolean;
2683
+ registerHandlers(handlers: Record<string, RecordRestoreHandler>): void;
2567
2684
  logRecord(record: AgentRecord): void;
2568
2685
  restore(record: AgentRecord): void;
2686
+ private routeToHandler;
2687
+ private getHandlerKey;
2569
2688
  replay(): Promise<{
2570
2689
  warning?: string;
2571
2690
  }>;
@@ -2618,7 +2737,6 @@ declare const ErrorCodes: {
2618
2737
  readonly SESSION_PERMISSION_MODE_INVALID: "session.permission_mode_invalid";
2619
2738
  readonly SESSION_THINKING_EMPTY: "session.thinking_empty";
2620
2739
  readonly SESSION_MODEL_EMPTY: "session.model_empty";
2621
- readonly SESSION_PLAN_MODE_INVALID: "session.plan_mode_invalid";
2622
2740
  readonly SESSION_APPROVAL_HANDLER_ERROR: "session.approval_handler_error";
2623
2741
  readonly SESSION_QUESTION_HANDLER_ERROR: "session.question_handler_error";
2624
2742
  readonly SESSION_INIT_FAILED: "session.init_failed";
@@ -2758,12 +2876,6 @@ declare const BYF_ERROR_INFO: {
2758
2876
  readonly public: true;
2759
2877
  readonly action: "Provide a non-empty model identifier.";
2760
2878
  };
2761
- readonly 'session.plan_mode_invalid': {
2762
- readonly title: "Invalid plan mode";
2763
- readonly retryable: false;
2764
- readonly public: true;
2765
- readonly action: "Provide a boolean plan mode.";
2766
- };
2767
2879
  readonly 'session.approval_handler_error': {
2768
2880
  readonly title: "Approval handler threw";
2769
2881
  readonly retryable: false;
@@ -3022,6 +3134,8 @@ interface UsageStatus$1 {
3022
3134
  readonly byModel?: Record<string, TokenUsage> | undefined;
3023
3135
  readonly currentTurn?: TokenUsage | undefined;
3024
3136
  readonly total?: TokenUsage | undefined;
3137
+ /** Cache hit rate across all recorded usage (0–1), undefined when no data. */
3138
+ readonly cacheHitRate?: CacheHitRate | undefined;
3025
3139
  }
3026
3140
  interface ToolUpdate {
3027
3141
  readonly kind: 'stdout' | 'stderr' | 'progress' | 'status' | 'custom';
@@ -3048,7 +3162,6 @@ interface AgentStatusUpdatedEvent {
3048
3162
  readonly contextTokens?: number | undefined;
3049
3163
  readonly maxContextTokens?: number | undefined;
3050
3164
  readonly contextUsage?: number | undefined;
3051
- readonly planMode?: boolean | undefined;
3052
3165
  readonly permission?: PermissionMode$1 | undefined;
3053
3166
  readonly usage?: UsageStatus$1 | undefined;
3054
3167
  }
@@ -3100,6 +3213,8 @@ interface TurnStepCompletedEvent {
3100
3213
  readonly finishReason?: string | undefined;
3101
3214
  readonly providerFinishReason?: FinishReason | undefined;
3102
3215
  readonly rawFinishReason?: string | undefined;
3216
+ readonly llmFirstTokenLatencyMs?: number | undefined;
3217
+ readonly llmStreamDurationMs?: number | undefined;
3103
3218
  }
3104
3219
  interface TurnStepRetryingEvent {
3105
3220
  readonly type: 'turn.step.retrying';
@@ -3168,6 +3283,7 @@ interface ToolResultEvent {
3168
3283
  readonly output: unknown;
3169
3284
  readonly isError?: boolean | undefined;
3170
3285
  readonly synthetic?: boolean | undefined;
3286
+ readonly blockedReason?: 'rejected' | 'cancelled' | undefined;
3171
3287
  }
3172
3288
  interface SubagentSpawnedEvent {
3173
3289
  readonly type: 'subagent.spawned';
@@ -3208,6 +3324,16 @@ interface CompactionCompletedEvent {
3208
3324
  readonly type: 'compaction.completed';
3209
3325
  readonly result: CompactionResult;
3210
3326
  }
3327
+ interface ObservationMaskingAppliedEvent {
3328
+ readonly type: 'observation_masking.applied';
3329
+ readonly maskedCount: number;
3330
+ readonly tokensBefore: number;
3331
+ readonly tokensAfter: number;
3332
+ }
3333
+ interface PruningAppliedEvent {
3334
+ readonly type: 'pruning.applied';
3335
+ readonly prunedCount: number;
3336
+ }
3211
3337
  interface BackgroundTaskStartedEvent {
3212
3338
  readonly type: 'background.task.started';
3213
3339
  readonly info: BackgroundTaskInfo$1;
@@ -3237,7 +3363,7 @@ interface McpServerStatusPayload {
3237
3363
  readonly toolCount: number;
3238
3364
  readonly error?: string | undefined;
3239
3365
  }
3240
- type AgentEvent$1 = ErrorEvent | WarningEvent | AgentStatusUpdatedEvent | SessionMetaUpdatedEvent | SkillActivatedEvent | TurnStartedEvent | TurnEndedEvent | TurnStepStartedEvent | TurnStepCompletedEvent | TurnStepRetryingEvent | TurnStepInterruptedEvent | AssistantDeltaEvent | HookResultEvent | ThinkingDeltaEvent | ToolCallDeltaEvent | ToolCallStartedEvent | ToolProgressEvent | ToolResultEvent | ToolListUpdatedEvent | McpServerStatusEvent | SubagentSpawnedEvent | SubagentCompletedEvent | SubagentFailedEvent | CompactionStartedEvent | CompactionBlockedEvent | CompactionCancelledEvent | CompactionCompletedEvent | BackgroundTaskStartedEvent | BackgroundTaskUpdatedEvent | BackgroundTaskTerminatedEvent;
3366
+ type AgentEvent$1 = ErrorEvent | WarningEvent | AgentStatusUpdatedEvent | SessionMetaUpdatedEvent | SkillActivatedEvent | TurnStartedEvent | TurnEndedEvent | TurnStepStartedEvent | TurnStepCompletedEvent | TurnStepRetryingEvent | TurnStepInterruptedEvent | AssistantDeltaEvent | HookResultEvent | ThinkingDeltaEvent | ToolCallDeltaEvent | ToolCallStartedEvent | ToolProgressEvent | ToolResultEvent | ToolListUpdatedEvent | McpServerStatusEvent | SubagentSpawnedEvent | SubagentCompletedEvent | SubagentFailedEvent | CompactionStartedEvent | CompactionBlockedEvent | CompactionCancelledEvent | CompactionCompletedEvent | ObservationMaskingAppliedEvent | PruningAppliedEvent | BackgroundTaskStartedEvent | BackgroundTaskUpdatedEvent | BackgroundTaskTerminatedEvent;
3241
3367
  type Event = AgentEvent$1 & {
3242
3368
  agentId: string;
3243
3369
  sessionId: string;
@@ -3290,6 +3416,7 @@ type WithSessionId<T> = WithExtraPayload<T, {
3290
3416
  declare function proxyWithExtraPayload<T, U>(methods: RPCMethods<WithExtraPayload<T, U>>, extraPayload: U): RPCMethods<T>;
3291
3417
  //#endregion
3292
3418
  //#region src/rpc/core-api.d.ts
3419
+ type PlanData = null;
3293
3420
  type JsonPrimitive = string | number | boolean | null;
3294
3421
  type JsonValue = JsonPrimitive | JsonValue[] | {
3295
3422
  readonly [key: string]: JsonValue;
@@ -3631,7 +3758,6 @@ interface ByfCoreOptions {
3631
3758
  readonly byfRequestHeaders?: Record<string, string> | undefined;
3632
3759
  readonly resolveOAuthTokenProvider?: OAuthTokenProviderResolver | undefined;
3633
3760
  readonly skillDirs?: readonly string[];
3634
- readonly telemetry?: TelemetryClient | undefined;
3635
3761
  }
3636
3762
  declare class ByfCore implements PromisableMethods<CoreAPI> {
3637
3763
  protected readonly rpcClient: CoreRPCClient;
@@ -3759,7 +3885,7 @@ declare class ByfCore implements PromisableMethods<CoreAPI> {
3759
3885
  getPlan({
3760
3886
  sessionId,
3761
3887
  ...payload
3762
- }: SessionAgentPayload<EmptyPayload>): PlanData$1 | Promise<PlanData$1>;
3888
+ }: SessionAgentPayload<EmptyPayload>): Promise<null> | null;
3763
3889
  getUsage({
3764
3890
  sessionId,
3765
3891
  ...payload
@@ -3816,10 +3942,11 @@ interface TurnEndResult {
3816
3942
  readonly event: TurnEndedEvent;
3817
3943
  readonly stopReason?: LoopTurnStopReason;
3818
3944
  }
3819
- declare class TurnFlow {
3945
+ declare class TurnFlow implements RecordRestoreHandler {
3820
3946
  protected readonly agent: Agent;
3821
3947
  private steerBuffer;
3822
3948
  private turnId;
3949
+ private _previousTurnMessageCount;
3823
3950
  private activeTurn;
3824
3951
  private readonly toolCallStartedAt;
3825
3952
  private readonly toolCallDupType;
@@ -3854,6 +3981,7 @@ declare class TurnFlow {
3854
3981
  private trackTurnInterrupted;
3855
3982
  private telemetryMode;
3856
3983
  private shouldTrackApiError;
3984
+ restoreRecord(record: AgentRecord): void;
3857
3985
  }
3858
3986
  //#endregion
3859
3987
  //#region src/agent/index.d.ts
@@ -3898,7 +4026,6 @@ declare class Agent {
3898
4026
  readonly turn: TurnFlow;
3899
4027
  readonly injection: InjectionManager;
3900
4028
  readonly permission: PermissionManager;
3901
- readonly planMode: PlanMode;
3902
4029
  readonly usage: UsageRecorder;
3903
4030
  readonly tools: ToolManager;
3904
4031
  readonly background: BackgroundManager;
@@ -3912,6 +4039,7 @@ declare class Agent {
3912
4039
  useProfile(profile: ResolvedAgentProfile, context?: PreparedSystemPromptContext): void;
3913
4040
  resume(): Promise<{
3914
4041
  warning?: string;
4042
+ error?: Error;
3915
4043
  }>;
3916
4044
  get rpcMethods(): PromisableMethods<AgentAPI>;
3917
4045
  emitEvent(event: AgentEvent): void;
@@ -3984,4 +4112,7 @@ interface ResolveLoggingInput {
3984
4112
  */
3985
4113
  declare function resolveLoggingConfig(input: ResolveLoggingInput): LoggingConfig;
3986
4114
  //#endregion
3987
- export { CreateSessionPayload as $, SessionConfig as $n, resolveByfHome as $r, CompactionCancelledEvent as $t, QuestionItem as A, ProviderType as Ai, WarningEvent as An, LoopStepEndEvent as Ar, SetThinkingPayload as At, SDKSessionRPC$1 as B, LogEntry as Bi, ByfErrorInfo as Bn, BackgroundTaskStatus as Br, WithAgentId as Bt, createRPC as C, PermissionConfigSchema as Ci, TurnEndedEvent as Cn, ToolInfo$1 as Cr, SessionMetadataPatch as Ct, ApprovalScope as D, PermissionRuleScopeSchema as Di, TurnStepRetryingEvent as Dn, LoopContentPartEvent as Dr, SetModelPayload as Dt, ApprovalResponse as E, PermissionRuleSchema as Ei, TurnStepInterruptedEvent as En, ToolStoreUpdate as Er, SetByfConfigPayload as Et, SDKAPI as F, ThinkingConfigSchema as Fi, toByfErrorPayload as Fn, ExecutableToolSuccessResult as Fr, StopBackgroundPayload as Ft, BeginCompactionPayload as G, RootLogger as Gi, AgentRecordPersistence as Gn, parseConfigString as Gr, ResumedAgentState as Gt, ToolCallResponse as H, LogPayload as Hi, AgentRecord as Hn, OAuthTokenProviderResolver as Hr, proxyWithExtraPayload as Ht, SDKAgentAPI as I, formatConfigValidationError as Ii, ByfError as In, ToolInputDisplay as Ir, TextPromptPart as It, CancelPayload as J, RuntimeConfig as Jn, writeConfigFile as Jr, AssistantDeltaEvent as Jt, ByfConfig as K, SessionAttachInput as Ki, UsageRecordScope as Kn, readConfigFile as Kr, AgentEvent$1 as Kt, SDKAgentRPC$1 as L, getDefaultConfig as Li, ByfErrorOptions as Ln, BackgroundLifecycleEvent as Lr, UnregisterToolPayload as Lt, QuestionRequest as M, ServicesConfig as Mi, fromByfErrorPayload as Mn, LoopToolResultEvent as Mr, ShellExecResult as Mt, QuestionResponse as N, ServicesConfigSchema as Ni, isByfError as Nn, ExecutableToolErrorResult as Nr, SkillSummary as Nt, QuestionAnswerMethod as O, ProviderConfig$1 as Oi, TurnStepStartedEvent as On, LoopRecordedEvent as Or, SetModelResult as Ot, QuestionResult as P, ThinkingConfig as Pi, makeErrorPayload as Pn, ExecutableToolResult as Pr, SteerPayload as Pt, CoreInfo as Q, Session as Qn, ensureByfHome as Qr, CompactionBlockedEvent as Qt, SDKRPC as R, validateConfig as Ri, BYF_ERROR_INFO as Rn, BackgroundTaskInfo$1 as Rr, Unsubscribe as Rt, SDKRPCClient as S, PermissionConfig as Si, TurnEndReason as Sn, BuiltinTool as Sr, SessionAPI as St, ApprovalRequest as T, PermissionRuleDecisionSchema as Ti, TurnStepCompletedEvent as Tn, UserToolRegistration as Tr, SetActiveToolsPayload as Tt, ActivateSkillPayload$1 as U, Logger as Ui, AgentRecordEvents as Un, configToTomlData as Ur, AgentReplayRecord as Ut, ToolCallRequest as V, LogLevel as Vi, ErrorCodes as Vn, BearerTokenProvider as Vr, WithSessionId as Vt, AgentAPI$1 as W, LoggingConfig as Wi, AgentRecordOf as Wn, ensureConfigFile as Wr, ResumeSessionResult as Wt, CloseSessionPayload as X, SubagentHandle as Xn, parseBooleanEnv as Xr, BackgroundTaskTerminatedEvent as Xt, CancelPlanPayload as Y, SessionSubagentHost as Yn, ResolveConfigValueInput as Yr, BackgroundTaskStartedEvent as Yt, CoreAPI as Z, AgentMeta as Zn, resolveConfigValue as Zr, BackgroundTaskUpdatedEvent as Zt, CoreRPC as _, McpServerStdioConfigSchema as _i, ToolListUpdatedEvent as _n, flushDiagnosticLogs as _r, ReconnectMcpServerPayload as _t, writeExportZip as a, ByfConfigSchema as ai, MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE as an, TelemetryPropertyValue as ar, GetBackgroundOutputPathPayload as at, RPCClient as b, OAuthRef$1 as bi, ToolResultEvent as bn, redact as br, RenameSessionPayload as bt, buildExportManifest as c, HookDefConfig as ci, McpServerStatusPayload as cn, PermissionApprovalResultRecord$1 as cr, JsonObject as ct, scanSessionWire as d, LoopControlSchema as di, SubagentCompletedEvent as dn, ContextMessage$1 as dr, ListSessionsPayload as dt, resolveConfigPath as ei, CompactionCompletedEvent as en, SessionMeta$1 as er, EmptyPayload as et, Agent as f, McpServerConfig as fi, SubagentFailedEvent as fn, PromptOrigin as fr, McpServerInfo as ft, ByfCoreOptions as g, McpServerStdioConfig as gi, ToolCallStartedEvent as gn, CompactionResult$1 as gr, PromptPayload as gt, ByfCore as h, McpServerHttpConfigSchema as hi, ToolCallDeltaEvent as hn, CompactionBeginData as hr, PromptPart as ht, collectFilesRecursive as i, ByfConfigPatchSchema as ii, HookResultEvent as in, TelemetryProperties as ir, ForkSessionPayload as it, QuestionOption as j, ProviderTypeSchema as ji, ByfErrorPayload as jn, LoopToolCallEvent as jr, ShellExecPayload as jt, QuestionAnswers as k, ProviderConfigSchema as ki, UsageStatus$1 as kn, LoopStepBeginEvent as kr, SetPermissionPayload as kt, SessionWireScan as l, HookDefSchema as li, SessionMetaUpdatedEvent as ln, PermissionMode$1 as lr, JsonPrimitive as lt, AgentType$1 as m, McpServerHttpConfig as mi, ThinkingDeltaEvent as mn, UserPromptOrigin as mr, PromptInput as mt, resolveLoggingConfig as n, BackgroundConfig as ni, ErrorEvent as nn, TelemetryClient as nr, ExportSessionPayload as nt, exportSessionDirectory as o, ByfServiceConfig as oi, McpOAuthAuthorizationUrlUpdateData as on, noopTelemetryClient as or, GetBackgroundOutputPayload as ot, AgentConfig as p, McpServerConfigSchema as pi, SubagentSpawnedEvent as pn, USER_PROMPT_ORIGIN as pr, McpStartupMetrics as pt, ByfConfigPatch as q, SessionLogHandle as qi, AgentConfigUpdateData$1 as qn, transformTomlData as qr, AgentStatusUpdatedEvent as qt, ExtraZipEntry as r, BackgroundConfigSchema as ri, Event as rn, TelemetryContextPatch as rr, ExportSessionResult as rt, WIRE_PROTOCOL_VERSION as s, ByfServiceConfigSchema as si, McpServerStatusEvent as sn, withTelemetryContext as sr, GetBackgroundPayload as st, ResolveLoggingInput as t, mergeConfigPatch as ti, CompactionStartedEvent as tn, SessionSkillConfig as tr, ExportSessionManifest as tt, normalizeTimestampMs as u, LoopControl as ui, SkillActivatedEvent as un, AgentContextData$1 as ur, JsonValue as ut, CoreRPCClient as v, ModelAlias as vi, ToolListUpdatedReason as vn, getRootLogger as vr, RegisterToolPayload as vt, ApprovalDecision as w, PermissionModeSchema as wi, TurnStartedEvent as wn, ToolSource as wr, SessionSummary as wt, RPCMethods as x, OAuthRefSchema as xi, ToolUpdate as xn, resolveGlobalLogPath as xr, ResumeSessionPayload as xt, RPCCallOptions as y, ModelAliasSchema as yi, ToolProgressEvent as yn, log as yr, RemoveByfProviderPayload as yt, SDKSessionAPI as z, LogContext as zi, ByfErrorCode as zn, BackgroundTaskKind as zr, UpdateSessionMetadataPayload as zt };
4115
+ //#region src/prompt-plan/builder.d.ts
4116
+ declare function buildPromptPlan(renderedSystemPrompt: string, providerCacheCapability: ProviderCacheCapability): PromptPlan;
4117
+ //#endregion
4118
+ export { CoreInfo as $, SessionSkillConfig as $n, resolveByfHome as $r, BackgroundTaskUpdatedEvent as $t, QuestionAnswers as A, ProviderType as Ai, TurnStepInterruptedEvent as An, LoopStepEndEvent as Ar, SetModelResult as At, SDKSessionAPI as B, LogEntry as Bi, ByfError as Bn, BackgroundTaskStatus as Br, Unsubscribe as Bt, SDKRPCClient as C, PermissionConfigSchema as Ci, ToolProgressEvent as Cn, PromptOrigin as Cr, ResumeSessionPayload as Ct, ApprovalResponse as D, PermissionRuleScopeSchema as Di, TurnEndedEvent as Dn, LoopContentPartEvent as Dr, SetActiveToolsPayload as Dt, ApprovalRequest as E, PermissionRuleSchema as Ei, TurnEndReason as En, ToolStoreUpdate as Er, SessionSummary as Et, QuestionResult as F, ThinkingConfigSchema as Fi, ByfErrorPayload as Fn, ExecutableToolSuccessResult as Fr, SkillSummary as Ft, AgentAPI$1 as G, RootLogger as Gi, ErrorCodes as Gn, parseConfigString as Gr, AgentReplayRecord as Gt, ToolCallRequest as H, LogPayload as Hi, BYF_ERROR_INFO as Hn, OAuthTokenProviderResolver as Hr, WithAgentId as Ht, SDKAPI as I, formatConfigValidationError as Ii, fromByfErrorPayload as In, ToolInputDisplay as Ir, SteerPayload as It, ByfConfigPatch as J, SubagentHandle as Jn, writeConfigFile as Jr, AgentEvent$1 as Jt, BeginCompactionPayload as K, SessionAttachInput as Ki, RuntimeConfig as Kn, readConfigFile as Kr, ResumeSessionResult as Kt, SDKAgentAPI as L, getDefaultConfig as Li, isByfError as Ln, BackgroundLifecycleEvent as Lr, StopBackgroundPayload as Lt, QuestionOption as M, ServicesConfig as Mi, TurnStepStartedEvent as Mn, LoopToolResultEvent as Mr, SetThinkingPayload as Mt, QuestionRequest as N, ServicesConfigSchema as Ni, UsageStatus$1 as Nn, ExecutableToolErrorResult as Nr, ShellExecPayload as Nt, ApprovalScope as O, ProviderConfig$1 as Oi, TurnStartedEvent as On, LoopRecordedEvent as Or, SetByfConfigPayload as Ot, QuestionResponse as P, ThinkingConfig as Pi, WarningEvent as Pn, ExecutableToolResult as Pr, ShellExecResult as Pt, CoreAPI as Q, SessionMeta$1 as Qn, ensureByfHome as Qr, BackgroundTaskTerminatedEvent as Qt, SDKAgentRPC$1 as R, validateConfig as Ri, makeErrorPayload as Rn, BackgroundTaskInfo$1 as Rr, TextPromptPart as Rt, RPCMethods as S, PermissionConfig as Si, ToolListUpdatedReason as Sn, ContextMessage$1 as Sr, RenameSessionPayload as St, ApprovalDecision as T, PermissionRuleDecisionSchema as Ti, ToolUpdate as Tn, UserPromptOrigin as Tr, SessionMetadataPatch as Tt, ToolCallResponse as U, Logger as Ui, ByfErrorCode as Un, configToTomlData as Ur, WithSessionId as Ut, SDKSessionRPC$1 as V, LogLevel as Vi, ByfErrorOptions as Vn, BearerTokenProvider as Vr, UpdateSessionMetadataPayload as Vt, ActivateSkillPayload$1 as W, LoggingConfig as Wi, ByfErrorInfo as Wn, ensureConfigFile as Wr, proxyWithExtraPayload as Wt, CancelPlanPayload as X, Session as Xn, parseBooleanEnv as Xr, AssistantDeltaEvent as Xt, CancelPayload as Y, AgentMeta as Yn, ResolveConfigValueInput as Yr, AgentStatusUpdatedEvent as Yt, CloseSessionPayload as Z, SessionConfig as Zn, resolveConfigValue as Zr, BackgroundTaskStartedEvent as Zt, ByfCoreOptions as _, McpServerStdioConfigSchema as _i, SubagentSpawnedEvent as _n, PermissionMode$1 as _r, PromptPart as _t, collectFilesRecursive as a, ByfConfigSchema as ai, Event as an, redact as ar, ForkSessionPayload as at, RPCCallOptions as b, OAuthRef$1 as bi, ToolCallStartedEvent as bn, CompactionResult$1 as br, RegisterToolPayload as bt, WIRE_PROTOCOL_VERSION as c, HookDefConfig as ci, McpOAuthAuthorizationUrlUpdateData as cn, ToolInfo$1 as cr, GetBackgroundPayload as ct, normalizeTimestampMs as d, LoopControlSchema as di, ObservationMaskingAppliedEvent as dn, AgentRecord as dr, JsonValue as dt, resolveConfigPath as ei, CompactionBlockedEvent as en, TelemetryClient as er, CreateSessionPayload as et, scanSessionWire as f, McpServerConfig as fi, PruningAppliedEvent as fn, AgentRecordEvents as fr, ListSessionsPayload as ft, ByfCore as g, McpServerStdioConfig as gi, SubagentFailedEvent as gn, PermissionApprovalResultRecord$1 as gr, PromptInput as gt, AgentType$1 as h, McpServerHttpConfigSchema as hi, SubagentCompletedEvent as hn, UsageRecordScope as hr, PlanData as ht, ExtraZipEntry as i, ByfConfigPatchSchema as ii, ErrorEvent as in, log as ir, ExportSessionResult as it, QuestionItem as j, ProviderTypeSchema as ji, TurnStepRetryingEvent as jn, LoopToolCallEvent as jr, SetPermissionPayload as jt, QuestionAnswerMethod as k, ProviderConfigSchema as ki, TurnStepCompletedEvent as kn, LoopStepBeginEvent as kr, SetModelPayload as kt, buildExportManifest as l, HookDefSchema as li, McpServerStatusEvent as ln, ToolSource as lr, JsonObject as lt, AgentConfig as m, McpServerHttpConfig as mi, SkillActivatedEvent as mn, AgentRecordPersistence as mr, McpStartupMetrics as mt, ResolveLoggingInput as n, BackgroundConfig as ni, CompactionCompletedEvent as nn, flushDiagnosticLogs as nr, ExportSessionManifest as nt, writeExportZip as o, ByfServiceConfig as oi, HookResultEvent as on, resolveGlobalLogPath as or, GetBackgroundOutputPathPayload as ot, Agent as p, McpServerConfigSchema as pi, SessionMetaUpdatedEvent as pn, AgentRecordOf as pr, McpServerInfo as pt, ByfConfig as q, SessionLogHandle as qi, SessionSubagentHost as qn, transformTomlData as qr, ResumedAgentState as qt, resolveLoggingConfig as r, BackgroundConfigSchema as ri, CompactionStartedEvent as rn, getRootLogger as rr, ExportSessionPayload as rt, exportSessionDirectory as s, ByfServiceConfigSchema as si, MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE as sn, BuiltinTool as sr, GetBackgroundOutputPayload as st, buildPromptPlan as t, mergeConfigPatch as ti, CompactionCancelledEvent as tn, TelemetryProperties as tr, EmptyPayload as tt, SessionWireScan as u, LoopControl as ui, McpServerStatusPayload as un, UserToolRegistration as ur, JsonPrimitive as ut, CoreRPC as v, ModelAlias as vi, ThinkingDeltaEvent as vn, AgentConfigUpdateData$1 as vr, PromptPayload as vt, createRPC as w, PermissionModeSchema as wi, ToolResultEvent as wn, USER_PROMPT_ORIGIN as wr, SessionAPI as wt, RPCClient as x, OAuthRefSchema as xi, ToolListUpdatedEvent as xn, AgentContextData$1 as xr, RemoveByfProviderPayload as xt, CoreRPCClient as y, ModelAliasSchema as yi, ToolCallDeltaEvent as yn, CompactionBeginData as yr, ReconnectMcpServerPayload as yt, SDKRPC as z, LogContext as zi, toByfErrorPayload as zn, BackgroundTaskKind as zr, UnregisterToolPayload as zt };