@kilnai/cli 0.23.1 → 1.0.0
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/README.md +33 -0
- package/dist/application/__tests__/plan-exit-tool.test.d.ts +2 -0
- package/dist/application/__tests__/plan-exit-tool.test.d.ts.map +1 -0
- package/dist/application/__tests__/plan-exit-tool.test.js +12 -0
- package/dist/application/__tests__/plan-exit-tool.test.js.map +1 -0
- package/dist/application/agent-loader.d.ts +12 -0
- package/dist/application/agent-loader.d.ts.map +1 -0
- package/dist/application/agent-loader.js +114 -0
- package/dist/application/agent-loader.js.map +1 -0
- package/dist/application/agent-loader.test.d.ts +2 -0
- package/dist/application/agent-loader.test.d.ts.map +1 -0
- package/dist/application/agent-loader.test.js +151 -0
- package/dist/application/agent-loader.test.js.map +1 -0
- package/dist/application/context-artifact-keys.d.ts +5 -0
- package/dist/application/context-artifact-keys.d.ts.map +1 -0
- package/dist/application/context-artifact-keys.js +14 -0
- package/dist/application/context-artifact-keys.js.map +1 -0
- package/dist/application/context-governance.d.ts +6 -0
- package/dist/application/context-governance.d.ts.map +1 -0
- package/dist/application/context-governance.js +20 -0
- package/dist/application/context-governance.js.map +1 -0
- package/dist/application/context-governor.d.ts +26 -0
- package/dist/application/context-governor.d.ts.map +1 -0
- package/dist/application/context-governor.js +164 -0
- package/dist/application/context-governor.js.map +1 -0
- package/dist/application/context-types.d.ts +20 -0
- package/dist/application/context-types.d.ts.map +1 -0
- package/dist/application/context-types.js +21 -0
- package/dist/application/context-types.js.map +1 -0
- package/dist/application/plan-exit-tool.d.ts +19 -0
- package/dist/application/plan-exit-tool.d.ts.map +1 -0
- package/dist/application/plan-exit-tool.js +13 -0
- package/dist/application/plan-exit-tool.js.map +1 -0
- package/dist/application/repo-summary-cache.d.ts +5 -0
- package/dist/application/repo-summary-cache.d.ts.map +1 -0
- package/dist/application/repo-summary-cache.js +82 -0
- package/dist/application/repo-summary-cache.js.map +1 -0
- package/dist/application/resume-strategy-feedback.d.ts +5 -0
- package/dist/application/resume-strategy-feedback.d.ts.map +1 -0
- package/dist/application/resume-strategy-feedback.js +81 -0
- package/dist/application/resume-strategy-feedback.js.map +1 -0
- package/dist/application/resume-strategy-policy.d.ts +26 -0
- package/dist/application/resume-strategy-policy.d.ts.map +1 -0
- package/dist/application/resume-strategy-policy.js +35 -0
- package/dist/application/resume-strategy-policy.js.map +1 -0
- package/dist/application/run-session.d.ts +39 -0
- package/dist/application/run-session.d.ts.map +1 -0
- package/dist/application/run-session.js +349 -0
- package/dist/application/run-session.js.map +1 -0
- package/dist/application/session-hooks.d.ts +20 -0
- package/dist/application/session-hooks.d.ts.map +1 -0
- package/dist/application/session-hooks.js +55 -0
- package/dist/application/session-hooks.js.map +1 -0
- package/dist/application/session-ledger.d.ts +12 -0
- package/dist/application/session-ledger.d.ts.map +1 -0
- package/dist/application/session-ledger.js +29 -0
- package/dist/application/session-ledger.js.map +1 -0
- package/dist/application/session-report.d.ts +19 -0
- package/dist/application/session-report.d.ts.map +1 -0
- package/dist/application/session-report.js +207 -0
- package/dist/application/session-report.js.map +1 -0
- package/dist/application/session-resume.d.ts +3 -0
- package/dist/application/session-resume.d.ts.map +1 -0
- package/dist/application/session-resume.js +16 -0
- package/dist/application/session-resume.js.map +1 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +138 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +141 -27
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/cron.d.ts +3 -0
- package/dist/commands/cron.d.ts.map +1 -0
- package/dist/commands/cron.js +201 -0
- package/dist/commands/cron.js.map +1 -0
- package/dist/commands/dev.js +2 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/domain.js +17 -17
- package/dist/commands/domain.js.map +1 -1
- package/dist/commands/init.d.ts +2 -11
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +14 -25
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp-config.d.ts +7 -1
- package/dist/commands/mcp-config.d.ts.map +1 -1
- package/dist/commands/mcp-config.js +26 -10
- package/dist/commands/mcp-config.js.map +1 -1
- package/dist/commands/memory.d.ts +1 -1
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +10 -10
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/run.d.ts +15 -3
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +464 -85
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/serve.d.ts +1 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +3 -3
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/skill-capture.d.ts +13 -0
- package/dist/commands/skill-capture.d.ts.map +1 -0
- package/dist/commands/skill-capture.js +212 -0
- package/dist/commands/skill-capture.js.map +1 -0
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +7 -3
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +15 -16
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +11 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +114 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/tools.d.ts +6 -0
- package/dist/commands/tools.d.ts.map +1 -0
- package/dist/commands/tools.js +28 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/commands/tui.d.ts +29 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +444 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/config/config-merger.d.ts +5 -0
- package/dist/config/config-merger.d.ts.map +1 -0
- package/dist/config/config-merger.js +25 -0
- package/dist/config/config-merger.js.map +1 -0
- package/dist/config/config-merger.test.d.ts +2 -0
- package/dist/config/config-merger.test.d.ts.map +1 -0
- package/dist/config/config-merger.test.js +165 -0
- package/dist/config/config-merger.test.js.map +1 -0
- package/dist/config/env-config.d.ts +5 -0
- package/dist/config/env-config.d.ts.map +1 -0
- package/dist/config/env-config.js +24 -0
- package/dist/config/env-config.js.map +1 -0
- package/dist/config/env-config.test.d.ts +2 -0
- package/dist/config/env-config.test.d.ts.map +1 -0
- package/dist/config/env-config.test.js +79 -0
- package/dist/config/env-config.test.js.map +1 -0
- package/dist/config/global-config.d.ts +23 -0
- package/dist/config/global-config.d.ts.map +1 -0
- package/dist/config/global-config.js +48 -0
- package/dist/config/global-config.js.map +1 -0
- package/dist/config/global-config.test.d.ts +2 -0
- package/dist/config/global-config.test.d.ts.map +1 -0
- package/dist/config/global-config.test.js +96 -0
- package/dist/config/global-config.test.js.map +1 -0
- package/dist/config-resolver.d.ts +5 -0
- package/dist/config-resolver.d.ts.map +1 -0
- package/dist/config-resolver.js +19 -0
- package/dist/config-resolver.js.map +1 -0
- package/dist/config.d.ts +8 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +193 -16
- package/dist/index.js.map +1 -1
- package/dist/kiln-yaml-types.d.ts +127 -0
- package/dist/kiln-yaml-types.d.ts.map +1 -0
- package/dist/kiln-yaml-types.js +42 -0
- package/dist/kiln-yaml-types.js.map +1 -0
- package/dist/kiln-yaml.d.ts +10 -0
- package/dist/kiln-yaml.d.ts.map +1 -0
- package/dist/kiln-yaml.js +109 -0
- package/dist/kiln-yaml.js.map +1 -0
- package/dist/mcp/config-generator.d.ts +9 -2
- package/dist/mcp/config-generator.d.ts.map +1 -1
- package/dist/mcp/config-generator.js +132 -2
- package/dist/mcp/config-generator.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-entry.js +0 -5
- package/dist/mcp-entry.js.map +1 -1
- package/dist/sync/agent-sync.d.ts +13 -0
- package/dist/sync/agent-sync.d.ts.map +1 -0
- package/dist/sync/agent-sync.js +130 -0
- package/dist/sync/agent-sync.js.map +1 -0
- package/dist/sync/agent-sync.test.d.ts +2 -0
- package/dist/sync/agent-sync.test.d.ts.map +1 -0
- package/dist/sync/agent-sync.test.js +130 -0
- package/dist/sync/agent-sync.test.js.map +1 -0
- package/dist/sync/agents-md-sync.d.ts +7 -0
- package/dist/sync/agents-md-sync.d.ts.map +1 -0
- package/dist/sync/agents-md-sync.js +44 -0
- package/dist/sync/agents-md-sync.js.map +1 -0
- package/dist/sync/agents-md-sync.test.d.ts +2 -0
- package/dist/sync/agents-md-sync.test.d.ts.map +1 -0
- package/dist/sync/agents-md-sync.test.js +154 -0
- package/dist/sync/agents-md-sync.test.js.map +1 -0
- package/dist/sync/hook-sync.d.ts +8 -0
- package/dist/sync/hook-sync.d.ts.map +1 -0
- package/dist/sync/hook-sync.js +90 -0
- package/dist/sync/hook-sync.js.map +1 -0
- package/dist/sync/security-sync.d.ts +9 -0
- package/dist/sync/security-sync.d.ts.map +1 -0
- package/dist/sync/security-sync.js +161 -0
- package/dist/sync/security-sync.js.map +1 -0
- package/dist/sync/skill-sync.d.ts +10 -0
- package/dist/sync/skill-sync.d.ts.map +1 -0
- package/dist/sync/skill-sync.js +87 -0
- package/dist/sync/skill-sync.js.map +1 -0
- package/dist/sync/skill-sync.test.d.ts +2 -0
- package/dist/sync/skill-sync.test.d.ts.map +1 -0
- package/dist/sync/skill-sync.test.js +163 -0
- package/dist/sync/skill-sync.test.js.map +1 -0
- package/dist/wrapper/approval-memory-store.d.ts +40 -0
- package/dist/wrapper/approval-memory-store.d.ts.map +1 -0
- package/dist/wrapper/approval-memory-store.js +132 -0
- package/dist/wrapper/approval-memory-store.js.map +1 -0
- package/dist/wrapper/claude-code-process.d.ts +32 -34
- package/dist/wrapper/claude-code-process.d.ts.map +1 -1
- package/dist/wrapper/claude-code-process.js +181 -66
- package/dist/wrapper/claude-code-process.js.map +1 -1
- package/dist/wrapper/cleanup-registry.d.ts +7 -0
- package/dist/wrapper/cleanup-registry.d.ts.map +1 -0
- package/dist/wrapper/cleanup-registry.js +11 -0
- package/dist/wrapper/cleanup-registry.js.map +1 -0
- package/dist/wrapper/codex-session.d.ts +49 -0
- package/dist/wrapper/codex-session.d.ts.map +1 -0
- package/dist/wrapper/codex-session.js +470 -0
- package/dist/wrapper/codex-session.js.map +1 -0
- package/dist/wrapper/debug.d.ts +2 -0
- package/dist/wrapper/debug.d.ts.map +1 -0
- package/dist/wrapper/debug.js +7 -0
- package/dist/wrapper/debug.js.map +1 -0
- package/dist/wrapper/executable-provider-session.d.ts +26 -0
- package/dist/wrapper/executable-provider-session.d.ts.map +1 -0
- package/dist/wrapper/executable-provider-session.js +214 -0
- package/dist/wrapper/executable-provider-session.js.map +1 -0
- package/dist/wrapper/hook-executor.d.ts +21 -0
- package/dist/wrapper/hook-executor.d.ts.map +1 -0
- package/dist/wrapper/hook-executor.js +100 -0
- package/dist/wrapper/hook-executor.js.map +1 -0
- package/dist/wrapper/hook-registry.d.ts +10 -0
- package/dist/wrapper/hook-registry.d.ts.map +1 -0
- package/dist/wrapper/hook-registry.js +57 -0
- package/dist/wrapper/hook-registry.js.map +1 -0
- package/dist/wrapper/index.d.ts +83 -2
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +11 -0
- package/dist/wrapper/index.js.map +1 -1
- package/dist/wrapper/mcp-selector.d.ts +2 -0
- package/dist/wrapper/mcp-selector.d.ts.map +1 -0
- package/dist/wrapper/mcp-selector.js +8 -0
- package/dist/wrapper/mcp-selector.js.map +1 -0
- package/dist/wrapper/opencode-session.d.ts +69 -0
- package/dist/wrapper/opencode-session.d.ts.map +1 -0
- package/dist/wrapper/opencode-session.js +568 -0
- package/dist/wrapper/opencode-session.js.map +1 -0
- package/dist/wrapper/permission-evaluator.d.ts +57 -0
- package/dist/wrapper/permission-evaluator.d.ts.map +1 -0
- package/dist/wrapper/permission-evaluator.js +310 -0
- package/dist/wrapper/permission-evaluator.js.map +1 -0
- package/dist/wrapper/permission-normalizer.d.ts +13 -0
- package/dist/wrapper/permission-normalizer.d.ts.map +1 -0
- package/dist/wrapper/permission-normalizer.js +88 -0
- package/dist/wrapper/permission-normalizer.js.map +1 -0
- package/dist/wrapper/permission-policy-authorizer.d.ts +12 -0
- package/dist/wrapper/permission-policy-authorizer.d.ts.map +1 -0
- package/dist/wrapper/permission-policy-authorizer.js +64 -0
- package/dist/wrapper/permission-policy-authorizer.js.map +1 -0
- package/dist/wrapper/preamble-builder.d.ts +7 -0
- package/dist/wrapper/preamble-builder.d.ts.map +1 -0
- package/dist/wrapper/preamble-builder.js +103 -0
- package/dist/wrapper/preamble-builder.js.map +1 -0
- package/dist/wrapper/provider-context.d.ts +20 -0
- package/dist/wrapper/provider-context.d.ts.map +1 -0
- package/dist/wrapper/provider-context.js +58 -0
- package/dist/wrapper/provider-context.js.map +1 -0
- package/dist/wrapper/provider-session.d.ts +27 -0
- package/dist/wrapper/provider-session.d.ts.map +1 -0
- package/dist/wrapper/provider-session.js +208 -0
- package/dist/wrapper/provider-session.js.map +1 -0
- package/dist/wrapper/session-manager.d.ts +21 -4
- package/dist/wrapper/session-manager.d.ts.map +1 -1
- package/dist/wrapper/session-manager.js +173 -14
- package/dist/wrapper/session-manager.js.map +1 -1
- package/dist/wrapper/session-registry.d.ts +136 -0
- package/dist/wrapper/session-registry.d.ts.map +1 -0
- package/dist/wrapper/session-registry.js +977 -0
- package/dist/wrapper/session-registry.js.map +1 -0
- package/dist/wrapper/session-store.d.ts +63 -0
- package/dist/wrapper/session-store.d.ts.map +1 -0
- package/dist/wrapper/session-store.js +215 -0
- package/dist/wrapper/session-store.js.map +1 -0
- package/dist/wrapper/session.d.ts +127 -0
- package/dist/wrapper/session.d.ts.map +1 -0
- package/dist/wrapper/session.js +14 -0
- package/dist/wrapper/session.js.map +1 -0
- package/dist/wrapper/worktree-manager.d.ts +30 -0
- package/dist/wrapper/worktree-manager.d.ts.map +1 -0
- package/dist/wrapper/worktree-manager.js +139 -0
- package/dist/wrapper/worktree-manager.js.map +1 -0
- package/package.json +11 -7
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { CodexOAuthAdapter, CodexOAuthAuth, DevToolRegistry, TOOL_SCHEMAS, BashTool, ReadTool, WriteTool, EditTool, GrepTool, GlobTool, GitTool, textPart, appendExecutionIdentity, resolveExecutionIdentity, EventBus, } from "@kilnai/core";
|
|
3
|
+
import { buildProviderSystemPrompt } from "./preamble-builder.js";
|
|
4
|
+
import { PermissionPolicyAuthorizer } from "./permission-policy-authorizer.js";
|
|
5
|
+
function buildBuiltinTools() {
|
|
6
|
+
const registry = new DevToolRegistry();
|
|
7
|
+
registry.register(new BashTool());
|
|
8
|
+
registry.register(new ReadTool());
|
|
9
|
+
registry.register(new WriteTool());
|
|
10
|
+
registry.register(new EditTool());
|
|
11
|
+
registry.register(new GrepTool());
|
|
12
|
+
registry.register(new GlobTool());
|
|
13
|
+
registry.register(new GitTool());
|
|
14
|
+
const tools = new Map();
|
|
15
|
+
for (const tool of registry.list()) {
|
|
16
|
+
tools.set(tool.name, async (input) => {
|
|
17
|
+
const result = await tool.execute({ name: tool.name, input });
|
|
18
|
+
return { output: result.output, isError: result.isError, metadata: result.metadata };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return tools;
|
|
22
|
+
}
|
|
23
|
+
function buildToolDefinitions() {
|
|
24
|
+
return Object.values(TOOL_SCHEMAS).map((tool) => ({
|
|
25
|
+
name: tool.name,
|
|
26
|
+
description: tool.description,
|
|
27
|
+
inputSchema: tool.inputSchema,
|
|
28
|
+
tags: new Set(),
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function buildCapabilityMap() {
|
|
32
|
+
const map = new Map();
|
|
33
|
+
for (const tool of Object.values(TOOL_SCHEMAS)) {
|
|
34
|
+
map.set(tool.name, {
|
|
35
|
+
name: tool.name,
|
|
36
|
+
description: tool.description,
|
|
37
|
+
schema: tool.inputSchema,
|
|
38
|
+
tags: [],
|
|
39
|
+
annotations: tool.annotations,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return map;
|
|
43
|
+
}
|
|
44
|
+
function deriveCapability(policy) {
|
|
45
|
+
const supportedTools = ["bash", "read", "write", "edit", "grep", "glob", "git"];
|
|
46
|
+
return {
|
|
47
|
+
mcp: false,
|
|
48
|
+
streaming: true,
|
|
49
|
+
resumable: false,
|
|
50
|
+
resume: false,
|
|
51
|
+
costTrackingMode: "computed",
|
|
52
|
+
supportedTools,
|
|
53
|
+
maxContextTokens: null,
|
|
54
|
+
priority: 1,
|
|
55
|
+
fallbackTo: null,
|
|
56
|
+
permissionPolicy: policy,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export class ExecutableProviderSession {
|
|
60
|
+
sessionId;
|
|
61
|
+
capabilities;
|
|
62
|
+
config;
|
|
63
|
+
builtinTools;
|
|
64
|
+
toolDefinitions;
|
|
65
|
+
eventBus;
|
|
66
|
+
constructor(config) {
|
|
67
|
+
this.sessionId = randomUUID();
|
|
68
|
+
this.config = config;
|
|
69
|
+
this.builtinTools = buildBuiltinTools();
|
|
70
|
+
this.toolDefinitions = buildToolDefinitions();
|
|
71
|
+
this.eventBus = new EventBus(100);
|
|
72
|
+
this.capabilities = deriveCapability(config.permissionPolicy);
|
|
73
|
+
}
|
|
74
|
+
get providerSessionId() {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
async *run(options) {
|
|
78
|
+
const startedAt = Date.now();
|
|
79
|
+
let isError = false;
|
|
80
|
+
if (options.abortSignal?.aborted) {
|
|
81
|
+
yield {
|
|
82
|
+
type: "error",
|
|
83
|
+
code: "ABORTED",
|
|
84
|
+
message: "Aborted before start",
|
|
85
|
+
isRetryable: false,
|
|
86
|
+
};
|
|
87
|
+
yield {
|
|
88
|
+
type: "completed",
|
|
89
|
+
totalUsd: 0,
|
|
90
|
+
durationMs: Date.now() - startedAt,
|
|
91
|
+
isError: true,
|
|
92
|
+
isPreflightCrash: true,
|
|
93
|
+
};
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const { ModeBOrchestrator } = await import("@kilnai/runtime");
|
|
98
|
+
const { ModeBSession } = await import("@kilnai/runtime");
|
|
99
|
+
const hasStructuredPreamble = this.isStructuredPreamble(options.prompt);
|
|
100
|
+
const baseSystemPrompt = options.system ?? (hasStructuredPreamble ? options.prompt : (this.config.systemPrompt ?? ""));
|
|
101
|
+
const structuredMessages = options.messages;
|
|
102
|
+
const userPrompt = hasStructuredPreamble
|
|
103
|
+
? this.config.task
|
|
104
|
+
: options.prompt;
|
|
105
|
+
const systemPrompt = appendExecutionIdentity(buildProviderSystemPrompt(baseSystemPrompt, this.config.constraintInstructions), resolveExecutionIdentity({
|
|
106
|
+
configuredProvider: "codex-oauth",
|
|
107
|
+
configuredModel: this.config.model,
|
|
108
|
+
}));
|
|
109
|
+
void (options.cwd ?? this.config.cwd ?? process.cwd());
|
|
110
|
+
const auth = new CodexOAuthAuth();
|
|
111
|
+
const adapter = new CodexOAuthAdapter({
|
|
112
|
+
auth,
|
|
113
|
+
defaultModel: this.config.model,
|
|
114
|
+
});
|
|
115
|
+
const authorizer = new PermissionPolicyAuthorizer(this.config.permissionPolicy);
|
|
116
|
+
const capabilityMap = buildCapabilityMap();
|
|
117
|
+
const cliSession = new ModeBSession({
|
|
118
|
+
appName: "kiln-cli",
|
|
119
|
+
tenantId: "cli-session",
|
|
120
|
+
userId: this.sessionId,
|
|
121
|
+
systemPrompt,
|
|
122
|
+
idleTimeoutMs: 30 * 60 * 1000,
|
|
123
|
+
});
|
|
124
|
+
const orchestrator = new ModeBOrchestrator({
|
|
125
|
+
provider: adapter,
|
|
126
|
+
model: this.config.model,
|
|
127
|
+
tools: this.toolDefinitions,
|
|
128
|
+
builtinTools: this.builtinTools,
|
|
129
|
+
eventBus: this.eventBus,
|
|
130
|
+
toolAuthorizer: authorizer,
|
|
131
|
+
capabilityMap,
|
|
132
|
+
dangerousCommandDetector: undefined,
|
|
133
|
+
});
|
|
134
|
+
const promptParts = [textPart(userPrompt)];
|
|
135
|
+
if (structuredMessages && structuredMessages.length > 0) {
|
|
136
|
+
this.hydrateConversation(cliSession, structuredMessages);
|
|
137
|
+
}
|
|
138
|
+
const result = await orchestrator.processMessage(cliSession, promptParts);
|
|
139
|
+
for (const part of result.parts) {
|
|
140
|
+
if (part.type === "text") {
|
|
141
|
+
yield { type: "text_delta", content: part.text };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const toolExec of result.toolExecutions ?? []) {
|
|
145
|
+
yield {
|
|
146
|
+
type: "tool_result",
|
|
147
|
+
toolName: toolExec.toolName,
|
|
148
|
+
output: toolExec.resultSummary,
|
|
149
|
+
};
|
|
150
|
+
if (toolExec.fileChanges && toolExec.fileChanges.length > 0) {
|
|
151
|
+
for (const fc of toolExec.fileChanges) {
|
|
152
|
+
yield {
|
|
153
|
+
type: "file_changed",
|
|
154
|
+
path: fc.path,
|
|
155
|
+
changeType: fc.changeType,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (result.escalation) {
|
|
161
|
+
yield {
|
|
162
|
+
type: "error",
|
|
163
|
+
code: "ESCALATION",
|
|
164
|
+
message: result.escalation.reason,
|
|
165
|
+
isRetryable: false,
|
|
166
|
+
};
|
|
167
|
+
isError = true;
|
|
168
|
+
}
|
|
169
|
+
yield { type: "cost_update", usd: 0, mode: "computed" };
|
|
170
|
+
yield {
|
|
171
|
+
type: "completed",
|
|
172
|
+
totalUsd: 0,
|
|
173
|
+
durationMs: Date.now() - startedAt,
|
|
174
|
+
isError,
|
|
175
|
+
isPreflightCrash: false,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
yield {
|
|
180
|
+
type: "error",
|
|
181
|
+
code: "EXECUTABLE_SESSION_ERROR",
|
|
182
|
+
message: err instanceof Error ? err.message : String(err),
|
|
183
|
+
isRetryable: false,
|
|
184
|
+
};
|
|
185
|
+
yield {
|
|
186
|
+
type: "completed",
|
|
187
|
+
totalUsd: 0,
|
|
188
|
+
durationMs: Date.now() - startedAt,
|
|
189
|
+
isError: true,
|
|
190
|
+
isPreflightCrash: false,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async dispose() {
|
|
195
|
+
// Stateless session; no process/socket lifecycle to tear down.
|
|
196
|
+
}
|
|
197
|
+
isStructuredPreamble(prompt) {
|
|
198
|
+
return prompt.trimStart().startsWith("<kiln-preamble>");
|
|
199
|
+
}
|
|
200
|
+
hydrateConversation(session, messages) {
|
|
201
|
+
for (let i = 0; i < messages.length - 1; i++) {
|
|
202
|
+
const message = messages[i];
|
|
203
|
+
if (!message)
|
|
204
|
+
continue;
|
|
205
|
+
if (message.role === "user") {
|
|
206
|
+
session.addUserMessage(message.parts);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
session.addAssistantMessage(message.parts);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=executable-provider-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executable-provider-session.js","sourceRoot":"","sources":["../../src/wrapper/executable-provider-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,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,CAAC,iBAAiB,CAAC,CAAC;IAC1D,CAAC;IAEO,mBAAmB,CACzB,OAGC,EACD,QAAiC;QAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,CAAC,OAAO;gBAAE,SAAS;YACvB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC5B,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HookEvent, HookHandler } from "../kiln-yaml-types.js";
|
|
2
|
+
export interface HookContext {
|
|
3
|
+
event: HookEvent;
|
|
4
|
+
toolName?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
workingDirectory: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HookResult {
|
|
9
|
+
handler: HookHandler;
|
|
10
|
+
exitCode: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
timedOut: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class HookExecutor {
|
|
16
|
+
run(handlers: readonly HookHandler[], ctx: HookContext): Promise<HookResult[]>;
|
|
17
|
+
private executeHandler;
|
|
18
|
+
private runSync;
|
|
19
|
+
private runAsync;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=hook-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-executor.d.ts","sourceRoot":"","sources":["../../src/wrapper/hook-executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,YAAY;IACjB,GAAG,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YAStE,cAAc;IAO5B,OAAO,CAAC,OAAO;IA6Cf,OAAO,CAAC,QAAQ;CAgDjB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
export class HookExecutor {
|
|
3
|
+
async run(handlers, ctx) {
|
|
4
|
+
const results = [];
|
|
5
|
+
for (const handler of handlers) {
|
|
6
|
+
const result = await this.executeHandler(handler, ctx);
|
|
7
|
+
results.push(result);
|
|
8
|
+
}
|
|
9
|
+
return results;
|
|
10
|
+
}
|
|
11
|
+
async executeHandler(handler, ctx) {
|
|
12
|
+
if (handler.async) {
|
|
13
|
+
return this.runAsync(handler, ctx);
|
|
14
|
+
}
|
|
15
|
+
return this.runSync(handler, ctx);
|
|
16
|
+
}
|
|
17
|
+
runSync(handler, ctx) {
|
|
18
|
+
const env = {
|
|
19
|
+
...process.env,
|
|
20
|
+
KILN_HOOK_EVENT: ctx.event,
|
|
21
|
+
KILN_HOOK_TOOL: ctx.toolName ?? "",
|
|
22
|
+
KILN_SESSION_ID: ctx.sessionId ?? "",
|
|
23
|
+
};
|
|
24
|
+
const timeoutMs = handler.timeoutSec ? handler.timeoutSec * 1000 : undefined;
|
|
25
|
+
const options = {
|
|
26
|
+
cwd: ctx.workingDirectory,
|
|
27
|
+
env,
|
|
28
|
+
shell: true,
|
|
29
|
+
encoding: "utf8",
|
|
30
|
+
};
|
|
31
|
+
if (timeoutMs)
|
|
32
|
+
options.timeout = timeoutMs;
|
|
33
|
+
try {
|
|
34
|
+
const result = spawnSync(handler.command, [], options);
|
|
35
|
+
return {
|
|
36
|
+
handler,
|
|
37
|
+
exitCode: result.status ?? -1,
|
|
38
|
+
stdout: result.stdout ?? "",
|
|
39
|
+
stderr: result.stderr ?? "",
|
|
40
|
+
timedOut: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
45
|
+
return {
|
|
46
|
+
handler,
|
|
47
|
+
exitCode: -1,
|
|
48
|
+
stdout: "",
|
|
49
|
+
stderr: errorMessage,
|
|
50
|
+
timedOut: errorMessage.includes("timeout"),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
runAsync(handler, ctx) {
|
|
55
|
+
const env = {
|
|
56
|
+
...process.env,
|
|
57
|
+
KILN_HOOK_EVENT: ctx.event,
|
|
58
|
+
KILN_HOOK_TOOL: ctx.toolName ?? "",
|
|
59
|
+
KILN_SESSION_ID: ctx.sessionId ?? "",
|
|
60
|
+
};
|
|
61
|
+
let proc = null;
|
|
62
|
+
let timedOut = false;
|
|
63
|
+
try {
|
|
64
|
+
proc = spawn(handler.command, [], {
|
|
65
|
+
cwd: ctx.workingDirectory,
|
|
66
|
+
env,
|
|
67
|
+
shell: true,
|
|
68
|
+
detached: true,
|
|
69
|
+
stdio: "ignore",
|
|
70
|
+
});
|
|
71
|
+
proc.unref();
|
|
72
|
+
if (handler.timeoutSec) {
|
|
73
|
+
const timeoutMs = handler.timeoutSec * 1000;
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
if (proc && !proc.killed) {
|
|
76
|
+
timedOut = true;
|
|
77
|
+
proc.kill();
|
|
78
|
+
}
|
|
79
|
+
}, timeoutMs);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return {
|
|
84
|
+
handler,
|
|
85
|
+
exitCode: -1,
|
|
86
|
+
stdout: "",
|
|
87
|
+
stderr: "Failed to spawn process",
|
|
88
|
+
timedOut: false,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
handler,
|
|
93
|
+
exitCode: 0,
|
|
94
|
+
stdout: "",
|
|
95
|
+
stderr: "",
|
|
96
|
+
timedOut,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=hook-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-executor.js","sourceRoot":"","sources":["../../src/wrapper/hook-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAqB,MAAM,oBAAoB,CAAC;AAmBzE,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,GAAG,CAAC,QAAgC,EAAE,GAAgB;QAC1D,MAAM,OAAO,GAAiB,EAAE,CAAC;QACjC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACvD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,OAAoB,EAAE,GAAgB;QACjE,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC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AC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HookEvent, HookHandler, KilnHooksConfig } from "../kiln-yaml-types.js";
|
|
2
|
+
export declare class HookRegistry {
|
|
3
|
+
private readonly rules;
|
|
4
|
+
constructor(config: KilnHooksConfig);
|
|
5
|
+
private initRules;
|
|
6
|
+
hasHooks(event: HookEvent): boolean;
|
|
7
|
+
getRules(event: HookEvent, toolName?: string): readonly HookHandler[];
|
|
8
|
+
private matchesGlob;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=hook-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-registry.d.ts","sourceRoot":"","sources":["../../src/wrapper/hook-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAY,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/F,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;gBAEhD,MAAM,EAAE,eAAe;IAKnC,OAAO,CAAC,SAAS;IAUjB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAInC,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE;IAerE,OAAO,CAAC,WAAW;CAapB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export class HookRegistry {
|
|
2
|
+
rules;
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.rules = new Map();
|
|
5
|
+
this.initRules(config);
|
|
6
|
+
}
|
|
7
|
+
initRules(config) {
|
|
8
|
+
if (config.PreToolUse)
|
|
9
|
+
this.rules.set("PreToolUse", config.PreToolUse);
|
|
10
|
+
if (config.PostToolUse)
|
|
11
|
+
this.rules.set("PostToolUse", config.PostToolUse);
|
|
12
|
+
if (config.UserPromptSubmit)
|
|
13
|
+
this.rules.set("UserPromptSubmit", config.UserPromptSubmit);
|
|
14
|
+
if (config.SessionStart)
|
|
15
|
+
this.rules.set("SessionStart", config.SessionStart);
|
|
16
|
+
if (config.SessionEnd)
|
|
17
|
+
this.rules.set("SessionEnd", config.SessionEnd);
|
|
18
|
+
if (config.SubagentStart)
|
|
19
|
+
this.rules.set("SubagentStart", config.SubagentStart);
|
|
20
|
+
if (config.SubagentStop)
|
|
21
|
+
this.rules.set("SubagentStop", config.SubagentStop);
|
|
22
|
+
}
|
|
23
|
+
hasHooks(event) {
|
|
24
|
+
return this.rules.has(event);
|
|
25
|
+
}
|
|
26
|
+
getRules(event, toolName) {
|
|
27
|
+
const rules = this.rules.get(event);
|
|
28
|
+
if (!rules)
|
|
29
|
+
return [];
|
|
30
|
+
const handlers = [];
|
|
31
|
+
for (const rule of rules) {
|
|
32
|
+
if (!rule.matcher || !toolName) {
|
|
33
|
+
handlers.push(...rule.hooks);
|
|
34
|
+
}
|
|
35
|
+
else if (this.matchesGlob(rule.matcher, toolName)) {
|
|
36
|
+
handlers.push(...rule.hooks);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return handlers;
|
|
40
|
+
}
|
|
41
|
+
matchesGlob(pattern, value) {
|
|
42
|
+
const parts = pattern.split("*");
|
|
43
|
+
if (parts.length === 1)
|
|
44
|
+
return pattern === value;
|
|
45
|
+
let pos = 0;
|
|
46
|
+
for (const part of parts) {
|
|
47
|
+
if (part === "")
|
|
48
|
+
continue;
|
|
49
|
+
const idx = value.indexOf(part, pos);
|
|
50
|
+
if (idx === -1)
|
|
51
|
+
return false;
|
|
52
|
+
pos = idx + part.length;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=hook-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-registry.js","sourceRoot":"","sources":["../../src/wrapper/hook-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IACN,KAA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C,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,MAAM,QAAQ,GAAkB,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC/B,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;iBAAM,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;gBACpD,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,WAAW,CAAC,OAAe,EAAE,KAAa;QAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,OAAO,KAAK,KAAK,CAAC;QAEjD,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,KAAK,EAAE;gBAAE,SAAS;YAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACrC,IAAI,GAAG,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC7B,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/wrapper/index.d.ts
CHANGED
|
@@ -5,16 +5,50 @@
|
|
|
5
5
|
* Post-session: save memory, generate report, sync to git.
|
|
6
6
|
*/
|
|
7
7
|
import type { DomainConfig } from "@kilnai/core";
|
|
8
|
+
import type { ProjectedContext, ProjectedContextBlockKind } from "../application/context-types.js";
|
|
9
|
+
import type { KilnPermissionPolicy } from "./session.js";
|
|
8
10
|
/** Session mode determines how Claude Code is launched */
|
|
9
|
-
export type SessionMode = "api-key" | "byok";
|
|
11
|
+
export type SessionMode = "api-key" | "byok" | "cli-wrapper";
|
|
12
|
+
export type ResumeStrategy = "none" | "cache-first" | "provider-native" | "fallback-replay";
|
|
13
|
+
export interface ResumeFeedback {
|
|
14
|
+
readonly sampleSize: number;
|
|
15
|
+
readonly preferredStrategy?: Extract<ResumeStrategy, "cache-first" | "provider-native" | "fallback-replay">;
|
|
16
|
+
readonly influencedChoice: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ResumeOutcome {
|
|
19
|
+
readonly succeeded: boolean;
|
|
20
|
+
readonly finalProvider?: string;
|
|
21
|
+
readonly costUsd: number;
|
|
22
|
+
readonly toolCallCount: number;
|
|
23
|
+
readonly durationMs: number;
|
|
24
|
+
readonly verificationPassed?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ContextGovernanceSummary {
|
|
27
|
+
readonly selectedTokens: number;
|
|
28
|
+
readonly tokenBudget?: number;
|
|
29
|
+
readonly overflow: boolean;
|
|
30
|
+
readonly selectedCount: number;
|
|
31
|
+
readonly deferredCount: number;
|
|
32
|
+
readonly selectedKinds: Partial<Record<ProjectedContextBlockKind, number>>;
|
|
33
|
+
readonly deferredKinds: Partial<Record<ProjectedContextBlockKind, number>>;
|
|
34
|
+
readonly selectedSources: Record<string, number>;
|
|
35
|
+
readonly deferredSources: Record<string, number>;
|
|
36
|
+
readonly deferredReasons: readonly string[];
|
|
37
|
+
}
|
|
10
38
|
/** Pre-session context built by the wrapper */
|
|
11
39
|
export interface SessionContext {
|
|
12
40
|
readonly mode: SessionMode;
|
|
13
41
|
readonly domain: DomainConfig;
|
|
14
42
|
readonly systemPrompt: string;
|
|
43
|
+
readonly projectedContext: ProjectedContext;
|
|
15
44
|
readonly mcpServerEntryPath: string;
|
|
16
45
|
readonly workingDirectory: string;
|
|
17
46
|
readonly task: string;
|
|
47
|
+
readonly worktreePath?: string;
|
|
48
|
+
readonly isWorker?: boolean;
|
|
49
|
+
readonly resumeSessionId?: string;
|
|
50
|
+
readonly resumeStrategy: ResumeStrategy;
|
|
51
|
+
readonly resumeFeedback?: ResumeFeedback;
|
|
18
52
|
}
|
|
19
53
|
/** Post-session report generated by the wrapper */
|
|
20
54
|
export interface SessionReport {
|
|
@@ -25,18 +59,65 @@ export interface SessionReport {
|
|
|
25
59
|
readonly cost: {
|
|
26
60
|
readonly total: number;
|
|
27
61
|
readonly byRoleModel: Record<string, number>;
|
|
62
|
+
readonly breakdown?: Array<{
|
|
63
|
+
readonly turn: number;
|
|
64
|
+
readonly inputTokens: number;
|
|
65
|
+
readonly outputTokens: number;
|
|
66
|
+
readonly cacheReadTokens: number;
|
|
67
|
+
readonly costUsd: number;
|
|
68
|
+
}>;
|
|
28
69
|
};
|
|
29
70
|
readonly duration: number;
|
|
71
|
+
readonly verificationResult?: {
|
|
72
|
+
readonly passed: boolean;
|
|
73
|
+
readonly checks: readonly {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly passed: boolean;
|
|
76
|
+
readonly output: string;
|
|
77
|
+
readonly duration: number;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
readonly evalScore?: {
|
|
81
|
+
readonly score: number;
|
|
82
|
+
readonly label: "excellent" | "good" | "fair" | "poor";
|
|
83
|
+
readonly signals: readonly string[];
|
|
84
|
+
};
|
|
85
|
+
readonly resumedFrom?: string;
|
|
86
|
+
readonly resumeStrategy?: ResumeStrategy;
|
|
87
|
+
readonly resumeFeedback?: ResumeFeedback;
|
|
88
|
+
readonly resumeOutcome?: ResumeOutcome;
|
|
89
|
+
readonly contextGovernance?: ContextGovernanceSummary;
|
|
30
90
|
}
|
|
31
91
|
/** Wrapper configuration */
|
|
32
92
|
export interface WrapperConfig {
|
|
33
93
|
readonly mode: SessionMode;
|
|
34
94
|
readonly apiKey?: string;
|
|
35
95
|
readonly provider?: string;
|
|
36
|
-
readonly
|
|
96
|
+
readonly permissionPolicy: KilnPermissionPolicy;
|
|
37
97
|
}
|
|
98
|
+
export { buildPreamble } from "./preamble-builder.js";
|
|
99
|
+
export { DefaultContextGovernor } from "../application/context-governor.js";
|
|
100
|
+
export type { ContextGovernor, ProjectContextInput, } from "../application/context-governor.js";
|
|
101
|
+
export type { ProjectedContext, ProjectedContextBlock, ProjectedContextBlockKind, } from "../application/context-types.js";
|
|
102
|
+
export type { SessionLedger } from "../application/session-ledger.js";
|
|
103
|
+
export { WorktreeManager } from "./worktree-manager.js";
|
|
38
104
|
export { ClaudeSession } from "./claude-code-process.js";
|
|
39
105
|
export type { ClaudeSessionConfig } from "./claude-code-process.js";
|
|
106
|
+
export { OpenCodeSession } from "./opencode-session.js";
|
|
107
|
+
export { CodexSession } from "./codex-session.js";
|
|
40
108
|
export { SessionManager } from "./session-manager.js";
|
|
41
109
|
export type { KilnAppConfig, SystemPromptOptions } from "../config.js";
|
|
110
|
+
export type { CostTrackingMode, SessionEvent, SessionCapabilities, SessionRunOptions, IKilnSession, KilnPermissionAction, KilnPermissionApproval, KilnSandboxMode, KilnToolPermissionRule, KilnCommandPermissionRule, KilnFileGovernancePolicy, KilnDataDestination, KilnDataFirewallRule, KilnAgentPermissionScope, KilnPermissionPolicy, } from "./session.js";
|
|
111
|
+
export { SessionRegistry, createDefaultRegistry, getProviderDisplayInfo, translatePermission, } from "./session-registry.js";
|
|
112
|
+
export type { ProviderId, ProviderDisplayInfo, SessionRequirements, } from "./session-registry.js";
|
|
113
|
+
export { SessionStore } from "./session-store.js";
|
|
114
|
+
export type { SessionRecord } from "./session-store.js";
|
|
115
|
+
export { ApprovalMemoryStore } from "./approval-memory-store.js";
|
|
116
|
+
export type { ApprovalScope, ApprovalSurface, ApprovalMemoryRecord, ApprovalGrantInput, ApprovalMatchQuery, } from "./approval-memory-store.js";
|
|
117
|
+
export { createPermissionEvaluator, resolveEffectivePermissionPolicy } from "./permission-evaluator.js";
|
|
118
|
+
export type { PermissionEvaluator, PermissionEvaluationRequest, PermissionDecision, PermissionDecisionSource, PermissionDecisionMatch, PermissionScopeInfo, EffectivePermissionPolicyResult, } from "./permission-evaluator.js";
|
|
119
|
+
export { HookRegistry } from "./hook-registry.js";
|
|
120
|
+
export { HookExecutor } from "./hook-executor.js";
|
|
121
|
+
export type { HookContext, HookResult } from "./hook-executor.js";
|
|
122
|
+
export type { HookEvent, HookHandler, HookRule, KilnHooksConfig, } from "../kiln-yaml-types.js";
|
|
42
123
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,MAAM,GACN,aAAa,CAAC;AAElB,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAE5F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,EAAE,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;IAC5G,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;I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MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
|
package/dist/wrapper/index.js
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* During: Claude Code runs with Kiln MCP tools available.
|
|
5
5
|
* Post-session: save memory, generate report, sync to git.
|
|
6
6
|
*/
|
|
7
|
+
export { buildPreamble } from "./preamble-builder.js";
|
|
8
|
+
export { DefaultContextGovernor } from "../application/context-governor.js";
|
|
9
|
+
export { WorktreeManager } from "./worktree-manager.js";
|
|
7
10
|
export { ClaudeSession } from "./claude-code-process.js";
|
|
11
|
+
export { OpenCodeSession } from "./opencode-session.js";
|
|
12
|
+
export { CodexSession } from "./codex-session.js";
|
|
8
13
|
export { SessionManager } from "./session-manager.js";
|
|
14
|
+
export { SessionRegistry, createDefaultRegistry, getProviderDisplayInfo, translatePermission, } from "./session-registry.js";
|
|
15
|
+
export { SessionStore } from "./session-store.js";
|
|
16
|
+
export { ApprovalMemoryStore } from "./approval-memory-store.js";
|
|
17
|
+
export { createPermissionEvaluator, resolveEffectivePermissionPolicy } from "./permission-evaluator.js";
|
|
18
|
+
export { HookRegistry } from "./hook-registry.js";
|
|
19
|
+
export { HookExecutor } from "./hook-executor.js";
|
|
9
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyGH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAW5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAmBtD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQjE,OAAO,EAAE,yBAAyB,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAWxG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-selector.d.ts","sourceRoot":"","sources":["../../src/wrapper/mcp-selector.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-selector.js","sourceRoot":"","sources":["../../src/wrapper/mcp-selector.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,OAAO,WAAW;SACf,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|