@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
|
@@ -1,498 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - 能力注册和查询
|
|
8
|
-
*
|
|
9
|
-
* Hook 分类:
|
|
10
|
-
* - 拦截语义:返回值改变执行流程
|
|
11
|
-
* - 观察语义:所有 plugin 都执行
|
|
12
|
-
* - 上下文注入:返回 prependContext / systemPrompt 等
|
|
13
|
-
*/
|
|
14
|
-
import type { Message, ToolCall, ToolResult, ThinkingLevel } from '@octopi-agent/core/types.js';
|
|
15
|
-
import type { ChannelAdapter, ChannelMessage, ChannelReply } from '../channel-types.js';
|
|
16
|
-
import type { HookContext } from '../../../shared/types/hook-context.js';
|
|
17
|
-
import type { ContextEngine } from '../../../context/types.js';
|
|
18
|
-
import type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig } from './loader.js';
|
|
19
|
-
import { CapabilityRegistry } from './capability.js';
|
|
20
|
-
/**
|
|
21
|
-
* before_model_resolve 事件
|
|
22
|
-
*/
|
|
23
|
-
export interface BeforeModelResolveEvent {
|
|
24
|
-
/** 当前 prompt */
|
|
25
|
-
prompt: string;
|
|
26
|
-
/** 上下文 */
|
|
27
|
-
ctx: HookContext;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* agent_turn_prepare 事件
|
|
31
|
-
*/
|
|
32
|
-
export interface AgentTurnPrepareEvent {
|
|
33
|
-
/** 当前 prompt */
|
|
34
|
-
prompt: string;
|
|
35
|
-
/** Session 消息 */
|
|
36
|
-
messages: Message[];
|
|
37
|
-
/** 上下文 */
|
|
38
|
-
ctx: HookContext;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* before_prompt_build 事件
|
|
42
|
-
*/
|
|
43
|
-
export interface BeforePromptBuildEvent {
|
|
44
|
-
/** 当前 prompt */
|
|
45
|
-
prompt: string;
|
|
46
|
-
/** Session 消息 */
|
|
47
|
-
messages: Message[];
|
|
48
|
-
/** 上下文 */
|
|
49
|
-
ctx: HookContext;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* before_agent_run 事件
|
|
53
|
-
*/
|
|
54
|
-
export interface BeforeAgentRunEvent {
|
|
55
|
-
/** 当前 prompt */
|
|
56
|
-
prompt: string;
|
|
57
|
-
/** 最终消息列表 */
|
|
58
|
-
messages: Message[];
|
|
59
|
-
/** System prompt */
|
|
60
|
-
systemPrompt?: string;
|
|
61
|
-
/** 上下文 */
|
|
62
|
-
ctx: HookContext;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* before_agent_reply 事件
|
|
66
|
-
*/
|
|
67
|
-
export interface BeforeAgentReplyEvent {
|
|
68
|
-
/** Session 消息 */
|
|
69
|
-
messages: Message[];
|
|
70
|
-
/** 上下文 */
|
|
71
|
-
ctx: HookContext;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* before_agent_finalize 事件
|
|
75
|
-
*/
|
|
76
|
-
export interface BeforeAgentFinalizeEvent {
|
|
77
|
-
/** Agent 的自然回复 */
|
|
78
|
-
reply: Message;
|
|
79
|
-
/** 上下文 */
|
|
80
|
-
ctx: HookContext;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* agent_end 事件
|
|
84
|
-
*/
|
|
85
|
-
export interface AgentEndEvent {
|
|
86
|
-
/** 最终消息 */
|
|
87
|
-
messages: Message[];
|
|
88
|
-
/** 是否成功 */
|
|
89
|
-
success: boolean;
|
|
90
|
-
/** 执行耗时 */
|
|
91
|
-
durationMs: number;
|
|
92
|
-
/** 上下文 */
|
|
93
|
-
ctx: HookContext;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* before_tool_call 事件
|
|
97
|
-
*/
|
|
98
|
-
export interface BeforeToolCallEvent {
|
|
99
|
-
/** Tool 名称 */
|
|
100
|
-
toolName: string;
|
|
101
|
-
/** Tool 参数 */
|
|
102
|
-
params: Record<string, unknown>;
|
|
103
|
-
/** Tool 调用信息 */
|
|
104
|
-
call: ToolCall;
|
|
105
|
-
/** 上下文 */
|
|
106
|
-
ctx: HookContext;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* after_tool_call 事件
|
|
110
|
-
*/
|
|
111
|
-
export interface AfterToolCallEvent {
|
|
112
|
-
/** Tool 调用信息 */
|
|
113
|
-
call: ToolCall;
|
|
114
|
-
/** Tool 结果 */
|
|
115
|
-
result: ToolResult;
|
|
116
|
-
/** 上下文 */
|
|
117
|
-
ctx: HookContext;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* message_received 事件
|
|
121
|
-
*/
|
|
122
|
-
export interface MessageReceivedEvent {
|
|
123
|
-
/** 渠道消息 */
|
|
124
|
-
message: ChannelMessage;
|
|
125
|
-
/** 上下文 */
|
|
126
|
-
ctx: HookContext;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* message_sending 事件
|
|
130
|
-
*/
|
|
131
|
-
export interface MessageSendingEvent {
|
|
132
|
-
/** 回复内容 */
|
|
133
|
-
reply: ChannelReply;
|
|
134
|
-
/** 上下文 */
|
|
135
|
-
ctx: HookContext;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* message_sent 事件
|
|
139
|
-
*/
|
|
140
|
-
export interface MessageSentEvent {
|
|
141
|
-
/** 回复内容 */
|
|
142
|
-
reply: ChannelReply;
|
|
143
|
-
/** 是否成功 */
|
|
144
|
-
success: boolean;
|
|
145
|
-
/** 上下文 */
|
|
146
|
-
ctx: HookContext;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* session_start / session_end 事件
|
|
150
|
-
*/
|
|
151
|
-
export interface SessionLifecycleEvent {
|
|
152
|
-
/** Session ID */
|
|
153
|
-
sessionId: string;
|
|
154
|
-
/** Agent ID */
|
|
155
|
-
agentId: string;
|
|
156
|
-
/** 原因 */
|
|
157
|
-
reason?: string;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* before_compaction / after_compaction 事件
|
|
161
|
-
*/
|
|
162
|
-
export interface CompactionEvent {
|
|
163
|
-
/** Session ID */
|
|
164
|
-
sessionId: string;
|
|
165
|
-
/** 是否实际执行了压缩 */
|
|
166
|
-
compacted: boolean;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* gateway_start / gateway_stop 事件
|
|
170
|
-
*/
|
|
171
|
-
export interface GatewayLifecycleEvent extends Record<string, unknown> {
|
|
172
|
-
/** 配置 */
|
|
173
|
-
config?: Record<string, unknown>;
|
|
174
|
-
/** 工作区目录 */
|
|
175
|
-
workspaceDir?: string;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* before_install 事件
|
|
179
|
-
*/
|
|
180
|
-
export interface BeforeInstallEvent {
|
|
181
|
-
/** 安装类型 */
|
|
182
|
-
type: 'skill' | 'plugin';
|
|
183
|
-
/** 安装源 */
|
|
184
|
-
source: string;
|
|
185
|
-
/** 安装目标 */
|
|
186
|
-
target: string;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* before_iteration 事件
|
|
190
|
-
*
|
|
191
|
-
* 每次 LLM 调用前触发(per-iteration)。
|
|
192
|
-
* 这是 Octopi 独有的迭代级 hook。
|
|
193
|
-
*/
|
|
194
|
-
export interface BeforeIterationEvent {
|
|
195
|
-
/** 当前迭代索引(从 0 开始) */
|
|
196
|
-
iteration: number;
|
|
197
|
-
/** 当前消息历史 */
|
|
198
|
-
messages: Message[];
|
|
199
|
-
/** 当前模型 */
|
|
200
|
-
model: string;
|
|
201
|
-
/** 当前 thinking 级别 */
|
|
202
|
-
thinking?: ThinkingLevel;
|
|
203
|
-
/** Session ID */
|
|
204
|
-
sessionId: string;
|
|
205
|
-
/** 上下文 */
|
|
206
|
-
ctx: HookContext;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* before_iteration 结果
|
|
210
|
-
*
|
|
211
|
-
* 返回 null/undefined 表示不干预,
|
|
212
|
-
* 返回对象可以覆盖本轮配置或停止循环。
|
|
213
|
-
*/
|
|
214
|
-
export interface BeforeIterationResult {
|
|
215
|
-
/** 覆盖本轮模型 */
|
|
216
|
-
model?: string;
|
|
217
|
-
/** 覆盖本轮 thinking 级别 */
|
|
218
|
-
thinking?: ThinkingLevel;
|
|
219
|
-
/** 注入到本轮 system prompt 的上下文 */
|
|
220
|
-
prependContext?: string;
|
|
221
|
-
/** 停止循环 */
|
|
222
|
-
stop?: boolean;
|
|
223
|
-
/** 停止原因 */
|
|
224
|
-
stopReason?: string;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* after_iteration 事件
|
|
228
|
-
*
|
|
229
|
-
* 每次 LLM 调用 + 工具执行完成后触发(per-iteration)。
|
|
230
|
-
* 这是 Octopi 独有的迭代级 hook。
|
|
231
|
-
*/
|
|
232
|
-
export interface AfterIterationEvent {
|
|
233
|
-
/** 当前迭代索引 */
|
|
234
|
-
iteration: number;
|
|
235
|
-
/** Assistant 回复 */
|
|
236
|
-
assistantMessage: Message;
|
|
237
|
-
/** 本轮工具调用 */
|
|
238
|
-
toolCalls: ToolCall[];
|
|
239
|
-
/** 本轮工具结果 */
|
|
240
|
-
toolResults: ToolResult[];
|
|
241
|
-
/** Token 用量 */
|
|
242
|
-
usage?: import('@octopi-agent/core/types/turn.js').TokenUsage;
|
|
243
|
-
/** Session ID */
|
|
244
|
-
sessionId: string;
|
|
245
|
-
/** 上下文 */
|
|
246
|
-
ctx: HookContext;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* loop_end 事件
|
|
250
|
-
*
|
|
251
|
-
* 循环结束时触发(per-message)。
|
|
252
|
-
*/
|
|
253
|
-
export interface LoopEndEvent {
|
|
254
|
-
/** 总迭代数 */
|
|
255
|
-
iterations: number;
|
|
256
|
-
/** 最终消息历史 */
|
|
257
|
-
messages: Message[];
|
|
258
|
-
/** 结束原因 */
|
|
259
|
-
reason: string;
|
|
260
|
-
/** 最终响应 */
|
|
261
|
-
response?: string;
|
|
262
|
-
/** 是否成功 */
|
|
263
|
-
success: boolean;
|
|
264
|
-
/** Session ID */
|
|
265
|
-
sessionId: string;
|
|
266
|
-
/** 上下文 */
|
|
267
|
-
ctx: HookContext;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* before_model_resolve 结果
|
|
271
|
-
*/
|
|
272
|
-
export interface ModelResolveResult {
|
|
273
|
-
/** 覆盖 provider */
|
|
274
|
-
provider?: string;
|
|
275
|
-
/** 覆盖 model */
|
|
276
|
-
model?: string;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* before_prompt_build 结果
|
|
280
|
-
*/
|
|
281
|
-
export interface PromptBuildResult {
|
|
282
|
-
/** 在消息前插入的上下文 */
|
|
283
|
-
prependContext?: string;
|
|
284
|
-
/** 在消息后追加的上下文 */
|
|
285
|
-
appendContext?: string;
|
|
286
|
-
/** 覆盖 system prompt */
|
|
287
|
-
systemPrompt?: string;
|
|
288
|
-
/** System prompt 前置追加 */
|
|
289
|
-
prependSystemContext?: string;
|
|
290
|
-
/** System prompt 后置追加 */
|
|
291
|
-
appendSystemContext?: string;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* before_agent_run 结果
|
|
295
|
-
*/
|
|
296
|
-
export interface AgentRunResult {
|
|
297
|
-
/** 结果类型 */
|
|
298
|
-
outcome: 'pass' | 'block';
|
|
299
|
-
/** 阻止原因(内部) */
|
|
300
|
-
reason?: string;
|
|
301
|
-
/** 用户可见的替换消息 */
|
|
302
|
-
message?: string;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* before_agent_reply 结果
|
|
306
|
-
*/
|
|
307
|
-
export type AgentReplyResult = Message | null;
|
|
308
|
-
/**
|
|
309
|
-
* before_agent_finalize 结果
|
|
310
|
-
*/
|
|
311
|
-
export interface AgentFinalizeResult {
|
|
312
|
-
/** 动作 */
|
|
313
|
-
action: 'revise' | 'finalize';
|
|
314
|
-
/** 修订原因 */
|
|
315
|
-
reason?: string;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* before_tool_call 结果
|
|
319
|
-
*/
|
|
320
|
-
export interface ToolCallResult {
|
|
321
|
-
/** 覆盖参数 */
|
|
322
|
-
params?: Record<string, unknown>;
|
|
323
|
-
/** 是否阻止执行 */
|
|
324
|
-
block?: boolean;
|
|
325
|
-
/** 阻止原因 */
|
|
326
|
-
blockReason?: string;
|
|
327
|
-
/** 需要用户审批 */
|
|
328
|
-
requireApproval?: {
|
|
329
|
-
title: string;
|
|
330
|
-
description: string;
|
|
331
|
-
severity?: 'info' | 'warning' | 'critical';
|
|
332
|
-
timeoutMs?: number;
|
|
333
|
-
timeoutBehavior?: 'allow' | 'deny';
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* message_sending 结果
|
|
338
|
-
*/
|
|
339
|
-
export interface MessageSendingResult {
|
|
340
|
-
/** 是否取消发送 */
|
|
341
|
-
cancel: boolean;
|
|
342
|
-
/** 取消原因 */
|
|
343
|
-
cancelReason?: string;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* before_install 结果
|
|
347
|
-
*/
|
|
348
|
-
export interface InstallResult {
|
|
349
|
-
/** 是否阻止安装 */
|
|
350
|
-
block: boolean;
|
|
351
|
-
/** 阻止原因 */
|
|
352
|
-
blockReason?: string;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Plugin Manager
|
|
356
|
-
*
|
|
357
|
-
* 负责加载 plugins、运行 hooks、管理能力注册。
|
|
358
|
-
*/
|
|
1
|
+
import type { PluginLoaderConfig, LoadedPlugin, PluginDiagnostic } from './loader.js';
|
|
2
|
+
import type { PluginCommandRecord, PluginToolRecord, PluginServiceRecord } from './contribution-registry.js';
|
|
3
|
+
import { HookAuditJournal } from '../hooks/journal.js';
|
|
4
|
+
import { type HitlAskResult } from '../../../governance/human-in-the-loop/decision-cache.js';
|
|
5
|
+
import type { ExtensionHookPort, HookToolApproval, HookToolEvent } from '../hooks/types.js';
|
|
6
|
+
/** Host-owned manager; the author SDK never receives this object. */
|
|
359
7
|
export declare class PluginManager {
|
|
360
|
-
/** Plugin Loader */
|
|
361
8
|
private loader;
|
|
362
|
-
|
|
363
|
-
readonly
|
|
364
|
-
|
|
365
|
-
private startTime?;
|
|
9
|
+
private readonly hookJournal;
|
|
10
|
+
private readonly hookPort;
|
|
11
|
+
private approvalSink?;
|
|
366
12
|
constructor(config?: PluginLoaderConfig);
|
|
367
|
-
|
|
368
|
-
* 发现并加载所有 plugins
|
|
369
|
-
*/
|
|
13
|
+
getDiagnostics(): PluginDiagnostic[];
|
|
370
14
|
discover(): Promise<LoadedPlugin[]>;
|
|
371
|
-
/**
|
|
372
|
-
* 获取所有已加载的 plugins
|
|
373
|
-
*/
|
|
374
15
|
getAllPlugins(): LoadedPlugin[];
|
|
375
|
-
/**
|
|
376
|
-
* 获取已注册的 plugin IDs
|
|
377
|
-
*/
|
|
378
16
|
getRegisteredIds(): string[];
|
|
379
|
-
/**
|
|
380
|
-
* 获取指定 plugin
|
|
381
|
-
*/
|
|
382
17
|
getPlugin(id: string): LoadedPlugin | undefined;
|
|
383
|
-
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
* @returns 最终结果
|
|
397
|
-
*/
|
|
398
|
-
runHook<T>(hookName: string, event: Record<string, unknown>, defaultResult: T, config?: PluginEntryConfig): Promise<T>;
|
|
399
|
-
/**
|
|
400
|
-
* 执行观察语义的 hook(所有 plugin 都执行,不拦截)
|
|
401
|
-
*/
|
|
402
|
-
runAllHooks(hookName: string, event: Record<string, unknown>): Promise<void>;
|
|
403
|
-
/**
|
|
404
|
-
* 收集指定 hook 的所有 handler entries
|
|
405
|
-
*/
|
|
406
|
-
private collectHookEntries;
|
|
407
|
-
/**
|
|
408
|
-
* 带超时执行
|
|
409
|
-
*/
|
|
410
|
-
private runWithTimeout;
|
|
411
|
-
/**
|
|
412
|
-
* 获取所有已注册的 providers
|
|
413
|
-
*/
|
|
414
|
-
getProviders(): Array<{
|
|
415
|
-
pluginId: string;
|
|
416
|
-
id: string;
|
|
417
|
-
provider: import('@octopi-agent/core/interfaces/model-provider.js').ModelProvider;
|
|
418
|
-
}>;
|
|
419
|
-
/**
|
|
420
|
-
* 获取所有已注册的 channels
|
|
421
|
-
*/
|
|
422
|
-
getChannels(): Array<{
|
|
423
|
-
pluginId: string;
|
|
424
|
-
id: string;
|
|
425
|
-
adapter: ChannelAdapter;
|
|
426
|
-
}>;
|
|
427
|
-
/**
|
|
428
|
-
* 获取所有已注册的 tools(过滤 optional)
|
|
429
|
-
*/
|
|
430
|
-
getTools(includeOptional?: boolean): Array<{
|
|
431
|
-
pluginId: string;
|
|
432
|
-
definition: import('@octopi-agent/core/types.js').ToolDefinition;
|
|
433
|
-
handler: import('@octopi-agent/core/types.js').ToolHandler;
|
|
434
|
-
}>;
|
|
435
|
-
/**
|
|
436
|
-
* 获取所有已注册的 context engines
|
|
437
|
-
*/
|
|
438
|
-
getContextEngines(): Array<{
|
|
439
|
-
id: string;
|
|
440
|
-
engine: ContextEngine;
|
|
441
|
-
}>;
|
|
442
|
-
/**
|
|
443
|
-
* 获取所有已注册的 commands
|
|
444
|
-
*/
|
|
445
|
-
getCommands(): Array<{
|
|
446
|
-
pluginId: string;
|
|
447
|
-
name: string;
|
|
448
|
-
handler: (event: unknown) => Promise<unknown>;
|
|
449
|
-
description?: string;
|
|
450
|
-
}>;
|
|
451
|
-
/**
|
|
452
|
-
* 获取所有已注册的 services
|
|
453
|
-
*/
|
|
454
|
-
getServices(): Array<{
|
|
455
|
-
pluginId: string;
|
|
456
|
-
id: string;
|
|
457
|
-
start: () => Promise<void>;
|
|
458
|
-
stop: () => Promise<void>;
|
|
459
|
-
}>;
|
|
460
|
-
/**
|
|
461
|
-
* 获取所有已注册的 web search providers
|
|
462
|
-
*/
|
|
463
|
-
getWebSearchProviders(): Array<{
|
|
464
|
-
pluginId: string;
|
|
465
|
-
provider: import('../tools/web-search-types.js').WebSearchProvider;
|
|
466
|
-
}>;
|
|
467
|
-
/**
|
|
468
|
-
* 获取所有已注册的 media understanding providers
|
|
469
|
-
*/
|
|
470
|
-
getMediaUnderstandingProviders(): Array<{
|
|
471
|
-
pluginId: string;
|
|
472
|
-
provider: unknown;
|
|
473
|
-
}>;
|
|
474
|
-
/**
|
|
475
|
-
* 获取所有已注册的 image generation providers
|
|
476
|
-
*/
|
|
477
|
-
getImageGenerationProviders(): Array<{
|
|
478
|
-
pluginId: string;
|
|
479
|
-
provider: unknown;
|
|
480
|
-
}>;
|
|
481
|
-
/**
|
|
482
|
-
* 获取所有已注册的 model catalog providers
|
|
483
|
-
*/
|
|
484
|
-
getModelCatalogProviders(): Array<{
|
|
485
|
-
pluginId: string;
|
|
486
|
-
provider: string;
|
|
487
|
-
kinds: string[];
|
|
488
|
-
liveCatalog: unknown;
|
|
489
|
-
}>;
|
|
490
|
-
/**
|
|
491
|
-
* 触发 gateway_start hook 并启动所有 plugin 服务
|
|
492
|
-
*/
|
|
493
|
-
onGatewayStart(config?: Record<string, unknown>, workspaceDir?: string): Promise<void>;
|
|
494
|
-
/**
|
|
495
|
-
* 触发 gateway_stop hook 并停止所有 plugin 服务
|
|
496
|
-
*/
|
|
497
|
-
onGatewayStop(): Promise<void>;
|
|
18
|
+
/** Narrow interception Port for Harness/Gateway consumers, not the whole Manager. */
|
|
19
|
+
getHookPort(): ExtensionHookPort;
|
|
20
|
+
/** Shared append-only audit sink for Host service lifecycle records. */
|
|
21
|
+
getHookAudit(): HookAuditJournal;
|
|
22
|
+
/** Install the Host's existing high-risk HITL channel; no channel fails closed. */
|
|
23
|
+
setToolApprovalSink(sink: (event: HookToolEvent, request: Readonly<HookToolApproval>) => Promise<HitlAskResult>): void;
|
|
24
|
+
getTools(includeOptional?: boolean): PluginToolRecord[];
|
|
25
|
+
getCommands(): PluginCommandRecord[];
|
|
26
|
+
getServices(): PluginServiceRecord[];
|
|
27
|
+
getCommandSessionOps(pluginId: string, name: string): PluginCommandRecord['sessionOps'] | undefined;
|
|
28
|
+
private getHookConfig;
|
|
29
|
+
private recordHook;
|
|
30
|
+
private approveToolCall;
|
|
498
31
|
}
|