@octopi-agent/engine 0.98.4 → 0.102.10
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-schema/agent.d.ts +35 -5
- package/dist/config-schema/agent.js +24 -4
- package/dist/config-schema/context.d.ts +6 -36
- package/dist/config-schema/context.js +4 -28
- package/dist/config-schema/engine.d.ts +57 -160
- package/dist/config-schema/engine.js +1 -5
- package/dist/config-schema/governance.d.ts +8 -1
- package/dist/config-schema/governance.js +8 -1
- package/dist/config-schema/models.d.ts +2 -8
- package/dist/config-schema/models.js +0 -2
- package/dist/config-schema/run.d.ts +2 -2
- package/dist/config-schema/run.js +2 -2
- package/dist/config-schema/shared.d.ts +0 -3
- package/dist/config-schema/shared.js +0 -2
- package/dist/config-schema/substrate.d.ts +14 -88
- package/dist/config-schema/substrate.js +22 -107
- package/dist/config.d.ts +45 -113
- package/dist/config.js +8 -2
- package/dist/harness/activation/dispatcher.js +7 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/runtime.js +13 -5
- package/dist/harness/activation/types.d.ts +2 -2
- package/dist/harness/agent/builder.d.ts +24 -3
- package/dist/harness/agent/builder.js +131 -27
- package/dist/harness/agent/config-bridge.js +9 -2
- package/dist/harness/agent/config-integrity.js +19 -2
- package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
- package/dist/harness/agent/wire-agent-builder.js +26 -7
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +3 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
- package/dist/harness/collaboration/delegation/child-run.js +4 -4
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/service.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.js +2 -1
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +2 -1
- package/dist/harness/collaboration/delegation/types.d.ts +23 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.js +11 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +0 -6
- package/dist/harness/context/capabilities/compact/engine.js +169 -121
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +5 -1
- package/dist/harness/context/capabilities/compact/index.js +4 -0
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +76 -11
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/types.d.ts +3 -6
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +236 -0
- package/dist/harness/context/default-context-engine.d.ts +195 -119
- package/dist/harness/context/default-context-engine.js +1241 -743
- package/dist/harness/context/index.d.ts +2 -2
- package/dist/harness/context/index.js +1 -1
- package/dist/harness/context/layer-types.d.ts +15 -0
- package/dist/harness/context/layer-types.js +14 -1
- package/dist/harness/context/layers.d.ts +14 -15
- package/dist/harness/context/layers.js +41 -11
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +9 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
- package/dist/harness/context/system-prompt-assembler.js +2 -1
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +6 -1
- package/dist/harness/context/tool-result-aging.js +16 -5
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +127 -117
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +83 -249
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +50 -117
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +11 -2
- package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/index.d.ts +12 -12
- package/dist/harness/index.js +7 -7
- package/dist/harness/knowledge/boot-config.d.ts +55 -0
- package/dist/harness/knowledge/boot-config.js +50 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +24 -2
- package/dist/harness/knowledge/client.js +19 -5
- package/dist/harness/knowledge/db.js +5 -0
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +6 -0
- package/dist/harness/knowledge/grounding.js +3 -1
- package/dist/harness/knowledge/http-app.js +35 -4
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +3 -0
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +13 -2
- package/dist/harness/knowledge/query-service.js +4 -2
- package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -2
- package/dist/harness/knowledge/query-worker.js +4 -2
- package/dist/harness/knowledge/read-http.js +5 -1
- package/dist/harness/knowledge/serve.d.ts +8 -7
- package/dist/harness/knowledge/serve.js +9 -0
- package/dist/harness/knowledge/source-store.js +26 -3
- package/dist/harness/knowledge/start-service-process.d.ts +15 -7
- package/dist/harness/knowledge/start-service-process.js +21 -9
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +37 -9
- package/dist/harness/knowledge/writer-service.js +120 -14
- package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
- package/dist/harness/knowledge/writer-worker-client.js +20 -2
- package/dist/harness/knowledge/writer-worker.js +9 -1
- package/dist/harness/memory/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +6 -4
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.js +25 -15
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +66 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +10 -4
- package/dist/harness/run/reliability/run-agent.js +137 -53
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- package/dist/harness/run/run-scope.d.ts +37 -4
- package/dist/harness/run/runner.d.ts +44 -29
- package/dist/harness/run/runner.js +320 -102
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- package/dist/harness/session/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +2 -2
- package/dist/harness/shared/events/agent-event-map.d.ts +46 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/types/agent-definition.d.ts +1 -2
- package/dist/index.d.ts +14 -17
- package/dist/index.js +7 -9
- package/dist/integration/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- package/dist/integration/providers/anthropic.js +14 -1
- package/dist/integration/providers/openai.js +7 -1
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump.d.ts +1 -1
- package/dist/integration/storage/archive-manager.d.ts +6 -0
- package/dist/integration/storage/archive-manager.js +10 -0
- package/dist/integration/storage/jsonl.d.ts +1 -1
- package/dist/integration/storage/jsonl.js +18 -16
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +1 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/package.json +11 -14
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 工具与 `DelegateService` 分离:服务可被嵌入方直接用,不经 LLM 工具面。
|
|
11
11
|
*/
|
|
12
12
|
import { DelegateResolutionError } from '../../../collaboration/delegation/service.js';
|
|
13
|
-
import { isTerminalDelegationStatus } from '../../../collaboration/delegation/types.js';
|
|
13
|
+
import { DEFAULT_DELEGATION_OUTPUT_CHARS, isTerminalDelegationStatus, } from '../../../collaboration/delegation/types.js';
|
|
14
14
|
/** 委派单摘要(进 LLM 结果,字段名 snake_case 对齐其他工具) */
|
|
15
15
|
function delegationSummary(d) {
|
|
16
16
|
return {
|
|
@@ -115,14 +115,19 @@ export function createDelegateDispatchTool(service) {
|
|
|
115
115
|
enum: ['clean', 'fork'],
|
|
116
116
|
description: "Context mode. 'clean' (default) starts the child with no parent history; 'fork' passes your message history for background.",
|
|
117
117
|
},
|
|
118
|
-
|
|
118
|
+
max_steps: {
|
|
119
119
|
type: 'number',
|
|
120
|
-
description: '
|
|
120
|
+
description: 'Step budget for the child run (model rounds; intersected with the target ceiling)',
|
|
121
121
|
},
|
|
122
122
|
max_tokens: {
|
|
123
123
|
type: 'number',
|
|
124
124
|
description: 'Token budget for the child run (intersected with the target ceiling)',
|
|
125
125
|
},
|
|
126
|
+
max_output_chars: {
|
|
127
|
+
type: 'number',
|
|
128
|
+
description: 'Truncation cap (chars) for the auto-returned result notice <output>. ' +
|
|
129
|
+
`Default ${DEFAULT_DELEGATION_OUTPUT_CHARS}. The full output is collectable via delegate_get (not subject to this cap).`,
|
|
130
|
+
},
|
|
126
131
|
timeout_ms: {
|
|
127
132
|
type: 'number',
|
|
128
133
|
description: 'Delegation timeout in milliseconds',
|
|
@@ -140,8 +145,11 @@ export function createDelegateDispatchTool(service) {
|
|
|
140
145
|
}
|
|
141
146
|
const contextMode = args.context === 'fork' ? 'fork' : 'clean';
|
|
142
147
|
const timeoutMs = args.timeout_ms != null ? Number(args.timeout_ms) : undefined;
|
|
143
|
-
const
|
|
148
|
+
const maxSteps = args.max_steps != null ? Number(args.max_steps) : undefined;
|
|
144
149
|
const maxTokens = args.max_tokens != null ? Number(args.max_tokens) : undefined;
|
|
150
|
+
// 非法值不在工具层静默丢弃(m6):透传给 dispatch,由 normalizeMaxOutputChars
|
|
151
|
+
// fail loud——错误经下方 catch 以 ok:false 回给 LLM,形成反馈闭环
|
|
152
|
+
const maxOutputChars = args.max_output_chars != null ? Number(args.max_output_chars) : undefined;
|
|
145
153
|
try {
|
|
146
154
|
const { delegation, resolvedAgentId } = await service.dispatch({
|
|
147
155
|
parent: {
|
|
@@ -154,11 +162,12 @@ export function createDelegateDispatchTool(service) {
|
|
|
154
162
|
target: agent ? { agentId: agent } : { trait },
|
|
155
163
|
task: String(args.task ?? ''),
|
|
156
164
|
input: String(args.input ?? ''),
|
|
165
|
+
maxOutputChars,
|
|
157
166
|
context: contextMode,
|
|
158
167
|
// D1:传快照而非活数组引用——父 run 在子起跑后仍会 append
|
|
159
168
|
parentMessages: contextMode === 'fork' ? context.messages.map((m) => ({ ...m })) : undefined,
|
|
160
|
-
budget:
|
|
161
|
-
? {
|
|
169
|
+
budget: maxSteps != null || maxTokens != null || timeoutMs != null
|
|
170
|
+
? { maxSteps, maxTokens, timeoutMs }
|
|
162
171
|
: undefined,
|
|
163
172
|
timeoutMs,
|
|
164
173
|
});
|
|
@@ -206,8 +215,9 @@ export function createDelegateListTool(service) {
|
|
|
206
215
|
status,
|
|
207
216
|
activeOnly,
|
|
208
217
|
});
|
|
209
|
-
// 列表是只读概览:不 markSurfaced
|
|
210
|
-
//
|
|
218
|
+
// 列表是只读概览:不 markSurfaced。结果体量无委派层上限(专用工具结果截断器
|
|
219
|
+
// 尚未接线——记债见 CHANGELOG v0.102.10),「标已送达」只留给明确取回单条全文的
|
|
220
|
+
// delegate_get,宁可提示多留也不误消音
|
|
211
221
|
return {
|
|
212
222
|
delegations: items.map(delegationSummary),
|
|
213
223
|
total: items.length,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Plugin Tool mounting and authorization shared by ToolBus, Agent, and Gateway. */
|
|
2
|
+
import type { RegisteredTool, ToolPolicy, ToolSource } from '@octopi-agent/core/types.js';
|
|
3
|
+
import type { PluginToolRecord } from '../plugins/contribution-registry.js';
|
|
4
|
+
/** Plugin Tools never inherit builtin's empty-allow visibility. */
|
|
5
|
+
export declare function isPluginToolPermitted(tool: RegisteredTool, policy?: ToolPolicy): boolean;
|
|
6
|
+
/** AgentTool/Runner projection variant: no handler is needed for policy evaluation. */
|
|
7
|
+
export declare function isPluginToolCallPermitted(name: string, source: ToolSource | undefined, policy?: ToolPolicy): boolean;
|
|
8
|
+
/** Adapter boundary: the host, not the plugin, assigns the contribution identity. */
|
|
9
|
+
export declare function pluginToolToRegisteredTool(record: PluginToolRecord): RegisteredTool;
|
|
10
|
+
/** Mount only explicitly permitted contributions into an Agent's local ToolBus. */
|
|
11
|
+
export declare function mountPluginTools(records: readonly PluginToolRecord[], agentId: string, policy: ToolPolicy | undefined, registerForAgent: (agentId: string, tool: RegisteredTool) => void): RegisteredTool[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Plugin Tool mounting and authorization shared by ToolBus, Agent, and Gateway. */
|
|
2
|
+
/** Plugin Tools never inherit builtin's empty-allow visibility. */
|
|
3
|
+
export function isPluginToolPermitted(tool, policy) {
|
|
4
|
+
return isPluginToolCallPermitted(tool.definition.name, tool.source, policy);
|
|
5
|
+
}
|
|
6
|
+
/** AgentTool/Runner projection variant: no handler is needed for policy evaluation. */
|
|
7
|
+
export function isPluginToolCallPermitted(name, source, policy) {
|
|
8
|
+
if (source?.kind !== 'plugin')
|
|
9
|
+
return true;
|
|
10
|
+
const allow = policy?.allow ?? [];
|
|
11
|
+
if (!(allow.includes('*') || allow.includes(name)))
|
|
12
|
+
return false;
|
|
13
|
+
if (policy?.deny?.includes('*') || policy?.deny?.includes(name))
|
|
14
|
+
return false;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
/** Adapter boundary: the host, not the plugin, assigns the contribution identity. */
|
|
18
|
+
export function pluginToolToRegisteredTool(record) {
|
|
19
|
+
const source = { kind: 'plugin', origin: record.pluginId, trustLevel: 'third-party' };
|
|
20
|
+
return {
|
|
21
|
+
definition: record.definition,
|
|
22
|
+
handler: record.handler,
|
|
23
|
+
source,
|
|
24
|
+
executionMode: record.executionMode ??
|
|
25
|
+
(record.definition.capabilities?.includes('fs-write') ? 'sequential' : undefined),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Mount only explicitly permitted contributions into an Agent's local ToolBus. */
|
|
29
|
+
export function mountPluginTools(records, agentId, policy, registerForAgent) {
|
|
30
|
+
const mounted = [];
|
|
31
|
+
for (const record of records) {
|
|
32
|
+
const tool = pluginToolToRegisteredTool(record);
|
|
33
|
+
if (!isPluginToolPermitted(tool, policy))
|
|
34
|
+
continue;
|
|
35
|
+
registerForAgent(agentId, tool);
|
|
36
|
+
mounted.push(tool);
|
|
37
|
+
}
|
|
38
|
+
return mounted;
|
|
39
|
+
}
|
|
@@ -59,7 +59,7 @@ export declare class DefaultToolBus implements ToolBus {
|
|
|
59
59
|
* 查找工具 → 参数校验 → 调用 handler。
|
|
60
60
|
* 适用于在 agentLoop 外部直接调用工具的场景。
|
|
61
61
|
*/
|
|
62
|
-
execute(name: string, args: Record<string, unknown>, context: import('@octopi-agent/core/types.js').ToolExecutionContext): Promise<unknown>;
|
|
62
|
+
execute(name: string, args: Record<string, unknown>, context: import('@octopi-agent/core/types.js').ToolExecutionContext, policy?: ToolPolicy): Promise<unknown>;
|
|
63
63
|
/**
|
|
64
64
|
* 获取全局注册的工具名集合(用于 SecurityGuard 的 registeredTools 校验)
|
|
65
65
|
*/
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { registerToolCapabilities } from '../../execution-environment/tool-capabilities.js';
|
|
20
20
|
import { buildToolLlmParameters } from '../../../agent/tool-purpose.js';
|
|
21
|
+
import { isPluginToolPermitted } from './plugin-tool.js';
|
|
21
22
|
/**
|
|
22
23
|
* DefaultToolBus — 工具总线实现
|
|
23
24
|
*
|
|
@@ -54,6 +55,9 @@ export class DefaultToolBus {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
registerForAgent(agentId, tool) {
|
|
58
|
+
if (this.getTool(tool.definition.name, agentId)) {
|
|
59
|
+
throw new Error(`Agent tool "${tool.definition.name}" already registered for "${agentId}"`);
|
|
60
|
+
}
|
|
57
61
|
if (!this.agentTools.has(agentId)) {
|
|
58
62
|
this.agentTools.set(agentId, new Map());
|
|
59
63
|
}
|
|
@@ -90,7 +94,7 @@ export class DefaultToolBus {
|
|
|
90
94
|
}
|
|
91
95
|
// ── 解析 ──
|
|
92
96
|
resolve(agentId, policy) {
|
|
93
|
-
let tools = this.listForAgent(agentId);
|
|
97
|
+
let tools = this.listForAgent(agentId).filter((tool) => isPluginToolPermitted(tool, policy));
|
|
94
98
|
if (policy) {
|
|
95
99
|
if (policy.allow && policy.allow.length > 0) {
|
|
96
100
|
const allowSet = new Set(policy.allow);
|
|
@@ -154,11 +158,16 @@ export class DefaultToolBus {
|
|
|
154
158
|
* 查找工具 → 参数校验 → 调用 handler。
|
|
155
159
|
* 适用于在 agentLoop 外部直接调用工具的场景。
|
|
156
160
|
*/
|
|
157
|
-
async execute(name, args, context) {
|
|
161
|
+
async execute(name, args, context, policy) {
|
|
158
162
|
const tool = this.getTool(name, context.agentId);
|
|
159
163
|
if (!tool) {
|
|
160
164
|
throw new Error(`Tool "${name}" not found`);
|
|
161
165
|
}
|
|
166
|
+
const { getRunScope } = await import('../../../run/run-scope.js');
|
|
167
|
+
const effectivePolicy = getRunScope()?.toolRuntime?.agentToolPolicy ?? policy;
|
|
168
|
+
if (!isPluginToolPermitted(tool, effectivePolicy)) {
|
|
169
|
+
throw new Error(`Plugin tool "${name}" is not allowed for agent "${context.agentId}"`);
|
|
170
|
+
}
|
|
162
171
|
this.validateArgs(name, args, tool.definition);
|
|
163
172
|
const { runWithToolLimits, resolveToolTimeoutMs } = await import('../../execution-environment/resource-limits.js');
|
|
164
173
|
return runWithToolLimits((signal) => tool.handler(args, { ...context, abortSignal: signal }), {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 见 arch/budget-redesign.md:只记录,不 kill。Policy 另层(P3+)。
|
|
5
5
|
*/
|
|
6
|
-
import type { TokenUsage } from '@octopi-agent/core/types/
|
|
6
|
+
import type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
7
7
|
/** 账本快照(Observer + Policy 只读输入) */
|
|
8
8
|
export interface UsageLedgerSnapshot {
|
|
9
9
|
scope: 'run' | 'session';
|
|
@@ -24,6 +24,8 @@ export interface UsageLedgerSnapshot {
|
|
|
24
24
|
elapsedMs: number;
|
|
25
25
|
/** P5: context 估算 tokens(最新值) */
|
|
26
26
|
contextEstTokens?: number;
|
|
27
|
+
/** context 实测 tokens(最近一次非摘要 LLM 调用的 prompt 实测;wrap-up 压力轴优先用它) */
|
|
28
|
+
contextActualTokens?: number;
|
|
27
29
|
/** P5: context 窗口大小(模型能力) */
|
|
28
30
|
contextWindowTokens?: number;
|
|
29
31
|
/** P5: 估算花费(币种由 pricing 决定) */
|
|
@@ -53,6 +55,7 @@ export declare class UsageLedger {
|
|
|
53
55
|
private summaryOutputTokens;
|
|
54
56
|
private toolCalls;
|
|
55
57
|
private contextEstTokens?;
|
|
58
|
+
private contextActualTokens?;
|
|
56
59
|
private contextWindowTokens?;
|
|
57
60
|
private toolSummaryApplied;
|
|
58
61
|
private toolOutputRawChars;
|
|
@@ -105,3 +108,12 @@ export declare class UsageLedger {
|
|
|
105
108
|
agentId?: string;
|
|
106
109
|
}): UsageLedgerSnapshot;
|
|
107
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* wrap-up 压力轴的 context 体量口径(单一实现):实测优先,估算只做前瞻补充。
|
|
113
|
+
* 毒估算/锚外推可把估算放大数倍(2026-11-07 实测 5.4× 虚高误杀 run),
|
|
114
|
+
* 压力裁决必须锚在 provider 实测上;无实测(首步前)才回落估算。
|
|
115
|
+
*
|
|
116
|
+
* @param snapshot - 用量账本快照
|
|
117
|
+
* @returns 压力裁决用的 context 体量(tokens),两者皆缺返回 undefined
|
|
118
|
+
*/
|
|
119
|
+
export declare function contextPressureTokens(snapshot: Pick<UsageLedgerSnapshot, 'contextActualTokens' | 'contextEstTokens'>): number | undefined;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 见 arch/budget-redesign.md:只记录,不 kill。Policy 另层(P3+)。
|
|
5
5
|
*/
|
|
6
|
-
import { nominalTotalTokens } from '@octopi-agent/core/types/
|
|
6
|
+
import { nominalTotalTokens } from '@octopi-agent/core/types/step.js';
|
|
7
7
|
/**
|
|
8
8
|
* UsageLedger
|
|
9
9
|
*/
|
|
@@ -20,6 +20,7 @@ export class UsageLedger {
|
|
|
20
20
|
summaryOutputTokens = 0;
|
|
21
21
|
toolCalls = 0;
|
|
22
22
|
contextEstTokens;
|
|
23
|
+
contextActualTokens;
|
|
23
24
|
contextWindowTokens;
|
|
24
25
|
toolSummaryApplied = 0;
|
|
25
26
|
toolOutputRawChars = 0;
|
|
@@ -46,6 +47,14 @@ export class UsageLedger {
|
|
|
46
47
|
this.summaryLlmCalls++;
|
|
47
48
|
this.summaryOutputTokens += usage.outputTokens;
|
|
48
49
|
}
|
|
50
|
+
else {
|
|
51
|
+
// context 实测:只认对话请求的 prompt 实测(摘要请求的 usage 是另一个请求的体量,
|
|
52
|
+
// 混入会污染压力轴);provider 报告优先,分项和兜底——与展示口径同源
|
|
53
|
+
const promptActual = usage.inputReportedTokens ??
|
|
54
|
+
usage.inputUncachedTokens + usage.inputCachedTokens + usage.inputCacheWriteTokens;
|
|
55
|
+
if (promptActual > 0)
|
|
56
|
+
this.contextActualTokens = promptActual;
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
/** @param n - 工具调用次数 */
|
|
51
60
|
recordToolCall(n = 1) {
|
|
@@ -98,6 +107,7 @@ export class UsageLedger {
|
|
|
98
107
|
this.summaryOutputTokens = 0;
|
|
99
108
|
this.toolCalls = 0;
|
|
100
109
|
this.contextEstTokens = undefined;
|
|
110
|
+
this.contextActualTokens = undefined;
|
|
101
111
|
this.contextWindowTokens = undefined;
|
|
102
112
|
this.toolSummaryApplied = 0;
|
|
103
113
|
this.toolOutputRawChars = 0;
|
|
@@ -127,6 +137,7 @@ export class UsageLedger {
|
|
|
127
137
|
toolCalls: this.toolCalls,
|
|
128
138
|
elapsedMs: Date.now() - this.startTime,
|
|
129
139
|
contextEstTokens: this.contextEstTokens,
|
|
140
|
+
contextActualTokens: this.contextActualTokens,
|
|
130
141
|
contextWindowTokens: this.contextWindowTokens,
|
|
131
142
|
toolSummaryApplied: this.toolSummaryApplied,
|
|
132
143
|
toolOutputRawChars: this.toolOutputRawChars,
|
|
@@ -135,3 +146,14 @@ export class UsageLedger {
|
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* wrap-up 压力轴的 context 体量口径(单一实现):实测优先,估算只做前瞻补充。
|
|
151
|
+
* 毒估算/锚外推可把估算放大数倍(2026-11-07 实测 5.4× 虚高误杀 run),
|
|
152
|
+
* 压力裁决必须锚在 provider 实测上;无实测(首步前)才回落估算。
|
|
153
|
+
*
|
|
154
|
+
* @param snapshot - 用量账本快照
|
|
155
|
+
* @returns 压力裁决用的 context 体量(tokens),两者皆缺返回 undefined
|
|
156
|
+
*/
|
|
157
|
+
export function contextPressureTokens(snapshot) {
|
|
158
|
+
return snapshot.contextActualTokens ?? snapshot.contextEstTokens;
|
|
159
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { HitlDecision } from '@octopi-agent/core/types/tools.js';
|
|
14
14
|
/** Which confirm surface produced the decision */
|
|
15
|
-
export type HitlChannel = 'high_risk' | 'effect';
|
|
15
|
+
export type HitlChannel = 'high_risk' | 'effect' | 'plugin_hook';
|
|
16
16
|
/** Cached scope of a remembered approval */
|
|
17
17
|
export type HitlCacheScope = 'session' | 'always';
|
|
18
18
|
/** 非人工拒绝来源(人工决策不带此标注);用于错误面与审计如实归因 */
|
|
@@ -62,7 +62,7 @@ export declare class HitlDecisionCache {
|
|
|
62
62
|
/**
|
|
63
63
|
* Look up a remembered approval.
|
|
64
64
|
*
|
|
65
|
-
* @param channel - high_risk | effect
|
|
65
|
+
* @param channel - high_risk | effect | plugin_hook
|
|
66
66
|
* @param key - tool name or effect kind
|
|
67
67
|
* @param options - sessionId (session scope) and/or agentId (always scope)
|
|
68
68
|
* @returns `'approve'` if cached, otherwise `null`
|
|
@@ -79,7 +79,7 @@ export declare class HitlDecisionCache {
|
|
|
79
79
|
* Missing scope id → silently one-shot (fail-safe, never over-grant).
|
|
80
80
|
*
|
|
81
81
|
* @param decision - host decision
|
|
82
|
-
* @param channel - high_risk | effect
|
|
82
|
+
* @param channel - high_risk | effect | plugin_hook
|
|
83
83
|
* @param key - tool name or effect kind
|
|
84
84
|
* @param options - sessionId and/or agentId
|
|
85
85
|
*/
|
|
@@ -43,7 +43,7 @@ export class HitlDecisionCache {
|
|
|
43
43
|
/**
|
|
44
44
|
* Look up a remembered approval.
|
|
45
45
|
*
|
|
46
|
-
* @param channel - high_risk | effect
|
|
46
|
+
* @param channel - high_risk | effect | plugin_hook
|
|
47
47
|
* @param key - tool name or effect kind
|
|
48
48
|
* @param options - sessionId (session scope) and/or agentId (always scope)
|
|
49
49
|
* @returns `'approve'` if cached, otherwise `null`
|
|
@@ -74,7 +74,7 @@ export class HitlDecisionCache {
|
|
|
74
74
|
* Missing scope id → silently one-shot (fail-safe, never over-grant).
|
|
75
75
|
*
|
|
76
76
|
* @param decision - host decision
|
|
77
|
-
* @param channel - high_risk | effect
|
|
77
|
+
* @param channel - high_risk | effect | plugin_hook
|
|
78
78
|
* @param key - tool name or effect kind
|
|
79
79
|
* @param options - sessionId and/or agentId
|
|
80
80
|
*/
|
|
@@ -138,8 +138,7 @@ export class CapabilityEnforcer {
|
|
|
138
138
|
case '*':
|
|
139
139
|
return { allowed: true };
|
|
140
140
|
case 'allowed-list':
|
|
141
|
-
|
|
142
|
-
return { allowed: true };
|
|
141
|
+
return { allowed: false, reason: `Plugin "${pluginId}" network allow-list is not implemented for host "${host}"` };
|
|
143
142
|
case 'none':
|
|
144
143
|
return { allowed: false, reason: `Plugin "${pluginId}" has no network access` };
|
|
145
144
|
default:
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -31,12 +31,7 @@ export type { DefaultContextEngineConfig } from './context/default-context-engin
|
|
|
31
31
|
export { HeuristicTokenEstimator, estimateTextTokens, estimateLLMMessages } from './context/index.js';
|
|
32
32
|
export { JSON_CHARS_PER_TOKEN, TOOL_RESULT_CHARS_PER_TOKEN, CHARS_PER_TOKEN, } from './context/index.js';
|
|
33
33
|
export { DefaultMessageSelector } from './context/message-selector.js';
|
|
34
|
-
export { TruncateCompressor } from './context/truncate-compressor.js';
|
|
35
|
-
export { LLMSummaryCompressor } from './context/llm-summarizer.js';
|
|
36
|
-
export { HybridCompressor } from './context/hybrid-compressor.js';
|
|
37
34
|
export { DefaultBudgetAllocator } from './context/budget-allocator.js';
|
|
38
|
-
export { SmartRouter } from './context/smart-router.js';
|
|
39
|
-
export type { SmartRouterConfig, Route, RoutingDecision } from './context/smart-router.js';
|
|
40
35
|
export { LAYER_ORDER, LAYER_PRIORITY, LAYER_DEFAULT_SHARE, extractLayerQuery, hasLayerText, DefaultContextAssembler, truncateTextToTokens, ALL_LAYER_IDS, buildContextLayersSnapshot, deriveLayerStatus, emptyContextLayersSnapshot, probeContextLayerHealth, probeAgentHomeHealth, PersonaLayer, SkillLayer, RuntimeLayer, KnowledgeLayer, MemoryLayer, CognitionLayer, WisdomLayer, createDefaultLayers, createProviderSummarize, pickSummarizeProvider, createDefaultSystemPromptAssembler, } from './context/index.js';
|
|
41
36
|
export type { ContextLayerId, LayerAssembleContext, LayerContent, ContextLayer, LayerManifestEntry, AssembleManifest, SystemAssembleResult, ContextAssembler, ContextAssembleParams, DefaultContextAssemblerConfig, CreateDefaultLayersOptions, CreateProviderSummarizeOptions, SystemPromptAssembleInput, SystemPromptAssembleOutput, ContextLayersSnapshot, LayerRuntimeView, LayerUiStatus, ContextLayerHealth, ContextLayerHealthEntry, ProbeContextHealthDeps, ContextCompactReason, ContextCompactEvent, ContextEmitFn, ContextCompactSnapshot, } from './context/index.js';
|
|
42
37
|
export { CapabilityEnforcer, PluginTrustLevel } from './governance/security/capability-enforcer.js';
|
|
@@ -50,14 +45,14 @@ export { FallbackProvider } from './run/reliability/fallback-provider.js';
|
|
|
50
45
|
export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
51
46
|
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
52
47
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
53
|
-
export {
|
|
54
|
-
export type { OctopiPluginDefinition
|
|
48
|
+
export { definePlugin } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
49
|
+
export type { OctopiPluginDefinition } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
55
50
|
export { PluginApi } from './extension/plugin-ecosystem/plugins/api.js';
|
|
56
51
|
export { PluginLoader } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
57
|
-
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
58
|
-
export {
|
|
59
|
-
export { validateManifest, parseManifest } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
60
|
-
export type { PluginManifest,
|
|
52
|
+
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig, PluginDiagnostic } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
53
|
+
export { PluginContributionRegistry } from './extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
54
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
55
|
+
export type { PluginManifest, PluginContributions, PluginHookName, PluginSessionOpName } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
61
56
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
62
57
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
63
58
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
@@ -125,10 +120,15 @@ export type { SessionSwitchRecord } from './session/types.js';
|
|
|
125
120
|
export type { RunAuditRecord } from './activation/types.js';
|
|
126
121
|
export { readSessionCompact, writeSessionCompact } from './session/compact.js';
|
|
127
122
|
export { compactStateKey } from './context/compact-key.js';
|
|
123
|
+
export { JsonlTransformStore, InMemoryTransformStore, resolveSessionTransformPaths, copySessionTransformDir, removeSessionTransformDir, scanOrphanSessionTransform, } from './session/transform-store.js';
|
|
124
|
+
export { foldTransformView } from './context/transform/fold.js';
|
|
125
|
+
export { anchorFor, anchorRange, resolveAnchor, resolveRun, canonicalMessageHash } from './context/transform/anchors.js';
|
|
126
|
+
export { legacySnapshotToRecords } from './context/transform/migrate.js';
|
|
127
|
+
export type { TransformRecord, TransformRun, TransformLedger, TransformStore, NewTransformRecord, MessageAnchor, TransformRecordType, TransformPlaceholder, TransformRecordMeta, } from './context/transform/types.js';
|
|
128
128
|
export { agentLoop, callModel, classifyError } from '@octopi-agent/core/loop/index.js';
|
|
129
129
|
export type { AgentContext, AgentTool, LoopToolResult, AgentLoopConfig, AgentLoopEvent, LoopObserver, ClassifiedError as LoopClassifiedError } from '@octopi-agent/core/loop/index.js';
|
|
130
130
|
export { Agent } from './run/agent/index.js';
|
|
131
|
-
export type { AgentOptions } from './run/agent/index.js';
|
|
131
|
+
export type { AgentOptions, RunIdentity } from './run/agent/index.js';
|
|
132
132
|
export { withRunScope, getRunScope, getRunSessionId, createRunId } from './run/run-scope.js';
|
|
133
133
|
export type { RunScope, RunToolRuntime } from './run/run-scope.js';
|
|
134
134
|
export { ObserverHub } from './observability/observer/hub.js';
|
package/dist/harness/index.js
CHANGED
|
@@ -24,11 +24,7 @@ export { DefaultContextEngine } from './context/default-context-engine.js';
|
|
|
24
24
|
export { HeuristicTokenEstimator, estimateTextTokens, estimateLLMMessages } from './context/index.js';
|
|
25
25
|
export { JSON_CHARS_PER_TOKEN, TOOL_RESULT_CHARS_PER_TOKEN, CHARS_PER_TOKEN, } from './context/index.js';
|
|
26
26
|
export { DefaultMessageSelector } from './context/message-selector.js';
|
|
27
|
-
export { TruncateCompressor } from './context/truncate-compressor.js';
|
|
28
|
-
export { LLMSummaryCompressor } from './context/llm-summarizer.js';
|
|
29
|
-
export { HybridCompressor } from './context/hybrid-compressor.js';
|
|
30
27
|
export { DefaultBudgetAllocator } from './context/budget-allocator.js';
|
|
31
|
-
export { SmartRouter } from './context/smart-router.js';
|
|
32
28
|
export { LAYER_ORDER, LAYER_PRIORITY, LAYER_DEFAULT_SHARE, extractLayerQuery, hasLayerText, DefaultContextAssembler, truncateTextToTokens, ALL_LAYER_IDS, buildContextLayersSnapshot, deriveLayerStatus, emptyContextLayersSnapshot, probeContextLayerHealth, probeAgentHomeHealth, PersonaLayer, SkillLayer, RuntimeLayer, KnowledgeLayer, MemoryLayer, CognitionLayer, WisdomLayer, createDefaultLayers, createProviderSummarize, pickSummarizeProvider, createDefaultSystemPromptAssembler, } from './context/index.js';
|
|
33
29
|
// ── Security ──
|
|
34
30
|
export { CapabilityEnforcer, PluginTrustLevel } from './governance/security/capability-enforcer.js';
|
|
@@ -42,11 +38,11 @@ export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
|
42
38
|
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
43
39
|
// ── Plugin Ecosystem ──
|
|
44
40
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
45
|
-
export {
|
|
41
|
+
export { definePlugin } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
46
42
|
export { PluginApi } from './extension/plugin-ecosystem/plugins/api.js';
|
|
47
43
|
export { PluginLoader } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
48
|
-
export {
|
|
49
|
-
export { validateManifest, parseManifest } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
44
|
+
export { PluginContributionRegistry } from './extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
45
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
50
46
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
51
47
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
52
48
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
@@ -94,6 +90,10 @@ export { InProcessSessionLock } from './run/concurrency/session-lease.js';
|
|
|
94
90
|
export { SessionAclService, SessionRoleCatalog, BUILTIN_SESSION_ROLES, computeEffectiveRights, intersectRights, applyRightsOverlay, exceedsRightsCeiling, L0_SESSION_RIGHTS_FLOOR, EMPTY_TOOL_RIGHTS, normalizeToolRights, intersectToolRights, toolRightsExceeds, isToolAllowedByRights, isToolPermitted, } from './governance/session-acl/index.js';
|
|
95
91
|
export { readSessionCompact, writeSessionCompact } from './session/compact.js';
|
|
96
92
|
export { compactStateKey } from './context/compact-key.js';
|
|
93
|
+
export { JsonlTransformStore, InMemoryTransformStore, resolveSessionTransformPaths, copySessionTransformDir, removeSessionTransformDir, scanOrphanSessionTransform, } from './session/transform-store.js';
|
|
94
|
+
export { foldTransformView } from './context/transform/fold.js';
|
|
95
|
+
export { anchorFor, anchorRange, resolveAnchor, resolveRun, canonicalMessageHash } from './context/transform/anchors.js';
|
|
96
|
+
export { legacySnapshotToRecords } from './context/transform/migrate.js';
|
|
97
97
|
// ── Config Bridge ──
|
|
98
98
|
// (exported from agent-building above)
|
|
99
99
|
// ── Loop re-export(纯函数与协议类型;Agent 门面在 harness/agent) ──
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* octopi.json `knowledge.*` 调参面 → Knowledge Service boot 调参块(唯一映射点)
|
|
3
|
+
*
|
|
4
|
+
* 背景:v0.51 Gateway 直连 knowledge.db 时这些键全量贯通;v0.60 拆独立 Service
|
|
5
|
+
* 后传递线丢失(配了不生效,见 arch/config-key-audit-2026-11-01.md §1a/§2)。
|
|
6
|
+
* v0.98.11 起经 boot 文件传入 Service——schema 形状(knowledge.embed / index /
|
|
7
|
+
* load / keywordWeight / autoInject / hint)到消费侧形状(KnowledgeIngestOptions /
|
|
8
|
+
* KnowledgeRetrieverOptions)的转换只发生在这里。
|
|
9
|
+
*
|
|
10
|
+
* @module harness/knowledge/boot-config
|
|
11
|
+
*/
|
|
12
|
+
import type { KnowledgeRuntimeConfig } from '../../config.js';
|
|
13
|
+
import type { KnowledgeFileLimitsInput } from './file-limits.js';
|
|
14
|
+
/** Phase B 向量化调参(KnowledgeIngestOptions embed 子集 + 启用开关) */
|
|
15
|
+
export interface KnowledgeBootEmbed {
|
|
16
|
+
/** false = 纯关键词索引(不外发 embed);缺省 true */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
embedBatch?: number;
|
|
19
|
+
embedMinIntervalMs?: number;
|
|
20
|
+
embedConcurrency?: number;
|
|
21
|
+
embedSecretPolicy?: 'allow' | 'redact' | 'skip';
|
|
22
|
+
}
|
|
23
|
+
/** Ingest 调参(KnowledgeIngestOptions 子集) */
|
|
24
|
+
export interface KnowledgeBootIngest {
|
|
25
|
+
parseConcurrency?: number;
|
|
26
|
+
/** fs watch debounce ms */
|
|
27
|
+
debounceMs?: number;
|
|
28
|
+
/** 队列深度上限(超出只报警,不丢任务) */
|
|
29
|
+
maxQueueDepth?: number;
|
|
30
|
+
diskWatermarkAlert?: boolean;
|
|
31
|
+
fileLimits?: KnowledgeFileLimitsInput;
|
|
32
|
+
}
|
|
33
|
+
/** 检索调参(KnowledgeRetrieverOptions 子集) */
|
|
34
|
+
export interface KnowledgeBootRetriever {
|
|
35
|
+
hybridKeyword?: boolean;
|
|
36
|
+
keywordWeight?: number;
|
|
37
|
+
injectMinScore?: number;
|
|
38
|
+
hintMinScore?: number;
|
|
39
|
+
minCoverage?: number;
|
|
40
|
+
}
|
|
41
|
+
/** boot 文件里的调参块 */
|
|
42
|
+
export interface KnowledgeBootTuning {
|
|
43
|
+
embed?: KnowledgeBootEmbed;
|
|
44
|
+
ingest?: KnowledgeBootIngest;
|
|
45
|
+
retriever?: KnowledgeBootRetriever;
|
|
46
|
+
/** false = 索引稳定后不自动生成 generatedDescription(catalog.autoDescribe;仅 manageLocal) */
|
|
47
|
+
autoDescribe?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 把 `knowledge.*` 配置映射为 Service boot 调参块。
|
|
51
|
+
*
|
|
52
|
+
* @param kn - octopi.json 的 knowledge 段(undefined = 全默认)
|
|
53
|
+
* @returns 调参三块;未配置的键不出现在输出中(消费侧用各自默认值)
|
|
54
|
+
*/
|
|
55
|
+
export declare function knowledgeTuningFromConfig(kn?: KnowledgeRuntimeConfig | null): KnowledgeBootTuning;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** 去掉值为 undefined 的键,保证输出只含显式配置(可安全展开进选项对象) */
|
|
2
|
+
function definedOnly(obj) {
|
|
3
|
+
const out = {};
|
|
4
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
5
|
+
if (v !== undefined)
|
|
6
|
+
out[k] = v;
|
|
7
|
+
}
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 把 `knowledge.*` 配置映射为 Service boot 调参块。
|
|
12
|
+
*
|
|
13
|
+
* @param kn - octopi.json 的 knowledge 段(undefined = 全默认)
|
|
14
|
+
* @returns 调参三块;未配置的键不出现在输出中(消费侧用各自默认值)
|
|
15
|
+
*/
|
|
16
|
+
export function knowledgeTuningFromConfig(kn) {
|
|
17
|
+
if (!kn)
|
|
18
|
+
return {};
|
|
19
|
+
const tuning = {};
|
|
20
|
+
const embed = definedOnly({
|
|
21
|
+
enabled: kn.embed?.enabled,
|
|
22
|
+
embedBatch: kn.embed?.embedBatch,
|
|
23
|
+
embedMinIntervalMs: kn.embed?.embedMinIntervalMs,
|
|
24
|
+
embedConcurrency: kn.embed?.embedConcurrency,
|
|
25
|
+
embedSecretPolicy: kn.embed?.embedSecretPolicy,
|
|
26
|
+
});
|
|
27
|
+
if (Object.keys(embed).length > 0)
|
|
28
|
+
tuning.embed = embed;
|
|
29
|
+
const ingest = definedOnly({
|
|
30
|
+
parseConcurrency: kn.load?.parseConcurrency,
|
|
31
|
+
debounceMs: kn.load?.debounceMs,
|
|
32
|
+
maxQueueDepth: kn.index?.queue?.maxDepth,
|
|
33
|
+
diskWatermarkAlert: kn.load?.diskWatermarkAlert,
|
|
34
|
+
fileLimits: kn.index?.files,
|
|
35
|
+
});
|
|
36
|
+
if (Object.keys(ingest).length > 0)
|
|
37
|
+
tuning.ingest = ingest;
|
|
38
|
+
const retriever = definedOnly({
|
|
39
|
+
hybridKeyword: kn.index?.hybridKeyword,
|
|
40
|
+
keywordWeight: kn.keywordWeight,
|
|
41
|
+
injectMinScore: kn.autoInject?.minScore,
|
|
42
|
+
hintMinScore: kn.hint?.minScore,
|
|
43
|
+
minCoverage: kn.autoInject?.minCoverage,
|
|
44
|
+
});
|
|
45
|
+
if (Object.keys(retriever).length > 0)
|
|
46
|
+
tuning.retriever = retriever;
|
|
47
|
+
if (kn.catalog?.autoDescribe !== undefined)
|
|
48
|
+
tuning.autoDescribe = kn.catalog.autoDescribe;
|
|
49
|
+
return tuning;
|
|
50
|
+
}
|
|
@@ -17,6 +17,8 @@ export interface KnowledgeCatalogItem {
|
|
|
17
17
|
status?: string;
|
|
18
18
|
/** 一行用途说明(人工 description 或 generatedDescription) */
|
|
19
19
|
description?: string;
|
|
20
|
+
/** description 的生成方(信任分级 human > llm > heuristic);仅自动描述时存在 */
|
|
21
|
+
descriptionSource?: 'human' | 'llm' | 'heuristic';
|
|
20
22
|
/** global | project | session */
|
|
21
23
|
scopeLevel?: string;
|
|
22
24
|
/** 规模粗标,如 "~1.2k files" / "small" */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* KnowledgeClient — Gateway 侧 RPC(不打开 knowledge.db)
|
|
3
3
|
*/
|
|
4
|
+
import type { KnowledgeSourceKind } from './types.js';
|
|
4
5
|
export interface KnowledgeClientOptions {
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
token: string;
|
|
@@ -116,11 +117,32 @@ export declare class KnowledgeClient {
|
|
|
116
117
|
}>;
|
|
117
118
|
}>;
|
|
118
119
|
catalog(agentId: string): Promise<unknown[]>;
|
|
119
|
-
promotionCandidates(
|
|
120
|
-
|
|
120
|
+
promotionCandidates(opts?: {
|
|
121
|
+
minSessions?: number;
|
|
122
|
+
minHits?: number;
|
|
123
|
+
}): Promise<unknown[]>;
|
|
124
|
+
describeSource(sourceId: string, input?: {
|
|
125
|
+
description: string;
|
|
126
|
+
source?: 'llm' | 'heuristic';
|
|
127
|
+
}): Promise<{
|
|
121
128
|
generatedDescription: string;
|
|
122
129
|
source: string;
|
|
123
130
|
}>;
|
|
131
|
+
/** B 方案取素材(Service 侧密钥扫描把关;blocked=true 时无 sample) */
|
|
132
|
+
getDescribeSample(sourceId: string): Promise<{
|
|
133
|
+
blocked: false;
|
|
134
|
+
meta: {
|
|
135
|
+
displayName: string;
|
|
136
|
+
kind: KnowledgeSourceKind;
|
|
137
|
+
location: string;
|
|
138
|
+
};
|
|
139
|
+
sample: string;
|
|
140
|
+
} | {
|
|
141
|
+
blocked: true;
|
|
142
|
+
secretHits: string[];
|
|
143
|
+
}>;
|
|
144
|
+
/** 待 LLM 升级的源 id(boot sweep 用) */
|
|
145
|
+
listDescribePending(): Promise<string[]>;
|
|
124
146
|
listChunks(agentId: string, sourceId: string, path: string): Promise<Array<{
|
|
125
147
|
id: string;
|
|
126
148
|
text: string;
|
|
@@ -161,11 +161,25 @@ export class KnowledgeClient {
|
|
|
161
161
|
catalog(agentId) {
|
|
162
162
|
return this.request('GET', `/v1/principals/${encodeURIComponent(agentId)}/catalog`, undefined, undefined, { read: true });
|
|
163
163
|
}
|
|
164
|
-
promotionCandidates() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
promotionCandidates(opts) {
|
|
165
|
+
const qs = new URLSearchParams();
|
|
166
|
+
if (opts?.minSessions != null)
|
|
167
|
+
qs.set('minSessions', String(opts.minSessions));
|
|
168
|
+
if (opts?.minHits != null)
|
|
169
|
+
qs.set('minHits', String(opts.minHits));
|
|
170
|
+
const search = qs.toString();
|
|
171
|
+
return this.request('GET', `/v1/promotion-candidates${search ? `?${search}` : ''}`, undefined, undefined, { read: true });
|
|
172
|
+
}
|
|
173
|
+
describeSource(sourceId, input) {
|
|
174
|
+
return this.request('POST', `/v1/sources/${encodeURIComponent(sourceId)}/describe`, input);
|
|
175
|
+
}
|
|
176
|
+
/** B 方案取素材(Service 侧密钥扫描把关;blocked=true 时无 sample) */
|
|
177
|
+
getDescribeSample(sourceId) {
|
|
178
|
+
return this.request('GET', `/v1/sources/${encodeURIComponent(sourceId)}/describe-sample`, undefined, undefined, { read: true });
|
|
179
|
+
}
|
|
180
|
+
/** 待 LLM 升级的源 id(boot sweep 用) */
|
|
181
|
+
listDescribePending() {
|
|
182
|
+
return this.request('GET', '/v1/describe-pending', undefined, undefined, { read: true });
|
|
169
183
|
}
|
|
170
184
|
listChunks(agentId, sourceId, path) {
|
|
171
185
|
const qs = new URLSearchParams({ sourceId, path });
|
|
@@ -138,6 +138,7 @@ export class KnowledgeDatabase {
|
|
|
138
138
|
display_name TEXT NOT NULL,
|
|
139
139
|
description TEXT,
|
|
140
140
|
generated_description TEXT,
|
|
141
|
+
generated_description_source TEXT,
|
|
141
142
|
catalog_priority INTEGER,
|
|
142
143
|
hidden_from_catalog INTEGER NOT NULL DEFAULT 0,
|
|
143
144
|
last_polled_at INTEGER,
|
|
@@ -267,6 +268,10 @@ export class KnowledgeDatabase {
|
|
|
267
268
|
{ name: 'discover_json', ddl: `discover_json TEXT` },
|
|
268
269
|
{ name: 'auth_ref', ddl: `auth_ref TEXT` },
|
|
269
270
|
{ name: 'last_polled_at', ddl: `last_polled_at INTEGER` },
|
|
271
|
+
{
|
|
272
|
+
name: 'generated_description_source',
|
|
273
|
+
ddl: `generated_description_source TEXT`,
|
|
274
|
+
},
|
|
270
275
|
]);
|
|
271
276
|
alterIfMissing('knowledge_projects', [
|
|
272
277
|
{ name: 'tenant_id', ddl: `tenant_id TEXT NOT NULL DEFAULT 'default'` },
|