typeclaw 0.50.0 → 0.51.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/dist/types/agent/bash-sandbox-env.d.ts +15 -0
- package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
- package/dist/types/agent/bash-sandbox.d.ts +94 -0
- package/dist/types/agent/compaction.d.ts +4 -4
- package/dist/types/agent/idle-compaction.d.ts +1 -0
- package/dist/types/agent/index.d.ts +5 -17
- package/dist/types/agent/output-allowance.d.ts +4 -0
- package/dist/types/agent/plugin-tools.d.ts +4 -75
- package/dist/types/agent/system-prompt-composition.d.ts +17 -0
- package/dist/types/agent/tools/ddg.d.ts +9 -0
- package/dist/types/agent/tools/stream-snapshot.d.ts +1 -1
- package/dist/types/agent/tools/webfetch/tool.d.ts +1 -1
- package/dist/types/channels/github-review-check.d.ts +1 -1
- package/dist/types/channels/router.d.ts +11 -49
- package/dist/types/config/config.d.ts +24 -11
- package/dist/types/config/providers.d.ts +3 -1
- package/dist/types/container/start.d.ts +1 -0
- package/dist/types/eval/cell.d.ts +26 -0
- package/dist/types/eval/config.d.ts +19 -0
- package/dist/types/eval/dispatch.d.ts +7 -0
- package/dist/types/eval/kernel.d.ts +28 -0
- package/dist/types/eval/process.d.ts +23 -0
- package/dist/types/eval/protocol.d.ts +34 -0
- package/dist/types/eval/sandbox.d.ts +10 -0
- package/dist/types/eval/tool.d.ts +17 -0
- package/dist/types/eval/wire.d.ts +33 -0
- package/dist/types/sandbox/env-exposure.d.ts +2 -0
- package/package.json +5 -5
- package/src/agent/bash-sandbox-env.ts +104 -0
- package/src/agent/bash-sandbox-proc.ts +70 -0
- package/src/agent/bash-sandbox.ts +225 -0
- package/src/agent/compaction.ts +22 -10
- package/src/agent/idle-compaction.ts +7 -3
- package/src/agent/index.ts +66 -157
- package/src/agent/output-allowance.ts +7 -0
- package/src/agent/plugin-tools.ts +29 -379
- package/src/agent/session-origin.ts +2 -1
- package/src/agent/subagent-completion-reminder.ts +2 -2
- package/src/agent/system-prompt-composition.ts +141 -0
- package/src/agent/system-prompt.ts +4 -4
- package/src/agent/todo/scope.ts +1 -1
- package/src/agent/tools/ddg.ts +71 -11
- package/src/agent/tools-without-local-file-operands.ts +4 -0
- package/src/browser/fill-secret.ts +307 -0
- package/src/bundled-plugins/explorer/explorer.ts +1 -1
- package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
- package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
- package/src/bundled-plugins/github-cli-auth/index.ts +10 -1
- package/src/bundled-plugins/managed-browser/index.ts +107 -2
- package/src/bundled-plugins/memory/dreaming.ts +4 -1
- package/src/bundled-plugins/memory/load-memory.ts +2 -4
- package/src/bundled-plugins/memory/memory-logger.ts +74 -2
- package/src/bundled-plugins/memory/transcript-preload.ts +103 -0
- package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
- package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
- package/src/channels/adapters/discord-bot-reference.ts +5 -4
- package/src/channels/adapters/discord-bot.ts +1 -0
- package/src/channels/adapters/discord-classify.ts +8 -3
- package/src/channels/adapters/discord.ts +29 -0
- package/src/channels/github-review-check.ts +5 -1
- package/src/channels/github-review-verdict-coordinator.ts +68 -2
- package/src/channels/router.ts +88 -107
- package/src/channels/subagent-completion-bridge.ts +3 -2
- package/src/cli/hostd.ts +3 -0
- package/src/config/config.ts +15 -0
- package/src/config/providers.ts +10 -4
- package/src/container/start.ts +37 -1
- package/src/doctor/checks.ts +25 -16
- package/src/doctor/index.ts +48 -12
- package/src/doctor/operational-incidents.ts +16 -1
- package/src/doctor/plugin-bridge.ts +14 -1
- package/src/doctor/stage.ts +14 -0
- package/src/doctor/types.ts +6 -0
- package/src/eval/cell.ts +93 -0
- package/src/eval/config.ts +32 -0
- package/src/eval/dispatch.ts +67 -0
- package/src/eval/entry.ts +261 -0
- package/src/eval/kernel.ts +154 -0
- package/src/eval/process.ts +113 -0
- package/src/eval/protocol.ts +26 -0
- package/src/eval/redeclare.ts +174 -0
- package/src/eval/sandbox.ts +114 -0
- package/src/eval/tool.ts +98 -0
- package/src/eval/wire.ts +93 -0
- package/src/operations/classify-tool-outcome.ts +1 -1
- package/src/plugin/core-tool-names.ts +6 -1
- package/src/sandbox/env-exposure.ts +20 -0
- package/src/server/index.ts +46 -11
- package/src/skills/typeclaw-config/SKILL.md +20 -2
- package/typeclaw.schema.json +52 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type BashEnvOverlay = Record<string, string>;
|
|
2
|
+
export declare function buildSandboxEnvPolicy(overlay: BashEnvOverlay | undefined, runtimeEnv: Record<string, string> | undefined, exposableEnvNames?: readonly string[], withhold?: readonly string[]): {
|
|
3
|
+
inherit?: string[];
|
|
4
|
+
set?: Record<string, string>;
|
|
5
|
+
withhold?: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function spreadSandboxEnv(policy: ReturnType<typeof buildSandboxEnvPolicy>): {
|
|
8
|
+
env?: ReturnType<typeof buildSandboxEnvPolicy>;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveExposableBashEnvNames(agentDir: string): {
|
|
11
|
+
exposable: string[];
|
|
12
|
+
withheld: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare function buildRoleScopedConfigEnv(agentDir: string, hiddenDirs: string[], envOverlay: BashEnvOverlay | undefined): BashEnvOverlay | undefined;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ProcStrategyResolution = {
|
|
2
|
+
strategy: 'real-proc' | 'proc-bind';
|
|
3
|
+
degradeReason?: undefined;
|
|
4
|
+
} | {
|
|
5
|
+
strategy: 'tmpfs';
|
|
6
|
+
degradeReason: 'definitive' | 'unverified';
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveProcStrategy(): Promise<ProcStrategyResolution>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { PermissionService } from "../permissions/permissions.js";
|
|
2
|
+
import { buildSandboxedCommand, cleanupPrivilegedSandboxRuntime, resolvePrivilegedSandboxRuntime, verifyPrivilegedSandboxRuntime, type SandboxMount, type SandboxNetwork, type SandboxPolicy, type DependencyBinReconciliation } from "../sandbox/index.js";
|
|
3
|
+
import { type ProcStrategyResolution } from "./bash-sandbox-proc.js";
|
|
4
|
+
import type { SessionOrigin } from "./session-origin.js";
|
|
5
|
+
export type DeferredBashPreparationResult = {
|
|
6
|
+
command: string;
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
mount: Extract<SandboxMount, {
|
|
9
|
+
type: 'ro-bind';
|
|
10
|
+
}>;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type DeferredBashPreparation = () => Promise<DeferredBashPreparationResult>;
|
|
14
|
+
export type BashSandboxBoundary = {
|
|
15
|
+
ensureAvailable: () => Promise<void>;
|
|
16
|
+
buildCommand: typeof buildSandboxedCommand;
|
|
17
|
+
resolveProcStrategy?: () => Promise<ProcStrategyResolution>;
|
|
18
|
+
resolveRuntime?: typeof resolvePrivilegedSandboxRuntime;
|
|
19
|
+
verifyRuntime?: typeof verifyPrivilegedSandboxRuntime;
|
|
20
|
+
cleanupRuntime?: typeof cleanupPrivilegedSandboxRuntime;
|
|
21
|
+
};
|
|
22
|
+
type BashFilesystemPolicyOptions = {
|
|
23
|
+
agentDir: string;
|
|
24
|
+
canWriteAgentRoot: boolean;
|
|
25
|
+
masks: {
|
|
26
|
+
dirs: string[];
|
|
27
|
+
files: string[];
|
|
28
|
+
};
|
|
29
|
+
writable: {
|
|
30
|
+
dirs: string[];
|
|
31
|
+
files: string[];
|
|
32
|
+
};
|
|
33
|
+
protected: {
|
|
34
|
+
dirs: string[];
|
|
35
|
+
files: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type PreparedBashSandbox = {
|
|
39
|
+
commandString: string;
|
|
40
|
+
policy: SandboxPolicy;
|
|
41
|
+
verify: () => Promise<void>;
|
|
42
|
+
cleanup: () => Promise<void>;
|
|
43
|
+
spawnEnv: Record<string, string>;
|
|
44
|
+
dependencyBins?: DependencyBinReconciliation;
|
|
45
|
+
withheld: {
|
|
46
|
+
paths: {
|
|
47
|
+
dirs: string[];
|
|
48
|
+
files: string[];
|
|
49
|
+
};
|
|
50
|
+
envNames: string[];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export declare function buildBashFilesystemPolicy(options: BashFilesystemPolicyOptions): {
|
|
54
|
+
writableRoot: {
|
|
55
|
+
dir: string;
|
|
56
|
+
};
|
|
57
|
+
masks: {
|
|
58
|
+
dirs: string[];
|
|
59
|
+
files: string[];
|
|
60
|
+
};
|
|
61
|
+
protected: {
|
|
62
|
+
dirs: string[];
|
|
63
|
+
files: string[];
|
|
64
|
+
};
|
|
65
|
+
writable?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
masks: {
|
|
68
|
+
dirs: string[];
|
|
69
|
+
files: string[];
|
|
70
|
+
};
|
|
71
|
+
writable: {
|
|
72
|
+
dirs: string[];
|
|
73
|
+
files: string[];
|
|
74
|
+
};
|
|
75
|
+
protected: {
|
|
76
|
+
dirs: string[];
|
|
77
|
+
files: string[];
|
|
78
|
+
};
|
|
79
|
+
writableRoot?: undefined;
|
|
80
|
+
};
|
|
81
|
+
export type BashSandboxRequest = {
|
|
82
|
+
readonly command: string;
|
|
83
|
+
readonly permissions: PermissionService;
|
|
84
|
+
readonly origin: SessionOrigin | undefined;
|
|
85
|
+
readonly agentDir: string;
|
|
86
|
+
readonly sessionId: string;
|
|
87
|
+
readonly envOverlay?: Record<string, string>;
|
|
88
|
+
readonly envWithhold?: string[];
|
|
89
|
+
readonly deferredPreparation?: DeferredBashPreparation;
|
|
90
|
+
readonly boundary?: BashSandboxBoundary;
|
|
91
|
+
readonly network?: SandboxNetwork;
|
|
92
|
+
};
|
|
93
|
+
export declare function prepareBashSandbox(options: BashSandboxRequest): Promise<PreparedBashSandbox>;
|
|
94
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { KnownApi, Model } from '@earendil-works/pi-ai';
|
|
2
2
|
import { SettingsManager } from '@earendil-works/pi-coding-agent';
|
|
3
3
|
export declare const COMPACTION_TRIGGER_PERCENT = 0.8;
|
|
4
|
-
export declare const COMPACTION_ABSOLUTE_TRIGGER_TOKENS =
|
|
4
|
+
export declare const COMPACTION_ABSOLUTE_TRIGGER_TOKENS = 200000;
|
|
5
5
|
export declare const COMPACTION_KEEP_RECENT_TOKENS = 20000;
|
|
6
|
-
export declare function compactionTriggerTokens<TApi extends KnownApi>(model: Model<TApi
|
|
7
|
-
export declare function reserveTokensForModel<TApi extends KnownApi>(model: Model<TApi
|
|
8
|
-
export declare function createCompactionSettingsManager<TApi extends KnownApi>(model: Model<TApi
|
|
6
|
+
export declare function compactionTriggerTokens<TApi extends KnownApi>(model: Model<TApi>, maxTriggerTokens?: number): number;
|
|
7
|
+
export declare function reserveTokensForModel<TApi extends KnownApi>(model: Model<TApi>, maxTriggerTokens?: number): number;
|
|
8
|
+
export declare function createCompactionSettingsManager<TApi extends KnownApi>(model: Model<TApi>, maxTriggerTokens?: number): SettingsManager;
|
|
@@ -2,6 +2,8 @@ import { createAgentSession, DefaultResourceLoader, SessionManager } from '@eare
|
|
|
2
2
|
import type { AgentSession, ToolDefinition } from '@earendil-works/pi-coding-agent';
|
|
3
3
|
import type { ChannelRouter } from "../channels/router.js";
|
|
4
4
|
import { type Models, type ResolvedProfile, type ThinkingLevel } from "../config/index.js";
|
|
5
|
+
import { type SystemPromptMode } from "./system-prompt-composition.js";
|
|
6
|
+
export { composeSystemPrompt, deriveSystemPromptMode, type SystemPromptMode, type SystemPromptComposition, } from "./system-prompt-composition.js";
|
|
5
7
|
import { type ModelRef } from "../config/providers.js";
|
|
6
8
|
import type { McpManager } from "../mcp/manager.js";
|
|
7
9
|
import { type PermissionService, type RolesConfig } from "../permissions/index.js";
|
|
@@ -12,14 +14,14 @@ import type { InternalGuard } from "./guard-types.js";
|
|
|
12
14
|
import type { LiveSubagentRegistry } from "./live-subagents.js";
|
|
13
15
|
import type { RestartHandoffOrigin } from "./restart-handoff/index.js";
|
|
14
16
|
import type { SubagentBashPolicy } from "./reviewer-bash-policy.js";
|
|
15
|
-
import { type SessionOrigin
|
|
17
|
+
import { type SessionOrigin } from "./session-origin.js";
|
|
16
18
|
import type { CreateSessionForSubagent, SubagentCoalescer, SubagentRegistry } from "./subagents.js";
|
|
17
19
|
import { type ToolResultBudget } from "./tool-result-budget.js";
|
|
18
20
|
export type { SessionOrigin } from "./session-origin.js";
|
|
19
21
|
export type { AgentSession };
|
|
20
22
|
export { renderTurnRoleAnchor, renderTurnTimeAnchor } from "./system-prompt.js";
|
|
21
23
|
type AgentSessionTools = NonNullable<Parameters<typeof createAgentSession>[0]>['tools'];
|
|
22
|
-
export
|
|
24
|
+
export { DEFAULT_MAX_OUTPUT_TOKENS } from "./output-allowance.js";
|
|
23
25
|
export type PluginSessionWiring = {
|
|
24
26
|
registry: PluginRegistry;
|
|
25
27
|
hooks: HookBus;
|
|
@@ -143,21 +145,7 @@ export type CreateResourceLoaderOptions = {
|
|
|
143
145
|
subagentRegistry?: SubagentRegistry;
|
|
144
146
|
mode?: SystemPromptMode;
|
|
145
147
|
proactiveNextStepNudge?: boolean;
|
|
148
|
+
evalEnabled?: boolean;
|
|
146
149
|
};
|
|
147
|
-
export declare function deriveSystemPromptMode(origin: SessionOrigin | undefined): SystemPromptMode;
|
|
148
|
-
export type SystemPromptMode = 'full' | 'slim';
|
|
149
|
-
export type SystemPromptComposition = {
|
|
150
|
-
mode?: SystemPromptMode;
|
|
151
|
-
branding?: boolean;
|
|
152
|
-
self: string;
|
|
153
|
-
subagentRoster?: string;
|
|
154
|
-
runtimeVersion?: string;
|
|
155
|
-
origin?: SessionOrigin;
|
|
156
|
-
roleContext?: SessionRoleContext;
|
|
157
|
-
mcpCatalog?: string;
|
|
158
|
-
gitNudge: string;
|
|
159
|
-
proactiveNextStepNudge?: string;
|
|
160
|
-
};
|
|
161
|
-
export declare function composeSystemPrompt(parts: SystemPromptComposition): string;
|
|
162
150
|
export declare function createResourceLoader(options?: CreateResourceLoaderOptions): Promise<DefaultResourceLoader>;
|
|
163
151
|
export declare function getBundledSkillsDir(): string;
|
|
@@ -5,7 +5,10 @@ import { IncidentLedger } from "../operations/index.js";
|
|
|
5
5
|
import type { RemediationRegistry } from "../operations/index.js";
|
|
6
6
|
import type { PermissionService } from "../permissions/permissions.js";
|
|
7
7
|
import type { BuiltinToolRef, HookBus, PluginLogger, Tool, ToolFileOperands } from "../plugin/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { commandNeedsRealProc } from "../sandbox/index.js";
|
|
9
|
+
import { type BashSandboxBoundary } from "./bash-sandbox.js";
|
|
10
|
+
export { buildBashFilesystemPolicy, type BashSandboxBoundary, type DeferredBashPreparation, type DeferredBashPreparationResult, } from "./bash-sandbox.js";
|
|
11
|
+
export { buildSandboxEnvPolicy } from "./bash-sandbox-env.js";
|
|
9
12
|
import type { InternalGuard } from "./guard-types.js";
|
|
10
13
|
import { type SubagentBashPolicy } from "./reviewer-bash-policy.js";
|
|
11
14
|
import type { SessionOrigin } from "./session-origin.js";
|
|
@@ -13,15 +16,6 @@ export declare const TYPECLAW_INTERNAL_BASH_ENV = "__typeclawBashEnv";
|
|
|
13
16
|
export declare const TYPECLAW_INTERNAL_BASH_WITHHOLD_ENV = "__typeclawBashWithholdEnv";
|
|
14
17
|
export declare const TYPECLAW_INTERNAL_BASH_PREPARE = "__typeclawBashPrepare";
|
|
15
18
|
type BashEnvOverlay = Record<string, string>;
|
|
16
|
-
export type DeferredBashPreparationResult = {
|
|
17
|
-
command: string;
|
|
18
|
-
env?: Record<string, string>;
|
|
19
|
-
mount: Extract<SandboxMount, {
|
|
20
|
-
type: 'ro-bind';
|
|
21
|
-
}>;
|
|
22
|
-
cleanup: () => Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
export type DeferredBashPreparation = () => Promise<DeferredBashPreparationResult>;
|
|
25
19
|
export declare function sanitizeBashSpawnEnvironment(inherited: NodeJS.ProcessEnv | undefined, overlay: BashEnvOverlay | undefined, withhold?: readonly string[]): NodeJS.ProcessEnv;
|
|
26
20
|
export declare function isPiCodingBuiltinName(name: string): boolean;
|
|
27
21
|
export declare function resolveBuiltinToolRefs(refs: BuiltinToolRef[], cwd: string, contextTools?: ReadonlyMap<string, ToolDefinition<any, any, any>>): ToolDefinition<any, any, any>[];
|
|
@@ -38,14 +32,6 @@ export type WrapToolOptions = {
|
|
|
38
32
|
getAbort?: () => ((reason?: string) => void) | undefined;
|
|
39
33
|
getLoopGuardTurn?: () => number | undefined;
|
|
40
34
|
};
|
|
41
|
-
export type BashSandboxBoundary = {
|
|
42
|
-
ensureAvailable: () => Promise<void>;
|
|
43
|
-
buildCommand: typeof buildSandboxedCommand;
|
|
44
|
-
resolveProcStrategy?: () => Promise<ProcStrategyResolution>;
|
|
45
|
-
resolveRuntime?: typeof resolvePrivilegedSandboxRuntime;
|
|
46
|
-
verifyRuntime?: typeof verifyPrivilegedSandboxRuntime;
|
|
47
|
-
cleanupRuntime?: typeof cleanupPrivilegedSandboxRuntime;
|
|
48
|
-
};
|
|
49
35
|
export type WrapSystemToolOptions = {
|
|
50
36
|
agentDir: string;
|
|
51
37
|
sessionId: string;
|
|
@@ -68,62 +54,5 @@ export declare function wrapSystemTool<TParams extends TSchema, TDetails = unkno
|
|
|
68
54
|
export declare function wrapBuiltinToolDefinition<TParams extends TSchema, TDetails = unknown, TState = any>(tool: ToolDefinition<TParams, TDetails, TState>, opts: WrapSystemToolOptions): ToolDefinition<TParams, TDetails, TState>;
|
|
69
55
|
export declare function defaultBuiltinPiToolDefinitions(cwd: string): ToolDefinition<any, any, any>[];
|
|
70
56
|
export declare function buildBuiltinPiToolOverrides(opts: WrapSystemToolOptions): ToolDefinition<any, any>[];
|
|
71
|
-
type BashFilesystemPolicyOptions = {
|
|
72
|
-
agentDir: string;
|
|
73
|
-
canWriteAgentRoot: boolean;
|
|
74
|
-
masks: {
|
|
75
|
-
dirs: string[];
|
|
76
|
-
files: string[];
|
|
77
|
-
};
|
|
78
|
-
writable: {
|
|
79
|
-
dirs: string[];
|
|
80
|
-
files: string[];
|
|
81
|
-
};
|
|
82
|
-
protected: {
|
|
83
|
-
dirs: string[];
|
|
84
|
-
files: string[];
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
export declare function buildBashFilesystemPolicy(options: BashFilesystemPolicyOptions): {
|
|
88
|
-
writableRoot: {
|
|
89
|
-
dir: string;
|
|
90
|
-
};
|
|
91
|
-
masks: {
|
|
92
|
-
dirs: string[];
|
|
93
|
-
files: string[];
|
|
94
|
-
};
|
|
95
|
-
protected: {
|
|
96
|
-
dirs: string[];
|
|
97
|
-
files: string[];
|
|
98
|
-
};
|
|
99
|
-
writable?: undefined;
|
|
100
|
-
} | {
|
|
101
|
-
masks: {
|
|
102
|
-
dirs: string[];
|
|
103
|
-
files: string[];
|
|
104
|
-
};
|
|
105
|
-
writable: {
|
|
106
|
-
dirs: string[];
|
|
107
|
-
files: string[];
|
|
108
|
-
};
|
|
109
|
-
protected: {
|
|
110
|
-
dirs: string[];
|
|
111
|
-
files: string[];
|
|
112
|
-
};
|
|
113
|
-
writableRoot?: undefined;
|
|
114
|
-
};
|
|
115
|
-
export declare function buildSandboxEnvPolicy(overlay: BashEnvOverlay | undefined, runtimeEnv: Record<string, string> | undefined, exposableEnvNames?: readonly string[], withhold?: readonly string[]): {
|
|
116
|
-
inherit?: string[];
|
|
117
|
-
set?: Record<string, string>;
|
|
118
|
-
withhold?: string[];
|
|
119
|
-
};
|
|
120
|
-
type ProcStrategyResolution = {
|
|
121
|
-
strategy: 'real-proc' | 'proc-bind';
|
|
122
|
-
degradeReason?: undefined;
|
|
123
|
-
} | {
|
|
124
|
-
strategy: 'tmpfs';
|
|
125
|
-
degradeReason: 'definitive' | 'unverified';
|
|
126
|
-
};
|
|
127
57
|
export declare function forgetSharedLoopGuardTool(sessionId: string, tool: string): void;
|
|
128
58
|
export declare function __resetSharedLoopGuardForTests(): void;
|
|
129
|
-
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SessionOrigin, type SessionRoleContext } from "./session-origin.js";
|
|
2
|
+
export declare function deriveSystemPromptMode(origin: SessionOrigin | undefined): SystemPromptMode;
|
|
3
|
+
export type SystemPromptMode = 'full' | 'slim';
|
|
4
|
+
export type SystemPromptComposition = {
|
|
5
|
+
mode?: SystemPromptMode;
|
|
6
|
+
branding?: boolean;
|
|
7
|
+
self: string;
|
|
8
|
+
subagentRoster?: string;
|
|
9
|
+
runtimeVersion?: string;
|
|
10
|
+
origin?: SessionOrigin;
|
|
11
|
+
roleContext?: SessionRoleContext;
|
|
12
|
+
mcpCatalog?: string;
|
|
13
|
+
gitNudge: string;
|
|
14
|
+
proactiveNextStepNudge?: string;
|
|
15
|
+
evalHint?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function composeSystemPrompt(parts: SystemPromptComposition): string;
|
|
@@ -2,6 +2,15 @@ import { type SearchRetryOptions } from "./search-retry.js";
|
|
|
2
2
|
export { _setCurlBinaryForTest } from "./curl-impersonate.js";
|
|
3
3
|
export declare const DDG_PROFILES: readonly ["curl_firefox147", "curl_safari184"];
|
|
4
4
|
export declare const DDG_CONCURRENCY = 2;
|
|
5
|
+
export declare const DDG_MIN_REQUEST_INTERVAL_MS = 1500;
|
|
6
|
+
export declare const DDG_CAPTCHA_COOLDOWN_MS: number;
|
|
7
|
+
type Pacing = {
|
|
8
|
+
intervalMs: number;
|
|
9
|
+
cooldownMs: number;
|
|
10
|
+
now: () => number;
|
|
11
|
+
sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export declare function _setDdgPacingForTest(override: Partial<Pacing> | null): void;
|
|
5
14
|
export type DdgResult = {
|
|
6
15
|
title: string;
|
|
7
16
|
url: string;
|
|
@@ -5,7 +5,7 @@ export type CreateStreamSnapshotToolOptions = {
|
|
|
5
5
|
now?: () => number;
|
|
6
6
|
};
|
|
7
7
|
export declare function createStreamSnapshotTool({ stream, now }: CreateStreamSnapshotToolOptions): import("@earendil-works/pi-coding-agent").ToolDefinition<Type.TObject<{
|
|
8
|
-
target_kind: Type.TOptional<Type.TUnion<Type.TLiteral<"cron" | "
|
|
8
|
+
target_kind: Type.TOptional<Type.TUnion<Type.TLiteral<"cron" | "session" | "broadcast" | "new-session">[]>>;
|
|
9
9
|
target_id: Type.TOptional<Type.TString>;
|
|
10
10
|
since_ms_ago: Type.TOptional<Type.TInteger>;
|
|
11
11
|
limit: Type.TOptional<Type.TInteger>;
|
|
@@ -2,7 +2,7 @@ import { Type } from '@earendil-works/pi-ai';
|
|
|
2
2
|
import { type WebFetchDetails } from "./types.js";
|
|
3
3
|
export declare const webFetchTool: import("@earendil-works/pi-coding-agent").ToolDefinition<Type.TObject<{
|
|
4
4
|
url: Type.TString;
|
|
5
|
-
strategy: Type.TOptional<Type.TUnion<Type.TLiteral<"
|
|
5
|
+
strategy: Type.TOptional<Type.TUnion<Type.TLiteral<"grep" | "jq" | "selector" | "snapshot" | "raw" | "readability">[]>>;
|
|
6
6
|
query: Type.TOptional<Type.TString>;
|
|
7
7
|
selector: Type.TOptional<Type.TString>;
|
|
8
8
|
pattern: Type.TOptional<Type.TString>;
|
|
@@ -112,7 +112,7 @@ export declare class GithubReviewCheckTracker {
|
|
|
112
112
|
reviewerSettled(taskId: string, settlement: ReviewerSettlement): Promise<void>;
|
|
113
113
|
reportActivity(taskId: string, activity: ReviewerActivity): void;
|
|
114
114
|
reviewPosted(key: ReviewCheckKey, state: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED', details?: ReviewCheckVerdictDetails): Promise<void>;
|
|
115
|
-
completePostingReviews(repo: string, pullRequest: number, state: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED'): Promise<void>;
|
|
115
|
+
completePostingReviews(repo: string, pullRequest: number, state: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED', headSha?: string): Promise<void>;
|
|
116
116
|
cancelPullRequest(repo: string, pullRequest: number, reason: string): Promise<void>;
|
|
117
117
|
sweep(): Promise<void>;
|
|
118
118
|
private createLease;
|
|
@@ -66,37 +66,16 @@ export declare const SEND_RATE_WINDOW_MS = 5000;
|
|
|
66
66
|
export declare const SEND_RATE_WARN_THRESHOLD = 3;
|
|
67
67
|
export declare const OUTBOUND_FLOOD_ERROR = "outbound message denied: content looks like a repeated-character flood";
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* WITHIN this window is guaranteed a cache hit on the provider side.
|
|
69
|
+
* Roll over only after more than 60 minutes without an engaged inbound.
|
|
70
|
+
* Continuity of an active conversation outweighs one cold prefix resend;
|
|
71
|
+
* compaction bounds the transcript carried by that resend.
|
|
73
72
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* context) still costs more to rebuild than its accumulated transcript is
|
|
79
|
-
* reused for one more turn rather than torn down. This targets the common
|
|
80
|
-
* channel shape — a human replying a few minutes past the cache TTL — where a
|
|
81
|
-
* full cold-start rebuild of a large memory/index-mode base context dominates
|
|
82
|
-
* the cost of carrying a modest transcript forward.
|
|
83
|
-
*
|
|
84
|
-
* Unlike SESSION_IDLE_MS (which evicts the in-memory entry without rollover), a
|
|
85
|
-
* rollover triggers a full tearDownLive + recreate on the next engaged inbound.
|
|
86
|
-
* The old session's transcript is preserved on disk; only the in-memory live
|
|
87
|
-
* entry and sessions.json pointer are replaced.
|
|
73
|
+
* SESSION_IDLE_MS (30 minutes) only evicts the in-memory entry: the next inbound
|
|
74
|
+
* within this freshness window rehydrates the same session file without rollover.
|
|
75
|
+
* A rollover tears down the live entry and replaces the sessions.json pointer;
|
|
76
|
+
* the old transcript remains on disk.
|
|
88
77
|
*/
|
|
89
78
|
export declare const SESSION_FRESHNESS_TTL_MS: number;
|
|
90
|
-
/**
|
|
91
|
-
* Hard ceiling on the cost-aware grace window. Past this age the live session is
|
|
92
|
-
* rolled over unconditionally regardless of base-vs-transcript cost: the grace
|
|
93
|
-
* decision only defers rollover, it never makes the session immortal. Bounding
|
|
94
|
-
* grace at 2x the soft TTL keeps a never-quite-idle session from accumulating an
|
|
95
|
-
* ever-growing, fully-uncached prefix (every turn past the soft boundary re-sends
|
|
96
|
-
* the whole prefix at no provider-cache discount) and prevents grace from
|
|
97
|
-
* silently becoming an unbounded TTL increase.
|
|
98
|
-
*/
|
|
99
|
-
export declare const SESSION_GRACE_HARD_TTL_MS: number;
|
|
100
79
|
/**
|
|
101
80
|
* Leak guard — NOT a freshness cap. A running background subagent pins its parent
|
|
102
81
|
* channel session against idle GC and stale-rollover for as long as the child is
|
|
@@ -118,25 +97,6 @@ export declare const SESSION_GRACE_HARD_TTL_MS: number;
|
|
|
118
97
|
* "this child is wedged," not "this child is busy".
|
|
119
98
|
*/
|
|
120
99
|
export declare const SESSION_CHILD_STUCK_BACKSTOP_MS: number;
|
|
121
|
-
/**
|
|
122
|
-
* Cost-aware grace decision for the soft→hard TTL band. Returns true when reusing
|
|
123
|
-
* the (now cache-cold) live session is cheaper than a fresh cold-start.
|
|
124
|
-
*
|
|
125
|
-
* After the soft TTL the provider prefix is cold either way, so the choice is:
|
|
126
|
-
* - rollover: pay to rebuild the fixed base context (system prompt + memory +
|
|
127
|
-
* prefetched context) plus a fresh first model call, OR
|
|
128
|
-
* - reuse: re-send the cold base context PLUS the accumulated transcript.
|
|
129
|
-
*
|
|
130
|
-
* Rollover only wins once the transcript a reused session would carry forward
|
|
131
|
-
* exceeds the base context a rollover would rebuild. We approximate both with the
|
|
132
|
-
* session transcript file: `baseContextBytes` is its size captured right after
|
|
133
|
-
* cold-start (the rendered prompt before any user turn), and the live delta is
|
|
134
|
-
* the growth since. While `baseContextBytes > transcriptDeltaBytes`, the fixed
|
|
135
|
-
* rebuild is the larger cost and grace is worth it. A `baseContextBytes` of 0
|
|
136
|
-
* (no transcript path available) disables grace — fail closed to the prior
|
|
137
|
-
* roll-over-at-soft-TTL behavior.
|
|
138
|
-
*/
|
|
139
|
-
export declare function isGraceWorthReusing(baseContextBytes: number, transcriptDeltaBytes: number): boolean;
|
|
140
100
|
export declare const ENSURE_LIVE_TIMEOUT_MS = 30000;
|
|
141
101
|
export declare class StaleLiveSessionError extends Error {
|
|
142
102
|
constructor(keyId: string);
|
|
@@ -260,6 +220,10 @@ type LiveSession = {
|
|
|
260
220
|
deferred: boolean;
|
|
261
221
|
}) | null;
|
|
262
222
|
githubReviewThreadCloseoutDecisionTurn: number | null;
|
|
223
|
+
githubReviewThreadResolvedAt: {
|
|
224
|
+
rootCommentId: string;
|
|
225
|
+
at: number;
|
|
226
|
+
} | null;
|
|
263
227
|
pendingGithubReviewRoundCloseout: string | null;
|
|
264
228
|
promptQueue: QueuedInbound[];
|
|
265
229
|
contextBuffer: ObservedInbound[];
|
|
@@ -276,7 +240,6 @@ type LiveSession = {
|
|
|
276
240
|
promptInFlight: boolean;
|
|
277
241
|
lastInboundAt: number;
|
|
278
242
|
recentMessages: SessionActivity[];
|
|
279
|
-
baseContextBytes: number;
|
|
280
243
|
firstUnprocessedAt: number;
|
|
281
244
|
currentTurnAuthorId: string | null;
|
|
282
245
|
currentTurnAuthorAdapter: AdapterId;
|
|
@@ -656,7 +619,6 @@ export type CreateChannelRouterOptions = {
|
|
|
656
619
|
now?: () => number;
|
|
657
620
|
retryRandom?: () => number;
|
|
658
621
|
onRetryBackoffStart?: () => void;
|
|
659
|
-
measureTranscriptBytes?: (path: string) => number;
|
|
660
622
|
runIdleContinuation?: typeof runIdleContinuation;
|
|
661
623
|
recordTurnOutcome?: typeof recordTurnOutcome;
|
|
662
624
|
ensureLiveTimeoutMs?: number;
|
|
@@ -161,22 +161,22 @@ export declare const customModelsSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z
|
|
|
161
161
|
export type CustomModels = z.infer<typeof customModelsSchema>;
|
|
162
162
|
export declare const thinkingLevelSchema: z.ZodEnum<{
|
|
163
163
|
off: "off";
|
|
164
|
-
|
|
164
|
+
high: "high";
|
|
165
165
|
low: "low";
|
|
166
|
+
max: "max";
|
|
166
167
|
medium: "medium";
|
|
167
|
-
|
|
168
|
+
minimal: "minimal";
|
|
168
169
|
xhigh: "xhigh";
|
|
169
|
-
max: "max";
|
|
170
170
|
}>;
|
|
171
171
|
export type ThinkingLevel = z.infer<typeof thinkingLevelSchema>;
|
|
172
172
|
export declare const modelsSchema: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodType<ProfileEntry, string | string[] | {
|
|
173
173
|
model?: string | undefined;
|
|
174
174
|
models?: string | string[] | undefined;
|
|
175
|
-
thinkingLevel?: "off" | "
|
|
175
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
176
176
|
}, z.core.$ZodTypeInternals<ProfileEntry, string | string[] | {
|
|
177
177
|
model?: string | undefined;
|
|
178
178
|
models?: string | string[] | undefined;
|
|
179
|
-
thinkingLevel?: "off" | "
|
|
179
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
180
180
|
}>>>, z.ZodTransform<Models, Record<string, ProfileEntry>>>;
|
|
181
181
|
export declare function modelOverrideRuleError(rule: string): string | undefined;
|
|
182
182
|
declare const modelOverrideSchema: z.ZodObject<{
|
|
@@ -184,11 +184,11 @@ declare const modelOverrideSchema: z.ZodObject<{
|
|
|
184
184
|
models: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodType<ProfileEntry, string | string[] | {
|
|
185
185
|
model?: string | undefined;
|
|
186
186
|
models?: string | string[] | undefined;
|
|
187
|
-
thinkingLevel?: "off" | "
|
|
187
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
188
188
|
}, z.core.$ZodTypeInternals<ProfileEntry, string | string[] | {
|
|
189
189
|
model?: string | undefined;
|
|
190
190
|
models?: string | string[] | undefined;
|
|
191
|
-
thinkingLevel?: "off" | "
|
|
191
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
192
192
|
}>>>, z.ZodTransform<Record<string, ProfileEntry>, Record<string, ProfileEntry>>>;
|
|
193
193
|
}, z.core.$strict>;
|
|
194
194
|
export type ModelOverride = z.infer<typeof modelOverrideSchema>;
|
|
@@ -197,11 +197,11 @@ export declare const modelOverridesSchema: z.ZodDefault<z.ZodRecord<z.ZodString,
|
|
|
197
197
|
models: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodType<ProfileEntry, string | string[] | {
|
|
198
198
|
model?: string | undefined;
|
|
199
199
|
models?: string | string[] | undefined;
|
|
200
|
-
thinkingLevel?: "off" | "
|
|
200
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
201
201
|
}, z.core.$ZodTypeInternals<ProfileEntry, string | string[] | {
|
|
202
202
|
model?: string | undefined;
|
|
203
203
|
models?: string | string[] | undefined;
|
|
204
|
-
thinkingLevel?: "off" | "
|
|
204
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
205
205
|
}>>>, z.ZodTransform<Record<string, ProfileEntry>, Record<string, ProfileEntry>>>;
|
|
206
206
|
}, z.core.$strict>>>;
|
|
207
207
|
export type ProfileEntry = {
|
|
@@ -233,11 +233,11 @@ export declare const configSchema: z.ZodObject<{
|
|
|
233
233
|
models: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodType<ProfileEntry, string | string[] | {
|
|
234
234
|
model?: string | undefined;
|
|
235
235
|
models?: string | string[] | undefined;
|
|
236
|
-
thinkingLevel?: "off" | "
|
|
236
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
237
237
|
}, z.core.$ZodTypeInternals<ProfileEntry, string | string[] | {
|
|
238
238
|
model?: string | undefined;
|
|
239
239
|
models?: string | string[] | undefined;
|
|
240
|
-
thinkingLevel?: "off" | "
|
|
240
|
+
thinkingLevel?: "off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh" | undefined;
|
|
241
241
|
}>>>, z.ZodTransform<Record<string, ProfileEntry>, Record<string, ProfileEntry>>>;
|
|
242
242
|
}, z.core.$strict>>>;
|
|
243
243
|
mounts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -668,6 +668,16 @@ export declare const configSchema: z.ZodObject<{
|
|
|
668
668
|
to: z.ZodString;
|
|
669
669
|
}, z.core.$strip>>>;
|
|
670
670
|
}, z.core.$strip>>;
|
|
671
|
+
eval: z.ZodDefault<z.ZodObject<{
|
|
672
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
673
|
+
origins: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
674
|
+
channel: "channel";
|
|
675
|
+
tui: "tui";
|
|
676
|
+
cron: "cron";
|
|
677
|
+
subagent: "subagent";
|
|
678
|
+
system: "system";
|
|
679
|
+
}>>>;
|
|
680
|
+
}, z.core.$strict>>;
|
|
671
681
|
docker: z.ZodDefault<z.ZodObject<{
|
|
672
682
|
file: z.ZodDefault<z.ZodObject<{
|
|
673
683
|
ffmpeg: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
@@ -727,6 +737,9 @@ export declare const configSchema: z.ZodObject<{
|
|
|
727
737
|
tokenEnv: z.ZodOptional<z.ZodString>;
|
|
728
738
|
}, z.core.$strip>>>;
|
|
729
739
|
branding: z.ZodDefault<z.ZodBoolean>;
|
|
740
|
+
compaction: z.ZodDefault<z.ZodObject<{
|
|
741
|
+
maxTriggerTokens: z.ZodOptional<z.ZodNumber>;
|
|
742
|
+
}, z.core.$strict>>;
|
|
730
743
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
731
744
|
export type Config = z.infer<typeof configSchema>;
|
|
732
745
|
export declare function resolveModel(ref: KnownModelRef | ModelRef | string): Model<KnownApi>;
|
|
@@ -108,6 +108,7 @@ export declare const KNOWN_PROVIDERS: {
|
|
|
108
108
|
readonly supportsAdditionalTools: true;
|
|
109
109
|
readonly supportsToolSearch: true;
|
|
110
110
|
readonly supportsMidConvoSystemMessages: true;
|
|
111
|
+
readonly supportsMidConvoEffort: true;
|
|
111
112
|
readonly supportsExplicitPromptCacheMode: true;
|
|
112
113
|
};
|
|
113
114
|
};
|
|
@@ -142,6 +143,7 @@ export declare const KNOWN_PROVIDERS: {
|
|
|
142
143
|
readonly supportsAdditionalTools: true;
|
|
143
144
|
readonly supportsToolSearch: true;
|
|
144
145
|
readonly supportsMidConvoSystemMessages: true;
|
|
146
|
+
readonly supportsMidConvoEffort: true;
|
|
145
147
|
readonly supportsExplicitPromptCacheMode: true;
|
|
146
148
|
};
|
|
147
149
|
};
|
|
@@ -735,7 +737,7 @@ export declare const KNOWN_PROVIDERS: {
|
|
|
735
737
|
readonly low: "low";
|
|
736
738
|
readonly medium: "medium";
|
|
737
739
|
readonly high: "high";
|
|
738
|
-
readonly xhigh:
|
|
740
|
+
readonly xhigh: "xhigh";
|
|
739
741
|
readonly max: null;
|
|
740
742
|
};
|
|
741
743
|
readonly compat: {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CellOutput, type HostFrame, type KernelFrame } from "./protocol.js";
|
|
2
|
+
export type EvalDispatch = (request: {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly args: Extract<KernelFrame, {
|
|
5
|
+
type: 'tool-call';
|
|
6
|
+
}>['args'];
|
|
7
|
+
readonly callId: string;
|
|
8
|
+
}, signal: AbortSignal) => Promise<unknown>;
|
|
9
|
+
export declare class EvalCell {
|
|
10
|
+
private readonly dispatch;
|
|
11
|
+
private readonly signal;
|
|
12
|
+
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
13
|
+
readonly output: CellOutput;
|
|
14
|
+
readonly completed: {
|
|
15
|
+
promise: Promise<void>;
|
|
16
|
+
resolve: (value?: void | PromiseLike<void> | undefined) => void;
|
|
17
|
+
reject: (reason?: any) => void;
|
|
18
|
+
};
|
|
19
|
+
private readonly ids;
|
|
20
|
+
private readonly pending;
|
|
21
|
+
private finished;
|
|
22
|
+
constructor(dispatch: EvalDispatch, signal: AbortSignal);
|
|
23
|
+
receive(frame: KernelFrame, send: (frame: HostFrame) => void): void;
|
|
24
|
+
private assertActive;
|
|
25
|
+
private invoke;
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WrapSystemToolOptions } from "../agent/plugin-tools.js";
|
|
3
|
+
import type { SessionOrigin } from "../agent/session-origin.js";
|
|
4
|
+
export declare const evalConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
5
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
origins: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
7
|
+
channel: "channel";
|
|
8
|
+
tui: "tui";
|
|
9
|
+
cron: "cron";
|
|
10
|
+
subagent: "subagent";
|
|
11
|
+
system: "system";
|
|
12
|
+
}>>>;
|
|
13
|
+
}, z.core.$strict>>;
|
|
14
|
+
export declare function evalEnabledForSession(options: {
|
|
15
|
+
readonly settings: z.infer<typeof evalConfigSchema>;
|
|
16
|
+
readonly origin: SessionOrigin | undefined;
|
|
17
|
+
readonly tools: readonly string[];
|
|
18
|
+
readonly bashPolicy?: WrapSystemToolOptions['bashPolicy'];
|
|
19
|
+
}): boolean;
|