@kodax-ai/kodax 0.7.41 → 0.7.43
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 +119 -3
- package/README.md +214 -286
- package/README_CN.md +173 -277
- package/dist/chunks/chunk-7G5PSL6C.js +830 -0
- package/dist/chunks/{chunk-6OB4AJOM.js → chunk-IYSK7LUK.js} +1 -1
- package/dist/chunks/chunk-K75O2CAE.js +31 -0
- package/dist/chunks/chunk-UG4262JI.js +502 -0
- package/dist/chunks/chunk-VHKAJDQD.js +425 -0
- package/dist/chunks/chunk-YMRZBS4G.js +2 -0
- package/dist/chunks/{compaction-config-LT5PEXPT.js → compaction-config-3E57ABCT.js} +1 -1
- package/dist/chunks/{construction-bootstrap-HBCWJFHC.js → construction-bootstrap-JR63KI5N.js} +4 -4
- package/dist/chunks/dist-KWHUKXEL.js +2 -0
- package/dist/chunks/dist-XANXEVTU.js +2 -0
- package/dist/chunks/utils-HQ2QCKJA.js +2 -0
- package/dist/index.d.ts +15 -10
- package/dist/index.js +5 -5
- package/dist/kodax_cli.js +1084 -1054
- package/dist/sdk-agent.d.ts +853 -135
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +932 -981
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +8 -5
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +17 -0
- package/dist/sdk-mcp.js +2 -0
- package/dist/sdk-repl.d.ts +343 -10
- package/dist/sdk-repl.js +2 -1
- package/dist/sdk-session.d.ts +176 -0
- package/dist/sdk-session.js +2 -0
- package/dist/sdk-skills.d.ts +72 -4
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{cost-tracker.d-C4dMlQuV.d.ts → base.d-FUJahC0i.d.ts} +22 -112
- package/dist/types-chunks/{bash-prefix-extractor.d-B2iliwdi.d.ts → bash-prefix-extractor.d-DMrGImMl.d.ts} +266 -228
- package/dist/types-chunks/capability.d-3C62G8Eq.d.ts +39 -0
- package/dist/types-chunks/config.d-BfJUXxC0.d.ts +41 -0
- package/dist/types-chunks/cost-tracker.d-wRtyEW9d.d.ts +110 -0
- package/dist/types-chunks/{history-cleanup.d-q1vAvCss.d.ts → file-tracker.d-zaLZeNBK.d.ts} +532 -15
- package/dist/types-chunks/manager.d-87belpiS.d.ts +370 -0
- package/dist/types-chunks/{resolver.d-BwD6TKz7.d.ts → resolver.d-CA68_NeH.d.ts} +150 -5
- package/dist/types-chunks/storage.d-DPAEX7zS.d.ts +115 -0
- package/dist/types-chunks/{capability.d-BxNgd1-c.d.ts → types.d-B1uGoVTE.d.ts} +72 -40
- package/dist/types-chunks/{instance-discovery.d-DZhp77vb.d.ts → types.d-CKJtjo-6.d.ts} +168 -258
- package/dist/types-chunks/types.d-mM8vqvhT.d.ts +254 -0
- package/dist/types-chunks/{storage.d-Bv9T99Qu.d.ts → utils.d-DkLZD_wa.d.ts} +38 -112
- package/package.json +15 -6
- package/dist/chunks/chunk-5TFLMGER.js +0 -2
- package/dist/chunks/chunk-6QO6HWGU.js +0 -30
- package/dist/chunks/chunk-EQ5DGS2W.js +0 -14
- package/dist/chunks/chunk-HYWVRTFA.js +0 -1233
- package/dist/chunks/chunk-SX2IS5JP.js +0 -16
- package/dist/chunks/chunk-ZPJPNLBK.js +0 -462
- package/dist/chunks/dist-M57GIWR4.js +0 -2
- package/dist/chunks/dist-V3BS2NKB.js +0 -2
- package/dist/chunks/utils-FAFUQJ2A.js +0 -2
package/dist/sdk-coding.d.ts
CHANGED
|
@@ -1,439 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { K as KODAX_DEFAULT_PROVIDER, b as KODAX_PROVIDERS, c as KODAX_PROVIDER_SNAPSHOTS, d as KODAX_REASONING_MODE_SEQUENCE, f as KodaXAnthropicCompatProvider, g as KodaXError,
|
|
4
|
-
import { K as KodaXBaseProvider
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { X as KodaXToolDefinition, Z as KodaXToolResultContentItem, D as KodaXReasoningMode, m as KodaXMessage, a0 as KodaXToolUseBlock, g as KodaXContentBlock, q as KodaXProviderCapabilityProfile, C as KodaXReasoningCapability, Q as KodaXTaskType, i as KodaXExecutionMode, P as KodaXTaskRoutingDecision, K as KodaXAmaControllerDecision, V as KodaXThinkingDepth } from './types-chunks/types.d-B1uGoVTE.js';
|
|
2
|
+
export { a as KodaXAmaFanoutClass, b as KodaXAmaFanoutPolicy, c as KodaXAmaProfile, d as KodaXAmaTactic, h as KodaXCustomProviderConfig, l as KodaXImageBlock, n as KodaXModelDescriptor, p as KodaXProtocolFamily, r as KodaXProviderConfig, t as KodaXProviderConversationSemantics, w as KodaXProviderMcpSupport, z as KodaXProviderStreamOptions, B as KodaXProviderTransport, E as KodaXReasoningOverride, F as KodaXReasoningRequest, G as KodaXRedactedThinkingBlock, H as KodaXReviewScale, I as KodaXRiskLevel, J as KodaXStreamResult, M as KodaXTaskBudgetOverrides, S as KodaXTextBlock, T as KodaXThinkingBlock, U as KodaXThinkingBudgetMap, W as KodaXTokenUsage, Y as KodaXToolResultBlock } from './types-chunks/types.d-B1uGoVTE.js';
|
|
3
|
+
export { K as KODAX_DEFAULT_PROVIDER, b as KODAX_PROVIDERS, c as KODAX_PROVIDER_SNAPSHOTS, d as KODAX_REASONING_MODE_SEQUENCE, f as KodaXAnthropicCompatProvider, g as KodaXError, h as KodaXModelCapabilities, j as KodaXOpenAICompatProvider, k as KodaXProviderError, l as KodaXRateLimitError, P as ProviderName, n as buildReasoningOverrideKey, p as clearReasoningOverride, q as clearRuntimeModelProviders, r as createCustomProvider, s as getAvailableProviderNames, t as getCustomModelCapabilities, u as getCustomProvider, v as getCustomProviderList, w as getCustomProviderModelDescriptors, x as getCustomProviderModels, y as getCustomProviderNames, A as getModelCapabilities, B as getProvider, C as getProviderConfiguredCapabilityProfile, D as getProviderConfiguredReasoningCapability, E as getProviderList, F as getProviderModel, G as getProviderModelDescriptors, H as getProviderModels, J as getRuntimeModelProvider, L as getRuntimeModelProviderNames, M as isCustomProviderName, N as isKnownProvider, O as isProviderConfigured, Q as isProviderName, S as isRuntimeModelProviderName, T as listAllModelCapabilities, U as listBuiltinModelCapabilities, V as listCustomProviderModelCapabilities, W as loadReasoningOverride, Z as reasoningCapabilityToOverride, _ as reasoningOverrideToCapability, $ as registerCustomProviders, a0 as registerModelProvider, a1 as resolveModelCapabilities, a2 as resolveProvider, a3 as resolveProviderModelDescriptors, a5 as saveReasoningOverride, a6 as validateCustomProviderConfig } from './types-chunks/resolver.d-CA68_NeH.js';
|
|
4
|
+
import { K as KodaXBaseProvider } from './types-chunks/base.d-FUJahC0i.js';
|
|
5
|
+
import { C as CapabilityKind, a as CapabilityProvider, b as CapabilityResult } from './types-chunks/capability.d-3C62G8Eq.js';
|
|
6
|
+
import { aq as KodaXToolExecutionContext, _ as KodaXRepoIntelligenceCapability, a1 as KodaXRepoIntelligenceTrace, $ as KodaXRepoIntelligenceMode, a3 as KodaXRepoRoutingSignals, a0 as KodaXRepoIntelligenceResolvedMode, W as KodaXOptions, L as KodaXInputArtifact, w as KodaXContextOptions, Z as KodaXProviderPolicyHints, ax as ProviderResilienceConfig, ay as ProviderResiliencePolicy, F as FailureStage, aD as ResilienceClassification, av as ProviderExecutionState, aA as RecoveryDecision, aC as RecoveryResult, a4 as KodaXResult, a7 as KodaXSessionControl, a8 as KodaXSessionMutators, J as KodaXFanoutSchedulerPlan, H as KodaXFanoutBranchTransition, I as KodaXFanoutSchedulerInput, v as KodaXChildContextBundle, Y as KodaXParentReductionContract, G as KodaXFanoutBranchRecord, N as KodaXManagedProtocolPayload, q as ExtensionRuntimeContract, y as KodaXEvents, k as AutoRules, aM as ToolCallSignal, aH as SignalCollector } from './types-chunks/bash-prefix-extractor.d-DMrGImMl.js';
|
|
7
|
+
export { C as AUTO_MODE_DENIAL_CONSECUTIVE_THRESHOLD, n as AUTO_MODE_DENIAL_CUMULATIVE_THRESHOLD, A as AgentsFile, a as AskUserMultiOptions, b as AskUserQuestionItem, c as AskUserQuestionOptions, d as AutoModeAskUser, e as AutoModeAskUserVerdict, D as AutoModeDenialTracker, f as AutoModeEngine, g as AutoModeGuardrailConfig, h as AutoModeSharedState, i as AutoModeStats, j as AutoModeToolGuardrail, B as BASH_POLICY_SPEC, E as BREAKER_ERROR_THRESHOLD, aO as BREAKER_WINDOW_MS, l as BashPrefixExtractor, m as BashPrefixResult, o as CircuitBreaker, p as CreateBashPrefixExtractorOptions, r as ExtractCommandPrefixOptions, K as KodaXAgentMode, s as KodaXBudgetDisclosureZone, t as KodaXBudgetExtensionRequest, u as KodaXChildAgentResult, x as KodaXContextTokenSnapshot, z as KodaXFanoutBranchLifecycle, M as KodaXManagedBudgetSnapshot, O as KodaXManagedTask, P as KodaXManagedTaskRuntimeState, Q as KodaXManagedTaskStatusEvent, R as KodaXMcpConnectMode, S as KodaXMcpServerConfig, T as KodaXMcpServersConfig, U as KodaXMcpTransport, V as KodaXMemoryStrategy, X as KodaXOrchestrationVerdict, a2 as KodaXRepoIntelligenceTraceEvent, a5 as KodaXRoleRoundSummary, a6 as KodaXRuntimeVerificationContract, a9 as KodaXSessionOptions, aa as KodaXSkillInvocationContext, ab as KodaXSkillMap, ac as KodaXSkillProjectionConfidence, ad as KodaXTaskCapabilityHint, ae as KodaXTaskContract, af as KodaXTaskEvidenceArtifact, ag as KodaXTaskEvidenceBundle, ah as KodaXTaskEvidenceEntry, ai as KodaXTaskRole, aj as KodaXTaskRoleAssignment, ak as KodaXTaskStatus, al as KodaXTaskSurface, am as KodaXTaskToolPolicy, an as KodaXTaskVerificationContract, ao as KodaXTaskVerificationCriterion, ap as KodaXTaskWorkItem, ar as KodaXVerificationScorecard, as as KodaXVerificationScorecardCriterion, at as LoadAgentsOptions, au as LoadedRulesSource, aw as ProviderRecoveryEvent, az as RecoveryAction, aB as RecoveryLadderStep, aE as ResilienceErrorClass, aF as RulesLoadError, aG as RulesLoadResult, aI as SkippedRulesSource, aJ as TodoItem, aK as TodoList, aL as TodoStatus, aN as TrustState, b3 as autoModeDenialShouldFallback, b4 as breakerShouldFallback, aP as collectAllSignals, aQ as computeRulesFingerprint, aU as createAutoModeDenialTracker, aR as createAutoModeToolGuardrail, aS as createBashPrefixExtractor, aT as createCircuitBreaker, aV as extractCommandPrefix, aW as formatAgentsForPrompt, aX as getKodaxGlobalDir, aY as loadAgentsFiles, aZ as loadAutoRules, a_ as parseAutoRules, a$ as readTrustState, b0 as recordAutoModeAllow, b1 as recordAutoModeBlock, b2 as recordBreakerError, b5 as trustProjectRules } from './types-chunks/bash-prefix-extractor.d-DMrGImMl.js';
|
|
8
|
+
import { f as KodaXJsonValue, b as KodaXExtensionSessionRecord, d as KodaXExtensionStore, S as SessionErrorMetadata } from './types-chunks/types.d-mM8vqvhT.js';
|
|
9
|
+
export { K as KodaXCompactMemoryProgress, a as KodaXCompactMemorySeed, c as KodaXExtensionSessionState, h as KodaXSessionArtifactLedgerEntry, i as KodaXSessionBranchSummaryEntry, j as KodaXSessionCompactionEntry, k as KodaXSessionData, l as KodaXSessionEntry, m as KodaXSessionEntryBase, n as KodaXSessionLabelEntry, o as KodaXSessionLineage, p as KodaXSessionMessageEntry, q as KodaXSessionMeta, r as KodaXSessionNavigationOptions, s as KodaXSessionRuntimeInfo, t as KodaXSessionScope, u as KodaXSessionStorage, v as KodaXSessionTreeNode, w as KodaXSessionUiHistoryItem, x as KodaXSessionUiHistoryItemType, y as KodaXSessionWorkspaceKind } from './types-chunks/types.d-mM8vqvhT.js';
|
|
10
|
+
import { Q as QualityInvariant, a6 as ToolCapability } from './types-chunks/file-tracker.d-zaLZeNBK.js';
|
|
11
|
+
export { C as CompactionContext, e as CompactionEntry, f as CompactionEntryPayload, g as CompactionPolicy, h as DefaultSummaryCompaction, i as DefaultSummaryCompactionOptions, I as InMemorySessionOptions, K as KODAX_API_MIN_INTERVAL, n as KODAX_DEFAULT_TIMEOUT, o as KODAX_HARD_TIMEOUT, p as KODAX_MAX_INCOMPLETE_RETRIES, r as KODAX_MAX_RETRIES, s as KODAX_MAX_TOKENS, t as KODAX_RETRY_BASE_DELAY, u as KODAX_STAGGER_DELAY, L as LINEAGE_ENTRY_TYPES, v as LineageArtifactLedgerPayload, w as LineageCompaction, x as LineageCompactionDelegates, y as LineageEntryType, z as LineageExtension, B as LineageLabelPayload, E as LineageTreeNode, F as MessageEntry, P as PROMISE_PATTERN, H as PresetDispatcher, S as RunEvent, T as RunOptions, U as RunResult, V as Runner, X as Session, Z as SessionEntry, _ as SessionExtension, $ as SessionForkOptions, ae as appendSessionLineageLabel, ag as applySessionCompaction, ah as archiveOldIslands, ai as buildSessionTree, ak as cleanupIncompleteToolCalls, al as countActiveLineageMessages, am as countTokens, an as createInMemorySession, ap as createSessionLineage, at as estimateTokens, au as extractArtifactLedger, ax as extractTitleFromMessages, ay as findPreviousUserEntryId, az as forkSessionLineage, aA as generateSessionId, aC as getAgentConfigHome, aD as getAgentConfigPath, aE as getAppDataDir, aF as getSessionLineagePath, aG as getSessionMessagesFromLineage, aH as mergeArtifactLedger, aJ as registerPresetDispatcher, aK as resolveSessionLineageTarget, aL as rewindSessionLineage, aO as setAgentConfigHome, aP as setSessionLineageActiveEntry, aQ as validateAndFixToolHistory } from './types-chunks/file-tracker.d-zaLZeNBK.js';
|
|
12
|
+
import { z as RunnableTool, A as Agent, a4 as ToolGuardrail, a as AgentMessage, J as RunnerLlmReturn, K as RunnerToolCall } from './types-chunks/types.d-CKJtjo-6.js';
|
|
13
|
+
export { c as AgentReasoningProfile, e as AgentTool, f as CompactionAnchor, i as CompactionResult, k as CompactionUpdate, o as Guardrail, H as Handoff, R as ReasoningDepth, a8 as createAgent, a9 as createHandoff } from './types-chunks/types.d-CKJtjo-6.js';
|
|
14
|
+
import { b as McpServersConfig } from './types-chunks/config.d-BfJUXxC0.js';
|
|
15
|
+
export { M as McpConnectMode, a as McpServerConfig, c as McpTransportKind } from './types-chunks/config.d-BfJUXxC0.js';
|
|
16
|
+
import { f as McpProviderOptions, b as McpCapabilityProvider } from './types-chunks/manager.d-87belpiS.js';
|
|
17
|
+
export { M as McpCapabilityDescriptor, a as McpCapabilityKind, c as McpCapabilityRisk, d as McpCatalogItem, e as McpManager, g as McpServerCatalog, h as McpServerCatalogSnapshot, i as McpServerLogs, j as McpServerRuntime, k as McpServerRuntimeDiagnostics, l as McpServerStatus, m as McpServerToolList, n as McpTransport, o as McpTransportEvents, p as createMcpCapabilityId, q as createMcpManager, r as createMcpTransport, s as defaultMcpCacheDir, t as getMcpCachePaths, u as parseMcpCapabilityId, v as searchMcpCatalog } from './types-chunks/manager.d-87belpiS.js';
|
|
18
|
+
import { a as CostTracker } from './types-chunks/cost-tracker.d-wRtyEW9d.js';
|
|
11
19
|
import '@anthropic-ai/sdk';
|
|
12
20
|
import 'openai';
|
|
13
21
|
|
|
14
|
-
/**
|
|
15
|
-
* LineageExtension — SessionExtension façade over lineage semantics.
|
|
16
|
-
*
|
|
17
|
-
* FEATURE_081 (v0.7.23): expresses today's `KodaXSessionLineage` operations
|
|
18
|
-
* (label, rewind, compaction ledger, branch summary) as a
|
|
19
|
-
* `SessionExtension` over the base `Session` primitive.
|
|
20
|
-
*
|
|
21
|
-
* FEATURE_082 (v0.7.24): moved from `@kodax-ai/coding/src/extensions/lineage.ts`
|
|
22
|
-
* to this package. Depends on `@kodax-ai/agent` for `Session` / `SessionEntry` /
|
|
23
|
-
* `SessionExtension` (Layer A primitives — extracted to `@kodax-ai/core` in
|
|
24
|
-
* FEATURE_082, merged back into `@kodax-ai/agent` in v0.7.35.1 FEATURE_142).
|
|
25
|
-
* `@kodax-ai/coding` keeps a barrel re-export.
|
|
26
|
-
*
|
|
27
|
-
* Scope:
|
|
28
|
-
* - Declare the extension object.
|
|
29
|
-
* - Implement `label` and `attachArtifact` operators that append standard
|
|
30
|
-
* entries to a Session.
|
|
31
|
-
* - Implement a `buildLineageTree` reducer that projects an entry stream
|
|
32
|
-
* back to a navigable tree.
|
|
33
|
-
* - NOT re-implemented here: `branch`, `rewind`, full compaction. Those
|
|
34
|
-
* stay in `@kodax-ai/agent/session-lineage.ts` for coding-preset use; the
|
|
35
|
-
* `LineageCompaction` policy in this package is the thin wrapper that
|
|
36
|
-
* adapts them to the Layer A `CompactionPolicy` contract.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Entry types claimed by `LineageExtension`. Mirrors the legacy
|
|
41
|
-
* `KodaXSessionEntry` tagged union plus a `rewind_marker` placeholder (the
|
|
42
|
-
* legacy lineage records rewinds via `activeEntryId` mutation; Session is
|
|
43
|
-
* linear, so a marker entry is the equivalent).
|
|
44
|
-
*/
|
|
45
|
-
declare const LINEAGE_ENTRY_TYPES: readonly ["message", "label", "compaction", "branch_summary", "archive_marker", "rewind_marker", "artifact_ledger"];
|
|
46
|
-
type LineageEntryType = (typeof LINEAGE_ENTRY_TYPES)[number];
|
|
47
|
-
/**
|
|
48
|
-
* Payload shape for a `label` entry. Mirrors
|
|
49
|
-
* `KodaXSessionLabelEntry.targetId`/`label` fields on the legacy lineage.
|
|
50
|
-
*/
|
|
51
|
-
interface LineageLabelPayload {
|
|
52
|
-
readonly targetId: string;
|
|
53
|
-
readonly label?: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Payload shape for an `artifact_ledger` entry. Mirrors a minimal subset of
|
|
57
|
-
* `KodaXSessionArtifactLedgerEntry`; full semantic fidelity is kept on the
|
|
58
|
-
* legacy side for now and normalised in FEATURE_082.
|
|
59
|
-
*/
|
|
60
|
-
interface LineageArtifactLedgerPayload {
|
|
61
|
-
readonly ref: string;
|
|
62
|
-
readonly kind?: string;
|
|
63
|
-
readonly summary?: string;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Projected tree node. Mirrors the navigation shape of
|
|
67
|
-
* `KodaXSessionTreeNode` from `@kodax-ai/agent/types.ts`, restricted to the
|
|
68
|
-
* fields the base Session can supply.
|
|
69
|
-
*/
|
|
70
|
-
interface LineageTreeNode {
|
|
71
|
-
readonly entry: SessionEntry;
|
|
72
|
-
readonly children: LineageTreeNode[];
|
|
73
|
-
readonly label?: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* The exported extension. Operators write standard-shaped entries; the
|
|
77
|
-
* reducer projects an entry stream back to a navigable tree.
|
|
78
|
-
*
|
|
79
|
-
* Immutability: top-level object, `operators`, and `reducers` are all
|
|
80
|
-
* frozen. Freezes are shallow — the functions stored inside `operators`
|
|
81
|
-
* and `reducers` are immutable by nature (closures reference only
|
|
82
|
-
* module-private state). External code must not mutate the extension;
|
|
83
|
-
* doing so is a programmer error that the type-level `readonly` already
|
|
84
|
-
* disallows without a cast.
|
|
85
|
-
*/
|
|
86
|
-
declare const LineageExtension: SessionExtension;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* LineageCompaction — `CompactionPolicy` adapter for the coding preset's
|
|
90
|
-
* FEATURE_072 lineage-native compaction runtime.
|
|
91
|
-
*
|
|
92
|
-
* FEATURE_082 (v0.7.24): introduced alongside the lineage extraction so the
|
|
93
|
-
* coding preset can implement `CompactionPolicy` without re-implementing the
|
|
94
|
-
* compaction loop. The actual compaction runtime (microcompaction, post-
|
|
95
|
-
* compact reconstruction, summary generation) stays in
|
|
96
|
-
* `@kodax-ai/agent/src/compaction/` until FEATURE_084 (v0.7.26) consolidates it.
|
|
97
|
-
*
|
|
98
|
-
* Usage (inside @kodax-ai/coding):
|
|
99
|
-
*
|
|
100
|
-
* const policy = new LineageCompaction({
|
|
101
|
-
* shouldCompact: (session, used, budget) => runFeature072Heuristic(used, budget),
|
|
102
|
-
* compact: async (session, ctx) => runFeature072Compaction(session, ctx),
|
|
103
|
-
* });
|
|
104
|
-
*
|
|
105
|
-
* The injected delegates keep this package free of coding-specific imports,
|
|
106
|
-
* preserving the dependency direction
|
|
107
|
-
* `@kodax-ai/coding -> @kodax-ai/session-lineage -> @kodax-ai/agent`.
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Delegates required to implement `LineageCompaction`. The coding preset
|
|
112
|
-
* supplies implementations that bridge to the existing FEATURE_072 code
|
|
113
|
-
* paths.
|
|
114
|
-
*/
|
|
115
|
-
interface LineageCompactionDelegates {
|
|
116
|
-
readonly shouldCompact: (session: Session, tokensUsed: number, budget: number) => boolean;
|
|
117
|
-
readonly compact: (session: Session, ctx: CompactionContext) => Promise<PolicyCompactionResult>;
|
|
118
|
-
readonly restore?: (session: Session, hint: unknown) => Promise<void>;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* `CompactionPolicy` implementation that preserves FEATURE_072 lineage-native
|
|
122
|
-
* compaction semantics by delegating to injected coding-preset functions.
|
|
123
|
-
*/
|
|
124
|
-
declare class LineageCompaction implements CompactionPolicy {
|
|
125
|
-
readonly name = "lineage-compaction";
|
|
126
|
-
private readonly delegates;
|
|
127
|
-
constructor(delegates: LineageCompactionDelegates);
|
|
128
|
-
shouldCompact(session: Session, tokensUsed: number, budget: number): boolean;
|
|
129
|
-
compact(session: Session, ctx: CompactionContext): Promise<PolicyCompactionResult>;
|
|
130
|
-
restore(session: Session, hint: unknown): Promise<void>;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @kodax-ai/agent Session
|
|
135
|
-
*
|
|
136
|
-
* 会话管理 - Session ID 生成和消息处理
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 生成会话 ID
|
|
141
|
-
* 格式: YYYYMMDD_HHMMSS
|
|
142
|
-
*/
|
|
143
|
-
declare function generateSessionId(): Promise<string>;
|
|
144
|
-
/**
|
|
145
|
-
* 从消息中提取标题
|
|
146
|
-
* 取第一条用户消息的前50个字符
|
|
147
|
-
*/
|
|
148
|
-
declare function extractTitleFromMessages(messages: KodaXMessage[]): string;
|
|
149
|
-
|
|
150
|
-
type NavigableSessionEntry = Exclude<KodaXSessionEntry, KodaXSessionLabelEntry>;
|
|
151
|
-
/**
|
|
152
|
-
* Reconcile a linear message list against an existing lineage tree.
|
|
153
|
-
*
|
|
154
|
-
* Existing matching entries are reused when possible, and only the missing
|
|
155
|
-
* tail is appended as new message entries.
|
|
156
|
-
*/
|
|
157
|
-
declare function createSessionLineage(messages: KodaXMessage[], previous?: KodaXSessionLineage): KodaXSessionLineage;
|
|
158
|
-
/**
|
|
159
|
-
* Walk the lineage from a target entry back to the root.
|
|
160
|
-
*
|
|
161
|
-
* Traversal stops safely if malformed data introduces a parent cycle.
|
|
162
|
-
*/
|
|
163
|
-
declare function getSessionLineagePath(lineage: KodaXSessionLineage, targetId?: string | null): NavigableSessionEntry[];
|
|
164
|
-
/**
|
|
165
|
-
* Build the effective LLM-visible message context for the active lineage path.
|
|
166
|
-
*
|
|
167
|
-
* FEATURE_072: for non-rewind compaction entries that carry
|
|
168
|
-
* `postCompactAttachments`, the slicer inlines attachments immediately after
|
|
169
|
-
* the summary. `getContextMessagesForEntry` stays 1-to-1 — attachments are a
|
|
170
|
-
* slicer-layer concern, which preserves the contract
|
|
171
|
-
* `entryMatchesContextMessage` and FEATURE_073's future firstKeptEntryId-based
|
|
172
|
-
* slicing both depend on.
|
|
173
|
-
*/
|
|
174
|
-
declare function getSessionMessagesFromLineage(lineage: KodaXSessionLineage, targetId?: string | null): KodaXMessage[];
|
|
175
|
-
/**
|
|
176
|
-
* Resolve an entry selector using either a direct entry id or the latest label.
|
|
177
|
-
*/
|
|
178
|
-
declare function resolveSessionLineageTarget(lineage: KodaXSessionLineage, selector: string): NavigableSessionEntry | undefined;
|
|
179
|
-
/**
|
|
180
|
-
* Move the active leaf to a selected target, optionally appending a
|
|
181
|
-
* branch-summary node that captures the abandoned path.
|
|
182
|
-
*/
|
|
183
|
-
declare function setSessionLineageActiveEntry(lineage: KodaXSessionLineage, selector: string, options?: KodaXSessionNavigationOptions): KodaXSessionLineage | null;
|
|
184
|
-
/**
|
|
185
|
-
* Append a label change entry that bookmarks a lineage node.
|
|
186
|
-
*/
|
|
187
|
-
declare function appendSessionLineageLabel(lineage: KodaXSessionLineage, selector: string, label?: string): KodaXSessionLineage | null;
|
|
188
|
-
/**
|
|
189
|
-
* Apply a compaction event to the lineage.
|
|
190
|
-
*
|
|
191
|
-
* FEATURE_072 signature change: `keptMessages` (the post-summary tail that
|
|
192
|
-
* will become lineage entries) and `postCompactAttachments` (ledger +
|
|
193
|
-
* file-content messages that live on the CompactionEntry itself) are now
|
|
194
|
-
* separate parameters. The kept tail MUST NOT include attachments — otherwise
|
|
195
|
-
* they would be double-stored (once as message entries in lineage, once on
|
|
196
|
-
* the compaction entry). Phase A keeps `postCompactAttachments` optional so
|
|
197
|
-
* current callers that pass `[]` (or omit it) behave identically to today.
|
|
198
|
-
* Phase B migrates callers to supply real attachments.
|
|
199
|
-
*/
|
|
200
|
-
declare function applySessionCompaction(lineage: KodaXSessionLineage | undefined, compactedMessages: KodaXMessage[], anchor: {
|
|
201
|
-
summary: string;
|
|
202
|
-
tokensBefore?: number;
|
|
203
|
-
tokensAfter?: number;
|
|
204
|
-
artifactLedgerId?: string;
|
|
205
|
-
reason?: string;
|
|
206
|
-
details?: KodaXJsonValue | CompactionDetails;
|
|
207
|
-
memorySeed?: KodaXCompactMemorySeed;
|
|
208
|
-
}, postCompactAttachments?: readonly KodaXMessage[]): KodaXSessionLineage;
|
|
209
|
-
/**
|
|
210
|
-
* Rewind the current session lineage to a target entry, truncating all entries after it.
|
|
211
|
-
* Records a rewind event in the lineage for auditability.
|
|
212
|
-
* Returns null if targetEntryId is not found.
|
|
213
|
-
*
|
|
214
|
-
* @param lineage - The session lineage to rewind
|
|
215
|
-
* @param targetEntryId - The entry ID to rewind to (inclusive)
|
|
216
|
-
* @returns A new lineage with entries truncated after the target, or null if target not found
|
|
217
|
-
*/
|
|
218
|
-
/**
|
|
219
|
-
* Find the entry ID of the second-to-last user message in the lineage.
|
|
220
|
-
* Used by `/rewind` (no argument) to go back one conversational turn.
|
|
221
|
-
* Returns null if fewer than 2 user messages exist.
|
|
222
|
-
*/
|
|
223
|
-
declare function findPreviousUserEntryId(lineage: KodaXSessionLineage): string | null;
|
|
224
|
-
declare function rewindSessionLineage(lineage: KodaXSessionLineage, targetEntryId: string): KodaXSessionLineage | null;
|
|
225
|
-
declare function forkSessionLineage(lineage: KodaXSessionLineage, selector?: string): KodaXSessionLineage | null;
|
|
226
|
-
/**
|
|
227
|
-
* Convert a lineage into a nested tree structure for UI presentation.
|
|
228
|
-
*/
|
|
229
|
-
declare function buildSessionTree(lineage: KodaXSessionLineage): KodaXSessionTreeNode[];
|
|
230
|
-
/**
|
|
231
|
-
* Count the effective context messages on the active lineage path.
|
|
232
|
-
*/
|
|
233
|
-
declare function countActiveLineageMessages(lineage: KodaXSessionLineage): number;
|
|
234
|
-
/**
|
|
235
|
-
* Archive message entries from old "islands" (disconnected subtrees).
|
|
236
|
-
*
|
|
237
|
-
* Each compaction entry has parentId: null, creating an independent island.
|
|
238
|
-
* The active leaf lives in one island (the "current" island). All other
|
|
239
|
-
* islands are considered "old" and eligible for archival.
|
|
240
|
-
*
|
|
241
|
-
* A "preserve closure" is computed first:
|
|
242
|
-
* - All entries in the current island (active path + recent branches)
|
|
243
|
-
* - Label targets and their ancestor chains
|
|
244
|
-
* - Non-message entries and their ancestor chains (prevents tree drift)
|
|
245
|
-
*
|
|
246
|
-
* Only entries outside the preserve closure are archived.
|
|
247
|
-
*/
|
|
248
|
-
declare function archiveOldIslands(lineage: KodaXSessionLineage): {
|
|
249
|
-
slimmedLineage: KodaXSessionLineage;
|
|
250
|
-
archivedEntries: KodaXSessionEntry[];
|
|
251
|
-
archivedCount: number;
|
|
252
|
-
archiveBatchId: string;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* @kodax-ai/agent File Tracking
|
|
257
|
-
*/
|
|
258
|
-
|
|
259
|
-
declare function extractArtifactLedger(messages: KodaXMessage[]): KodaXSessionArtifactLedgerEntry[];
|
|
260
|
-
declare function mergeArtifactLedger(existing: KodaXSessionArtifactLedgerEntry[], next: KodaXSessionArtifactLedgerEntry[]): KodaXSessionArtifactLedgerEntry[];
|
|
261
|
-
|
|
262
|
-
type McpCapabilityKind = 'tool' | 'resource' | 'prompt';
|
|
263
|
-
type McpCapabilityRisk = 'read' | 'write' | 'network' | 'exec';
|
|
264
|
-
interface McpCatalogItem {
|
|
265
|
-
id: string;
|
|
266
|
-
serverId: string;
|
|
267
|
-
kind: McpCapabilityKind;
|
|
268
|
-
name: string;
|
|
269
|
-
title?: string;
|
|
270
|
-
summary: string;
|
|
271
|
-
tags?: string[];
|
|
272
|
-
risk?: McpCapabilityRisk;
|
|
273
|
-
annotations?: Record<string, unknown>;
|
|
274
|
-
cachedAt: string;
|
|
275
|
-
}
|
|
276
|
-
interface McpCapabilityDescriptor extends McpCatalogItem {
|
|
277
|
-
inputSchema?: unknown;
|
|
278
|
-
outputSchema?: unknown;
|
|
279
|
-
promptArgsSchema?: unknown;
|
|
280
|
-
uri?: string;
|
|
281
|
-
mimeType?: string;
|
|
282
|
-
}
|
|
283
|
-
interface McpServerCatalogSnapshot {
|
|
284
|
-
serverId: string;
|
|
285
|
-
items: McpCatalogItem[];
|
|
286
|
-
descriptors: McpCapabilityDescriptor[];
|
|
287
|
-
updatedAt: string;
|
|
288
|
-
}
|
|
289
|
-
interface McpCatalogSearchOptions {
|
|
290
|
-
kind?: McpCapabilityKind;
|
|
291
|
-
limit?: number;
|
|
292
|
-
}
|
|
293
|
-
declare function defaultMcpCacheDir(): string;
|
|
294
|
-
declare function createMcpCapabilityId(serverId: string, kind: McpCapabilityKind, name: string): string;
|
|
295
|
-
declare function parseMcpCapabilityId(id: string): {
|
|
296
|
-
serverId: string;
|
|
297
|
-
kind: McpCapabilityKind;
|
|
298
|
-
name: string;
|
|
299
|
-
};
|
|
300
|
-
declare function searchMcpCatalog(items: readonly McpCatalogItem[], query: string, options?: McpCatalogSearchOptions): McpCatalogItem[];
|
|
301
|
-
declare function getMcpCachePaths(cacheDir: string, serverId: string): {
|
|
302
|
-
catalogDir: string;
|
|
303
|
-
indexPath: string;
|
|
304
|
-
itemsPath: string;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
interface McpServerRuntimeDiagnostics {
|
|
308
|
-
serverId: string;
|
|
309
|
-
connect: 'lazy' | 'prewarm' | 'disabled';
|
|
310
|
-
status: 'idle' | 'connecting' | 'ready' | 'error' | 'disabled';
|
|
311
|
-
dirty: boolean;
|
|
312
|
-
lastError?: string;
|
|
313
|
-
cachedAt?: string;
|
|
314
|
-
tools: number;
|
|
315
|
-
resources: number;
|
|
316
|
-
prompts: number;
|
|
317
|
-
}
|
|
318
|
-
declare class McpServerRuntime {
|
|
319
|
-
private readonly serverId;
|
|
320
|
-
private readonly config;
|
|
321
|
-
private readonly cacheDir;
|
|
322
|
-
private transport?;
|
|
323
|
-
private readonly pending;
|
|
324
|
-
private nextRequestId;
|
|
325
|
-
private initialized;
|
|
326
|
-
private connectPromise?;
|
|
327
|
-
private catalog?;
|
|
328
|
-
private diagnostics;
|
|
329
|
-
constructor(serverId: string, config: McpServerConfig, cacheDir: string);
|
|
330
|
-
getDiagnostics(): McpServerRuntimeDiagnostics;
|
|
331
|
-
prewarmIfNeeded(): Promise<void>;
|
|
332
|
-
/** Load catalog from memory or disk only — never triggers a lazy connection. */
|
|
333
|
-
getCachedCatalog(): Promise<McpServerCatalogSnapshot | undefined>;
|
|
334
|
-
getCatalog(forceRefresh?: boolean): Promise<McpServerCatalogSnapshot>;
|
|
335
|
-
describeCapability(capabilityId: string): Promise<McpCapabilityDescriptor | undefined>;
|
|
336
|
-
callTool(name: string, args: Record<string, unknown>): Promise<{
|
|
337
|
-
content?: string;
|
|
338
|
-
structuredContent?: unknown;
|
|
339
|
-
metadata?: Record<string, unknown>;
|
|
340
|
-
}>;
|
|
341
|
-
readResource(name: string, options: Record<string, unknown>): Promise<{
|
|
342
|
-
content?: string;
|
|
343
|
-
structuredContent?: unknown;
|
|
344
|
-
metadata?: Record<string, unknown>;
|
|
345
|
-
}>;
|
|
346
|
-
getPrompt(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
347
|
-
refreshCatalog(forceReconnect?: boolean): Promise<void>;
|
|
348
|
-
/** Public teardown — clears everything including the connect lock. */
|
|
349
|
-
dispose(): Promise<void>;
|
|
350
|
-
/** Internal transport teardown — does NOT clear connectPromise so the
|
|
351
|
-
* retry loop inside doConnect() can safely call it between attempts. */
|
|
352
|
-
private resetTransport;
|
|
353
|
-
private connect;
|
|
354
|
-
private doConnect;
|
|
355
|
-
private listDescriptors;
|
|
356
|
-
private request;
|
|
357
|
-
private notify;
|
|
358
|
-
private handleMessage;
|
|
359
|
-
private failPending;
|
|
360
|
-
private applyCatalogSnapshot;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* `McpCapabilityProvider` — implements the Layer A `CapabilityProvider`
|
|
365
|
-
* contract for an MCP server fleet.
|
|
366
|
-
*
|
|
367
|
-
* FEATURE_082 (v0.7.24): moved from
|
|
368
|
-
* `@kodax-ai/coding/src/capabilities/providers/mcp/provider.ts` to this package.
|
|
369
|
-
* The coding-specific `registerConfiguredMcpCapabilityProvider` adapter (which
|
|
370
|
-
* pulls in `KodaXExtensionRuntime`) lives in
|
|
371
|
-
* `@kodax-ai/coding/src/capabilities/providers/mcp-adapter.ts`.
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
|
-
interface McpProviderOptions {
|
|
375
|
-
cacheDir?: string;
|
|
376
|
-
}
|
|
377
|
-
declare class McpCapabilityProvider implements CapabilityProvider {
|
|
378
|
-
readonly id = "mcp";
|
|
379
|
-
readonly kinds: CapabilityProvider['kinds'];
|
|
380
|
-
private readonly runtimes;
|
|
381
|
-
private readonly cacheDir;
|
|
382
|
-
/**
|
|
383
|
-
* Construct an MCP capability provider.
|
|
384
|
-
*
|
|
385
|
-
* **Cache-dir capture warning (v0.7.35.1 FEATURE_145)** — when
|
|
386
|
-
* `options.cacheDir` is omitted, this constructor resolves
|
|
387
|
-
* `defaultMcpCacheDir()` ONCE at instantiation time and threads the
|
|
388
|
-
* result into every `McpServerRuntime` it spawns. If a substrate
|
|
389
|
-
* consumer plans to redirect the agent config home via
|
|
390
|
-
* `setAgentConfigHome()` from `@kodax-ai/agent`, that call MUST happen
|
|
391
|
-
* BEFORE constructing this provider. Late calls have no effect on
|
|
392
|
-
* already-constructed runtimes.
|
|
393
|
-
*
|
|
394
|
-
* To bypass the agent-home resolver entirely, pass
|
|
395
|
-
* `options.cacheDir` explicitly — that path wins unconditionally.
|
|
396
|
-
*/
|
|
397
|
-
constructor(servers: McpServersConfig | undefined, options?: McpProviderOptions);
|
|
398
|
-
hasActiveServers(): boolean;
|
|
399
|
-
prewarm(): Promise<void>;
|
|
400
|
-
search(query: string, options?: {
|
|
401
|
-
kind?: CapabilityKind;
|
|
402
|
-
limit?: number;
|
|
403
|
-
server?: string;
|
|
404
|
-
}): Promise<unknown[]>;
|
|
405
|
-
describe(id: string): Promise<unknown>;
|
|
406
|
-
execute(id: string, input: Record<string, unknown>): Promise<CapabilityResult>;
|
|
407
|
-
read(id: string, options?: Record<string, unknown>): Promise<CapabilityResult>;
|
|
408
|
-
getPrompt(id: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
409
|
-
getPromptContext(): Promise<string | undefined>;
|
|
410
|
-
getDiagnostics(): Record<string, unknown> | undefined;
|
|
411
|
-
refresh(): Promise<void>;
|
|
412
|
-
dispose(): Promise<void>;
|
|
413
|
-
private collectCatalogItems;
|
|
414
|
-
private listServerDiagnostics;
|
|
415
|
-
private requireRuntime;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
interface McpTransportEvents {
|
|
419
|
-
/** Called with a complete JSON-RPC message (raw JSON string). */
|
|
420
|
-
onMessage(raw: string): void;
|
|
421
|
-
onError(error: Error): void;
|
|
422
|
-
onClose(reason: string): void;
|
|
423
|
-
}
|
|
424
|
-
interface McpTransport {
|
|
425
|
-
open(events: McpTransportEvents): Promise<void>;
|
|
426
|
-
/** Send a JSON string. The transport handles framing. */
|
|
427
|
-
send(json: string): Promise<void>;
|
|
428
|
-
close(): Promise<void>;
|
|
429
|
-
readonly connected: boolean;
|
|
430
|
-
}
|
|
431
|
-
type StdioFraming = 'content-length' | 'ndjson';
|
|
432
|
-
interface McpTransportOptions {
|
|
433
|
-
stdioFraming?: StdioFraming;
|
|
434
|
-
}
|
|
435
|
-
declare function createMcpTransport(config: McpServerConfig, options?: McpTransportOptions): McpTransport;
|
|
436
|
-
|
|
437
22
|
/**
|
|
438
23
|
* KodaX Core Errors
|
|
439
24
|
*
|
|
@@ -506,12 +91,63 @@ interface ToolProgress {
|
|
|
506
91
|
readonly stage: string;
|
|
507
92
|
readonly message: string;
|
|
508
93
|
}
|
|
509
|
-
/**
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Final result a tool may return. Either a plain string (the default for
|
|
96
|
+
* text-only tools) OR a typed-array form for multimodal returns (e.g.
|
|
97
|
+
* `read` on an image path returns `[{type:'text',...}, {type:'image',...}]`).
|
|
98
|
+
* Providers serialize each shape to their wire format; OpenAI-compat
|
|
99
|
+
* gateways downgrade image items to a placeholder rather than rejecting.
|
|
100
|
+
*
|
|
101
|
+
* The array form mirrors claudecode's FileReadTool image return — Claude
|
|
102
|
+
* Code packs image data into `tool_result` content so the model can
|
|
103
|
+
* re-fetch images via the tool path. See
|
|
104
|
+
* `c:/Works/claudecode/src/tools/FileReadTool/FileReadTool.ts:866-891`.
|
|
105
|
+
*/
|
|
106
|
+
type ToolResult = string | readonly KodaXToolResultContentItem[];
|
|
107
|
+
/** Standard tool handler — returns a final result (text or multimodal). */
|
|
108
|
+
type ToolHandlerSync = (input: Record<string, unknown>, context: KodaXToolExecutionContext) => Promise<ToolResult>;
|
|
109
|
+
/** Streaming tool handler — yields progress updates, returns final result. */
|
|
110
|
+
type ToolHandlerStreaming = (input: Record<string, unknown>, context: KodaXToolExecutionContext) => AsyncGenerator<ToolProgress, ToolResult, void>;
|
|
513
111
|
/** Union of both handler types. Existing tools use ToolHandlerSync; new long-running tools may use ToolHandlerStreaming. */
|
|
514
112
|
type ToolHandler = ToolHandlerSync | ToolHandlerStreaming;
|
|
113
|
+
/**
|
|
114
|
+
* v0.7.42 — Declarative tool side-effect class.
|
|
115
|
+
*
|
|
116
|
+
* Required field on every {@link LocalToolDefinition}. Used by:
|
|
117
|
+
* - Plan mode: tools with `sideEffect !== 'readonly'` are blocked unless
|
|
118
|
+
* they explicitly opt in via `planModeAllowed: true` (e.g.
|
|
119
|
+
* `exit_plan_mode`, `task_stop`).
|
|
120
|
+
* - SDK embedders (KodaX Space etc.): iterate `getAllRegisteredTools()`
|
|
121
|
+
* and build their own blocklist by category — replaces the previous
|
|
122
|
+
* practice of hardcoding a `Set<string>` of tool names, which silently
|
|
123
|
+
* drifted whenever KodaX added a new tool.
|
|
124
|
+
* - Internal permission system: `FILE_MODIFICATION_TOOLS` and
|
|
125
|
+
* `MODIFICATION_TOOLS` exports in `@kodax-ai/repl` are now computed
|
|
126
|
+
* from this metadata at module load time, so adding a new
|
|
127
|
+
* `'mutates-fs'` tool here automatically reaches every callsite
|
|
128
|
+
* that consumes those sets.
|
|
129
|
+
*
|
|
130
|
+
* Categories (mutually exclusive; pick the dominant effect):
|
|
131
|
+
* - `'readonly'` — produces no observable side effect, just reads
|
|
132
|
+
* local state (FS, registry, computed views).
|
|
133
|
+
* - `'mutates-fs'` — writes to the local filesystem (write, edit,
|
|
134
|
+
* multi-edit, undo, worktree-*, construction
|
|
135
|
+
* artifacts). Bash is NOT in this bucket; it has
|
|
136
|
+
* its own.
|
|
137
|
+
* - `'mutates-shell'` — invokes an arbitrary shell command (bash).
|
|
138
|
+
* - `'mutates-network'` — performs a network request that may have side
|
|
139
|
+
* effects on the remote (web_fetch with any
|
|
140
|
+
* method, web_search, MCP server calls).
|
|
141
|
+
* - `'mutates-state'` — changes internal session/agent state without
|
|
142
|
+
* FS or shell side effects (todo_update,
|
|
143
|
+
* send_message, dispatch_child_task,
|
|
144
|
+
* exit_plan_mode, emit_managed_protocol).
|
|
145
|
+
*
|
|
146
|
+
* Pick the dominant effect when a tool touches multiple. e.g. `dispatch_
|
|
147
|
+
* child_task` may transitively run any tool, but its own direct effect is
|
|
148
|
+
* spawning a child agent (`mutates-state`).
|
|
149
|
+
*/
|
|
150
|
+
type ToolSideEffect = 'readonly' | 'mutates-fs' | 'mutates-shell' | 'mutates-network' | 'mutates-state';
|
|
515
151
|
/**
|
|
516
152
|
* FEATURE_149 (v0.7.38) — interrupt-on-submit policy for in-flight tools.
|
|
517
153
|
*
|
|
@@ -533,11 +169,60 @@ type ToolHandler = ToolHandlerSync | ToolHandlerStreaming;
|
|
|
533
169
|
type ToolInterruptBehavior = 'cancel' | 'wait';
|
|
534
170
|
interface LocalToolDefinition extends KodaXToolDefinition {
|
|
535
171
|
handler: ToolHandler;
|
|
172
|
+
/**
|
|
173
|
+
* v0.7.42 — Required declarative side-effect class. See
|
|
174
|
+
* {@link ToolSideEffect} for category definitions and rationale. Plan
|
|
175
|
+
* mode and SDK embedders' permission brokers consume this; failure to
|
|
176
|
+
* declare is a TypeScript error (by design — `sideEffect` is required,
|
|
177
|
+
* not optional, to prevent silent drift when new tools are added).
|
|
178
|
+
*/
|
|
179
|
+
sideEffect: ToolSideEffect;
|
|
180
|
+
/**
|
|
181
|
+
* v0.7.42 — Optional plan-mode override.
|
|
182
|
+
*
|
|
183
|
+
* - `undefined` (default): plan-mode permits only `sideEffect ===
|
|
184
|
+
* 'readonly'` tools.
|
|
185
|
+
* - `true`: explicitly permitted in plan mode even when sideEffect is
|
|
186
|
+
* not `'readonly'`. Reserve for tools whose effect is itself part of
|
|
187
|
+
* the planning loop (`exit_plan_mode`, `task_stop`, `todo_update`,
|
|
188
|
+
* `todo_create`, `ask_user_question`).
|
|
189
|
+
* - `false`: explicitly blocked in plan mode even when sideEffect is
|
|
190
|
+
* `'readonly'`. Rare — useful for read-only tools whose output would
|
|
191
|
+
* leak content the planner should not see.
|
|
192
|
+
*/
|
|
193
|
+
planModeAllowed?: boolean;
|
|
536
194
|
/**
|
|
537
195
|
* FEATURE_149 (v0.7.38) — submit-time interrupt policy. See
|
|
538
196
|
* {@link ToolInterruptBehavior}. Default `'wait'` when undefined.
|
|
539
197
|
*/
|
|
540
198
|
interruptBehavior?: ToolInterruptBehavior;
|
|
199
|
+
/**
|
|
200
|
+
* Progressive disclosure — when `true`, the tool's full description is
|
|
201
|
+
* replaced with `searchHint` (a one-line summary) in the LLM-visible
|
|
202
|
+
* tool schema until the per-session unlock Set marks the tool name as
|
|
203
|
+
* unlocked. Unlocking happens via the `tool_search` tool: the LLM
|
|
204
|
+
* invokes `tool_search` with a query that selects this tool, and the
|
|
205
|
+
* full description + JSON schema are returned in the tool_result text.
|
|
206
|
+
* The next `getActiveToolDefinitions` call for the same session sees
|
|
207
|
+
* the unlock and emits the full description.
|
|
208
|
+
*
|
|
209
|
+
* Use for tools with rich descriptions (>500 bytes) whose teaching
|
|
210
|
+
* content the model only needs to consume when it actually plans to
|
|
211
|
+
* call the tool. Saves turn-1 context without dropping the tool.
|
|
212
|
+
*
|
|
213
|
+
* Mirrors claudecode `Tool.shouldDefer` — see
|
|
214
|
+
* `c:/Works/claudecode/src/tools/Tool.ts` for the parent design and
|
|
215
|
+
* `c:/Works/claudecode/src/tools/ToolSearchTool/` for the bootstrap.
|
|
216
|
+
*/
|
|
217
|
+
shouldDefer?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* One-line hint shown in place of the full description when this tool
|
|
220
|
+
* is deferred and not yet unlocked. Required when `shouldDefer: true`.
|
|
221
|
+
* Should answer "when would I want to look this up" in ≤ 100 chars
|
|
222
|
+
* so the LLM can decide whether to invoke `tool_search` for the full
|
|
223
|
+
* schema. Example: `'Fetch a specific remote URL — use tool_search to load full schema.'`
|
|
224
|
+
*/
|
|
225
|
+
searchHint?: string;
|
|
541
226
|
/**
|
|
542
227
|
* Classifier projection — REQUIRED (FEATURE_092 v0.7.33).
|
|
543
228
|
*
|
|
@@ -643,12 +328,59 @@ declare function getBuiltinToolDefinition(name: string): KodaXToolDefinition | u
|
|
|
643
328
|
declare function getBuiltinRegisteredToolDefinition(name: string): RegisteredToolDefinition | undefined;
|
|
644
329
|
declare function createBuiltinToolDefinition(name: string): LocalToolDefinition | undefined;
|
|
645
330
|
declare function listBuiltinToolDefinitions(): RegisteredToolDefinition[];
|
|
331
|
+
/**
|
|
332
|
+
* v0.7.42 — snapshot of every currently-active tool registration.
|
|
333
|
+
*
|
|
334
|
+
* Returns the most-recent registration for each tool name (mirroring
|
|
335
|
+
* {@link getRegisteredToolDefinition}'s single-name semantics across the
|
|
336
|
+
* full registry). Use this to drive metadata-based filters such as:
|
|
337
|
+
*
|
|
338
|
+
* - SDK embedder permission brokers building a blocklist by side-effect class:
|
|
339
|
+
* `getAllRegisteredTools().filter(t => t.sideEffect !== 'readonly')`
|
|
340
|
+
* - UI that displays available tools grouped by category.
|
|
341
|
+
* - Plan-mode gates that compute their own blocklist from metadata
|
|
342
|
+
* instead of hardcoded `Set<string>` of names.
|
|
343
|
+
*
|
|
344
|
+
* The returned array is a fresh copy per call (safe to mutate without
|
|
345
|
+
* affecting the registry). Order is registration order (sorted by name
|
|
346
|
+
* within each registration to keep the snapshot deterministic).
|
|
347
|
+
*/
|
|
348
|
+
declare function getAllRegisteredTools(): RegisteredToolDefinition[];
|
|
349
|
+
/**
|
|
350
|
+
* v0.7.42 — plan-mode permit check driven by tool metadata.
|
|
351
|
+
*
|
|
352
|
+
* - `sideEffect === 'readonly'` ⇒ permitted (unless explicitly
|
|
353
|
+
* `planModeAllowed: false`).
|
|
354
|
+
* - `planModeAllowed: true` ⇒ permitted (overrides non-readonly).
|
|
355
|
+
* - any other sideEffect ⇒ blocked.
|
|
356
|
+
*
|
|
357
|
+
* Returns `false` for unknown tool names (fail-closed). Use this in
|
|
358
|
+
* preference to hardcoded `Set<string>` of tool names — adding a new
|
|
359
|
+
* `'mutates-fs'` builtin will flow through automatically.
|
|
360
|
+
*/
|
|
361
|
+
declare function isToolPlanModeAllowed(name: string): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* v0.7.42 — does this tool mutate the filesystem?
|
|
364
|
+
*
|
|
365
|
+
* Wraps `sideEffect === 'mutates-fs'`. Used by the REPL permission
|
|
366
|
+
* pipeline's gitRoot guard and Space's permission broker. Replaces the
|
|
367
|
+
* previous practice of hardcoding `Set(["write", "edit"])`-style lookups
|
|
368
|
+
* scattered across 5+ callsites.
|
|
369
|
+
*/
|
|
370
|
+
declare function isToolFileMutation(name: string): boolean;
|
|
371
|
+
/**
|
|
372
|
+
* v0.7.42 — does this tool mutate anything (FS, shell, network, state)?
|
|
373
|
+
*
|
|
374
|
+
* True for every `sideEffect` except `'readonly'`. Fail-closed (unknown
|
|
375
|
+
* names return `true` — assumed mutating until proven otherwise).
|
|
376
|
+
*/
|
|
377
|
+
declare function isToolMutation(name: string): boolean;
|
|
646
378
|
declare function getRequiredToolParams(name: string): string[];
|
|
647
379
|
declare function listTools(): string[];
|
|
648
380
|
declare function listToolDefinitions(): KodaXToolDefinition[];
|
|
649
381
|
declare function executeTool(name: string, input: Record<string, unknown>, ctx: KodaXToolExecutionContext): Promise<string>;
|
|
650
382
|
|
|
651
|
-
declare function toolRead(input: Record<string, unknown>, ctx: KodaXToolExecutionContext): Promise<string>;
|
|
383
|
+
declare function toolRead(input: Record<string, unknown>, ctx: KodaXToolExecutionContext): Promise<string | readonly KodaXToolResultContentItem[]>;
|
|
652
384
|
|
|
653
385
|
declare function toolWrite(input: Record<string, unknown>, ctx: KodaXToolExecutionContext): Promise<string>;
|
|
654
386
|
|
|
@@ -726,6 +458,291 @@ declare function toolCodeSearch(input: Record<string, unknown>, ctx: KodaXToolEx
|
|
|
726
458
|
|
|
727
459
|
declare function toolSemanticLookup(input: Record<string, unknown>, ctx: KodaXToolExecutionContext): Promise<string>;
|
|
728
460
|
|
|
461
|
+
/**
|
|
462
|
+
* KodaX Constructed-World types (FEATURE_087, v0.7.28).
|
|
463
|
+
*
|
|
464
|
+
* Runtime-generated capabilities (tools / agents / skills / ...) live in
|
|
465
|
+
* `.kodax/constructed/` and are loaded into the same registries as builtin
|
|
466
|
+
* primitives. v0.7.28 only ships tool generation (FEATURE_088); other kinds
|
|
467
|
+
* land in FEATURE_089 / FEATURE_090.
|
|
468
|
+
*
|
|
469
|
+
* Cross-references:
|
|
470
|
+
* - DD §14 — lifecycle, security model, registry merge semantics.
|
|
471
|
+
* - docs/features/v0.7.28.md — capability schema, generation flow.
|
|
472
|
+
*/
|
|
473
|
+
/**
|
|
474
|
+
* Handler script source. v0.7.28 limits language to `'javascript'` so that
|
|
475
|
+
* `loadHandler()` can `await import()` the file directly without an
|
|
476
|
+
* intermediate TS → JS compile step (no esbuild / tsx dependency).
|
|
477
|
+
*
|
|
478
|
+
* TypeScript handlers are explicitly out of scope; Coding Agent generates
|
|
479
|
+
* JS strings on the wire.
|
|
480
|
+
*/
|
|
481
|
+
interface ScriptSource {
|
|
482
|
+
readonly kind: 'script';
|
|
483
|
+
readonly language: 'javascript';
|
|
484
|
+
readonly code: string;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Capability declaration.
|
|
488
|
+
*
|
|
489
|
+
* v0.7.28 ships the single-dimension form: a whitelist of builtin tool
|
|
490
|
+
* names that the handler may invoke through `ctx.tools.<name>(...)`.
|
|
491
|
+
* All I/O — fs / net / env — must flow through builtin tools (`read` /
|
|
492
|
+
* `write` / `bash` / etc.); handlers do not receive direct `ctx.fs` /
|
|
493
|
+
* `ctx.net` / `ctx.env` entry points.
|
|
494
|
+
*
|
|
495
|
+
* Forward-compatible evolution: if the future demands path/domain-level
|
|
496
|
+
* constraints, this can grow to `(string | { name; constraints })[]`
|
|
497
|
+
* without breaking existing manifests.
|
|
498
|
+
*/
|
|
499
|
+
interface Capabilities {
|
|
500
|
+
readonly tools: readonly string[];
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Tool-kind artifact body (the `content` of `ConstructionArtifact` when
|
|
504
|
+
* `kind === 'tool'`).
|
|
505
|
+
*/
|
|
506
|
+
interface ToolContent {
|
|
507
|
+
readonly description: string;
|
|
508
|
+
readonly inputSchema: Record<string, unknown>;
|
|
509
|
+
readonly capabilities: Capabilities;
|
|
510
|
+
readonly handler: ScriptSource;
|
|
511
|
+
/**
|
|
512
|
+
* Per-tool timeout override. Defaults to {@link DEFAULT_HANDLER_TIMEOUT_MS}
|
|
513
|
+
* when omitted. Bounded by AbortController in `loadHandler()`.
|
|
514
|
+
*/
|
|
515
|
+
readonly timeoutMs?: number;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Default handler timeout. Picked to match the historical ceiling on
|
|
519
|
+
* builtin streaming tools (30s); revisit if a constructed tool demands
|
|
520
|
+
* longer-running computation.
|
|
521
|
+
*/
|
|
522
|
+
declare const DEFAULT_HANDLER_TIMEOUT_MS = 30000;
|
|
523
|
+
/**
|
|
524
|
+
* Lifecycle state on disk. Drives both the startup glob filter and the
|
|
525
|
+
* `revoke()` semantics. See DD §14.1 — file system is the single source
|
|
526
|
+
* of truth; no separate `_manifest.json` index file (C4 decision).
|
|
527
|
+
*/
|
|
528
|
+
type ArtifactStatus = 'staged' | 'active' | 'revoked';
|
|
529
|
+
/**
|
|
530
|
+
* Reference to a tool by stable id. v0.7.31 (FEATURE_089) introduces
|
|
531
|
+
* Agent manifests that bundle tool refs rather than inline tool bodies;
|
|
532
|
+
* the resolver expands these refs to concrete `KodaXToolDefinition`
|
|
533
|
+
* instances at activate time.
|
|
534
|
+
*
|
|
535
|
+
* `ref` shape:
|
|
536
|
+
* - `builtin:<name>` — a tool from the static registry
|
|
537
|
+
* (e.g. `builtin:read`, `builtin:bash`)
|
|
538
|
+
* - `constructed:<name>@<ver>` — a previously-activated constructed tool
|
|
539
|
+
*/
|
|
540
|
+
interface ToolRef {
|
|
541
|
+
readonly ref: string;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Reference to a Guardrail by stable id. The Layer A `Guardrail`
|
|
545
|
+
* declaration is name-only (no runtime hooks); resolvers map known
|
|
546
|
+
* names to constructed `ToolGuardrail` / `InputGuardrail` /
|
|
547
|
+
* `OutputGuardrail` instances at activation time.
|
|
548
|
+
*/
|
|
549
|
+
interface GuardrailRef {
|
|
550
|
+
readonly kind: 'input' | 'output' | 'tool';
|
|
551
|
+
readonly ref: string;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Reference to a handoff target by stable id (another constructed agent
|
|
555
|
+
* or a builtin role). The resolver expands `target.ref` to the actual
|
|
556
|
+
* `Agent` declaration at admission time so the handoff DAG check
|
|
557
|
+
* (`handoffLegality` invariant) sees the full graph.
|
|
558
|
+
*/
|
|
559
|
+
interface AgentHandoffRef {
|
|
560
|
+
readonly target: {
|
|
561
|
+
readonly ref: string;
|
|
562
|
+
};
|
|
563
|
+
readonly kind: 'continuation' | 'as-tool';
|
|
564
|
+
readonly description?: string;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Reasoning profile declaration mirroring the Layer A
|
|
568
|
+
* `AgentReasoningProfile`. Kept structurally identical so the resolver
|
|
569
|
+
* passes the value through without re-shaping.
|
|
570
|
+
*/
|
|
571
|
+
interface AgentReasoningRef {
|
|
572
|
+
readonly default: 'quick' | 'balanced' | 'deep';
|
|
573
|
+
readonly max?: 'quick' | 'balanced' | 'deep';
|
|
574
|
+
readonly escalateOnRevise?: boolean;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Sandbox test case. Used by `sandbox_test_agent` to verify a
|
|
578
|
+
* constructed agent before it can activate. Each case feeds `input`
|
|
579
|
+
* to a sandbox Runner instance and grades the agent's final output:
|
|
580
|
+
*
|
|
581
|
+
* - `expectMatch` — final text must match this regex (string form)
|
|
582
|
+
* - `expectNotMatch` — final text must NOT match this regex
|
|
583
|
+
* - `expectFinalText` — exact substring match (case-sensitive)
|
|
584
|
+
*
|
|
585
|
+
* At least one of the three expect-fields must be present; the cases
|
|
586
|
+
* are graded by `runSandboxAgentTest()` (FEATURE_089 Phase 3.5).
|
|
587
|
+
*/
|
|
588
|
+
interface AgentTestCase {
|
|
589
|
+
readonly id: string;
|
|
590
|
+
readonly input: string;
|
|
591
|
+
readonly expectMatch?: string;
|
|
592
|
+
readonly expectNotMatch?: string;
|
|
593
|
+
readonly expectFinalText?: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Agent-kind artifact body (the `content` of `ConstructionArtifact`
|
|
597
|
+
* when `kind === 'agent'`).
|
|
598
|
+
*
|
|
599
|
+
* FEATURE_089 (v0.7.31): all fields except `instructions` are optional;
|
|
600
|
+
* a minimal "echo agent" can be expressed as `{ instructions: '...' }`.
|
|
601
|
+
* Tool / handoff / guardrail refs are resolved at admission time
|
|
602
|
+
* (Runner.admit's 5-step audit expands them and feeds the resolved
|
|
603
|
+
* Agent through the invariant chain).
|
|
604
|
+
*/
|
|
605
|
+
interface AgentContent {
|
|
606
|
+
readonly instructions: string;
|
|
607
|
+
readonly tools?: readonly ToolRef[];
|
|
608
|
+
readonly handoffs?: readonly AgentHandoffRef[];
|
|
609
|
+
readonly reasoning?: AgentReasoningRef;
|
|
610
|
+
readonly guardrails?: readonly GuardrailRef[];
|
|
611
|
+
readonly model?: string;
|
|
612
|
+
readonly provider?: string;
|
|
613
|
+
/**
|
|
614
|
+
* FEATURE_191 — one-sentence human-readable summary surfaced in the
|
|
615
|
+
* Worker system prompt's `=== Available specialist agents ===`
|
|
616
|
+
* block (FEATURE_191 A.3) and in `/agents list` UIs. Frontmatter
|
|
617
|
+
* `description` field of `~/.kodax/agents/<name>.md` and the
|
|
618
|
+
* `name`-paired argument of `KodaXExtensionAPI.registerAgent`
|
|
619
|
+
* funnel into this field. Optional for backward compatibility with
|
|
620
|
+
* FEATURE_089 minimal-agent shape (`{ instructions: '...' }`);
|
|
621
|
+
* the SP block renders `(no description)` when absent.
|
|
622
|
+
*/
|
|
623
|
+
readonly description?: string;
|
|
624
|
+
/**
|
|
625
|
+
* Optional structured-output schema mirroring `Agent.outputSchema`.
|
|
626
|
+
* Pure pass-through to the runtime — admission does not validate
|
|
627
|
+
* shape semantics here, only well-formed JSON.
|
|
628
|
+
*/
|
|
629
|
+
readonly outputSchema?: Record<string, unknown>;
|
|
630
|
+
/**
|
|
631
|
+
* Optional sandbox test cases. When present, `sandbox_test_agent`
|
|
632
|
+
* runs them; when absent, the test step performs only the static
|
|
633
|
+
* checks (manifest schema + admission audit).
|
|
634
|
+
*/
|
|
635
|
+
readonly testCases?: readonly AgentTestCase[];
|
|
636
|
+
/**
|
|
637
|
+
* Maximum total budget (iteration count) the agent may consume.
|
|
638
|
+
* Plumbed onto the resolved `AgentManifest.maxBudget` and clamped by
|
|
639
|
+
* `budgetCeiling` invariant during admission.
|
|
640
|
+
*/
|
|
641
|
+
readonly maxBudget?: number;
|
|
642
|
+
/**
|
|
643
|
+
* Voluntary additional invariants the LLM declares this agent
|
|
644
|
+
* commits to. Plumbed onto `AgentManifest.declaredInvariants`;
|
|
645
|
+
* unioned on top of the required set during admission.
|
|
646
|
+
*/
|
|
647
|
+
readonly declaredInvariants?: readonly string[];
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Persisted artifact shape (one JSON file per name/version under
|
|
651
|
+
* `.kodax/constructed/<kind>s/<name>/<version>.json`).
|
|
652
|
+
*
|
|
653
|
+
* Discriminated union over `kind`:
|
|
654
|
+
* - `kind: 'tool'` — v0.7.28 (FEATURE_088) tool generation
|
|
655
|
+
* - `kind: 'agent'` — v0.7.31 (FEATURE_089) agent generation; passes
|
|
656
|
+
* through `Runner.admit()` at activation time
|
|
657
|
+
*
|
|
658
|
+
* Lifecycle fields (status / timestamps / contentHash / sourceAgent /
|
|
659
|
+
* signedBy) are common to all kinds.
|
|
660
|
+
*/
|
|
661
|
+
type ConstructionArtifact = ToolArtifact | AgentArtifact;
|
|
662
|
+
interface ConstructionArtifactBase {
|
|
663
|
+
readonly name: string;
|
|
664
|
+
readonly version: string;
|
|
665
|
+
status: ArtifactStatus;
|
|
666
|
+
readonly signedBy?: string;
|
|
667
|
+
readonly createdAt: number;
|
|
668
|
+
readonly sourceAgent?: string;
|
|
669
|
+
testedAt?: number;
|
|
670
|
+
activatedAt?: number;
|
|
671
|
+
revokedAt?: number;
|
|
672
|
+
/**
|
|
673
|
+
* SHA-256 of `JSON.stringify(content)` captured at activate time.
|
|
674
|
+
* `rehydrateActiveArtifacts()` recomputes and compares — a mismatch
|
|
675
|
+
* indicates the manifest was edited between activation and the next
|
|
676
|
+
* boot (naive cross-session tampering, e.g. an LLM rewriting the .json
|
|
677
|
+
* via the Write tool without recomputing the hash). Mismatched
|
|
678
|
+
* artifacts are skipped at rehydrate with a stderr warning. This is
|
|
679
|
+
* NOT a defense against a coordinated attacker who recomputes the
|
|
680
|
+
* hash; the threat model is single-user CLI integrity, not multi-user
|
|
681
|
+
* supply chain.
|
|
682
|
+
*/
|
|
683
|
+
contentHash?: string;
|
|
684
|
+
}
|
|
685
|
+
interface ToolArtifact extends ConstructionArtifactBase {
|
|
686
|
+
readonly kind: 'tool';
|
|
687
|
+
readonly content: ToolContent;
|
|
688
|
+
}
|
|
689
|
+
interface AgentArtifact extends ConstructionArtifactBase {
|
|
690
|
+
readonly kind: 'agent';
|
|
691
|
+
readonly content: AgentContent;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Returned by {@link ConstructionRuntime.stage}; opaque handle that
|
|
695
|
+
* downstream `test()` / `activate()` calls bind to.
|
|
696
|
+
*/
|
|
697
|
+
interface StagedHandle {
|
|
698
|
+
readonly artifact: ConstructionArtifact;
|
|
699
|
+
readonly stagedAt: number;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Outcome of {@link ConstructionRuntime.test}. `ok=false` blocks
|
|
703
|
+
* activation; `warnings` surface but do not block.
|
|
704
|
+
*/
|
|
705
|
+
interface TestResult {
|
|
706
|
+
readonly ok: boolean;
|
|
707
|
+
readonly errors?: readonly string[];
|
|
708
|
+
readonly warnings?: readonly string[];
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Policy gate — invoked once per `activate()` before the artifact is
|
|
712
|
+
* registered. Default rejects implicit auto-approval; the REPL surface
|
|
713
|
+
* binds a dialog-based policy in `packages/repl/src/common/construction-
|
|
714
|
+
* bootstrap.ts` so user approval flows through the live askUser channel.
|
|
715
|
+
*
|
|
716
|
+
* Modeled as a function type rather than an interface (D3 decision):
|
|
717
|
+
* keeps the contract surface tiny, no class boilerplate.
|
|
718
|
+
*
|
|
719
|
+
* No declarative `kodax.config.ts` override hatch is provided — see the
|
|
720
|
+
* "Deferred Design Decisions" section in `features/v0.7.28.md` for why
|
|
721
|
+
* a `risk_mode` enum (when truly needed) is preferred over user-authored
|
|
722
|
+
* policy functions.
|
|
723
|
+
*/
|
|
724
|
+
type ConstructionPolicy = (artifact: ConstructionArtifact) => Promise<ConstructionPolicyVerdict>;
|
|
725
|
+
type ConstructionPolicyVerdict = 'approve' | 'reject' | 'ask-user';
|
|
726
|
+
/** Default policy: always ask the user; no implicit approvals. */
|
|
727
|
+
declare const defaultPolicy: ConstructionPolicy;
|
|
728
|
+
/**
|
|
729
|
+
* Thrown by `CtxProxy` when handler attempts to access a tool not declared
|
|
730
|
+
* in `capabilities.tools`. Caught in tracer; surfaces as a tool error.
|
|
731
|
+
*/
|
|
732
|
+
declare class CapabilityDeniedError extends Error {
|
|
733
|
+
readonly toolName: string;
|
|
734
|
+
readonly declaredTools: readonly string[];
|
|
735
|
+
constructor(toolName: string, declaredTools: readonly string[]);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Thrown when a manifest cannot be parsed / is missing required fields.
|
|
739
|
+
* Surfaces during stage() / startup glob; tracer records details.
|
|
740
|
+
*/
|
|
741
|
+
declare class ConstructionManifestError extends Error {
|
|
742
|
+
readonly path?: string;
|
|
743
|
+
constructor(message: string, path?: string);
|
|
744
|
+
}
|
|
745
|
+
|
|
729
746
|
interface ExecOptions {
|
|
730
747
|
/** Extra environment variables to inject (merged with safe base env). */
|
|
731
748
|
readonly env?: Readonly<Record<string, string>>;
|
|
@@ -907,6 +924,51 @@ interface ExtensionTurnSettleHookContext {
|
|
|
907
924
|
setModelSelection: (next: ExtensionModelSelection) => void;
|
|
908
925
|
setThinkingLevel: (level: KodaXReasoningMode) => void;
|
|
909
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* FEATURE_184 (v0.7.45) — Stop Hook bridge context for extensions.
|
|
929
|
+
*
|
|
930
|
+
* Fires ONLY when the model terminates a turn text-only (no tool_use)
|
|
931
|
+
* — a strict subset of `turn:settle`, which fires on every turn end
|
|
932
|
+
* including mid-task tool turns. Use this hook for verification or
|
|
933
|
+
* "is the task actually done?" checks. The three-state return surface
|
|
934
|
+
* mirrors `RunOptions.stopHook` at the agent layer; the bridge passes
|
|
935
|
+
* the extension's return through unchanged.
|
|
936
|
+
*
|
|
937
|
+
* Coding-layer first-party consumers (Sidecar Verifier, FEATURE_184
|
|
938
|
+
* Phase D) wire directly to the agent `stopHook`. Third-party
|
|
939
|
+
* extensions write `api.hook('turn:complete', handler)` and the bridge
|
|
940
|
+
* dispatches to them inside the agent's `stopHook` callback. Handlers
|
|
941
|
+
* fire in registration order, first non-`void` return short-circuits
|
|
942
|
+
* the chain (matches `tool:before` semantics).
|
|
943
|
+
*
|
|
944
|
+
* Scope note: this hook fires on the AMA `runner-driven` path only
|
|
945
|
+
* (main loop, B1 retry, V2 worker). SA-path child agents dispatched
|
|
946
|
+
* via `dispatch_child_task` go through `runKodaX` and do NOT trigger
|
|
947
|
+
* this hook — observe their lifecycle via `turn:settle` on the SA
|
|
948
|
+
* path. Extensions wanting "every agent termination" semantics must
|
|
949
|
+
* register both hooks.
|
|
950
|
+
*/
|
|
951
|
+
interface ExtensionTurnCompleteHookContext {
|
|
952
|
+
sessionId: string;
|
|
953
|
+
lastAssistantText: string;
|
|
954
|
+
signal: 'natural-end';
|
|
955
|
+
reanimateCount: number;
|
|
956
|
+
reanimateBudget: number;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* FEATURE_184 (v0.7.45) — Extension `turn:complete` return surface.
|
|
960
|
+
*
|
|
961
|
+
* - `void` / `undefined` → accept the termination, defer to next
|
|
962
|
+
* handler (or fall through to agent terminal path if none).
|
|
963
|
+
* - `string` → reanimate: synthesize a user message, run another
|
|
964
|
+
* turn. Bounded by Runner's `stopHookReanimateBudget`.
|
|
965
|
+
* - `{ abort: true, reason }` → halt the run, surface reason to
|
|
966
|
+
* caller via `RunResult.output` + `stoppedByHook = true`.
|
|
967
|
+
*/
|
|
968
|
+
type ExtensionTurnCompleteHookResult = void | string | {
|
|
969
|
+
readonly abort: true;
|
|
970
|
+
readonly reason: string;
|
|
971
|
+
};
|
|
910
972
|
interface ExtensionSessionHydrateHookContext {
|
|
911
973
|
sessionId: string;
|
|
912
974
|
getState: <T = KodaXJsonValue>(key: string) => T | undefined;
|
|
@@ -1018,9 +1080,14 @@ type TodoMutationSource = 'tool' | 'internal';
|
|
|
1018
1080
|
* FEATURE_170 v0.7.41 — seed shape passed to `'todo:before-create'`.
|
|
1019
1081
|
* Mirrors `TodoAddSeed` from todo-store.ts (kept structurally compatible
|
|
1020
1082
|
* to avoid coupling extension authors to the internal task-engine type).
|
|
1083
|
+
*
|
|
1084
|
+
* v0.7.42 — `content` renamed to `subject` + optional `description` to
|
|
1085
|
+
* match claudecode V2 `TaskCreateTool` schema. See `TodoItem` JSDoc in
|
|
1086
|
+
* packages/coding/src/types.ts.
|
|
1021
1087
|
*/
|
|
1022
1088
|
interface ExtensionTodoCreateSeed {
|
|
1023
|
-
readonly
|
|
1089
|
+
readonly subject: string;
|
|
1090
|
+
readonly description?: string;
|
|
1024
1091
|
readonly activeForm?: string;
|
|
1025
1092
|
readonly evaluator?: 'build' | 'test' | 'lint';
|
|
1026
1093
|
readonly owner?: string;
|
|
@@ -1040,7 +1107,9 @@ interface ExtensionTodoCreateSeed {
|
|
|
1040
1107
|
*/
|
|
1041
1108
|
interface KodaXTodoItem {
|
|
1042
1109
|
readonly id: string;
|
|
1043
|
-
|
|
1110
|
+
/** v0.7.42 — see TodoItem.subject JSDoc in packages/coding/src/types.ts. */
|
|
1111
|
+
readonly subject: string;
|
|
1112
|
+
readonly description?: string;
|
|
1044
1113
|
readonly status: 'pending' | 'in_progress' | 'completed' | 'failed' | 'skipped' | 'cancelled';
|
|
1045
1114
|
readonly owner?: string;
|
|
1046
1115
|
readonly sourceObligationIndex?: number;
|
|
@@ -1053,6 +1122,7 @@ interface ExtensionHookMap {
|
|
|
1053
1122
|
'tool:before': (context: ExtensionToolBeforeHookContext) => Promise<void | string | false> | void | string | false;
|
|
1054
1123
|
'provider:before': (context: ExtensionProviderBeforeHookContext) => Promise<void> | void;
|
|
1055
1124
|
'turn:settle': (context: ExtensionTurnSettleHookContext) => Promise<void> | void;
|
|
1125
|
+
'turn:complete': (context: ExtensionTurnCompleteHookContext) => Promise<ExtensionTurnCompleteHookResult> | ExtensionTurnCompleteHookResult;
|
|
1056
1126
|
'session:hydrate': (context: ExtensionSessionHydrateHookContext) => Promise<void> | void;
|
|
1057
1127
|
'todo:before-create': (context: {
|
|
1058
1128
|
seed: ExtensionTodoCreateSeed;
|
|
@@ -1086,6 +1156,53 @@ interface KodaXExtensionAPI {
|
|
|
1086
1156
|
registerCapabilityProvider: (provider: CapabilityProvider) => () => void;
|
|
1087
1157
|
registerCommand: (command: ExtensionCommandDefinition) => () => void;
|
|
1088
1158
|
registerSkillPath: (skillPath: string) => () => void;
|
|
1159
|
+
/**
|
|
1160
|
+
* FEATURE_191 (v0.7.43) — register a constructed agent at extension
|
|
1161
|
+
* activate time. The extension supplies the agent name and an
|
|
1162
|
+
* `AgentContent` body (instructions + optional tools/handoffs/
|
|
1163
|
+
* reasoning/model/description); the runtime threads it through
|
|
1164
|
+
* `buildAdmissionManifest` + `Runner.admit` and registers the
|
|
1165
|
+
* activated Agent via `registerConstructedAgent({ source:
|
|
1166
|
+
* 'extension' })`. The returned dispose fn (also auto-pushed onto
|
|
1167
|
+
* the extension's disposables list) unregisters the agent on
|
|
1168
|
+
* extension deactivate.
|
|
1169
|
+
*
|
|
1170
|
+
* Returns `Promise<() => void>` — **you MUST `await` the call**
|
|
1171
|
+
* before invoking the dispose function. Unlike sibling
|
|
1172
|
+
* `registerTool` (sync), this is async because `Runner.admit` is
|
|
1173
|
+
* declared async (FEATURE_101 admission contract — admission may
|
|
1174
|
+
* consult disk for handoff-target staged-agent resolution).
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* // CORRECT — await unwraps the Promise to a sync dispose
|
|
1179
|
+
* export default async function activate(api: KodaXExtensionAPI) {
|
|
1180
|
+
* const dispose = await api.registerAgent('db-reviewer', {
|
|
1181
|
+
* instructions: 'You review DB migrations.',
|
|
1182
|
+
* description: 'DB migration reviewer',
|
|
1183
|
+
* });
|
|
1184
|
+
* // dispose() is now callable on demand; the runtime also auto-
|
|
1185
|
+
* // disposes via the extension's disposables list at deactivate.
|
|
1186
|
+
* }
|
|
1187
|
+
* ```
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```ts
|
|
1191
|
+
* // WRONG — TypeScript catches this; .js / @ts-ignore consumers
|
|
1192
|
+
* // hit a runtime TypeError because Promise is not a function.
|
|
1193
|
+
* export default function activate(api: KodaXExtensionAPI) {
|
|
1194
|
+
* const dispose = api.registerAgent('x', { instructions: '...' });
|
|
1195
|
+
* dispose(); // TypeError: dispose is not a function
|
|
1196
|
+
* }
|
|
1197
|
+
* ```
|
|
1198
|
+
*
|
|
1199
|
+
* Throws on admission rejection (with the verdict reason) so the
|
|
1200
|
+
* extension author sees the failure at activate time rather than
|
|
1201
|
+
* having a silently-dropped registration. The throw also halts
|
|
1202
|
+
* extension loading — the extension's other registrations roll back
|
|
1203
|
+
* via `LoadedExtensionRecord.disposables` reverse-iterate.
|
|
1204
|
+
*/
|
|
1205
|
+
registerAgent: (name: string, content: AgentContent) => Promise<() => void>;
|
|
1089
1206
|
on: <TEvent extends keyof ExtensionEventMap>(event: TEvent, handler: (payload: ExtensionEventMap[TEvent]) => Promise<void> | void) => () => void;
|
|
1090
1207
|
hook: <THook extends keyof ExtensionHookMap>(hook: THook, handler: ExtensionHookMap[THook]) => () => void;
|
|
1091
1208
|
logger: ExtensionLogger;
|
|
@@ -1508,7 +1625,7 @@ declare function warmRepoIntelligenceRuntime(options?: {
|
|
|
1508
1625
|
trace?: boolean;
|
|
1509
1626
|
}): Promise<RepoIntelligenceRuntimeWarmResult>;
|
|
1510
1627
|
|
|
1511
|
-
declare const SYSTEM_PROMPT = "You are KodaX, a helpful multi-provider coding agent. You can read, write, and edit files, and execute shell commands.\n\n## Error Handling\n\nWhen a tool call returns an error:\n1. STOP and READ the error message carefully\n2. DO NOT repeat the same tool call with the same parameters\n3. Identify what's wrong (missing parameter? wrong type? wrong path?)\n4. Fix the issue BEFORE making another tool call\n5. Common errors:\n - \"Missing required parameter 'X'\" -> Add the missing parameter to your JSON\n - \"File not found\" -> Check the path with read or glob first\n - \"String not found\" -> Read the file again to see exact content\n\nWhen a shell command fails, prefer this recovery order:\n1. Check whether a specialized tool can solve the task directly\n2. Fix the command itself (quoting, workdir, platform-specific command, smaller scope)\n3. Split the task into smaller read/edit/write steps\n4. Only create a helper script when repeated inline commands are clearly less safe or less maintainable\n\n## Editing Files\n\n- Always read the file first to understand its current content\n- Make precise, targeted edits rather than rewriting entire files\n- Preserve the existing code style and formatting\n- Do not create new files unless the user asks for one or the task genuinely needs one. Prefer editing an existing file to creating a new one, as this prevents file bloat and keeps each tool call small\n- When a modification is scoped to an existing file, ALWAYS prefer `edit` over `write`. Only fall back to `write` when no file exists yet or the user explicitly requested a complete rewrite\n\n## Tool Usage\n\nPrefer specialized tools over shell for file operations:\n- Use read to view files instead of cat, head, or tail\n- Use edit to modify existing files instead of sed or awk when possible\n- Use write to create new files instead of echo redirection or heredocs\n- Use glob or grep for file discovery and content search before falling back to shell\n- When multiple read-only tool calls are independent, emit them in the same response so parallel mode can run them together\n- Only serialize tool calls when a later call depends on an earlier result\n- Keep parallel batches focused: prefer a few narrow grep/read/diff calls over many tiny sequential probes\n\nRead is intentionally bounded:\n- A single read call only returns a limited slice of a file\n- For large files, continue with offset/limit instead of retrying a whole-file read\n- Prefer grep first, then read the specific section you need\n\nTool outputs are also bounded:\n- Large bash output may be truncated to the tail\n- Large grep results and diffs may be summarized\n- When you see a truncation hint, narrow the next tool call instead of repeating the same broad request\n- If edit fails to find a stable anchor, do not rewrite the entire existing file with write; retry with a smaller unique edit anchor or use insert_after_anchor for section appends\n\nIf you truly need a script:\n- Do NOT create temporary scripts or scratch files in the project root\n- Do NOT place them at `.agent/` top level \u2014 that directory is reserved for system-managed artifacts (managed-tasks/, project/, repo-intelligence/, etc.)\n- Write them to `.agent/tmp/` (relative to the git root). This is the designated ephemeral workspace; files there can be safely cleaned up later\n- Alternatively, use the system temp directory if the script does not need to be inspectable from the project\n- Treat helper scripts as a last resort, not the default recovery path\n\n## Shell Commands\n\n- Be careful with destructive operations\n- Reserve shell commands for terminal operations such as git, package managers, builds, tests, and system commands\n- Prefer read-only operations when possible\n- For file edits, prefer read/edit/write over shell transforms unless shell scripting is genuinely more efficient\n\n### Cross-Platform Notes\n\nDifferent platforms have different commands:\n- Move: `move` (Windows) vs `mv` (Unix/Mac)\n- List: `dir` (Windows) vs `ls` (Unix/Mac)\n- Delete: `del` (Windows) vs `rm` (Unix/Mac)\n\n**IMPORTANT: Directories are created automatically by the `write` tool.**\n- NEVER use `mkdir` before writing files - the write tool handles directory creation\n- If you truly need an empty directory: `mkdir dir` (Windows) or `mkdir -p dir` (Unix)\n\nIf you see \"not recognized\", \"\u4E0D\u662F\u5185\u90E8\u6216\u5916\u90E8\u547D\u4EE4\", or a similar shell lookup error, the command does not exist on this platform. Try the platform equivalent.\n\n## Multi-step Tasks\n\n- Track your progress by listing what you've done and what's next\n- Break complex tasks into smaller steps\n- Summarize progress periodically\n\n## Plan Before Action\n\nFor any non-trivial task (creating files, editing code, running complex commands):\n1. First explain your understanding of the task\n2. Outline your approach (what files, what changes, what order)\n3. Consider potential issues (edge cases, dependencies, conflicts)\n4. Then execute step by step\n\nFor simple read-only tasks (reading a file, listing directory), just do it directly.\n\nIf the environment is currently in a read-only planning mode:\n- Do not try to write files or run mutating shell commands during planning\n- Finish the plan first\n- After the plan is complete, use `ask_user_question` to ask whether the user wants to proceed with implementation\n- If the user confirms, call `set_permission_mode` with `mode: \"accept-edits\"` to switch to implementation mode\n- If the user declines, stay in plan mode \u2014 do NOT call `set_permission_mode`\n\n## Asking User Questions\n\nWhen you need the user to make decisions, use `ask_user_question`.\n- For **multiple independent questions**, use the `questions` array (
|
|
1628
|
+
declare const SYSTEM_PROMPT = "You are KodaX, a helpful multi-provider coding agent. You can read, write, and edit files, and execute shell commands.\n\n## Error Handling\n\nWhen a tool call returns an error:\n1. STOP and READ the error message carefully\n2. DO NOT repeat the same tool call with the same parameters \u2014 a re-issue with identical params almost always lands in a retry loop that wastes tokens without producing new information. Vary the params or switch to a different tool\n3. Identify what's wrong (missing parameter? wrong type? wrong path?)\n4. Fix the issue BEFORE making another tool call\n5. Common errors:\n - \"Missing required parameter 'X'\" -> Add the missing parameter to your JSON\n - \"File not found\" -> Check the path with read or glob first\n - \"String not found\" -> Read the file again to see exact content\n\nWhen a shell command fails, prefer this recovery order:\n1. Check whether a specialized tool can solve the task directly\n2. Fix the command itself (quoting, workdir, platform-specific command, smaller scope)\n3. Split the task into smaller read/edit/write steps\n4. Only create a helper script when repeated inline commands are clearly less safe or less maintainable\n\n## Editing Files\n\n- Always read the file first to understand its current content\n- Make precise, targeted edits rather than rewriting entire files\n- Preserve the existing code style and formatting\n- Do not create new files unless the user asks for one or the task genuinely needs one. Prefer editing an existing file to creating a new one, as this prevents file bloat and keeps each tool call small\n- When a modification is scoped to an existing file, ALWAYS prefer `edit` over `write`. Only fall back to `write` when no file exists yet or the user explicitly requested a complete rewrite\n\n## Tool Usage\n\nPrefer specialized tools over shell for file operations:\n- Use read to view files instead of cat, head, or tail\n- Use edit to modify existing files instead of sed or awk when possible\n- Use write to create new files instead of echo redirection or heredocs\n- Use glob or grep for file discovery and content search before falling back to shell\n- When multiple read-only tool calls are independent, emit them in the same response so parallel mode can run them together\n- Only serialize tool calls when a later call depends on an earlier result\n- Keep parallel batches focused: prefer a few narrow grep/read/diff calls over many tiny sequential probes\n\nRead is intentionally bounded:\n- A single read call only returns a limited slice of a file\n- For large files, continue with offset/limit instead of retrying a whole-file read\n- Prefer grep first, then read the specific section you need\n\nTool outputs are also bounded:\n- Large bash output may be truncated to the tail\n- Large grep results and diffs may be summarized\n- When you see a truncation hint, narrow the next tool call instead of repeating the same broad request\n- If edit fails to find a stable anchor, do not rewrite the entire existing file with write; retry with a smaller unique edit anchor or use insert_after_anchor for section appends\n\nIf you truly need a script:\n- Do NOT create temporary scripts or scratch files in the project root \u2014 they leak into `git status` and file listings, confusing the user about what was actually changed\n- Do NOT place them at `.agent/` top level \u2014 that directory is reserved for system-managed artifacts (managed-tasks/, project/, repo-intelligence/, etc.)\n- Write them to `.agent/tmp/` (relative to the git root). This is the designated ephemeral workspace; files there can be safely cleaned up later\n- Alternatively, use the system temp directory if the script does not need to be inspectable from the project\n- Treat helper scripts as a last resort, not the default recovery path\n\n## Shell Commands\n\n- Be careful with destructive operations\n- Reserve shell commands for terminal operations such as git, package managers, builds, tests, and system commands\n- Prefer read-only operations when possible\n- For file edits, prefer read/edit/write over shell transforms unless shell scripting is genuinely more efficient\n\n### Cross-Platform Notes\n\nDifferent platforms have different commands:\n- Move: `move` (Windows) vs `mv` (Unix/Mac)\n- List: `dir` (Windows) vs `ls` (Unix/Mac)\n- Delete: `del` (Windows) vs `rm` (Unix/Mac)\n\n**IMPORTANT: Directories are created automatically by the `write` tool.**\n- NEVER use `mkdir` before writing files - the write tool handles directory creation\n- If you truly need an empty directory: `mkdir dir` (Windows) or `mkdir -p dir` (Unix)\n\nIf you see \"not recognized\", \"\u4E0D\u662F\u5185\u90E8\u6216\u5916\u90E8\u547D\u4EE4\", or a similar shell lookup error, the command does not exist on this platform. Try the platform equivalent.\n\n## Multi-step Tasks\n\n- Track your progress by listing what you've done and what's next\n- Break complex tasks into smaller steps\n- Summarize progress periodically\n\n## Plan Before Action\n\nFor any non-trivial task (creating files, editing code, running complex commands):\n1. First explain your understanding of the task\n2. Outline your approach (what files, what changes, what order)\n3. Consider potential issues (edge cases, dependencies, conflicts)\n4. Then execute step by step\n\nFor simple read-only tasks (reading a file, listing directory), just do it directly.\n\nIf the environment is currently in a read-only planning mode:\n- Do not try to write files or run mutating shell commands during planning\n- Finish the plan first\n- After the plan is complete, use `ask_user_question` to ask whether the user wants to proceed with implementation\n- If the user confirms, call `set_permission_mode` with `mode: \"accept-edits\"` to switch to implementation mode\n- If the user declines, stay in plan mode \u2014 do NOT call `set_permission_mode`\n\n## Asking User Questions\n\nWhen you need the user to make decisions, use `ask_user_question`.\n- For **multiple independent questions**, use the `questions` array (the schema accepts up to 4 items per call \u2014 if you need more, ask the additional ones in a follow-up turn). Each question has its own `question`, `header`, `options`, and optional `multi_select`. The user answers each question separately. Do NOT combine multiple questions into a single question string with pre-combined option combinations, because that forces the user to mentally disambiguate combinations and breaks the option-button UI.\n- For a **single question**, use the `question` + `options` fields as before.\n- For **free-text input**, use `kind: \"input\"`.\n\nAlways explain what you're doing before taking action.\n\n{context}";
|
|
1512
1629
|
|
|
1513
1630
|
type KodaXPromptSectionSlot = 'base' | 'runtime-context' | 'session-context' | 'capability-truth' | 'base-suffix' | 'mode-overlay' | 'project-rules' | 'skill-addendum' | 'specialist';
|
|
1514
1631
|
type KodaXPromptSectionStability = 'stable' | 'dynamic' | 'project' | 'specialist';
|
|
@@ -1602,7 +1719,7 @@ declare function buildSystemPrompt(options: KodaXOptions, isNewSession: boolean)
|
|
|
1602
1719
|
* reuse is at the **pattern** level (each agent has its own
|
|
1603
1720
|
* `capability-sections.ts`), not the **content** level.
|
|
1604
1721
|
* - Hoisting to `@kodax-ai/agent/` would force `@kodax-ai/agent` →
|
|
1605
|
-
* `@kodax-ai/
|
|
1722
|
+
* `@kodax-ai/agent` / `@kodax-ai/agent` cross-package dependencies,
|
|
1606
1723
|
* breaking the "agent doesn't depend on application-layer
|
|
1607
1724
|
* packages" promise.
|
|
1608
1725
|
* - The drift problem this batch solves is "SA / AMA assemble the
|
|
@@ -1806,11 +1923,12 @@ declare function createReasoningPlan(options: KodaXOptions, prompt: string, prov
|
|
|
1806
1923
|
*
|
|
1807
1924
|
* Capability inventory: docs/features/v0.7.29-capability-inventory.md#cap-039-promise-signal-split-for-thinking-mode-replay
|
|
1808
1925
|
*
|
|
1809
|
-
* Recognises the convention used by managed-protocol
|
|
1810
|
-
* Planner
|
|
1811
|
-
* of an assistant turn — e.g. `[CONFIRMED H1_EXECUTE_EVAL]
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1926
|
+
* Recognises the convention historically used by V1 managed-protocol
|
|
1927
|
+
* harnesses (Scout / Planner / Generator / Evaluator) to embed a single-line
|
|
1928
|
+
* signal at the end of an assistant turn — e.g. `[CONFIRMED H1_EXECUTE_EVAL]`.
|
|
1929
|
+
* Most of those downstream consumers (`scout-signals.ts`, in-chain Evaluator
|
|
1930
|
+
* gating) were retired in FEATURE_184 / FEATURE_193; the helper is kept as
|
|
1931
|
+
* the canonical signal-extraction primitive for any future consumer.
|
|
1814
1932
|
*
|
|
1815
1933
|
* Returns `[signal, residual]` where:
|
|
1816
1934
|
* - `signal` — uppercased tag (e.g. `CONFIRMED`) or `''` when absent
|
|
@@ -2041,23 +2159,92 @@ declare function reconstructMessagesWithToolGuard(stableMessages: KodaXMessage[]
|
|
|
2041
2159
|
* per ADR-020 / v0.7.29 §239 §371). Substrate body lives in
|
|
2042
2160
|
* `agent-runtime/run-substrate.ts` (`runSubstrate`) and is wired via
|
|
2043
2161
|
* the `Agent.substrateExecutor` closure attached in `coding-preset.ts`.
|
|
2162
|
+
*
|
|
2163
|
+
* v0.7.42: `runRunKodaXInternal` is the shared implementation. The
|
|
2164
|
+
* embedder-facing `startKodaX` (non-blocking, returns `RunningSession`)
|
|
2165
|
+
* lives in `./running-session.ts` and wraps the same internal path —
|
|
2166
|
+
* no dual route (per feedback_no_parallel_refactor_paths).
|
|
2044
2167
|
*/
|
|
2045
2168
|
|
|
2046
2169
|
declare function runKodaX(options: KodaXOptions, prompt: string): Promise<KodaXResult>;
|
|
2047
2170
|
|
|
2171
|
+
/**
|
|
2172
|
+
* RunningSession — v0.7.42 (closes gap 6 reported by KodaX Space).
|
|
2173
|
+
*
|
|
2174
|
+
* `runKodaX(opts, prompt)` is a blocking `Promise<KodaXResult>` — once
|
|
2175
|
+
* a run is in-flight the SDK consumer cannot observe its session id,
|
|
2176
|
+
* flip provider / model / reasoning mid-run, or abort cooperatively
|
|
2177
|
+
* without forging an external `AbortSignal` and squinting at the
|
|
2178
|
+
* resolved `KodaXResult` after the fact.
|
|
2179
|
+
*
|
|
2180
|
+
* `startKodaX(opts, prompt)` returns a `RunningSession` handle
|
|
2181
|
+
* immediately (the run starts on the next microtask). The handle
|
|
2182
|
+
* exposes:
|
|
2183
|
+
*
|
|
2184
|
+
* - `id` — the resolved session id (from
|
|
2185
|
+
* `options.session.id` or freshly generated)
|
|
2186
|
+
* - `currentProvider` / `currentModel` / `currentReasoning`
|
|
2187
|
+
* — last value the embedder requested
|
|
2188
|
+
* (mirrors what the next turn will see)
|
|
2189
|
+
* - `setProvider` / `setModel` / `setReasoning`
|
|
2190
|
+
* — apply between turns; the next CAP-055
|
|
2191
|
+
* re-resolution picks them up
|
|
2192
|
+
* - `abort(reason?)` — cooperative abort via internal
|
|
2193
|
+
* `AbortController`; honors external
|
|
2194
|
+
* `options.abortSignal` too (forwarded)
|
|
2195
|
+
* - `result` — `Promise<KodaXResult>` (same shape
|
|
2196
|
+
* `runKodaX` returns)
|
|
2197
|
+
*
|
|
2198
|
+
* `runKodaX` is now a thin wrapper over `startKodaX(...).result` so
|
|
2199
|
+
* there is no dual code path (per feedback_no_parallel_refactor_paths).
|
|
2200
|
+
*/
|
|
2201
|
+
|
|
2202
|
+
interface RunningSession {
|
|
2203
|
+
/** Session id used by the underlying run (echoes options.session.id when supplied). */
|
|
2204
|
+
readonly id: string;
|
|
2205
|
+
/** Last provider value requested via constructor or `setProvider`. */
|
|
2206
|
+
readonly currentProvider: string;
|
|
2207
|
+
/** Last model value requested via constructor or `setModel`. Undefined = provider default. */
|
|
2208
|
+
readonly currentModel: string | undefined;
|
|
2209
|
+
/** Last reasoning mode requested via constructor or `setReasoning`. */
|
|
2210
|
+
readonly currentReasoning: KodaXReasoningMode | undefined;
|
|
2211
|
+
/** Whether `abort` has been called (or the external signal has fired). */
|
|
2212
|
+
readonly aborted: boolean;
|
|
2213
|
+
/** Whether the substrate has wired up the live mutators yet. */
|
|
2214
|
+
readonly attached: boolean;
|
|
2215
|
+
/** Switch provider mid-run. Applies on the next turn. */
|
|
2216
|
+
setProvider(name: string): void;
|
|
2217
|
+
/** Switch model mid-run. Pass undefined to clear an override. */
|
|
2218
|
+
setModel(model: string | undefined): void;
|
|
2219
|
+
/** Switch reasoning mode mid-run. */
|
|
2220
|
+
setReasoning(mode: KodaXReasoningMode | undefined): void;
|
|
2221
|
+
/** Cooperatively abort. The underlying provider stream sees an AbortError. */
|
|
2222
|
+
abort(reason?: unknown): void;
|
|
2223
|
+
/** Resolves to the same shape `runKodaX` returns. */
|
|
2224
|
+
readonly result: Promise<KodaXResult>;
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Public-friendly factory for {@link KodaXSessionControl}. Callers that
|
|
2228
|
+
* want the mid-run mutation surface WITHOUT the `startKodaX` wrapper
|
|
2229
|
+
* (e.g. building their own abort + lifecycle) can instantiate this and
|
|
2230
|
+
* pass it as `KodaXOptions.sessionControl`.
|
|
2231
|
+
*/
|
|
2232
|
+
declare function createSessionControl(): KodaXSessionControl & KodaXSessionMutators;
|
|
2233
|
+
declare function startKodaX(options: KodaXOptions, prompt: string): RunningSession;
|
|
2234
|
+
|
|
2048
2235
|
/**
|
|
2049
2236
|
* v0.7.35.1 FEATURE_142 (B-R1) — Coding-flavored compaction summary prompts.
|
|
2050
2237
|
*
|
|
2051
2238
|
* These are the verbatim v0.7.35 compaction prompts (byte-identical to
|
|
2052
2239
|
* the prior `SUMMARY_PROMPT` / `UPDATE_SUMMARY_PROMPT` constants in
|
|
2053
|
-
* `@kodax-ai/
|
|
2240
|
+
* `@kodax-ai/agent/src/compaction/summary-generator.ts`). They
|
|
2054
2241
|
* remain the empirically best-performing prompts on the coding domain
|
|
2055
2242
|
* (96.7% recall on the 10-fixture eval; see
|
|
2056
2243
|
* `tests/compaction-prompt.eval.ts`) AND happen to also be the best on
|
|
2057
2244
|
* the non-coding domain (97.0% recall) in the same eval — the wording
|
|
2058
2245
|
* is coding-flavored but the structure generalizes.
|
|
2059
2246
|
*
|
|
2060
|
-
* Why they live here: per ADR-021, @kodax-ai/
|
|
2247
|
+
* Why they live here: per ADR-021, @kodax-ai/agent is the
|
|
2061
2248
|
* generic compaction primitive package and must not enumerate
|
|
2062
2249
|
* coding-specific language ("coding agent", "file paths, function
|
|
2063
2250
|
* names", "HTTP status codes", "## Files & Changes") in its public
|
|
@@ -2071,7 +2258,7 @@ declare function runKodaX(options: KodaXOptions, prompt: string): Promise<KodaXR
|
|
|
2071
2258
|
* coding path produces a byte-equivalent prompt to v0.7.35 — preserving
|
|
2072
2259
|
* the empirically validated 96.7% recall.
|
|
2073
2260
|
*
|
|
2074
|
-
* Generic / non-coding consumers of @kodax-ai/
|
|
2261
|
+
* Generic / non-coding consumers of @kodax-ai/agent get the
|
|
2075
2262
|
* neutral `DEFAULT_SUMMARY_PROMPT` / `DEFAULT_UPDATE_SUMMARY_PROMPT`
|
|
2076
2263
|
* (the candidate-a-conservative eval winner) by default — they pay a
|
|
2077
2264
|
* 2-3pt non-coding recall cost for not knowing they should pass these
|
|
@@ -2143,33 +2330,6 @@ declare const boundedRevise: QualityInvariant;
|
|
|
2143
2330
|
|
|
2144
2331
|
declare const budgetCeiling: QualityInvariant;
|
|
2145
2332
|
|
|
2146
|
-
/**
|
|
2147
|
-
* FEATURE_101 invariant: `independentReview`.
|
|
2148
|
-
*
|
|
2149
|
-
* Verifier-binding invariant: when a manifest's role topology includes
|
|
2150
|
-
* a Generator (mutation-producing) role, an Evaluator must also be
|
|
2151
|
-
* reachable so the generator's output is independently verified. v1
|
|
2152
|
-
* uses agent name conventions (`generator` / `evaluator`) — the
|
|
2153
|
-
* canonical role names declared by `@kodax-ai/core/task-engine-agents.ts`.
|
|
2154
|
-
*
|
|
2155
|
-
* Hooks:
|
|
2156
|
-
* - admit: walk the reachable handoff graph from the manifest. If
|
|
2157
|
-
* any node has name === 'generator', some node must also have name
|
|
2158
|
-
* === 'evaluator'. Single-role manifests (scout / planner / direct
|
|
2159
|
-
* execution) admit unconditionally.
|
|
2160
|
-
* - assertTerminal: if the deliverable recorded mutations, it must
|
|
2161
|
-
* carry a `verdict` field (the evaluator's accept/revise/blocked
|
|
2162
|
-
* emission). A mutating run with no verdict means the generator
|
|
2163
|
-
* bypassed verification — reject.
|
|
2164
|
-
*
|
|
2165
|
-
* The verifier-can't-read-generator-reasoning contract from
|
|
2166
|
-
* FEATURE_101 §verifier separation lives at the message-routing layer
|
|
2167
|
-
* (handoff inputFilter); admission's job here is to ensure the role
|
|
2168
|
-
* pairing exists, not to police the message flow.
|
|
2169
|
-
*/
|
|
2170
|
-
|
|
2171
|
-
declare const independentReview: QualityInvariant;
|
|
2172
|
-
|
|
2173
2333
|
/**
|
|
2174
2334
|
* FEATURE_101 invariant: `toolPermission`.
|
|
2175
2335
|
*
|
|
@@ -2211,15 +2371,19 @@ declare const toolPermission: QualityInvariant;
|
|
|
2211
2371
|
*
|
|
2212
2372
|
* - Three pure invariants (finalOwner, handoffLegality, evidenceTrail)
|
|
2213
2373
|
* are pure functions of admission types and live in @kodax-ai/agent.
|
|
2214
|
-
* -
|
|
2215
|
-
* boundedRevise
|
|
2216
|
-
*
|
|
2217
|
-
*
|
|
2374
|
+
* - Three coupled invariants (budgetCeiling, toolPermission,
|
|
2375
|
+
* boundedRevise) tie into @kodax-ai/coding's budget controller /
|
|
2376
|
+
* tool registry / revise tracker and live here.
|
|
2377
|
+
* (FEATURE_184 Phase C.1: `independentReview` deleted — superseded by
|
|
2378
|
+
* Sidecar Verifier.)
|
|
2218
2379
|
* - `harnessSelectionTiming` (FEATURE_106 external) reads coding's AMA
|
|
2219
2380
|
* `ctx.recorder.scout.payload.scout.confirmedHarness` and lives here
|
|
2220
2381
|
* too (v0.7.35.1 FEATURE_142 A-R2 moved it from @kodax-ai/agent per
|
|
2221
2382
|
* ADR-021 — agent admission framework must not enumerate coding-AMA
|
|
2222
|
-
* field names).
|
|
2383
|
+
* field names). FEATURE_193 (v0.7.43) retired V1 Scout — the
|
|
2384
|
+
* invariant is now a permanent no-op (predicate always admits)
|
|
2385
|
+
* but stays registered so existing admission manifests + tests
|
|
2386
|
+
* keep working.
|
|
2223
2387
|
*
|
|
2224
2388
|
* `registerCodingInvariants()` is the canonical bootstrap entry point
|
|
2225
2389
|
* — call it once at SDK startup (or in test setup paired with
|
|
@@ -2235,11 +2399,11 @@ declare const toolPermission: QualityInvariant;
|
|
|
2235
2399
|
*
|
|
2236
2400
|
* v0.7.36 FEATURE_114: added `planBeforeMutate` — V2 plan-first
|
|
2237
2401
|
* structural observation. Registers alongside `harnessSelectionTiming`
|
|
2238
|
-
* (not as a replacement)
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2402
|
+
* (not as a replacement). FEATURE_193 (v0.7.43) retired V1 — the
|
|
2403
|
+
* `harnessSelectionTiming` predicate is now a permanent no-op (it
|
|
2404
|
+
* always admits, since the V2 Worker single-loop is the new V2
|
|
2405
|
+
* harness-discipline anchor) but stays registered so existing
|
|
2406
|
+
* admission manifests + tests keep working.
|
|
2243
2407
|
*/
|
|
2244
2408
|
declare const CODING_INVARIANTS: readonly QualityInvariant[];
|
|
2245
2409
|
/**
|
|
@@ -2283,40 +2447,30 @@ declare function markFanoutBranchCompleted(plan: KodaXFanoutSchedulerPlan, bundl
|
|
|
2283
2447
|
declare function markFanoutBranchCancelled(plan: KodaXFanoutSchedulerPlan, bundleId: string, reason: string): KodaXFanoutSchedulerPlan;
|
|
2284
2448
|
|
|
2285
2449
|
/**
|
|
2286
|
-
* Protocol emitter tools
|
|
2287
|
-
*
|
|
2288
|
-
* Four role-specific `RunnableTool`s that replace the fenced-block text
|
|
2289
|
-
* protocol used by Scout / Planner / Generator / Evaluator today. Each tool
|
|
2290
|
-
* accepts a structured JSON payload, normalizes it via
|
|
2291
|
-
* `coerceManagedProtocolToolPayload` (the same normalizer the old fenced-block
|
|
2292
|
-
* parser uses), and surfaces the normalized payload on the tool result
|
|
2293
|
-
* `metadata.payload` field so the new Runner-driven task engine
|
|
2294
|
-
* (FEATURE_084 Shard 5) can make routing decisions without text parsing.
|
|
2450
|
+
* Protocol emitter tools.
|
|
2295
2451
|
*
|
|
2296
|
-
*
|
|
2297
|
-
*
|
|
2298
|
-
*
|
|
2299
|
-
*
|
|
2300
|
-
*
|
|
2301
|
-
*
|
|
2302
|
-
*
|
|
2303
|
-
* `coerceManagedProtocolToolPayload` between both paths.
|
|
2452
|
+
* After FEATURE_193 (v0.7.43) V1 chain retirement, this module exposes a
|
|
2453
|
+
* single emitter: `emitVerdict` (the Sidecar Verifier verdict tool). The
|
|
2454
|
+
* supporting types and helpers (`ProtocolEmitterMetadata`,
|
|
2455
|
+
* `resolveHandoffTarget`, `buildEmitter`, `summarizeNormalized`) survive in
|
|
2456
|
+
* generic form because `verifier-recorder-bridge.ts` and the recorder
|
|
2457
|
+
* still observe the emitter metadata shape — but every Scout / Planner /
|
|
2458
|
+
* Generator branch is gone with the V1 roles.
|
|
2304
2459
|
*/
|
|
2305
2460
|
|
|
2306
|
-
/** Public tool name — LLM sees this on the tool list. */
|
|
2307
|
-
declare const EMIT_SCOUT_VERDICT_TOOL_NAME = "emit_scout_verdict";
|
|
2308
|
-
declare const EMIT_CONTRACT_TOOL_NAME = "emit_contract";
|
|
2309
|
-
declare const EMIT_HANDOFF_TOOL_NAME = "emit_handoff";
|
|
2310
2461
|
declare const EMIT_VERDICT_TOOL_NAME = "emit_verdict";
|
|
2311
2462
|
/**
|
|
2312
2463
|
* Shared metadata shape on the tool result. The Runner-driven task engine
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2464
|
+
* inspects `payload` to understand the Sidecar Verifier verdict.
|
|
2465
|
+
*
|
|
2466
|
+
* FEATURE_193 (v0.7.43): the role union narrowed from the V1 four-role
|
|
2467
|
+
* set (scout/planner/generator/evaluator) to `'evaluator'` only — Sidecar
|
|
2468
|
+
* Verifier is the sole emitter that survives V1 chain retirement.
|
|
2315
2469
|
*/
|
|
2316
2470
|
interface ProtocolEmitterMetadata {
|
|
2317
|
-
/** The role that emitted this payload — always
|
|
2318
|
-
readonly role: '
|
|
2319
|
-
/** Normalized payload slice (
|
|
2471
|
+
/** The role that emitted this payload — always `'evaluator'` in V2. */
|
|
2472
|
+
readonly role: 'evaluator';
|
|
2473
|
+
/** Normalized payload slice (verdict). */
|
|
2320
2474
|
readonly payload: Partial<KodaXManagedProtocolPayload>;
|
|
2321
2475
|
/**
|
|
2322
2476
|
* FEATURE_084 Shard 4 handoff signal. When set, the Runner looks up the
|
|
@@ -2333,29 +2487,19 @@ interface ProtocolEmitterMetadata {
|
|
|
2333
2487
|
readonly isTerminal?: boolean;
|
|
2334
2488
|
}
|
|
2335
2489
|
/**
|
|
2336
|
-
*
|
|
2337
|
-
*
|
|
2338
|
-
* `metadata.payload.
|
|
2339
|
-
* to
|
|
2340
|
-
|
|
2341
|
-
declare const emitScoutVerdict: RunnableTool;
|
|
2342
|
-
/**
|
|
2343
|
-
* Planner contract emitter (H2 only). Produces the execution contract the
|
|
2344
|
-
* Generator consumes: success criteria, required evidence, constraints.
|
|
2345
|
-
*/
|
|
2346
|
-
declare const emitContract: RunnableTool;
|
|
2347
|
-
/**
|
|
2348
|
-
* Generator handoff emitter. Signals that the Generator has finished its
|
|
2349
|
-
* execution round and hands off to the Evaluator for verification.
|
|
2490
|
+
* Sidecar Verifier verdict emitter (FEATURE_184). Decides the terminal
|
|
2491
|
+
* outcome of the round: accept, revise (Worker re-runs to fix), or
|
|
2492
|
+
* blocked. The Runner-driven engine reads `metadata.payload.verdict.status`
|
|
2493
|
+
* to decide next hop. Called by the Stop-hook Sidecar Verifier, never
|
|
2494
|
+
* by Worker/Generator directly.
|
|
2350
2495
|
*/
|
|
2351
|
-
declare const
|
|
2496
|
+
declare const emitVerdict: RunnableTool;
|
|
2352
2497
|
/**
|
|
2353
|
-
*
|
|
2354
|
-
*
|
|
2355
|
-
*
|
|
2498
|
+
* Emitter tools tuple. FEATURE_190 (v0.7.43) shrank from 4→3 with
|
|
2499
|
+
* `emitHandoff` deletion; FEATURE_193 (v0.7.43) shrank to 1 with
|
|
2500
|
+
* `emitScoutVerdict` + `emitContract` deletion — only the Sidecar Verifier
|
|
2501
|
+
* emitter survives.
|
|
2356
2502
|
*/
|
|
2357
|
-
declare const emitVerdict: RunnableTool;
|
|
2358
|
-
/** All four emitter tools, exposed as a tuple for iteration. */
|
|
2359
2503
|
declare const PROTOCOL_EMITTER_TOOLS: readonly RunnableTool[];
|
|
2360
2504
|
|
|
2361
2505
|
declare function runManagedTask(options: KodaXOptions, prompt: string): Promise<KodaXResult>;
|
|
@@ -2464,11 +2608,11 @@ declare function getActiveExtensionRuntime(): KodaXExtensionRuntime | null;
|
|
|
2464
2608
|
|
|
2465
2609
|
/**
|
|
2466
2610
|
* Coding-runtime adapter: registers an `McpCapabilityProvider` (from
|
|
2467
|
-
* `@kodax-ai/
|
|
2611
|
+
* `@kodax-ai/agent`) against the coding-specific `KodaXExtensionRuntime`.
|
|
2468
2612
|
*
|
|
2469
2613
|
* FEATURE_082 (v0.7.24): split out of the old
|
|
2470
2614
|
* `capabilities/providers/mcp/provider.ts`. The provider class now lives in
|
|
2471
|
-
* `@kodax-ai/
|
|
2615
|
+
* `@kodax-ai/agent` and stays free of any coding runtime dependency; this file
|
|
2472
2616
|
* is the thin bridge that wires the provider into the coding extension
|
|
2473
2617
|
* runtime.
|
|
2474
2618
|
*/
|
|
@@ -2540,13 +2684,13 @@ type OrchestrationWorkerRunner<TTask extends OrchestrationWorkerSpec = Orchestra
|
|
|
2540
2684
|
* `appendTrace` to `{workspaceDir}/orchestration-trace.jsonl`.
|
|
2541
2685
|
*
|
|
2542
2686
|
* @deprecated FEATURE_083 (v0.7.24) originally superseded this by
|
|
2543
|
-
* `AgentSpan` / `HandoffSpan` in `@kodax-ai/
|
|
2687
|
+
* `AgentSpan` / `HandoffSpan` in `@kodax-ai/agent`. **FEATURE_086 (v0.7.27)
|
|
2544
2688
|
* evaluated removal and kept it**: AgentSpan is scoped to a single Runner
|
|
2545
2689
|
* lifecycle, whereas OrchestrationTraceEvent spans across Tasks scheduled
|
|
2546
2690
|
* by `runOrchestration` — no cross-task span equivalent exists yet, and
|
|
2547
2691
|
* `runOrchestration` + this type are part of the `@kodax-ai/coding` public
|
|
2548
2692
|
* surface. The `@deprecated` tag is kept as a signal that new code
|
|
2549
|
-
* targeting in-Runner tracing should prefer `@kodax-ai/
|
|
2693
|
+
* targeting in-Runner tracing should prefer `@kodax-ai/agent` spans;
|
|
2550
2694
|
* cross-task orchestration code is free to continue using this event.
|
|
2551
2695
|
*/
|
|
2552
2696
|
interface OrchestrationTraceEvent {
|
|
@@ -2691,471 +2835,135 @@ declare function createDenialTracker(): DenialTracker;
|
|
|
2691
2835
|
* - bash: first 3 tokens of the command
|
|
2692
2836
|
* - edit/write/read: file path
|
|
2693
2837
|
* - other: tool name + hash prefix
|
|
2694
|
-
*/
|
|
2695
|
-
declare function computeInputSignature(toolName: string, input: Record<string, unknown>): string;
|
|
2696
|
-
declare function recordDenial(tracker: DenialTracker, toolName: string, input: Record<string, unknown>, reason?: string): DenialTracker;
|
|
2697
|
-
declare function isDeniedRecently(tracker: DenialTracker, toolName: string, input: Record<string, unknown>, ttl?: number): boolean;
|
|
2698
|
-
/**
|
|
2699
|
-
* Generate a denial context string for injection into agent messages.
|
|
2700
|
-
* Tells the LLM what was denied so it can adjust its strategy.
|
|
2701
|
-
*/
|
|
2702
|
-
declare function getDenialContext(tracker: DenialTracker): string;
|
|
2703
|
-
|
|
2704
|
-
/**
|
|
2705
|
-
* Placeholder Agent declarations for the coding-AMA H2 task-engine roles
|
|
2706
|
-
* (Scout / Planner / Generator / Evaluator).
|
|
2707
|
-
*
|
|
2708
|
-
* FEATURE_080 (v0.7.23): these declarations exist so the role identities
|
|
2709
|
-
* are represented as Layer A `Agent` data, which downstream features need:
|
|
2710
|
-
*
|
|
2711
|
-
* - FEATURE_084 (v0.7.26): runtime rewrite of Scout/Planner/Generator/
|
|
2712
|
-
* Evaluator on top of `Runner` consumes these declarations as the
|
|
2713
|
-
* source of truth for role metadata.
|
|
2714
|
-
* - FEATURE_078 (v0.7.29): reasoning profiles attach to the `reasoning`
|
|
2715
|
-
* field on these declarations.
|
|
2716
|
-
* - FEATURE_087+ self-construction: Agent-as-data means role specs can
|
|
2717
|
-
* be serialized, versioned, and mutated.
|
|
2718
|
-
*
|
|
2719
|
-
* Runtime note: **no preset dispatcher is registered for these agents**.
|
|
2720
|
-
* They are declarative placeholders. `Runner.run(scoutAgent, ...)` without
|
|
2721
|
-
* an `opts.llm` callback will throw the generic "no dispatcher" error;
|
|
2722
|
-
* that's intentional — the current task-engine executes these roles via
|
|
2723
|
-
* its existing internal flow, not through `Runner`. FEATURE_084 wires the
|
|
2724
|
-
* Runner runtime to these declarations.
|
|
2725
|
-
*
|
|
2726
|
-
* `instructions` strings here are short identifier-level summaries — the
|
|
2727
|
-
* full role prompts live in
|
|
2728
|
-
* `packages/coding/src/task-engine/_internal/prompts/role-prompt.ts` (the
|
|
2729
|
-
* FEATURE_079 extraction) and are loaded by the existing code path.
|
|
2730
|
-
*
|
|
2731
|
-
* v0.7.35.1 FEATURE_142 (A-R1): moved from `@kodax-ai/agent/src/primitives/`
|
|
2732
|
-
* back to `@kodax-ai/coding/src/agents/`. These role declarations are
|
|
2733
|
-
* coding-AMA-specific (Scout / Planner / Generator / Evaluator are the
|
|
2734
|
-
* H2 state-machine roles, not generic Agent platform primitives). Per
|
|
2735
|
-
* ADR-021, the universal `@kodax-ai/agent` framework must not predeclare
|
|
2736
|
-
* coding's H2 role identities.
|
|
2737
|
-
*/
|
|
2738
|
-
|
|
2739
|
-
declare const SCOUT_AGENT_NAME = "kodax/role/scout";
|
|
2740
|
-
declare const PLANNER_AGENT_NAME = "kodax/role/planner";
|
|
2741
|
-
declare const GENERATOR_AGENT_NAME = "kodax/role/generator";
|
|
2742
|
-
declare const EVALUATOR_AGENT_NAME = "kodax/role/evaluator";
|
|
2743
|
-
/**
|
|
2744
|
-
* Scout role declaration. Scout is the AMA entry point that both judges
|
|
2745
|
-
* task complexity and executes the H0 direct case; on H1/H2 it hands off
|
|
2746
|
-
* to Generator or Planner (see FEATURE_061).
|
|
2747
|
-
*/
|
|
2748
|
-
declare const scoutAgent: Agent;
|
|
2749
|
-
/**
|
|
2750
|
-
* Planner role declaration. Produces an execution plan consumed by
|
|
2751
|
-
* Generator in the H2 harness.
|
|
2752
|
-
*/
|
|
2753
|
-
declare const plannerAgent: Agent;
|
|
2754
|
-
/**
|
|
2755
|
-
* Generator role declaration. Performs the actual code changes /
|
|
2756
|
-
* investigations in both H1 and H2 harnesses.
|
|
2757
|
-
*/
|
|
2758
|
-
declare const generatorAgent: Agent;
|
|
2759
|
-
/**
|
|
2760
|
-
* Evaluator role declaration. Lightweight verifier in H1, structured
|
|
2761
|
-
* revise/replan gate in H2.
|
|
2762
|
-
*/
|
|
2763
|
-
declare const evaluatorAgent: Agent;
|
|
2764
|
-
/** All four placeholder role agents, exposed for iteration in downstream features. */
|
|
2765
|
-
declare const TASK_ENGINE_ROLE_AGENTS: Readonly<{
|
|
2766
|
-
readonly scout: Agent<unknown>;
|
|
2767
|
-
readonly planner: Agent<unknown>;
|
|
2768
|
-
readonly generator: Agent<unknown>;
|
|
2769
|
-
readonly evaluator: Agent<unknown>;
|
|
2770
|
-
}>;
|
|
2771
|
-
|
|
2772
|
-
/**
|
|
2773
|
-
* Default coding agent preset (FEATURE_080 → FEATURE_100).
|
|
2774
|
-
*
|
|
2775
|
-
* History:
|
|
2776
|
-
* v0.7.23 (FEATURE_080) introduced "Option Y": a `registerPresetDispatcher`
|
|
2777
|
-
* indirection that wrapped `runKodaX` so `Runner.run(defaultCodingAgent, …)`
|
|
2778
|
-
* appeared SDK-native while the body stayed on the legacy path. The trade-off
|
|
2779
|
-
* was deliberate parity insurance during the Layer-A primitives rollout.
|
|
2780
|
-
*
|
|
2781
|
-
* v0.7.29 (FEATURE_100) deletes Option Y per ADR-020. The substrate executor
|
|
2782
|
-
* is attached directly to the Agent declaration via `Agent.substrateExecutor`
|
|
2783
|
-
* (an Agent field added in this version), and `Runner.run` consults that
|
|
2784
|
-
* field before any registry lookup. No `registerPresetDispatcher` call is
|
|
2785
|
-
* made any more, so `Runner.run(createDefaultCodingAgent(), …)` and
|
|
2786
|
-
* `runKodaX(opts, prompt)` (now a thin `Runner.run` wrapper in `agent.ts`)
|
|
2787
|
-
* share one execution path.
|
|
2788
|
-
*
|
|
2789
|
-
* This file stays in `@kodax-ai/coding` because the substrate executor closure
|
|
2790
|
-
* imports `runSubstrate` from `agent-runtime/run-substrate.ts`. Importing
|
|
2791
|
-
* `@kodax-ai/core` alone never loads the substrate body.
|
|
2792
|
-
*/
|
|
2793
|
-
|
|
2794
|
-
/** Stable name used as the dispatch key for the built-in coding preset. */
|
|
2795
|
-
declare const DEFAULT_CODING_AGENT_NAME = "kodax/coding/default";
|
|
2796
|
-
/**
|
|
2797
|
-
* Construct the default coding Agent declaration. SDK consumers may write
|
|
2798
|
-
* `Runner.run(createDefaultCodingAgent(), prompt, { presetOptions })` and
|
|
2799
|
-
* the Runner will execute the substrate via `Agent.substrateExecutor`.
|
|
2800
|
-
*
|
|
2801
|
-
* `overrides` lets callers attach additional declarative fields
|
|
2802
|
-
* (e.g. custom `reasoning` profile, extra `guardrails`, custom
|
|
2803
|
-
* `provider`/`model`); these are preserved on the Agent and may be
|
|
2804
|
-
* consumed by the substrate executor through `presetOptions`.
|
|
2805
|
-
*/
|
|
2806
|
-
declare function createDefaultCodingAgent(overrides?: Partial<Omit<Agent, 'name' | 'instructions'>>): Agent;
|
|
2807
|
-
|
|
2808
|
-
/**
|
|
2809
|
-
* Coding Agent declarations — FEATURE_084 (v0.7.26).
|
|
2810
|
-
*
|
|
2811
|
-
* **These are declarative references exposing the canonical Scout /
|
|
2812
|
-
* Planner / Generator / Evaluator topology to SDK consumers.** Each
|
|
2813
|
-
* exported Agent carries the role's emit tool + the H0/H1/H2 handoff
|
|
2814
|
-
* graph, but carries ONLY a short identifier `instructions` string and
|
|
2815
|
-
* NO coding tools (read / grep / bash / write / edit / etc.).
|
|
2816
|
-
*
|
|
2817
|
-
* **The runtime agents are built fresh by
|
|
2818
|
-
* `task-engine/runner-driven.ts::buildRunnerAgentChain` on every run**,
|
|
2819
|
-
* with:
|
|
2820
|
-
* - full v0.7.22-parity `instructions` via
|
|
2821
|
-
* `_internal/managed-task/role-prompt.ts::createRolePrompt` (dynamic
|
|
2822
|
-
* closure resolving decision / contract / metadata / verification /
|
|
2823
|
-
* tool-policy / evidence-strategy / dispatch guidance per turn)
|
|
2824
|
-
* - per-run coding tools (read / grep / glob / bash / write / edit /
|
|
2825
|
-
* dispatch_child_task) wrapped with budget + mutation tracking +
|
|
2826
|
-
* progress reporting
|
|
2827
|
-
* - recorder-wrapped emit tools that drive the budget-extension
|
|
2828
|
-
* dialog + degraded-continue logic
|
|
2829
|
-
*
|
|
2830
|
-
* So these exports are **useful as topology documentation and as a
|
|
2831
|
-
* starting point for custom Runner invocations** (e.g. Runner.run with
|
|
2832
|
-
* your own llm adapter), but they are NOT the agents that run under
|
|
2833
|
-
* normal AMA dispatch. Do not expect wrapping `scoutCodingAgent` to
|
|
2834
|
-
* give you the behaviour of an in-SDK AMA run — for that, use
|
|
2835
|
-
* `runManagedTaskViaRunner` or the preset dispatcher on
|
|
2836
|
-
* `createDefaultCodingAgent`.
|
|
2837
|
-
*/
|
|
2838
|
-
|
|
2839
|
-
/** Marker exported for tests and for future binding sites in Shard 5. */
|
|
2840
|
-
declare const CODING_AGENT_MARKER: "kodax-coding-agent@0.7.26";
|
|
2841
|
-
declare const scoutCodingAgent: Agent;
|
|
2842
|
-
declare const plannerCodingAgent: Agent;
|
|
2843
|
-
declare const generatorCodingAgent: Agent;
|
|
2844
|
-
declare const evaluatorCodingAgent: Agent;
|
|
2845
|
-
/**
|
|
2846
|
-
* Topology record — iterable form of the four coding agents. Shard 5's
|
|
2847
|
-
* Runner-driven dispatcher uses this as the agent lookup.
|
|
2848
|
-
*/
|
|
2849
|
-
declare const CODING_AGENTS: Readonly<{
|
|
2850
|
-
readonly scout: Agent<unknown>;
|
|
2851
|
-
readonly planner: Agent<unknown>;
|
|
2852
|
-
readonly generator: Agent<unknown>;
|
|
2853
|
-
readonly evaluator: Agent<unknown>;
|
|
2854
|
-
}>;
|
|
2855
|
-
|
|
2856
|
-
/**
|
|
2857
|
-
* Adapter: wrap `applyToolResultGuardrail` (the existing per-tool truncation
|
|
2858
|
-
* policy) as a Layer A `ToolGuardrail.afterTool`.
|
|
2859
|
-
*
|
|
2860
|
-
* FEATURE_085 (v0.7.26): the tri-layer Guardrail runtime lives in
|
|
2861
|
-
* `@kodax-ai/core`. The existing truncation logic in `tool-result-policy.ts`
|
|
2862
|
-
* predates that runtime and targets `KodaXToolExecutionContext`. Rather
|
|
2863
|
-
* than merge the two, we expose an adapter that coding consumers can
|
|
2864
|
-
* register when driving a Runner through the generic path — the adapter
|
|
2865
|
-
* preserves byte-exact truncation behaviour while participating in the
|
|
2866
|
-
* new Guardrail lifecycle (Span emission, declaration-order composition).
|
|
2867
|
-
*
|
|
2868
|
-
* **Not** registered by default. Consumers opt in via
|
|
2869
|
-
* `Runner.run(agent, input, { guardrails: [createToolResultTruncationGuardrail(ctx)] })`.
|
|
2870
|
-
* The built-in `runKodaX` preset dispatcher continues to call
|
|
2871
|
-
* `applyToolResultGuardrail` directly — no behavioural change there.
|
|
2872
|
-
*/
|
|
2873
|
-
|
|
2874
|
-
declare const TOOL_RESULT_TRUNCATION_GUARDRAIL_NAME = "tool-result-truncation";
|
|
2875
|
-
/**
|
|
2876
|
-
* Create a `ToolGuardrail` that delegates to `applyToolResultGuardrail` in
|
|
2877
|
-
* its `afterTool` hook. The returned guardrail does not touch the call
|
|
2878
|
-
* going in (no `beforeTool`).
|
|
2879
|
-
*
|
|
2880
|
-
* @param ctx The coding-layer execution context that
|
|
2881
|
-
* `applyToolResultGuardrail` needs (mutation tracker, persistence dir,
|
|
2882
|
-
* etc.). Typically created alongside the `KodaXOptions` for the run.
|
|
2883
|
-
*/
|
|
2884
|
-
declare function createToolResultTruncationGuardrail(ctx: KodaXToolExecutionContext): ToolGuardrail;
|
|
2885
|
-
|
|
2886
|
-
/**
|
|
2887
|
-
* KodaX Constructed-World types (FEATURE_087, v0.7.28).
|
|
2888
|
-
*
|
|
2889
|
-
* Runtime-generated capabilities (tools / agents / skills / ...) live in
|
|
2890
|
-
* `.kodax/constructed/` and are loaded into the same registries as builtin
|
|
2891
|
-
* primitives. v0.7.28 only ships tool generation (FEATURE_088); other kinds
|
|
2892
|
-
* land in FEATURE_089 / FEATURE_090.
|
|
2893
|
-
*
|
|
2894
|
-
* Cross-references:
|
|
2895
|
-
* - DD §14 — lifecycle, security model, registry merge semantics.
|
|
2896
|
-
* - docs/features/v0.7.28.md — capability schema, generation flow.
|
|
2897
|
-
*/
|
|
2898
|
-
/**
|
|
2899
|
-
* Handler script source. v0.7.28 limits language to `'javascript'` so that
|
|
2900
|
-
* `loadHandler()` can `await import()` the file directly without an
|
|
2901
|
-
* intermediate TS → JS compile step (no esbuild / tsx dependency).
|
|
2902
|
-
*
|
|
2903
|
-
* TypeScript handlers are explicitly out of scope; Coding Agent generates
|
|
2904
|
-
* JS strings on the wire.
|
|
2905
|
-
*/
|
|
2906
|
-
interface ScriptSource {
|
|
2907
|
-
readonly kind: 'script';
|
|
2908
|
-
readonly language: 'javascript';
|
|
2909
|
-
readonly code: string;
|
|
2910
|
-
}
|
|
2911
|
-
/**
|
|
2912
|
-
* Capability declaration.
|
|
2913
|
-
*
|
|
2914
|
-
* v0.7.28 ships the single-dimension form: a whitelist of builtin tool
|
|
2915
|
-
* names that the handler may invoke through `ctx.tools.<name>(...)`.
|
|
2916
|
-
* All I/O — fs / net / env — must flow through builtin tools (`read` /
|
|
2917
|
-
* `write` / `bash` / etc.); handlers do not receive direct `ctx.fs` /
|
|
2918
|
-
* `ctx.net` / `ctx.env` entry points.
|
|
2919
|
-
*
|
|
2920
|
-
* Forward-compatible evolution: if the future demands path/domain-level
|
|
2921
|
-
* constraints, this can grow to `(string | { name; constraints })[]`
|
|
2922
|
-
* without breaking existing manifests.
|
|
2923
|
-
*/
|
|
2924
|
-
interface Capabilities {
|
|
2925
|
-
readonly tools: readonly string[];
|
|
2926
|
-
}
|
|
2927
|
-
/**
|
|
2928
|
-
* Tool-kind artifact body (the `content` of `ConstructionArtifact` when
|
|
2929
|
-
* `kind === 'tool'`).
|
|
2930
|
-
*/
|
|
2931
|
-
interface ToolContent {
|
|
2932
|
-
readonly description: string;
|
|
2933
|
-
readonly inputSchema: Record<string, unknown>;
|
|
2934
|
-
readonly capabilities: Capabilities;
|
|
2935
|
-
readonly handler: ScriptSource;
|
|
2936
|
-
/**
|
|
2937
|
-
* Per-tool timeout override. Defaults to {@link DEFAULT_HANDLER_TIMEOUT_MS}
|
|
2938
|
-
* when omitted. Bounded by AbortController in `loadHandler()`.
|
|
2939
|
-
*/
|
|
2940
|
-
readonly timeoutMs?: number;
|
|
2941
|
-
}
|
|
2942
|
-
/**
|
|
2943
|
-
* Default handler timeout. Picked to match the historical ceiling on
|
|
2944
|
-
* builtin streaming tools (30s); revisit if a constructed tool demands
|
|
2945
|
-
* longer-running computation.
|
|
2946
|
-
*/
|
|
2947
|
-
declare const DEFAULT_HANDLER_TIMEOUT_MS = 30000;
|
|
2948
|
-
/**
|
|
2949
|
-
* Lifecycle state on disk. Drives both the startup glob filter and the
|
|
2950
|
-
* `revoke()` semantics. See DD §14.1 — file system is the single source
|
|
2951
|
-
* of truth; no separate `_manifest.json` index file (C4 decision).
|
|
2952
|
-
*/
|
|
2953
|
-
type ArtifactStatus = 'staged' | 'active' | 'revoked';
|
|
2954
|
-
/**
|
|
2955
|
-
* Reference to a tool by stable id. v0.7.31 (FEATURE_089) introduces
|
|
2956
|
-
* Agent manifests that bundle tool refs rather than inline tool bodies;
|
|
2957
|
-
* the resolver expands these refs to concrete `KodaXToolDefinition`
|
|
2958
|
-
* instances at activate time.
|
|
2959
|
-
*
|
|
2960
|
-
* `ref` shape:
|
|
2961
|
-
* - `builtin:<name>` — a tool from the static registry
|
|
2962
|
-
* (e.g. `builtin:read`, `builtin:bash`)
|
|
2963
|
-
* - `constructed:<name>@<ver>` — a previously-activated constructed tool
|
|
2964
|
-
*/
|
|
2965
|
-
interface ToolRef {
|
|
2966
|
-
readonly ref: string;
|
|
2967
|
-
}
|
|
2968
|
-
/**
|
|
2969
|
-
* Reference to a Guardrail by stable id. The Layer A `Guardrail`
|
|
2970
|
-
* declaration is name-only (no runtime hooks); resolvers map known
|
|
2971
|
-
* names to constructed `ToolGuardrail` / `InputGuardrail` /
|
|
2972
|
-
* `OutputGuardrail` instances at activation time.
|
|
2973
|
-
*/
|
|
2974
|
-
interface GuardrailRef {
|
|
2975
|
-
readonly kind: 'input' | 'output' | 'tool';
|
|
2976
|
-
readonly ref: string;
|
|
2977
|
-
}
|
|
2978
|
-
/**
|
|
2979
|
-
* Reference to a handoff target by stable id (another constructed agent
|
|
2980
|
-
* or a builtin role). The resolver expands `target.ref` to the actual
|
|
2981
|
-
* `Agent` declaration at admission time so the handoff DAG check
|
|
2982
|
-
* (`handoffLegality` invariant) sees the full graph.
|
|
2983
|
-
*/
|
|
2984
|
-
interface AgentHandoffRef {
|
|
2985
|
-
readonly target: {
|
|
2986
|
-
readonly ref: string;
|
|
2987
|
-
};
|
|
2988
|
-
readonly kind: 'continuation' | 'as-tool';
|
|
2989
|
-
readonly description?: string;
|
|
2990
|
-
}
|
|
2838
|
+
*/
|
|
2839
|
+
declare function computeInputSignature(toolName: string, input: Record<string, unknown>): string;
|
|
2840
|
+
declare function recordDenial(tracker: DenialTracker, toolName: string, input: Record<string, unknown>, reason?: string): DenialTracker;
|
|
2841
|
+
declare function isDeniedRecently(tracker: DenialTracker, toolName: string, input: Record<string, unknown>, ttl?: number): boolean;
|
|
2991
2842
|
/**
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
* passes the value through without re-shaping.
|
|
2843
|
+
* Generate a denial context string for injection into agent messages.
|
|
2844
|
+
* Tells the LLM what was denied so it can adjust its strategy.
|
|
2995
2845
|
*/
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
readonly max?: 'quick' | 'balanced' | 'deep';
|
|
2999
|
-
readonly escalateOnRevise?: boolean;
|
|
3000
|
-
}
|
|
2846
|
+
declare function getDenialContext(tracker: DenialTracker): string;
|
|
2847
|
+
|
|
3001
2848
|
/**
|
|
3002
|
-
*
|
|
3003
|
-
* constructed agent before it can activate. Each case feeds `input`
|
|
3004
|
-
* to a sandbox Runner instance and grades the agent's final output:
|
|
2849
|
+
* Role-name constants for the coding-AMA task-engine.
|
|
3005
2850
|
*
|
|
3006
|
-
*
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
2851
|
+
* FEATURE_193 v0.7.43: V1 chain (Scout/Planner/Generator) retired — the
|
|
2852
|
+
* placeholder Agent declarations are deleted, but the name constants
|
|
2853
|
+
* (`SCOUT_AGENT_NAME` / `PLANNER_AGENT_NAME` / `GENERATOR_AGENT_NAME`) survive
|
|
2854
|
+
* as string literals so:
|
|
2855
|
+
* - verdict-recorder.ts routing logic that compares `handoffTarget` against
|
|
2856
|
+
* these names still compiles
|
|
2857
|
+
* - historical session id strings that reference these roles can still parse
|
|
3009
2858
|
*
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
2859
|
+
* Worker is the only live placeholder Agent — the runtime Worker (with full
|
|
2860
|
+
* tool set, handoffs, mutation guards) is constructed in
|
|
2861
|
+
* `task-engine/runner-driven.ts::buildRunnerAgentChain`.
|
|
3012
2862
|
*/
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
readonly expectFinalText?: string;
|
|
3019
|
-
}
|
|
2863
|
+
|
|
2864
|
+
declare const SCOUT_AGENT_NAME = "kodax/role/scout";
|
|
2865
|
+
declare const PLANNER_AGENT_NAME = "kodax/role/planner";
|
|
2866
|
+
declare const GENERATOR_AGENT_NAME = "kodax/role/generator";
|
|
2867
|
+
declare const WORKER_AGENT_NAME = "kodax/role/worker";
|
|
3020
2868
|
/**
|
|
3021
|
-
*
|
|
3022
|
-
*
|
|
2869
|
+
* Worker role declaration — FEATURE_114 v0.7.36. The single primary agent
|
|
2870
|
+
* after FEATURE_193 V1 chain retirement. Plans (todo_update), executes
|
|
2871
|
+
* (read/write/edit/bash/dispatch), text-only terminates so Sidecar Verifier
|
|
2872
|
+
* (FEATURE_184 Phase D.2) runs verification.
|
|
3023
2873
|
*
|
|
3024
|
-
*
|
|
3025
|
-
*
|
|
3026
|
-
*
|
|
3027
|
-
* (Runner.admit's 5-step audit expands them and feeds the resolved
|
|
3028
|
-
* Agent through the invariant chain).
|
|
2874
|
+
* Placeholder for Layer A `Agent` data — the runtime Worker (with full
|
|
2875
|
+
* tool set, handoffs, mutation guards) is constructed in
|
|
2876
|
+
* `task-engine/runner-driven.ts::buildRunnerAgentChain`.
|
|
3029
2877
|
*/
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
readonly
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
readonly model?: string;
|
|
3037
|
-
readonly provider?: string;
|
|
3038
|
-
/**
|
|
3039
|
-
* Optional structured-output schema mirroring `Agent.outputSchema`.
|
|
3040
|
-
* Pure pass-through to the runtime — admission does not validate
|
|
3041
|
-
* shape semantics here, only well-formed JSON.
|
|
3042
|
-
*/
|
|
3043
|
-
readonly outputSchema?: Record<string, unknown>;
|
|
3044
|
-
/**
|
|
3045
|
-
* Optional sandbox test cases. When present, `sandbox_test_agent`
|
|
3046
|
-
* runs them; when absent, the test step performs only the static
|
|
3047
|
-
* checks (manifest schema + admission audit).
|
|
3048
|
-
*/
|
|
3049
|
-
readonly testCases?: readonly AgentTestCase[];
|
|
3050
|
-
/**
|
|
3051
|
-
* Maximum total budget (iteration count) the agent may consume.
|
|
3052
|
-
* Plumbed onto the resolved `AgentManifest.maxBudget` and clamped by
|
|
3053
|
-
* `budgetCeiling` invariant during admission.
|
|
3054
|
-
*/
|
|
3055
|
-
readonly maxBudget?: number;
|
|
3056
|
-
/**
|
|
3057
|
-
* Voluntary additional invariants the LLM declares this agent
|
|
3058
|
-
* commits to. Plumbed onto `AgentManifest.declaredInvariants`;
|
|
3059
|
-
* unioned on top of the required set during admission.
|
|
3060
|
-
*/
|
|
3061
|
-
readonly declaredInvariants?: readonly string[];
|
|
3062
|
-
}
|
|
2878
|
+
declare const workerAgent: Agent;
|
|
2879
|
+
/** Worker role agent exposed for iteration in downstream features. */
|
|
2880
|
+
declare const TASK_ENGINE_ROLE_AGENTS: Readonly<{
|
|
2881
|
+
readonly worker: Agent<unknown>;
|
|
2882
|
+
}>;
|
|
2883
|
+
|
|
3063
2884
|
/**
|
|
3064
|
-
*
|
|
3065
|
-
* `.kodax/constructed/<kind>s/<name>/<version>.json`).
|
|
2885
|
+
* Default coding agent preset (FEATURE_080 → FEATURE_100).
|
|
3066
2886
|
*
|
|
3067
|
-
*
|
|
3068
|
-
*
|
|
3069
|
-
*
|
|
3070
|
-
*
|
|
2887
|
+
* History:
|
|
2888
|
+
* v0.7.23 (FEATURE_080) introduced "Option Y": a `registerPresetDispatcher`
|
|
2889
|
+
* indirection that wrapped `runKodaX` so `Runner.run(defaultCodingAgent, …)`
|
|
2890
|
+
* appeared SDK-native while the body stayed on the legacy path. The trade-off
|
|
2891
|
+
* was deliberate parity insurance during the Layer-A primitives rollout.
|
|
3071
2892
|
*
|
|
3072
|
-
*
|
|
3073
|
-
*
|
|
2893
|
+
* v0.7.29 (FEATURE_100) deletes Option Y per ADR-020. The substrate executor
|
|
2894
|
+
* is attached directly to the Agent declaration via `Agent.substrateExecutor`
|
|
2895
|
+
* (an Agent field added in this version), and `Runner.run` consults that
|
|
2896
|
+
* field before any registry lookup. No `registerPresetDispatcher` call is
|
|
2897
|
+
* made any more, so `Runner.run(createDefaultCodingAgent(), …)` and
|
|
2898
|
+
* `runKodaX(opts, prompt)` (now a thin `Runner.run` wrapper in `agent.ts`)
|
|
2899
|
+
* share one execution path.
|
|
2900
|
+
*
|
|
2901
|
+
* This file stays in `@kodax-ai/coding` because the substrate executor closure
|
|
2902
|
+
* imports `runSubstrate` from `agent-runtime/run-substrate.ts`. Importing
|
|
2903
|
+
* `@kodax-ai/core` alone never loads the substrate body.
|
|
3074
2904
|
*/
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
readonly version: string;
|
|
3079
|
-
status: ArtifactStatus;
|
|
3080
|
-
readonly signedBy?: string;
|
|
3081
|
-
readonly createdAt: number;
|
|
3082
|
-
readonly sourceAgent?: string;
|
|
3083
|
-
testedAt?: number;
|
|
3084
|
-
activatedAt?: number;
|
|
3085
|
-
revokedAt?: number;
|
|
3086
|
-
/**
|
|
3087
|
-
* SHA-256 of `JSON.stringify(content)` captured at activate time.
|
|
3088
|
-
* `rehydrateActiveArtifacts()` recomputes and compares — a mismatch
|
|
3089
|
-
* indicates the manifest was edited between activation and the next
|
|
3090
|
-
* boot (naive cross-session tampering, e.g. an LLM rewriting the .json
|
|
3091
|
-
* via the Write tool without recomputing the hash). Mismatched
|
|
3092
|
-
* artifacts are skipped at rehydrate with a stderr warning. This is
|
|
3093
|
-
* NOT a defense against a coordinated attacker who recomputes the
|
|
3094
|
-
* hash; the threat model is single-user CLI integrity, not multi-user
|
|
3095
|
-
* supply chain.
|
|
3096
|
-
*/
|
|
3097
|
-
contentHash?: string;
|
|
3098
|
-
}
|
|
3099
|
-
interface ToolArtifact extends ConstructionArtifactBase {
|
|
3100
|
-
readonly kind: 'tool';
|
|
3101
|
-
readonly content: ToolContent;
|
|
3102
|
-
}
|
|
3103
|
-
interface AgentArtifact extends ConstructionArtifactBase {
|
|
3104
|
-
readonly kind: 'agent';
|
|
3105
|
-
readonly content: AgentContent;
|
|
3106
|
-
}
|
|
2905
|
+
|
|
2906
|
+
/** Stable name used as the dispatch key for the built-in coding preset. */
|
|
2907
|
+
declare const DEFAULT_CODING_AGENT_NAME = "kodax/coding/default";
|
|
3107
2908
|
/**
|
|
3108
|
-
*
|
|
3109
|
-
*
|
|
2909
|
+
* Construct the default coding Agent declaration. SDK consumers may write
|
|
2910
|
+
* `Runner.run(createDefaultCodingAgent(), prompt, { presetOptions })` and
|
|
2911
|
+
* the Runner will execute the substrate via `Agent.substrateExecutor`.
|
|
2912
|
+
*
|
|
2913
|
+
* `overrides` lets callers attach additional declarative fields
|
|
2914
|
+
* (e.g. custom `reasoning` profile, extra `guardrails`, custom
|
|
2915
|
+
* `provider`/`model`); these are preserved on the Agent and may be
|
|
2916
|
+
* consumed by the substrate executor through `presetOptions`.
|
|
3110
2917
|
*/
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
readonly stagedAt: number;
|
|
3114
|
-
}
|
|
2918
|
+
declare function createDefaultCodingAgent(overrides?: Partial<Omit<Agent, 'name' | 'instructions'>>): Agent;
|
|
2919
|
+
|
|
3115
2920
|
/**
|
|
3116
|
-
*
|
|
3117
|
-
*
|
|
2921
|
+
* Coding Agent declarations — FEATURE_193 v0.7.43.
|
|
2922
|
+
*
|
|
2923
|
+
* The V1 chain (Scout / Planner / Generator) was retired in FEATURE_193.
|
|
2924
|
+
* The Worker single-loop is now the only entry path; the runtime Worker
|
|
2925
|
+
* agent (with full tool set, handoffs, mutation guards) is constructed
|
|
2926
|
+
* fresh by `task-engine/runner-driven.ts::buildRunnerAgentChain` on every
|
|
2927
|
+
* run. This file retains only the declarative marker for the
|
|
2928
|
+
* `Constructed` admission contract since downstream consumers
|
|
2929
|
+
* (coding-preset / extension API) test against it.
|
|
3118
2930
|
*/
|
|
3119
|
-
interface TestResult {
|
|
3120
|
-
readonly ok: boolean;
|
|
3121
|
-
readonly errors?: readonly string[];
|
|
3122
|
-
readonly warnings?: readonly string[];
|
|
3123
|
-
}
|
|
3124
2931
|
/**
|
|
3125
|
-
*
|
|
3126
|
-
*
|
|
3127
|
-
*
|
|
3128
|
-
* bootstrap.ts` so user approval flows through the live askUser channel.
|
|
3129
|
-
*
|
|
3130
|
-
* Modeled as a function type rather than an interface (D3 decision):
|
|
3131
|
-
* keeps the contract surface tiny, no class boilerplate.
|
|
3132
|
-
*
|
|
3133
|
-
* No declarative `kodax.config.ts` override hatch is provided — see the
|
|
3134
|
-
* "Deferred Design Decisions" section in `features/v0.7.28.md` for why
|
|
3135
|
-
* a `risk_mode` enum (when truly needed) is preferred over user-authored
|
|
3136
|
-
* policy functions.
|
|
2932
|
+
* Sentinel guardrail name used by the coding-AMA admission contract to
|
|
2933
|
+
* identify Constructed agents (FEATURE_087+). Kept here as the canonical
|
|
2934
|
+
* marker string after the V1 chain agent declarations were retired.
|
|
3137
2935
|
*/
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
/** Default policy: always ask the user; no implicit approvals. */
|
|
3141
|
-
declare const defaultPolicy: ConstructionPolicy;
|
|
2936
|
+
declare const CODING_AGENT_MARKER = "kodax/coding-agent";
|
|
2937
|
+
|
|
3142
2938
|
/**
|
|
3143
|
-
*
|
|
3144
|
-
*
|
|
2939
|
+
* Adapter: wrap `applyToolResultGuardrail` (the existing per-tool truncation
|
|
2940
|
+
* policy) as a Layer A `ToolGuardrail.afterTool`.
|
|
2941
|
+
*
|
|
2942
|
+
* FEATURE_085 (v0.7.26): the tri-layer Guardrail runtime lives in
|
|
2943
|
+
* `@kodax-ai/core`. The existing truncation logic in `tool-result-policy.ts`
|
|
2944
|
+
* predates that runtime and targets `KodaXToolExecutionContext`. Rather
|
|
2945
|
+
* than merge the two, we expose an adapter that coding consumers can
|
|
2946
|
+
* register when driving a Runner through the generic path — the adapter
|
|
2947
|
+
* preserves byte-exact truncation behaviour while participating in the
|
|
2948
|
+
* new Guardrail lifecycle (Span emission, declaration-order composition).
|
|
2949
|
+
*
|
|
2950
|
+
* **Not** registered by default. Consumers opt in via
|
|
2951
|
+
* `Runner.run(agent, input, { guardrails: [createToolResultTruncationGuardrail(ctx)] })`.
|
|
2952
|
+
* The built-in `runKodaX` preset dispatcher continues to call
|
|
2953
|
+
* `applyToolResultGuardrail` directly — no behavioural change there.
|
|
3145
2954
|
*/
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
readonly declaredTools: readonly string[];
|
|
3149
|
-
constructor(toolName: string, declaredTools: readonly string[]);
|
|
3150
|
-
}
|
|
2955
|
+
|
|
2956
|
+
declare const TOOL_RESULT_TRUNCATION_GUARDRAIL_NAME = "tool-result-truncation";
|
|
3151
2957
|
/**
|
|
3152
|
-
*
|
|
3153
|
-
*
|
|
2958
|
+
* Create a `ToolGuardrail` that delegates to `applyToolResultGuardrail` in
|
|
2959
|
+
* its `afterTool` hook. The returned guardrail does not touch the call
|
|
2960
|
+
* going in (no `beforeTool`).
|
|
2961
|
+
*
|
|
2962
|
+
* @param ctx The coding-layer execution context that
|
|
2963
|
+
* `applyToolResultGuardrail` needs (mutation tracker, persistence dir,
|
|
2964
|
+
* etc.). Typically created alongside the `KodaXOptions` for the run.
|
|
3154
2965
|
*/
|
|
3155
|
-
declare
|
|
3156
|
-
readonly path?: string;
|
|
3157
|
-
constructor(message: string, path?: string);
|
|
3158
|
-
}
|
|
2966
|
+
declare function createToolResultTruncationGuardrail(ctx: KodaXToolExecutionContext): ToolGuardrail;
|
|
3159
2967
|
|
|
3160
2968
|
/**
|
|
3161
2969
|
* FEATURE_089 Phase 3.5 — Sandbox Agent Test Runner.
|
|
@@ -3657,6 +3465,149 @@ declare function hasPendingSwap(name: string): boolean;
|
|
|
3657
3465
|
*/
|
|
3658
3466
|
declare function drainPendingSwaps(): readonly string[];
|
|
3659
3467
|
|
|
3468
|
+
/**
|
|
3469
|
+
* FEATURE_191 (v0.7.43) — markdown-defined agent loader.
|
|
3470
|
+
*
|
|
3471
|
+
* Scans two directories for user/project-authored agent definitions
|
|
3472
|
+
* (claudecode-style `<name>.md` with YAML frontmatter + body) and
|
|
3473
|
+
* registers them as constructed agents via `Runner.admit` →
|
|
3474
|
+
* `registerConstructedAgent`. Two-tier path (user first, then project)
|
|
3475
|
+
* with `last-write-wins` semantics implements precedence: a project
|
|
3476
|
+
* agent of the same name shadows the user agent (the more-specific
|
|
3477
|
+
* scope wins).
|
|
3478
|
+
*
|
|
3479
|
+
* Markdown shape:
|
|
3480
|
+
*
|
|
3481
|
+
* ---
|
|
3482
|
+
* name: db-reviewer
|
|
3483
|
+
* description: Reviews DB migrations for safety
|
|
3484
|
+
* tools: [read, grep]
|
|
3485
|
+
* model: claude-sonnet-4-6
|
|
3486
|
+
* ---
|
|
3487
|
+
* You are a DB migration reviewer. ...
|
|
3488
|
+
*
|
|
3489
|
+
* Files without YAML frontmatter, or with a missing `name`, are
|
|
3490
|
+
* silently skipped (claudecode-compatible: a `.md` without
|
|
3491
|
+
* frontmatter is treated as a reference doc). Files with frontmatter
|
|
3492
|
+
* but a missing/invalid `description` are reported as failures so the
|
|
3493
|
+
* REPL can surface diagnostics.
|
|
3494
|
+
*
|
|
3495
|
+
* `mcpServers` / `hooks` / `memory` / `isolation` / `permissionMode` /
|
|
3496
|
+
* `maxTurns` / `skills` frontmatter fields are ignored in v0.7.43 — they
|
|
3497
|
+
* are intentional non-goals; each one is an independent product
|
|
3498
|
+
* decision. Ignoring them silently keeps user `.md` files
|
|
3499
|
+
* forward-compatible across future feature versions.
|
|
3500
|
+
*/
|
|
3501
|
+
/**
|
|
3502
|
+
* Per-file failure record returned to the boot caller. Mirrors
|
|
3503
|
+
* claudecode's `getAgentDefinitionsWithOverrides.failedFiles` shape so
|
|
3504
|
+
* the REPL `/agents list` diagnostic can surface per-file reasons
|
|
3505
|
+
* instead of a global count.
|
|
3506
|
+
*/
|
|
3507
|
+
interface MarkdownLoadFailure {
|
|
3508
|
+
readonly path: string;
|
|
3509
|
+
readonly reason: string;
|
|
3510
|
+
}
|
|
3511
|
+
interface LoadAgentsFromMarkdownResult {
|
|
3512
|
+
readonly loaded: number;
|
|
3513
|
+
readonly failed: readonly MarkdownLoadFailure[];
|
|
3514
|
+
}
|
|
3515
|
+
interface LoadAgentsFromMarkdownOptions {
|
|
3516
|
+
/**
|
|
3517
|
+
* Project root. Defaults to `process.cwd()`. Project agents live at
|
|
3518
|
+
* `<cwd>/.kodax/agents/*.md` and override user-level agents of the
|
|
3519
|
+
* same name via last-write-wins (loaded second).
|
|
3520
|
+
*/
|
|
3521
|
+
readonly cwd?: string;
|
|
3522
|
+
/**
|
|
3523
|
+
* Override for the user-level config home. Defaults to the agent
|
|
3524
|
+
* runtime's resolved config home (`getAgentConfigHome()`, e.g.
|
|
3525
|
+
* `~/.kodax`). User agents live at `<configHome>/agents/*.md` and
|
|
3526
|
+
* are loaded before project agents.
|
|
3527
|
+
*/
|
|
3528
|
+
readonly configHome?: string;
|
|
3529
|
+
}
|
|
3530
|
+
/**
|
|
3531
|
+
* FEATURE_197 (v0.7.43) — discovered markdown agent metadata.
|
|
3532
|
+
*
|
|
3533
|
+
* Read-only counterpart to `ConstructedAgentEntry` exposed by
|
|
3534
|
+
* `discoverMarkdownAgents`. Differs from `ConstructedAgentEntry` in
|
|
3535
|
+
* three ways: (1) no resolved `Agent` runtime object — discovery is
|
|
3536
|
+
* purely file-system-side; (2) `source` is narrowed to the two
|
|
3537
|
+
* markdown scopes only; (3) `path` carries the source file location
|
|
3538
|
+
* so consumers can offer "open file" affordances.
|
|
3539
|
+
*/
|
|
3540
|
+
interface DiscoveredMarkdownAgent {
|
|
3541
|
+
/** Agent name from frontmatter `name` field. */
|
|
3542
|
+
readonly name: string;
|
|
3543
|
+
/** Agent description from frontmatter `description` field. */
|
|
3544
|
+
readonly description: string;
|
|
3545
|
+
/** Provenance: which scope the file was found in. */
|
|
3546
|
+
readonly source: 'markdown:user' | 'markdown:project';
|
|
3547
|
+
/** Absolute path of the markdown file on disk. */
|
|
3548
|
+
readonly path: string;
|
|
3549
|
+
/**
|
|
3550
|
+
* Tool names declared in the frontmatter `tools` field, normalized
|
|
3551
|
+
* to a string array. The `builtin:` prefix that the loader applies
|
|
3552
|
+
* to `ToolRef`s is NOT applied here — discovery returns the raw
|
|
3553
|
+
* names the user wrote.
|
|
3554
|
+
*/
|
|
3555
|
+
readonly tools?: readonly string[];
|
|
3556
|
+
/** Optional model alias from frontmatter `model` field. */
|
|
3557
|
+
readonly model?: string;
|
|
3558
|
+
}
|
|
3559
|
+
interface DiscoverMarkdownAgentsResult {
|
|
3560
|
+
/**
|
|
3561
|
+
* Well-formed agents found in the scanned directories. Same
|
|
3562
|
+
* last-write-wins precedence as `loadAgentsFromMarkdown`: when a
|
|
3563
|
+
* name appears in both user and project scopes, the project entry
|
|
3564
|
+
* wins and the user entry is omitted. The returned set mirrors
|
|
3565
|
+
* exactly what `loadAgentsFromMarkdown` would activate.
|
|
3566
|
+
*/
|
|
3567
|
+
readonly agents: readonly DiscoveredMarkdownAgent[];
|
|
3568
|
+
/** Files that had frontmatter but failed validation. */
|
|
3569
|
+
readonly failed: readonly MarkdownLoadFailure[];
|
|
3570
|
+
}
|
|
3571
|
+
/**
|
|
3572
|
+
* Entry point. Scans user then project dirs; registers every
|
|
3573
|
+
* well-formed agent that passes admission. Failures are accumulated
|
|
3574
|
+
* into the result instead of throwing — a single malformed file must
|
|
3575
|
+
* not break boot.
|
|
3576
|
+
*/
|
|
3577
|
+
declare function loadAgentsFromMarkdown(opts?: LoadAgentsFromMarkdownOptions): Promise<LoadAgentsFromMarkdownResult>;
|
|
3578
|
+
/**
|
|
3579
|
+
* FEATURE_197 (v0.7.43) — read-only counterpart to
|
|
3580
|
+
* `loadAgentsFromMarkdown`. Scans the same two-tier path (user dir
|
|
3581
|
+
* then project dir) and returns metadata for every well-formed
|
|
3582
|
+
* agent found, WITHOUT calling `Runner.admit` or
|
|
3583
|
+
* `registerConstructedAgent`. Pure file-system + YAML parse — no
|
|
3584
|
+
* mutation of the in-memory agent registry.
|
|
3585
|
+
*
|
|
3586
|
+
* SDK consumers building an "agent picker" UI call this to preview
|
|
3587
|
+
* available agents before deciding whether (and when) to call
|
|
3588
|
+
* `loadAgentsFromMarkdown` to activate them.
|
|
3589
|
+
*
|
|
3590
|
+
* Validation semantics match `loadAgentsFromMarkdown` exactly so
|
|
3591
|
+
* that `discoverMarkdownAgents` + `loadAgentsFromMarkdown` agree on
|
|
3592
|
+
* which files are well-formed:
|
|
3593
|
+
* - Missing/empty `description` → reported in `failed`
|
|
3594
|
+
* - Empty body → reported in `failed`
|
|
3595
|
+
* - No frontmatter / missing `name` → silently skipped (treated
|
|
3596
|
+
* as reference doc, claudecode parity)
|
|
3597
|
+
* - I/O error on a single file → reported in `failed`
|
|
3598
|
+
*
|
|
3599
|
+
* Precedence: project entries shadow user entries of the same name
|
|
3600
|
+
* (last-write-wins via `Map.set`), matching the loader's effective
|
|
3601
|
+
* activation order. Consumers wanting to see shadowed user entries
|
|
3602
|
+
* should run a separate pass with `cwd` pointing at a non-existent
|
|
3603
|
+
* dir — feature not added by default per YAGNI.
|
|
3604
|
+
*
|
|
3605
|
+
* Does NOT validate against admission invariants — discovered
|
|
3606
|
+
* agents may still be rejected when `loadAgentsFromMarkdown` runs
|
|
3607
|
+
* (e.g. unknown tool refs). Validation happens at load time.
|
|
3608
|
+
*/
|
|
3609
|
+
declare function discoverMarkdownAgents(opts?: LoadAgentsFromMarkdownOptions): Promise<DiscoverMarkdownAgentsResult>;
|
|
3610
|
+
|
|
3660
3611
|
/**
|
|
3661
3612
|
* CtxProxy — runtime gate for constructed tool handlers.
|
|
3662
3613
|
*
|
|
@@ -4545,5 +4496,5 @@ declare function readWindowFromEnv(): number | undefined;
|
|
|
4545
4496
|
*/
|
|
4546
4497
|
declare function speculativeRace<T>(promise: Promise<T>, windowMs?: number): Promise<SpeculativeResult<T>>;
|
|
4547
4498
|
|
|
4548
|
-
export { Agent, AgentMessage, AutoRules, CANCELLED_TOOL_RESULT_MESSAGE, CANCELLED_TOOL_RESULT_PREFIX,
|
|
4549
|
-
export type { AbsoluteDenyMatch, AbsoluteDenyMiss, AbsoluteDenyResult, AgentArtifact, ArtifactStatus, AstCheckResult, AstRuleId, AstRuleViolation, AuditEntry, AuditEventKind, BashClassificationResult, BashClassifierConfig, BashRiskLevel, BudgetState, BuildClassifierPromptInput, BuildPromptInput, Capabilities, ChangedFileEntry, ChangedFileStatus, ChangedScopeAreaSummary, ChangedScopeReport, ClassifierDecision, ClassifierPrompt, ClassifyDecision, ClassifyOptions, ConstructionArtifact, ConstructionPolicy, ConstructionPolicyVerdict, CreateCtxProxyOptions, CreateKodaXTaskRunnerOptions, DenialRecord, DenialTracker, DisableState, EditRecoveryDiagnostic, EditToolErrorCode, ErrorClassification, ExecOptions, ExecResult, ExtensionCommandContext, ExtensionCommandDefinition, ExtensionCommandInvocation, ExtensionCommandResult, ExtensionContributionSource, ExtensionEventMap, ExtensionFailureDiagnostic, ExtensionFailureStage, ExtensionHookMap, ExtensionLoadSource, ExtensionLogger, ExtensionRuntimeController, ExtensionRuntimeDiagnostics, ExtensionToolBeforeHookContext, ImpactEstimateResult, KodaXAgentWorkerSpec, KodaXExtensionAPI, KodaXExtensionActivationResult, KodaXExtensionModule, KodaXPromptSection, KodaXPromptSectionDefinition, KodaXPromptSectionSlot, KodaXPromptSectionStability, KodaXPromptSnapshot, KodaXPromptSnapshotMetadata, KodaXProviderCapabilitySnapshot, KodaXProviderPolicyDecision, KodaXProviderPolicyIssue, KodaXProviderPolicyIssueSeverity, KodaXProviderSourceKind, KodaXRetrievalArtifact, KodaXRetrievalFreshness, KodaXRetrievalItem, KodaXRetrievalResult, KodaXRetrievalScope, KodaXRetrievalToolName, KodaXRetrievalTrust, LanguageCapabilityTier,
|
|
4499
|
+
export { Agent, AgentMessage, AutoRules, CANCELLED_TOOL_RESULT_MESSAGE, CANCELLED_TOOL_RESULT_PREFIX, CODING_AGENT_MARKER, CODING_INVARIANTS, CODING_SUMMARY_PROMPT, CODING_UPDATE_SUMMARY_PROMPT, CapabilityDeniedError, CapabilityKind, CapabilityProvider, CapabilityResult, KodaXClient as Client, ConstructionManifestError, DEFAULT_CODING_AGENT_NAME, DEFAULT_DANGEROUS_PATTERNS, DEFAULT_HANDLER_TIMEOUT_MS, DEFAULT_RESILIENCE_CONFIG, DEFAULT_SAFE_PATTERNS, DEFAULT_SELF_MODIFY_BUDGET, DEFAULT_WINDOW_MS as DEFAULT_SPECULATIVE_WINDOW_MS, DEFAULT_TOOL_OUTPUT_MAX_BYTES, DEFAULT_TOOL_OUTPUT_MAX_LINES, EMIT_VERDICT_TOOL_NAME, ErrorCategory, FailureStage, GENERATOR_AGENT_NAME, KODAX_TOOLS, KodaXAmaControllerDecision, KodaXBaseProvider, KodaXChildContextBundle, KodaXClient, KodaXContentBlock, KodaXContextOptions, KodaXEvents, KodaXExecutionMode, KodaXExtensionRuntime, KodaXExtensionSessionRecord, KodaXFanoutBranchRecord, KodaXFanoutBranchTransition, KodaXFanoutSchedulerInput, KodaXFanoutSchedulerPlan, KodaXInputArtifact, KodaXJsonValue, KodaXMessage, KodaXOptions, KodaXParentReductionContract, KodaXProviderCapabilityProfile, KodaXProviderPolicyHints, KodaXReasoningCapability, KodaXReasoningMode, KodaXRepoIntelligenceCapability, KodaXRepoIntelligenceMode, KodaXRepoIntelligenceResolvedMode, KodaXRepoIntelligenceTrace, KodaXRepoRoutingSignals, KodaXResult, KodaXSessionControl, KodaXSessionError, KodaXSessionMutators, KodaXTaskRoutingDecision, KodaXTaskType, KodaXTerminalError, KodaXThinkingDepth, KodaXToolDefinition, KodaXToolError, KodaXToolExecutionContext, KodaXToolUseBlock, McpCapabilityProvider, McpProviderOptions, McpServersConfig, PLANNER_AGENT_NAME, PROMPT_SECTION_REGISTRY, PROTOCOL_EMITTER_TOOLS, ProviderExecutionState, ProviderRecoveryCoordinator, ProviderResilienceConfig, ProviderResiliencePolicy, READ_DEFAULT_LIMIT, READ_MAX_LINE_CHARS, READ_PREFLIGHT_SIZE_BYTES, REPOINTEL_DEFAULT_ENDPOINT, RecoveryDecision, RecoveryResult, ResilienceClassification, SCOUT_AGENT_NAME, SYSTEM_PROMPT, SessionErrorMetadata, SignalCollector, StableBoundaryTracker, TASK_ENGINE_ROLE_AGENTS, TOOL_RESULT_TRUNCATION_GUARDRAIL_NAME, ToolCallSignal, WORKER_AGENT_NAME, _resetRuntimeForTesting, activate, analyzeChangedScope, appendAuditEntry, applyFanoutBranchTransition, applyToolResultGuardrail, assignFanoutBranchWorker, bashSignalCollector, boundedRevise, budgetCeiling, buildAmaControllerDecision, buildCapabilityContextSections, buildClassifierPrompt, buildFallbackRoutingDecision, buildFanoutSchedulerPlan, buildLlmReviewPrompt, buildPromptMessageContent, buildPromptOverlay, buildPromptSnapshot, buildProviderCapabilitySnapshot, buildProviderPolicyHintsForDecision, buildProviderPolicyPromptNotes, buildRepoIntelligenceContext, buildRepoIntelligenceIndex, buildRepoOverview, buildSystemPrompt, buildSystemPromptSnapshot, checkAbsoluteDeny, checkIncompleteToolCalls, checkPromiseSignal, classify, classifyBashCommand, classifyError, classifyResilienceError, computeInputSignature, configureRuntime, convertCapabilityReadResult, convertProviderSearchResults, countActiveFanoutBranches, createBashClassifierConfig, createBuiltinToolDefinition, createCtxProxy, createDefaultCodingAgent, createDenialTracker, createExtensionRuntime, createFanoutSchedulerInput, createKodaXTaskRunner, createPromptSection, createReasoningPlan, createSessionControl, createToolResultTruncationGuardrail, defaultPolicy, disableSelfModify, discoverMarkdownAgents, drainPendingSwaps, emitVerdict, evaluateProviderPolicy, exec, executeTool, extractComparableUserMessageText, extractHtmlTitle, extractPromptComparableText, fileSignalCollector, finalizeRetrievalResult, findByVersion, formatParallelDispatchResult, formatSize, getActiveExtensionRuntime, getAllRegisteredTools, getBuiltinRegisteredToolDefinition, getBuiltinToolDefinition, getDenialContext, getFanoutBranch, getImpactEstimate, getModuleContext, getProcessContext, getRegisteredToolDefinition, getRepoIntelligenceIndex, getRepoOverview, getRepoRoutingSignals, getRequiredToolParams, getSymbolContext, getTool, getToolDefinition, getToolRegistrations, getToolResultPolicy, hasPendingSwap, inferTaskType, inspectEditFailure, inspectRepoIntelligenceRuntime, isDeniedRecently, isParallelDispatchDirective, isToolFileMutation, isToolMutation, isToolPlanModeAllowed, listAll, list as listArtifacts, listBuiltinToolDefinitions, listConstructed, listToolDefinitions, listTools, loadAgentsFromMarkdown, loadHandler, markFanoutBranchCancelled, markFanoutBranchCompleted, orderPromptSections, parseClassifierOutput, parseEditToolError, parseLlmReviewVerdict, parseModelSpec, persistToolOutput, prewarmRepoIntelligenceCaches, readArtifact, readAuditEntries, readBudget, readDisableState, readWindowFromEnv as readSpeculativeWindowFromEnv, reasoningModeToDepth, reconstructMessagesWithToolGuard, recordDenial, registerCodingInvariants, registerConfiguredMcpCapabilityProvider, registerOfficialSandboxExtension, registerTool, rehydrateActiveArtifacts, remaining as remainingSelfModifyBudget, renderChangedScope, renderImpactEstimate, renderModuleContext, renderProcessContext, renderPromptSections, renderRepoOverview, renderRetrievalResult, renderSymbolContext, resetBudget, resolveClassifierModel, resolveConstructedAgent, resolveReasoningMode, resolveRepoIntelligenceMode, resolveRepoIntelligenceRuntimeConfig, resolveResilienceConfig, resolveToolCapability, revoke, rollbackSelfModify, runAstRules, runKodaX, runLlmReview, runManagedTask, runOrchestration, setActiveExtensionRuntime, speculativeRace, stage, startKodaX, stripAssistantText, stripHtmlToText, test as testArtifact, toolAskUserQuestion, toolBash, toolChangedDiff, toolChangedScope, toolCodeSearch, toolEdit, toolGlob, toolGrep, toolImpactEstimate, toolInsertAfterAnchor, toolModuleContext, toolPermission, toolProcessContext, toolRead, toolRepoOverview, toolSemanticLookup, toolSymbolContext, toolUndo, toolWebFetch, toolWebSearch, toolWrite, truncateHead, truncateLine, truncateTail, validateSubtaskIndependence, validateToolSchemaForProvider, warmRepoIntelligenceRuntime, webhook, workerAgent };
|
|
4500
|
+
export type { AbsoluteDenyMatch, AbsoluteDenyMiss, AbsoluteDenyResult, AgentArtifact, ArtifactStatus, AstCheckResult, AstRuleId, AstRuleViolation, AuditEntry, AuditEventKind, BashClassificationResult, BashClassifierConfig, BashRiskLevel, BudgetState, BuildClassifierPromptInput, BuildPromptInput, Capabilities, ChangedFileEntry, ChangedFileStatus, ChangedScopeAreaSummary, ChangedScopeReport, ClassifierDecision, ClassifierPrompt, ClassifyDecision, ClassifyOptions, ConstructionArtifact, ConstructionPolicy, ConstructionPolicyVerdict, CreateCtxProxyOptions, CreateKodaXTaskRunnerOptions, DenialRecord, DenialTracker, DisableState, DiscoverMarkdownAgentsResult, DiscoveredMarkdownAgent, EditRecoveryDiagnostic, EditToolErrorCode, ErrorClassification, ExecOptions, ExecResult, ExtensionCommandContext, ExtensionCommandDefinition, ExtensionCommandInvocation, ExtensionCommandResult, ExtensionContributionSource, ExtensionEventMap, ExtensionFailureDiagnostic, ExtensionFailureStage, ExtensionHookMap, ExtensionLoadSource, ExtensionLogger, ExtensionRuntimeController, ExtensionRuntimeDiagnostics, ExtensionToolBeforeHookContext, ImpactEstimateResult, KodaXAgentWorkerSpec, KodaXExtensionAPI, KodaXExtensionActivationResult, KodaXExtensionModule, KodaXPromptSection, KodaXPromptSectionDefinition, KodaXPromptSectionSlot, KodaXPromptSectionStability, KodaXPromptSnapshot, KodaXPromptSnapshotMetadata, KodaXProviderCapabilitySnapshot, KodaXProviderPolicyDecision, KodaXProviderPolicyIssue, KodaXProviderPolicyIssueSeverity, KodaXProviderSourceKind, KodaXRetrievalArtifact, KodaXRetrievalFreshness, KodaXRetrievalItem, KodaXRetrievalResult, KodaXRetrievalScope, KodaXRetrievalToolName, KodaXRetrievalTrust, LanguageCapabilityTier, LlmReviewClient, LlmReviewResult, LlmReviewVerdict, LoadAgentsFromMarkdownOptions, LoadAgentsFromMarkdownResult, LoadHandlerOptions, LoadHandlerScope, LoadedExtensionDiagnostic, LocalToolDefinition, MarkdownLoadFailure, ModelProviderRegistration, ModuleCapsule, ModuleContextResult, OfficialSandboxMode, OfficialSandboxOptions, OrchestrationArtifact, OrchestrationCompletedTask, OrchestrationRunEvents, OrchestrationRunOptions, OrchestrationRunResult, OrchestrationTaskBudget, OrchestrationTaskContext, OrchestrationTaskExecution, OrchestrationTaskStatus, OrchestrationTraceEvent, OrchestrationWorkerResult, OrchestrationWorkerRunner, OrchestrationWorkerSpec, ParallelDispatchDirective, ParallelDispatchResult, ParallelSubtask, ParsedModelSpec, ProcessCapsule, ProcessContextResult, ProcessStep, ProtocolEmitterMetadata, RegisteredCapabilityProviderDiagnostic, RegisteredCommandDiagnostic, RegisteredHookDiagnostic, RegisteredToolDefinition, RegisteredToolDiagnostic, RepoAreaKind, RepoAreaOverview, RepoIntelligenceIndex, RepoIntelligenceRuntimeInspection, RepoIntelligenceRuntimeWarmResult, RepoLanguageId, RepoLanguageSupport, RepoOverview, RepoSymbolKind, RepoSymbolRecord, RepoSymbolReference, ResolveClassifierModelOptions, ResolveSource, ResolvedClassifierModel, RollbackResult, RunningSession, SchemaProvider, SchemaValidationResult, ScriptSource, SelfModifyAskUser, SelfModifyAskUserInput, SelfModifyDiffSeverity, SelfModifyDiffSummary, SpeculativeResult, StagedHandle, StripOptions, SymbolContextResult, TestArtifactOptions, TestResult, TierZeroPatternId, ToolContent, ToolDefinitionSource, ToolHandler, ToolRegistrationOptions, ToolRegistry, ToolSideEffect, WebhookOptions, WebhookResult };
|