@shuind/dsh-codex-harness 0.2.21 → 0.2.32-dsh-v0.2.2-rc.1
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 +121 -0
- package/README.md +48 -38
- package/RELEASE.md +61 -0
- package/assets/codex.svg +5 -0
- package/cordis.patch.yml +150 -6
- package/docs/preset-library.md +39 -23
- package/docs/tool-policy-benchmark.json +310 -0
- package/docs/tool-policy.md +144 -0
- package/lib/client.js +1639 -111
- package/lib/compaction.js +17 -2
- package/lib/index.js +799 -188
- package/lib/installer.js +50 -6
- package/lib/preferences.js +111 -0
- package/lib/tool-policy.js +2235 -0
- package/lib/typert.js +57 -10
- package/lib/types/activity.d.ts +1 -1
- package/lib/types/activity.js +50 -14
- package/lib/types/client/activity.d.ts +33 -9
- package/lib/types/client/desktop.d.ts +43 -0
- package/lib/types/client/desktop.js +121 -0
- package/lib/types/client/entry.d.ts +10 -0
- package/lib/types/client/entry.js +12 -0
- package/lib/types/client/index.d.ts +109 -19
- package/lib/types/client/index.js +21 -40
- package/lib/types/client/policy-drafts.d.ts +25 -0
- package/lib/types/client/policy-drafts.js +47 -0
- package/lib/types/client/preset-copy.d.ts +1 -0
- package/lib/types/client/preset-copy.js +2 -0
- package/lib/types/client/preset-manager.d.ts +12 -2
- package/lib/types/client/preset-manager.js +70 -25
- package/lib/types/client/preset-requests.d.ts +12 -0
- package/lib/types/client/preset-requests.js +101 -0
- package/lib/types/client/session.d.ts +6 -0
- package/lib/types/client/session.js +9 -0
- package/lib/types/client/tool-policy.d.ts +120 -0
- package/lib/types/client/tool-policy.js +394 -0
- package/lib/types/compaction.d.ts +3 -3
- package/lib/types/compaction.js +6 -2
- package/lib/types/desktop-preset.d.ts +20 -0
- package/lib/types/desktop-preset.js +39 -0
- package/lib/types/exec.d.ts +4 -0
- package/lib/types/exec.js +192 -66
- package/lib/types/host-settings.d.ts +4 -0
- package/lib/types/host-settings.js +13 -0
- package/lib/types/index.d.ts +20 -2
- package/lib/types/index.js +181 -68
- package/lib/types/installer.js +11 -2
- package/lib/types/preferences.d.ts +11 -0
- package/lib/types/preferences.js +16 -0
- package/lib/types/preset-editor-remote.d.ts +2 -0
- package/lib/types/preset-editor-remote.js +6 -2
- package/lib/types/preset-editor.d.ts +12 -7
- package/lib/types/preset-editor.js +43 -13
- package/lib/types/preset-prompt-catalog-schema.d.ts +16 -0
- package/lib/types/preset-prompt-catalog-schema.js +11 -0
- package/lib/types/preset-prompt-catalog.d.ts +21 -0
- package/lib/types/preset-prompt-catalog.js +192 -0
- package/lib/types/preset-prompt-contract.d.ts +22 -0
- package/lib/types/preset-prompt-contract.js +3 -0
- package/lib/types/preset-tool-catalog-schema.d.ts +38 -0
- package/lib/types/preset-tool-catalog-schema.js +28 -0
- package/lib/types/preset-tool-catalog.d.ts +5 -0
- package/lib/types/preset-tool-catalog.js +51 -0
- package/lib/types/prompt-sections.d.ts +1 -1
- package/lib/types/prompt-sections.js +9 -3
- package/lib/types/prompt.js +4 -2
- package/lib/types/remote.js +23 -8
- package/lib/types/settings.d.ts +3 -3
- package/lib/types/settings.js +3 -3
- package/lib/types/tool-capabilities.d.ts +32 -0
- package/lib/types/tool-capabilities.js +42 -0
- package/lib/types/tool-policy-contract.d.ts +60 -0
- package/lib/types/tool-policy-contract.js +26 -0
- package/lib/types/tool-policy.d.ts +171 -0
- package/lib/types/tool-policy.js +367 -0
- package/lib/types/typert.host.d.ts +2 -2
- package/lib/types/typert.host.js +12 -2
- package/locale/en.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 +375 -299
- package/scripts/benchmark-tool-policy.mjs +186 -0
- package/scripts/build-preset.mjs +19 -0
- package/scripts/clean-build.mjs +11 -0
- package/src/activity-types.ts +7 -0
- package/src/activity.ts +158 -0
- package/src/client/activity.ts +82 -0
- package/src/client/desktop.tsx +162 -0
- package/src/client/entry.tsx +16 -0
- package/src/client/index.tsx +972 -0
- package/src/client/policy-drafts.ts +56 -0
- package/src/client/preset-copy.ts +83 -0
- package/src/client/preset-manager.tsx +281 -0
- package/src/client/preset-requests.ts +113 -0
- package/src/client/session.ts +11 -0
- package/src/client/tool-policy.tsx +380 -0
- package/src/compact-command.ts +112 -0
- package/src/compaction.ts +190 -0
- package/src/context.ts +15 -0
- package/src/desktop-preset.ts +55 -0
- package/src/exec.ts +570 -0
- package/src/host-settings.ts +17 -0
- package/src/index.ts +1097 -0
- package/src/installer.ts +172 -0
- package/src/invariant.ts +34 -0
- package/src/patch.ts +258 -0
- package/src/preferences.ts +17 -0
- package/src/preset-contract.ts +85 -0
- package/src/preset-editor-remote.ts +41 -0
- package/src/preset-editor.ts +502 -0
- package/src/preset-prompt-catalog-schema.ts +10 -0
- package/src/preset-prompt-catalog.ts +191 -0
- package/src/preset-prompt-contract.ts +21 -0
- package/src/preset-tool-catalog-schema.ts +28 -0
- package/src/preset-tool-catalog.ts +51 -0
- package/src/prompt-sections.ts +33 -0
- package/src/prompt.ts +62 -0
- package/src/remote.ts +748 -0
- package/src/settings.ts +79 -0
- package/src/tool-capabilities.ts +76 -0
- package/src/tool-policy-contract.ts +76 -0
- package/src/tool-policy.ts +388 -0
- package/src/typert.host.ts +119 -0
- package/tsconfig.json +29 -0
- package/tsdown.config.ts +110 -0
- package/lib/types/preset-templates.d.ts +0 -36
- package/lib/types/preset-templates.js +0 -12
package/lib/types/remote.js
CHANGED
|
@@ -5,6 +5,7 @@ import { mkdirSync, writeFileSync } from 'node:fs';
|
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { join, resolve } from 'node:path';
|
|
7
7
|
import { APPLY_PATCH_DESCRIPTION, APPLY_PATCH_GRAMMAR } from "./patch.js";
|
|
8
|
+
import { readHostSettings } from "./host-settings.js";
|
|
8
9
|
const SETTINGS_NAMESPACE = 'llm-pi-ai';
|
|
9
10
|
const REMOTE_COMPACTION_OPEN = '<codex-remote-compaction>';
|
|
10
11
|
const REMOTE_COMPACTION_CLOSE = '</codex-remote-compaction>';
|
|
@@ -21,8 +22,7 @@ function isGptModel(model) {
|
|
|
21
22
|
return typeof model === 'string' && /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
22
23
|
}
|
|
23
24
|
function settingsOf(ctx) {
|
|
24
|
-
|
|
25
|
-
return provider?.get?.(SETTINGS_NAMESPACE);
|
|
25
|
+
return readHostSettings(ctx, SETTINGS_NAMESPACE);
|
|
26
26
|
}
|
|
27
27
|
function profileOf(ctx, provider) {
|
|
28
28
|
return settingsOf(ctx)?.providers?.[provider];
|
|
@@ -452,7 +452,7 @@ export function installHostedWebSearch() {
|
|
|
452
452
|
/** Iterate an existing DSH stream with the hosted-request context installed. */
|
|
453
453
|
export function hostedWebSearchStream(next, options = {}) {
|
|
454
454
|
return (async function* () {
|
|
455
|
-
const iterator = next()[Symbol.asyncIterator]();
|
|
455
|
+
const iterator = HOSTED_REQUESTS.run(options, () => next()[Symbol.asyncIterator]());
|
|
456
456
|
let completed = false;
|
|
457
457
|
try {
|
|
458
458
|
while (true) {
|
|
@@ -466,7 +466,7 @@ export function hostedWebSearchStream(next, options = {}) {
|
|
|
466
466
|
}
|
|
467
467
|
finally {
|
|
468
468
|
if (!completed)
|
|
469
|
-
await iterator.return?.();
|
|
469
|
+
await HOSTED_REQUESTS.run(options, () => iterator.return?.());
|
|
470
470
|
}
|
|
471
471
|
})();
|
|
472
472
|
}
|
|
@@ -520,7 +520,17 @@ function textOf(message) {
|
|
|
520
520
|
function responsesInput(messages) {
|
|
521
521
|
const result = [];
|
|
522
522
|
for (const message of messages) {
|
|
523
|
+
// This lightweight compact transport cannot serialize attachment references or
|
|
524
|
+
// in-history tool updates losslessly. Delegate those requests to DSH's adapter.
|
|
525
|
+
if (message.content.some(block => block.type === 'image' || block.type === 'file'
|
|
526
|
+
|| block.type === 'tool-addition' || block.type === 'tool-removal')) {
|
|
527
|
+
throw new Error('Codex remote compaction requires the DSH adapter for attachments or tool-history updates');
|
|
528
|
+
}
|
|
523
529
|
const text = textOf(message);
|
|
530
|
+
if (message.role === 'tool') {
|
|
531
|
+
result.push({ type: 'function_call_output', call_id: message.toolCallId, output: text });
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
524
534
|
if (message.role === 'assistant') {
|
|
525
535
|
if (text.length > 0)
|
|
526
536
|
result.push({
|
|
@@ -540,20 +550,25 @@ function responsesInput(messages) {
|
|
|
540
550
|
}
|
|
541
551
|
continue;
|
|
542
552
|
}
|
|
543
|
-
const role = message.role === 'system' ? 'developer' : 'user';
|
|
553
|
+
const role = message.role === 'system' || message.role === 'developer' ? 'developer' : 'user';
|
|
544
554
|
if (text.length > 0)
|
|
545
555
|
result.push({
|
|
546
556
|
type: 'message',
|
|
547
557
|
role,
|
|
548
558
|
content: [{ type: 'input_text', text }],
|
|
549
559
|
});
|
|
550
|
-
|
|
551
|
-
|
|
560
|
+
// Older hosts represented results as content blocks on a user message.
|
|
561
|
+
const legacyBlocks = message.content;
|
|
562
|
+
for (const candidate of legacyBlocks) {
|
|
563
|
+
if (typeof candidate !== 'object' || candidate === null)
|
|
564
|
+
continue;
|
|
565
|
+
const block = candidate;
|
|
566
|
+
if (block.type !== 'tool-result' || typeof block.toolCallId !== 'string' || !Array.isArray(block.content))
|
|
552
567
|
continue;
|
|
553
568
|
result.push({
|
|
554
569
|
type: 'function_call_output',
|
|
555
570
|
call_id: block.toolCallId,
|
|
556
|
-
output: block.content.filter(item => item.type === 'text').map(item => item.text).join(''),
|
|
571
|
+
output: block.content.filter(item => item.type === 'text').map(item => item.text ?? '').join(''),
|
|
557
572
|
});
|
|
558
573
|
}
|
|
559
574
|
}
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ export interface CodexSettings {
|
|
|
20
20
|
systemPrompt?: string;
|
|
21
21
|
/** Inject the plugin-owned Codex operating prompt. */
|
|
22
22
|
promptEnabled: boolean;
|
|
23
|
-
/**
|
|
23
|
+
/** Deprecated compatibility baseline, snapshotted into future Agent tool plans. */
|
|
24
24
|
terminalToolsEnabled: boolean;
|
|
25
|
-
/**
|
|
25
|
+
/** Deprecated tool baseline; also retains the legacy JSON/custom wire-format preference. */
|
|
26
26
|
patchToolEnabled: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/** Deprecated compatibility baseline, not a live veto of a compiled plan. */
|
|
28
28
|
planToolEnabled: boolean;
|
|
29
29
|
/** Upgrade local web_search declarations to the hosted Responses tool. */
|
|
30
30
|
hostedWebSearchEnabled: boolean;
|
package/lib/types/settings.js
CHANGED
|
@@ -29,9 +29,9 @@ export const CODEX_SETTINGS_SCHEMA = z.object({
|
|
|
29
29
|
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
30
30
|
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
31
31
|
promptEnabled: z.boolean().default(true),
|
|
32
|
-
terminalToolsEnabled: z.boolean().default(true),
|
|
33
|
-
patchToolEnabled: z.boolean().default(true),
|
|
34
|
-
planToolEnabled: z.boolean().default(true),
|
|
32
|
+
terminalToolsEnabled: z.boolean().default(true).hidden(),
|
|
33
|
+
patchToolEnabled: z.boolean().default(true).hidden(),
|
|
34
|
+
planToolEnabled: z.boolean().default(true).hidden(),
|
|
35
35
|
hostedWebSearchEnabled: z.boolean().default(true),
|
|
36
36
|
remoteCompactionEnabled: z.boolean().default(true),
|
|
37
37
|
activityIndicatorEnabled: z.boolean().default(true),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Host-only ownership marks and the optional Agent-snapshot availability seam. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
5
|
+
import type { ScopeKey } from '@deepseek-ai/dsh-scope';
|
|
6
|
+
import type { AssembleContext } from '@deepseek-ai/dsh-system-prompt';
|
|
7
|
+
import type { CodexSettings } from './settings.ts';
|
|
8
|
+
import type { CodexToolMetadata, LegacyCapabilities } from './tool-policy-contract.ts';
|
|
9
|
+
export interface CodexToolPolicyResolver {
|
|
10
|
+
/** Undefined means an older, unsnapshotted Agent retains the compatibility path. */
|
|
11
|
+
enabled(agent: Agent, name: string, metadata: CodexToolMetadata): boolean | undefined;
|
|
12
|
+
hasPromptOverride?(scope: ScopeKey, name: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
declare module '@deepseek-ai/dsh-system-prompt' {
|
|
15
|
+
interface AssembleContext {
|
|
16
|
+
/** Read-only own-plugin probe: do not reapply obsolete Codex prompt preferences. */
|
|
17
|
+
codexPresetPromptProbe?: true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Only our old presentation hooks consume this; registrations remain provider-owned. */
|
|
21
|
+
export declare function hasPresetPromptOverride(ctx: Context, context: AssembleContext, name: string): boolean;
|
|
22
|
+
declare module '@deepseek-ai/cordis' {
|
|
23
|
+
interface Context {
|
|
24
|
+
codexToolPolicy: CodexToolPolicyResolver;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare function markCodexTool<T extends ToolDefinition>(definition: T, metadata: CodexToolMetadata): T;
|
|
28
|
+
export declare function codexToolMetadata(definition: ToolDefinition): CodexToolMetadata | undefined;
|
|
29
|
+
/** Read once for a new Agent or catalog. No caller keeps the live preference object. */
|
|
30
|
+
export declare function readLegacyCapabilities(ctx: Context): Readonly<Required<LegacyCapabilities>>;
|
|
31
|
+
export declare function codexToolEnabled(ctx: Context, agent: Agent | undefined, name: string, metadata: CodexToolMetadata, fallback: () => CodexSettings, authority?: boolean): boolean;
|
|
32
|
+
//# sourceMappingURL=tool-capabilities.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE } from "./settings.js";
|
|
2
|
+
import { readHostSettings } from "./host-settings.js";
|
|
3
|
+
// Core and policy are bundled separately. A global symbol survives that boundary;
|
|
4
|
+
// matching an unmarked third-party tool by name would not establish ownership.
|
|
5
|
+
const OWNED_TOOL = Symbol.for('@shuind/dsh-codex-harness:tool-capability:v1');
|
|
6
|
+
const CAPABILITIES = ['terminalToolsEnabled', 'planToolEnabled', 'patchToolEnabled'];
|
|
7
|
+
/** Only our old presentation hooks consume this; registrations remain provider-owned. */
|
|
8
|
+
export function hasPresetPromptOverride(ctx, context, name) {
|
|
9
|
+
if (context.codexPresetPromptProbe === true)
|
|
10
|
+
return ['deployment:persona-prefix', 'deployment:persona-suffix', 'codex:base'].includes(name);
|
|
11
|
+
return context.scope !== undefined && ctx.get('codexToolPolicy')?.hasPromptOverride?.(context.scope, name) === true;
|
|
12
|
+
}
|
|
13
|
+
export function markCodexTool(definition, metadata) {
|
|
14
|
+
Object.defineProperty(definition, OWNED_TOOL, { value: Object.freeze({ ...metadata }) });
|
|
15
|
+
return definition;
|
|
16
|
+
}
|
|
17
|
+
export function codexToolMetadata(definition) {
|
|
18
|
+
const value = definition[OWNED_TOOL];
|
|
19
|
+
if (value === null || typeof value !== 'object')
|
|
20
|
+
return undefined;
|
|
21
|
+
const data = value;
|
|
22
|
+
if (!CAPABILITIES.includes(data.capability) || typeof data.presetEnabled !== 'boolean'
|
|
23
|
+
|| data.presetOverridesLegacy !== undefined && typeof data.presetOverridesLegacy !== 'boolean')
|
|
24
|
+
return undefined;
|
|
25
|
+
return { capability: data.capability, presetEnabled: data.presetEnabled,
|
|
26
|
+
...(data.presetOverridesLegacy === undefined ? {} : { presetOverridesLegacy: data.presetOverridesLegacy }) };
|
|
27
|
+
}
|
|
28
|
+
/** Read once for a new Agent or catalog. No caller keeps the live preference object. */
|
|
29
|
+
export function readLegacyCapabilities(ctx) {
|
|
30
|
+
const current = readHostSettings(ctx, CODEX_SETTINGS_NAMESPACE);
|
|
31
|
+
return Object.freeze(Object.fromEntries(CAPABILITIES.map(key => [key, current?.[key] ?? CODEX_SETTINGS_ENTRY[key]])));
|
|
32
|
+
}
|
|
33
|
+
export function codexToolEnabled(ctx, agent, name, metadata, fallback, authority) {
|
|
34
|
+
if (!metadata.presetEnabled)
|
|
35
|
+
return false;
|
|
36
|
+
// Only a successfully compiled adapter plan supplies this authority.
|
|
37
|
+
if (authority !== undefined)
|
|
38
|
+
return authority;
|
|
39
|
+
const decision = agent === undefined ? undefined : ctx.get('codexToolPolicy')?.enabled(agent, name, metadata);
|
|
40
|
+
return decision ?? fallback()[metadata.capability] !== false;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=tool-capabilities.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Client-safe tool choices. The concrete adapters remain Host-owned. */
|
|
2
|
+
import type { PresetPromptOverride } from './preset-prompt-contract.ts';
|
|
3
|
+
export { PRESET_PROMPT_NAMES } from './preset-prompt-contract.ts';
|
|
4
|
+
export type { PresetPromptName, PresetPromptOverride, PresetPromptEntry, PresetPromptCatalog } from './preset-prompt-contract.ts';
|
|
5
|
+
export type ToolAction = 'keep' | 'hide' | 'codex-exec' | 'codex-plan';
|
|
6
|
+
export type ReplacementAction = Extract<ToolAction, 'codex-exec' | 'codex-plan'>;
|
|
7
|
+
export type CodexCapability = 'terminalToolsEnabled' | 'planToolEnabled' | 'patchToolEnabled';
|
|
8
|
+
export type LegacyCapabilities = Partial<Record<CodexCapability, boolean>>;
|
|
9
|
+
/** Ownership metadata, not a promise that `keep` admits a locally disabled tool. */
|
|
10
|
+
export interface CodexToolMetadata {
|
|
11
|
+
readonly capability: CodexCapability;
|
|
12
|
+
readonly presetEnabled: boolean;
|
|
13
|
+
/** An explicit old per-preset boolean already overrode the shared baseline. */
|
|
14
|
+
readonly presetOverridesLegacy?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ToolActionContext {
|
|
17
|
+
readonly legacyCapabilities?: LegacyCapabilities;
|
|
18
|
+
readonly codexTool?: CodexToolMetadata;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolActionRule {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly action: ToolAction;
|
|
23
|
+
}
|
|
24
|
+
export interface ToolPolicyRule {
|
|
25
|
+
readonly preset: string;
|
|
26
|
+
readonly allow?: readonly string[];
|
|
27
|
+
readonly deny?: readonly string[];
|
|
28
|
+
/** Legacy category defaults; new UI rules explicitly set both to false. */
|
|
29
|
+
readonly replaceShell?: boolean;
|
|
30
|
+
readonly replacePlan?: boolean;
|
|
31
|
+
/** Explicit per-source choices override the legacy masks and category defaults. */
|
|
32
|
+
readonly tools?: readonly ToolActionRule[];
|
|
33
|
+
/** Exact reviewed section replacements, scoped to future Agents of this preset. */
|
|
34
|
+
readonly promptOverrides?: readonly PresetPromptOverride[];
|
|
35
|
+
}
|
|
36
|
+
export interface PresetToolReplacement {
|
|
37
|
+
readonly action: ReplacementAction;
|
|
38
|
+
readonly tools: readonly string[];
|
|
39
|
+
readonly available: boolean;
|
|
40
|
+
readonly reason?: 'conditional' | 'target-exists';
|
|
41
|
+
}
|
|
42
|
+
export interface PresetToolEntry {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly description: string;
|
|
45
|
+
readonly conditional: boolean;
|
|
46
|
+
readonly replacements: readonly PresetToolReplacement[];
|
|
47
|
+
readonly codexTool?: CodexToolMetadata;
|
|
48
|
+
}
|
|
49
|
+
export interface PresetToolCatalog {
|
|
50
|
+
readonly preset: string;
|
|
51
|
+
/** Registration snapshot, not admission for a particular Agent/model step. */
|
|
52
|
+
readonly registeredOnly: true;
|
|
53
|
+
readonly tools: readonly PresetToolEntry[];
|
|
54
|
+
readonly legacyCapabilities?: LegacyCapabilities;
|
|
55
|
+
}
|
|
56
|
+
/** Legacy configuration remains a baseline, never a live second veto of an explicit choice. */
|
|
57
|
+
export declare function legacyToolAction(rule: ToolPolicyRule | undefined, name: string, context?: ToolActionContext): ToolAction;
|
|
58
|
+
/** Policy action only: `keep` still respects the original preset's local enablement. */
|
|
59
|
+
export declare function effectiveToolAction(rule: ToolPolicyRule | undefined, name: string, context?: ToolActionContext): ToolAction;
|
|
60
|
+
//# sourceMappingURL=tool-policy-contract.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { PRESET_PROMPT_NAMES } from "./preset-prompt-contract.js";
|
|
2
|
+
/** Legacy configuration remains a baseline, never a live second veto of an explicit choice. */
|
|
3
|
+
export function legacyToolAction(rule, name, context = {}) {
|
|
4
|
+
let action = 'keep';
|
|
5
|
+
if (rule !== undefined) {
|
|
6
|
+
if ((rule.allow !== undefined && !rule.allow.includes(name)) || rule.deny?.includes(name))
|
|
7
|
+
return 'hide';
|
|
8
|
+
if ((name === 'bash' || name === 'pwsh') && rule.replaceShell !== false)
|
|
9
|
+
action = 'codex-exec';
|
|
10
|
+
if (name === 'todo_write' && rule.replacePlan !== false)
|
|
11
|
+
action = 'codex-plan';
|
|
12
|
+
}
|
|
13
|
+
const capability = context.codexTool?.capability
|
|
14
|
+
?? (action === 'codex-exec' ? 'terminalToolsEnabled' : action === 'codex-plan' ? 'planToolEnabled' : undefined);
|
|
15
|
+
// Only owned definitions and chosen Codex adapters consume the legacy baseline.
|
|
16
|
+
// A third-party tool with the same name does not become a Codex capability.
|
|
17
|
+
const presetOverride = context.codexTool?.presetOverridesLegacy === true && context.codexTool.presetEnabled;
|
|
18
|
+
if (!presetOverride && capability !== undefined && context.legacyCapabilities?.[capability] === false)
|
|
19
|
+
return 'hide';
|
|
20
|
+
return action;
|
|
21
|
+
}
|
|
22
|
+
/** Policy action only: `keep` still respects the original preset's local enablement. */
|
|
23
|
+
export function effectiveToolAction(rule, name, context = {}) {
|
|
24
|
+
return rule?.tools?.find(tool => tool.name === name)?.action ?? legacyToolAction(rule, name, context);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=tool-policy-contract.js.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/** Opt-in Host overlays for future Agents; source presets and Persona stay untouched. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import z from '@deepseek-ai/schemastery';
|
|
4
|
+
import type { ToolPolicyRule } from './tool-policy-contract.ts';
|
|
5
|
+
export type { ToolAction, ToolActionRule, ToolPolicyRule } from './tool-policy-contract.ts';
|
|
6
|
+
export declare const name = "codex-tool-policy";
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
export interface Config {
|
|
9
|
+
/** Empty by default: no preset or existing Agent is changed implicitly. */
|
|
10
|
+
rules?: readonly ToolPolicyRule[];
|
|
11
|
+
}
|
|
12
|
+
export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
13
|
+
rules: z<({
|
|
14
|
+
preset?: string | null;
|
|
15
|
+
allow?: string[] | null;
|
|
16
|
+
deny?: string[] | null;
|
|
17
|
+
replaceShell?: boolean | null;
|
|
18
|
+
replacePlan?: boolean | null;
|
|
19
|
+
tools?: ({
|
|
20
|
+
name?: string | null;
|
|
21
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
22
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
23
|
+
promptOverrides?: ({
|
|
24
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
25
|
+
text?: string | null;
|
|
26
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
27
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
28
|
+
preset: z<string, string, "defined">;
|
|
29
|
+
allow: z<string[], string[], "plain">;
|
|
30
|
+
deny: z<string[], string[], "plain">;
|
|
31
|
+
replaceShell: z<boolean, boolean, "defined">;
|
|
32
|
+
replacePlan: z<boolean, boolean, "defined">;
|
|
33
|
+
tools: z<({
|
|
34
|
+
name?: string | null;
|
|
35
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
36
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
37
|
+
name: z<string, string, "defined">;
|
|
38
|
+
action: z<"keep" | "hide" | "codex-exec" | "codex-plan", "keep" | "hide" | "codex-exec" | "codex-plan", "defined">;
|
|
39
|
+
}>>[], "plain">;
|
|
40
|
+
promptOverrides: z<({
|
|
41
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
42
|
+
text?: string | null;
|
|
43
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
44
|
+
name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
45
|
+
text: z<string, string, "defined">;
|
|
46
|
+
}>>[], "plain">;
|
|
47
|
+
}>>[], "defined">;
|
|
48
|
+
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
49
|
+
rules: z<({
|
|
50
|
+
preset?: string | null;
|
|
51
|
+
allow?: string[] | null;
|
|
52
|
+
deny?: string[] | null;
|
|
53
|
+
replaceShell?: boolean | null;
|
|
54
|
+
replacePlan?: boolean | null;
|
|
55
|
+
tools?: ({
|
|
56
|
+
name?: string | null;
|
|
57
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
58
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
59
|
+
promptOverrides?: ({
|
|
60
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
61
|
+
text?: string | null;
|
|
62
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
63
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
64
|
+
preset: z<string, string, "defined">;
|
|
65
|
+
allow: z<string[], string[], "plain">;
|
|
66
|
+
deny: z<string[], string[], "plain">;
|
|
67
|
+
replaceShell: z<boolean, boolean, "defined">;
|
|
68
|
+
replacePlan: z<boolean, boolean, "defined">;
|
|
69
|
+
tools: z<({
|
|
70
|
+
name?: string | null;
|
|
71
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
72
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
73
|
+
name: z<string, string, "defined">;
|
|
74
|
+
action: z<"keep" | "hide" | "codex-exec" | "codex-plan", "keep" | "hide" | "codex-exec" | "codex-plan", "defined">;
|
|
75
|
+
}>>[], "plain">;
|
|
76
|
+
promptOverrides: z<({
|
|
77
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
78
|
+
text?: string | null;
|
|
79
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
80
|
+
name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
81
|
+
text: z<string, string, "defined">;
|
|
82
|
+
}>>[], "plain">;
|
|
83
|
+
}>>[], "defined">;
|
|
84
|
+
}>>>, "volatile">;
|
|
85
|
+
/** Loader activations receive a volatile reference; direct callers may pass plain rules. */
|
|
86
|
+
export type ToolPolicyConfigSource = Config | ReturnType<typeof Config>;
|
|
87
|
+
/**
|
|
88
|
+
* Affect future Agent lifecycles only. No existing-agent scan, polling, prompt
|
|
89
|
+
* rewrite, source-preset edit, or executor replacement is performed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function apply(ctx: Context, config?: ToolPolicyConfigSource): void;
|
|
92
|
+
declare const _default: {
|
|
93
|
+
name: string;
|
|
94
|
+
inject: string[];
|
|
95
|
+
Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
96
|
+
rules: z<({
|
|
97
|
+
preset?: string | null;
|
|
98
|
+
allow?: string[] | null;
|
|
99
|
+
deny?: string[] | null;
|
|
100
|
+
replaceShell?: boolean | null;
|
|
101
|
+
replacePlan?: boolean | null;
|
|
102
|
+
tools?: ({
|
|
103
|
+
name?: string | null;
|
|
104
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
105
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
106
|
+
promptOverrides?: ({
|
|
107
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
108
|
+
text?: string | null;
|
|
109
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
110
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
111
|
+
preset: z<string, string, "defined">;
|
|
112
|
+
allow: z<string[], string[], "plain">;
|
|
113
|
+
deny: z<string[], string[], "plain">;
|
|
114
|
+
replaceShell: z<boolean, boolean, "defined">;
|
|
115
|
+
replacePlan: z<boolean, boolean, "defined">;
|
|
116
|
+
tools: z<({
|
|
117
|
+
name?: string | null;
|
|
118
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
119
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
120
|
+
name: z<string, string, "defined">;
|
|
121
|
+
action: z<"keep" | "hide" | "codex-exec" | "codex-plan", "keep" | "hide" | "codex-exec" | "codex-plan", "defined">;
|
|
122
|
+
}>>[], "plain">;
|
|
123
|
+
promptOverrides: z<({
|
|
124
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
125
|
+
text?: string | null;
|
|
126
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
127
|
+
name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
128
|
+
text: z<string, string, "defined">;
|
|
129
|
+
}>>[], "plain">;
|
|
130
|
+
}>>[], "defined">;
|
|
131
|
+
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
132
|
+
rules: z<({
|
|
133
|
+
preset?: string | null;
|
|
134
|
+
allow?: string[] | null;
|
|
135
|
+
deny?: string[] | null;
|
|
136
|
+
replaceShell?: boolean | null;
|
|
137
|
+
replacePlan?: boolean | null;
|
|
138
|
+
tools?: ({
|
|
139
|
+
name?: string | null;
|
|
140
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
141
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
142
|
+
promptOverrides?: ({
|
|
143
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
144
|
+
text?: string | null;
|
|
145
|
+
} & import("@deepseek-ai/cosmokit").Dict)[] | null;
|
|
146
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
147
|
+
preset: z<string, string, "defined">;
|
|
148
|
+
allow: z<string[], string[], "plain">;
|
|
149
|
+
deny: z<string[], string[], "plain">;
|
|
150
|
+
replaceShell: z<boolean, boolean, "defined">;
|
|
151
|
+
replacePlan: z<boolean, boolean, "defined">;
|
|
152
|
+
tools: z<({
|
|
153
|
+
name?: string | null;
|
|
154
|
+
action?: "keep" | "hide" | "codex-exec" | "codex-plan" | null;
|
|
155
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
156
|
+
name: z<string, string, "defined">;
|
|
157
|
+
action: z<"keep" | "hide" | "codex-exec" | "codex-plan", "keep" | "hide" | "codex-exec" | "codex-plan", "defined">;
|
|
158
|
+
}>>[], "plain">;
|
|
159
|
+
promptOverrides: z<({
|
|
160
|
+
name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
|
|
161
|
+
text?: string | null;
|
|
162
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
163
|
+
name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
|
|
164
|
+
text: z<string, string, "defined">;
|
|
165
|
+
}>>[], "plain">;
|
|
166
|
+
}>>[], "defined">;
|
|
167
|
+
}>>>, "volatile">;
|
|
168
|
+
apply: typeof apply;
|
|
169
|
+
};
|
|
170
|
+
export default _default;
|
|
171
|
+
//# sourceMappingURL=tool-policy.d.ts.map
|