@octopi-agent/engine 0.70.7 → 0.90.11
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/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +81 -5
- package/dist/config-schema/context.d.ts +24 -5
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +205 -13
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +93 -1
- package/dist/config-schema/models.d.ts +3 -3
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +13 -0
- package/dist/config-schema/shared.js +22 -0
- package/dist/config-schema/substrate.d.ts +2 -2
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +201 -8
- package/dist/config.js +105 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +50 -5
- package/dist/harness/agent/builder.js +189 -59
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +84 -291
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +46 -0
- package/dist/harness/agent/tool-purpose.js +127 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +370 -0
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +8 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -9
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/registry.js +10 -0
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +85 -1
- package/dist/harness/context/layer-types.js +110 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
- package/dist/harness/context/system-prompt-assembler.js +73 -6
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +258 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +358 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/isolation.js +5 -1
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +521 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +51 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +153 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +241 -70
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +463 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +16 -12
- package/dist/harness/index.js +10 -6
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +8 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +121 -39
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +154 -151
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/purge.js +4 -1
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +12 -0
- package/dist/harness/observability/observer/hub.js +53 -2
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +80 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +110 -18
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +117 -16
- package/dist/harness/run/runner.js +668 -157
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +16 -5
- package/dist/harness/session/in-memory-store.d.ts +6 -0
- package/dist/harness/session/in-memory-store.js +55 -3
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.js +25 -9
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +39 -0
- package/dist/harness/shared/events/agent-event-map.js +2 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +29 -0
- package/dist/integration/storage/jsonl.js +243 -41
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedule_* / timer_* 工具
|
|
3
|
+
*
|
|
4
|
+
* - timer_*:回合内阻塞等待(arch/session-schedules.md §5.1)
|
|
5
|
+
* - schedule_*:登记跨回合作业,立刻返回(§5.2)
|
|
6
|
+
* 写入唯一入口是 SessionScheduleService;工具不直接碰 Store。
|
|
7
|
+
*/
|
|
8
|
+
import { parseDurationMs } from './types.js';
|
|
9
|
+
const DEFAULT_MAX_WAIT_MS = 10 * 60_000;
|
|
10
|
+
const DEFAULT_HARD_MAX_WAIT_MS = 30 * 60_000;
|
|
11
|
+
/** 每会话协作取消源集合(timer_cancel 全部 abort) */
|
|
12
|
+
const sessionWaits = new Map();
|
|
13
|
+
function trackWait(sessionId, controller) {
|
|
14
|
+
let set = sessionWaits.get(sessionId);
|
|
15
|
+
if (!set) {
|
|
16
|
+
set = new Set();
|
|
17
|
+
sessionWaits.set(sessionId, set);
|
|
18
|
+
}
|
|
19
|
+
set.add(controller);
|
|
20
|
+
}
|
|
21
|
+
function untrackWait(sessionId, controller) {
|
|
22
|
+
const set = sessionWaits.get(sessionId);
|
|
23
|
+
if (!set)
|
|
24
|
+
return;
|
|
25
|
+
set.delete(controller);
|
|
26
|
+
if (set.size === 0)
|
|
27
|
+
sessionWaits.delete(sessionId);
|
|
28
|
+
}
|
|
29
|
+
function scheduleSummary(s) {
|
|
30
|
+
return {
|
|
31
|
+
id: s.id,
|
|
32
|
+
session_id: s.sessionId,
|
|
33
|
+
kind: s.kind,
|
|
34
|
+
status: s.status,
|
|
35
|
+
next_fire_at: s.nextFireAt,
|
|
36
|
+
fire_at: s.fireAt,
|
|
37
|
+
interval_ms: s.intervalMs,
|
|
38
|
+
cron: s.cron,
|
|
39
|
+
run_count: s.runCount,
|
|
40
|
+
max_runs: s.maxRuns,
|
|
41
|
+
delivery: s.payload.delivery,
|
|
42
|
+
title: s.payload.title,
|
|
43
|
+
prompt: s.payload.text,
|
|
44
|
+
task_id: s.payload.taskId,
|
|
45
|
+
catch_up: s.catchUp,
|
|
46
|
+
coalesce_key: s.coalesceKey,
|
|
47
|
+
created_at: s.createdBy.at,
|
|
48
|
+
last_fire_at: s.lastFireAt,
|
|
49
|
+
last_error: s.lastError,
|
|
50
|
+
updated_at: s.updatedAt,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function resolveDuration(args) {
|
|
54
|
+
if (args.duration !== undefined && args.duration !== null && String(args.duration).trim() !== '') {
|
|
55
|
+
return parseDurationMs(args.duration);
|
|
56
|
+
}
|
|
57
|
+
if (args.seconds !== undefined && args.seconds !== null && String(args.seconds).trim() !== '') {
|
|
58
|
+
return parseDurationMs(Number(args.seconds));
|
|
59
|
+
}
|
|
60
|
+
if (args.every !== undefined && args.every !== null && String(args.every).trim() !== '') {
|
|
61
|
+
return parseDurationMs(args.every);
|
|
62
|
+
}
|
|
63
|
+
if (args.delay !== undefined && args.delay !== null && String(args.delay).trim() !== '') {
|
|
64
|
+
return parseDurationMs(args.delay);
|
|
65
|
+
}
|
|
66
|
+
throw new Error('Missing duration; provide duration (e.g. "45s") or seconds');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 创建 timer_* + schedule_* 工具集
|
|
70
|
+
*
|
|
71
|
+
* @param service - SessionScheduleService(须已 open)
|
|
72
|
+
* @param timerOptions - timer_wait 上限
|
|
73
|
+
*/
|
|
74
|
+
export function createSessionScheduleTools(service, timerOptions) {
|
|
75
|
+
return [
|
|
76
|
+
createTimerWaitTool(timerOptions),
|
|
77
|
+
createTimerCancelTool(),
|
|
78
|
+
createScheduleSetTool(service),
|
|
79
|
+
createScheduleUpdateTool(service),
|
|
80
|
+
createScheduleListTool(service),
|
|
81
|
+
createScheduleCancelTool(service),
|
|
82
|
+
createSchedulePauseTool(service),
|
|
83
|
+
createScheduleResumeTool(service),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
/** timer_wait — 回合内阻塞 */
|
|
87
|
+
export function createTimerWaitTool(options) {
|
|
88
|
+
const maxMs = options?.maxDurationMs ?? DEFAULT_MAX_WAIT_MS;
|
|
89
|
+
const hardMaxMs = options?.hardMaxDurationMs ?? DEFAULT_HARD_MAX_WAIT_MS;
|
|
90
|
+
return {
|
|
91
|
+
definition: {
|
|
92
|
+
name: 'timer_wait',
|
|
93
|
+
capabilities: [],
|
|
94
|
+
description: 'Block the current turn and wait for a short duration (seconds~minutes), then continue. ' +
|
|
95
|
+
'For waking later after the turn ends, use schedule_set instead. ' +
|
|
96
|
+
`Max ${Math.round(maxMs / 60000)} minutes (hard cap ${Math.round(hardMaxMs / 60000)}).`,
|
|
97
|
+
timeoutMs: hardMaxMs + 5_000,
|
|
98
|
+
parameters: {
|
|
99
|
+
duration: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'Wait duration: "30s", "5m", "2h", or a number of seconds',
|
|
102
|
+
},
|
|
103
|
+
seconds: {
|
|
104
|
+
type: 'number',
|
|
105
|
+
description: 'Wait duration in seconds (alternative to duration)',
|
|
106
|
+
minimum: 0,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
handler: async (args, context) => {
|
|
111
|
+
const ms = resolveDuration(args);
|
|
112
|
+
if (ms > hardMaxMs) {
|
|
113
|
+
throw new Error(`timer_wait duration ${ms}ms exceeds hard max ${hardMaxMs}ms. ` +
|
|
114
|
+
'Use schedule_set to leave this turn and continue later.');
|
|
115
|
+
}
|
|
116
|
+
if (ms > maxMs) {
|
|
117
|
+
throw new Error(`timer_wait duration ${ms}ms exceeds max ${maxMs}ms. ` +
|
|
118
|
+
'Use schedule_set to leave this turn and continue later.');
|
|
119
|
+
}
|
|
120
|
+
const startedAt = Date.now();
|
|
121
|
+
const controller = new AbortController();
|
|
122
|
+
const onParentAbort = () => controller.abort();
|
|
123
|
+
if (context.abortSignal) {
|
|
124
|
+
if (context.abortSignal.aborted) {
|
|
125
|
+
throw new Error('timer_wait aborted before start');
|
|
126
|
+
}
|
|
127
|
+
context.abortSignal.addEventListener('abort', onParentAbort, { once: true });
|
|
128
|
+
}
|
|
129
|
+
trackWait(context.sessionId, controller);
|
|
130
|
+
try {
|
|
131
|
+
await new Promise((resolve, reject) => {
|
|
132
|
+
const timer = setTimeout(() => {
|
|
133
|
+
controller.signal.removeEventListener('abort', onAbort);
|
|
134
|
+
resolve();
|
|
135
|
+
}, ms);
|
|
136
|
+
const onAbort = () => {
|
|
137
|
+
clearTimeout(timer);
|
|
138
|
+
reject(new Error('timer_wait cancelled'));
|
|
139
|
+
};
|
|
140
|
+
if (controller.signal.aborted) {
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
reject(new Error('timer_wait cancelled'));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
controller.signal.addEventListener('abort', onAbort, { once: true });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
context.abortSignal?.removeEventListener('abort', onParentAbort);
|
|
150
|
+
untrackWait(context.sessionId, controller);
|
|
151
|
+
}
|
|
152
|
+
const endedAt = Date.now();
|
|
153
|
+
return {
|
|
154
|
+
waited_ms: endedAt - startedAt,
|
|
155
|
+
started_at: startedAt,
|
|
156
|
+
ended_at: endedAt,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** timer_cancel — 取消本会话在途 timer_wait */
|
|
162
|
+
export function createTimerCancelTool() {
|
|
163
|
+
return {
|
|
164
|
+
definition: {
|
|
165
|
+
name: 'timer_cancel',
|
|
166
|
+
capabilities: [],
|
|
167
|
+
description: 'Cancel an in-flight timer_wait in this session.',
|
|
168
|
+
parameters: {},
|
|
169
|
+
},
|
|
170
|
+
handler: async (_args, context) => {
|
|
171
|
+
const set = sessionWaits.get(context.sessionId);
|
|
172
|
+
if (!set || set.size === 0) {
|
|
173
|
+
return { cancelled: false, reason: 'no_active_wait' };
|
|
174
|
+
}
|
|
175
|
+
const n = set.size;
|
|
176
|
+
for (const controller of set) {
|
|
177
|
+
controller.abort();
|
|
178
|
+
}
|
|
179
|
+
sessionWaits.delete(context.sessionId);
|
|
180
|
+
return { cancelled: true, aborted: n };
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** schedule_set */
|
|
185
|
+
export function createScheduleSetTool(service) {
|
|
186
|
+
return {
|
|
187
|
+
definition: {
|
|
188
|
+
name: 'schedule_set',
|
|
189
|
+
capabilities: ['send'],
|
|
190
|
+
description: 'Register a non-blocking schedule that wakes this session LATER (or periodically) and runs a full agent turn THEN. ' +
|
|
191
|
+
'CRITICAL: Do NOT execute the prompt now and do NOT start the work in this turn. ' +
|
|
192
|
+
'After schedule_set returns, end your turn immediately and wait for the scheduled wake. ' +
|
|
193
|
+
'Exactly one of delay / at / every / cron. ' +
|
|
194
|
+
'Use timer_wait instead only if you must stay blocked in this turn.',
|
|
195
|
+
parameters: {
|
|
196
|
+
prompt: {
|
|
197
|
+
type: 'string',
|
|
198
|
+
description: 'What to do WHEN THE SCHEDULE FIRES (not now). Keep it self-contained for a later turn.',
|
|
199
|
+
required: true,
|
|
200
|
+
},
|
|
201
|
+
title: {
|
|
202
|
+
type: 'string',
|
|
203
|
+
description: 'Short display title',
|
|
204
|
+
},
|
|
205
|
+
delay: {
|
|
206
|
+
type: 'string',
|
|
207
|
+
description: 'One-shot relative delay, e.g. "2h", "30m", or seconds',
|
|
208
|
+
},
|
|
209
|
+
at: {
|
|
210
|
+
type: 'string',
|
|
211
|
+
description: 'One-shot absolute future time (ISO 8601 with timezone, or epoch ms). Must be in the future.',
|
|
212
|
+
},
|
|
213
|
+
every: {
|
|
214
|
+
type: 'string',
|
|
215
|
+
description: 'Recurring interval, e.g. "30m"',
|
|
216
|
+
},
|
|
217
|
+
cron: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
description: 'Recurring cron: "分 时 日 月 周", e.g. "0 9 * * 1-5"',
|
|
220
|
+
},
|
|
221
|
+
max_runs: {
|
|
222
|
+
type: 'number',
|
|
223
|
+
description: 'Stop after N successful fires (recurring)',
|
|
224
|
+
minimum: 1,
|
|
225
|
+
},
|
|
226
|
+
delivery: {
|
|
227
|
+
type: 'string',
|
|
228
|
+
description: 'wakeup = full agent run (default); notify = message only',
|
|
229
|
+
enum: ['wakeup', 'notify'],
|
|
230
|
+
},
|
|
231
|
+
task_id: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Optional SessionTask id to link',
|
|
234
|
+
},
|
|
235
|
+
coalesce_key: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
description: 'Merge rapid fires with the same key',
|
|
238
|
+
},
|
|
239
|
+
catch_up: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
description: 'Missed fire policy after pause/restart',
|
|
242
|
+
enum: ['skip', 'fire_once'],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
handler: async (args, context) => {
|
|
247
|
+
const prompt = String(args.prompt ?? '').trim();
|
|
248
|
+
if (!prompt) {
|
|
249
|
+
throw new Error('prompt must not be empty');
|
|
250
|
+
}
|
|
251
|
+
const delivery = args.delivery === 'notify' ? 'notify' : 'wakeup';
|
|
252
|
+
const schedule = await service.set({
|
|
253
|
+
sessionId: context.sessionId,
|
|
254
|
+
agentId: context.agentId,
|
|
255
|
+
payload: {
|
|
256
|
+
delivery,
|
|
257
|
+
text: prompt,
|
|
258
|
+
...(args.title ? { title: String(args.title) } : {}),
|
|
259
|
+
...(args.task_id ? { taskId: String(args.task_id) } : {}),
|
|
260
|
+
},
|
|
261
|
+
...(context.runId ? { createdByRunId: context.runId } : {}),
|
|
262
|
+
...(args.delay !== undefined ? { delay: args.delay } : {}),
|
|
263
|
+
...(args.at !== undefined ? { at: args.at } : {}),
|
|
264
|
+
...(args.every !== undefined ? { every: args.every } : {}),
|
|
265
|
+
...(args.cron !== undefined ? { cron: String(args.cron) } : {}),
|
|
266
|
+
...(args.max_runs !== undefined ? { maxRuns: Number(args.max_runs) } : {}),
|
|
267
|
+
...(args.coalesce_key
|
|
268
|
+
? { coalesceKey: String(args.coalesce_key) }
|
|
269
|
+
: {}),
|
|
270
|
+
...(args.catch_up === 'fire_once' || args.catch_up === 'skip'
|
|
271
|
+
? { catchUp: args.catch_up }
|
|
272
|
+
: {}),
|
|
273
|
+
});
|
|
274
|
+
return {
|
|
275
|
+
...scheduleSummary(schedule),
|
|
276
|
+
note: 'SCHEDULE REGISTERED — DO NOT run the prompt now. End this turn. ' +
|
|
277
|
+
'The platform will wake this session at next_fire_at and then you execute the prompt.',
|
|
278
|
+
do_not_run_now: true,
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/** schedule_update */
|
|
284
|
+
export function createScheduleUpdateTool(service) {
|
|
285
|
+
return {
|
|
286
|
+
definition: {
|
|
287
|
+
name: 'schedule_update',
|
|
288
|
+
capabilities: ['send'],
|
|
289
|
+
description: 'Update an existing schedule (prompt, title, max_runs, catch_up, or time). ' +
|
|
290
|
+
'Only active/paused schedules can be updated. Changing time re-arms the job.',
|
|
291
|
+
parameters: {
|
|
292
|
+
id: { type: 'string', description: 'Schedule id', required: true },
|
|
293
|
+
prompt: { type: 'string', description: 'New prompt (what to do when fired)' },
|
|
294
|
+
title: { type: 'string', description: 'New display title' },
|
|
295
|
+
max_runs: { type: 'number', description: 'New max fire count', minimum: 1 },
|
|
296
|
+
catch_up: {
|
|
297
|
+
type: 'string',
|
|
298
|
+
description: 'Missed fire policy',
|
|
299
|
+
enum: ['skip', 'fire_once'],
|
|
300
|
+
},
|
|
301
|
+
delay: { type: 'string', description: 'Replace time with relative delay' },
|
|
302
|
+
at: { type: 'string', description: 'Replace time with absolute future time' },
|
|
303
|
+
every: { type: 'string', description: 'Replace time with interval' },
|
|
304
|
+
cron: { type: 'string', description: 'Replace time with cron' },
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
handler: async (args, context) => {
|
|
308
|
+
const id = String(args.id ?? '');
|
|
309
|
+
const existing = service.get(id);
|
|
310
|
+
if (!existing || existing.sessionId !== context.sessionId) {
|
|
311
|
+
throw new Error(`Schedule not found in this session: ${id}`);
|
|
312
|
+
}
|
|
313
|
+
const hasTime = ['delay', 'at', 'every', 'cron'].some((k) => args[k] !== undefined && String(args[k]).trim() !== '');
|
|
314
|
+
const timeSpec = hasTime
|
|
315
|
+
? {
|
|
316
|
+
...(args.delay !== undefined && String(args.delay).trim() !== ''
|
|
317
|
+
? { delay: args.delay }
|
|
318
|
+
: {}),
|
|
319
|
+
...(args.at !== undefined && String(args.at).trim() !== ''
|
|
320
|
+
? { at: args.at }
|
|
321
|
+
: {}),
|
|
322
|
+
...(args.every !== undefined && String(args.every).trim() !== ''
|
|
323
|
+
? { every: args.every }
|
|
324
|
+
: {}),
|
|
325
|
+
...(args.cron !== undefined && String(args.cron).trim() !== ''
|
|
326
|
+
? { cron: String(args.cron) }
|
|
327
|
+
: {}),
|
|
328
|
+
}
|
|
329
|
+
: undefined;
|
|
330
|
+
const schedule = service.update(id, {
|
|
331
|
+
...(args.prompt !== undefined ? { prompt: String(args.prompt) } : {}),
|
|
332
|
+
...(args.title !== undefined ? { title: String(args.title) } : {}),
|
|
333
|
+
...(args.max_runs !== undefined ? { maxRuns: Number(args.max_runs) } : {}),
|
|
334
|
+
...(args.catch_up === 'skip' || args.catch_up === 'fire_once'
|
|
335
|
+
? { catchUp: args.catch_up }
|
|
336
|
+
: {}),
|
|
337
|
+
...(timeSpec ? { time: timeSpec } : {}),
|
|
338
|
+
});
|
|
339
|
+
return scheduleSummary(schedule);
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/** schedule_list */
|
|
344
|
+
export function createScheduleListTool(service) {
|
|
345
|
+
return {
|
|
346
|
+
definition: {
|
|
347
|
+
name: 'schedule_list',
|
|
348
|
+
capabilities: ['fs-read'],
|
|
349
|
+
description: 'List schedules in this session (default: open active/paused).',
|
|
350
|
+
parameters: {
|
|
351
|
+
status: {
|
|
352
|
+
type: 'string',
|
|
353
|
+
description: 'Filter by status',
|
|
354
|
+
enum: ['active', 'paused', 'completed', 'cancelled', 'failed'],
|
|
355
|
+
},
|
|
356
|
+
active_only: {
|
|
357
|
+
type: 'boolean',
|
|
358
|
+
description: 'Only active and paused (default true)',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
handler: async (args, context) => {
|
|
363
|
+
const activeOnly = args.active_only !== false;
|
|
364
|
+
const status = args.status;
|
|
365
|
+
const items = service.list(context.sessionId, {
|
|
366
|
+
activeOnly: status ? false : activeOnly,
|
|
367
|
+
...(status ? { status } : {}),
|
|
368
|
+
});
|
|
369
|
+
return {
|
|
370
|
+
schedules: items.map(scheduleSummary),
|
|
371
|
+
total: items.length,
|
|
372
|
+
};
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/** schedule_cancel */
|
|
377
|
+
export function createScheduleCancelTool(service) {
|
|
378
|
+
return {
|
|
379
|
+
definition: {
|
|
380
|
+
name: 'schedule_cancel',
|
|
381
|
+
capabilities: ['send'],
|
|
382
|
+
description: 'Cancel a schedule by id. Settled schedules cannot be cancelled.',
|
|
383
|
+
parameters: {
|
|
384
|
+
id: { type: 'string', description: 'Schedule id', required: true },
|
|
385
|
+
reason: { type: 'string', description: 'Optional reason' },
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
handler: async (args, context) => {
|
|
389
|
+
const id = String(args.id ?? '');
|
|
390
|
+
const reason = args.reason ? String(args.reason) : undefined;
|
|
391
|
+
// 仅允许取消本会话作业,避免跨会话误操作
|
|
392
|
+
const existing = service.get(id);
|
|
393
|
+
if (!existing || existing.sessionId !== context.sessionId) {
|
|
394
|
+
throw new Error(`Schedule not found in this session: ${id}`);
|
|
395
|
+
}
|
|
396
|
+
const schedule = service.cancel(id, reason);
|
|
397
|
+
return scheduleSummary(schedule);
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
/** schedule_pause */
|
|
402
|
+
export function createSchedulePauseTool(service) {
|
|
403
|
+
return {
|
|
404
|
+
definition: {
|
|
405
|
+
name: 'schedule_pause',
|
|
406
|
+
capabilities: ['send'],
|
|
407
|
+
description: 'Pause an active schedule (no fire until resume).',
|
|
408
|
+
parameters: {
|
|
409
|
+
id: { type: 'string', description: 'Schedule id', required: true },
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
handler: async (args, context) => {
|
|
413
|
+
const id = String(args.id ?? '');
|
|
414
|
+
const existing = service.get(id);
|
|
415
|
+
if (!existing || existing.sessionId !== context.sessionId) {
|
|
416
|
+
throw new Error(`Schedule not found in this session: ${id}`);
|
|
417
|
+
}
|
|
418
|
+
return scheduleSummary(service.pause(id));
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
/** schedule_resume */
|
|
423
|
+
export function createScheduleResumeTool(service) {
|
|
424
|
+
return {
|
|
425
|
+
definition: {
|
|
426
|
+
name: 'schedule_resume',
|
|
427
|
+
capabilities: ['send'],
|
|
428
|
+
description: 'Resume a paused schedule (applies catch_up policy if overdue).',
|
|
429
|
+
parameters: {
|
|
430
|
+
id: { type: 'string', description: 'Schedule id', required: true },
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
handler: async (args, context) => {
|
|
434
|
+
const id = String(args.id ?? '');
|
|
435
|
+
const existing = service.get(id);
|
|
436
|
+
if (!existing || existing.sessionId !== context.sessionId) {
|
|
437
|
+
throw new Error(`Schedule not found in this session: ${id}`);
|
|
438
|
+
}
|
|
439
|
+
return scheduleSummary(service.resume(id));
|
|
440
|
+
},
|
|
441
|
+
};
|
|
442
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionSchedule — Agent 自发起跨回合作业
|
|
3
|
+
*
|
|
4
|
+
* 见 arch/session-schedules.md。与 SessionTask 词汇刻意分离,避免语义混用。
|
|
5
|
+
*
|
|
6
|
+
* @layer harness/session/schedules — 独立作业注册表(schedules.db),非 Discourse。
|
|
7
|
+
*/
|
|
8
|
+
/** 作业状态 */
|
|
9
|
+
export type SessionScheduleStatus = 'active' | 'paused' | 'completed' | 'cancelled'
|
|
10
|
+
/** 不可恢复:无法计算下次点火 / 记账失败(瞬时 dispatch 错误只写 lastError,不进 failed) */
|
|
11
|
+
| 'failed';
|
|
12
|
+
/** 时间形态 */
|
|
13
|
+
export type SessionScheduleKind = 'once' | 'interval' | 'cron';
|
|
14
|
+
/** 点火投递方式 */
|
|
15
|
+
export type ScheduleDelivery = 'wakeup' | 'notify';
|
|
16
|
+
/** 重启/暂停错过点火策略 */
|
|
17
|
+
export type ScheduleCatchUp = 'skip' | 'fire_once';
|
|
18
|
+
/** 到点要做的事 */
|
|
19
|
+
export interface SessionSchedulePayload {
|
|
20
|
+
/** wakeup = 本会话完整 Run;notify = 只落消息 */
|
|
21
|
+
delivery: ScheduleDelivery;
|
|
22
|
+
/** 到点指令正文 */
|
|
23
|
+
text: string;
|
|
24
|
+
/** 可选关联 SessionTask */
|
|
25
|
+
taskId?: string;
|
|
26
|
+
/** 展示用短标题 */
|
|
27
|
+
title?: string;
|
|
28
|
+
}
|
|
29
|
+
/** 作业记录 */
|
|
30
|
+
export interface SessionSchedule {
|
|
31
|
+
id: string;
|
|
32
|
+
sessionId: string;
|
|
33
|
+
agentId: string;
|
|
34
|
+
kind: SessionScheduleKind;
|
|
35
|
+
/** once:绝对毫秒时间戳 */
|
|
36
|
+
fireAt?: number;
|
|
37
|
+
/** interval:间隔毫秒 */
|
|
38
|
+
intervalMs?: number;
|
|
39
|
+
/** cron:五字段表达式 */
|
|
40
|
+
cron?: string;
|
|
41
|
+
nextFireAt: number;
|
|
42
|
+
maxRuns?: number;
|
|
43
|
+
runCount: number;
|
|
44
|
+
payload: SessionSchedulePayload;
|
|
45
|
+
coalesceKey?: string;
|
|
46
|
+
catchUp: ScheduleCatchUp;
|
|
47
|
+
status: SessionScheduleStatus;
|
|
48
|
+
createdBy: {
|
|
49
|
+
runId?: string;
|
|
50
|
+
at: number;
|
|
51
|
+
};
|
|
52
|
+
lastFireAt?: number;
|
|
53
|
+
lastFireId?: string;
|
|
54
|
+
lastError?: string;
|
|
55
|
+
updatedAt: number;
|
|
56
|
+
}
|
|
57
|
+
/** 创建入参 */
|
|
58
|
+
export interface SessionScheduleCreateInput {
|
|
59
|
+
sessionId: string;
|
|
60
|
+
agentId: string;
|
|
61
|
+
kind: SessionScheduleKind;
|
|
62
|
+
fireAt?: number;
|
|
63
|
+
intervalMs?: number;
|
|
64
|
+
cron?: string;
|
|
65
|
+
maxRuns?: number;
|
|
66
|
+
payload: SessionSchedulePayload;
|
|
67
|
+
coalesceKey?: string;
|
|
68
|
+
catchUp?: ScheduleCatchUp;
|
|
69
|
+
createdByRunId?: string;
|
|
70
|
+
}
|
|
71
|
+
/** 合法迁移表;终态无出边 */
|
|
72
|
+
export declare const SCHEDULE_TRANSITIONS: Readonly<Record<SessionScheduleStatus, readonly SessionScheduleStatus[]>>;
|
|
73
|
+
/** 未闭合(注入与 list 默认) */
|
|
74
|
+
export declare const ACTIVE_SCHEDULE_STATUSES: readonly SessionScheduleStatus[];
|
|
75
|
+
export declare const TERMINAL_SCHEDULE_STATUSES: readonly SessionScheduleStatus[];
|
|
76
|
+
/**
|
|
77
|
+
* 是否允许 from → to
|
|
78
|
+
*
|
|
79
|
+
* @param from - 当前状态
|
|
80
|
+
* @param to - 目标状态
|
|
81
|
+
*/
|
|
82
|
+
export declare function canTransition(from: SessionScheduleStatus, to: SessionScheduleStatus): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* 校验迁移;非法则抛错(禁止静默 no-op)
|
|
85
|
+
*
|
|
86
|
+
* @param from - 当前状态
|
|
87
|
+
* @param to - 目标状态
|
|
88
|
+
* @param id - 作业 id(错误信息)
|
|
89
|
+
*/
|
|
90
|
+
export declare function assertTransition(from: SessionScheduleStatus, to: SessionScheduleStatus, id?: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* 是否未闭合
|
|
93
|
+
*
|
|
94
|
+
* @param status - 作业状态
|
|
95
|
+
*/
|
|
96
|
+
export declare function isScheduleActiveish(status: SessionScheduleStatus): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 解析时长为毫秒。
|
|
99
|
+
* 接受 `"30s" | "5m" | "2h" | "1d" | "500ms"`,或数字(按 **秒** 解释,与 timer_wait.seconds 一致)。
|
|
100
|
+
*
|
|
101
|
+
* @param input - 时长字符串或秒数
|
|
102
|
+
* @returns 毫秒;非法输入抛错
|
|
103
|
+
*/
|
|
104
|
+
export declare function parseDurationMs(input: string | number): number;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionSchedule — Agent 自发起跨回合作业
|
|
3
|
+
*
|
|
4
|
+
* 见 arch/session-schedules.md。与 SessionTask 词汇刻意分离,避免语义混用。
|
|
5
|
+
*
|
|
6
|
+
* @layer harness/session/schedules — 独立作业注册表(schedules.db),非 Discourse。
|
|
7
|
+
*/
|
|
8
|
+
// ── 状态机(arch/session-schedules.md §4.1) ──
|
|
9
|
+
/** 合法迁移表;终态无出边 */
|
|
10
|
+
export const SCHEDULE_TRANSITIONS = {
|
|
11
|
+
active: ['paused', 'completed', 'cancelled', 'failed'],
|
|
12
|
+
paused: ['active', 'cancelled'],
|
|
13
|
+
completed: [],
|
|
14
|
+
cancelled: [],
|
|
15
|
+
failed: [],
|
|
16
|
+
};
|
|
17
|
+
/** 未闭合(注入与 list 默认) */
|
|
18
|
+
export const ACTIVE_SCHEDULE_STATUSES = [
|
|
19
|
+
'active',
|
|
20
|
+
'paused',
|
|
21
|
+
];
|
|
22
|
+
export const TERMINAL_SCHEDULE_STATUSES = [
|
|
23
|
+
'completed',
|
|
24
|
+
'cancelled',
|
|
25
|
+
'failed',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* 是否允许 from → to
|
|
29
|
+
*
|
|
30
|
+
* @param from - 当前状态
|
|
31
|
+
* @param to - 目标状态
|
|
32
|
+
*/
|
|
33
|
+
export function canTransition(from, to) {
|
|
34
|
+
return SCHEDULE_TRANSITIONS[from].includes(to);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 校验迁移;非法则抛错(禁止静默 no-op)
|
|
38
|
+
*
|
|
39
|
+
* @param from - 当前状态
|
|
40
|
+
* @param to - 目标状态
|
|
41
|
+
* @param id - 作业 id(错误信息)
|
|
42
|
+
*/
|
|
43
|
+
export function assertTransition(from, to, id) {
|
|
44
|
+
if (from === to) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!canTransition(from, to)) {
|
|
48
|
+
const allowed = SCHEDULE_TRANSITIONS[from].join(', ') || '(none)';
|
|
49
|
+
throw new Error(`Illegal schedule transition: ${from} → ${to}${id ? ` (${id})` : ''}. Allowed: ${allowed}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 是否未闭合
|
|
54
|
+
*
|
|
55
|
+
* @param status - 作业状态
|
|
56
|
+
*/
|
|
57
|
+
export function isScheduleActiveish(status) {
|
|
58
|
+
return ACTIVE_SCHEDULE_STATUSES.includes(status);
|
|
59
|
+
}
|
|
60
|
+
// ── 时长解析(timer_wait / delay / every 共用) ──
|
|
61
|
+
const DURATION_RE = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/i;
|
|
62
|
+
const UNIT_MS = {
|
|
63
|
+
ms: 1,
|
|
64
|
+
s: 1000,
|
|
65
|
+
m: 60_000,
|
|
66
|
+
h: 3_600_000,
|
|
67
|
+
d: 86_400_000,
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* 解析时长为毫秒。
|
|
71
|
+
* 接受 `"30s" | "5m" | "2h" | "1d" | "500ms"`,或数字(按 **秒** 解释,与 timer_wait.seconds 一致)。
|
|
72
|
+
*
|
|
73
|
+
* @param input - 时长字符串或秒数
|
|
74
|
+
* @returns 毫秒;非法输入抛错
|
|
75
|
+
*/
|
|
76
|
+
export function parseDurationMs(input) {
|
|
77
|
+
if (typeof input === 'number') {
|
|
78
|
+
if (!Number.isFinite(input) || input < 0) {
|
|
79
|
+
throw new Error(`Invalid duration seconds: ${input}`);
|
|
80
|
+
}
|
|
81
|
+
return Math.round(input * 1000);
|
|
82
|
+
}
|
|
83
|
+
const raw = String(input ?? '').trim();
|
|
84
|
+
if (!raw) {
|
|
85
|
+
throw new Error('Duration must not be empty');
|
|
86
|
+
}
|
|
87
|
+
// 纯数字字符串按秒
|
|
88
|
+
if (/^\d+(?:\.\d+)?$/.test(raw)) {
|
|
89
|
+
return Math.round(Number(raw) * 1000);
|
|
90
|
+
}
|
|
91
|
+
const m = DURATION_RE.exec(raw);
|
|
92
|
+
if (!m) {
|
|
93
|
+
throw new Error(`Invalid duration: ${input}. Use e.g. "30s", "5m", "2h", "1d", or seconds number`);
|
|
94
|
+
}
|
|
95
|
+
const unit = m[2].toLowerCase();
|
|
96
|
+
return Math.round(Number(m[1]) * UNIT_MS[unit]);
|
|
97
|
+
}
|