@kodax-ai/kodax 0.7.50 → 0.7.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1814 -1773
- package/README.md +1215 -1213
- package/README_CN.md +636 -634
- package/dist/chunks/agent-XXTR7T37.js +2 -0
- package/dist/chunks/argument-completer-VMH6VZ4X.js +2 -0
- package/dist/chunks/chunk-4RVSFOUT.js +420 -0
- package/dist/chunks/chunk-5USNUSTL.js +648 -0
- package/dist/chunks/chunk-7X7SOVER.js +492 -0
- package/dist/chunks/{chunk-HR64F32V.js → chunk-BFXFSEHK.js} +1 -1
- package/dist/chunks/chunk-HMATTIU6.js +574 -0
- package/dist/chunks/{chunk-SK4HOYT2.js → chunk-JJTUBNQX.js} +1 -1
- package/dist/chunks/chunk-LE6STNVN.js +31 -0
- package/dist/chunks/chunk-MFPYZT52.js +301 -0
- package/dist/chunks/{compaction-config-DDJSQ4OT.js → compaction-config-UBPCNGC2.js} +1 -1
- package/dist/chunks/{construction-bootstrap-4QNM2BVM.js → construction-bootstrap-BXRMA3KL.js} +1 -1
- package/dist/chunks/dist-IHH4BYIU.js +2 -0
- package/dist/chunks/{dist-OJSNNI7P.js → dist-Z6U7TWKJ.js} +1 -1
- package/dist/chunks/utils-6WZHBMCC.js +2 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.js +4 -4
- package/dist/kodax_cli.js +1004 -978
- package/dist/provider-capabilities.json +2 -0
- package/dist/sdk-agent.d.ts +16 -10
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +32 -16
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +3 -5
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-repl.d.ts +16 -727
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-session.d.ts +8 -224
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{types.d-rPRl2LSB.d.ts → base.d-BBNUF9nz.d.ts} +271 -3
- package/dist/types-chunks/{bash-prefix-extractor.d-B0CIb0N3.d.ts → bash-prefix-extractor.d-DBFZEwop.d.ts} +15 -521
- package/dist/types-chunks/{capsule.d-CwBEm6M-.d.ts → capsule.d-CNonpwAZ.d.ts} +3 -3
- package/dist/types-chunks/guardrail.d-B18oO1gt.d.ts +518 -0
- package/dist/types-chunks/{process.d-BbiXD24v.d.ts → process.d-Bj82oJhD.d.ts} +348 -275
- package/dist/types-chunks/{resolver.d-CQfaJbht.d.ts → resolver.d-CCX9NXWP.d.ts} +2 -2
- package/dist/types-chunks/sdk-session-D4tqRl0_.d.ts +977 -0
- package/dist/types-chunks/{storage.d-J2GqOgaX.d.ts → storage.d-CabW10Nt.d.ts} +78 -3
- package/dist/types-chunks/types.d-D4jL-gAA.d.ts +273 -0
- package/dist/types-chunks/{utils.d-D_-jrRku.d.ts → utils.d-23Gn14zP.d.ts} +7 -81
- package/package.json +3 -3
- package/dist/chunks/argument-completer-3WX5B42G.js +0 -2
- package/dist/chunks/chunk-5UJQ2GKJ.js +0 -574
- package/dist/chunks/chunk-MFOMFMSK.js +0 -1056
- package/dist/chunks/chunk-UB5IAZHF.js +0 -476
- package/dist/chunks/chunk-XZY4CIDV.js +0 -31
- package/dist/chunks/chunk-YJLRBIEW.js +0 -301
- package/dist/chunks/dist-T256OSDI.js +0 -2
- package/dist/chunks/utils-JHIEOX6Z.js +0 -2
- package/dist/types-chunks/base.d-C4jYVjJh.d.ts +0 -270
- package/dist/types-chunks/types.d-BnjX2Gn4.d.ts +0 -297
package/dist/sdk-repl.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{$ as
|
|
3
|
-
`)[0]?.replace(/^#\s*/,"").trim()??"").slice(0,60)||"(prompt command)";n.set(f,{name:f,description:i,content:d,type:"prompt"})}catch{}continue}if(m===".js"||m===".ts")try{let g=await import(c.join(o,t));for(let[i,p]of Object.entries(g))if(i.startsWith("command_")&&typeof p=="function"){let s=i.replace("command_",""),C=p.description??s;n.set(s,{name:s,description:String(C).slice(0,60),content:`[Programmable command: ${s}]`,type:"programmable",execute:p})}}catch{}}}catch{}return n}a(K,"loadCommands");async function X(e,n,o,r){let t=o.get(e);return t?t.type==="prompt"?n?t.content.replace(/{args}/g,n):t.content:t.type==="programmable"&&t.execute?t.execute({args:n,runAgent:r}):null:null}a(X,"processCommandCall");function h(e){if(!e.startsWith("/"))return null;let n=e.slice(1).split(/\s+/,2);if(n.length===0)return null;let[o,r]=n;return o?[o,r]:null}a(h,"parseCommandCall");export{
|
|
2
|
+
import{$ as un,$a as fo,A as Q,Aa as $n,Ab as qo,B as T,Ba as qn,Bb as zo,C as U,Ca as zn,Cb as Bo,D as V,Da as Bn,Db as Eo,E as Y,Ea as En,Eb as Go,F as Z,Fa as Gn,Fb as Ho,G as tt,Ga as Hn,Gb as Jo,H as nt,Ha as Jn,Hb as Qo,I as ot,Ia as Qn,Ib as To,J as et,Ja as Tn,Jb as Uo,K as rt,Ka as Un,Kb as Vo,L as at,La as Vn,Lb as Yo,M as pt,Ma as Yn,Mb as Zo,N as lt,Na as Zn,Nb as te,O as ut,Oa as to,Ob as ne,P as ft,Pa as no,Pb as oe,Q as nn,Qa as oo,Qb as ee,R as on,Ra as eo,Rb as re,S as en,Sa as ro,Sb as ae,T as rn,Ta as ao,Tb as me,U as an,Ua as mo,V as mn,Va as io,W as sn,Wa as so,X as cn,Xa as co,Y as dn,Ya as po,Z as pn,Za as lo,_ as ln,_a as uo,a as D,aa as fn,ab as go,b as P,ba as gn,bb as Co,c as M,ca as Cn,cb as xo,d as w,da as xn,db as yo,e as N,ea as yn,eb as Ko,f as _,fa as Kn,fb as Xo,g as b,ga as Xn,gb as ho,h as j,ha as hn,hb as Do,i as k,ia as Dn,ib as Po,j as A,ja as Pn,jb as Mo,k as O,ka as Mn,kb as wo,l as R,la as wn,lb as No,m as S,ma as Nn,mb as _o,n as v,na as _n,nb as bo,o as I,oa as bn,ob as jo,p as L,pa as jn,pb as ko,q as W,qa as kn,qb as Ao,r as F,ra as An,rb as Oo,s as $,sa as On,sb as Ro,t as q,ta as Rn,tb as So,u as z,ua as Sn,ub as vo,v as B,va as vn,vb as Io,w as E,wa as In,wb as Lo,x as G,xa as Ln,xb as Wo,y as H,ya as Wn,yb as Fo,z as J,za as Fn,zb as $o}from"./chunks/chunk-MFPYZT52.js";import{I as Gt,J as Ht,K as Jt,L as Qt,M as Tt,R as Ut,S as Vt,a as mt,b as it,c as st,d as ct,e as dt,f as gt,h as Ct,k as xt,l as yt,m as Kt,n as It,p as Lt,pa as Yt,q as Wt,qa as Zt,r as Ft,ra as tn,s as $t,u as qt,v as zt,w as Bt,x as Et}from"./chunks/chunk-7X7SOVER.js";import{D as vt,b as Xt,c as ht,d as Dt,e as Pt,f as Mt,h as wt,i as Nt,j as _t,k as bt,u as jt,v as kt,w as At,x as Ot,y as Rt,z as St}from"./chunks/chunk-BFXFSEHK.js";import"./chunks/chunk-JJTUBNQX.js";import"./chunks/chunk-EVIDQWMF.js";import"./chunks/chunk-4RVSFOUT.js";import"./chunks/chunk-5USNUSTL.js";import"./chunks/chunk-LE6STNVN.js";import"./chunks/chunk-HMATTIU6.js";import{a}from"./chunks/chunk-V4WSBIXB.js";import l from"fs/promises";import c from"path";import x from"os";var u=c.join(x.homedir(),".kodax","commands");function y(){return u}a(y,"getDefaultCommandDir");async function K(e){let n=new Map,o=e??u;try{await l.mkdir(o,{recursive:!0});let r=await l.readdir(o);for(let t of r){let m=c.extname(t),f=t.replace(m,"");if(m===".md"){try{let d=await l.readFile(c.join(o,t),"utf-8"),i=(d.split(`
|
|
3
|
+
`)[0]?.replace(/^#\s*/,"").trim()??"").slice(0,60)||"(prompt command)";n.set(f,{name:f,description:i,content:d,type:"prompt"})}catch{}continue}if(m===".js"||m===".ts")try{let g=await import(c.join(o,t));for(let[i,p]of Object.entries(g))if(i.startsWith("command_")&&typeof p=="function"){let s=i.replace("command_",""),C=p.description??s;n.set(s,{name:s,description:String(C).slice(0,60),content:`[Programmable command: ${s}]`,type:"programmable",execute:p})}}catch{}}}catch{}return n}a(K,"loadCommands");async function X(e,n,o,r){let t=o.get(e);return t?t.type==="prompt"?n?t.content.replace(/{args}/g,n):t.content:t.type==="programmable"&&t.execute?t.execute({args:n,runAgent:r}):null:null}a(X,"processCommandCall");function h(e){if(!e.startsWith("/"))return null;let n=e.slice(1).split(/\s+/,2);if(n.length===0)return null;let[o,r]=n;return o?[o,r]:null}a(h,"parseCommandCall");export{Xn as App,nn as AutocompleteContextProvider,Yt as BUILTIN_COMMANDS,Gn as BackgroundTaskBar,Jn as ChildActivitySurface,So as ConsoleCapturer,dt as DEFAULT_UI_STATE,$n as DialogSurface,pn as DotsIndicator,Qo as FileSessionStorage,Dn as FullscreenTranscriptLayout,gn as HistoryItemRenderer,sn as InputPrompt,u as KODAX_COMMANDS_DIR,Dt as KODAX_CONFIG_FILE,Xt as KODAX_DIR,ht as KODAX_SESSIONS_DIR,_t as KODAX_VERSION,ft as KeyMatchers,ct as KeypressHandlerPriority,ot as KeypressParser,lt as KeypressProvider,L as LRUCache,fn as LoadingIndicator,io as MemorySessionStorage,Pn as MessageActions,Cn as MessageList,Mn as MessageSelector,zn as NotificationsSurface,gt as PERMISSION_MODES,Pt as PREVIEW_MAX_LENGTH,No as PendingInputsIndicator,ln as ProgressIndicator,Nn as PromptComposer,jn as PromptFooter,_n as PromptFooterLeftSide,bn as PromptFooterRightSide,kn as PromptHelpMenu,Fn as PromptSuggestionsSurface,qn as QueuedCommandsSurface,hn as SimpleApp,cn as SimpleInputPrompt,xn as SimpleMessageDisplay,Kn as SimpleStatusBar,tt as SingleLineTextInput,dn as Spinner,En as StashNotice,yn as StatusBar,Bn as StatusNoticesSurface,Tn as StreamingProvider,mt as StreamingState,Wn as SuggestionsDisplay,st as TOOL_STATUS_ICONS,an as TextBuffer,Z as TextInput,un as ThinkingIndicator,Mo as ToolCallDisplay,it as ToolCallStatus,wo as ToolGroup,Po as ToolProgressBar,Do as ToolStatusBadge,wn as TranscriptViewport,Sn as UIStateProvider,eo as _resetQueuedPromptsCacheForTests,ee as archiveSession,mo as bootstrapAutoMode,J as calculateVisualCursorFromLayout,H as calculateVisualLayout,zt as collectBashWriteTargets,xt as computeConfirmTools,Xo as createCliEvents,On as createHistoryItem,ro as createInteractiveContext,ho as createJsonEvents,to as createKeyMatcher,pt as createKeypressManager,so as createMemorySessionStorage,xo as createRecoveryHistoryItem,go as createRetryHistoryItem,me as createSessionManager,Qn as createStreamingManager,Rn as createToolCall,Q as darkTheme,oe as deleteSession,Ro as detectTerminalCapabilities,j as detectTerminalHostProfile,b as detectTerminalRenderHost,yo as emitRecoveryHistoryItem,Co as emitRetryHistoryItem,tn as executeCommand,co as executeShellCommand,Jt as extractHistorySeedsFromMessage,Qt as extractHistorySeedsFromMessages,Tt as extractTextContent,Ut as extractTitle,Yo as forkSession,Vt as formatMessagePreview,An as generateId,Ft as generateSavePattern,Bt as getBashOutsideProjectWriteRisk,q as getCharAtCodePoint,W as getCodePointLength,$o as getCustomProviderConfig,y as getDefaultCommandDir,St as getGitRoot,at as getKeyDisplayName,Eo as getMcpServerConfig,Et as getPlanModeBlockReason,jt as getProviderList,bt as getProviderModel,S as getTerminalHostCapabilities,Ao as getTerminalWidth,V as getTheme,Y as getThemeNames,Nt as getVersion,$ as getVisualWidth,G as getVisualWidthCached,P as hasCursorUpViewportYankRisk,w as hasMainScreenRenderScrollRisk,Mt as hydrateProcessEnvFromShell,$t as isAlwaysConfirmPath,It as isBashReadCommand,Lt as isBashWriteCommand,I as isClassicReplForced,et as isFunctionKey,v as isOwnedRendererPreferred,qt as isPathInsideProject,yt as isPermissionMode,rt as isPrintable,kt as isProviderConfigured,M as isRemoteConptyHost,Oo as isScreenReader,po as isShellCommand,lo as isShellCommandSuccess,N as isTmuxControlMode,Wt as isToolCallAllowed,D as isVsCodeTerminalHostEnv,F as isWideChar,Fo as listCustomProviders,Bo as listMcpServers,ne as listRunningSessions,To as listSessions,K as loadCommands,At as loadConfig,Vo as loadFullTranscript,Uo as loadSession,Hn as measureChildActivitySurfaceRows,T as minimalTheme,Kt as normalizePermissionMode,Zt as parseCommand,h as parseCommandCall,nt as parseKeypress,Ct as permissionModeDisplayName,Ot as prepareRuntimeConfig,X as processCommandCall,Wo as processSpecialSyntax,vt as rateLimitedCall,wt as registerConfiguredCustomProviders,zo as removeCustomProvider,Ho as removeMcpServer,_ as resetTmuxControlModeProbeForTesting,k as resolveConfiguredTuiRendererMode,A as resolveEffectiveTuiRendererMode,R as resolveFullscreenPolicy,O as resolveInteractiveSurfacePreference,fo as restoreHistoryItemsFromSession,Zo as rewindSession,Ko as runInkInteractiveMode,Lo as runInteractiveMode,Rt as saveConfig,Gt as seedToHistoryItem,te as setActiveEntry,z as splitByCodePoints,bo as supports256Colors,ko as supportsEmoji,_o as supportsTrueColor,jo as supportsUnicode,U as themes,Ht as toolCallSeedToHistoryToolCall,ao as touchContext,uo as trimPersistedUiHistorySnapshot,B as truncateByVisualWidth,re as unarchiveSession,qo as upsertCustomProvider,Go as upsertMcpServer,en as useAutocomplete,on as useAutocompleteContext,rn as useInputHistory,Zn as useKeypress,ut as useKeypressManager,oo as useQueuedPromptContents,no as useQueuedPrompts,Yn as useStreaming,Vn as useStreamingActions,Un as useStreamingState,mn as useTextBuffer,Ln as useUI,In as useUIActions,vn as useUIState,Jo as validateMcpServerConfig,E as visualWidthCache,ae as watchSessions,vo as withCapture,Io as withCaptureSync};
|
package/dist/sdk-session.d.ts
CHANGED
|
@@ -1,224 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import './types-chunks/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* NEVER throw — missing sessions return null, blocked operations return
|
|
10
|
-
* an error envelope, missing directories return empty arrays / no-op
|
|
11
|
-
* watchers.
|
|
12
|
-
*
|
|
13
|
-
* The `@kodax-ai/kodax/session` SDK subpath re-exports this module.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
interface SessionSummary {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly title: string;
|
|
19
|
-
readonly msgCount: number;
|
|
20
|
-
readonly tag?: string;
|
|
21
|
-
readonly createdAt?: string;
|
|
22
|
-
readonly runtimeInfo?: {
|
|
23
|
-
workspaceRoot?: string;
|
|
24
|
-
gitRoot?: string;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* FEATURE_219 (v0.7.46) — the per-project directory key this session lives
|
|
28
|
-
* under (ADR-038 §7). A backward-compatible hint: consumers may pass it back
|
|
29
|
-
* for precise disambiguation, but `loadSession(id)` works without it.
|
|
30
|
-
*/
|
|
31
|
-
readonly projectKey?: string;
|
|
32
|
-
/** FEATURE_219 — true when the session is whole-session archived (only ever
|
|
33
|
-
* surfaced when `includeArchived` is set). */
|
|
34
|
-
readonly archived?: boolean;
|
|
35
|
-
}
|
|
36
|
-
type SessionTranscriptEntryType = 'message' | 'compaction' | 'branch_summary';
|
|
37
|
-
interface SessionTranscriptEntry {
|
|
38
|
-
readonly entryId: string;
|
|
39
|
-
readonly parentId: string | null;
|
|
40
|
-
readonly timestamp: string;
|
|
41
|
-
readonly type: SessionTranscriptEntryType;
|
|
42
|
-
readonly message: KodaXMessage;
|
|
43
|
-
readonly active: boolean;
|
|
44
|
-
readonly summary?: string;
|
|
45
|
-
}
|
|
46
|
-
interface FullTranscriptSessionData extends Omit<SessionData, 'messages'> {
|
|
47
|
-
readonly messages: KodaXMessage[];
|
|
48
|
-
readonly activeMessages: KodaXMessage[];
|
|
49
|
-
readonly transcriptEntries: SessionTranscriptEntry[];
|
|
50
|
-
}
|
|
51
|
-
interface ListSessionsOptions {
|
|
52
|
-
/**
|
|
53
|
-
* Alias for gitRoot; backwards-compat with KodaX Space terminology.
|
|
54
|
-
* When provided, list() is scoped to sessions from this project root.
|
|
55
|
-
*/
|
|
56
|
-
readonly projectRoot?: string;
|
|
57
|
-
/**
|
|
58
|
-
* Which session scopes to include.
|
|
59
|
-
* - 'user' (default): only user-initiated sessions.
|
|
60
|
-
* - 'managed-task-worker': only managed-task worker sessions.
|
|
61
|
-
* - 'all': no scope filter.
|
|
62
|
-
*/
|
|
63
|
-
readonly scope?: 'user' | 'managed-task-worker' | 'all';
|
|
64
|
-
/**
|
|
65
|
-
* Whether to include whole-session-archived sessions. FEATURE_219 (v0.7.46):
|
|
66
|
-
* archived sessions live in `<projectKey>/archived/` (see `archiveSession`);
|
|
67
|
-
* also still hides the legacy `archived-` filename prefix. Default false.
|
|
68
|
-
*/
|
|
69
|
-
readonly includeArchived?: boolean;
|
|
70
|
-
/** Maximum number of sessions to return. Default 50. */
|
|
71
|
-
readonly limit?: number;
|
|
72
|
-
/**
|
|
73
|
-
* ISO date string — return only sessions whose createdAt is before this
|
|
74
|
-
* timestamp. Applied after list + scope filtering.
|
|
75
|
-
*/
|
|
76
|
-
readonly before?: string;
|
|
77
|
-
/** Exact match. Omitted means no tag filter. */
|
|
78
|
-
readonly tag?: string;
|
|
79
|
-
}
|
|
80
|
-
type WatchSessionsCallback = (event: {
|
|
81
|
-
kind: 'change' | 'add' | 'remove';
|
|
82
|
-
sessionId: string;
|
|
83
|
-
}) => void;
|
|
84
|
-
interface SessionManager {
|
|
85
|
-
listSessions: typeof listSessions;
|
|
86
|
-
loadSession: typeof loadSession;
|
|
87
|
-
loadFullTranscript: typeof loadFullTranscript;
|
|
88
|
-
forkSession: typeof forkSession;
|
|
89
|
-
rewindSession: typeof rewindSession;
|
|
90
|
-
setActiveEntry: typeof setActiveEntry;
|
|
91
|
-
deleteSession: typeof deleteSession;
|
|
92
|
-
archiveSession: typeof archiveSession;
|
|
93
|
-
unarchiveSession: typeof unarchiveSession;
|
|
94
|
-
listRunningSessions: typeof listRunningSessions;
|
|
95
|
-
watchSessions: typeof watchSessions;
|
|
96
|
-
/**
|
|
97
|
-
* v0.7.43 — the raw write-side storage instance. SDK embedders pass
|
|
98
|
-
* this into `runKodaX({ session: { id, scope, storage } })` so the
|
|
99
|
-
* SA / AMA loops write per-turn JSONL snapshots to disk. Without an
|
|
100
|
-
* injected storage, `saveSessionSnapshot` is a silent no-op and the
|
|
101
|
-
* sessions directory stays empty regardless of `session.id`.
|
|
102
|
-
*
|
|
103
|
-
* See {@link FileSessionStorage} for the concrete implementation and
|
|
104
|
-
* `docs/SDK_EMBEDDER_GUIDE.md` §6 for the end-to-end recipe.
|
|
105
|
-
*/
|
|
106
|
-
storage: FileSessionStorage;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* List sessions, optionally filtered by scope, limit, and date.
|
|
110
|
-
* NEVER throws. Returns [] when the sessions directory is empty or missing.
|
|
111
|
-
*/
|
|
112
|
-
declare function listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
113
|
-
/**
|
|
114
|
-
* Load full session data by ID.
|
|
115
|
-
* Returns null for a missing session. NEVER throws.
|
|
116
|
-
*/
|
|
117
|
-
declare function loadSession(id: string): Promise<SessionData | null>;
|
|
118
|
-
/**
|
|
119
|
-
* Load append-order transcript data by ID.
|
|
120
|
-
*
|
|
121
|
-
* `loadSession` remains the active model-context API. This helper is for UI
|
|
122
|
-
* scrollback: it returns every persisted transcript-bearing lineage entry in
|
|
123
|
-
* append order and keeps the active branch in `activeMessages`.
|
|
124
|
-
*/
|
|
125
|
-
declare function loadFullTranscript(id: string): Promise<FullTranscriptSessionData | null>;
|
|
126
|
-
/**
|
|
127
|
-
* Fork a session at an optional selector.
|
|
128
|
-
* Returns null for a missing session. NEVER throws.
|
|
129
|
-
*/
|
|
130
|
-
declare function forkSession(id: string, opts?: {
|
|
131
|
-
selector?: string;
|
|
132
|
-
sessionId?: string;
|
|
133
|
-
title?: string;
|
|
134
|
-
}): Promise<{
|
|
135
|
-
sessionId: string;
|
|
136
|
-
data: SessionData;
|
|
137
|
-
} | null>;
|
|
138
|
-
/**
|
|
139
|
-
* Rewind a session to a previous user entry.
|
|
140
|
-
* Returns null for a missing session. NEVER throws.
|
|
141
|
-
*/
|
|
142
|
-
declare function rewindSession(id: string, opts?: {
|
|
143
|
-
selector?: string;
|
|
144
|
-
}): Promise<SessionData | null>;
|
|
145
|
-
/**
|
|
146
|
-
* Set the active lineage entry by selector.
|
|
147
|
-
* Returns null for a missing session. NEVER throws.
|
|
148
|
-
*/
|
|
149
|
-
declare function setActiveEntry(id: string, selector: string): Promise<SessionData | null>;
|
|
150
|
-
interface RunningSessionInfo {
|
|
151
|
-
readonly pid: number;
|
|
152
|
-
readonly startedAt: number;
|
|
153
|
-
readonly cwd: string;
|
|
154
|
-
/**
|
|
155
|
-
* v0.7.43 — populated from `PersistedSessionState.sessionId`, published
|
|
156
|
-
* by the REPL after `createInteractiveContext`. Remains `undefined` for
|
|
157
|
-
* a brief window during a peer's bootstrap (before the first sessionId
|
|
158
|
-
* is generated) and for peers running pre-v0.7.43 binaries; consumers
|
|
159
|
-
* MUST handle `undefined`.
|
|
160
|
-
*/
|
|
161
|
-
readonly sessionId: string | undefined;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Returns live KodaX sibling instances (excluding this process).
|
|
165
|
-
* Uses discoverInstances() from @kodax-ai/agent (FEATURE_125 Team Mode).
|
|
166
|
-
* NEVER throws. Returns [] when no instances directory exists.
|
|
167
|
-
*/
|
|
168
|
-
declare function listRunningSessions(): Promise<RunningSessionInfo[]>;
|
|
169
|
-
type DeleteSessionResult = {
|
|
170
|
-
ok: true;
|
|
171
|
-
} | {
|
|
172
|
-
error: {
|
|
173
|
-
code: 'session_running';
|
|
174
|
-
runningProcess: {
|
|
175
|
-
pid: number;
|
|
176
|
-
startedAt: number;
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Delete a session by ID.
|
|
182
|
-
* Returns { ok: true } on success (including when the session doesn't exist).
|
|
183
|
-
* Returns an error envelope when the session is currently running.
|
|
184
|
-
* NEVER throws.
|
|
185
|
-
*/
|
|
186
|
-
declare function deleteSession(id: string): Promise<DeleteSessionResult>;
|
|
187
|
-
/**
|
|
188
|
-
* FEATURE_219 (v0.7.46) — whole-session archive. Moves the session (and its
|
|
189
|
-
* island sidecar) into `<projectKey>/archived/`. Returns false for a missing
|
|
190
|
-
* session. NEVER throws. Archived sessions are hidden from the default listing
|
|
191
|
-
* and resurface only with `listSessions({ includeArchived: true })`.
|
|
192
|
-
*/
|
|
193
|
-
declare function archiveSession(id: string): Promise<boolean>;
|
|
194
|
-
/** Restore an archived session back into its project directory. NEVER throws. */
|
|
195
|
-
declare function unarchiveSession(id: string): Promise<boolean>;
|
|
196
|
-
/**
|
|
197
|
-
* Watch the sessions directory for changes.
|
|
198
|
-
* Returns { close() } that stops the watcher / poll interval.
|
|
199
|
-
*
|
|
200
|
-
* Platform branches:
|
|
201
|
-
* - POSIX: fs.watch() with 100ms debounce.
|
|
202
|
-
* - Windows: readdir poll every 1000ms, diffed against a snapshot.
|
|
203
|
-
*
|
|
204
|
-
* NEVER throws — if the directory doesn't exist the watcher is a no-op
|
|
205
|
-
* until the directory is created.
|
|
206
|
-
*/
|
|
207
|
-
declare function watchSessions(cb: WatchSessionsCallback): {
|
|
208
|
-
close: () => void;
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* Factory that returns an object with all session management methods bound.
|
|
212
|
-
*
|
|
213
|
-
* v0.7.43 (FEATURE_173 Part B follow-up) — the `sessionsDir` override is
|
|
214
|
-
* now honored. When provided, all read/write/watch operations go through
|
|
215
|
-
* that directory instead of the module-load-frozen `KODAX_SESSIONS_DIR`.
|
|
216
|
-
* `listRunningSessions` still consults the agent-config-home instances
|
|
217
|
-
* directory (sibling-process awareness is not scoped per sessions dir).
|
|
218
|
-
*/
|
|
219
|
-
declare function createSessionManager(opts?: {
|
|
220
|
-
sessionsDir?: string;
|
|
221
|
-
}): SessionManager;
|
|
222
|
-
|
|
223
|
-
export { archiveSession, createSessionManager, deleteSession, forkSession, listRunningSessions, listSessions, loadFullTranscript, loadSession, rewindSession, setActiveEntry, unarchiveSession, watchSessions };
|
|
224
|
-
export type { DeleteSessionResult, FullTranscriptSessionData, ListSessionsOptions, RunningSessionInfo, SessionManager, SessionSummary, SessionTranscriptEntry, SessionTranscriptEntryType, WatchSessionsCallback };
|
|
1
|
+
export { c as CreatableHistoryItem, e as DeleteSessionResult, F as FullTranscriptSessionData, r as HistorySeedSourceMessage, v as ListSessionsOptions, R as RestoreHistoryItemsFromSessionInput, y as RestoredHistorySeed, z as RunningSessionInfo, S as SessionManager, B as SessionSummary, E as SessionTranscriptEntry, G as SessionTranscriptEntryType, a3 as WatchSessionsCallback, a4 as archiveSession, a5 as createSessionManager, a6 as deleteSession, a7 as extractHistorySeedsFromMessage, a8 as extractHistorySeedsFromMessages, ab as forkSession, ad as listRunningSessions, ae as listSessions, af as loadFullTranscript, ag as loadSession, ah as restoreHistoryItemsFromSession, ai as rewindSession, ak as setActiveEntry, an as unarchiveSession, ao as watchSessions } from './types-chunks/sdk-session-D4tqRl0_.js';
|
|
2
|
+
export { ac as KodaXSessionUiHistoryItem, ad as KodaXSessionUiHistoryItemType, ae as KodaXSessionUiTextHistoryItem, af as KodaXSessionUiTextHistoryItemType, ag as KodaXSessionUiToolCall, ah as KodaXSessionUiToolCallStatus, ai as KodaXSessionUiToolGroupHistoryItem } from './types-chunks/process.d-Bj82oJhD.js';
|
|
3
|
+
import './types-chunks/storage.d-CabW10Nt.js';
|
|
4
|
+
import './types-chunks/bash-prefix-extractor.d-DBFZEwop.js';
|
|
5
|
+
import './types-chunks/base.d-BBNUF9nz.js';
|
|
6
|
+
import 'vscode-languageserver-protocol';
|
|
7
|
+
import './types-chunks/capability.d-3C62G8Eq.js';
|
|
8
|
+
import './types-chunks/cost-tracker.d-wRtyEW9d.js';
|
package/dist/sdk-session.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{Lb as
|
|
2
|
+
import{$a as o,Ib as i,Jb as t,Kb as r,Lb as n,Mb as a,Nb as S,Ob as l,Pb as y,Qb as d,Rb as m,Sb as p,Tb as c}from"./chunks/chunk-MFPYZT52.js";import{K as s,L as e}from"./chunks/chunk-7X7SOVER.js";import"./chunks/chunk-BFXFSEHK.js";import"./chunks/chunk-JJTUBNQX.js";import"./chunks/chunk-EVIDQWMF.js";import"./chunks/chunk-4RVSFOUT.js";import"./chunks/chunk-5USNUSTL.js";import"./chunks/chunk-LE6STNVN.js";import"./chunks/chunk-HMATTIU6.js";import"./chunks/chunk-V4WSBIXB.js";export{d as archiveSession,c as createSessionManager,y as deleteSession,s as extractHistorySeedsFromMessage,e as extractHistorySeedsFromMessages,n as forkSession,l as listRunningSessions,i as listSessions,r as loadFullTranscript,t as loadSession,o as restoreHistoryItemsFromSession,a as rewindSession,S as setActiveEntry,m as unarchiveSession,p as watchSessions};
|
package/dist/sdk-skills.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{$b as t,Yb as l,Zb as e,_b as i,ac as a,bc as o,fc as k,gc as r,hc as S,ic as s,jc as n,kc as g,lc as u,mc as c,nc as x,oc as d,pc as P,qc as R,rc as h,sc as p,tc as v,uc as y,vc as M,wc as f,xc as m,yc as E}from"./chunks/chunk-
|
|
2
|
+
import{$b as t,Yb as l,Zb as e,_b as i,ac as a,bc as o,fc as k,gc as r,hc as S,ic as s,jc as n,kc as g,lc as u,mc as c,nc as x,oc as d,pc as P,qc as R,rc as h,sc as p,tc as v,uc as y,vc as M,wc as f,xc as m,yc as E}from"./chunks/chunk-HMATTIU6.js";import"./chunks/chunk-V4WSBIXB.js";export{y as SkillExecutor,R as SkillRegistry,x as VariableResolver,t as clearPluginSkillPaths,M as createExecutor,d as createResolver,n as discoverSkills,u as discoverSkillsWithMonorepo,f as executeSkill,m as expandSkillForLLM,E as formatSkillActivationMessage,a as getDefaultSkillPaths,g as getNestedSkillPaths,o as getSkillPathsFlat,h as getSkillRegistry,p as initializeSkillRegistry,i as listPluginSkillPaths,S as loadFullSkill,s as loadSkillFileContent,r as loadSkillMetadata,c as parseArguments,k as parseSkillMarkdown,l as registerPluginSkillPath,v as resetSkillRegistry,P as resolveSkillContent,e as unregisterPluginSkillPath};
|
|
@@ -119,7 +119,7 @@ interface KodaXToolDefinition {
|
|
|
119
119
|
required?: string[];
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
type KodaXReasoningCapability = 'native-effort' | 'native-budget' | 'native-toggle' | 'none' | 'prompt-only' | 'unknown';
|
|
122
|
+
type KodaXReasoningCapability = 'native-effort' | 'native-budget' | 'native-toggle' | 'native-adaptive' | 'none' | 'prompt-only' | 'unknown';
|
|
123
123
|
type KodaXProviderTransport = 'native-api' | 'cli-bridge';
|
|
124
124
|
type KodaXProviderConversationSemantics = 'full-history' | 'last-user-message';
|
|
125
125
|
type KodaXProviderMcpSupport = 'native' | 'none';
|
|
@@ -140,7 +140,7 @@ interface KodaXProviderCapabilityProfile {
|
|
|
140
140
|
multimodalSupport?: KodaXProviderMultimodalSupport;
|
|
141
141
|
evidenceSupport?: KodaXProviderEvidenceSupport;
|
|
142
142
|
}
|
|
143
|
-
type KodaXReasoningOverride = 'budget' | 'effort' | 'toggle' | 'none';
|
|
143
|
+
type KodaXReasoningOverride = 'budget' | 'effort' | 'toggle' | 'adaptive' | 'none';
|
|
144
144
|
type KodaXReasoningMode = 'off' | 'auto' | 'quick' | 'balanced' | 'deep';
|
|
145
145
|
type KodaXThinkingDepth = 'off' | 'low' | 'medium' | 'high';
|
|
146
146
|
type KodaXTaskType = 'conversation' | 'lookup' | 'review' | 'bugfix' | 'edit' | 'refactor' | 'plan' | 'qa' | 'unknown';
|
|
@@ -482,4 +482,272 @@ interface KodaXProviderStreamOptions {
|
|
|
482
482
|
signal?: AbortSignal;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
|
|
485
|
+
/**
|
|
486
|
+
* Retry-After header parsing — FEATURE_130 (v0.7.36).
|
|
487
|
+
*
|
|
488
|
+
* Handles the four forms KodaX's 12 provider adapters encounter when a
|
|
489
|
+
* model returns 429 (rate limit) or 503/529 (overloaded):
|
|
490
|
+
*
|
|
491
|
+
* 1. `Retry-After: 120` — integer seconds (HTTP 7231 standard)
|
|
492
|
+
* 2. `Retry-After: <HTTP-date>` — RFC 7231 IMF-fixdate
|
|
493
|
+
* e.g. "Wed, 21 Oct 2026 07:28:00 GMT"
|
|
494
|
+
* 3. `retry-after-ms: 45000` — Anthropic millisecond extension
|
|
495
|
+
* 4. (no Retry-After header present) — falls back to exponential backoff
|
|
496
|
+
* capped at `maxBackoffMs`, with optional jitter for the
|
|
497
|
+
* "thundering herd" protection.
|
|
498
|
+
*
|
|
499
|
+
* All return values are normalized to whole milliseconds and clamped to
|
|
500
|
+
* a sensible upper bound — never block the user for more than 120s, and
|
|
501
|
+
* never honor a header advertising a wait longer than `maxHeaderWaitMs`
|
|
502
|
+
* (default 120s). Beyond that limit we still extract the header but cap
|
|
503
|
+
* it; the calling provider can check `cappedFromHeader` to decide
|
|
504
|
+
* whether to surface a "rate limit exceeded — please wait" error to the
|
|
505
|
+
* user instead of silently sleeping for two minutes.
|
|
506
|
+
*
|
|
507
|
+
* Pattern-B (FEATURE_119) interaction: the helper is referentially
|
|
508
|
+
* transparent and stateless — it can be invoked concurrently by N
|
|
509
|
+
* parallel children without coordination. The retry loop in each
|
|
510
|
+
* provider holds its own attempt counter; this helper only translates
|
|
511
|
+
* headers/attempts into wait durations.
|
|
512
|
+
*
|
|
513
|
+
* Reference: opencode session/retry.ts:14-123 (4-form coverage).
|
|
514
|
+
*/
|
|
515
|
+
type RetryAfterSource = 'retry-after-seconds' | 'retry-after-date' | 'retry-after-ms' | 'exponential-backoff';
|
|
516
|
+
type RetryAfterResult = {
|
|
517
|
+
readonly type: 'header';
|
|
518
|
+
readonly waitMs: number;
|
|
519
|
+
readonly source: 'retry-after-seconds' | 'retry-after-date' | 'retry-after-ms';
|
|
520
|
+
/** True when the header value exceeded `maxHeaderWaitMs` and was clamped. */
|
|
521
|
+
readonly cappedFromHeader: boolean;
|
|
522
|
+
} | {
|
|
523
|
+
readonly type: 'backoff';
|
|
524
|
+
readonly waitMs: number;
|
|
525
|
+
readonly source: 'exponential-backoff';
|
|
526
|
+
readonly attempt: number;
|
|
527
|
+
};
|
|
528
|
+
interface ParseRetryAfterOptions {
|
|
529
|
+
/** Zero-based attempt index used by the backoff branch (0 = first retry). */
|
|
530
|
+
readonly attempt: number;
|
|
531
|
+
/** Base delay for exponential backoff. Default 1000ms. */
|
|
532
|
+
readonly baseBackoffMs?: number;
|
|
533
|
+
/** Maximum exponential backoff cap. Default 30000ms. */
|
|
534
|
+
readonly maxBackoffMs?: number;
|
|
535
|
+
/** Maximum wait honored from a header. Default 120000ms. */
|
|
536
|
+
readonly maxHeaderWaitMs?: number;
|
|
537
|
+
/**
|
|
538
|
+
* Override the "now" reference used by the HTTP-date branch.
|
|
539
|
+
* Test-only escape hatch — production code should leave this undefined.
|
|
540
|
+
*/
|
|
541
|
+
readonly now?: () => number;
|
|
542
|
+
/**
|
|
543
|
+
* Whether the backoff branch adds 0-25% jitter on top of the base
|
|
544
|
+
* exponential. Default true (matches the legacy `withRateLimit`
|
|
545
|
+
* jitter contract). Tests can pass `false` for deterministic output.
|
|
546
|
+
*/
|
|
547
|
+
readonly withJitter?: boolean;
|
|
548
|
+
}
|
|
549
|
+
type HeadersLike = Headers | Record<string, string | string[] | undefined> | undefined;
|
|
550
|
+
/**
|
|
551
|
+
* Parse rate-limit/overload retry-after headers (4 forms) and decide
|
|
552
|
+
* how long the caller should sleep before retrying. Returns either:
|
|
553
|
+
*
|
|
554
|
+
* - `{type: 'header', ...}` when one of the supported headers was found
|
|
555
|
+
* and converted into a wait duration; OR
|
|
556
|
+
* - `{type: 'backoff', ...}` falling back to exponential backoff for
|
|
557
|
+
* the given `attempt` index when no header is present.
|
|
558
|
+
*/
|
|
559
|
+
declare function parseRetryAfter(headers: HeadersLike, options: ParseRetryAfterOptions): RetryAfterResult;
|
|
560
|
+
/**
|
|
561
|
+
* Pull headers off a thrown error in the various shapes produced across
|
|
562
|
+
* provider SDKs (Anthropic, OpenAI, fetch-based custom providers).
|
|
563
|
+
* Returns `undefined` when no headers can be located — the helper then
|
|
564
|
+
* falls through to exponential backoff.
|
|
565
|
+
*/
|
|
566
|
+
declare function extractHeadersFromError(error: unknown): HeadersLike;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* KodaX Base Provider
|
|
570
|
+
*
|
|
571
|
+
* Provider 抽象基类 - 所有 Provider 的公共基础
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* FEATURE_130 (v0.7.36): structured payload fired through
|
|
576
|
+
* `KodaXEvents.onRetryAfter` whenever a provider's `withRateLimit`
|
|
577
|
+
* loop catches a 429 / 503 / 529 response and decides to wait. The
|
|
578
|
+
* `source` field carries which retry-after header form (or fallback)
|
|
579
|
+
* produced the wait duration so UI surfaces can show "provider asked
|
|
580
|
+
* us to wait 45s" vs "no header, exp-backoff guess of 4s".
|
|
581
|
+
*/
|
|
582
|
+
interface KodaXRetryAfterEvent {
|
|
583
|
+
readonly provider: string;
|
|
584
|
+
readonly waitMs: number;
|
|
585
|
+
readonly reason: 'rate-limit' | 'overloaded';
|
|
586
|
+
readonly source: RetryAfterSource;
|
|
587
|
+
readonly attempt: number;
|
|
588
|
+
readonly maxAttempts: number;
|
|
589
|
+
}
|
|
590
|
+
type KodaXOnRetryAfterCallback = (event: KodaXRetryAfterEvent) => void;
|
|
591
|
+
declare abstract class KodaXBaseProvider {
|
|
592
|
+
abstract readonly name: string;
|
|
593
|
+
abstract readonly supportsThinking: boolean;
|
|
594
|
+
protected abstract readonly config: KodaXProviderConfig;
|
|
595
|
+
/**
|
|
596
|
+
* Per-request override for `max_tokens` in the next provider call. Consumed
|
|
597
|
+
* once and cleared in `withRateLimit` after the next successful response.
|
|
598
|
+
* Two callers set this:
|
|
599
|
+
* 1. Context-overflow recovery inside `withRateLimit` (reduces budget
|
|
600
|
+
* when the model reports "prompt too long").
|
|
601
|
+
* 2. The agent loop's max_tokens escalation path, which flips this to
|
|
602
|
+
* `KODAX_ESCALATED_MAX_OUTPUT_TOKENS` when a capped-budget turn
|
|
603
|
+
* returns `stop_reason: max_tokens`. See `coding/src/agent.ts`.
|
|
604
|
+
*/
|
|
605
|
+
protected maxOutputTokensOverride?: number;
|
|
606
|
+
/**
|
|
607
|
+
* Public setter for the one-shot override above. Callers outside the
|
|
608
|
+
* provider package (notably the agent loop's escalation branch) use this
|
|
609
|
+
* to stage a larger budget for the next stream call in the same logical
|
|
610
|
+
* turn. Pass `undefined` to clear a stale override explicitly.
|
|
611
|
+
*/
|
|
612
|
+
setMaxOutputTokensOverride(value: number | undefined): void;
|
|
613
|
+
/**
|
|
614
|
+
* Returns the max_tokens value the provider will currently use on its
|
|
615
|
+
* next request. Precedence (highest to lowest):
|
|
616
|
+
* 1. One-shot override (agent escalation, context-overflow recovery)
|
|
617
|
+
* 2. User env var `KODAX_MAX_OUTPUT_TOKENS` (explicit user intent)
|
|
618
|
+
* 3. Active model descriptor's `maxOutputTokens` (FEATURE_098)
|
|
619
|
+
* 4. Provider config default
|
|
620
|
+
* 5. Global `KODAX_MAX_TOKENS` fallback
|
|
621
|
+
* Used by provider stream() paths and by the agent loop to decide
|
|
622
|
+
* whether escalation is applicable (see `coding/src/agent.ts`).
|
|
623
|
+
*/
|
|
624
|
+
getEffectiveMaxOutputTokens(model?: string): number;
|
|
625
|
+
/**
|
|
626
|
+
* Hard cap on a single streaming request's wall-clock duration (ms).
|
|
627
|
+
* Returns undefined when no cap is configured. Consumed by the
|
|
628
|
+
* resilience layer to abort a doomed stream before the server-side
|
|
629
|
+
* kill window fires; routed through `non_streaming_fallback`.
|
|
630
|
+
*
|
|
631
|
+
* Cascade (highest to lowest):
|
|
632
|
+
* 1. Active model descriptor's `streamMaxDurationMs`
|
|
633
|
+
* 2. Provider config default
|
|
634
|
+
* 3. undefined (watchdog disabled)
|
|
635
|
+
*/
|
|
636
|
+
getStreamMaxDurationMs(model?: string): number | undefined;
|
|
637
|
+
/**
|
|
638
|
+
* Resolves whether OpenAI-compat `reasoning_content` should echo back
|
|
639
|
+
* on replayed assistant messages for the given model. Same cascade as
|
|
640
|
+
* `getStreamMaxDurationMs`. Defaults to false when neither layer sets it.
|
|
641
|
+
*/
|
|
642
|
+
getEffectiveReplayReasoningContent(model?: string): boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Resolves whether Anthropic-style thinking signatures must verify
|
|
645
|
+
* strictly (Anthropic proper only). Same cascade as
|
|
646
|
+
* `getStreamMaxDurationMs`. Defaults to false (lenient) when neither
|
|
647
|
+
* layer sets it — matches third-party Anthropic-compat behavior.
|
|
648
|
+
*/
|
|
649
|
+
getEffectiveStrictThinkingSignature(model?: string): boolean;
|
|
650
|
+
abstract stream(messages: KodaXMessage[], tools: KodaXToolDefinition[], system: string, reasoning?: boolean | KodaXReasoningRequest, streamOptions?: KodaXProviderStreamOptions, signal?: AbortSignal): Promise<KodaXStreamResult>;
|
|
651
|
+
supportsNonStreamingFallback(): boolean;
|
|
652
|
+
complete(_messages: KodaXMessage[], _tools: KodaXToolDefinition[], _system: string, _reasoning?: boolean | KodaXReasoningRequest, _streamOptions?: KodaXProviderStreamOptions, _signal?: AbortSignal): Promise<KodaXStreamResult>;
|
|
653
|
+
isConfigured(): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* FEATURE_216 v0.7.45 — Lightweight credential verification. Returns
|
|
656
|
+
* a never-throws envelope with `ok` + categorized `error`. Concrete
|
|
657
|
+
* compat base classes (`KodaXAnthropicCompatProvider`,
|
|
658
|
+
* `KodaXOpenAICompatProvider`) override this to dispatch by the
|
|
659
|
+
* `verifyStrategy` field. The default here returns `unsupported` so
|
|
660
|
+
* Provider classes that don't extend a compat base — or future ones
|
|
661
|
+
* yet to be wired — fail safely instead of throwing.
|
|
662
|
+
*
|
|
663
|
+
* Distinct from `isConfigured()`: that one is env-only (no network);
|
|
664
|
+
* this one hits the wire (zero or ~7 tokens depending on strategy)
|
|
665
|
+
* and verifies the key is actually accepted by the upstream.
|
|
666
|
+
*/
|
|
667
|
+
verifyCredential(_opts?: {
|
|
668
|
+
timeoutMs?: number;
|
|
669
|
+
signal?: AbortSignal;
|
|
670
|
+
}): Promise<KodaXVerifyCredentialResult>;
|
|
671
|
+
getModel(): string;
|
|
672
|
+
getAvailableModels(): string[];
|
|
673
|
+
getModelDescriptor(modelId?: string): KodaXModelDescriptor | undefined;
|
|
674
|
+
getBaseUrl(): string | undefined;
|
|
675
|
+
getApiKeyEnv(): string;
|
|
676
|
+
getCapabilityProfile(): KodaXProviderCapabilityProfile;
|
|
677
|
+
getConfiguredReasoningCapability(modelOverride?: string): KodaXReasoningCapability;
|
|
678
|
+
getReasoningCapability(modelOverride?: string): KodaXReasoningCapability;
|
|
679
|
+
getReasoningOverride(modelOverride?: string): KodaXReasoningOverride | undefined;
|
|
680
|
+
getReasoningOverrideKey(modelOverride?: string): string;
|
|
681
|
+
protected persistReasoningCapabilityOverride(capability: KodaXReasoningCapability, modelOverride?: string): void;
|
|
682
|
+
protected shouldFallbackForReasoningError(error: unknown, ...terms: string[]): boolean;
|
|
683
|
+
protected shouldFallbackForSpecificReasoningError(error: unknown, ...terms: string[]): boolean;
|
|
684
|
+
protected shouldFallbackForForcedToolChoiceError(error: unknown): boolean;
|
|
685
|
+
protected isServerError(error: unknown): boolean;
|
|
686
|
+
protected getReasoningFallbackChain(capability: KodaXReasoningCapability): KodaXReasoningCapability[];
|
|
687
|
+
/**
|
|
688
|
+
* 获取模型的上下文窗口大小
|
|
689
|
+
*
|
|
690
|
+
* Backwards-compatible no-arg form: resolves against the provider's
|
|
691
|
+
* default model descriptor. New call sites that know the active
|
|
692
|
+
* model should use `getEffectiveContextWindow(model)` directly.
|
|
693
|
+
* @returns 上下文窗口大小 (tokens)
|
|
694
|
+
*/
|
|
695
|
+
getContextWindow(): number;
|
|
696
|
+
/**
|
|
697
|
+
* Resolves the context window for a specific model.
|
|
698
|
+
* Precedence (highest to lowest):
|
|
699
|
+
* 1. Active model descriptor's `contextWindow` (FEATURE_098)
|
|
700
|
+
* 2. Provider config default
|
|
701
|
+
* 3. 200_000 fallback
|
|
702
|
+
* The user-level `compaction.contextWindow` is layered on top of
|
|
703
|
+
* this at the call site, so it remains the highest-priority manual
|
|
704
|
+
* override.
|
|
705
|
+
*/
|
|
706
|
+
getEffectiveContextWindow(model?: string): number;
|
|
707
|
+
protected getApiKey(): string;
|
|
708
|
+
protected shouldLogStreamDiagnostics(): boolean;
|
|
709
|
+
protected logStreamDiagnostic(...args: unknown[]): void;
|
|
710
|
+
protected normalizeReasoning(reasoning?: boolean | KodaXReasoningRequest): Required<KodaXReasoningRequest>;
|
|
711
|
+
/**
|
|
712
|
+
* Called when ECONNRESET/EPIPE is detected, indicating a stale keep-alive
|
|
713
|
+
* socket. Subclasses should override to rebuild their HTTP client with a
|
|
714
|
+
* fresh connection pool so the next retry uses a new TCP connection.
|
|
715
|
+
*/
|
|
716
|
+
protected onStaleConnection(): void;
|
|
717
|
+
protected isRateLimitError(error: unknown): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* FEATURE_130: classify a rate-limit error as either a 429-style
|
|
720
|
+
* "rate-limit" or a 503/529-style "overloaded" condition. The
|
|
721
|
+
* distinction matters for UI: "rate-limit" usually surfaces a
|
|
722
|
+
* provider-supplied retry-after window; "overloaded" tends to fall
|
|
723
|
+
* through to exponential backoff with no header. Both flow through
|
|
724
|
+
* the same retry path; this only labels the event.
|
|
725
|
+
*/
|
|
726
|
+
protected classifyRateLimitReason(error: unknown): 'rate-limit' | 'overloaded';
|
|
727
|
+
/**
|
|
728
|
+
* Extract Retry-After delay from error headers (429/529 responses).
|
|
729
|
+
* Returns milliseconds, or undefined when no usable header is present.
|
|
730
|
+
*
|
|
731
|
+
* FEATURE_130 (v0.7.36): now delegates to the shared `parseRetryAfter`
|
|
732
|
+
* helper so all 12 provider adapters get 4-form coverage without each
|
|
733
|
+
* adapter rolling its own parser. The 4 forms supported are:
|
|
734
|
+
* - `Retry-After: <integer-seconds>`
|
|
735
|
+
* - `Retry-After: <HTTP-date>`
|
|
736
|
+
* - `retry-after-ms: <milliseconds>` (Anthropic extension)
|
|
737
|
+
* - exponential-backoff fallback (returned via `withRateLimit`,
|
|
738
|
+
* not through this helper — it is `undefined` here when no
|
|
739
|
+
* header is present, which the caller then resolves to backoff)
|
|
740
|
+
*/
|
|
741
|
+
protected extractRetryAfterMs(error: unknown): number | undefined;
|
|
742
|
+
/**
|
|
743
|
+
* Detect "prompt too long / context window exceeded" errors and compute
|
|
744
|
+
* a reduced max_tokens for retry. Returns undefined if not a context
|
|
745
|
+
* overflow error.
|
|
746
|
+
*/
|
|
747
|
+
protected parseContextOverflow(error: unknown): number | undefined;
|
|
748
|
+
protected isContextOverflowError(error: unknown): boolean;
|
|
749
|
+
protected withRateLimit<T>(fn: () => Promise<T>, signal?: AbortSignal, retries?: number, onRateLimit?: (attempt: number, maxRetries: number, delayMs: number) => void, onRetryAfter?: KodaXOnRetryAfterCallback): Promise<T>;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export { extractHeadersFromError as aa, parseRetryAfter as ab, KodaXBaseProvider as f };
|
|
753
|
+
export type { KodaXToolDefinition as $, KodaXProviderMultimodalSupport as A, KodaXProviderSessionSupport as B, KodaXProviderStreamOptions as C, KodaXProviderToolCallingFidelity as D, KodaXProviderTransport as E, KodaXReasoningCapability as F, KodaXReasoningMode as G, KodaXReasoningOverride as H, KodaXReasoningRequest as I, KodaXRedactedThinkingBlock as J, KodaXAmaControllerDecision as K, KodaXRetryAfterEvent as L, KodaXReviewScale as M, KodaXRiskLevel as N, KodaXStreamResult as O, KodaXTaskActionability as P, KodaXTaskBudgetOverrides as Q, KodaXTaskComplexity as R, KodaXTaskFamily as S, KodaXTaskRoutingDecision as T, KodaXTaskType as U, KodaXTaskWorkIntent as V, KodaXTextBlock as W, KodaXThinkingBlock as X, KodaXThinkingBudgetMap as Y, KodaXThinkingDepth as Z, KodaXTokenUsage as _, KodaXAmaFanoutClass as a, KodaXToolResultBlock as a0, KodaXToolResultContentItem as a1, KodaXToolResultImageItem as a2, KodaXToolResultTextItem as a3, KodaXToolUseBlock as a4, KodaXVerifyCredentialResult as a5, KodaXVerifyStrategy as a6, ParseRetryAfterOptions as a7, RetryAfterResult as a8, RetryAfterSource as a9, KodaXAmaFanoutPolicy as b, KodaXAmaProfile as c, KodaXAmaTactic as d, KodaXAssuranceIntent as e, KodaXCacheBoundary as g, KodaXContentBlock as h, KodaXCustomProviderConfig as i, KodaXExecutionMode as j, KodaXExecutionPattern as k, KodaXHarnessProfile as l, KodaXImageBlock as m, KodaXListModelsResult as n, KodaXMessage as o, KodaXModelDescriptor as p, KodaXMutationSurface as q, KodaXOnRetryAfterCallback as r, KodaXProtocolFamily as s, KodaXProviderCapabilityProfile as t, KodaXProviderConfig as u, KodaXProviderContextFidelity as v, KodaXProviderConversationSemantics as w, KodaXProviderEvidenceSupport as x, KodaXProviderLongRunningSupport as y, KodaXProviderMcpSupport as z };
|