@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
|
@@ -192,6 +192,17 @@ export declare function withRunScope<T>(scope: RunScope, gen: AsyncGenerator<T>)
|
|
|
192
192
|
* @returns 当前作用域;不在 run 中时 undefined
|
|
193
193
|
*/
|
|
194
194
|
export declare function getRunScope(): RunScope | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* 在既有 RunScope 上下文中执行 fn。
|
|
197
|
+
*
|
|
198
|
+
* 供 ALS 边界之外的回调(CDP/事件回调等 socket 驱动路径)重入运行期上下文——
|
|
199
|
+
* 否则宿主 `confirmEffect` 这类按 `getRunScope()` 定界的能力在回调里拿不到 scope。
|
|
200
|
+
*
|
|
201
|
+
* @param scope - 本 run 的作用域身份(handler 执行期捕获)
|
|
202
|
+
* @param fn - 在该作用域内执行的函数(同步调用其内部的 scope 读取即可)
|
|
203
|
+
* @returns fn 的返回值
|
|
204
|
+
*/
|
|
205
|
+
export declare function runInScope<T>(scope: RunScope, fn: () => T): T;
|
|
195
206
|
/**
|
|
196
207
|
* 读取当前 run 的 sessionId
|
|
197
208
|
*
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @module harness/run/run-scope
|
|
10
10
|
*/
|
|
11
11
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
12
|
+
import { randomBytes } from 'node:crypto';
|
|
12
13
|
let runIdSeq = 0;
|
|
13
14
|
/**
|
|
14
15
|
* 生成与 RunScope 对齐的 runId(含 sessionId/agentId,可读且可排序)
|
|
@@ -20,7 +21,11 @@ let runIdSeq = 0;
|
|
|
20
21
|
*/
|
|
21
22
|
export function createRunId(sessionId, agentId, at = Date.now()) {
|
|
22
23
|
runIdSeq += 1;
|
|
23
|
-
|
|
24
|
+
// 随机后缀:seq 是进程内计数(重启归零),同毫秒 + 同会话 + 重启的极端序列
|
|
25
|
+
// 曾可碰撞并 run——runId 自 v0.120.5 起是老化 run 边界的语义载体,碰撞会把
|
|
26
|
+
// 两个 run 并成一个保护域;随机后缀消掉这条理论路径(评审 del-5ca70159 P3-11)
|
|
27
|
+
const rand = randomBytes(4).readUInt32BE(0).toString(36);
|
|
28
|
+
return `run_${at.toString(36)}_${runIdSeq.toString(36)}_${rand}_${sessionId}_${agentId}`;
|
|
24
29
|
}
|
|
25
30
|
const runScopeStorage = new AsyncLocalStorage();
|
|
26
31
|
/**
|
|
@@ -47,6 +52,19 @@ export async function* withRunScope(scope, gen) {
|
|
|
47
52
|
export function getRunScope() {
|
|
48
53
|
return runScopeStorage.getStore();
|
|
49
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* 在既有 RunScope 上下文中执行 fn。
|
|
57
|
+
*
|
|
58
|
+
* 供 ALS 边界之外的回调(CDP/事件回调等 socket 驱动路径)重入运行期上下文——
|
|
59
|
+
* 否则宿主 `confirmEffect` 这类按 `getRunScope()` 定界的能力在回调里拿不到 scope。
|
|
60
|
+
*
|
|
61
|
+
* @param scope - 本 run 的作用域身份(handler 执行期捕获)
|
|
62
|
+
* @param fn - 在该作用域内执行的函数(同步调用其内部的 scope 读取即可)
|
|
63
|
+
* @returns fn 的返回值
|
|
64
|
+
*/
|
|
65
|
+
export function runInScope(scope, fn) {
|
|
66
|
+
return runScopeStorage.run(scope, fn);
|
|
67
|
+
}
|
|
50
68
|
/**
|
|
51
69
|
* 读取当前 run 的 sessionId
|
|
52
70
|
*
|
|
@@ -18,8 +18,45 @@ type TypedSessionStore = SessionStore<SessionData>;
|
|
|
18
18
|
import type { Agent } from './agent/index.js';
|
|
19
19
|
import type { HarnessLoopEvent } from './reliability/harness-events.js';
|
|
20
20
|
import type { ReliabilityHarness } from './reliability/run-agent.js';
|
|
21
|
+
import { collectToolAgers, collectToolArgAgers } from '../context/tool-result-aging.js';
|
|
21
22
|
import { type OpsAuditEvent } from '../extension/execution-environment/ops-audit.js';
|
|
22
23
|
import type { SessionTaskService } from '../session/tasks/service.js';
|
|
24
|
+
/** Runner 压缩执行选项(compactSession / requestInRunCompact 共用形状;禁手抄) */
|
|
25
|
+
export type CompactSessionOptions = {
|
|
26
|
+
compactStructural: (input: {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
messages: Message[];
|
|
30
|
+
summarize?: import('../context/types.js').SummarizeFunction;
|
|
31
|
+
compactTargetTokens?: number;
|
|
32
|
+
/** task 快照:交接式摘要指令尾部注入 */
|
|
33
|
+
taskSnapshot?: string;
|
|
34
|
+
/** 请求口径计量原料(2026-11-08 B1):与会话下一请求同源的 system/tools */
|
|
35
|
+
systemPrompt?: string;
|
|
36
|
+
tools?: import('@octopi-agent/core/interfaces/model-provider.js').LLMToolDefinition[];
|
|
37
|
+
/** 旧压缩快照读口(迁移输入) */
|
|
38
|
+
loadCompactState?: (sessionId: string) => Promise<import('../context/types.js').ContextCompactSnapshot | undefined> | import('../context/types.js').ContextCompactSnapshot | undefined;
|
|
39
|
+
toolAgers?: ReturnType<typeof collectToolAgers>;
|
|
40
|
+
toolArgAgers?: ReturnType<typeof collectToolArgAgers>;
|
|
41
|
+
/** run 中止信号(in-run 路):摘要/压缩调用随 run abort 取消 */
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}) => Promise<import('../context/capabilities/compact/types.js').CompactOutcome>;
|
|
44
|
+
summarize?: import('../context/types.js').SummarizeFunction;
|
|
45
|
+
compactTargetTokens?: number;
|
|
46
|
+
/** 请求口径计量原料(2026-11-08 B1):透传给 compactStructural */
|
|
47
|
+
systemPrompt?: string;
|
|
48
|
+
tools?: import('@octopi-agent/core/interfaces/model-provider.js').LLMToolDefinition[];
|
|
49
|
+
/** 老化策略:摘要前缀必须与会话请求同形(缺它 → 默认指针 → 前缀分叉) */
|
|
50
|
+
toolAgers?: ReturnType<typeof collectToolAgers>;
|
|
51
|
+
toolArgAgers?: ReturnType<typeof collectToolArgAgers>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* in-run 压缩不可承接(无活跃 run / run 已收尾)——调用方(RunHost)应落回
|
|
55
|
+
* compactSession 锁路径执行。抛此类 = 语义化的 fallback 信号,不是故障。
|
|
56
|
+
*/
|
|
57
|
+
export declare class InRunCompactUnavailable extends Error {
|
|
58
|
+
constructor(message: string);
|
|
59
|
+
}
|
|
23
60
|
import type { SessionInboxEntry, SessionInboxBinding } from '../activation/inbox.js';
|
|
24
61
|
import { type ToolIsolationMode } from '../extension/execution-environment/isolation.js';
|
|
25
62
|
import { type SessionLease } from './concurrency/session-lease.js';
|
|
@@ -147,6 +184,8 @@ export interface SessionAwareRunnerConfig {
|
|
|
147
184
|
effectPolicy?: import("../extension/execution-environment/effect-policy.js").EffectPolicyConfig;
|
|
148
185
|
/** credentials.requireBindings(SEC-3c):无绑定凭证不可 resolve */
|
|
149
186
|
requireCredentialBindings?: boolean;
|
|
187
|
+
/** 归属租户(arch/multi-tenancy.md §4):RunScope.principal.tenantId 缺省锚(凭证域解析/归属);缺省 = 宿主面语义 */
|
|
188
|
+
tenantId?: string;
|
|
150
189
|
confirmEffect?: import("../extension/execution-environment/effect-policy.js").ConfirmEffect;
|
|
151
190
|
/** 附件轻量意图分流的默认 provider(仅无 Gateway 模型快照时回退)。 */
|
|
152
191
|
defaultIntentProvider?: import('@octopi-agent/core/interfaces/model-provider.js').ModelProvider;
|
|
@@ -304,6 +343,12 @@ export declare class SessionAwareRunner {
|
|
|
304
343
|
private config;
|
|
305
344
|
/** Session 状态机缓存 */
|
|
306
345
|
private stateMachines;
|
|
346
|
+
/** 活跃 handle 会话(in-run 压缩承接判定;sessionId → run 归属 agentId,E4 键校验用) */
|
|
347
|
+
private readonly activeHandleSessions;
|
|
348
|
+
/** in-flight 压缩执行(key = sessionId\\0agentId):执行期间的请求 join 当前执行(coalesce 跨缝,评审 del-d0830117 F5) */
|
|
349
|
+
private readonly inFlightCompacts;
|
|
350
|
+
/** in-run 压缩请求槽(sessionId → 队列;消息缝 drain,见 requestInRunCompact) */
|
|
351
|
+
private readonly inRunCompactRequests;
|
|
307
352
|
/** 自主子系统运行时 */
|
|
308
353
|
private _subsystemRuntime?;
|
|
309
354
|
private _backfillTrigger?;
|
|
@@ -312,6 +357,8 @@ export declare class SessionAwareRunner {
|
|
|
312
357
|
private _events?;
|
|
313
358
|
/** 产品 Observer Hub(Run 现场;可选) */
|
|
314
359
|
private _observerHub?;
|
|
360
|
+
/** 观测专属事件出口(跨进程桥;见 setObservedEventSink) */
|
|
361
|
+
private _observedEventSink?;
|
|
315
362
|
/** 工具运行时上下文提供者 */
|
|
316
363
|
private toolContextProvider?;
|
|
317
364
|
/** 文件式 persona 的 run 时解析器;每次 handle 前解析,实现热更新 */
|
|
@@ -373,7 +420,23 @@ export declare class SessionAwareRunner {
|
|
|
373
420
|
*/
|
|
374
421
|
setObserverHub(hub: import('../observability/observer/hub.js').ObserverHub | undefined): void;
|
|
375
422
|
/**
|
|
376
|
-
*
|
|
423
|
+
* 注入观测专属事件出口(跨进程桥:run 实例 → gateway)。
|
|
424
|
+
*
|
|
425
|
+
* emitObserved 事件分两类:loop adapted 事件(已进 execute 流 yield,`streamed` 标记)
|
|
426
|
+
* 与观测专属事件(context.layers.assembled / tool.exec.update / run.timing 等,
|
|
427
|
+
* 只进 Hub+EventBus、不进事件 yield 流)。进程内 EventBus 的可见性在 run/gateway
|
|
428
|
+
* 拆分后不再跨进程,专属事件经此 sink 转 notify('session_event') 过网线;
|
|
429
|
+
* streamed 事件已在 execute 流中,不得重复过线。
|
|
430
|
+
*
|
|
431
|
+
* @param sink - 专属事件回调(异常 fail-open,不中断 run)
|
|
432
|
+
*/
|
|
433
|
+
setObservedEventSink(sink: ((event: import('@octopi-agent/core/primitives/event-bus.js').AgentEvent) => void) | undefined): void;
|
|
434
|
+
/**
|
|
435
|
+
* 发射事件:先采 Observer Hub,再进 EventBus(协调总线)。
|
|
436
|
+
*
|
|
437
|
+
* @param event - §7 事件词表
|
|
438
|
+
* @param opts.streamed - 事件已经 execute 流 yield(loop adapted);此时不再走
|
|
439
|
+
* observedEventSink,防跨进程桥重复过线
|
|
377
440
|
*/
|
|
378
441
|
private emitObserved;
|
|
379
442
|
/**
|
|
@@ -487,6 +550,54 @@ export declare class SessionAwareRunner {
|
|
|
487
550
|
* @yields AgentEvent 事件流(向后兼容格式)
|
|
488
551
|
*/
|
|
489
552
|
handle(sessionId: string, input: Message, runConfig: RunConfig, signal?: AbortSignal, inboxBinding?: SessionInboxBinding, initialInboxEntry?: SessionInboxEntry): AsyncGenerator<import('@octopi-agent/core/primitives/event-bus.js').AgentEvent>;
|
|
553
|
+
/**
|
|
554
|
+
* 某会话的 LLM 工具面(wire 面)——「无 run」调用方(manual 压缩)的单一来源。
|
|
555
|
+
*
|
|
556
|
+
* 与 run 内组装(`runContext.tools`)同式:`agent.toolsForSession` ∩ `agentToolPolicy`
|
|
557
|
+
* ∩ session ACL `toolRights`(SEC-2 同一漏斗,禁手抄)。摘要请求要吃到前缀缓存,
|
|
558
|
+
* 它的 tools 必须与下一主请求逐字节相同——多一个少一个,前缀就从第一字节断开。
|
|
559
|
+
*
|
|
560
|
+
* 差异如实声明(不假装等价):run 内还能叠 per-run `rightsCeiling` 与 run 启动时的
|
|
561
|
+
* 工具集快照;这里取不到 run,只能取配置级天花板。ACL 拒绝时不抛——压缩是用户显式
|
|
562
|
+
* 操作,不应因参与者授权不可用而整体失效——但要打日志(fail loud,不静默)。
|
|
563
|
+
*
|
|
564
|
+
* @param sessionId - 会话 id
|
|
565
|
+
* @param agentId - 归属 agent(ACL 授权主体)
|
|
566
|
+
* @returns provider 格式工具定义(顺序与会话面一致)
|
|
567
|
+
*/
|
|
568
|
+
resolveSessionLlmTools(sessionId: string, agentId: string): Promise<import('@octopi-agent/core/interfaces/model-provider.js').LLMToolDefinition[]>;
|
|
569
|
+
/**
|
|
570
|
+
* 会话工具面的唯一过滤点(SEC-2 漏斗,禁手抄)
|
|
571
|
+
*
|
|
572
|
+
* `resolveSessionLlmTools`(只要 wire 定义)与 `resolveSessionToolSurface`
|
|
573
|
+
* (wire 定义 + 老化策略)都必须经过这里——**不允许各自复述一遍过滤链**。
|
|
574
|
+
* 2026-11-13 的前缀分叉正是因为两条路径各自手抄参数表,改一边忘另一边。
|
|
575
|
+
*
|
|
576
|
+
* @param sessionId - 会话 id
|
|
577
|
+
* @param agentId - 归属 agent(ACL 授权主体)
|
|
578
|
+
* @returns 经 ACL/策略过滤后的 AgentTool 集合
|
|
579
|
+
*/
|
|
580
|
+
private resolveSessionToolSet;
|
|
581
|
+
/**
|
|
582
|
+
* 某会话的 wire 工具面 **同时**带出老化策略(manual 压缩专用)
|
|
583
|
+
*
|
|
584
|
+
* 为什么必须成对返回:摘要请求的 messages 前缀要与会话请求逐字节相同,
|
|
585
|
+
* 而 messages 老化依赖 toolAgers。只给 tools(wire 定义)不给 agers,
|
|
586
|
+
* 摘要视图就会退回默认机械指针 —— 2026-11-13 生产实测:678 个共同工具结果中
|
|
587
|
+
* 515 个(76%)形态不同 → 前缀从第 2 条消息起就分叉,缓存 0 命中。
|
|
588
|
+
*
|
|
589
|
+
* 单一漏斗:内部仍走 {@link resolveSessionLlmTools} 的同一过滤(`toolsForSession`
|
|
590
|
+
* ∩ `agentToolPolicy` ∩ session ACL),两边不可能出现两份工具集。
|
|
591
|
+
*
|
|
592
|
+
* @param sessionId - 会话 id
|
|
593
|
+
* @param agentId - 归属 agent
|
|
594
|
+
* @returns wire 工具定义(顺序与会话面一致)与按名索引的老化器
|
|
595
|
+
*/
|
|
596
|
+
resolveSessionToolSurface(sessionId: string, agentId: string): Promise<{
|
|
597
|
+
tools: import('@octopi-agent/core/interfaces/model-provider.js').LLMToolDefinition[];
|
|
598
|
+
toolAgers: ReturnType<typeof collectToolAgers>;
|
|
599
|
+
toolArgAgers: ReturnType<typeof collectToolArgAgers>;
|
|
600
|
+
}>;
|
|
490
601
|
/**
|
|
491
602
|
* Session compact under the same session lock as handle (E1/E4).
|
|
492
603
|
*
|
|
@@ -499,27 +610,42 @@ export declare class SessionAwareRunner {
|
|
|
499
610
|
* @param options - structural compact engine callback + summarize params
|
|
500
611
|
* @returns compact result
|
|
501
612
|
*/
|
|
502
|
-
compactSession(sessionId: string, agentId: string, options:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
613
|
+
compactSession(sessionId: string, agentId: string, options: CompactSessionOptions): Promise<import('../context/capabilities/compact/types.js').CompactTransportOutcome>;
|
|
614
|
+
/**
|
|
615
|
+
* 压缩执行核心(**无锁**):两个入口共用——compactSession(锁路径,store 快照)与
|
|
616
|
+
* in-run 消息缝(run 持锁中,传 handle 内活 session,见 requestInRunCompact)。
|
|
617
|
+
* 锁语义(E1/E4 单写者)由入口负责,本方法不得再抢锁(自抢即死锁)。
|
|
618
|
+
*
|
|
619
|
+
* @param sessionId - 会话 id
|
|
620
|
+
* @param agentId - compact 视图归属 agent(E4 键)
|
|
621
|
+
* @param session - 会话数据(消息/任务/compact 快照读口的来源)
|
|
622
|
+
* @param options - 压缩执行选项(compactStructural 等,已解析)
|
|
623
|
+
* @param signal - run 中止信号(in-run 路透传至摘要/压缩调用;锁路径不传)
|
|
624
|
+
* @returns 压缩结果
|
|
625
|
+
*/
|
|
626
|
+
private runCompactCore;
|
|
627
|
+
/**
|
|
628
|
+
* mid-run 手动压缩(方案 A,2026-11-20 拍板):请求交**活跃 run** 在下一个消息缝
|
|
629
|
+
* 执行同一条 compact 路径(同保护/同摘要/同 transform 记录),不抢 session 锁
|
|
630
|
+
* (run 持锁中,自抢即死锁)。同 (sessionId, agentId) 的并发请求 coalesce 到
|
|
631
|
+
* 同一次缝执行。无活跃 run / run 已收尾 → 抛 InRunCompactUnavailable,
|
|
632
|
+
* 调用方落回 compactSession 锁路径(FIFO 立即执行)。
|
|
633
|
+
*
|
|
634
|
+
* @param sessionId - 会话 id
|
|
635
|
+
* @param agentId - compact 视图归属 agent(E4 键)
|
|
636
|
+
* @param options - 与 compactSession 同形的解析结果(compactStructural 等)
|
|
637
|
+
* @returns 压缩结果(下一个消息缝执行完成后 resolve)
|
|
638
|
+
* @throws {InRunCompactUnavailable} 无活跃 run 可承接(调用方 fallback 锁路径)
|
|
639
|
+
*/
|
|
640
|
+
requestInRunCompact(sessionId: string, agentId: string, options: CompactSessionOptions): Promise<import('../context/capabilities/compact/types.js').CompactTransportOutcome>;
|
|
641
|
+
/**
|
|
642
|
+
* 消息缝执行 in-run 压缩队列(consumeMessages 缝上调用;run 持锁,单写者)。
|
|
643
|
+
* 逐条执行、逐条结算;单条失败只 reject 该条,不拖垮队列。
|
|
644
|
+
*
|
|
645
|
+
* @param sessionId - 会话 id
|
|
646
|
+
* @param session - handle 内活 session(消息/任务最新视图)
|
|
647
|
+
*/
|
|
648
|
+
private drainInRunCompacts;
|
|
523
649
|
/**
|
|
524
650
|
* 获取 Session 锁(经 SessionLease;E2 键 = sessionId)
|
|
525
651
|
*
|
|
@@ -551,6 +677,7 @@ export declare class SessionAwareRunner {
|
|
|
551
677
|
* @param userMessage - 本 turn 用户消息对象(session.messages 中的同一引用)
|
|
552
678
|
* @param turnId - 会话内单调 turn id
|
|
553
679
|
* @param turnContextXml - `<turn_context>…</turn_context>` 整段
|
|
680
|
+
* @param runId - 本 run 归因(`metadata.runId`,tool-result-aging 的 run 起点边界用)
|
|
554
681
|
* @throws 若已定形(禁止二次改写)
|
|
555
682
|
*/
|
|
556
683
|
private bakeTurnStart;
|