@codex-native/sdk 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -284,6 +284,79 @@ type TurnOptions = {
284
284
  modelProvider?: string;
285
285
  };
286
286
 
287
+ type NativeUserInputItem = {
288
+ type: "text";
289
+ text: string;
290
+ } | {
291
+ type: "local_image";
292
+ path: string;
293
+ } | {
294
+ type: "skill_inline";
295
+ name: string;
296
+ contents: string;
297
+ };
298
+ type NativeRunRequest = {
299
+ prompt: string;
300
+ threadId?: string;
301
+ inputItems?: NativeUserInputItem[];
302
+ images?: string[];
303
+ model?: string;
304
+ modelProvider?: string;
305
+ oss?: boolean;
306
+ sandboxMode?: SandboxMode;
307
+ approvalMode?: ApprovalMode;
308
+ workspaceWriteOptions?: WorkspaceWriteOptions;
309
+ workingDirectory?: string;
310
+ skipGitRepoCheck?: boolean;
311
+ outputSchema?: unknown;
312
+ baseUrl?: string;
313
+ apiKey?: string;
314
+ linuxSandboxPath?: string;
315
+ reasoningEffort?: ReasoningEffort;
316
+ reasoningSummary?: ReasoningSummary;
317
+ /** @deprecated Use sandboxMode and approvalMode instead */
318
+ fullAuto?: boolean;
319
+ reviewMode?: boolean;
320
+ reviewHint?: string;
321
+ };
322
+ type NativeForkRequest = {
323
+ threadId: string;
324
+ nthUserMessage: number;
325
+ model?: string;
326
+ modelProvider?: string;
327
+ oss?: boolean;
328
+ sandboxMode?: SandboxMode;
329
+ approvalMode?: ApprovalMode;
330
+ workspaceWriteOptions?: WorkspaceWriteOptions;
331
+ workingDirectory?: string;
332
+ skipGitRepoCheck?: boolean;
333
+ baseUrl?: string;
334
+ apiKey?: string;
335
+ linuxSandboxPath?: string;
336
+ fullAuto?: boolean;
337
+ };
338
+ type NativeConversationConfig = {
339
+ model?: string;
340
+ modelProvider?: string;
341
+ oss?: boolean;
342
+ sandboxMode?: SandboxMode;
343
+ approvalMode?: ApprovalMode;
344
+ workspaceWriteOptions?: WorkspaceWriteOptions;
345
+ workingDirectory?: string;
346
+ skipGitRepoCheck?: boolean;
347
+ baseUrl?: string;
348
+ apiKey?: string;
349
+ linuxSandboxPath?: string;
350
+ reasoningEffort?: ReasoningEffort;
351
+ reasoningSummary?: ReasoningSummary;
352
+ fullAuto?: boolean;
353
+ };
354
+ type NativeConversationListRequest = {
355
+ config?: NativeConversationConfig;
356
+ pageSize?: number;
357
+ cursor?: string;
358
+ modelProviders?: string[];
359
+ };
287
360
  type NativeConversationSummary = {
288
361
  id: string;
289
362
  path: string;
@@ -296,6 +369,17 @@ type NativeConversationListPage = {
296
369
  numScannedFiles: number;
297
370
  reachedScanCap: boolean;
298
371
  };
372
+ type NativeDeleteConversationRequest = {
373
+ id: string;
374
+ config?: NativeConversationConfig;
375
+ };
376
+ type NativeDeleteConversationResult = {
377
+ deleted: boolean;
378
+ };
379
+ type NativeResumeFromRolloutRequest = {
380
+ rolloutPath: string;
381
+ config?: NativeConversationConfig;
382
+ };
299
383
  type NativeTuiRequest = {
300
384
  prompt?: string;
301
385
  images?: string[];
@@ -320,6 +404,47 @@ type NativeTuiRequest = {
320
404
  reasoningEffort?: ReasoningEffort;
321
405
  reasoningSummary?: ReasoningSummary;
322
406
  };
407
+ type PlanStatus = "pending" | "in_progress" | "completed";
408
+ type NativeEmitBackgroundEventRequest = {
409
+ threadId: string;
410
+ message: string;
411
+ };
412
+ type NativeEmitPlanUpdateRequest = {
413
+ threadId: string;
414
+ explanation?: string;
415
+ plan: Array<{
416
+ step: string;
417
+ status: PlanStatus;
418
+ }>;
419
+ };
420
+ type NativeModifyPlanRequest = {
421
+ threadId: string;
422
+ operations: PlanOperation[];
423
+ };
424
+ type PlanOperation = {
425
+ type: "add";
426
+ item: {
427
+ step: string;
428
+ status?: PlanStatus;
429
+ };
430
+ } | {
431
+ type: "update";
432
+ index: number;
433
+ updates: {
434
+ step?: string;
435
+ status?: PlanStatus;
436
+ };
437
+ } | {
438
+ type: "remove";
439
+ index: number;
440
+ } | {
441
+ type: "reorder";
442
+ newOrder: number[];
443
+ };
444
+ type NativeToolInterceptorNativeContext = {
445
+ invocation: NativeToolInvocation;
446
+ token: string;
447
+ };
323
448
  type NativeTokenUsage = {
324
449
  inputTokens: number;
325
450
  cachedInputTokens: number;
@@ -337,6 +462,11 @@ type NativeTuiExitInfo = {
337
462
  conversationId?: string;
338
463
  updateAction?: NativeUpdateActionInfo;
339
464
  };
465
+ type NativeTuiSession = {
466
+ wait(): Promise<NativeTuiExitInfo>;
467
+ shutdown(): void;
468
+ readonly closed: boolean;
469
+ };
340
470
  type RepoDiffFileChange = {
341
471
  path: string;
342
472
  status: string;
@@ -420,6 +550,62 @@ type TokenizerOptions = {
420
550
  type TokenizerEncodeOptions = TokenizerOptions & {
421
551
  withSpecialTokens?: boolean;
422
552
  };
553
+ type NativeBinding = {
554
+ runThread(request: NativeRunRequest): Promise<string[]>;
555
+ runThreadStream(request: NativeRunRequest, onEvent: (err: unknown, eventJson?: string) => void): Promise<void>;
556
+ compactThread(request: NativeRunRequest): Promise<string[]>;
557
+ forkThread(request: NativeForkRequest): Promise<NativeForkResult>;
558
+ listConversations(request: NativeConversationListRequest): Promise<NativeConversationListPage>;
559
+ deleteConversation(request: NativeDeleteConversationRequest): Promise<NativeDeleteConversationResult>;
560
+ resumeConversationFromRollout(request: NativeResumeFromRolloutRequest): Promise<NativeForkResult>;
561
+ runTui(request: NativeTuiRequest): Promise<NativeTuiExitInfo>;
562
+ tuiTestRun?(request: {
563
+ width: number;
564
+ height: number;
565
+ viewport: {
566
+ x: number;
567
+ y: number;
568
+ width: number;
569
+ height: number;
570
+ };
571
+ lines: string[];
572
+ }): Promise<string[]>;
573
+ callToolBuiltin(token: string, invocation?: NativeToolInvocation): Promise<NativeToolResult>;
574
+ callRegisteredToolForTest?(toolName: string, invocation: NativeToolInvocation): Promise<NativeToolResult>;
575
+ clearRegisteredTools(): void;
576
+ registerTool(info: NativeToolInfo, handler: (call: NativeToolInvocation) => Promise<NativeToolResult> | NativeToolResult): void;
577
+ registerToolInterceptor(toolName: string, handler: (context: NativeToolInterceptorNativeContext) => Promise<NativeToolResult> | NativeToolResult): void;
578
+ listRegisteredTools(): NativeToolInfo[];
579
+ registerApprovalCallback?(handler: (request: ApprovalRequest) => boolean | Promise<boolean>): void;
580
+ emitBackgroundEvent(request: NativeEmitBackgroundEventRequest): Promise<void>;
581
+ emitPlanUpdate(request: NativeEmitPlanUpdateRequest): Promise<void>;
582
+ modifyPlan(request: NativeModifyPlanRequest): Promise<void>;
583
+ startTui?(request: NativeTuiRequest): NativeTuiSession;
584
+ ev_completed(id: string): string;
585
+ ev_response_created(id: string): string;
586
+ ev_assistant_message(id: string, text: string): string;
587
+ ev_function_call(callId: string, name: string, args: string): string;
588
+ sse(events: string[]): string;
589
+ ensureTokioRuntime?: () => void;
590
+ isTokioRuntimeAvailable?: () => boolean;
591
+ cloudTasksList?(env?: string, baseUrl?: string, apiKey?: string): Promise<string>;
592
+ cloudTasksGetDiff?(taskId: string, baseUrl?: string, apiKey?: string): Promise<string>;
593
+ cloudTasksApplyPreflight?(taskId: string, diffOverride?: string, baseUrl?: string, apiKey?: string): Promise<string>;
594
+ cloudTasksApply?(taskId: string, diffOverride?: string, baseUrl?: string, apiKey?: string): Promise<string>;
595
+ cloudTasksCreate?(envId: string, prompt: string, gitRef?: string, qaMode?: boolean, bestOfN?: number, baseUrl?: string, apiKey?: string): Promise<string>;
596
+ reverieListConversations(codexHomePath: string, limit?: number, offset?: number): Promise<ReverieConversation[]>;
597
+ reverieSearchConversations(codexHomePath: string, query: string, limit?: number): Promise<ReverieSearchResult[]>;
598
+ reverieSearchSemantic?(codexHomePath: string, context: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSearchResult[]>;
599
+ reverieIndexSemantic?(codexHomePath: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSemanticIndexStats>;
600
+ reverieGetConversationInsights(conversationPath: string, query?: string): Promise<string[]>;
601
+ toonEncode(value: unknown): string;
602
+ fastEmbedInit?(options: FastEmbedInitOptions): Promise<void>;
603
+ fastEmbedEmbed?(request: FastEmbedEmbedRequest): Promise<number[][]>;
604
+ tokenizerCount(text: string, options?: TokenizerOptions): number;
605
+ tokenizerEncode(text: string, options?: TokenizerEncodeOptions): number[];
606
+ tokenizerDecode(tokens: number[], options?: TokenizerOptions): string;
607
+ collectRepoDiffSummary?(cwd: string, baseBranchOverride?: string, options?: NativeRepoDiffOptions): Promise<RepoDiffSummary>;
608
+ };
423
609
  type NativeToolInfo = {
424
610
  name: string;
425
611
  description?: string;
@@ -447,6 +633,12 @@ type ApprovalRequest = {
447
633
  details?: unknown;
448
634
  context?: string;
449
635
  };
636
+ type NativeRepoDiffOptions = {
637
+ maxFiles?: number;
638
+ diffContextLines?: number;
639
+ diffCharLimit?: number;
640
+ };
641
+ declare function getNativeBinding(): NativeBinding | null;
450
642
  declare function reverieListConversations(codexHomePath: string, limit?: number, offset?: number): Promise<ReverieConversation[]>;
451
643
  declare function reverieSearchConversations(codexHomePath: string, query: string, limit?: number): Promise<ReverieSearchResult[]>;
452
644
  declare function reverieSearchSemantic(codexHomePath: string, context: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSearchResult[]>;
@@ -998,7 +1190,7 @@ type ToolExecutorResult = string | NativeToolResult | {
998
1190
  output?: string;
999
1191
  error?: string;
1000
1192
  success?: boolean;
1001
- } | void;
1193
+ } | Record<string, unknown> | unknown[] | number | boolean | null | void;
1002
1194
  type ToolExecutor = (context: ToolExecutionContext) => Promise<ToolExecutorResult> | ToolExecutorResult;
1003
1195
  declare function registerCodexToolExecutor(name: string, executor: ToolExecutor): void;
1004
1196
  declare function getCodexToolExecutor(name: string): ToolExecutor | undefined;
@@ -2306,4 +2498,4 @@ declare function evAssistantMessage(id: string, text: string): string;
2306
2498
  declare function evFunctionCall(callId: string, name: string, args: string): string;
2307
2499
  declare function sse(events: string[]): string;
2308
2500
 
2309
- export { type AgentMessageItem, type AgentRunner, type ApprovalMode, type ApprovalRequest, type BranchLevelContext, type BranchReview, type CloudApplyOutcome, type CloudApplyStatus, type DiffSummary as CloudDiffSummary, type CloudTaskStatus, type CloudTaskSummary, CloudTasks, type CloudTasksOptions, Codex, type CodexOptions, CodexProvider, type CodexProviderOptions, type CodexToolOptions, type CommandExecutionItem, type CommandExecutionStatus, type CommitReview, type ConversationListOptions, type ConversationListPage, type ConversationSummary, type CurrentChangesReview, type CustomReview, DEFAULT_RERANKER_BATCH_SIZE, DEFAULT_RERANKER_TOP_K, DEFAULT_REVERIE_LIMIT, DEFAULT_REVERIE_MAX_CANDIDATES, DEFAULT_SERVERS, type DelegationResult, type DiagnosticSeverity, type ErrorItem, type FastEmbedEmbedRequest, type FastEmbedInitOptions, type FastEmbedRerankerModelCode, type FileChangeItem, type FileDiagnostics, type FileLevelContext, type FileUpdateChange, type ForkOptions, type FormatStreamOptions, type FormattedStream, type GradingOptions, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type LogEntry, LogLevel, type LogOutput, type LogScope, Logger, type LoggerConfig, type LspDiagnosticSeverity, LspDiagnosticsBridge, LspManager, type LspManagerOptions, type LspServerConfig, type McpToolCallItem, type McpToolCallStatus, type NativeForkResult, type NativeTokenUsage, type NativeToolDefinition, type NativeToolInterceptorContext, type NativeToolInvocation, type NativeToolResult, type NativeTuiExitInfo, type NativeTuiRequest, type NativeUpdateActionInfo, type NativeUpdateActionKind, type NormalizedDiagnostic, OpenCodeAgent, type OpenCodeAgentOptions, type PatchApplyStatus, type PatchChangeKind, type PermissionDecision, type PermissionRequest, type ProjectLevelContext, type QualityFilterStats, REVERIE_CANDIDATE_MULTIPLIER, REVERIE_EMBED_MODEL, REVERIE_LLM_GRADE_THRESHOLD, REVERIE_RERANKER_MODEL, type ReasoningItem, type RepoDiffFileChange, type RepoDiffSummary, type RepoDiffSummaryOptions, type ReverieContext, type ReverieEpisodeSummary, type ReverieFilterStats, type ReverieInsight$1 as ReverieInsight, type ReveriePipelineOptions, type ReveriePipelineResult, type ReverieResult, type ReverieSearchLevel, type ReverieSearchOptions, type ReverieSemanticIndexStats, type ReverieSemanticSearchOptions, type ReviewInvocationOptions, type ReviewTarget, type RunResult, type RunStreamedResult, type RunTuiOptions, type SandboxMode, ScopedLogger, type SkillDefinition, type SkillMentionTrigger, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadLoggingSink, type ThreadOptions, type ThreadStartedEvent, type TodoItem, type TodoListItem, type TokenizerEncodeOptions, type TokenizerOptions, type ToolCallEvent, type ToolExecutionContext, type ToolExecutor, type ToolExecutorResult, type TuiSession, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type UserInput, type WebSearchItem, type WorkspaceLocator, applyFileReveriePipeline, applyQualityPipeline, applyReveriePipeline, attachLspDiagnostics, buildBranchContext, buildFileContext, buildProjectContext, clearCodexToolExecutors, codexTool, collectRepoDiffSummary, contextToQuery, createThreadLogger, deduplicateReverieInsights, encodeToToon, evAssistantMessage, evCompleted, evFunctionCall, evResponseCreated, extractKeySymbols, fastEmbedEmbed, fastEmbedInit, filterBySeverity, findServerForFile, formatDiagnosticsForBackgroundEvent, formatDiagnosticsForTool, formatDiagnosticsWithSummary, formatFileList, formatStream, getCodexToolExecutor, gradeReverieRelevance, gradeReveriesInParallel, isValidReverieExcerpt, logApprovedReveries, logLLMGrading, logLevelResults, logMultiLevelSearch, logMultiLevelSummary, logReverieFiltering, logReverieHintQuality, logReverieInsights, logReverieSearch, logger, registerCodexToolExecutor, resolveWorkspaceRoot, reverieGetConversationInsights, reverieIndexSemantic, reverieListConversations, reverieSearchConversations, reverieSearchSemantic, runThreadTurnWithLogs, runTui, searchBranchLevel, searchFileLevel, searchMultiLevel, searchProjectLevel, searchReveries, sse, startTui, summarizeDiagnostics, tokenizerCount, tokenizerDecode, tokenizerEncode, truncate as truncateText };
2501
+ export { type AgentMessageItem, type AgentRunner, type ApprovalMode, type ApprovalRequest, type BranchLevelContext, type BranchReview, type CloudApplyOutcome, type CloudApplyStatus, type DiffSummary as CloudDiffSummary, type CloudTaskStatus, type CloudTaskSummary, CloudTasks, type CloudTasksOptions, Codex, type CodexOptions, CodexProvider, type CodexProviderOptions, type CodexToolOptions, type CommandExecutionItem, type CommandExecutionStatus, type CommitReview, type ConversationListOptions, type ConversationListPage, type ConversationSummary, type CurrentChangesReview, type CustomReview, DEFAULT_RERANKER_BATCH_SIZE, DEFAULT_RERANKER_TOP_K, DEFAULT_REVERIE_LIMIT, DEFAULT_REVERIE_MAX_CANDIDATES, DEFAULT_SERVERS, type DelegationResult, type DiagnosticSeverity, type ErrorItem, type FastEmbedEmbedRequest, type FastEmbedInitOptions, type FastEmbedRerankerModelCode, type FileChangeItem, type FileDiagnostics, type FileLevelContext, type FileUpdateChange, type ForkOptions, type FormatStreamOptions, type FormattedStream, type GradingOptions, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type LogEntry, LogLevel, type LogOutput, type LogScope, Logger, type LoggerConfig, type LspDiagnosticSeverity, LspDiagnosticsBridge, LspManager, type LspManagerOptions, type LspServerConfig, type McpToolCallItem, type McpToolCallStatus, type NativeForkResult, type NativeTokenUsage, type NativeToolDefinition, type NativeToolInterceptorContext, type NativeToolInvocation, type NativeToolResult, type NativeTuiExitInfo, type NativeTuiRequest, type NativeUpdateActionInfo, type NativeUpdateActionKind, type NormalizedDiagnostic, OpenCodeAgent, type OpenCodeAgentOptions, type PatchApplyStatus, type PatchChangeKind, type PermissionDecision, type PermissionRequest, type ProjectLevelContext, type QualityFilterStats, REVERIE_CANDIDATE_MULTIPLIER, REVERIE_EMBED_MODEL, REVERIE_LLM_GRADE_THRESHOLD, REVERIE_RERANKER_MODEL, type ReasoningItem, type RepoDiffFileChange, type RepoDiffSummary, type RepoDiffSummaryOptions, type ReverieContext, type ReverieEpisodeSummary, type ReverieFilterStats, type ReverieInsight$1 as ReverieInsight, type ReveriePipelineOptions, type ReveriePipelineResult, type ReverieResult, type ReverieSearchLevel, type ReverieSearchOptions, type ReverieSemanticIndexStats, type ReverieSemanticSearchOptions, type ReviewInvocationOptions, type ReviewTarget, type RunResult, type RunStreamedResult, type RunTuiOptions, type SandboxMode, ScopedLogger, type SkillDefinition, type SkillMentionTrigger, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadLoggingSink, type ThreadOptions, type ThreadStartedEvent, type TodoItem, type TodoListItem, type TokenizerEncodeOptions, type TokenizerOptions, type ToolCallEvent, type ToolExecutionContext, type ToolExecutor, type ToolExecutorResult, type TuiSession, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type UserInput, type WebSearchItem, type WorkspaceLocator, applyFileReveriePipeline, applyQualityPipeline, applyReveriePipeline, attachLspDiagnostics, buildBranchContext, buildFileContext, buildProjectContext, clearCodexToolExecutors, codexTool, collectRepoDiffSummary, contextToQuery, createThreadLogger, deduplicateReverieInsights, encodeToToon, evAssistantMessage, evCompleted, evFunctionCall, evResponseCreated, extractKeySymbols, fastEmbedEmbed, fastEmbedInit, filterBySeverity, findServerForFile, formatDiagnosticsForBackgroundEvent, formatDiagnosticsForTool, formatDiagnosticsWithSummary, formatFileList, formatStream, getCodexToolExecutor, getNativeBinding, gradeReverieRelevance, gradeReveriesInParallel, isValidReverieExcerpt, logApprovedReveries, logLLMGrading, logLevelResults, logMultiLevelSearch, logMultiLevelSummary, logReverieFiltering, logReverieHintQuality, logReverieInsights, logReverieSearch, logger, registerCodexToolExecutor, resolveWorkspaceRoot, reverieGetConversationInsights, reverieIndexSemantic, reverieListConversations, reverieSearchConversations, reverieSearchSemantic, runThreadTurnWithLogs, runTui, searchBranchLevel, searchFileLevel, searchMultiLevel, searchProjectLevel, searchReveries, sse, startTui, summarizeDiagnostics, tokenizerCount, tokenizerDecode, tokenizerEncode, truncate as truncateText };
package/dist/index.d.ts CHANGED
@@ -284,6 +284,79 @@ type TurnOptions = {
284
284
  modelProvider?: string;
285
285
  };
286
286
 
287
+ type NativeUserInputItem = {
288
+ type: "text";
289
+ text: string;
290
+ } | {
291
+ type: "local_image";
292
+ path: string;
293
+ } | {
294
+ type: "skill_inline";
295
+ name: string;
296
+ contents: string;
297
+ };
298
+ type NativeRunRequest = {
299
+ prompt: string;
300
+ threadId?: string;
301
+ inputItems?: NativeUserInputItem[];
302
+ images?: string[];
303
+ model?: string;
304
+ modelProvider?: string;
305
+ oss?: boolean;
306
+ sandboxMode?: SandboxMode;
307
+ approvalMode?: ApprovalMode;
308
+ workspaceWriteOptions?: WorkspaceWriteOptions;
309
+ workingDirectory?: string;
310
+ skipGitRepoCheck?: boolean;
311
+ outputSchema?: unknown;
312
+ baseUrl?: string;
313
+ apiKey?: string;
314
+ linuxSandboxPath?: string;
315
+ reasoningEffort?: ReasoningEffort;
316
+ reasoningSummary?: ReasoningSummary;
317
+ /** @deprecated Use sandboxMode and approvalMode instead */
318
+ fullAuto?: boolean;
319
+ reviewMode?: boolean;
320
+ reviewHint?: string;
321
+ };
322
+ type NativeForkRequest = {
323
+ threadId: string;
324
+ nthUserMessage: number;
325
+ model?: string;
326
+ modelProvider?: string;
327
+ oss?: boolean;
328
+ sandboxMode?: SandboxMode;
329
+ approvalMode?: ApprovalMode;
330
+ workspaceWriteOptions?: WorkspaceWriteOptions;
331
+ workingDirectory?: string;
332
+ skipGitRepoCheck?: boolean;
333
+ baseUrl?: string;
334
+ apiKey?: string;
335
+ linuxSandboxPath?: string;
336
+ fullAuto?: boolean;
337
+ };
338
+ type NativeConversationConfig = {
339
+ model?: string;
340
+ modelProvider?: string;
341
+ oss?: boolean;
342
+ sandboxMode?: SandboxMode;
343
+ approvalMode?: ApprovalMode;
344
+ workspaceWriteOptions?: WorkspaceWriteOptions;
345
+ workingDirectory?: string;
346
+ skipGitRepoCheck?: boolean;
347
+ baseUrl?: string;
348
+ apiKey?: string;
349
+ linuxSandboxPath?: string;
350
+ reasoningEffort?: ReasoningEffort;
351
+ reasoningSummary?: ReasoningSummary;
352
+ fullAuto?: boolean;
353
+ };
354
+ type NativeConversationListRequest = {
355
+ config?: NativeConversationConfig;
356
+ pageSize?: number;
357
+ cursor?: string;
358
+ modelProviders?: string[];
359
+ };
287
360
  type NativeConversationSummary = {
288
361
  id: string;
289
362
  path: string;
@@ -296,6 +369,17 @@ type NativeConversationListPage = {
296
369
  numScannedFiles: number;
297
370
  reachedScanCap: boolean;
298
371
  };
372
+ type NativeDeleteConversationRequest = {
373
+ id: string;
374
+ config?: NativeConversationConfig;
375
+ };
376
+ type NativeDeleteConversationResult = {
377
+ deleted: boolean;
378
+ };
379
+ type NativeResumeFromRolloutRequest = {
380
+ rolloutPath: string;
381
+ config?: NativeConversationConfig;
382
+ };
299
383
  type NativeTuiRequest = {
300
384
  prompt?: string;
301
385
  images?: string[];
@@ -320,6 +404,47 @@ type NativeTuiRequest = {
320
404
  reasoningEffort?: ReasoningEffort;
321
405
  reasoningSummary?: ReasoningSummary;
322
406
  };
407
+ type PlanStatus = "pending" | "in_progress" | "completed";
408
+ type NativeEmitBackgroundEventRequest = {
409
+ threadId: string;
410
+ message: string;
411
+ };
412
+ type NativeEmitPlanUpdateRequest = {
413
+ threadId: string;
414
+ explanation?: string;
415
+ plan: Array<{
416
+ step: string;
417
+ status: PlanStatus;
418
+ }>;
419
+ };
420
+ type NativeModifyPlanRequest = {
421
+ threadId: string;
422
+ operations: PlanOperation[];
423
+ };
424
+ type PlanOperation = {
425
+ type: "add";
426
+ item: {
427
+ step: string;
428
+ status?: PlanStatus;
429
+ };
430
+ } | {
431
+ type: "update";
432
+ index: number;
433
+ updates: {
434
+ step?: string;
435
+ status?: PlanStatus;
436
+ };
437
+ } | {
438
+ type: "remove";
439
+ index: number;
440
+ } | {
441
+ type: "reorder";
442
+ newOrder: number[];
443
+ };
444
+ type NativeToolInterceptorNativeContext = {
445
+ invocation: NativeToolInvocation;
446
+ token: string;
447
+ };
323
448
  type NativeTokenUsage = {
324
449
  inputTokens: number;
325
450
  cachedInputTokens: number;
@@ -337,6 +462,11 @@ type NativeTuiExitInfo = {
337
462
  conversationId?: string;
338
463
  updateAction?: NativeUpdateActionInfo;
339
464
  };
465
+ type NativeTuiSession = {
466
+ wait(): Promise<NativeTuiExitInfo>;
467
+ shutdown(): void;
468
+ readonly closed: boolean;
469
+ };
340
470
  type RepoDiffFileChange = {
341
471
  path: string;
342
472
  status: string;
@@ -420,6 +550,62 @@ type TokenizerOptions = {
420
550
  type TokenizerEncodeOptions = TokenizerOptions & {
421
551
  withSpecialTokens?: boolean;
422
552
  };
553
+ type NativeBinding = {
554
+ runThread(request: NativeRunRequest): Promise<string[]>;
555
+ runThreadStream(request: NativeRunRequest, onEvent: (err: unknown, eventJson?: string) => void): Promise<void>;
556
+ compactThread(request: NativeRunRequest): Promise<string[]>;
557
+ forkThread(request: NativeForkRequest): Promise<NativeForkResult>;
558
+ listConversations(request: NativeConversationListRequest): Promise<NativeConversationListPage>;
559
+ deleteConversation(request: NativeDeleteConversationRequest): Promise<NativeDeleteConversationResult>;
560
+ resumeConversationFromRollout(request: NativeResumeFromRolloutRequest): Promise<NativeForkResult>;
561
+ runTui(request: NativeTuiRequest): Promise<NativeTuiExitInfo>;
562
+ tuiTestRun?(request: {
563
+ width: number;
564
+ height: number;
565
+ viewport: {
566
+ x: number;
567
+ y: number;
568
+ width: number;
569
+ height: number;
570
+ };
571
+ lines: string[];
572
+ }): Promise<string[]>;
573
+ callToolBuiltin(token: string, invocation?: NativeToolInvocation): Promise<NativeToolResult>;
574
+ callRegisteredToolForTest?(toolName: string, invocation: NativeToolInvocation): Promise<NativeToolResult>;
575
+ clearRegisteredTools(): void;
576
+ registerTool(info: NativeToolInfo, handler: (call: NativeToolInvocation) => Promise<NativeToolResult> | NativeToolResult): void;
577
+ registerToolInterceptor(toolName: string, handler: (context: NativeToolInterceptorNativeContext) => Promise<NativeToolResult> | NativeToolResult): void;
578
+ listRegisteredTools(): NativeToolInfo[];
579
+ registerApprovalCallback?(handler: (request: ApprovalRequest) => boolean | Promise<boolean>): void;
580
+ emitBackgroundEvent(request: NativeEmitBackgroundEventRequest): Promise<void>;
581
+ emitPlanUpdate(request: NativeEmitPlanUpdateRequest): Promise<void>;
582
+ modifyPlan(request: NativeModifyPlanRequest): Promise<void>;
583
+ startTui?(request: NativeTuiRequest): NativeTuiSession;
584
+ ev_completed(id: string): string;
585
+ ev_response_created(id: string): string;
586
+ ev_assistant_message(id: string, text: string): string;
587
+ ev_function_call(callId: string, name: string, args: string): string;
588
+ sse(events: string[]): string;
589
+ ensureTokioRuntime?: () => void;
590
+ isTokioRuntimeAvailable?: () => boolean;
591
+ cloudTasksList?(env?: string, baseUrl?: string, apiKey?: string): Promise<string>;
592
+ cloudTasksGetDiff?(taskId: string, baseUrl?: string, apiKey?: string): Promise<string>;
593
+ cloudTasksApplyPreflight?(taskId: string, diffOverride?: string, baseUrl?: string, apiKey?: string): Promise<string>;
594
+ cloudTasksApply?(taskId: string, diffOverride?: string, baseUrl?: string, apiKey?: string): Promise<string>;
595
+ cloudTasksCreate?(envId: string, prompt: string, gitRef?: string, qaMode?: boolean, bestOfN?: number, baseUrl?: string, apiKey?: string): Promise<string>;
596
+ reverieListConversations(codexHomePath: string, limit?: number, offset?: number): Promise<ReverieConversation[]>;
597
+ reverieSearchConversations(codexHomePath: string, query: string, limit?: number): Promise<ReverieSearchResult[]>;
598
+ reverieSearchSemantic?(codexHomePath: string, context: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSearchResult[]>;
599
+ reverieIndexSemantic?(codexHomePath: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSemanticIndexStats>;
600
+ reverieGetConversationInsights(conversationPath: string, query?: string): Promise<string[]>;
601
+ toonEncode(value: unknown): string;
602
+ fastEmbedInit?(options: FastEmbedInitOptions): Promise<void>;
603
+ fastEmbedEmbed?(request: FastEmbedEmbedRequest): Promise<number[][]>;
604
+ tokenizerCount(text: string, options?: TokenizerOptions): number;
605
+ tokenizerEncode(text: string, options?: TokenizerEncodeOptions): number[];
606
+ tokenizerDecode(tokens: number[], options?: TokenizerOptions): string;
607
+ collectRepoDiffSummary?(cwd: string, baseBranchOverride?: string, options?: NativeRepoDiffOptions): Promise<RepoDiffSummary>;
608
+ };
423
609
  type NativeToolInfo = {
424
610
  name: string;
425
611
  description?: string;
@@ -447,6 +633,12 @@ type ApprovalRequest = {
447
633
  details?: unknown;
448
634
  context?: string;
449
635
  };
636
+ type NativeRepoDiffOptions = {
637
+ maxFiles?: number;
638
+ diffContextLines?: number;
639
+ diffCharLimit?: number;
640
+ };
641
+ declare function getNativeBinding(): NativeBinding | null;
450
642
  declare function reverieListConversations(codexHomePath: string, limit?: number, offset?: number): Promise<ReverieConversation[]>;
451
643
  declare function reverieSearchConversations(codexHomePath: string, query: string, limit?: number): Promise<ReverieSearchResult[]>;
452
644
  declare function reverieSearchSemantic(codexHomePath: string, context: string, options?: ReverieSemanticSearchOptions): Promise<ReverieSearchResult[]>;
@@ -998,7 +1190,7 @@ type ToolExecutorResult = string | NativeToolResult | {
998
1190
  output?: string;
999
1191
  error?: string;
1000
1192
  success?: boolean;
1001
- } | void;
1193
+ } | Record<string, unknown> | unknown[] | number | boolean | null | void;
1002
1194
  type ToolExecutor = (context: ToolExecutionContext) => Promise<ToolExecutorResult> | ToolExecutorResult;
1003
1195
  declare function registerCodexToolExecutor(name: string, executor: ToolExecutor): void;
1004
1196
  declare function getCodexToolExecutor(name: string): ToolExecutor | undefined;
@@ -2306,4 +2498,4 @@ declare function evAssistantMessage(id: string, text: string): string;
2306
2498
  declare function evFunctionCall(callId: string, name: string, args: string): string;
2307
2499
  declare function sse(events: string[]): string;
2308
2500
 
2309
- export { type AgentMessageItem, type AgentRunner, type ApprovalMode, type ApprovalRequest, type BranchLevelContext, type BranchReview, type CloudApplyOutcome, type CloudApplyStatus, type DiffSummary as CloudDiffSummary, type CloudTaskStatus, type CloudTaskSummary, CloudTasks, type CloudTasksOptions, Codex, type CodexOptions, CodexProvider, type CodexProviderOptions, type CodexToolOptions, type CommandExecutionItem, type CommandExecutionStatus, type CommitReview, type ConversationListOptions, type ConversationListPage, type ConversationSummary, type CurrentChangesReview, type CustomReview, DEFAULT_RERANKER_BATCH_SIZE, DEFAULT_RERANKER_TOP_K, DEFAULT_REVERIE_LIMIT, DEFAULT_REVERIE_MAX_CANDIDATES, DEFAULT_SERVERS, type DelegationResult, type DiagnosticSeverity, type ErrorItem, type FastEmbedEmbedRequest, type FastEmbedInitOptions, type FastEmbedRerankerModelCode, type FileChangeItem, type FileDiagnostics, type FileLevelContext, type FileUpdateChange, type ForkOptions, type FormatStreamOptions, type FormattedStream, type GradingOptions, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type LogEntry, LogLevel, type LogOutput, type LogScope, Logger, type LoggerConfig, type LspDiagnosticSeverity, LspDiagnosticsBridge, LspManager, type LspManagerOptions, type LspServerConfig, type McpToolCallItem, type McpToolCallStatus, type NativeForkResult, type NativeTokenUsage, type NativeToolDefinition, type NativeToolInterceptorContext, type NativeToolInvocation, type NativeToolResult, type NativeTuiExitInfo, type NativeTuiRequest, type NativeUpdateActionInfo, type NativeUpdateActionKind, type NormalizedDiagnostic, OpenCodeAgent, type OpenCodeAgentOptions, type PatchApplyStatus, type PatchChangeKind, type PermissionDecision, type PermissionRequest, type ProjectLevelContext, type QualityFilterStats, REVERIE_CANDIDATE_MULTIPLIER, REVERIE_EMBED_MODEL, REVERIE_LLM_GRADE_THRESHOLD, REVERIE_RERANKER_MODEL, type ReasoningItem, type RepoDiffFileChange, type RepoDiffSummary, type RepoDiffSummaryOptions, type ReverieContext, type ReverieEpisodeSummary, type ReverieFilterStats, type ReverieInsight$1 as ReverieInsight, type ReveriePipelineOptions, type ReveriePipelineResult, type ReverieResult, type ReverieSearchLevel, type ReverieSearchOptions, type ReverieSemanticIndexStats, type ReverieSemanticSearchOptions, type ReviewInvocationOptions, type ReviewTarget, type RunResult, type RunStreamedResult, type RunTuiOptions, type SandboxMode, ScopedLogger, type SkillDefinition, type SkillMentionTrigger, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadLoggingSink, type ThreadOptions, type ThreadStartedEvent, type TodoItem, type TodoListItem, type TokenizerEncodeOptions, type TokenizerOptions, type ToolCallEvent, type ToolExecutionContext, type ToolExecutor, type ToolExecutorResult, type TuiSession, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type UserInput, type WebSearchItem, type WorkspaceLocator, applyFileReveriePipeline, applyQualityPipeline, applyReveriePipeline, attachLspDiagnostics, buildBranchContext, buildFileContext, buildProjectContext, clearCodexToolExecutors, codexTool, collectRepoDiffSummary, contextToQuery, createThreadLogger, deduplicateReverieInsights, encodeToToon, evAssistantMessage, evCompleted, evFunctionCall, evResponseCreated, extractKeySymbols, fastEmbedEmbed, fastEmbedInit, filterBySeverity, findServerForFile, formatDiagnosticsForBackgroundEvent, formatDiagnosticsForTool, formatDiagnosticsWithSummary, formatFileList, formatStream, getCodexToolExecutor, gradeReverieRelevance, gradeReveriesInParallel, isValidReverieExcerpt, logApprovedReveries, logLLMGrading, logLevelResults, logMultiLevelSearch, logMultiLevelSummary, logReverieFiltering, logReverieHintQuality, logReverieInsights, logReverieSearch, logger, registerCodexToolExecutor, resolveWorkspaceRoot, reverieGetConversationInsights, reverieIndexSemantic, reverieListConversations, reverieSearchConversations, reverieSearchSemantic, runThreadTurnWithLogs, runTui, searchBranchLevel, searchFileLevel, searchMultiLevel, searchProjectLevel, searchReveries, sse, startTui, summarizeDiagnostics, tokenizerCount, tokenizerDecode, tokenizerEncode, truncate as truncateText };
2501
+ export { type AgentMessageItem, type AgentRunner, type ApprovalMode, type ApprovalRequest, type BranchLevelContext, type BranchReview, type CloudApplyOutcome, type CloudApplyStatus, type DiffSummary as CloudDiffSummary, type CloudTaskStatus, type CloudTaskSummary, CloudTasks, type CloudTasksOptions, Codex, type CodexOptions, CodexProvider, type CodexProviderOptions, type CodexToolOptions, type CommandExecutionItem, type CommandExecutionStatus, type CommitReview, type ConversationListOptions, type ConversationListPage, type ConversationSummary, type CurrentChangesReview, type CustomReview, DEFAULT_RERANKER_BATCH_SIZE, DEFAULT_RERANKER_TOP_K, DEFAULT_REVERIE_LIMIT, DEFAULT_REVERIE_MAX_CANDIDATES, DEFAULT_SERVERS, type DelegationResult, type DiagnosticSeverity, type ErrorItem, type FastEmbedEmbedRequest, type FastEmbedInitOptions, type FastEmbedRerankerModelCode, type FileChangeItem, type FileDiagnostics, type FileLevelContext, type FileUpdateChange, type ForkOptions, type FormatStreamOptions, type FormattedStream, type GradingOptions, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type LogEntry, LogLevel, type LogOutput, type LogScope, Logger, type LoggerConfig, type LspDiagnosticSeverity, LspDiagnosticsBridge, LspManager, type LspManagerOptions, type LspServerConfig, type McpToolCallItem, type McpToolCallStatus, type NativeForkResult, type NativeTokenUsage, type NativeToolDefinition, type NativeToolInterceptorContext, type NativeToolInvocation, type NativeToolResult, type NativeTuiExitInfo, type NativeTuiRequest, type NativeUpdateActionInfo, type NativeUpdateActionKind, type NormalizedDiagnostic, OpenCodeAgent, type OpenCodeAgentOptions, type PatchApplyStatus, type PatchChangeKind, type PermissionDecision, type PermissionRequest, type ProjectLevelContext, type QualityFilterStats, REVERIE_CANDIDATE_MULTIPLIER, REVERIE_EMBED_MODEL, REVERIE_LLM_GRADE_THRESHOLD, REVERIE_RERANKER_MODEL, type ReasoningItem, type RepoDiffFileChange, type RepoDiffSummary, type RepoDiffSummaryOptions, type ReverieContext, type ReverieEpisodeSummary, type ReverieFilterStats, type ReverieInsight$1 as ReverieInsight, type ReveriePipelineOptions, type ReveriePipelineResult, type ReverieResult, type ReverieSearchLevel, type ReverieSearchOptions, type ReverieSemanticIndexStats, type ReverieSemanticSearchOptions, type ReviewInvocationOptions, type ReviewTarget, type RunResult, type RunStreamedResult, type RunTuiOptions, type SandboxMode, ScopedLogger, type SkillDefinition, type SkillMentionTrigger, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadLoggingSink, type ThreadOptions, type ThreadStartedEvent, type TodoItem, type TodoListItem, type TokenizerEncodeOptions, type TokenizerOptions, type ToolCallEvent, type ToolExecutionContext, type ToolExecutor, type ToolExecutorResult, type TuiSession, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type UserInput, type WebSearchItem, type WorkspaceLocator, applyFileReveriePipeline, applyQualityPipeline, applyReveriePipeline, attachLspDiagnostics, buildBranchContext, buildFileContext, buildProjectContext, clearCodexToolExecutors, codexTool, collectRepoDiffSummary, contextToQuery, createThreadLogger, deduplicateReverieInsights, encodeToToon, evAssistantMessage, evCompleted, evFunctionCall, evResponseCreated, extractKeySymbols, fastEmbedEmbed, fastEmbedInit, filterBySeverity, findServerForFile, formatDiagnosticsForBackgroundEvent, formatDiagnosticsForTool, formatDiagnosticsWithSummary, formatFileList, formatStream, getCodexToolExecutor, getNativeBinding, gradeReverieRelevance, gradeReveriesInParallel, isValidReverieExcerpt, logApprovedReveries, logLLMGrading, logLevelResults, logMultiLevelSearch, logMultiLevelSummary, logReverieFiltering, logReverieHintQuality, logReverieInsights, logReverieSearch, logger, registerCodexToolExecutor, resolveWorkspaceRoot, reverieGetConversationInsights, reverieIndexSemantic, reverieListConversations, reverieSearchConversations, reverieSearchSemantic, runThreadTurnWithLogs, runTui, searchBranchLevel, searchFileLevel, searchMultiLevel, searchProjectLevel, searchReveries, sse, startTui, summarizeDiagnostics, tokenizerCount, tokenizerDecode, tokenizerEncode, truncate as truncateText };
package/dist/index.mjs CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  tokenizerCount,
28
28
  tokenizerDecode,
29
29
  tokenizerEncode
30
- } from "./chunk-LFJNLOFF.mjs";
30
+ } from "./chunk-ZAYUMM55.mjs";
31
31
 
32
32
  // src/agents/toolRegistry.ts
33
33
  var executors = /* @__PURE__ */ new Map();
@@ -264,10 +264,21 @@ var CodexModel = class {
264
264
  };
265
265
  this.codex.registerTool(nativeToolDef);
266
266
  this.registeredTools.add(tool2.name);
267
- console.log(`Registered tool with Codex: ${tool2.name}`);
267
+ const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
268
+ if (DEBUG) {
269
+ try {
270
+ process.stderr.write(`[codex-native] Registered tool with Codex: ${tool2.name}
271
+ `);
272
+ } catch {
273
+ }
274
+ }
268
275
  } catch (error) {
269
276
  const errorMessage = `Failed to register tool ${tool2.name}: ${error instanceof Error ? error.message : String(error)}`;
270
- console.error(errorMessage);
277
+ try {
278
+ process.stderr.write(`[codex-native] ${errorMessage}
279
+ `);
280
+ } catch {
281
+ }
271
282
  }
272
283
  }
273
284
  }
@@ -292,11 +303,21 @@ var CodexModel = class {
292
303
  * but the framework integration is not yet complete.
293
304
  */
294
305
  async executeToolViaFramework(invocation) {
295
- console.log("[DEBUG executeToolViaFramework] invocation:", JSON.stringify(invocation, null, 2));
296
- console.log("[DEBUG executeToolViaFramework] invocation type:", typeof invocation);
297
- console.log("[DEBUG executeToolViaFramework] invocation keys:", invocation ? Object.keys(invocation) : "null/undefined");
306
+ const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
307
+ if (DEBUG) {
308
+ try {
309
+ process.stderr.write(
310
+ `[codex-native] executeToolViaFramework invocation: ${JSON.stringify(invocation)}
311
+ `
312
+ );
313
+ } catch {
314
+ }
315
+ }
298
316
  if (!invocation) {
299
- console.warn("Codex requested a tool execution without invocation data.");
317
+ try {
318
+ process.stderr.write("[codex-native] Codex requested a tool execution without invocation data.\n");
319
+ } catch {
320
+ }
300
321
  return {
301
322
  output: JSON.stringify({
302
323
  message: "Tool invocation payload missing",
@@ -306,13 +327,23 @@ var CodexModel = class {
306
327
  error: "Missing tool invocation data from Codex"
307
328
  };
308
329
  }
309
- console.log(
310
- `Tool execution requested by Codex: ${invocation.toolName} (callId: ${invocation.callId})`
311
- );
330
+ if (DEBUG) {
331
+ try {
332
+ process.stderr.write(
333
+ `[codex-native] Tool execution requested: ${invocation.toolName} (callId: ${invocation.callId})
334
+ `
335
+ );
336
+ } catch {
337
+ }
338
+ }
312
339
  const executor = this.toolExecutors.get(invocation.toolName) ?? getCodexToolExecutor(invocation.toolName);
313
340
  if (!executor) {
314
341
  const message = `No Codex executor registered for tool '${invocation.toolName}'. Use codexTool() or provide a codexExecute handler.`;
315
- console.warn(message);
342
+ try {
343
+ process.stderr.write(`[codex-native] ${message}
344
+ `);
345
+ } catch {
346
+ }
316
347
  return {
317
348
  success: false,
318
349
  error: message,
@@ -357,7 +388,15 @@ var CodexModel = class {
357
388
  if (typeof result === "string") {
358
389
  return { success: true, output: result };
359
390
  }
360
- if (typeof result === "object" && ("output" in result || "error" in result || "success" in result)) {
391
+ const isNativeToolResultLike = (value) => {
392
+ if (!value || typeof value !== "object") return false;
393
+ if (!("output" in value) && !("error" in value) && !("success" in value)) return false;
394
+ if ("success" in value && value.success != null && typeof value.success !== "boolean") return false;
395
+ if ("output" in value && value.output != null && typeof value.output !== "string") return false;
396
+ if ("error" in value && value.error != null && typeof value.error !== "string") return false;
397
+ return true;
398
+ };
399
+ if (isNativeToolResultLike(result)) {
361
400
  return {
362
401
  success: result.success ?? !result.error,
363
402
  output: result.output,
@@ -2663,6 +2702,7 @@ export {
2663
2702
  formatFileList,
2664
2703
  formatStream,
2665
2704
  getCodexToolExecutor,
2705
+ getNativeBinding,
2666
2706
  gradeReverieRelevance,
2667
2707
  gradeReveriesInParallel,
2668
2708
  isValidReverieExcerpt,