@octopi-agent/engine 0.86.38 → 0.97.15
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/config-admin/agent-presets.d.ts +70 -0
- package/dist/config-admin/agent-presets.js +243 -0
- package/dist/config-admin/discover.d.ts +30 -0
- package/dist/config-admin/discover.js +48 -0
- package/dist/config-admin/env.d.ts +22 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/index.d.ts +20 -0
- package/dist/config-admin/index.js +15 -0
- package/dist/config-admin/model-presets.d.ts +75 -0
- package/dist/config-admin/model-presets.js +249 -0
- package/dist/config-admin/name-guard.d.ts +14 -0
- package/dist/config-admin/name-guard.js +24 -0
- package/dist/config-admin/patch.d.ts +56 -0
- package/dist/config-admin/patch.js +201 -0
- package/dist/config-admin/port.d.ts +68 -0
- package/dist/config-admin/port.js +21 -0
- package/dist/config-admin/redact.d.ts +39 -0
- package/dist/config-admin/redact.js +42 -0
- package/dist/config-schema/agent.d.ts +43 -1
- package/dist/config-schema/agent.js +12 -5
- package/dist/config-schema/context.d.ts +7 -2
- package/dist/config-schema/context.js +8 -0
- package/dist/config-schema/engine.d.ts +110 -8
- package/dist/config-schema/governance.d.ts +43 -1
- package/dist/config-schema/governance.js +160 -2
- package/dist/config-schema/models.d.ts +7 -4
- package/dist/config-schema/models.js +4 -1
- package/dist/config-schema/observability.d.ts +9 -0
- package/dist/config-schema/observability.js +29 -0
- package/dist/config-schema/run.d.ts +3 -0
- package/dist/config-schema/run.js +14 -0
- package/dist/config-schema/shared.d.ts +3 -0
- package/dist/config-schema/shared.js +12 -0
- package/dist/config-schema/substrate.d.ts +1 -1
- package/dist/config.d.ts +60 -13
- package/dist/config.js +81 -78
- package/dist/harness/activation/dispatcher.d.ts +8 -2
- package/dist/harness/activation/dispatcher.js +33 -5
- package/dist/harness/activation/inbox.d.ts +87 -0
- package/dist/harness/activation/inbox.js +169 -0
- package/dist/harness/activation/runtime.d.ts +9 -8
- package/dist/harness/activation/runtime.js +100 -8
- package/dist/harness/activation/types.d.ts +19 -0
- package/dist/harness/activation/types.js +2 -0
- package/dist/harness/agent/builder.d.ts +18 -3
- package/dist/harness/agent/builder.js +42 -17
- package/dist/harness/agent/config-bridge.d.ts +5 -0
- package/dist/harness/agent/config-bridge.js +7 -1
- package/dist/harness/agent/config-integrity.d.ts +72 -0
- package/dist/harness/agent/config-integrity.js +146 -0
- package/dist/harness/agent/tool-purpose.d.ts +9 -1
- package/dist/harness/agent/tool-purpose.js +11 -2
- package/dist/harness/agent/wire-agent-builder.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +3 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -1
- package/dist/harness/collaboration/delegation/child-run.js +21 -5
- package/dist/harness/collaboration/delegation/notifier.js +4 -3
- package/dist/harness/collaboration/delegation/service.js +2 -3
- package/dist/harness/collaboration/delegation/wiring.js +6 -5
- package/dist/harness/collaboration/orchestration/reflector/llm-reflector.d.ts +1 -1
- package/dist/harness/collaboration/orchestration/reflector/llm-reflector.js +1 -1
- package/dist/harness/context/capabilities/compact/engine.d.ts +30 -0
- package/dist/harness/context/capabilities/compact/engine.js +198 -46
- package/dist/harness/context/capabilities/compact/handover.d.ts +78 -0
- package/dist/harness/context/capabilities/compact/handover.js +107 -0
- package/dist/harness/context/capabilities/compact/index.d.ts +3 -1
- package/dist/harness/context/capabilities/compact/index.js +2 -1
- package/dist/harness/context/capabilities/compact/types.d.ts +30 -1
- package/dist/harness/context/capabilities/summary/executor.js +2 -1
- package/dist/harness/context/capabilities/summary/policies.js +8 -5
- package/dist/harness/context/constitution/default-agents.md +11 -10
- package/dist/harness/context/default-context-engine.d.ts +34 -4
- package/dist/harness/context/default-context-engine.js +198 -53
- package/dist/harness/context/hybrid-compressor.js +6 -0
- package/dist/harness/context/layer-types.d.ts +36 -0
- package/dist/harness/context/layer-types.js +38 -0
- package/dist/harness/context/llm-summarizer.d.ts +2 -8
- package/dist/harness/context/llm-summarizer.js +69 -91
- package/dist/harness/context/message-selector.js +4 -3
- package/dist/harness/context/root-instructions.js +1 -1
- package/dist/harness/context/summarize.d.ts +2 -0
- package/dist/harness/context/summarize.js +7 -2
- package/dist/harness/context/system-prompt-assembler.js +10 -4
- package/dist/harness/context/tool-result-aging.js +2 -2
- package/dist/harness/context/truncate-compressor.js +7 -0
- package/dist/harness/context/turn-envelope.d.ts +4 -3
- package/dist/harness/context/turn-envelope.js +4 -3
- package/dist/harness/context/types.d.ts +33 -1
- package/dist/harness/extension/execution-environment/dangerous-commands.d.ts +28 -0
- package/dist/harness/extension/execution-environment/dangerous-commands.js +129 -0
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +133 -4
- package/dist/harness/extension/execution-environment/effect-policy.js +263 -14
- package/dist/harness/extension/execution-environment/index.d.ts +4 -2
- package/dist/harness/extension/execution-environment/index.js +2 -1
- package/dist/harness/extension/execution-environment/isolation.js +5 -1
- package/dist/harness/extension/execution-environment/kill-switch.d.ts +34 -0
- package/dist/harness/extension/execution-environment/kill-switch.js +46 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +200 -0
- package/dist/harness/extension/execution-environment/ops-audit.js +338 -0
- package/dist/harness/extension/execution-environment/privileged-exec.d.ts +158 -0
- package/dist/harness/extension/execution-environment/privileged-exec.js +418 -0
- package/dist/harness/extension/execution-environment/process-info.d.ts +180 -0
- package/dist/harness/extension/execution-environment/process-info.js +466 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +7 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +9 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +109 -0
- package/dist/harness/extension/execution-environment/sandbox.js +264 -29
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +1 -1
- package/dist/harness/extension/execution-environment/tool-capabilities.js +6 -0
- package/dist/harness/extension/execution-environment/types.d.ts +19 -0
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +50 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +4 -5
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +5 -15
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +53 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +10 -17
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +8 -8
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +9 -100
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/privileged-tool.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/privileged-tool.js +350 -0
- package/dist/harness/extension/plugin-ecosystem/tools/process-tools.d.ts +30 -0
- package/dist/harness/extension/plugin-ecosystem/tools/process-tools.js +137 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +54 -4
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +42 -16
- package/dist/harness/governance/security/temp-path.d.ts +9 -0
- package/dist/harness/governance/security/temp-path.js +13 -2
- package/dist/harness/governance/session-acl/seed-roles.js +14 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.js +3 -0
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- package/dist/harness/knowledge/fts.js +1 -2
- package/dist/harness/knowledge/grounding.js +5 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +180 -48
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +150 -150
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- package/dist/harness/knowledge/purge.js +4 -1
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/sqlite/keyword-search.d.ts +1 -0
- package/dist/harness/memory/sqlite/keyword-search.js +4 -3
- package/dist/harness/observability/observer/hub.js +38 -1
- package/dist/harness/observability/observer/run-snapshot.js +1 -0
- package/dist/harness/observability/observer/types.d.ts +27 -0
- package/dist/harness/run/agent/agent.d.ts +7 -0
- package/dist/harness/run/agent/agent.js +23 -1
- package/dist/harness/run/reliability/fallback-provider.d.ts +117 -5
- package/dist/harness/run/reliability/fallback-provider.js +262 -22
- package/dist/harness/run/reliability/harness-events.d.ts +24 -1
- package/dist/harness/run/reliability/model-error-policy.d.ts +32 -0
- package/dist/harness/run/reliability/model-error-policy.js +42 -0
- package/dist/harness/run/reliability/provider-wrapper.js +29 -2
- package/dist/harness/run/reliability/refusal-guard.d.ts +20 -0
- package/dist/harness/run/reliability/refusal-guard.js +102 -0
- package/dist/harness/run/reliability/run-agent.js +231 -33
- package/dist/harness/run/run-guard/default-run-guard.js +1 -1
- package/dist/harness/run/run-scope.d.ts +31 -0
- package/dist/harness/run/runner.d.ts +132 -2
- package/dist/harness/run/runner.js +679 -60
- package/dist/harness/session/attachments/llm-intent.js +2 -1
- package/dist/harness/session/history/port.js +15 -5
- package/dist/harness/session/in-memory-store.d.ts +5 -0
- package/dist/harness/session/in-memory-store.js +33 -2
- package/dist/harness/session/tasks/render.d.ts +4 -1
- package/dist/harness/session/tasks/render.js +10 -7
- package/dist/harness/session/title.js +25 -9
- package/dist/harness/shared/events/agent-event-map.d.ts +92 -0
- package/dist/harness/shared/events/agent-event-map.js +7 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4 -3
- package/dist/integration/agent-runtime/channel-message-source.js +19 -1
- package/dist/integration/index.d.ts +2 -0
- package/dist/integration/index.js +1 -0
- package/dist/integration/observability/loop-watchdog.d.ts +56 -0
- package/dist/integration/observability/loop-watchdog.js +177 -0
- package/dist/integration/observability/metrics.d.ts +3 -0
- package/dist/integration/observability/metrics.js +18 -7
- package/dist/integration/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- package/dist/integration/providers/anthropic.d.ts +23 -0
- package/dist/integration/providers/anthropic.js +97 -12
- package/dist/integration/providers/fetch-timeout.d.ts +42 -0
- package/dist/integration/providers/fetch-timeout.js +51 -0
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -11
- package/dist/integration/providers/provider-diagnostics.d.ts +80 -0
- package/dist/integration/providers/provider-diagnostics.js +89 -0
- package/dist/integration/providers/timeout-coherence.d.ts +52 -0
- package/dist/integration/providers/timeout-coherence.js +68 -0
- package/dist/integration/providers/wire-dump.d.ts +62 -0
- package/dist/integration/providers/wire-dump.js +111 -2
- package/dist/integration/storage/jsonl.d.ts +19 -1
- package/dist/integration/storage/jsonl.js +100 -4
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +1 -1
- package/dist/subsystems/memory-steward/backfill/handler.js +1 -1
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/formation/handler.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置脱敏 — WebUI 回显形态(arch/config-hot-reload.md §0)
|
|
3
|
+
*
|
|
4
|
+
* apiKey 只回显「是否已配置 + 引用形态」,绝不回显明文值。
|
|
5
|
+
* `${VAR}` 形态给变量名;明文形态只标记 `literal`。
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
const ENV_REF_PATTERN = /^\$\{(\w+)(?::-.*?)?\}$/;
|
|
10
|
+
/**
|
|
11
|
+
* 把 apiKey 字符串脱敏为 `RedactedSecret`
|
|
12
|
+
*
|
|
13
|
+
* @param value - 原始 apiKey(可能为 `${VAR}` 形态、明文或空)
|
|
14
|
+
* @returns 脱敏视图(不含明文)
|
|
15
|
+
*/
|
|
16
|
+
export function redactSecret(value) {
|
|
17
|
+
if (!value)
|
|
18
|
+
return { configured: false, ref: null };
|
|
19
|
+
const m = ENV_REF_PATTERN.exec(value);
|
|
20
|
+
if (m)
|
|
21
|
+
return { configured: true, ref: m[1] };
|
|
22
|
+
return { configured: true, ref: 'literal' };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 脱敏单个 provider 配置
|
|
26
|
+
*
|
|
27
|
+
* @param name - provider 名
|
|
28
|
+
* @param pc - provider 配置(已展开 `${ENV}` 的运行时形态或 raw 形态均可)
|
|
29
|
+
* @returns 脱敏视图
|
|
30
|
+
*/
|
|
31
|
+
export function redactProvider(name, pc) {
|
|
32
|
+
const out = {
|
|
33
|
+
name,
|
|
34
|
+
baseUrl: typeof pc.baseUrl === 'string' ? pc.baseUrl : '',
|
|
35
|
+
api: typeof pc.api === 'string' ? pc.api : '',
|
|
36
|
+
models: Array.isArray(pc.models) ? pc.models : [],
|
|
37
|
+
apiKey: redactSecret(typeof pc.apiKey === 'string' ? pc.apiKey : undefined),
|
|
38
|
+
};
|
|
39
|
+
if (typeof pc.timeoutSeconds === 'number')
|
|
40
|
+
out.timeoutSeconds = pc.timeoutSeconds;
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
@@ -53,14 +53,56 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
53
53
|
maxBlobBytes: z.ZodOptional<z.ZodNumber>;
|
|
54
54
|
}, z.core.$strip>>;
|
|
55
55
|
shellJournal: z.ZodOptional<z.ZodEnum<{
|
|
56
|
-
snapshot: "snapshot";
|
|
57
56
|
off: "off";
|
|
57
|
+
snapshot: "snapshot";
|
|
58
58
|
}>>;
|
|
59
59
|
shellJournalLimit: z.ZodOptional<z.ZodObject<{
|
|
60
60
|
maxFiles: z.ZodOptional<z.ZodNumber>;
|
|
61
61
|
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
62
62
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
63
63
|
}, z.core.$strip>>;
|
|
64
|
+
jail: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
none: "none";
|
|
66
|
+
auto: "auto";
|
|
67
|
+
require: "require";
|
|
68
|
+
}>>;
|
|
69
|
+
onJailUnavailable: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
refuse: "refuse";
|
|
71
|
+
degrade: "degrade";
|
|
72
|
+
}>>;
|
|
73
|
+
privilegedAck: z.ZodOptional<z.ZodString>;
|
|
74
|
+
escalation: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
76
|
+
full: "full";
|
|
77
|
+
none: "none";
|
|
78
|
+
allowlist: "allowlist";
|
|
79
|
+
}>>;
|
|
80
|
+
via: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
sudo: "sudo";
|
|
82
|
+
direct: "direct";
|
|
83
|
+
}>>;
|
|
84
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
85
|
+
id: z.ZodOptional<z.ZodString>;
|
|
86
|
+
cmd: z.ZodString;
|
|
87
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$strict>>>;
|
|
91
|
+
}, z.core.$strict>>;
|
|
92
|
+
dangerousCommands: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
94
|
+
deny: "deny";
|
|
95
|
+
confirm: "confirm";
|
|
96
|
+
off: "off";
|
|
97
|
+
}>>;
|
|
98
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
}, z.core.$strict>>;
|
|
100
|
+
opsAudit: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
off: "off";
|
|
102
|
+
on: "on";
|
|
103
|
+
}>>;
|
|
104
|
+
opsAuditPath: z.ZodOptional<z.ZodString>;
|
|
105
|
+
opsAuditExportPath: z.ZodOptional<z.ZodString>;
|
|
64
106
|
}, z.core.$strip>>;
|
|
65
107
|
persona: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
66
108
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -4,18 +4,25 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { InlinePersonaSchema, ModelConfigSchema, NetworkHostSchema, SessionRightsSchema, ToolPolicySchema, } from './shared.js';
|
|
7
|
+
import { ConfigPathSchema, InlinePersonaSchema, ModelConfigSchema, NetworkHostSchema, SessionRightsSchema, ToolPolicySchema, } from './shared.js';
|
|
8
8
|
import { EffectPolicyConfigSchema } from './governance.js';
|
|
9
9
|
export const AgentConfigSchema = z.object({
|
|
10
10
|
id: z.string({ error: 'Agent must have an id' }).min(1, 'Agent id cannot be empty'),
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* agent 文件态 home(persona / skills / agent.db 基线)。与 `workspace` 同规:
|
|
13
|
+
* 绝对路径或 `~` 形态——相对路径加载即拒,杜绝隐式 resolve 到进程 cwd。
|
|
14
|
+
*/
|
|
15
|
+
home: ConfigPathSchema.optional(),
|
|
16
|
+
/** 工具基路径:绝对路径或 ~ 形态(相对路径加载即拒,杜绝隐式 resolve 到进程 cwd) */
|
|
17
|
+
workspace: ConfigPathSchema.optional(),
|
|
13
18
|
/** ToolEffectPolicy 运行模式(P3);与 tools allow/deny 无关 */
|
|
14
19
|
effectPolicy: EffectPolicyConfigSchema.optional(),
|
|
15
|
-
persona
|
|
20
|
+
/** 文件式 persona 目录,或内联 systemPrompt。legacy string 形态等价 home(同路径契约) */
|
|
21
|
+
persona: z.union([ConfigPathSchema, InlinePersonaSchema]).optional(),
|
|
16
22
|
model: z.union([z.string().min(1), ModelConfigSchema]),
|
|
17
23
|
tools: ToolPolicySchema.optional(),
|
|
18
|
-
|
|
24
|
+
/** Skill 目录(缺省 `home/skills`):与 `workspace`/`home` 同规(绝对或 `~` 形态,拒相对) */
|
|
25
|
+
skillDirectory: ConfigPathSchema.optional(),
|
|
19
26
|
skills: z.array(z.string()).optional(),
|
|
20
27
|
channelBindings: z.record(z.string(), z.string()).optional(),
|
|
21
28
|
/** Session ACL 天花板(E6 L1);与角色 max / 绑定取交集 */
|
|
@@ -20,6 +20,11 @@ export declare const ContextEngineConfigSchema: z.ZodObject<{
|
|
|
20
20
|
}>>;
|
|
21
21
|
protectFirstN: z.ZodOptional<z.ZodNumber>;
|
|
22
22
|
protectLastN: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
summaryBudget: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
ratioPct: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
minTokens: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
23
28
|
proactiveCompactRatio: z.ZodOptional<z.ZodNumber>;
|
|
24
29
|
proactiveCooldownMs: z.ZodOptional<z.ZodNumber>;
|
|
25
30
|
historyAging: z.ZodOptional<z.ZodObject<{
|
|
@@ -88,6 +93,7 @@ export declare const SummaryConfigSchema: z.ZodObject<{
|
|
|
88
93
|
kindFromSource: z.ZodOptional<z.ZodBoolean>;
|
|
89
94
|
informationalKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
90
95
|
auto: "auto";
|
|
96
|
+
opaque: "opaque";
|
|
91
97
|
web_page: "web_page";
|
|
92
98
|
file_text: "file_text";
|
|
93
99
|
document: "document";
|
|
@@ -95,7 +101,6 @@ export declare const SummaryConfigSchema: z.ZodObject<{
|
|
|
95
101
|
api_json: "api_json";
|
|
96
102
|
log: "log";
|
|
97
103
|
conversation: "conversation";
|
|
98
|
-
opaque: "opaque";
|
|
99
104
|
}>>>;
|
|
100
105
|
onFail: z.ZodOptional<z.ZodEnum<{
|
|
101
106
|
error: "error";
|
|
@@ -172,8 +177,8 @@ export declare const DocumentsConfigSchema: z.ZodObject<{
|
|
|
172
177
|
export declare const ConstitutionConfigSchema: z.ZodObject<{
|
|
173
178
|
mode: z.ZodEnum<{
|
|
174
179
|
off: "off";
|
|
175
|
-
custom: "custom";
|
|
176
180
|
product: "product";
|
|
181
|
+
custom: "custom";
|
|
177
182
|
}>;
|
|
178
183
|
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
179
184
|
}, z.core.$strip>;
|
|
@@ -29,6 +29,14 @@ export const ContextEngineConfigSchema = z.object({
|
|
|
29
29
|
type: z.enum(['default', 'custom']).optional(),
|
|
30
30
|
protectFirstN: z.number().min(0).optional(),
|
|
31
31
|
protectLastN: z.number().min(0).optional(),
|
|
32
|
+
/** 摘要软目标预算(P1c 缺省 clamp(2%, 2k, 8k)) */
|
|
33
|
+
summaryBudget: z
|
|
34
|
+
.object({
|
|
35
|
+
ratioPct: z.number().positive().optional(),
|
|
36
|
+
minTokens: z.number().positive().optional(),
|
|
37
|
+
maxTokens: z.number().positive().optional(),
|
|
38
|
+
})
|
|
39
|
+
.optional(),
|
|
32
40
|
/** 0 = 禁新的路径 A 压缩(不只禁 LLM;不丢粘滞视图);见 ContextEngineConfig JSDoc */
|
|
33
41
|
proactiveCompactRatio: z.number().min(0).max(1).optional(),
|
|
34
42
|
proactiveCooldownMs: z.number().min(0).optional(),
|
|
@@ -60,14 +60,56 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
60
60
|
maxBlobBytes: z.ZodOptional<z.ZodNumber>;
|
|
61
61
|
}, z.core.$strip>>;
|
|
62
62
|
shellJournal: z.ZodOptional<z.ZodEnum<{
|
|
63
|
-
snapshot: "snapshot";
|
|
64
63
|
off: "off";
|
|
64
|
+
snapshot: "snapshot";
|
|
65
65
|
}>>;
|
|
66
66
|
shellJournalLimit: z.ZodOptional<z.ZodObject<{
|
|
67
67
|
maxFiles: z.ZodOptional<z.ZodNumber>;
|
|
68
68
|
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
69
69
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
70
70
|
}, z.core.$strip>>;
|
|
71
|
+
jail: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
none: "none";
|
|
73
|
+
auto: "auto";
|
|
74
|
+
require: "require";
|
|
75
|
+
}>>;
|
|
76
|
+
onJailUnavailable: z.ZodOptional<z.ZodEnum<{
|
|
77
|
+
refuse: "refuse";
|
|
78
|
+
degrade: "degrade";
|
|
79
|
+
}>>;
|
|
80
|
+
privilegedAck: z.ZodOptional<z.ZodString>;
|
|
81
|
+
escalation: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
full: "full";
|
|
84
|
+
none: "none";
|
|
85
|
+
allowlist: "allowlist";
|
|
86
|
+
}>>;
|
|
87
|
+
via: z.ZodOptional<z.ZodEnum<{
|
|
88
|
+
sudo: "sudo";
|
|
89
|
+
direct: "direct";
|
|
90
|
+
}>>;
|
|
91
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
92
|
+
id: z.ZodOptional<z.ZodString>;
|
|
93
|
+
cmd: z.ZodString;
|
|
94
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>>>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
dangerousCommands: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
deny: "deny";
|
|
102
|
+
confirm: "confirm";
|
|
103
|
+
off: "off";
|
|
104
|
+
}>>;
|
|
105
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strict>>;
|
|
107
|
+
opsAudit: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
off: "off";
|
|
109
|
+
on: "on";
|
|
110
|
+
}>>;
|
|
111
|
+
opsAuditPath: z.ZodOptional<z.ZodString>;
|
|
112
|
+
opsAuditExportPath: z.ZodOptional<z.ZodString>;
|
|
71
113
|
}, z.core.$strip>>;
|
|
72
114
|
persona: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
73
115
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -157,7 +199,7 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
157
199
|
}>>;
|
|
158
200
|
providers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
159
201
|
baseUrl: z.ZodString;
|
|
160
|
-
apiKey: z.ZodString
|
|
202
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
161
203
|
api: z.ZodEnum<{
|
|
162
204
|
"openai-completions": "openai-completions";
|
|
163
205
|
"anthropic-messages": "anthropic-messages";
|
|
@@ -174,6 +216,7 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
174
216
|
}>>>;
|
|
175
217
|
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
176
218
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
219
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
177
220
|
}, z.core.$strip>>;
|
|
178
221
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
179
222
|
}, z.core.$strip>>;
|
|
@@ -185,9 +228,9 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
185
228
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
186
229
|
type: z.ZodOptional<z.ZodEnum<{
|
|
187
230
|
openai: "openai";
|
|
231
|
+
http: "http";
|
|
188
232
|
custom: "custom";
|
|
189
233
|
ollama: "ollama";
|
|
190
|
-
http: "http";
|
|
191
234
|
}>>;
|
|
192
235
|
provider: z.ZodOptional<z.ZodString>;
|
|
193
236
|
model: z.ZodString;
|
|
@@ -269,6 +312,9 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
269
312
|
modelCall: z.ZodOptional<z.ZodObject<{
|
|
270
313
|
idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
271
314
|
absoluteTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
315
|
+
fallbackAttemptTtftMs: z.ZodOptional<z.ZodNumber>;
|
|
316
|
+
fallbackDegradeTtlMs: z.ZodOptional<z.ZodNumber>;
|
|
317
|
+
fallbackChatAttemptMs: z.ZodOptional<z.ZodNumber>;
|
|
272
318
|
}, z.core.$strip>>;
|
|
273
319
|
agentRuntime: z.ZodOptional<z.ZodObject<{
|
|
274
320
|
coalesceWindowMs: z.ZodOptional<z.ZodNumber>;
|
|
@@ -301,6 +347,11 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
301
347
|
}>>;
|
|
302
348
|
protectFirstN: z.ZodOptional<z.ZodNumber>;
|
|
303
349
|
protectLastN: z.ZodOptional<z.ZodNumber>;
|
|
350
|
+
summaryBudget: z.ZodOptional<z.ZodObject<{
|
|
351
|
+
ratioPct: z.ZodOptional<z.ZodNumber>;
|
|
352
|
+
minTokens: z.ZodOptional<z.ZodNumber>;
|
|
353
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
354
|
+
}, z.core.$strip>>;
|
|
304
355
|
proactiveCompactRatio: z.ZodOptional<z.ZodNumber>;
|
|
305
356
|
proactiveCooldownMs: z.ZodOptional<z.ZodNumber>;
|
|
306
357
|
historyAging: z.ZodOptional<z.ZodObject<{
|
|
@@ -369,6 +420,7 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
369
420
|
kindFromSource: z.ZodOptional<z.ZodBoolean>;
|
|
370
421
|
informationalKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
371
422
|
auto: "auto";
|
|
423
|
+
opaque: "opaque";
|
|
372
424
|
web_page: "web_page";
|
|
373
425
|
file_text: "file_text";
|
|
374
426
|
document: "document";
|
|
@@ -376,7 +428,6 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
376
428
|
api_json: "api_json";
|
|
377
429
|
log: "log";
|
|
378
430
|
conversation: "conversation";
|
|
379
|
-
opaque: "opaque";
|
|
380
431
|
}>>>;
|
|
381
432
|
onFail: z.ZodOptional<z.ZodEnum<{
|
|
382
433
|
error: "error";
|
|
@@ -494,8 +545,8 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
494
545
|
hybridKeyword: z.ZodOptional<z.ZodBoolean>;
|
|
495
546
|
embedSecretPolicy: z.ZodOptional<z.ZodEnum<{
|
|
496
547
|
allow: "allow";
|
|
497
|
-
redact: "redact";
|
|
498
548
|
skip: "skip";
|
|
549
|
+
redact: "redact";
|
|
499
550
|
}>>;
|
|
500
551
|
phaseA: z.ZodOptional<z.ZodObject<{
|
|
501
552
|
concurrency: z.ZodOptional<z.ZodNumber>;
|
|
@@ -578,8 +629,8 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
578
629
|
constitution: z.ZodOptional<z.ZodObject<{
|
|
579
630
|
mode: z.ZodEnum<{
|
|
580
631
|
off: "off";
|
|
581
|
-
custom: "custom";
|
|
582
632
|
product: "product";
|
|
633
|
+
custom: "custom";
|
|
583
634
|
}>;
|
|
584
635
|
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
585
636
|
}, z.core.$strip>>;
|
|
@@ -605,8 +656,8 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
605
656
|
constitution: z.ZodOptional<z.ZodObject<{
|
|
606
657
|
mode: z.ZodEnum<{
|
|
607
658
|
off: "off";
|
|
608
|
-
custom: "custom";
|
|
609
659
|
product: "product";
|
|
660
|
+
custom: "custom";
|
|
610
661
|
}>;
|
|
611
662
|
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
612
663
|
}, z.core.$strip>>;
|
|
@@ -845,14 +896,56 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
845
896
|
maxBlobBytes: z.ZodOptional<z.ZodNumber>;
|
|
846
897
|
}, z.core.$strip>>;
|
|
847
898
|
shellJournal: z.ZodOptional<z.ZodEnum<{
|
|
848
|
-
snapshot: "snapshot";
|
|
849
899
|
off: "off";
|
|
900
|
+
snapshot: "snapshot";
|
|
850
901
|
}>>;
|
|
851
902
|
shellJournalLimit: z.ZodOptional<z.ZodObject<{
|
|
852
903
|
maxFiles: z.ZodOptional<z.ZodNumber>;
|
|
853
904
|
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
854
905
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
855
906
|
}, z.core.$strip>>;
|
|
907
|
+
jail: z.ZodOptional<z.ZodEnum<{
|
|
908
|
+
none: "none";
|
|
909
|
+
auto: "auto";
|
|
910
|
+
require: "require";
|
|
911
|
+
}>>;
|
|
912
|
+
onJailUnavailable: z.ZodOptional<z.ZodEnum<{
|
|
913
|
+
refuse: "refuse";
|
|
914
|
+
degrade: "degrade";
|
|
915
|
+
}>>;
|
|
916
|
+
privilegedAck: z.ZodOptional<z.ZodString>;
|
|
917
|
+
escalation: z.ZodOptional<z.ZodObject<{
|
|
918
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
919
|
+
full: "full";
|
|
920
|
+
none: "none";
|
|
921
|
+
allowlist: "allowlist";
|
|
922
|
+
}>>;
|
|
923
|
+
via: z.ZodOptional<z.ZodEnum<{
|
|
924
|
+
sudo: "sudo";
|
|
925
|
+
direct: "direct";
|
|
926
|
+
}>>;
|
|
927
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
928
|
+
id: z.ZodOptional<z.ZodString>;
|
|
929
|
+
cmd: z.ZodString;
|
|
930
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
931
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
932
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
933
|
+
}, z.core.$strict>>>;
|
|
934
|
+
}, z.core.$strict>>;
|
|
935
|
+
dangerousCommands: z.ZodOptional<z.ZodObject<{
|
|
936
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
937
|
+
deny: "deny";
|
|
938
|
+
confirm: "confirm";
|
|
939
|
+
off: "off";
|
|
940
|
+
}>>;
|
|
941
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
942
|
+
}, z.core.$strict>>;
|
|
943
|
+
opsAudit: z.ZodOptional<z.ZodEnum<{
|
|
944
|
+
off: "off";
|
|
945
|
+
on: "on";
|
|
946
|
+
}>>;
|
|
947
|
+
opsAuditPath: z.ZodOptional<z.ZodString>;
|
|
948
|
+
opsAuditExportPath: z.ZodOptional<z.ZodString>;
|
|
856
949
|
}, z.core.$strip>>;
|
|
857
950
|
sessionAcl: z.ZodOptional<z.ZodObject<{
|
|
858
951
|
roles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -915,6 +1008,15 @@ export declare const engineConfigSchema: z.ZodObject<{
|
|
|
915
1008
|
dir: z.ZodOptional<z.ZodString>;
|
|
916
1009
|
maxCallsPerSession: z.ZodOptional<z.ZodNumber>;
|
|
917
1010
|
maxBodyBytes: z.ZodOptional<z.ZodNumber>;
|
|
1011
|
+
maxResponseChars: z.ZodOptional<z.ZodNumber>;
|
|
1012
|
+
}, z.core.$strip>>;
|
|
1013
|
+
loopWatchdog: z.ZodOptional<z.ZodObject<{
|
|
1014
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1015
|
+
intervalMs: z.ZodOptional<z.ZodNumber>;
|
|
1016
|
+
stallThresholdMs: z.ZodOptional<z.ZodNumber>;
|
|
1017
|
+
reportFile: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
captureSample: z.ZodOptional<z.ZodBoolean>;
|
|
1019
|
+
footprintThresholdMb: z.ZodOptional<z.ZodNumber>;
|
|
918
1020
|
}, z.core.$strip>>;
|
|
919
1021
|
}, z.core.$strip>>;
|
|
920
1022
|
observer: z.ZodOptional<z.ZodObject<{
|
|
@@ -97,14 +97,56 @@ export declare const EffectPolicyConfigSchema: z.ZodObject<{
|
|
|
97
97
|
maxBlobBytes: z.ZodOptional<z.ZodNumber>;
|
|
98
98
|
}, z.core.$strip>>;
|
|
99
99
|
shellJournal: z.ZodOptional<z.ZodEnum<{
|
|
100
|
-
snapshot: "snapshot";
|
|
101
100
|
off: "off";
|
|
101
|
+
snapshot: "snapshot";
|
|
102
102
|
}>>;
|
|
103
103
|
shellJournalLimit: z.ZodOptional<z.ZodObject<{
|
|
104
104
|
maxFiles: z.ZodOptional<z.ZodNumber>;
|
|
105
105
|
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
106
106
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
107
107
|
}, z.core.$strip>>;
|
|
108
|
+
jail: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
none: "none";
|
|
110
|
+
auto: "auto";
|
|
111
|
+
require: "require";
|
|
112
|
+
}>>;
|
|
113
|
+
onJailUnavailable: z.ZodOptional<z.ZodEnum<{
|
|
114
|
+
refuse: "refuse";
|
|
115
|
+
degrade: "degrade";
|
|
116
|
+
}>>;
|
|
117
|
+
privilegedAck: z.ZodOptional<z.ZodString>;
|
|
118
|
+
escalation: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
full: "full";
|
|
121
|
+
none: "none";
|
|
122
|
+
allowlist: "allowlist";
|
|
123
|
+
}>>;
|
|
124
|
+
via: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
sudo: "sudo";
|
|
126
|
+
direct: "direct";
|
|
127
|
+
}>>;
|
|
128
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodOptional<z.ZodString>;
|
|
130
|
+
cmd: z.ZodString;
|
|
131
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strict>>>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
dangerousCommands: z.ZodOptional<z.ZodObject<{
|
|
137
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
138
|
+
deny: "deny";
|
|
139
|
+
confirm: "confirm";
|
|
140
|
+
off: "off";
|
|
141
|
+
}>>;
|
|
142
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strict>>;
|
|
144
|
+
opsAudit: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
off: "off";
|
|
146
|
+
on: "on";
|
|
147
|
+
}>>;
|
|
148
|
+
opsAuditPath: z.ZodOptional<z.ZodString>;
|
|
149
|
+
opsAuditExportPath: z.ZodOptional<z.ZodString>;
|
|
108
150
|
}, z.core.$strip>;
|
|
109
151
|
export declare const ToolIsolationConfigSchema: z.ZodEnum<{
|
|
110
152
|
none: "none";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { SessionRightsSchema } from './shared.js';
|
|
7
|
+
import { ConfigPathSchema, SessionRightsSchema } from './shared.js';
|
|
8
8
|
export const SecurityConfigSchema = z.object({
|
|
9
9
|
enforce: z.enum(['block', 'audit']).optional(),
|
|
10
10
|
injectionSensitivity: z.enum(['low', 'medium', 'high']).optional(),
|
|
@@ -56,7 +56,8 @@ export const EffectPolicyConfigSchema = z.object({
|
|
|
56
56
|
* degrade 降 effectiveMode + toolSurface=reduced + securityDegraded。
|
|
57
57
|
*/
|
|
58
58
|
untrustedAdmission: z.enum(['refuse', 'degrade']).optional(),
|
|
59
|
-
|
|
59
|
+
/** 额外事务 root(绝对路径或 ~ 形态);并入 allowRoots */
|
|
60
|
+
transactionRoots: z.array(ConfigPathSchema).optional(),
|
|
60
61
|
pathContainment: z.enum(['strict', 'soft', 'none']).optional(),
|
|
61
62
|
shellEscape: z.enum(['deny', 'confirm', 'allow']).optional(),
|
|
62
63
|
processLimits: z.boolean().optional(),
|
|
@@ -86,6 +87,163 @@ export const EffectPolicyConfigSchema = z.object({
|
|
|
86
87
|
maxFileSize: z.number().int().nonnegative().optional(),
|
|
87
88
|
})
|
|
88
89
|
.optional(),
|
|
90
|
+
/**
|
|
91
|
+
* 进程牢笼意图(ops P0):auto(缺省,按模式派生,缺笼如实降级 + 告警)|
|
|
92
|
+
* require(拿不到即拒)| none(显式无笼,需 privilegedAck)。
|
|
93
|
+
*/
|
|
94
|
+
jail: z.enum(['auto', 'require', 'none']).optional(),
|
|
95
|
+
/** jail 意图落空时:refuse 拒绝执行 | degrade(缺省)记 securityDegraded + 告警 */
|
|
96
|
+
onJailUnavailable: z.enum(['refuse', 'degrade']).optional(),
|
|
97
|
+
/** `jail: "none"` 时必填的显式表态(授权 ≠ 降级;§8.1) */
|
|
98
|
+
privilegedAck: z.string().min(1).optional(),
|
|
99
|
+
/** 提权策略(ops P3/P4):`allowlist` 按 cmd+args 全等放行;`full` 全量档(§4.1 严格前提) */
|
|
100
|
+
escalation: z
|
|
101
|
+
.object({
|
|
102
|
+
policy: z.enum(['none', 'allowlist', 'full']).optional(),
|
|
103
|
+
via: z.enum(['sudo', 'direct']).optional(),
|
|
104
|
+
allow: z
|
|
105
|
+
.array(
|
|
106
|
+
// strict:未知子键拒绝启动(`confrim` 拼错 = 确认闸静默消失,§6.1 教训)
|
|
107
|
+
z
|
|
108
|
+
.object({
|
|
109
|
+
id: z.string().min(1).optional(),
|
|
110
|
+
cmd: z.string().min(1),
|
|
111
|
+
args: z.array(z.string()).optional(),
|
|
112
|
+
confirm: z.boolean().optional(),
|
|
113
|
+
cwd: z.string().min(1).optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict())
|
|
116
|
+
.optional(),
|
|
117
|
+
})
|
|
118
|
+
.strict()
|
|
119
|
+
.optional(),
|
|
120
|
+
/**
|
|
121
|
+
* 危险命令减速带(§6:只拦事故不拦攻击)。命中保守分类表的 argv:
|
|
122
|
+
* `confirm`(缺省)走 HitlDecision 确认 | `deny` 直接拒绝 | `off` 关闭分类。
|
|
123
|
+
* `timeoutMs` 确认超时(超时一律 deny,outcome 不可配);缺省 120000。
|
|
124
|
+
*/
|
|
125
|
+
dangerousCommands: z
|
|
126
|
+
.object({
|
|
127
|
+
policy: z.enum(['confirm', 'deny', 'off']).optional(),
|
|
128
|
+
timeoutMs: z.number().int().positive().optional(),
|
|
129
|
+
})
|
|
130
|
+
.strict()
|
|
131
|
+
.optional(),
|
|
132
|
+
/** ops 审计账本开关(安全字段:重启生效 + 宿主署名);缺省 `on` */
|
|
133
|
+
opsAudit: z.enum(['on', 'off']).optional(),
|
|
134
|
+
/** ops 审计账本路径(缺省 `<OCTOPI_HOME>/audit/ops.<agentId>.jsonl`) */
|
|
135
|
+
opsAuditPath: z.string().min(1).optional(),
|
|
136
|
+
/**
|
|
137
|
+
* 审计外送收口路径(P5 原则 8 唯一不可抵赖档);缺省不外送。
|
|
138
|
+
* 必须放在 agent 可写面之外(放 `~/.octopi` 内等于没外送)。
|
|
139
|
+
*/
|
|
140
|
+
opsAuditExportPath: z.string().min(1).optional(),
|
|
141
|
+
}).superRefine((v, ctx) => {
|
|
142
|
+
// 配置矛盾 fail-closed(§4.1):拒绝启动,不做静默取舍
|
|
143
|
+
if (v.jail === 'none') {
|
|
144
|
+
if (!v.privilegedAck?.trim()) {
|
|
145
|
+
ctx.addIssue({
|
|
146
|
+
code: z.ZodIssueCode.custom,
|
|
147
|
+
path: ['privilegedAck'],
|
|
148
|
+
message: 'jail=none requires privilegedAck (explicit unjailed choice)',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (v.mode === 'untrusted') {
|
|
152
|
+
ctx.addIssue({
|
|
153
|
+
code: z.ZodIssueCode.custom,
|
|
154
|
+
path: ['jail'],
|
|
155
|
+
message: 'jail=none cannot combine with mode=untrusted (untrusted promises a jail)',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (v.jail === 'none' && v.onJailUnavailable === 'refuse') {
|
|
160
|
+
ctx.addIssue({
|
|
161
|
+
code: z.ZodIssueCode.custom,
|
|
162
|
+
path: ['onJailUnavailable'],
|
|
163
|
+
message: 'onJailUnavailable=refuse has no meaning under jail=none (remove it, or use jail=auto/require)',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// 注:effectPolicy.network 目前不在配置 schema(library-only);jail=none 下
|
|
167
|
+
// network=deny/allowlist 的拒绝在 resolveEffectiveEffectPolicy 守卫
|
|
168
|
+
if ((v.jail === 'require' || v.onJailUnavailable === 'refuse') &&
|
|
169
|
+
v.untrustedAdmission === 'degrade') {
|
|
170
|
+
ctx.addIssue({
|
|
171
|
+
code: z.ZodIssueCode.custom,
|
|
172
|
+
path: ['jail'],
|
|
173
|
+
message: 'jail=require/onJailUnavailable=refuse contradicts untrustedAdmission=degrade (same condition, opposite outcomes)',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// ops P3:提权规则纯形状矛盾(TOCTOU/启动探测在 resolve 与 daemon 层)
|
|
177
|
+
if (v.escalation && v.escalation.policy !== undefined && v.escalation.policy !== 'none' && v.mode === 'untrusted') {
|
|
178
|
+
ctx.addIssue({
|
|
179
|
+
code: z.ZodIssueCode.custom,
|
|
180
|
+
path: ['escalation', 'policy'],
|
|
181
|
+
message: 'escalation cannot combine with mode=untrusted (untrusted promises a jail)',
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (v.escalation?.policy === 'full') {
|
|
185
|
+
// §4.1 全量档:矛盾 fail-closed(v1 矛盾规则收缩到 full 档;allowlist 档不矛盾)
|
|
186
|
+
if (v.mode !== 'host') {
|
|
187
|
+
ctx.addIssue({
|
|
188
|
+
code: z.ZodIssueCode.custom,
|
|
189
|
+
path: ['escalation', 'policy'],
|
|
190
|
+
message: 'escalation.policy=full requires mode=host (explicitly designated machine)',
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (v.jail !== 'none') {
|
|
194
|
+
ctx.addIssue({
|
|
195
|
+
code: z.ZodIssueCode.custom,
|
|
196
|
+
path: ['escalation', 'policy'],
|
|
197
|
+
message: 'escalation.policy=full requires jail=none (whole-shell freedom contradicts a jailed shell)',
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (!v.privilegedAck?.trim()) {
|
|
201
|
+
ctx.addIssue({
|
|
202
|
+
code: z.ZodIssueCode.custom,
|
|
203
|
+
path: ['privilegedAck'],
|
|
204
|
+
message: 'escalation.policy=full requires privilegedAck (explicit privileged declaration)',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if ((v.escalation.allow ?? []).length > 0) {
|
|
208
|
+
// 死键 fail-loud:full 档没有 allowlist 面(§6.1 教训:静默忽略 = 误导配置读者)
|
|
209
|
+
ctx.addIssue({
|
|
210
|
+
code: z.ZodIssueCode.custom,
|
|
211
|
+
path: ['escalation', 'allow'],
|
|
212
|
+
message: 'escalation.policy=full takes no escalation.allow rules (remove them, or use policy=allowlist)',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (v.escalation?.policy === 'allowlist') {
|
|
217
|
+
const rules = v.escalation.allow ?? [];
|
|
218
|
+
if (rules.length === 0) {
|
|
219
|
+
ctx.addIssue({
|
|
220
|
+
code: z.ZodIssueCode.custom,
|
|
221
|
+
path: ['escalation', 'allow'],
|
|
222
|
+
message: 'escalation.policy=allowlist requires non-empty escalation.allow rules',
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
const seen = new Set();
|
|
226
|
+
for (const [i, rule] of rules.entries()) {
|
|
227
|
+
const absolute = rule.cmd.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(rule.cmd);
|
|
228
|
+
if (!absolute) {
|
|
229
|
+
ctx.addIssue({
|
|
230
|
+
code: z.ZodIssueCode.custom,
|
|
231
|
+
path: ['escalation', 'allow', i, 'cmd'],
|
|
232
|
+
message: 'escalation rule cmd must be an absolute path (PATH resolution = replaceable binary)',
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// 重复 (cmd,args):后写的 confirm:true 会被先命中者静默忽略 → 查重拒绝
|
|
236
|
+
const dupKey = JSON.stringify([rule.cmd, rule.args ?? []]);
|
|
237
|
+
if (seen.has(dupKey)) {
|
|
238
|
+
ctx.addIssue({
|
|
239
|
+
code: z.ZodIssueCode.custom,
|
|
240
|
+
path: ['escalation', 'allow', i],
|
|
241
|
+
message: 'duplicate escalation rule (cmd,args) — the first match wins silently',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
seen.add(dupKey);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
89
247
|
});
|
|
90
248
|
export const ToolIsolationConfigSchema = z.enum(['none', 'session-subdir', 'session-lock']);
|
|
91
249
|
/**
|