@octopi-agent/engine 0.102.10 → 0.121.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/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/console-access-key.d.ts +46 -0
- package/dist/config-admin/console-access-key.js +47 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +8 -2
- package/dist/config-admin/index.js +4 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +83 -0
- package/dist/config-admin/onboarding-apply.js +259 -0
- package/dist/config-admin/onboarding.d.ts +160 -0
- package/dist/config-admin/onboarding.js +298 -0
- package/dist/config-admin/password-policy.d.ts +24 -0
- package/dist/config-admin/password-policy.js +31 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +5 -1
- package/dist/config-schema/agent.js +20 -2
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +7 -2
- package/dist/config-schema/context.js +6 -3
- package/dist/config-schema/engine.d.ts +86 -7
- package/dist/config-schema/engine.js +9 -2
- package/dist/config-schema/governance.d.ts +12 -1
- package/dist/config-schema/governance.js +10 -2
- package/dist/config-schema/models.d.ts +12 -8
- package/dist/config-schema/models.js +16 -1
- package/dist/config-schema/run.d.ts +4 -0
- package/dist/config-schema/run.js +10 -0
- package/dist/config-schema/shared.d.ts +1 -0
- package/dist/config-schema/shared.js +4 -2
- package/dist/config-schema/substrate.d.ts +5 -0
- package/dist/config-schema/substrate.js +8 -0
- package/dist/config.d.ts +116 -10
- package/dist/config.js +109 -13
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +4 -0
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +119 -28
- package/dist/harness/activation/types.d.ts +19 -2
- package/dist/harness/agent/builder.d.ts +12 -0
- package/dist/harness/agent/builder.js +78 -22
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +15 -3
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +2 -0
- package/dist/harness/agent/wire-agent-builder.js +9 -2
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +13 -3
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +48 -39
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -0
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +4 -0
- package/dist/harness/collaboration/delegation/child-run.d.ts +9 -0
- package/dist/harness/collaboration/delegation/child-run.js +34 -2
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +9 -4
- package/dist/harness/collaboration/delegation/service.js +33 -12
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +1 -0
- package/dist/harness/collaboration/delegation/types.d.ts +11 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +1 -0
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -5
- package/dist/harness/context/capabilities/compact/engine.js +127 -39
- package/dist/harness/context/capabilities/compact/index.d.ts +2 -1
- package/dist/harness/context/capabilities/compact/index.js +1 -1
- package/dist/harness/context/capabilities/compact/types.d.ts +59 -9
- package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +16 -0
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.js +8 -1
- package/dist/harness/context/default-context-engine.d.ts +100 -6
- package/dist/harness/context/default-context-engine.js +382 -89
- package/dist/harness/context/index.d.ts +2 -1
- package/dist/harness/context/index.js +1 -0
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +57 -0
- package/dist/harness/context/layer-types.js +73 -1
- package/dist/harness/context/layers.d.ts +3 -0
- package/dist/harness/context/layers.js +13 -6
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.js +18 -0
- package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
- package/dist/harness/context/system-prompt-assembler.js +5 -2
- package/dist/harness/context/tool-result-aging.d.ts +104 -16
- package/dist/harness/context/tool-result-aging.js +211 -57
- package/dist/harness/context/types.d.ts +71 -4
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +27 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +168 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +156 -15
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +40 -5
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +45 -26
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +42 -76
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +30 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +46 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +19 -14
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +10 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- package/dist/harness/governance/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- package/dist/harness/governance/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +5 -3
- package/dist/harness/index.js +2 -2
- package/dist/harness/knowledge/boot-config.d.ts +2 -0
- package/dist/harness/knowledge/boot-config.js +2 -0
- package/dist/harness/knowledge/client.d.ts +53 -7
- package/dist/harness/knowledge/client.js +77 -20
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +107 -41
- package/dist/harness/knowledge/engine-thread.js +5 -7
- package/dist/harness/knowledge/grounding.js +4 -1
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +82 -21
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +2 -3
- package/dist/harness/knowledge/query-service.d.ts +12 -2
- package/dist/harness/knowledge/query-service.js +75 -41
- package/dist/harness/knowledge/query-worker-client.d.ts +5 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -1
- package/dist/harness/knowledge/query-worker.js +5 -3
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +9 -2
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +6 -1
- package/dist/harness/knowledge/serve.js +5 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +297 -71
- package/dist/harness/knowledge/start-service-process.d.ts +27 -8
- package/dist/harness/knowledge/start-service-process.js +49 -90
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/writer-service.d.ts +18 -2
- package/dist/harness/knowledge/writer-service.js +80 -16
- package/dist/harness/knowledge/writer-worker-client.d.ts +9 -2
- package/dist/harness/knowledge/writer-worker-client.js +20 -3
- package/dist/harness/knowledge/writer-worker.js +11 -4
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/types.d.ts +18 -2
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +95 -2
- package/dist/harness/run/agent/agent.js +3 -2
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/reliability/run-agent.d.ts +22 -0
- package/dist/harness/run/reliability/run-agent.js +79 -10
- package/dist/harness/run/run-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +11 -0
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +149 -22
- package/dist/harness/run/runner.js +352 -35
- package/dist/harness/session/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -0
- package/dist/harness/session/types.d.ts +10 -14
- package/dist/harness/shared/events/agent-event-map.d.ts +29 -0
- package/dist/harness/shared/types/agent-definition.d.ts +6 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +27 -2
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +41 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +56 -2
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +14 -2
- package/dist/integration/storage/archive-manager.js +24 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +9 -0
- package/dist/integration/storage/jsonl.js +137 -38
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +3 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +5 -3
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
7
7
|
import type { AgentEvent } from '@octopi-agent/core/primitives/event-bus.js';
|
|
8
|
+
import type { SessionRights } from '../governance/session-acl/types.js';
|
|
8
9
|
export type TriggerType = 'message' | 'schedule' | 'event' | 'escalate' | 'agent_signal' | 'manual';
|
|
9
10
|
export type TriggerPayload = {
|
|
10
11
|
kind: 'user_message';
|
|
@@ -26,6 +27,8 @@ export interface Trigger {
|
|
|
26
27
|
agentId?: string;
|
|
27
28
|
toAgents?: string[];
|
|
28
29
|
sessionId?: string;
|
|
30
|
+
/** 触发源归属租户(§9.1-6:渠道锚/租户会话创建方);合入 run principal,缺省锚 agent 归属 */
|
|
31
|
+
tenantId?: string;
|
|
29
32
|
/** 来源端时间戳;缺省用 dispatch 时刻 */
|
|
30
33
|
timestamp?: number;
|
|
31
34
|
payload: TriggerPayload;
|
|
@@ -75,6 +78,13 @@ export interface RunRequest {
|
|
|
75
78
|
modelOverride?: string;
|
|
76
79
|
/** modelOverride 为裸名时的 provider */
|
|
77
80
|
modelProvider?: string;
|
|
81
|
+
/**
|
|
82
|
+
* per-run systemPrompt 覆盖(委派子 run:模板 persona + 编排指令,delegation §9.4)。
|
|
83
|
+
* 显式值覆盖挂载默认;缺省沿用挂载体 defaults。
|
|
84
|
+
*/
|
|
85
|
+
systemPrompt?: string;
|
|
86
|
+
/** per-run 权利天花板(D3:只能收紧不能放宽;Runner 与模板天花板取交集) */
|
|
87
|
+
rightsCeiling?: SessionRights;
|
|
78
88
|
/** Principal / Intent 字段位(宪法 I6);宿主填充,引擎不做权限 NLU */
|
|
79
89
|
actorId?: string;
|
|
80
90
|
actorType?: 'host' | 'user' | 'agent' | 'service' | 'timer' | 'subsystem';
|
|
@@ -97,7 +107,8 @@ export interface RunDispatcher {
|
|
|
97
107
|
execute(req: RunRequest, signal?: AbortSignal): AsyncIterable<AgentEvent>;
|
|
98
108
|
/** 可选:活跃 Run 接续;缺省保持原 Trigger 排队语义。 */
|
|
99
109
|
inbox?: {
|
|
100
|
-
|
|
110
|
+
/** 本地 SessionInbox 同步返回;跨进程代理返回 Promise(远程 inboxOffer op)。 */
|
|
111
|
+
offer(signal: import('./inbox.js').SessionInboxSignal): import('./inbox.js').InboxOfferResult | Promise<import('./inbox.js').InboxOfferResult>;
|
|
101
112
|
};
|
|
102
113
|
}
|
|
103
114
|
/** dispatch 调用方选项 */
|
|
@@ -143,13 +154,19 @@ export type DispatchResult = {
|
|
|
143
154
|
status: 'accepted';
|
|
144
155
|
agentId: string;
|
|
145
156
|
sessionId: string;
|
|
146
|
-
|
|
157
|
+
/**
|
|
158
|
+
* continued = 活跃 Run 接收续接;duplicate = 同 id 已受理/已入上下文
|
|
159
|
+
* (at-least-once 重投的去重出口),不重复执行、不重复回答。
|
|
160
|
+
*/
|
|
161
|
+
delivery: 'continued' | 'duplicate';
|
|
147
162
|
} | {
|
|
148
163
|
status: 'skipped';
|
|
149
164
|
reason: 'no_agent' | 'filtered' | 'runtime_stopped' | 'aborted';
|
|
150
165
|
} | {
|
|
151
166
|
status: 'failed';
|
|
152
167
|
error: string;
|
|
168
|
+
/** lease_held 延迟重投已排程:本次拒可见,回答稍后经随行 onEvent 补达 */
|
|
169
|
+
retryScheduled?: boolean;
|
|
153
170
|
};
|
|
154
171
|
/** fan-out 聚合结果(toAgents 长度 > 1 时由 dispatch 返回) */
|
|
155
172
|
export type FanoutDispatchResult = {
|
|
@@ -139,6 +139,14 @@ export interface AgentBuildResult {
|
|
|
139
139
|
registerTools: (tools: RegisteredTool[]) => void;
|
|
140
140
|
/** ContextEngine 实例(手动压缩入口) */
|
|
141
141
|
contextEngine?: import('../context/types.js').ContextEngine;
|
|
142
|
+
/**
|
|
143
|
+
* 脉搏注册表(P0c A′):本 agent 声明的全部周期任务(key 已带 agentId 前缀、实例内唯一)。
|
|
144
|
+
* run 宿主聚合为实例级 PulseSpec 自述给 gateway 脉搏调度器;fire 为进程内驱动入口。
|
|
145
|
+
*/
|
|
146
|
+
pulses: Array<{
|
|
147
|
+
spec: import('../activation/run-protocol.js').PulseSpec;
|
|
148
|
+
fire: () => Promise<unknown>;
|
|
149
|
+
}>;
|
|
142
150
|
contextHealth: (agentId?: string) => Promise<import('../context/layer-health.js').ContextLayerHealth>;
|
|
143
151
|
}
|
|
144
152
|
/** 缺省子系统搜索并加载 spec(供 build 自动发现与 serve 启动日志共用) */
|
|
@@ -245,6 +253,8 @@ export declare class AgentBuilder {
|
|
|
245
253
|
private _agentHome?;
|
|
246
254
|
/** 逻辑 agentId(观测 / 子系统审计用) */
|
|
247
255
|
private _agentId?;
|
|
256
|
+
/** 归属租户(arch/multi-tenancy.md §4):audit 打标 / 家当派生域;缺省 = DEFAULT_TENANT_ID 语义 */
|
|
257
|
+
private _tenantId?;
|
|
248
258
|
/** Deferred until build so .pluginTools() and .agentId() order is immaterial. */
|
|
249
259
|
private _pluginToolRecords;
|
|
250
260
|
/** 设置模型提供者 */
|
|
@@ -474,6 +484,8 @@ export declare class AgentBuilder {
|
|
|
474
484
|
agentHome(dir: string): this;
|
|
475
485
|
/** 逻辑 agentId(extract pending 扫描 / 观测) */
|
|
476
486
|
agentId(id: string): this;
|
|
487
|
+
/** 归属租户(audit 打标 / 家当派生域;arch/multi-tenancy.md §4) */
|
|
488
|
+
tenantId(id: string): this;
|
|
477
489
|
/** 直接设置 systemPrompt(优先于 persona 目录) */
|
|
478
490
|
systemPrompt(prompt: string): this;
|
|
479
491
|
/** 设置 Session 存储 */
|
|
@@ -18,7 +18,8 @@ import * as pluginToolAdapter from '../extension/plugin-ecosystem/tools/plugin-t
|
|
|
18
18
|
import { expandHomePath } from '../../paths.js';
|
|
19
19
|
import { createUnconfiguredFileEffects, createUnconfiguredMemoryEffects, } from '../extension/execution-environment/undo-log.js';
|
|
20
20
|
import { JournaledMemoryStore } from '../extension/execution-environment/memory-undo.js';
|
|
21
|
-
import { buildToolLlmParameters, prepareHandlerArgs, resolveToolCallPurpose
|
|
21
|
+
import { buildToolLlmParameters, prepareHandlerArgs, resolveToolCallPurpose } from './tool-purpose.js';
|
|
22
|
+
import { buildToolDefinitions } from '@octopi-agent/core/loop/index.js';
|
|
22
23
|
import { Agent } from '../run/agent/index.js';
|
|
23
24
|
import { DEFAULT_RELIABILITY_CONFIG } from '../run/reliability/run-agent.js';
|
|
24
25
|
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
@@ -36,6 +37,7 @@ import { PersonaSource } from './persona.js';
|
|
|
36
37
|
import { getRunScope } from '../run/run-scope.js';
|
|
37
38
|
import { DefaultContextEngine } from '../context/default-context-engine.js';
|
|
38
39
|
import { createProviderSummarize } from '../context/summarize.js';
|
|
40
|
+
import { collectToolAgers, collectToolArgAgers } from '../context/tool-result-aging.js';
|
|
39
41
|
import { createDefaultSystemPromptAssembler } from '../context/system-prompt-assembler.js';
|
|
40
42
|
import { SessionAwareRunner } from '../run/runner.js';
|
|
41
43
|
import { DefaultMcpManager } from '../extension/plugin-ecosystem/mcp/manager.js';
|
|
@@ -154,22 +156,22 @@ class RuntimeToolContextProvider {
|
|
|
154
156
|
};
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
|
-
/**
|
|
158
|
-
* 发给 LLM 的 JSON Schema 净化 + purpose 统一装配见 tool-purpose.ts(arch/tool-call-purpose.md)。
|
|
159
|
-
* 此处仅保留兼容别名。
|
|
160
|
-
*/
|
|
161
|
-
const sanitizeLlmJsonSchema = sanitizeToolJsonSchema;
|
|
162
159
|
/**
|
|
163
160
|
* 将 RegisteredTool 转换为 AgentTool(新循环格式)
|
|
164
161
|
*
|
|
165
162
|
* purpose schema 必须经 buildToolLlmParameters 统一装配,
|
|
166
163
|
* 与 gateway 热更新路径(registeredToolToAgentTool)同构。
|
|
164
|
+
* (发送给 LLM 的 wire 面映射见 core `buildToolDefinitions`;schema 净化的唯一入口
|
|
165
|
+
* 仍是 tool-purpose.ts,见 arch/tool-call-purpose.md。)
|
|
167
166
|
*/
|
|
168
167
|
function convertToAgentTool(tool, contextProvider) {
|
|
169
168
|
return {
|
|
170
169
|
name: tool.definition.name,
|
|
171
170
|
description: tool.definition.description,
|
|
172
171
|
executionMode: tool.executionMode,
|
|
172
|
+
// 结果老化策略:唯一声明源在 RegisteredTool,透传供老化层按名取用(同 executionMode)
|
|
173
|
+
...(tool.ageArgs ? { ageArgs: tool.ageArgs } : {}),
|
|
174
|
+
...(tool.ageResult ? { ageResult: tool.ageResult } : {}),
|
|
173
175
|
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
174
176
|
parameters: buildToolLlmParameters(tool.definition.parameters),
|
|
175
177
|
execute: async (toolCallId, args, signal, onUpdate) => {
|
|
@@ -445,6 +447,8 @@ export class AgentBuilder {
|
|
|
445
447
|
_agentHome;
|
|
446
448
|
/** 逻辑 agentId(观测 / 子系统审计用) */
|
|
447
449
|
_agentId;
|
|
450
|
+
/** 归属租户(arch/multi-tenancy.md §4):audit 打标 / 家当派生域;缺省 = DEFAULT_TENANT_ID 语义 */
|
|
451
|
+
_tenantId;
|
|
448
452
|
/** Deferred until build so .pluginTools() and .agentId() order is immaterial. */
|
|
449
453
|
_pluginToolRecords = [];
|
|
450
454
|
model(providerOrName) {
|
|
@@ -829,6 +833,15 @@ export class AgentBuilder {
|
|
|
829
833
|
this._agentId = id;
|
|
830
834
|
return this;
|
|
831
835
|
}
|
|
836
|
+
/** 归属租户(audit 打标 / 家当派生域;arch/multi-tenancy.md §4) */
|
|
837
|
+
tenantId(id) {
|
|
838
|
+
const trimmed = id.trim();
|
|
839
|
+
if (!trimmed) {
|
|
840
|
+
throw new Error('tenantId must be non-empty');
|
|
841
|
+
}
|
|
842
|
+
this._tenantId = trimmed;
|
|
843
|
+
return this;
|
|
844
|
+
}
|
|
832
845
|
/** 直接设置 systemPrompt(优先于 persona 目录) */
|
|
833
846
|
systemPrompt(prompt) {
|
|
834
847
|
this._systemPrompt = prompt;
|
|
@@ -902,6 +915,8 @@ export class AgentBuilder {
|
|
|
902
915
|
const sessionTaskService = this._runnerConfig?.sessionTaskService ?? new SessionTaskService(store, events);
|
|
903
916
|
this._runnerConfig = {
|
|
904
917
|
...this._runnerConfig,
|
|
918
|
+
// 归属租户补全(Runner principal 缺省锚):显式 runnerConfig 优先,顺序不可变
|
|
919
|
+
...(this._tenantId && !this._runnerConfig?.tenantId ? { tenantId: this._tenantId } : {}),
|
|
905
920
|
sessionTaskService,
|
|
906
921
|
};
|
|
907
922
|
if (!this._toolBus.getTool('task_list')) {
|
|
@@ -1132,6 +1147,10 @@ export class AgentBuilder {
|
|
|
1132
1147
|
};
|
|
1133
1148
|
});
|
|
1134
1149
|
}
|
|
1150
|
+
// P0c A′ 脉搏注册表:本 agent 装配产物的全部周期任务(backfill 扫描 / health 探测 /
|
|
1151
|
+
// 子系统 schedule),key 带 agentId 前缀保证实例内唯一;run 宿主聚合后自述给 gateway。
|
|
1152
|
+
const pulseOwner = this._agentId ?? 'default';
|
|
1153
|
+
const pulses = [];
|
|
1135
1154
|
// 子系统装配:自动发现 + allow/deny 过滤 + 注册
|
|
1136
1155
|
const allowlist = options?.subsystemAllowlist ?? this._subsystemAllowlist;
|
|
1137
1156
|
const denylist = options?.subsystemDenylist ?? this._subsystemDenylist;
|
|
@@ -1169,6 +1188,7 @@ export class AgentBuilder {
|
|
|
1169
1188
|
},
|
|
1170
1189
|
auditDir: this._subsystemAuditDir,
|
|
1171
1190
|
agentId: this._agentId,
|
|
1191
|
+
tenantId: this._tenantId,
|
|
1172
1192
|
securityEnforcement,
|
|
1173
1193
|
});
|
|
1174
1194
|
const registeredIds = new Set();
|
|
@@ -1255,6 +1275,13 @@ export class AgentBuilder {
|
|
|
1255
1275
|
if (registeredIds.size > 0 || candidateSpecs.length > 0 || this._subsystemDir) {
|
|
1256
1276
|
runner.setSubsystemRuntime(subsystemRuntime);
|
|
1257
1277
|
}
|
|
1278
|
+
// 子系统 schedule 脉搏(P0c A′:原 sense scheduleTimer/runOnStart 由 gateway 单发驱动)
|
|
1279
|
+
for (const p of subsystemRuntime.pulseSpecs()) {
|
|
1280
|
+
pulses.push({
|
|
1281
|
+
spec: { ...p, key: `${pulseOwner}:${p.key}`, agentId: this._agentId },
|
|
1282
|
+
fire: () => subsystemRuntime.pulse(p.key),
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1258
1285
|
// 补录脉搏:硬收敛 / idle 漂移 / 覆盖差
|
|
1259
1286
|
// `memory.backfill.enabled=false` 时不启动 Trigger(省 LLM);denylist 不注册子系统时同样不启动
|
|
1260
1287
|
const backfillCfg = this._memoryConfig?.backfill;
|
|
@@ -1274,6 +1301,13 @@ export class AgentBuilder {
|
|
|
1274
1301
|
});
|
|
1275
1302
|
trigger.start();
|
|
1276
1303
|
runner.setBackfillTrigger(trigger);
|
|
1304
|
+
// idle/gap 周期扫描脉搏(P0c A′:硬收敛仍走事件,属执行面尾)
|
|
1305
|
+
for (const p of trigger.pulseSpecs()) {
|
|
1306
|
+
pulses.push({
|
|
1307
|
+
spec: { ...p, key: `${pulseOwner}:${p.key}`, agentId: this._agentId },
|
|
1308
|
+
fire: () => trigger.pulse(p.key),
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1277
1311
|
}
|
|
1278
1312
|
else if (!backfillEnabled && registeredIds.has('memory.steward.backfill')) {
|
|
1279
1313
|
console.log('[AgentBuilder] memory.backfill.enabled=false — auto backfill trigger off');
|
|
@@ -1289,8 +1323,14 @@ export class AgentBuilder {
|
|
|
1289
1323
|
shadowBacklogLimit: healthCfg?.shadowBacklogLimit,
|
|
1290
1324
|
limits: healthCfg?.limits,
|
|
1291
1325
|
});
|
|
1292
|
-
probe.start();
|
|
1293
1326
|
runner.setMemoryHealthProbe(probe);
|
|
1327
|
+
// memory.health 探测脉搏(P0c A′)
|
|
1328
|
+
for (const p of probe.pulseSpecs()) {
|
|
1329
|
+
pulses.push({
|
|
1330
|
+
spec: { ...p, key: `${pulseOwner}:${p.key}`, agentId: this._agentId },
|
|
1331
|
+
fire: () => probe.pulse(p.key),
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1294
1334
|
}
|
|
1295
1335
|
}
|
|
1296
1336
|
const skillManagerForHealth = skillManager;
|
|
@@ -1316,6 +1356,7 @@ export class AgentBuilder {
|
|
|
1316
1356
|
runner,
|
|
1317
1357
|
mcpManager,
|
|
1318
1358
|
runtime: subsystemRuntime,
|
|
1359
|
+
pulses,
|
|
1319
1360
|
events,
|
|
1320
1361
|
store,
|
|
1321
1362
|
registerTools,
|
|
@@ -1463,14 +1504,11 @@ export class AgentBuilder {
|
|
|
1463
1504
|
// 必须是 0;回落实例工具面(agent.context.tools)会让估算多算整包 tools(毒样本)。
|
|
1464
1505
|
// 实例面只在 run context 本身就是实例 context 时经 scope.tools 自然成立。
|
|
1465
1506
|
const toolSource = scope?.tools ?? [];
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
parameters: sanitizeLlmJsonSchema(t.parameters ?? { type: 'object', properties: {} }),
|
|
1472
|
-
},
|
|
1473
|
-
}));
|
|
1507
|
+
// 工具面单源(2026-11-12):与 loop 发送的 toolDefs 用同一映射(core
|
|
1508
|
+
// buildToolDefinitions),摘要请求据此带逐字节相同的 tools 才能吃到前缀缓存。
|
|
1509
|
+
// parameters 在 RegisteredTool→AgentTool 阶段已过 buildToolLlmParameters 净化,
|
|
1510
|
+
// 此处不再二次 sanitize(二次过滤是空转,且会让估算面与 wire 面各自漂移)。
|
|
1511
|
+
const tools = buildToolDefinitions(toolSource);
|
|
1474
1512
|
// 方案 B:只读 snapshot.contextWindow;未知则 undefined(跳过自动压缩)
|
|
1475
1513
|
// 禁止再调 getModelInfo —— FallbackProvider 可能返回 chain[0] 的窗口
|
|
1476
1514
|
const snapshot = getResolvedModel();
|
|
@@ -1478,13 +1516,17 @@ export class AgentBuilder {
|
|
|
1478
1516
|
const contextWindow = snapshot?.contextWindow != null && snapshot.contextWindow > 0
|
|
1479
1517
|
? snapshot.contextWindow
|
|
1480
1518
|
: undefined;
|
|
1481
|
-
|
|
1519
|
+
// ── 请求视图:messages + tools 一次产出,loop 不再自推工具面 ──
|
|
1520
|
+
const assembled = await contextEngine.assemble({
|
|
1482
1521
|
sessionId,
|
|
1483
1522
|
agentId,
|
|
1484
1523
|
modelKey: snapshot?.ref,
|
|
1485
1524
|
messages,
|
|
1486
1525
|
systemPrompt,
|
|
1487
1526
|
tools,
|
|
1527
|
+
// 工具自带老化策略:从 run 级工具面按名收集(与 tools 分开——后者是 wire 投影)
|
|
1528
|
+
toolAgers: collectToolAgers(toolSource),
|
|
1529
|
+
toolArgAgers: collectToolArgAgers(toolSource),
|
|
1488
1530
|
tokenBudget: contextWindow,
|
|
1489
1531
|
contextWindow,
|
|
1490
1532
|
maxOutputTokens: snapshot?.maxOutputTokens,
|
|
@@ -1519,12 +1561,25 @@ export class AgentBuilder {
|
|
|
1519
1561
|
bus.emit(event);
|
|
1520
1562
|
},
|
|
1521
1563
|
});
|
|
1564
|
+
// 请求视图两半:messages 与 tools 同批交给 loop(缓存前缀的另一半,禁各自拼装)
|
|
1565
|
+
const { messages: llmMessages } = assembled;
|
|
1566
|
+
// 契约护栏(REVIEW del-b5ffc13a MAJ-1):`AssembleResult.tools` 是必填字段,但
|
|
1567
|
+
// `tools: []` 同样能通过编译——那会让模型静默失去**全部**工具能力(loop 以视图为准)。
|
|
1568
|
+
// 装配面非空而引擎返回空 = 契约违背(多半是迁移只改了一半),显式告警。
|
|
1569
|
+
const requestTools = assembled.tools;
|
|
1570
|
+
if (Array.isArray(requestTools) && requestTools.length === 0 && tools.length > 0) {
|
|
1571
|
+
console.warn(`[AgentBuilder] context engine returned an empty tool face while ${tools.length} tools ` +
|
|
1572
|
+
`are registered (session=${sessionId}) — the agent loses ALL tool capability; ` +
|
|
1573
|
+
`an engine that intends this must be changed deliberately`);
|
|
1574
|
+
}
|
|
1575
|
+
const resultEstimated = assembled.estimatedTokens;
|
|
1576
|
+
const resultReadingSource = assembled.readingSource;
|
|
1522
1577
|
// 压缩覆盖/摘要正文由转换记录账本持久(记录先落盘后发视图);
|
|
1523
1578
|
// 旧 compactState 快照回写已随记录模型退役(迁移读口仍在 run 起点)。
|
|
1524
1579
|
// Observer P1:LLM 实际输入视图(ContextEngine 出口)
|
|
1525
1580
|
// 真源 = hub.recordLlmMessages;事件只带 summarizeLlmMessages,避免双套统计/覆盖全文
|
|
1526
1581
|
if (this._observerHub?.isEnabled() && this._observerHub.getConfig().channels['context.llm']) {
|
|
1527
|
-
const llmInput =
|
|
1582
|
+
const llmInput = llmMessages.map((m) => ({
|
|
1528
1583
|
role: m.role,
|
|
1529
1584
|
content: m.content,
|
|
1530
1585
|
}));
|
|
@@ -1532,7 +1587,7 @@ export class AgentBuilder {
|
|
|
1532
1587
|
sessionId,
|
|
1533
1588
|
agentId,
|
|
1534
1589
|
messages: llmInput,
|
|
1535
|
-
estimatedTokens:
|
|
1590
|
+
estimatedTokens: resultEstimated,
|
|
1536
1591
|
});
|
|
1537
1592
|
this._events?.emit({
|
|
1538
1593
|
type: 'run.scope.llm',
|
|
@@ -1543,7 +1598,7 @@ export class AgentBuilder {
|
|
|
1543
1598
|
sessionId,
|
|
1544
1599
|
agentId,
|
|
1545
1600
|
summary: summarizeLlmMessages(llmInput),
|
|
1546
|
-
estimatedTokens:
|
|
1601
|
+
estimatedTokens: resultEstimated,
|
|
1547
1602
|
},
|
|
1548
1603
|
});
|
|
1549
1604
|
}
|
|
@@ -1551,15 +1606,16 @@ export class AgentBuilder {
|
|
|
1551
1606
|
// 按 session 键控——共享 Agent 单例下并发会话各取自己的估算,不串号。
|
|
1552
1607
|
// readingSource(评审 F5):读数是校准/实测锚定/裸估算——生产日志可判定读数可信度
|
|
1553
1608
|
const pressure = {
|
|
1554
|
-
estimatedTokens:
|
|
1609
|
+
estimatedTokens: resultEstimated,
|
|
1555
1610
|
contextWindow,
|
|
1556
|
-
readingSource:
|
|
1611
|
+
readingSource: resultReadingSource,
|
|
1557
1612
|
};
|
|
1558
1613
|
this._contextPressureBySession.set(sessionId, pressure);
|
|
1559
1614
|
this._lastContextPressure = pressure;
|
|
1560
1615
|
// droppedSummary 不得进 system(动态注记打穿前缀缓存)。
|
|
1561
1616
|
// 本轮直接不投递;压缩语义由消息侧 contextSummary 承载。
|
|
1562
|
-
|
|
1617
|
+
// 请求视图:工具面与 messages 同批交给 loop(缓存前缀的另一半)
|
|
1618
|
+
return { messages: llmMessages, tools: requestTools };
|
|
1563
1619
|
});
|
|
1564
1620
|
agent.setOnAfterStep(async (identity, usage, step) => {
|
|
1565
1621
|
// 身份只信调用方显式传入(40-engineering #8 单源):runner 事件循环跑在 run 的
|
|
@@ -40,8 +40,13 @@ export interface BuiltAgent {
|
|
|
40
40
|
* 从配置中创建所有 Provider 实例
|
|
41
41
|
*
|
|
42
42
|
* 返回 provider name → ModelProvider 的映射。
|
|
43
|
+
*
|
|
44
|
+
* @param config - 归一化 Harness 配置
|
|
45
|
+
* @param options - resolvePluginProvider 解析插件 Provider 工厂(models.providers[].plugin)
|
|
43
46
|
*/
|
|
44
|
-
export declare function resolveProviders(config: NormalizedHarnessConfig
|
|
47
|
+
export declare function resolveProviders(config: NormalizedHarnessConfig, options?: {
|
|
48
|
+
resolvePluginProvider?: (ref: string) => import('../extension/plugin-ecosystem/plugins/contribution-registry.js').PluginProviderRecord | undefined;
|
|
49
|
+
}): Promise<Map<string, ModelProvider>>;
|
|
45
50
|
/**
|
|
46
51
|
* 按架构文档 4.9 的三级搜索路径加载子系统
|
|
47
52
|
*
|
|
@@ -90,4 +95,8 @@ export interface BuildFromConfigOptions {
|
|
|
90
95
|
* ops P2:`securityIntegrity`(安全配置漂移守卫)与 `opsAuditPath` 走此通道。
|
|
91
96
|
*/
|
|
92
97
|
runnerConfig?: import('../run/runner.js').SessionAwareRunnerConfig;
|
|
98
|
+
/**
|
|
99
|
+
* 插件 Provider 工厂解析(`models.providers[].plugin`);未注入时插件 provider 创建 fail-loud。
|
|
100
|
+
*/
|
|
101
|
+
resolvePluginProvider?: (ref: string) => import('../extension/plugin-ecosystem/plugins/contribution-registry.js').PluginProviderRecord | undefined;
|
|
93
102
|
}
|
|
@@ -25,17 +25,27 @@ import { wireDelegation } from '../collaboration/delegation/wiring.js';
|
|
|
25
25
|
* 从配置中创建所有 Provider 实例
|
|
26
26
|
*
|
|
27
27
|
* 返回 provider name → ModelProvider 的映射。
|
|
28
|
+
*
|
|
29
|
+
* @param config - 归一化 Harness 配置
|
|
30
|
+
* @param options - resolvePluginProvider 解析插件 Provider 工厂(models.providers[].plugin)
|
|
28
31
|
*/
|
|
29
|
-
export async function resolveProviders(config) {
|
|
32
|
+
export async function resolveProviders(config, options) {
|
|
30
33
|
const providers = new Map();
|
|
31
34
|
// wire dump 是纯观测:未启用时 undefined,启用后 sink 在该层共享(单一写队列 + 单一环形计数)
|
|
32
35
|
const wireDump = await createWireDumpSinkFromConfig(config.observability?.llmRequestDump);
|
|
33
36
|
for (const [name, pc] of Object.entries(config.models?.providers ?? {})) {
|
|
34
37
|
try {
|
|
35
|
-
const provider = await createProviderFromConfig(name, pc, {
|
|
38
|
+
const provider = await createProviderFromConfig(name, pc, {
|
|
39
|
+
wireDump,
|
|
40
|
+
...(options?.resolvePluginProvider === undefined ? {} : { resolvePluginProvider: options.resolvePluginProvider }),
|
|
41
|
+
});
|
|
36
42
|
providers.set(name, provider);
|
|
37
43
|
}
|
|
38
44
|
catch (err) {
|
|
45
|
+
// 插件 provider 的失败必须 fail-closed:吞掉会让 buildAgent 报误导性的 "unknown provider",
|
|
46
|
+
// 真实原因(插件未发现/被禁用/注册失败)不能丢
|
|
47
|
+
if (pc.plugin !== undefined)
|
|
48
|
+
throw err;
|
|
39
49
|
console.warn(`[ConfigBridge] Failed to create provider "${name}":`, err);
|
|
40
50
|
}
|
|
41
51
|
}
|
|
@@ -95,7 +105,9 @@ export async function resolveSubsystemSpecs(projectRoot) {
|
|
|
95
105
|
export async function buildFromConfig(config, options) {
|
|
96
106
|
const flatModels = config.flatModels ?? [];
|
|
97
107
|
// 1. 解析共享资源
|
|
98
|
-
const providers = await resolveProviders(config
|
|
108
|
+
const providers = await resolveProviders(config, {
|
|
109
|
+
...(options?.resolvePluginProvider === undefined ? {} : { resolvePluginProvider: options.resolvePluginProvider }),
|
|
110
|
+
});
|
|
99
111
|
const securityConfig = resolveSecurityConfig(config);
|
|
100
112
|
const budgetConfig = config.budgetPolicy;
|
|
101
113
|
const runGuardConfig = config.runGuard;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RegisteredTool → AgentTool 适配(热更新已 build Agent 的 client tool)。
|
|
3
|
+
*
|
|
4
|
+
* 将 RegisteredTool 转换为 Loop AgentTool(与 builder.convertToAgentTool、
|
|
5
|
+
* think.buildAgentTools 同构)。原居 gateway.ts,P0b 随客户端工具面迁 run 侧时
|
|
6
|
+
* 归位 engine(其全部依赖本就在 engine)。导出供测试覆盖三处映射的
|
|
7
|
+
* executionMode 透传一致性。
|
|
8
|
+
*/
|
|
9
|
+
import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
10
|
+
export declare function registeredToolToAgentTool(tool: RegisteredTool): {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
executionMode?: 'parallel' | 'sequential';
|
|
14
|
+
source?: import('@octopi-agent/core/types.js').ToolSource;
|
|
15
|
+
parameters?: Record<string, unknown>;
|
|
16
|
+
execute: (toolCallId: string, args: unknown, signal?: AbortSignal, onUpdate?: (partial: {
|
|
17
|
+
content?: unknown;
|
|
18
|
+
}) => void) => Promise<{
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
content: unknown;
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
durationMs?: number;
|
|
24
|
+
purpose?: string;
|
|
25
|
+
source?: import('@octopi-agent/core/types.js').ToolSource;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RegisteredTool → AgentTool 适配(热更新已 build Agent 的 client tool)。
|
|
3
|
+
*
|
|
4
|
+
* 将 RegisteredTool 转换为 Loop AgentTool(与 builder.convertToAgentTool、
|
|
5
|
+
* think.buildAgentTools 同构)。原居 gateway.ts,P0b 随客户端工具面迁 run 侧时
|
|
6
|
+
* 归位 engine(其全部依赖本就在 engine)。导出供测试覆盖三处映射的
|
|
7
|
+
* executionMode 透传一致性。
|
|
8
|
+
*/
|
|
9
|
+
import { buildToolLlmParameters, prepareHandlerArgs, resolveToolCallPurpose, } from './tool-purpose.js';
|
|
10
|
+
import { getRunScope } from '../run/run-scope.js';
|
|
11
|
+
export function registeredToolToAgentTool(tool) {
|
|
12
|
+
return {
|
|
13
|
+
name: tool.definition.name,
|
|
14
|
+
description: tool.definition.description,
|
|
15
|
+
// 与 convertToAgentTool 同构:purpose 统一装配(arch/tool-call-purpose.md)
|
|
16
|
+
...(tool.executionMode ? { executionMode: tool.executionMode } : {}),
|
|
17
|
+
// 结果老化策略(同 executionMode:唯一声明源在 RegisteredTool)
|
|
18
|
+
...(tool.ageArgs ? { ageArgs: tool.ageArgs } : {}),
|
|
19
|
+
...(tool.ageResult ? { ageResult: tool.ageResult } : {}),
|
|
20
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
21
|
+
parameters: buildToolLlmParameters(tool.definition.parameters),
|
|
22
|
+
execute: async (toolCallId, args, signal, onUpdate) => {
|
|
23
|
+
const startTime = Date.now();
|
|
24
|
+
try {
|
|
25
|
+
const rawArgs = (args ?? {});
|
|
26
|
+
// schema 已 required purpose;模型漏填时推导,不中断调用
|
|
27
|
+
const purpose = resolveToolCallPurpose(tool.definition.name, rawArgs);
|
|
28
|
+
const handlerArgs = prepareHandlerArgs(rawArgs, tool.definition);
|
|
29
|
+
const scope = getRunScope();
|
|
30
|
+
const { isPluginToolPermitted } = await import('../extension/plugin-ecosystem/tools/plugin-tool.js');
|
|
31
|
+
if (!isPluginToolPermitted(tool, scope?.toolRuntime?.agentToolPolicy)) {
|
|
32
|
+
throw new Error(`Plugin tool "${tool.definition.name}" is not allowed for this agent`);
|
|
33
|
+
}
|
|
34
|
+
const result = await tool.handler(handlerArgs, {
|
|
35
|
+
sessionId: scope?.sessionId ?? 'unknown',
|
|
36
|
+
agentId: scope?.agentId ?? 'unknown',
|
|
37
|
+
messages: scope?.toolRuntime?.messages ?? [],
|
|
38
|
+
abortSignal: signal,
|
|
39
|
+
// 工具部分输出通道(展示用途);无转发器时不给工具假通道
|
|
40
|
+
...(onUpdate ? { onUpdate } : {}),
|
|
41
|
+
fileEffects: scope?.toolRuntime?.fileEffects
|
|
42
|
+
?? (await import('../extension/execution-environment/undo-log.js')).createUnconfiguredFileEffects(),
|
|
43
|
+
memoryEffects: scope?.toolRuntime?.memoryEffects
|
|
44
|
+
?? (await import('../extension/execution-environment/undo-log.js')).createUnconfiguredMemoryEffects(),
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
toolCallId,
|
|
48
|
+
name: tool.definition.name,
|
|
49
|
+
content: result,
|
|
50
|
+
purpose,
|
|
51
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
52
|
+
durationMs: Date.now() - startTime,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
toolCallId,
|
|
58
|
+
name: tool.definition.name,
|
|
59
|
+
content: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
60
|
+
isError: true,
|
|
61
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
62
|
+
durationMs: Date.now() - startTime,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -78,6 +78,8 @@ export interface AgentWireSpec {
|
|
|
78
78
|
/** 已解析/已包装的主模型 provider */
|
|
79
79
|
model: ModelProvider;
|
|
80
80
|
agentId: string;
|
|
81
|
+
/** 归属租户(arch/multi-tenancy.md §4);缺省 DEFAULT_TENANT_ID,透传 audit 打标与家当派生 */
|
|
82
|
+
tenantId?: string;
|
|
81
83
|
workspace?: string;
|
|
82
84
|
/** agent 文件态持久目录(persona/skills) */
|
|
83
85
|
home?: string;
|
|
@@ -20,6 +20,7 @@ import { DefaultContextEngine } from '../context/default-context-engine.js';
|
|
|
20
20
|
import { DefaultBudgetAllocator } from '../context/budget-allocator.js';
|
|
21
21
|
import { JsonlTransformStore } from '../session/transform-store.js';
|
|
22
22
|
import { initShellParser } from '../governance/security/shell-parser.js';
|
|
23
|
+
import { sqliteVecOption } from '../memory/sqlite/sqlite-vec.js';
|
|
23
24
|
// ── 配置解析(唯一实现;供 wire 与公开导出共用) ──
|
|
24
25
|
/**
|
|
25
26
|
* 解析子系统审计目录(docs/autonomous-subsystem.md §10)
|
|
@@ -190,6 +191,10 @@ export async function wireAgentBuilder(builder, spec) {
|
|
|
190
191
|
const agentHome = spec.home ? expandHomePath(spec.home.trim()) : undefined;
|
|
191
192
|
// agentId 无条件接线(审计分区 / 工具域对称);home 只决定 agent 文件态目录
|
|
192
193
|
builder.agentId(spec.agentId);
|
|
194
|
+
// 归属租户透传(audit 打标 / 家当派生域);缺省不设 = 存量 DEFAULT 语义
|
|
195
|
+
if (spec.tenantId) {
|
|
196
|
+
builder.tenantId(spec.tenantId);
|
|
197
|
+
}
|
|
193
198
|
if (spec.home) {
|
|
194
199
|
builder.agentHome(spec.home);
|
|
195
200
|
}
|
|
@@ -352,8 +357,8 @@ async function wireContextStores(builder, input) {
|
|
|
352
357
|
const useVec = embRuntime && embRuntime.vectorEngine !== 'js';
|
|
353
358
|
const db = await AgentDatabase.create({
|
|
354
359
|
dbPath: join(input.agentHome, 'agent.db'),
|
|
355
|
-
sqliteVec:
|
|
356
|
-
?
|
|
360
|
+
sqliteVec: embRuntime
|
|
361
|
+
? sqliteVecOption(embRuntime.vectorEngine, embRuntime.sqliteVecExtensionPath)
|
|
357
362
|
: false,
|
|
358
363
|
vectorDimensions: useVec ? embRuntime?.dimensions : undefined,
|
|
359
364
|
});
|
|
@@ -377,6 +382,8 @@ async function wireContextStores(builder, input) {
|
|
|
377
382
|
embeddingProvider: embRuntime?.provider ?? null,
|
|
378
383
|
mergeThreshold: cog?.identity?.mergeThreshold,
|
|
379
384
|
candidateBandHi: cog?.identity?.candidateBandHi,
|
|
385
|
+
semanticSeedMaxDistance: cog?.identity?.semanticSeedMaxDistance,
|
|
386
|
+
semanticSeedEmbedTimeoutMs: cog?.identity?.semanticSeedEmbedTimeoutMs,
|
|
380
387
|
stopNodes: cog?.capacity?.stopNodes,
|
|
381
388
|
stopEdges: cog?.capacity?.stopEdges,
|
|
382
389
|
causesMinIndependentMemories: cog?.relations?.causesMinIndependentMemories,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module harness/capabilities/document/backends/plain
|
|
5
5
|
*/
|
|
6
|
+
import { elidedCharsMarker } from '@octopi-agent/core/elision.js';
|
|
6
7
|
function decodeUtf8(data) {
|
|
7
8
|
return new TextDecoder('utf-8', { fatal: false }).decode(data);
|
|
8
9
|
}
|
|
@@ -33,7 +34,7 @@ export const plainTextBackend = {
|
|
|
33
34
|
const warnings = [];
|
|
34
35
|
const maxChars = options.maxTextChars && options.maxTextChars > 0 ? options.maxTextChars : 0;
|
|
35
36
|
if (maxChars > 0 && text.length > maxChars) {
|
|
36
|
-
text = `${text.slice(0, maxChars)}\n\n
|
|
37
|
+
text = `${text.slice(0, maxChars)}\n\n${elidedCharsMarker(text.length - maxChars)}`;
|
|
37
38
|
warnings.push({
|
|
38
39
|
code: 'PARTIAL_EXTRACT',
|
|
39
40
|
message: `text truncated to maxTextChars=${maxChars}`,
|
|
@@ -20,6 +20,7 @@ export function createLegacyConverterFromConfig(options) {
|
|
|
20
20
|
maxInputBytes: options.maxInputBytes,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
// remote(MinerU/WPS
|
|
24
|
-
|
|
23
|
+
// 'remote'(MinerU/WPS/云转换)为前瞻性枚举值,尚无实现——fail-loud,
|
|
24
|
+
// 禁止静默退回「不做转换」(那会让抽取悄悄降级为 T0-only)。
|
|
25
|
+
throw new Error('not_implemented: documents.legacy.converter="remote" (MinerU/WPS/cloud) — use "soffice" or "none"');
|
|
25
26
|
}
|
|
@@ -5,6 +5,11 @@ export interface AuditQuery {
|
|
|
5
5
|
since?: number;
|
|
6
6
|
until?: number;
|
|
7
7
|
agentId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 归属租户(arch/multi-tenancy.md §4);缺省不过滤(host 管理面)。
|
|
10
|
+
* 旧布局数据缺 tenantId 视作 DEFAULT_TENANT_ID。
|
|
11
|
+
*/
|
|
12
|
+
tenantId?: string;
|
|
8
13
|
limit?: number;
|
|
9
14
|
}
|
|
10
15
|
export interface AuditReaderConfig {
|
|
@@ -14,5 +19,17 @@ export declare class AuditReader {
|
|
|
14
19
|
private auditDir;
|
|
15
20
|
constructor(config: AuditReaderConfig);
|
|
16
21
|
query(filter?: AuditQuery): SubsystemRun[];
|
|
22
|
+
/**
|
|
23
|
+
* 检索目录解析:**双布局兼容**(MAJ-6,2026-11-13 评审)。
|
|
24
|
+
*
|
|
25
|
+
* - 新布局(三段式):`{tenantId}/[{agentId}/]{subsystemId}/`——writer 恒按记录租户分区;
|
|
26
|
+
* - legacy(旧两段):`[{agentId}/]{subsystemId}/`(升级前数据,租户视作 DEFAULT)。
|
|
27
|
+
*
|
|
28
|
+
* 叶子分类按段数 + 各解释逐一匹配查询(2 段同时尝试 (tenant,subsystem) 与
|
|
29
|
+
* (agent,subsystem) 两种解释,任一命中即收)。不做模糊 includes 匹配——租户名
|
|
30
|
+
* 与 agent 名可重合,位置语义才是准的。
|
|
31
|
+
*/
|
|
17
32
|
private getSearchDirs;
|
|
33
|
+
/** 叶子路径段对查询的双解释匹配(见 getSearchDirs) */
|
|
34
|
+
private partsMatch;
|
|
18
35
|
}
|