@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
|
@@ -123,9 +123,14 @@ export class HitlDecisionCache {
|
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Resolve through cache + host hook with in-flight de-dup.
|
|
126
|
-
* Concurrent callers for the same key share one `ask()
|
|
126
|
+
* Concurrent callers for the same key share one `ask()` and one outcome object
|
|
127
|
+
* (decision + timedOut + attribution — 合流者不得各自编造拒绝来源).
|
|
127
128
|
*/
|
|
128
129
|
resolve(options) {
|
|
130
|
+
return this.resolveOutcome(options).then((outcome) => outcome.allowed);
|
|
131
|
+
}
|
|
132
|
+
/** 同 {@link resolve},但回传完整结果(timedOut / 拒绝来源 / 归因),供错误面与审计口径一致。 */
|
|
133
|
+
resolveOutcome(options) {
|
|
129
134
|
const inflightKey = options.sessionId
|
|
130
135
|
? sessionKey(options.channel, options.sessionId, options.key)
|
|
131
136
|
: options.agentId
|
|
@@ -134,37 +139,48 @@ export class HitlDecisionCache {
|
|
|
134
139
|
const existing = this.inflight.get(inflightKey);
|
|
135
140
|
if (existing)
|
|
136
141
|
return existing;
|
|
137
|
-
const pending = this.
|
|
142
|
+
const pending = this.resolveOutcomeUncached(options).finally(() => {
|
|
138
143
|
this.inflight.delete(inflightKey);
|
|
139
144
|
});
|
|
140
145
|
this.inflight.set(inflightKey, pending);
|
|
141
146
|
return pending;
|
|
142
147
|
}
|
|
143
|
-
async
|
|
148
|
+
async resolveOutcomeUncached(options) {
|
|
144
149
|
const cached = this.get(options.channel, options.key, {
|
|
145
150
|
sessionId: options.sessionId,
|
|
146
151
|
agentId: options.agentId,
|
|
147
152
|
});
|
|
148
|
-
if (cached === 'approve')
|
|
149
|
-
return true;
|
|
150
|
-
|
|
153
|
+
if (cached === 'approve') {
|
|
154
|
+
return { allowed: true, decision: 'approve', timedOut: false };
|
|
155
|
+
}
|
|
156
|
+
let outcome;
|
|
151
157
|
try {
|
|
152
|
-
|
|
158
|
+
const raw = await options.ask();
|
|
159
|
+
const result = typeof raw === 'string' ? { decision: raw } : raw;
|
|
160
|
+
outcome = {
|
|
161
|
+
allowed: result.decision === 'approve' ||
|
|
162
|
+
result.decision === 'approve_session' ||
|
|
163
|
+
result.decision === 'approve_always',
|
|
164
|
+
decision: result.decision,
|
|
165
|
+
timedOut: result.timedOut ?? false,
|
|
166
|
+
...(result.denyReason !== undefined ? { denyReason: result.denyReason } : {}),
|
|
167
|
+
...(result.denyDetail !== undefined ? { denyDetail: result.denyDetail } : {}),
|
|
168
|
+
...(result.approver !== undefined ? { approver: result.approver } : {}),
|
|
169
|
+
...(result.channel !== undefined ? { channel: result.channel } : {}),
|
|
170
|
+
};
|
|
153
171
|
}
|
|
154
172
|
catch {
|
|
155
|
-
// 审批通道异常按拒绝处理(fail-safe
|
|
156
|
-
|
|
173
|
+
// 审批通道异常按拒绝处理(fail-safe);吞掉异常体只因「不放行」结论不变——
|
|
174
|
+
// 但来源如实标注 channel_error,异常绝不伪装成人工拒绝
|
|
175
|
+
outcome = { allowed: false, decision: 'deny', timedOut: false, denyReason: 'channel_error' };
|
|
157
176
|
}
|
|
158
|
-
if (
|
|
159
|
-
decision
|
|
160
|
-
decision === 'approve_always') {
|
|
161
|
-
this.remember(decision, options.channel, options.key, {
|
|
177
|
+
if (outcome.allowed) {
|
|
178
|
+
this.remember(outcome.decision, options.channel, options.key, {
|
|
162
179
|
sessionId: options.sessionId,
|
|
163
180
|
agentId: options.agentId,
|
|
164
181
|
});
|
|
165
|
-
return true;
|
|
166
182
|
}
|
|
167
|
-
return
|
|
183
|
+
return outcome;
|
|
168
184
|
}
|
|
169
185
|
}
|
|
170
186
|
/** Process-wide default cache (keys include sessionId / agentId). */
|
|
@@ -179,6 +195,16 @@ export const defaultHitlCache = new HitlDecisionCache();
|
|
|
179
195
|
* @returns true only when the call is approved (cached or live)
|
|
180
196
|
*/
|
|
181
197
|
export async function resolveHitlDecision(options) {
|
|
198
|
+
return (await resolveHitlOutcome(options)).allowed;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 同 {@link resolveHitlDecision},但回传完整结果(timedOut / 拒绝来源 / 归因)——
|
|
202
|
+
* 供调用方把错误面标注得与审计一致:超时 ≠ 人工拒绝 ≠ 通道故障,三者不得混为一谈。
|
|
203
|
+
*
|
|
204
|
+
* @param options - 同 resolveHitlDecision
|
|
205
|
+
* @returns 完整决策结果(同 key 并发合流共享同一对象)
|
|
206
|
+
*/
|
|
207
|
+
export async function resolveHitlOutcome(options) {
|
|
182
208
|
const cache = options.cache ?? defaultHitlCache;
|
|
183
|
-
return cache.
|
|
209
|
+
return cache.resolveOutcome(options);
|
|
184
210
|
}
|
|
@@ -30,6 +30,15 @@ export declare function ensureTrailingSep(p: string): string;
|
|
|
30
30
|
* Windows 风格路径大小写不敏感、分隔符归一为 `\`。
|
|
31
31
|
*/
|
|
32
32
|
export declare function startsWithPathPrefix(path: string, prefix: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 当前用户 home(用户目录推导的单一来源)
|
|
35
|
+
*
|
|
36
|
+
* 实现与测试共用,防两侧推导漂移:env 被清洗(HOME 缺失)时实现落 `homedir()`、
|
|
37
|
+
* 测试若走 `?? ''` 就会分叉(曾在 darwin 上把测试打挂)。
|
|
38
|
+
*
|
|
39
|
+
* @returns 用户 home 目录(原始分隔符风格)
|
|
40
|
+
*/
|
|
41
|
+
export declare function currentUserHome(): string;
|
|
33
42
|
/**
|
|
34
43
|
* 临时目录前缀清单
|
|
35
44
|
*
|
|
@@ -68,6 +68,18 @@ export function startsWithPathPrefix(path, prefix) {
|
|
|
68
68
|
return true;
|
|
69
69
|
return p.startsWith(b + '/');
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* 当前用户 home(用户目录推导的单一来源)
|
|
73
|
+
*
|
|
74
|
+
* 实现与测试共用,防两侧推导漂移:env 被清洗(HOME 缺失)时实现落 `homedir()`、
|
|
75
|
+
* 测试若走 `?? ''` 就会分叉(曾在 darwin 上把测试打挂)。
|
|
76
|
+
*
|
|
77
|
+
* @returns 用户 home 目录(原始分隔符风格)
|
|
78
|
+
*/
|
|
79
|
+
export function currentUserHome() {
|
|
80
|
+
// `||` 而非 `??`:HOME 为空串时视为未设置,回落 homedir()(旧实现同语义)
|
|
81
|
+
return process.env.USERPROFILE || process.env.HOME || homedir();
|
|
82
|
+
}
|
|
71
83
|
/**
|
|
72
84
|
* 临时目录前缀清单
|
|
73
85
|
*
|
|
@@ -101,8 +113,7 @@ export function getTempPrefixes() {
|
|
|
101
113
|
prefixes.push(ensureTrailingSep(systemRoot) + 'Temp\\');
|
|
102
114
|
}
|
|
103
115
|
// 用户 AppData Temp(无 TEMP 环境变量时的静态路径)
|
|
104
|
-
const
|
|
105
|
-
const home = userProfile ? userProfile.replace(/\//g, '\\') : homedir().replace(/\//g, '\\');
|
|
116
|
+
const home = currentUserHome().replace(/\//g, '\\');
|
|
106
117
|
if (home) {
|
|
107
118
|
const base = home.endsWith('\\') ? home : home + '\\';
|
|
108
119
|
prefixes.push(base + 'AppData\\Local\\Temp\\');
|
|
@@ -14,6 +14,16 @@ function rights(input) {
|
|
|
14
14
|
toolRights: input.toolRights ?? { allow: undefined, deny: [], denyCapabilities: [] },
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* 提权请求者授权(ops §8.6 拍板:T1 缺省仅 owner 可请求):
|
|
19
|
+
* 非 owner 角色默认 deny `priv_exec`——缺权参与者在 toolRights 层即拒,
|
|
20
|
+
* 连确认闸都到不了。owner 显式不受限。
|
|
21
|
+
*/
|
|
22
|
+
const NON_OWNER_PRIVILEGE = {
|
|
23
|
+
allow: undefined,
|
|
24
|
+
deny: ['priv_exec'],
|
|
25
|
+
denyCapabilities: [],
|
|
26
|
+
};
|
|
17
27
|
/** Built-in five-role catalog (v1: no consultant) */
|
|
18
28
|
export const BUILTIN_SESSION_ROLES = [
|
|
19
29
|
{
|
|
@@ -37,6 +47,7 @@ export const BUILTIN_SESSION_ROLES = [
|
|
|
37
47
|
readScope: 'full',
|
|
38
48
|
writeMemory: true,
|
|
39
49
|
canManageTasks: true,
|
|
50
|
+
toolRights: NON_OWNER_PRIVILEGE,
|
|
40
51
|
canHandoff: false,
|
|
41
52
|
}),
|
|
42
53
|
},
|
|
@@ -49,6 +60,7 @@ export const BUILTIN_SESSION_ROLES = [
|
|
|
49
60
|
readScope: 'full',
|
|
50
61
|
writeMemory: false,
|
|
51
62
|
canManageTasks: false,
|
|
63
|
+
toolRights: NON_OWNER_PRIVILEGE,
|
|
52
64
|
canHandoff: false,
|
|
53
65
|
}),
|
|
54
66
|
},
|
|
@@ -61,6 +73,7 @@ export const BUILTIN_SESSION_ROLES = [
|
|
|
61
73
|
readScope: 'none',
|
|
62
74
|
writeMemory: false,
|
|
63
75
|
canManageTasks: false,
|
|
76
|
+
toolRights: NON_OWNER_PRIVILEGE,
|
|
64
77
|
canHandoff: false,
|
|
65
78
|
}),
|
|
66
79
|
},
|
|
@@ -73,6 +86,7 @@ export const BUILTIN_SESSION_ROLES = [
|
|
|
73
86
|
readScope: 'full',
|
|
74
87
|
writeMemory: true,
|
|
75
88
|
canManageTasks: true,
|
|
89
|
+
toolRights: NON_OWNER_PRIVILEGE,
|
|
76
90
|
canHandoff: false,
|
|
77
91
|
}),
|
|
78
92
|
},
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export { RunMetricsCollector } from './run/reliability/run-metrics-collector.js'
|
|
|
47
47
|
export { CircuitBreaker } from './run/reliability/circuit-breaker.js';
|
|
48
48
|
export { wrapProviderWithCircuitBreaker } from './run/reliability/provider-wrapper.js';
|
|
49
49
|
export { FallbackProvider } from './run/reliability/fallback-provider.js';
|
|
50
|
+
export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
51
|
+
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
50
52
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
51
53
|
export { definePluginEntry, defineChannelPluginEntry } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
52
54
|
export type { OctopiPluginDefinition, OctopiChannelPluginDefinition } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
@@ -58,6 +60,8 @@ export { validateManifest, parseManifest } from './extension/plugin-ecosystem/pl
|
|
|
58
60
|
export type { PluginManifest, PluginContracts, ActivationConfig } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
59
61
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
60
62
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
63
|
+
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
64
|
+
export type { GitStatusSnapshot, GitStatusSnapshotBody, GitStatusSnapshotOptions, GitStatusEntry, GitStatusBranch, GitStatusCounts, GitStatusGroup, GitStatusKind, } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
61
65
|
export { DefaultSkillManager, FileSystemSkillSource } from './extension/plugin-ecosystem/skills/manager.js';
|
|
62
66
|
export type { SkillSource, DiscoveredSkill } from './extension/plugin-ecosystem/skills/manager.js';
|
|
63
67
|
export type { SkillDefinition, SkillManager } from './extension/plugin-ecosystem/skills/types.js';
|
package/dist/harness/index.js
CHANGED
|
@@ -38,6 +38,8 @@ export { RunMetricsCollector } from './run/reliability/run-metrics-collector.js'
|
|
|
38
38
|
export { CircuitBreaker } from './run/reliability/circuit-breaker.js';
|
|
39
39
|
export { wrapProviderWithCircuitBreaker } from './run/reliability/provider-wrapper.js';
|
|
40
40
|
export { FallbackProvider } from './run/reliability/fallback-provider.js';
|
|
41
|
+
export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
42
|
+
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
41
43
|
// ── Plugin Ecosystem ──
|
|
42
44
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
43
45
|
export { definePluginEntry, defineChannelPluginEntry } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
@@ -47,6 +49,7 @@ export { CapabilityRegistry } from './extension/plugin-ecosystem/plugins/capabil
|
|
|
47
49
|
export { validateManifest, parseManifest } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
48
50
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
49
51
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
52
|
+
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
50
53
|
export { DefaultSkillManager, FileSystemSkillSource } from './extension/plugin-ecosystem/skills/manager.js';
|
|
51
54
|
export { IssueRegistry } from './observability/diagnostics/index.js';
|
|
52
55
|
export { CommandRouter, parseCommand, normalizeCommandName, createBuiltinCommands, createClientCatalogCommand, skillCommandsFromManager, loadUserCommandDefs, pluginCommandsFromManager, } from './extension/plugin-ecosystem/commands/index.js';
|
|
@@ -28,6 +28,14 @@ export interface StatLike {
|
|
|
28
28
|
export declare function normalizePathLexical(input: string): string;
|
|
29
29
|
/** 有则 realpath,否则词法 */
|
|
30
30
|
export declare function normalizeFsPath(input: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* 真实文件身份键(同步):realpath 归一(解析 symlink 与 `/var`↔`/private/var` 等平台别名)。
|
|
33
|
+
* 供 Membership 匹配层做「同一真实文件」判定,勿按 cwd 猜身份。
|
|
34
|
+
*
|
|
35
|
+
* @param input - 路径(词法归一后必须是绝对路径)
|
|
36
|
+
* @returns realpath 归一形态;相对路径或盘上不存在时返回 null(此时调用方只信词法形态)
|
|
37
|
+
*/
|
|
38
|
+
export declare function realIdentitySync(input: string): string | null;
|
|
31
39
|
export declare function foldPathForCompare(p: string, kind: 'win' | 'posix'): string;
|
|
32
40
|
export declare function pathCompareKind(normalized: string): 'win' | 'posix';
|
|
33
41
|
/**
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { stat } from 'node:fs/promises';
|
|
8
8
|
import { realpath } from 'node:fs/promises';
|
|
9
|
+
import { realpathSync } from 'node:fs';
|
|
9
10
|
import path from 'node:path';
|
|
10
11
|
/**
|
|
11
12
|
* Windows / POSIX 路径词法归一(§7)。不要求存在。
|
|
@@ -68,6 +69,30 @@ export async function normalizeFsPath(input) {
|
|
|
68
69
|
return lexical;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* 真实文件身份键(同步):realpath 归一(解析 symlink 与 `/var`↔`/private/var` 等平台别名)。
|
|
74
|
+
* 供 Membership 匹配层做「同一真实文件」判定,勿按 cwd 猜身份。
|
|
75
|
+
*
|
|
76
|
+
* @param input - 路径(词法归一后必须是绝对路径)
|
|
77
|
+
* @returns realpath 归一形态;相对路径或盘上不存在时返回 null(此时调用方只信词法形态)
|
|
78
|
+
*/
|
|
79
|
+
export function realIdentitySync(input) {
|
|
80
|
+
let lexical;
|
|
81
|
+
try {
|
|
82
|
+
lexical = normalizePathLexical(input);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// 相对路径:拒绝按 cwd 解析(会把「old.md」猜成无关文件的身份)
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return normalizePathLexical(realpathSync(lexical));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// 盘上不存在(已删文件/合成路径):无别名可解析
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
71
96
|
export function foldPathForCompare(p, kind) {
|
|
72
97
|
return kind === 'win' ? p.toLowerCase() : p;
|
|
73
98
|
}
|
|
@@ -88,7 +113,7 @@ export function isPathPrefix(prefix, full) {
|
|
|
88
113
|
export function canonicalizeUrl(raw) {
|
|
89
114
|
const u = new URL(raw);
|
|
90
115
|
u.hash = '';
|
|
91
|
-
// **保留 query
|
|
116
|
+
// **保留 query**:`?id=1` / `?id=2` 大概率是不同文档(契约修订)
|
|
92
117
|
u.hostname = u.hostname.toLowerCase();
|
|
93
118
|
if ((u.protocol === 'http:' && u.port === '80') ||
|
|
94
119
|
(u.protocol === 'https:' && u.port === '443')) {
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* 中文不靠默认分词:索引/查询都写入「词 + CJK 二元组」token 流(对齐 Memory)。
|
|
5
5
|
* FTS 表非权威;upsert/remove 同步维护,可整库 rebuild。
|
|
6
6
|
*/
|
|
7
|
-
import { tokenizeKeywordQuery } from '../memory/sqlite/keyword-search.js';
|
|
7
|
+
import { CJK_RE, tokenizeKeywordQuery } from '../memory/sqlite/keyword-search.js';
|
|
8
8
|
const TOKEN_SPLIT = /[^\p{L}\p{N}_]+/u;
|
|
9
|
-
const CJK_RE = /[㐀-䶿一-鿿豈--ヿ]/;
|
|
10
9
|
/** 超长 token(base64/uuid/hash/压缩 JS 标识)不进倒排,避免 FTS 膨胀 */
|
|
11
10
|
const MAX_TOKEN_CHARS = 32;
|
|
12
11
|
/** 单 chunk token 流上限,防止病态正文写爆 FTS */
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
import { getTextContent } from '@octopi-agent/core/types.js';
|
|
7
7
|
/** 消息 metadata.source 标记 */
|
|
8
8
|
export const KNOWLEDGE_GROUNDING_SOURCE = 'knowledgeGrounding';
|
|
9
|
-
/**
|
|
10
|
-
import {
|
|
9
|
+
/** 真实用户发言判定(载体插槽不是用户发言,query 不采信;谓词见 context/layer-types) */
|
|
10
|
+
import { isHumanSpeech } from '../context/layer-types.js';
|
|
11
11
|
/**
|
|
12
12
|
* v1 query:最近 user + 可选前 1–2 条 user;不用 assistant 长文
|
|
13
13
|
*/
|
|
14
14
|
export function resolveGroundingQuery(messages, opts) {
|
|
15
15
|
const prior = Math.max(0, opts?.includePriorUserTurns ?? 1);
|
|
16
|
-
const users = messages.filter((m) =>
|
|
16
|
+
const users = messages.filter((m) => isHumanSpeech(m));
|
|
17
17
|
const recent = users.slice(-1 - prior);
|
|
18
18
|
const parts = recent.map((m) => getTextContent(m.content).trim()).filter(Boolean);
|
|
19
19
|
const joined = parts.join('\n');
|
|
@@ -62,10 +62,10 @@ export function formatKnowledgeGroundingMessage(pack) {
|
|
|
62
62
|
function estimateTokens(text) {
|
|
63
63
|
return Math.ceil(text.length / 4);
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
65
|
+
/** 最近一条真实用户发言的文本(skipIf 启发式只看本轮;载体插槽不计) */
|
|
66
66
|
function latestUserText(messages) {
|
|
67
67
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
68
|
-
if (messages[i]
|
|
68
|
+
if (isHumanSpeech(messages[i])) {
|
|
69
69
|
return getTextContent(messages[i].content);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -141,15 +141,32 @@ export declare class KnowledgeIndexStore {
|
|
|
141
141
|
ext?: string;
|
|
142
142
|
max?: number;
|
|
143
143
|
}): string[];
|
|
144
|
-
/**
|
|
145
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Membership 视图解析:query 的 logical 形态 → 该真实文件在本 source 下的全部 logical_path。
|
|
146
|
+
* 快路径字面命中;未命中再按真实文件身份(realpath)比对——symlink / `/var`↔`/private/var`
|
|
147
|
+
* 别名视为同一 path(合规 purge 不得因路径形态不同而漏删)。
|
|
148
|
+
*
|
|
149
|
+
* @param sourceId - 源 id
|
|
150
|
+
* @param logical - 查询路径(已 slash 归一)
|
|
151
|
+
* @returns 命中的存储字面 logical_path 列表(可能含多种拼写形态)
|
|
152
|
+
*/
|
|
153
|
+
private resolveMembershipPaths;
|
|
154
|
+
/**
|
|
155
|
+
* 解绑 path;File 仅在零认领时 purge(单文件同步语义,供测试/轻量路径)。
|
|
156
|
+
* 按真实文件身份匹配(见 resolveMembershipPaths)。
|
|
157
|
+
*
|
|
158
|
+
* @returns 实际解绑的存储字面 logical_path(供 hit log 按真实字面清痕)
|
|
159
|
+
*/
|
|
160
|
+
removeFile(sourceId: KnowledgeSourceId | string, path: string): string[];
|
|
146
161
|
/**
|
|
147
162
|
* 解绑 path + 可能的 purge(异步让出)。
|
|
148
163
|
* 单文件 purge 也可能删数千 chunk——必须让出,否则 Engine 调度不了 HTTP 回包。
|
|
164
|
+
*
|
|
165
|
+
* @returns 实际解绑的存储字面 logical_path(供 hit log 按真实字面清痕)
|
|
149
166
|
*/
|
|
150
167
|
removeFileAsync(sourceId: KnowledgeSourceId | string, path: string, opts?: {
|
|
151
168
|
yieldEvery?: number;
|
|
152
|
-
}): Promise<
|
|
169
|
+
}): Promise<string[]>;
|
|
153
170
|
/**
|
|
154
171
|
* 批量解绑:每 `yieldEvery` 条让出事件循环。
|
|
155
172
|
* 删大目录(数百文件)时同步连环 DELETE 会堵死 Engine,HTTP/Query 回包都无法调度。
|
|
@@ -158,6 +175,15 @@ export declare class KnowledgeIndexStore {
|
|
|
158
175
|
yieldEvery?: number;
|
|
159
176
|
}): Promise<number>;
|
|
160
177
|
removeFiles(sourceId: KnowledgeSourceId | string, paths: string[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* 子树成员收集:前缀 SQL 命中 ∪ 真实身份落在子树内的别名形态
|
|
180
|
+
* (防 `/var`↔`/private/var`、symlink 前缀漏删)。
|
|
181
|
+
*
|
|
182
|
+
* @param sourceId - 源 id
|
|
183
|
+
* @param prefix - 子树前缀(已 slash 归一、去尾斜杠)
|
|
184
|
+
* @returns 命中的存储字面 logical_path 列表(去重)
|
|
185
|
+
*/
|
|
186
|
+
private collectTreeMembershipPaths;
|
|
161
187
|
/**
|
|
162
188
|
* 删除 path 及子树:先收集 logical_path,再分批异步解绑 + purge。
|
|
163
189
|
*/
|
|
@@ -172,7 +198,8 @@ export declare class KnowledgeIndexStore {
|
|
|
172
198
|
yieldEvery?: number;
|
|
173
199
|
}): Promise<number>;
|
|
174
200
|
clearSource(sourceId: KnowledgeSourceId | string): void;
|
|
175
|
-
|
|
201
|
+
/** 单文件 purge:透传真实身份匹配到的存储字面(供 hit log 清痕) */
|
|
202
|
+
purgePath(sourceId: KnowledgeSourceId | string, path: string): string[];
|
|
176
203
|
/** 按 fileId 物理删除(membership 已清) */
|
|
177
204
|
purgeFile(fileId: string): void;
|
|
178
205
|
purgeFileAsync(fileId: string, opts?: {
|