@shuind/dsh-codex-harness 0.2.21 → 0.3.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/CHANGELOG.md +185 -0
- package/README.md +38 -50
- package/RELEASE.md +61 -0
- package/assets/codex.svg +5 -0
- package/cordis.patch.yml +181 -6
- package/docs/preset-library.md +33 -23
- package/docs/tool-policy-benchmark.json +310 -0
- package/docs/tool-policy.md +148 -0
- package/lib/client.js +4774 -2416
- package/lib/compact-command.js +416 -0
- package/lib/compaction.js +141 -12
- package/lib/hybrid-executor.js +1196 -0
- package/lib/index.js +3658 -2334
- package/lib/preferences.js +117 -0
- package/lib/tool-policy.js +2422 -0
- package/lib/typert.js +86 -79
- package/lib/types/client/activity.d.ts +33 -9
- package/lib/types/client/activity.js +4 -3
- package/lib/types/client/desktop.d.ts +67 -0
- package/lib/types/client/desktop.js +229 -0
- package/lib/types/client/index.d.ts +207 -110
- package/lib/types/client/index.js +99 -492
- package/lib/types/client/policy-drafts.d.ts +25 -0
- package/lib/types/client/policy-drafts.js +47 -0
- package/lib/types/client/policy-locale.d.ts +260 -0
- package/lib/types/client/policy-locale.js +357 -0
- package/lib/types/client/preset-manager.d.ts +38 -10
- package/lib/types/client/preset-manager.js +235 -185
- package/lib/types/client/preset-requests.d.ts +12 -0
- package/lib/types/client/preset-requests.js +101 -0
- package/lib/types/client/tool-policy.d.ts +33 -0
- package/lib/types/client/tool-policy.js +336 -0
- package/lib/types/contracts/preset-editor-schema.d.ts +78 -0
- package/lib/types/contracts/preset-editor-schema.js +95 -0
- package/lib/types/{prompt.js → contracts/prompt.js} +13 -7
- package/lib/types/{settings.d.ts → contracts/settings.d.ts} +11 -4
- package/lib/types/{settings.js → contracts/settings.js} +22 -6
- package/lib/types/contracts/tool-policy-contract.d.ts +63 -0
- package/lib/types/contracts/tool-policy-contract.js +33 -0
- package/lib/types/contracts/ui-contracts.d.ts +92 -0
- package/lib/types/contracts/ui-contracts.js +83 -0
- package/lib/types/entries/client.d.ts +10 -0
- package/lib/types/entries/client.js +10 -0
- package/lib/types/{compact-command.d.ts → entries/compact-command.d.ts} +2 -0
- package/lib/types/entries/compact-command.js +176 -0
- package/lib/types/{compaction.d.ts → entries/compaction.d.ts} +15 -3
- package/lib/types/{compaction.js → entries/compaction.js} +47 -11
- package/lib/types/entries/hybrid-executor.d.ts +19 -0
- package/lib/types/entries/hybrid-executor.js +57 -0
- package/lib/types/entries/index.d.ts +66 -0
- package/lib/types/entries/index.js +192 -0
- package/lib/types/entries/preferences.d.ts +11 -0
- package/lib/types/entries/preferences.js +16 -0
- package/lib/types/entries/tool-policy.d.ts +97 -0
- package/lib/types/entries/tool-policy.js +158 -0
- package/lib/types/entries/typert.host.d.ts +23 -0
- package/lib/types/entries/typert.host.js +24 -0
- package/lib/types/hybrid/codex-hybrid-executor.d.ts +44 -0
- package/lib/types/hybrid/codex-hybrid-executor.js +257 -0
- package/lib/types/hybrid/hybrid-sdk.d.ts +13 -0
- package/lib/types/hybrid/hybrid-sdk.js +196 -0
- package/lib/types/hybrid/program-calls.d.ts +28 -0
- package/lib/types/hybrid/program-calls.js +193 -0
- package/lib/types/hybrid/subcall-scheduler.d.ts +90 -0
- package/lib/types/hybrid/subcall-scheduler.js +343 -0
- package/lib/types/policy/deferred-tools.d.ts +42 -0
- package/lib/types/policy/deferred-tools.js +264 -0
- package/lib/types/policy/overlay-installer.d.ts +12 -0
- package/lib/types/policy/overlay-installer.js +179 -0
- package/lib/types/policy/rule-resolver.d.ts +94 -0
- package/lib/types/policy/rule-resolver.js +114 -0
- package/lib/types/policy/tool-capabilities.d.ts +33 -0
- package/lib/types/policy/tool-capabilities.js +46 -0
- package/lib/types/{activity.d.ts → presets/activity.d.ts} +3 -5
- package/lib/types/{activity.js → presets/activity.js} +51 -27
- package/lib/types/presets/desktop-preset.d.ts +22 -0
- package/lib/types/presets/desktop-preset.js +43 -0
- package/lib/types/presets/preset-editor.d.ts +47 -0
- package/lib/types/presets/preset-editor.js +81 -0
- package/lib/types/presets/preset-prompt-catalog.d.ts +23 -0
- package/lib/types/presets/preset-prompt-catalog.js +215 -0
- package/lib/types/presets/preset-tool-catalog.d.ts +5 -0
- package/lib/types/presets/preset-tool-catalog.js +58 -0
- package/lib/types/presets/runtime-enhancements.d.ts +45 -0
- package/lib/types/presets/runtime-enhancements.js +349 -0
- package/lib/types/presets/small-window-compaction.d.ts +15 -0
- package/lib/types/presets/small-window-compaction.js +121 -0
- package/lib/types/responses/compact-checkpoint.d.ts +27 -0
- package/lib/types/responses/compact-checkpoint.js +257 -0
- package/lib/types/responses/fetch-transport.d.ts +16 -0
- package/lib/types/responses/fetch-transport.js +257 -0
- package/lib/types/responses/remote-compact.d.ts +13 -0
- package/lib/types/responses/remote-compact.js +319 -0
- package/lib/types/responses/sse-diagnostics.d.ts +9 -0
- package/lib/types/responses/sse-diagnostics.js +157 -0
- package/lib/types/responses/wire-rewrite.d.ts +35 -0
- package/lib/types/responses/wire-rewrite.js +237 -0
- package/lib/types/tools/exec-output.d.ts +58 -0
- package/lib/types/tools/exec-output.js +173 -0
- package/lib/types/tools/exec-plan-tools.d.ts +37 -0
- package/lib/types/tools/exec-plan-tools.js +265 -0
- package/lib/types/tools/exec-runner.d.ts +21 -0
- package/lib/types/tools/exec-runner.js +385 -0
- package/lib/types/tools/patch-tool.d.ts +16 -0
- package/lib/types/tools/patch-tool.js +258 -0
- package/lib/types/{patch.d.ts → tools/patch.d.ts} +1 -1
- package/lib/types/{patch.js → tools/patch.js} +96 -21
- package/locale/en.json +6 -0
- package/locale/hybrid-executor/en.json +6 -0
- package/locale/hybrid-executor/zh.json +6 -0
- package/locale/tool-policy/en.json +6 -0
- package/locale/tool-policy/zh.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +297 -299
- package/presets/{codex-collaboration → codex-hybrid}/agent.cordis.yml +45 -48
- package/presets/codex-hybrid/preset.yml +3 -0
- package/scripts/benchmark-tool-policy.mjs +186 -0
- package/scripts/build-preset.mjs +19 -0
- package/scripts/clean-build.mjs +11 -0
- package/src/client/activity.ts +83 -0
- package/src/client/desktop.tsx +276 -0
- package/src/client/index.tsx +391 -0
- package/src/client/policy-drafts.ts +56 -0
- package/src/client/policy-locale.ts +362 -0
- package/src/client/preset-manager.tsx +376 -0
- package/src/client/preset-requests.ts +113 -0
- package/src/client/tool-policy.tsx +402 -0
- package/src/contracts/preset-editor-schema.ts +110 -0
- package/src/contracts/prompt.ts +66 -0
- package/src/contracts/settings.ts +103 -0
- package/src/contracts/tool-policy-contract.ts +93 -0
- package/src/contracts/ui-contracts.ts +173 -0
- package/src/entries/client.tsx +14 -0
- package/src/entries/compact-command.ts +256 -0
- package/src/entries/compaction.ts +218 -0
- package/src/entries/hybrid-executor.ts +76 -0
- package/src/entries/index.ts +298 -0
- package/src/entries/preferences.ts +17 -0
- package/src/entries/tool-policy.ts +162 -0
- package/src/entries/typert.host.ts +29 -0
- package/src/hybrid/codex-hybrid-executor.ts +310 -0
- package/src/hybrid/hybrid-sdk.ts +217 -0
- package/src/hybrid/program-calls.ts +202 -0
- package/src/hybrid/subcall-scheduler.ts +446 -0
- package/src/policy/deferred-tools.ts +331 -0
- package/src/policy/overlay-installer.ts +191 -0
- package/src/policy/rule-resolver.ts +128 -0
- package/src/policy/tool-capabilities.ts +88 -0
- package/src/presets/activity.ts +146 -0
- package/src/presets/desktop-preset.ts +60 -0
- package/src/presets/preset-editor.ts +101 -0
- package/src/presets/preset-prompt-catalog.ts +221 -0
- package/src/presets/preset-tool-catalog.ts +58 -0
- package/src/presets/runtime-enhancements.ts +415 -0
- package/src/presets/small-window-compaction.ts +166 -0
- package/src/responses/compact-checkpoint.ts +264 -0
- package/src/responses/fetch-transport.ts +290 -0
- package/src/responses/remote-compact.ts +393 -0
- package/src/responses/sse-diagnostics.ts +156 -0
- package/src/responses/wire-rewrite.ts +261 -0
- package/src/tools/exec-output.ts +211 -0
- package/src/tools/exec-plan-tools.ts +307 -0
- package/src/tools/exec-runner.ts +445 -0
- package/src/tools/patch-tool.ts +331 -0
- package/src/tools/patch.ts +328 -0
- package/tsconfig.json +29 -0
- package/tsdown.config.ts +110 -0
- package/lib/installer.js +0 -237
- package/lib/invariant.js +0 -23
- package/lib/types/activity-types.d.ts +0 -6
- package/lib/types/activity-types.js +0 -3
- package/lib/types/client/preset-copy.d.ts +0 -42
- package/lib/types/client/preset-copy.js +0 -81
- package/lib/types/compact-command.js +0 -79
- package/lib/types/context.d.ts +0 -8
- package/lib/types/context.js +0 -14
- package/lib/types/exec.d.ts +0 -46
- package/lib/types/exec.js +0 -365
- package/lib/types/index.d.ts +0 -95
- package/lib/types/index.js +0 -738
- package/lib/types/installer.d.ts +0 -27
- package/lib/types/installer.js +0 -146
- package/lib/types/invariant.d.ts +0 -16
- package/lib/types/invariant.js +0 -22
- package/lib/types/preset-contract.d.ts +0 -69
- package/lib/types/preset-contract.js +0 -22
- package/lib/types/preset-editor-remote.d.ts +0 -30
- package/lib/types/preset-editor-remote.js +0 -37
- package/lib/types/preset-editor.d.ts +0 -69
- package/lib/types/preset-editor.js +0 -557
- package/lib/types/preset-templates.d.ts +0 -36
- package/lib/types/preset-templates.js +0 -12
- package/lib/types/prompt-sections.d.ts +0 -15
- package/lib/types/prompt-sections.js +0 -23
- package/lib/types/remote.d.ts +0 -40
- package/lib/types/remote.js +0 -683
- package/lib/types/typert.host.d.ts +0 -47
- package/lib/types/typert.host.js +0 -99
- package/presets/codex-collaboration/preset.yml +0 -3
- /package/lib/types/{prompt.d.ts → contracts/prompt.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Codex compaction backend that honors the latest durable request capacity. */
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
|
|
4
|
+
import { CODEX_SETTINGS_NAMESPACE, isGptModel, readHostSettings } from "../contracts/settings.js";
|
|
4
5
|
/**
|
|
5
6
|
* The main plugin entry and the compact-command subpath can be evaluated as
|
|
6
7
|
* separate bundles. Keep their async context carrier on the process global so
|
|
@@ -24,17 +25,13 @@ export function runCodexCompactionMode(mode, task) {
|
|
|
24
25
|
export function codexCompactionMode() {
|
|
25
26
|
return COMPACTION_MODE.getStore();
|
|
26
27
|
}
|
|
27
|
-
const CODEX_SETTINGS_NAMESPACE = 'codex';
|
|
28
|
-
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
29
|
-
function isGptModel(model) {
|
|
30
|
-
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
31
|
-
}
|
|
32
28
|
/** Read the live Codex capacity without requiring a custom LLM service API. */
|
|
33
29
|
function configuredContextWindow(ctx) {
|
|
34
30
|
const settings = ctx.get('settings');
|
|
35
|
-
|
|
31
|
+
const preferences = ctx.get('codexPreferences');
|
|
32
|
+
if (settings?.describe === undefined && preferences?.current === undefined)
|
|
36
33
|
return { available: false };
|
|
37
|
-
const value =
|
|
34
|
+
const value = readHostSettings(ctx, CODEX_SETTINGS_NAMESPACE);
|
|
38
35
|
return {
|
|
39
36
|
available: true,
|
|
40
37
|
...value?.contextWindow !== undefined
|
|
@@ -54,6 +51,8 @@ function requestContextWindow(session, provider, model) {
|
|
|
54
51
|
}
|
|
55
52
|
/** Resolve the capacity currently in force for an active Codex compaction. */
|
|
56
53
|
function activeContextWindow(ctx, activeSession, provider, model) {
|
|
54
|
+
if (provider === 'openai-codex')
|
|
55
|
+
return undefined;
|
|
57
56
|
const session = activeSession.getStore();
|
|
58
57
|
const requestContext = session?.requestContext();
|
|
59
58
|
const configured = isGptModel(model)
|
|
@@ -68,6 +67,33 @@ function activeContextWindow(ctx, activeSession, provider, model) {
|
|
|
68
67
|
? requestContext.contextWindow
|
|
69
68
|
: undefined);
|
|
70
69
|
}
|
|
70
|
+
const DSH_COMPACT_PROMPT_PREFIX = 'You are now acting as a compaction engine';
|
|
71
|
+
/**
|
|
72
|
+
* When `/compact local` is active, neutralize DSH's exact compaction prompt
|
|
73
|
+
* prefix on a shallow clone so external adapters (`dsh-codex-connect`) fall
|
|
74
|
+
* through to local text summarization instead of firing `compaction_trigger`.
|
|
75
|
+
*/
|
|
76
|
+
export function withExplicitLocalCompactionInstruction(options) {
|
|
77
|
+
if (codexCompactionMode() !== 'local' || options.purpose !== 'compaction' || options.messages.length === 0) {
|
|
78
|
+
return options;
|
|
79
|
+
}
|
|
80
|
+
const last = options.messages.at(-1);
|
|
81
|
+
if (last === undefined || last.role !== 'user' || ('id' in last && last.id !== undefined)) {
|
|
82
|
+
return options;
|
|
83
|
+
}
|
|
84
|
+
const first = last.content[0];
|
|
85
|
+
if (first === undefined || first.type !== 'text' || !first.text.startsWith(DSH_COMPACT_PROMPT_PREFIX)) {
|
|
86
|
+
return options;
|
|
87
|
+
}
|
|
88
|
+
const updatedLast = {
|
|
89
|
+
...last,
|
|
90
|
+
content: [{ ...first, text: `\n${first.text}` }, ...last.content.slice(1)],
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
...options,
|
|
94
|
+
messages: [...options.messages.slice(0, -1), updatedLast],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
71
97
|
/** Overlay capacity lookup and auxiliary summary requests for compaction. */
|
|
72
98
|
function withDurableContextCapacity(llm, ctx, activeSession) {
|
|
73
99
|
return new Proxy(llm, {
|
|
@@ -87,10 +113,11 @@ function withDurableContextCapacity(llm, ctx, activeSession) {
|
|
|
87
113
|
if (property === 'stream') {
|
|
88
114
|
return (options) => {
|
|
89
115
|
const contextWindow = activeContextWindow(ctx, activeSession, options.provider, options.model);
|
|
90
|
-
|
|
91
|
-
|
|
116
|
+
const patched = withExplicitLocalCompactionInstruction(options);
|
|
117
|
+
if (contextWindow === undefined || patched.contextWindow === contextWindow) {
|
|
118
|
+
return target.stream(patched);
|
|
92
119
|
}
|
|
93
|
-
return target.stream({ ...
|
|
120
|
+
return target.stream({ ...patched, contextWindow });
|
|
94
121
|
};
|
|
95
122
|
}
|
|
96
123
|
const value = Reflect.get(target, property, target);
|
|
@@ -106,18 +133,27 @@ function withDurableContextCapacity(llm, ctx, activeSession) {
|
|
|
106
133
|
export default class CodexCompactionEngine extends BasicCompactionEngine {
|
|
107
134
|
static inject = BasicCompactionEngine.inject;
|
|
108
135
|
static Config = BasicCompactionEngine.Config;
|
|
136
|
+
codexSmallWindowReady = true;
|
|
109
137
|
activeSession;
|
|
110
138
|
constructor(ctx, config = {}) {
|
|
111
139
|
const activeSession = new AsyncLocalStorage();
|
|
112
140
|
const llm = ctx.get('llm');
|
|
113
141
|
if (llm === undefined)
|
|
114
142
|
throw new Error('codex compaction requires ctx.llm');
|
|
115
|
-
|
|
143
|
+
const normalizedConfig = {
|
|
144
|
+
...config,
|
|
145
|
+
headroomTokens: config.headroomTokens ?? 8_192,
|
|
146
|
+
maxTokens: config.maxTokens ?? config.headroomTokens ?? 65_536,
|
|
147
|
+
};
|
|
148
|
+
super(ctx.extend({ llm: withDurableContextCapacity(llm, ctx, activeSession) }), normalizedConfig);
|
|
116
149
|
this.activeSession = activeSession;
|
|
117
150
|
}
|
|
118
151
|
compactIfNeeded(agent, trigger, signal) {
|
|
119
152
|
return this.activeSession.run(agent.session, () => super.compactIfNeeded(agent, trigger, signal));
|
|
120
153
|
}
|
|
154
|
+
compactRegion(...args) {
|
|
155
|
+
return this.activeSession.run(args[2].session, () => super.compactRegion(...args));
|
|
156
|
+
}
|
|
121
157
|
compactNow(agent, signal, sourceCommandId) {
|
|
122
158
|
return this.activeSession.run(agent.session, () => super.compactNow(agent, signal, sourceCommandId));
|
|
123
159
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Asymmetric hybrid executor plugin entry and `codexHybridDefaults` wiring. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import { CodexHybridExecutor, Config, DEFAULT_HYBRID_DIRECT_TOOLS } from '../hybrid/codex-hybrid-executor.ts';
|
|
4
|
+
import { CodeResetFailedError, CodeRunFailedError } from '../hybrid/program-calls.ts';
|
|
5
|
+
import type { PtcDispatchEventData, PtcDispatchLog, PtcDispatchStartEventData } from '../hybrid/subcall-scheduler.ts';
|
|
6
|
+
export { CodexHybridExecutor, Config, DEFAULT_HYBRID_DIRECT_TOOLS, CodeResetFailedError, CodeRunFailedError, };
|
|
7
|
+
export type { PtcDispatchEventData, PtcDispatchLog, PtcDispatchStartEventData };
|
|
8
|
+
export declare const name = "codex-hybrid-executor";
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/** Mount `CodexHybridExecutor` and publish default hidden/deferred tools for the owning scope. */
|
|
11
|
+
export declare function apply(ctx: Context, config?: Partial<Config>): void;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
name: string;
|
|
14
|
+
inject: string[];
|
|
15
|
+
Config: import("@deepseek-ai/schemastery").default<Partial<Config>, Config>;
|
|
16
|
+
apply: typeof apply;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=hybrid-executor.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { scopeOf, scopeParentOf } from '@deepseek-ai/dsh-scope';
|
|
2
|
+
import { CodexHybridExecutor, Config, DEFAULT_HYBRID_DIRECT_TOOLS, } from "../hybrid/codex-hybrid-executor.js";
|
|
3
|
+
import { CodeResetFailedError, CodeRunFailedError } from "../hybrid/program-calls.js";
|
|
4
|
+
import { ACTIVATE_TOOLS_NAME, registerHybridDefaultDeferredTools, registerHybridDefaultHiddenTools, yieldDeferredToolsOverlay, } from "../policy/deferred-tools.js";
|
|
5
|
+
export { CodexHybridExecutor, Config, DEFAULT_HYBRID_DIRECT_TOOLS, CodeResetFailedError, CodeRunFailedError, };
|
|
6
|
+
export const name = 'codex-hybrid-executor';
|
|
7
|
+
export const inject = ['tools', 'systemPrompt', 'ptcRuntime'];
|
|
8
|
+
/** Mount `CodexHybridExecutor` and publish default hidden/deferred tools for the owning scope. */
|
|
9
|
+
export function apply(ctx, config = {}) {
|
|
10
|
+
const resolved = Config(config);
|
|
11
|
+
const executor = new CodexHybridExecutor(ctx, resolved);
|
|
12
|
+
ctx.tools.setExecutor(executor);
|
|
13
|
+
const hiddenSet = new Set(resolved.hiddenTools.map(item => item.trim()).filter(Boolean));
|
|
14
|
+
const deferredSet = new Set(resolved.deferredTools.map(item => item.trim()).filter(Boolean));
|
|
15
|
+
if (hiddenSet.size > 0) {
|
|
16
|
+
ctx.effect(() => registerHybridDefaultHiddenTools(ctx, hiddenSet), 'codex-hybrid: default hidden tools');
|
|
17
|
+
}
|
|
18
|
+
if (deferredSet.size > 0) {
|
|
19
|
+
ctx.effect(() => registerHybridDefaultDeferredTools(ctx, deferredSet), 'codex-hybrid: default deferred tools');
|
|
20
|
+
}
|
|
21
|
+
if ((deferredSet.size > 0 || hiddenSet.size > 0) && typeof ctx.on === 'function') {
|
|
22
|
+
const parentScope = scopeOf(ctx);
|
|
23
|
+
ctx.on('agent/created', ({ agent }) => {
|
|
24
|
+
if (agent.ctx.get('codexToolPolicy') !== undefined)
|
|
25
|
+
return;
|
|
26
|
+
if (parentScope !== undefined && scopeParentOf(agent) !== parentScope)
|
|
27
|
+
return;
|
|
28
|
+
const agentTools = agent.ctx.get('tools');
|
|
29
|
+
const agentPrompt = agent.ctx.get('systemPrompt');
|
|
30
|
+
if (agentTools === undefined || agentPrompt === undefined)
|
|
31
|
+
return;
|
|
32
|
+
if (agentTools.get(ACTIVATE_TOOLS_NAME, agent) !== undefined)
|
|
33
|
+
return;
|
|
34
|
+
const upstream = scopeParentOf(agent);
|
|
35
|
+
const hiddenUpstream = [...hiddenSet].filter(tool => {
|
|
36
|
+
const visible = agentTools.get(tool, agent);
|
|
37
|
+
return visible !== undefined && agentTools.get(tool, upstream) === visible;
|
|
38
|
+
});
|
|
39
|
+
const deferredDefs = agentTools.definitions(upstream).filter(def => def.name !== ACTIVATE_TOOLS_NAME
|
|
40
|
+
&& !hiddenSet.has(def.name)
|
|
41
|
+
&& deferredSet.has(def.name)
|
|
42
|
+
&& agentTools.get(def.name, agent) !== undefined
|
|
43
|
+
&& agentTools.executable(def.name, agent) === def
|
|
44
|
+
&& agentTools.get(def.name, upstream) === def);
|
|
45
|
+
if (hiddenUpstream.length === 0 && deferredDefs.length === 0)
|
|
46
|
+
return;
|
|
47
|
+
agent.ctx.effect(function* () {
|
|
48
|
+
if (hiddenUpstream.length > 0)
|
|
49
|
+
yield agentTools.restrict({ deny: hiddenUpstream });
|
|
50
|
+
if (deferredDefs.length > 0)
|
|
51
|
+
yield* yieldDeferredToolsOverlay(agentTools, agentPrompt, deferredDefs, agent);
|
|
52
|
+
}, 'codex-hybrid: standalone baseline tools');
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export default { name, inject, Config, apply };
|
|
57
|
+
//# sourceMappingURL=hybrid-executor.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import z from '@deepseek-ai/schemastery';
|
|
4
|
+
import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT } from '../contracts/prompt.ts';
|
|
5
|
+
import type { CodexSettings } from '../contracts/settings.ts';
|
|
6
|
+
import { applyCodexPresentationSettings, applyCodexRequestSettings, buildCodexSystemPrompt, enrichCodexModel, normalizeCodexPromptAssembly, syncCodexContextWindow, withPresetPrompt } from '../presets/runtime-enhancements.ts';
|
|
7
|
+
import type { CodexModelProfile, CodexRequestConfig } from '../presets/runtime-enhancements.ts';
|
|
8
|
+
import { registerCodexExecAndPlan } from '../tools/exec-plan-tools.ts';
|
|
9
|
+
import type { CodexExecAndPlanOptions } from '../tools/exec-plan-tools.ts';
|
|
10
|
+
export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, };
|
|
11
|
+
export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from '../contracts/settings.ts';
|
|
12
|
+
export type { CodexSettings };
|
|
13
|
+
export { registerCodexExecAndPlan };
|
|
14
|
+
export type { CodexExecAndPlanOptions };
|
|
15
|
+
export { enrichCodexModel, syncCodexContextWindow, applyCodexRequestSettings, normalizeCodexPromptAssembly, applyCodexPresentationSettings, buildCodexSystemPrompt, withPresetPrompt, };
|
|
16
|
+
export type { CodexRequestConfig, CodexModelProfile };
|
|
17
|
+
export declare const name = "codex";
|
|
18
|
+
export declare const inject: string[];
|
|
19
|
+
/** Configuration for the Codex shell result bridge. */
|
|
20
|
+
export interface Config {
|
|
21
|
+
/** Install request/transport/activity enhancements for every agent scope. */
|
|
22
|
+
globalEnhancements?: boolean;
|
|
23
|
+
/** Install the Codex operating prompt and four core tools in this scope. */
|
|
24
|
+
codexCore?: boolean;
|
|
25
|
+
/** Default wait before a pipe-backed command yields a session id. */
|
|
26
|
+
defaultYieldTimeMs?: number;
|
|
27
|
+
/** Default wait for an empty `write_stdin` poll. */
|
|
28
|
+
pollYieldTimeMs?: number;
|
|
29
|
+
/** Default wait for a non-empty `write_stdin` send. */
|
|
30
|
+
writeYieldTimeMs?: number;
|
|
31
|
+
/** Maximum output retained in one canonical result, in UTF-8 bytes. */
|
|
32
|
+
maxOutputBytes?: number;
|
|
33
|
+
/** Send GPT Responses requests with the native hosted web_search tool first. */
|
|
34
|
+
hostedWebSearch?: boolean;
|
|
35
|
+
/** Use the provider's /responses/compact endpoint before local compaction. */
|
|
36
|
+
remoteCompact?: boolean;
|
|
37
|
+
/** Complete plugin-owned Codex operating prompt. */
|
|
38
|
+
systemPrompt?: string;
|
|
39
|
+
/** Explicit per-preset operating prompt; overrides the shared prompt only. */
|
|
40
|
+
presetPrompt?: string;
|
|
41
|
+
/** Per-preset Codex capability overrides. Omitted values follow shared settings. */
|
|
42
|
+
promptEnabled?: boolean;
|
|
43
|
+
terminalToolsEnabled?: boolean;
|
|
44
|
+
patchToolEnabled?: boolean;
|
|
45
|
+
planToolEnabled?: boolean;
|
|
46
|
+
hostedWebSearchEnabled?: boolean;
|
|
47
|
+
remoteCompactionEnabled?: boolean;
|
|
48
|
+
/** Deployment Persona template. */
|
|
49
|
+
persona?: string;
|
|
50
|
+
/** DSH Core source-checkout guidance template. */
|
|
51
|
+
harnessSourcePrompt?: string;
|
|
52
|
+
/** DSH Core Web GUI guidance template. */
|
|
53
|
+
webSurfacePrompt?: string;
|
|
54
|
+
}
|
|
55
|
+
/** Runtime configuration schema for the Codex tool bridge. */
|
|
56
|
+
export declare const Config: z<Config>;
|
|
57
|
+
/** Mount the Codex prompt/tool layer inside one fixed agent preset. */
|
|
58
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
59
|
+
declare const _default: {
|
|
60
|
+
name: string;
|
|
61
|
+
inject: string[];
|
|
62
|
+
Config: z<Config>;
|
|
63
|
+
apply: typeof apply;
|
|
64
|
+
};
|
|
65
|
+
export default _default;
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, resolveCodexSystemPrompt, } from "../contracts/prompt.js";
|
|
4
|
+
import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE, isGptModel, readHostSettings, } from "../contracts/settings.js";
|
|
5
|
+
import { CODEX_CONTEXT_MAX, OPENAI_CODEX_MODEL_LIMITS } from "../contracts/ui-contracts.js";
|
|
6
|
+
import { hasPresetPromptOverride } from "../policy/tool-capabilities.js";
|
|
7
|
+
import { registerCodexActivityProjection } from "../presets/activity.js";
|
|
8
|
+
import { applyCodexPresentationSettings, applyCodexRequestSettings, buildCodexSystemPrompt, enrichCodexModel, installCodexContextProjection, installPresetEditor, normalizeCodexPromptAssembly, syncCodexContextWindow, watchConfiguredGptModels, withPresetPrompt, } from "../presets/runtime-enhancements.js";
|
|
9
|
+
import { installSmallWindowCompaction } from "../presets/small-window-compaction.js";
|
|
10
|
+
import { collectTrustedCompactionMarkers } from "../responses/compact-checkpoint.js";
|
|
11
|
+
import { installHostedWebSearch, hostedWebSearchStream } from "../responses/fetch-transport.js";
|
|
12
|
+
import { hasDirectResponsesCompactRoute, remoteCompactStream } from "../responses/remote-compact.js";
|
|
13
|
+
import { repairLegacyPiAiContextOverflow } from "../responses/sse-diagnostics.js";
|
|
14
|
+
import { DEFAULT_MAX_OUTPUT_BYTES, registerCodexExecAndPlan, registerExecTools, registerPlanTool, } from "../tools/exec-plan-tools.js";
|
|
15
|
+
import { registerPatchTool } from "../tools/patch-tool.js";
|
|
16
|
+
import { installGlobalCompactCommand } from "./compact-command.js";
|
|
17
|
+
import { codexCompactionMode, withExplicitLocalCompactionInstruction } from "./compaction.js";
|
|
18
|
+
export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, };
|
|
19
|
+
export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from "../contracts/settings.js";
|
|
20
|
+
export { registerCodexExecAndPlan };
|
|
21
|
+
export { enrichCodexModel, syncCodexContextWindow, applyCodexRequestSettings, normalizeCodexPromptAssembly, applyCodexPresentationSettings, buildCodexSystemPrompt, withPresetPrompt, };
|
|
22
|
+
export const name = 'codex';
|
|
23
|
+
export const inject = ['tools', 'systemPrompt', 'shell', 'fs', 'llm', 'credentials', 'settings'];
|
|
24
|
+
/** Runtime configuration schema for the Codex tool bridge. */
|
|
25
|
+
export const Config = z.object({
|
|
26
|
+
globalEnhancements: z.boolean().default(true),
|
|
27
|
+
codexCore: z.boolean().default(true),
|
|
28
|
+
defaultYieldTimeMs: z.number().step(1).min(0).default(10_000),
|
|
29
|
+
pollYieldTimeMs: z.number().step(1).min(0).default(5_000),
|
|
30
|
+
writeYieldTimeMs: z.number().step(1).min(0).default(250),
|
|
31
|
+
maxOutputBytes: z.number().step(1).min(1).default(DEFAULT_MAX_OUTPUT_BYTES),
|
|
32
|
+
hostedWebSearch: z.boolean().default(true),
|
|
33
|
+
remoteCompact: z.boolean().default(true),
|
|
34
|
+
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
35
|
+
presetPrompt: z.string(),
|
|
36
|
+
promptEnabled: z.boolean(),
|
|
37
|
+
terminalToolsEnabled: z.boolean(),
|
|
38
|
+
patchToolEnabled: z.boolean(),
|
|
39
|
+
planToolEnabled: z.boolean(),
|
|
40
|
+
hostedWebSearchEnabled: z.boolean(),
|
|
41
|
+
remoteCompactionEnabled: z.boolean(),
|
|
42
|
+
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
43
|
+
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
44
|
+
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
45
|
+
});
|
|
46
|
+
/** Mount the Codex prompt/tool layer inside one fixed agent preset. */
|
|
47
|
+
export function apply(ctx, config = {}) {
|
|
48
|
+
const resolved = {
|
|
49
|
+
globalEnhancements: config.globalEnhancements ?? true,
|
|
50
|
+
codexCore: config.codexCore ?? true,
|
|
51
|
+
defaultYieldTimeMs: config.defaultYieldTimeMs ?? 10_000,
|
|
52
|
+
pollYieldTimeMs: config.pollYieldTimeMs ?? 5_000,
|
|
53
|
+
writeYieldTimeMs: config.writeYieldTimeMs ?? 250,
|
|
54
|
+
maxOutputBytes: config.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
55
|
+
hostedWebSearch: config.hostedWebSearch ?? true,
|
|
56
|
+
remoteCompact: config.remoteCompact ?? true,
|
|
57
|
+
systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT,
|
|
58
|
+
persona: config.persona ?? DEFAULT_CODEX_PERSONA,
|
|
59
|
+
harnessSourcePrompt: config.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
60
|
+
webSurfacePrompt: config.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT,
|
|
61
|
+
};
|
|
62
|
+
if (resolved.codexCore
|
|
63
|
+
&& ctx.fs.sandboxMode !== undefined
|
|
64
|
+
&& ctx.get('sandboxPolicy') === undefined) {
|
|
65
|
+
throw new Error('codex: a sandboxing filesystem requires ctx.sandboxPolicy');
|
|
66
|
+
}
|
|
67
|
+
const baseSettings = {
|
|
68
|
+
...CODEX_SETTINGS_ENTRY,
|
|
69
|
+
systemPrompt: resolved.systemPrompt,
|
|
70
|
+
persona: resolved.persona,
|
|
71
|
+
harnessSourcePrompt: resolved.harnessSourcePrompt,
|
|
72
|
+
webSurfacePrompt: resolved.webSurfacePrompt,
|
|
73
|
+
};
|
|
74
|
+
const sharedSettings = {
|
|
75
|
+
current: () => ({
|
|
76
|
+
...baseSettings,
|
|
77
|
+
...readHostSettings(ctx, CODEX_SETTINGS_NAMESPACE),
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
const codexSettings = { current: () => {
|
|
81
|
+
const shared = withPresetPrompt(sharedSettings.current(), config.presetPrompt);
|
|
82
|
+
return {
|
|
83
|
+
...shared,
|
|
84
|
+
...(config.promptEnabled === undefined ? {} : { promptEnabled: config.promptEnabled }),
|
|
85
|
+
...(config.terminalToolsEnabled === undefined ? {} : { terminalToolsEnabled: config.terminalToolsEnabled }),
|
|
86
|
+
...(config.patchToolEnabled === undefined ? {} : { patchToolEnabled: config.patchToolEnabled }),
|
|
87
|
+
...(config.planToolEnabled === undefined ? {} : { planToolEnabled: config.planToolEnabled }),
|
|
88
|
+
...(config.hostedWebSearchEnabled === undefined ? {} : { hostedWebSearchEnabled: config.hostedWebSearchEnabled }),
|
|
89
|
+
...(config.remoteCompactionEnabled === undefined ? {} : { remoteCompactionEnabled: config.remoteCompactionEnabled }),
|
|
90
|
+
};
|
|
91
|
+
} };
|
|
92
|
+
const execConfig = {
|
|
93
|
+
...resolved,
|
|
94
|
+
currentSettings: codexSettings.current,
|
|
95
|
+
presetEnabled: config.terminalToolsEnabled !== false,
|
|
96
|
+
presetOverridesLegacy: config.terminalToolsEnabled !== undefined,
|
|
97
|
+
};
|
|
98
|
+
if (resolved.globalEnhancements) {
|
|
99
|
+
// Native presets reject host services in their isolated composition.
|
|
100
|
+
installPresetEditor(ctx);
|
|
101
|
+
installGlobalCompactCommand(ctx);
|
|
102
|
+
// The generic pi-ai plugin remains the owner of provider routes. This
|
|
103
|
+
// layer adds only request metadata and remote-first transport behavior.
|
|
104
|
+
watchConfiguredGptModels(ctx);
|
|
105
|
+
registerCodexActivityProjection(ctx);
|
|
106
|
+
installCodexContextProjection(ctx, codexSettings.current);
|
|
107
|
+
const lastRequestByAgent = new WeakMap();
|
|
108
|
+
installSmallWindowCompaction(ctx, codexSettings.current, lastRequestByAgent);
|
|
109
|
+
ctx.on('agent/request', async (payload, next) => {
|
|
110
|
+
const request = await next();
|
|
111
|
+
const updated = applyCodexRequestSettings(request, codexSettings.current());
|
|
112
|
+
const agent = payload?.agent;
|
|
113
|
+
if (agent !== null && typeof agent === 'object')
|
|
114
|
+
lastRequestByAgent.set(agent, updated);
|
|
115
|
+
return updated;
|
|
116
|
+
});
|
|
117
|
+
if (typeof ctx.effect === 'function') {
|
|
118
|
+
const disposeHostedWebSearch = installHostedWebSearch();
|
|
119
|
+
ctx.effect(() => disposeHostedWebSearch, 'codex: Responses transport wrapper');
|
|
120
|
+
}
|
|
121
|
+
ctx.on('llm/stream', ((options, next) => {
|
|
122
|
+
const settings = codexSettings.current();
|
|
123
|
+
const isCodexConnect = options.provider === 'openai-codex';
|
|
124
|
+
const contextWindow = options.contextWindow ?? (isCodexConnect ? undefined : settings.contextWindow);
|
|
125
|
+
const modelMax = typeof options.model === 'string'
|
|
126
|
+
? OPENAI_CODEX_MODEL_LIMITS[options.model]?.maxTokens
|
|
127
|
+
: undefined;
|
|
128
|
+
const repairCeiling = isCodexConnect
|
|
129
|
+
? (modelMax ?? CODEX_CONTEXT_MAX)
|
|
130
|
+
: options.purpose === 'compaction'
|
|
131
|
+
? Math.max(contextWindow ?? 0, modelMax ?? CODEX_CONTEXT_MAX)
|
|
132
|
+
: contextWindow;
|
|
133
|
+
const serviceTier = options.serviceTier ?? (!isCodexConnect && settings.fast ? 'priority' : undefined);
|
|
134
|
+
const trustedCheckpoints = Array.isArray(options.messages) ? collectTrustedCompactionMarkers(options.messages) : undefined;
|
|
135
|
+
const compactionMode = codexCompactionMode();
|
|
136
|
+
const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, repairCeiling);
|
|
137
|
+
if (options.purpose === 'compaction' && isGptModel(options.model)) {
|
|
138
|
+
if (compactionMode === 'local') {
|
|
139
|
+
const localOptions = withExplicitLocalCompactionInstruction(options);
|
|
140
|
+
if (localOptions !== options) {
|
|
141
|
+
if (!Object.isFrozen(options)) {
|
|
142
|
+
options.messages = localOptions.messages;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return repairLegacyPiAiContextOverflow(ctx.llm.stream(localOptions), options.model, repairCeiling);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return legacySafeNext();
|
|
149
|
+
}
|
|
150
|
+
const useRemoteCompaction = compactionMode === 'remote'
|
|
151
|
+
|| (compactionMode !== 'local' && resolved.remoteCompact && settings.remoteCompactionEnabled);
|
|
152
|
+
if (useRemoteCompaction && hasDirectResponsesCompactRoute(ctx, options.provider)) {
|
|
153
|
+
return remoteCompactStream(ctx, options, legacySafeNext, {
|
|
154
|
+
...serviceTier === undefined ? {} : { serviceTier },
|
|
155
|
+
hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
|
|
156
|
+
customApplyPatch: settings.patchToolEnabled,
|
|
157
|
+
...trustedCheckpoints === undefined ? {} : { trustedCheckpoints },
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return legacySafeNext();
|
|
161
|
+
}
|
|
162
|
+
if (options.purpose === undefined && isGptModel(options.model)) {
|
|
163
|
+
return repairLegacyPiAiContextOverflow(hostedWebSearchStream(next, {
|
|
164
|
+
...serviceTier === undefined ? {} : { serviceTier },
|
|
165
|
+
hostedWebSearch: !isCodexConnect && resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
|
|
166
|
+
customApplyPatch: settings.patchToolEnabled,
|
|
167
|
+
...trustedCheckpoints === undefined ? {} : { trustedCheckpoints },
|
|
168
|
+
}), options.model, repairCeiling);
|
|
169
|
+
}
|
|
170
|
+
return next();
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
if (resolved.codexCore) {
|
|
174
|
+
ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
|
|
175
|
+
const protectedNames = new Set(['deployment:persona-prefix', 'deployment:persona-suffix', 'codex:base']
|
|
176
|
+
.filter(name => hasPresetPromptOverride(ctx, context, name)));
|
|
177
|
+
return applyCodexPresentationSettings(await next(), codexSettings.current(), protectedNames);
|
|
178
|
+
});
|
|
179
|
+
ctx.systemPrompt.section({
|
|
180
|
+
name: 'codex:base',
|
|
181
|
+
order: 10,
|
|
182
|
+
text: () => codexSettings.current().promptEnabled
|
|
183
|
+
? resolveCodexSystemPrompt(codexSettings.current().systemPrompt)
|
|
184
|
+
: '',
|
|
185
|
+
});
|
|
186
|
+
registerExecTools(ctx, execConfig);
|
|
187
|
+
registerPatchTool(ctx, codexSettings.current, config.patchToolEnabled !== false, undefined, config.patchToolEnabled !== undefined);
|
|
188
|
+
registerPlanTool(ctx, codexSettings.current, config.planToolEnabled !== false, undefined, config.planToolEnabled !== undefined);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export default { name, inject, Config, apply };
|
|
192
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Profile-backed live preferences on DSH 0.2; legacy hosts keep settings.yaml. */
|
|
2
|
+
import { Service, type Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import { type CodexSettings } from '../contracts/settings.ts';
|
|
4
|
+
export declare const Config: import("@deepseek-ai/schemastery").default<NoInfer<CodexSettings>, NoInfer<CodexSettings>, "volatile-defined">;
|
|
5
|
+
export default class CodexPreferences extends Service {
|
|
6
|
+
private readonly value;
|
|
7
|
+
static Config: import("@deepseek-ai/schemastery").default<NoInfer<CodexSettings>, NoInfer<CodexSettings>, "volatile-defined">;
|
|
8
|
+
constructor(ctx: Context, value: ReturnType<typeof Config>);
|
|
9
|
+
current(): CodexSettings;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=preferences.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Profile-backed live preferences on DSH 0.2; legacy hosts keep settings.yaml. */
|
|
2
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_SCHEMA } from "../contracts/settings.js";
|
|
4
|
+
export const Config = CODEX_SETTINGS_SCHEMA.default(CODEX_SETTINGS_ENTRY).volatile();
|
|
5
|
+
export default class CodexPreferences extends Service {
|
|
6
|
+
value;
|
|
7
|
+
static Config = Config;
|
|
8
|
+
constructor(ctx, value) {
|
|
9
|
+
super(ctx, 'codexPreferences');
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
current() {
|
|
13
|
+
return this.value.get() ?? CODEX_SETTINGS_ENTRY;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=preferences.js.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Opt-in Host overlays for future Agents; source presets and Persona stay untouched. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { ToolPolicyConfigSource } from '../policy/rule-resolver.ts';
|
|
4
|
+
export type { ToolAction, ToolActionRule, ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
|
|
5
|
+
export { Config } from '../policy/rule-resolver.ts';
|
|
6
|
+
export type { ToolPolicyConfigSource } from '../policy/rule-resolver.ts';
|
|
7
|
+
export declare const name = "codex-tool-policy";
|
|
8
|
+
export declare const inject: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Affect future Agent lifecycles only. No existing-agent scan, polling, prompt
|
|
11
|
+
* rewrite, source-preset edit, or executor replacement is performed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function apply(ctx: Context, config?: ToolPolicyConfigSource): void;
|
|
14
|
+
declare const _default: {
|
|
15
|
+
name: string;
|
|
16
|
+
inject: string[];
|
|
17
|
+
Config: import("@deepseek-ai/schemastery").default<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
18
|
+
rules: import("@deepseek-ai/schemastery").default<({
|
|
19
|
+
preset?: string | null;
|
|
20
|
+
allow?: string[] | null;
|
|
21
|
+
deny?: string[] | null;
|
|
22
|
+
replaceShell?: boolean | null;
|
|
23
|
+
replacePlan?: boolean | null;
|
|
24
|
+
replacePatch?: boolean | null;
|
|
25
|
+
tools?: ({
|
|
26
|
+
name?: string | null;
|
|
27
|
+
action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
|
|
28
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
29
|
+
promptOverrides?: ({
|
|
30
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
31
|
+
text?: string | null;
|
|
32
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
33
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
34
|
+
preset: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
35
|
+
allow: import("@deepseek-ai/schemastery").default<string[], string[], "plain">;
|
|
36
|
+
deny: import("@deepseek-ai/schemastery").default<string[], string[], "plain">;
|
|
37
|
+
replaceShell: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
38
|
+
replacePlan: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
39
|
+
replacePatch: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
40
|
+
tools: import("@deepseek-ai/schemastery").default<({
|
|
41
|
+
name?: string | null;
|
|
42
|
+
action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
|
|
43
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
44
|
+
name: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
45
|
+
action: import("@deepseek-ai/schemastery").default<"codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "defined">;
|
|
46
|
+
}>>[], "plain">;
|
|
47
|
+
promptOverrides: import("@deepseek-ai/schemastery").default<({
|
|
48
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
49
|
+
text?: string | null;
|
|
50
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
51
|
+
name: import("@deepseek-ai/schemastery").default<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
52
|
+
text: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
53
|
+
}>>[], "plain">;
|
|
54
|
+
}>>[], "defined">;
|
|
55
|
+
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
56
|
+
rules: import("@deepseek-ai/schemastery").default<({
|
|
57
|
+
preset?: string | null;
|
|
58
|
+
allow?: string[] | null;
|
|
59
|
+
deny?: string[] | null;
|
|
60
|
+
replaceShell?: boolean | null;
|
|
61
|
+
replacePlan?: boolean | null;
|
|
62
|
+
replacePatch?: boolean | null;
|
|
63
|
+
tools?: ({
|
|
64
|
+
name?: string | null;
|
|
65
|
+
action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
|
|
66
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
67
|
+
promptOverrides?: ({
|
|
68
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
69
|
+
text?: string | null;
|
|
70
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
71
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
72
|
+
preset: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
73
|
+
allow: import("@deepseek-ai/schemastery").default<string[], string[], "plain">;
|
|
74
|
+
deny: import("@deepseek-ai/schemastery").default<string[], string[], "plain">;
|
|
75
|
+
replaceShell: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
76
|
+
replacePlan: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
77
|
+
replacePatch: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
78
|
+
tools: import("@deepseek-ai/schemastery").default<({
|
|
79
|
+
name?: string | null;
|
|
80
|
+
action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
|
|
81
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
82
|
+
name: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
83
|
+
action: import("@deepseek-ai/schemastery").default<"codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "defined">;
|
|
84
|
+
}>>[], "plain">;
|
|
85
|
+
promptOverrides: import("@deepseek-ai/schemastery").default<({
|
|
86
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
87
|
+
text?: string | null;
|
|
88
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
89
|
+
name: import("@deepseek-ai/schemastery").default<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
90
|
+
text: import("@deepseek-ai/schemastery").default<string, string, "defined">;
|
|
91
|
+
}>>[], "plain">;
|
|
92
|
+
}>>[], "defined">;
|
|
93
|
+
}>>>, "volatile">;
|
|
94
|
+
apply: typeof apply;
|
|
95
|
+
};
|
|
96
|
+
export default _default;
|
|
97
|
+
//# sourceMappingURL=tool-policy.d.ts.map
|