@oyasmi/pipiclaw 0.9.3 → 0.9.4-beta.2
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/agent/builtin-commands.d.ts +19 -0
- package/dist/agent/builtin-commands.js +80 -0
- package/dist/agent/channel-runner.d.ts +20 -208
- package/dist/agent/channel-runner.js +167 -1188
- package/dist/agent/maintenance-context.d.ts +1 -1
- package/dist/agent/maintenance-context.js +1 -1
- package/dist/agent/prompt/manifest.d.ts +6 -1
- package/dist/agent/prompt/manifest.js +45 -64
- package/dist/agent/prompt/resources.d.ts +3 -0
- package/dist/agent/prompt/resources.js +11 -2
- package/dist/agent/runner-factory.d.ts +1 -43
- package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
- package/dist/agent/{command-extension.js → session/command-extension.js} +48 -35
- package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
- package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
- package/dist/agent/session/model-selection.d.ts +47 -0
- package/dist/agent/session/model-selection.js +99 -0
- package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
- package/dist/agent/session/session-adapter.js +159 -0
- package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
- package/dist/agent/{session-events.js → session/session-events.js} +24 -13
- package/dist/agent/session/session-host.d.ts +200 -0
- package/dist/agent/session/session-host.js +621 -0
- package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +5 -3
- package/dist/agent/status-render.d.ts +0 -1
- package/dist/agent/status-render.js +4 -16
- package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
- package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
- package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
- package/dist/agent/{run-queue.js → turn/run-queue.js} +10 -5
- package/dist/{memory → agent/turn}/task-digest.js +4 -4
- package/dist/agent/turn/turn-context.d.ts +14 -0
- package/dist/agent/turn/turn-context.js +64 -0
- package/dist/agent/turn/turn-error.d.ts +31 -0
- package/dist/agent/turn/turn-error.js +68 -0
- package/dist/agent/turn/turn-finish.d.ts +50 -0
- package/dist/agent/turn/turn-finish.js +188 -0
- package/dist/agent/turn/turn-input.d.ts +43 -0
- package/dist/agent/turn/turn-input.js +79 -0
- package/dist/agent/turn/turn-pipeline.d.ts +68 -0
- package/dist/agent/turn/turn-pipeline.js +257 -0
- package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
- package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
- package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
- package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
- package/dist/agent/types.d.ts +43 -2
- package/dist/agent/types.js +1 -1
- package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
- package/dist/{models/auth-cli.js → app/auth-command.js} +14 -10
- package/dist/{runtime/app-home.d.ts → app/home.d.ts} +6 -2
- package/dist/{runtime/app-home.js → app/home.js} +22 -75
- package/dist/{runtime → app}/proxy.js +4 -2
- package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
- package/dist/{app-services.js → app/services.js} +17 -14
- package/dist/channel/channel-context.d.ts +12 -2
- package/dist/channel/channel-context.js +29 -2
- package/dist/channel/channel-event.d.ts +10 -2
- package/dist/channel/channel-event.js +1 -1
- package/dist/channel/channel-index.js +4 -1
- package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
- package/dist/{runtime/project-commands.js → channel/commands.js} +17 -16
- package/dist/channel/project-scope-store.js +1 -1
- package/dist/channel/store.js +4 -0
- package/dist/commands/catalog.d.ts +24 -7
- package/dist/commands/catalog.js +91 -44
- package/dist/commands/reply-limits.d.ts +6 -0
- package/dist/commands/reply-limits.js +24 -0
- package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
- package/dist/{runtime/report-commands.js → commands/router.js} +6 -6
- package/dist/{settings.d.ts → config/settings.d.ts} +10 -10
- package/dist/{settings.js → config/settings.js} +11 -11
- package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
- package/dist/{tools/config.js → config/tools.js} +5 -2
- package/dist/dingtalk/access-token.d.ts +12 -0
- package/dist/dingtalk/access-token.js +51 -0
- package/dist/dingtalk/api.d.ts +19 -0
- package/dist/dingtalk/api.js +67 -0
- package/dist/dingtalk/bot.d.ts +97 -0
- package/dist/dingtalk/bot.js +389 -0
- package/dist/dingtalk/cards.d.ts +56 -0
- package/dist/dingtalk/cards.js +318 -0
- package/dist/{runtime → dingtalk}/channel-queue.js +4 -1
- package/dist/dingtalk/config.d.ts +19 -0
- package/dist/dingtalk/config.js +95 -0
- package/dist/dingtalk/connection.d.ts +57 -0
- package/dist/dingtalk/connection.js +356 -0
- package/dist/dingtalk/conversation-meta.d.ts +16 -0
- package/dist/dingtalk/conversation-meta.js +77 -0
- package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
- package/dist/{runtime → dingtalk}/delivery.js +29 -15
- package/dist/dingtalk/handler.d.ts +90 -0
- package/dist/dingtalk/handler.js +1 -0
- package/dist/dingtalk/inbound.d.ts +66 -0
- package/dist/dingtalk/inbound.js +137 -0
- package/dist/dingtalk/media.d.ts +66 -0
- package/dist/dingtalk/media.js +214 -0
- package/dist/events/{event-commands.js → commands.js} +99 -45
- package/dist/events/parse.d.ts +14 -0
- package/dist/events/parse.js +114 -0
- package/dist/events/types.d.ts +93 -0
- package/dist/events/types.js +1 -0
- package/dist/events/{event-validation.d.ts → validation.d.ts} +14 -3
- package/dist/events/{event-validation.js → validation.js} +17 -9
- package/dist/events/watcher.d.ts +67 -0
- package/dist/events/{events.js → watcher.js} +63 -121
- package/dist/executor.js +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -2
- package/dist/jobs/launch.d.ts +42 -0
- package/dist/jobs/launch.js +118 -0
- package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
- package/dist/{agent/job-manager.js → jobs/manager.js} +34 -157
- package/dist/jobs/record.d.ts +55 -0
- package/dist/jobs/record.js +36 -0
- package/dist/log.d.ts +12 -2
- package/dist/log.js +26 -34
- package/dist/main.js +3 -3
- package/dist/memory/commands.js +29 -23
- package/dist/memory/lifecycle.js +26 -5
- package/dist/memory/maintenance-gates.d.ts +2 -2
- package/dist/memory/maintenance-state.js +4 -1
- package/dist/memory/maintenance-tuning.d.ts +15 -0
- package/dist/memory/maintenance-tuning.js +3 -0
- package/dist/memory/reflect-job.d.ts +2 -2
- package/dist/memory/reflect-job.js +4 -2
- package/dist/memory/scheduler.d.ts +3 -3
- package/dist/memory/scheduler.js +5 -2
- package/dist/memory/sidecar-worker.js +1 -1
- package/dist/memory/transcript.js +1 -1
- package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
- package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
- package/dist/models/login-identity.d.ts +2 -0
- package/dist/models/login-identity.js +83 -0
- package/dist/models/provider-login.d.ts +3 -1
- package/dist/models/provider-login.js +8 -2
- package/dist/models/reference.d.ts +20 -0
- package/dist/models/{utils.js → reference.js} +0 -48
- package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
- package/dist/models/runtime.js +52 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +9 -0
- package/dist/playbooks/agent-delegation.md +2 -2
- package/dist/playbooks/catalog.d.ts +6 -2
- package/dist/playbooks/catalog.js +9 -6
- package/dist/runtime/bootstrap.d.ts +7 -17
- package/dist/runtime/bootstrap.js +70 -659
- package/dist/runtime/durable-dispatch.d.ts +43 -4
- package/dist/runtime/durable-dispatch.js +153 -3
- package/dist/runtime/inbound-images.d.ts +18 -0
- package/dist/runtime/inbound-images.js +51 -0
- package/dist/runtime/shutdown.d.ts +39 -0
- package/dist/runtime/shutdown.js +120 -0
- package/dist/runtime/stop-watchdog.d.ts +16 -0
- package/dist/runtime/stop-watchdog.js +32 -0
- package/dist/runtime/task-driver.d.ts +6 -4
- package/dist/runtime/task-driver.js +58 -23
- package/dist/runtime/task-migration.js +25 -8
- package/dist/runtime/task-spawn.d.ts +1 -1
- package/dist/runtime/task-spawn.js +13 -6
- package/dist/runtime/turn-handler.d.ts +47 -0
- package/dist/runtime/turn-handler.js +318 -0
- package/dist/runtime/turn-run.d.ts +52 -0
- package/dist/runtime/turn-run.js +318 -0
- package/dist/runtime/wake-coalescing.d.ts +18 -0
- package/dist/runtime/wake-coalescing.js +29 -0
- package/dist/security/block-message.d.ts +22 -1
- package/dist/security/block-message.js +66 -1
- package/dist/security/command-guard.js +4 -0
- package/dist/security/network.d.ts +2 -1
- package/dist/security/network.js +7 -2
- package/dist/security/path-guard-check.js +2 -2
- package/dist/security/path-guard.js +4 -0
- package/dist/security/types.d.ts +1 -2
- package/dist/security/types.js +1 -2
- package/dist/shared/exact-keys.d.ts +1 -1
- package/dist/shared/format.d.ts +12 -0
- package/dist/shared/format.js +37 -0
- package/dist/shared/host-process.js +16 -4
- package/dist/shared/wake-claim.d.ts +1 -1
- package/dist/shared/with-timeout.d.ts +3 -2
- package/dist/shared/with-timeout.js +14 -3
- package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
- package/dist/{runtime/skill-commands.js → skills/commands.js} +18 -11
- package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
- package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
- package/dist/skills/workspace.d.ts +33 -0
- package/dist/skills/workspace.js +116 -0
- package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +9 -7
- package/dist/{runtime/subagent-commands.js → subagents/commands.js} +116 -77
- package/dist/subagents/completion-wake.d.ts +17 -0
- package/dist/subagents/completion-wake.js +76 -0
- package/dist/subagents/detached-discovery.js +1 -1
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +2 -2
- package/dist/subagents/dispatch.d.ts +33 -0
- package/dist/subagents/dispatch.js +190 -0
- package/dist/subagents/external/claude-code.js +23 -1
- package/dist/subagents/external/dispatch.d.ts +25 -0
- package/dist/subagents/external/dispatch.js +90 -0
- package/dist/subagents/external/harness.d.ts +1 -1
- package/dist/subagents/external/progress-tail.d.ts +18 -1
- package/dist/subagents/external/progress-tail.js +64 -17
- package/dist/subagents/external/run.d.ts +5 -1
- package/dist/subagents/external/run.js +23 -9
- package/dist/subagents/external/settlement.d.ts +4 -1
- package/dist/subagents/external/settlement.js +1 -1
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/grace.d.ts +24 -0
- package/dist/subagents/grace.js +57 -0
- package/dist/subagents/internal/outcome.d.ts +24 -0
- package/dist/subagents/internal/outcome.js +149 -0
- package/dist/subagents/internal/provider-retry.d.ts +19 -0
- package/dist/subagents/internal/provider-retry.js +83 -0
- package/dist/subagents/internal/run.d.ts +31 -0
- package/dist/subagents/internal/run.js +240 -0
- package/dist/subagents/internal/state.d.ts +43 -0
- package/dist/subagents/internal/state.js +48 -0
- package/dist/subagents/internal/worker.d.ts +51 -0
- package/dist/subagents/internal/worker.js +167 -0
- package/dist/subagents/result.d.ts +62 -0
- package/dist/subagents/result.js +103 -0
- package/dist/subagents/run-record.d.ts +222 -0
- package/dist/subagents/run-record.js +101 -0
- package/dist/subagents/run-registry.d.ts +9 -0
- package/dist/subagents/run-registry.js +125 -0
- package/dist/subagents/runs.d.ts +16 -232
- package/dist/subagents/runs.js +132 -310
- package/dist/subagents/task-envelope.d.ts +36 -0
- package/dist/subagents/task-envelope.js +168 -0
- package/dist/subagents/types.d.ts +154 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification-outcome.d.ts +1 -1
- package/dist/subagents/workspace-summary.d.ts +16 -4
- package/dist/subagents/workspace-summary.js +74 -18
- package/dist/tasks/board.d.ts +10 -3
- package/dist/tasks/board.js +38 -3
- package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
- package/dist/tasks/{work-log.js → bound-work.js} +1 -1
- package/dist/tasks/brief.js +1 -1
- package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
- package/dist/{runtime/task-commands.js → tasks/commands.js} +117 -67
- package/dist/tasks/contract-input.d.ts +1 -1
- package/dist/tasks/contract-input.js +1 -1
- package/dist/tasks/create.js +1 -1
- package/dist/tasks/frontmatter.d.ts +5 -0
- package/dist/tasks/frontmatter.js +8 -0
- package/dist/tasks/{log.d.ts → loop-log.d.ts} +11 -1
- package/dist/tasks/{log.js → loop-log.js} +59 -3
- package/dist/tasks/mutation-lock.js +1 -1
- package/dist/tasks/session-path.js +1 -1
- package/dist/tasks/steer.js +1 -1
- package/dist/tasks/store.js +6 -4
- package/dist/tasks/ticket.d.ts +3 -1
- package/dist/tasks/ticket.js +19 -1
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/bash.js +2 -2
- package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +11 -3
- package/dist/tools/{tool-details.js → contract/details.js} +42 -5
- package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
- package/dist/tools/event-manage.d.ts +1 -1
- package/dist/tools/event-manage.js +4 -4
- package/dist/tools/index.d.ts +5 -3
- package/dist/tools/index.js +8 -6
- package/dist/tools/job.d.ts +1 -1
- package/dist/tools/memory-manage.js +4 -1
- package/dist/tools/registry.d.ts +7 -7
- package/dist/tools/registry.js +6 -6
- package/dist/tools/session-search.d.ts +1 -1
- package/dist/tools/skill.d.ts +2 -34
- package/dist/tools/skill.js +8 -116
- package/dist/tools/subagent-manage.d.ts +1 -1
- package/dist/tools/subagent-manage.js +19 -13
- package/dist/tools/subagent.d.ts +46 -0
- package/dist/tools/subagent.js +127 -0
- package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
- package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
- package/dist/tools/task-manage/lifecycle.js +2 -2
- package/dist/tools/task-manage/log-view.js +2 -2
- package/dist/tools/task-manage/shared.js +3 -3
- package/dist/tools/task-manage/step-end.js +7 -4
- package/dist/tools/task-manage/types.d.ts +1 -1
- package/dist/tools/web-fetch.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tui/app.d.ts +1 -1
- package/dist/tui/app.js +6 -6
- package/dist/tui/cli.d.ts +1 -1
- package/dist/tui/cli.js +3 -3
- package/dist/tui/commands.js +4 -4
- package/dist/tui/frontend.d.ts +44 -0
- package/dist/tui/frontend.js +13 -0
- package/dist/tui/pitui-frontend.d.ts +1 -1
- package/dist/tui/pitui-frontend.js +1 -1
- package/dist/tui/plain-frontend.d.ts +1 -1
- package/dist/tui/renderer.d.ts +3 -42
- package/dist/tui/renderer.js +3 -2
- package/dist/tui/terminal-context.d.ts +2 -2
- package/dist/tui/terminal-media-sender.d.ts +1 -1
- package/dist/tui/turn-controller.d.ts +3 -1
- package/dist/tui/turn-controller.js +36 -21
- package/dist/usage/ledger.js +7 -1
- package/dist/usage/render.js +3 -1
- package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
- package/dist/web/client.d.ts +5 -1
- package/dist/web/client.js +4 -0
- package/dist/web/config.d.ts +1 -1
- package/dist/web/fetch.d.ts +1 -1
- package/dist/web/search-providers.d.ts +1 -1
- package/dist/web/search.d.ts +1 -1
- package/package.json +9 -7
- package/dist/agent/session-adapter.js +0 -77
- package/dist/events/events.d.ts +0 -159
- package/dist/runtime/dingtalk.d.ts +0 -272
- package/dist/runtime/dingtalk.js +0 -1416
- package/dist/subagents/tool.d.ts +0 -206
- package/dist/subagents/tool.js +0 -1088
- /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
- /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
- /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
- /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
- /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
- /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
- /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
- /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
- /package/dist/{runtime → app}/proxy.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
- /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
- /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
- /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
- /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
- /package/dist/tasks/{ledger.js → contract.js} +0 -0
- /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
- /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
- /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
- /package/dist/{shared/types.js → usage/totals.js} +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Collaborators (runner, frontend, store) are injected so the machine can be
|
|
7
7
|
* unit-tested with fakes and a fake clock. `app.ts` builds the real ones.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { formatBusyHint, formatFollowupQueued, formatNoRunningTurn, formatSteerQueued, formatUnknownCommandMessage, isSessionCommandName, slashCommandName, } from "../commands/catalog.js";
|
|
10
10
|
import * as log from "../log.js";
|
|
11
11
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
12
12
|
import { errorMessage } from "../shared/text-utils.js";
|
|
@@ -66,7 +66,10 @@ export class TurnController {
|
|
|
66
66
|
this.submitChain = this.submitChain
|
|
67
67
|
.then(() => this.processSubmit(text))
|
|
68
68
|
.catch((err) => {
|
|
69
|
-
log.
|
|
69
|
+
log.logWarn("tui.submit.failed", "Submit failed", {
|
|
70
|
+
channelId: this.deps.channelId,
|
|
71
|
+
reason: errorMessage(err),
|
|
72
|
+
});
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
async processSubmit(text) {
|
|
@@ -92,7 +95,7 @@ export class TurnController {
|
|
|
92
95
|
this.deps.frontend.showNotice("正在停止…");
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
95
|
-
this.deps.frontend.showNotice("
|
|
98
|
+
this.deps.frontend.showNotice(formatNoRunningTurn("stop"));
|
|
96
99
|
}
|
|
97
100
|
return;
|
|
98
101
|
case "followup":
|
|
@@ -114,7 +117,7 @@ export class TurnController {
|
|
|
114
117
|
// steered into the running turn as literal text (review 2026-08-24 §1.6; matches
|
|
115
118
|
// the DingTalk busy refusal in dingtalk.ts).
|
|
116
119
|
if (name && isSessionCommandName(name) && this.deps.runner.isBusy()) {
|
|
117
|
-
this.deps.frontend.showFinal(
|
|
120
|
+
this.deps.frontend.showFinal(formatBusyHint());
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
123
|
await this.applyText(outcome.text);
|
|
@@ -127,7 +130,7 @@ export class TurnController {
|
|
|
127
130
|
if (this.deps.runner.isBusy()) {
|
|
128
131
|
try {
|
|
129
132
|
await this.deps.runner.queueSteer(text, this.deps.userName);
|
|
130
|
-
this.deps.frontend.showNotice(
|
|
133
|
+
this.deps.frontend.showNotice(formatSteerQueued(false));
|
|
131
134
|
return;
|
|
132
135
|
}
|
|
133
136
|
catch {
|
|
@@ -139,7 +142,7 @@ export class TurnController {
|
|
|
139
142
|
applyFollowup(text) {
|
|
140
143
|
if (this.deps.runner.isBusy()) {
|
|
141
144
|
this.followups.push(text);
|
|
142
|
-
this.deps.frontend.showNotice(
|
|
145
|
+
this.deps.frontend.showNotice(formatFollowupQueued());
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
this.beginTurn(text);
|
|
@@ -159,7 +162,7 @@ export class TurnController {
|
|
|
159
162
|
await this.deps.runner.run(ctx, this.deps.store);
|
|
160
163
|
}
|
|
161
164
|
catch (err) {
|
|
162
|
-
this.deps.frontend.showNotice(
|
|
165
|
+
this.deps.frontend.showNotice(`处理失败:${errorMessage(err)}`);
|
|
163
166
|
}
|
|
164
167
|
finally {
|
|
165
168
|
await ctx.close();
|
|
@@ -171,7 +174,10 @@ export class TurnController {
|
|
|
171
174
|
// The turn is over whether it settled or its finally threw (e.g. a frontend
|
|
172
175
|
// method failing); drain either way and never leak an unhandled rejection.
|
|
173
176
|
void this.currentTurn.then(() => this.drainFollowups(), (err) => {
|
|
174
|
-
log.
|
|
177
|
+
log.logWarn("tui.turn.finalizer_failed", "Turn finalizer failed", {
|
|
178
|
+
channelId: this.deps.channelId,
|
|
179
|
+
reason: errorMessage(err),
|
|
180
|
+
});
|
|
175
181
|
this.deps.runner.endTurn();
|
|
176
182
|
this.drainFollowups();
|
|
177
183
|
});
|
|
@@ -204,7 +210,10 @@ export class TurnController {
|
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
212
|
catch (err) {
|
|
207
|
-
log.
|
|
213
|
+
log.logWarn("channel.archive.write_failed", "User message archive failed", {
|
|
214
|
+
channelId: this.deps.channelId,
|
|
215
|
+
reason: errorMessage(err),
|
|
216
|
+
});
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
219
|
handleInterrupt() {
|
|
@@ -220,14 +229,17 @@ export class TurnController {
|
|
|
220
229
|
return;
|
|
221
230
|
}
|
|
222
231
|
this.exitArmed = true;
|
|
223
|
-
this.deps.frontend.showNotice("
|
|
232
|
+
this.deps.frontend.showNotice("再按一次 Ctrl-C 退出。");
|
|
224
233
|
}
|
|
225
234
|
requestExit() {
|
|
226
235
|
// shutdown() restores the terminal in a finally, so a rejection here means only
|
|
227
236
|
// the memory-flush bookkeeping failed — log it rather than leak an unhandled
|
|
228
237
|
// rejection that could abort the process before exitResolve runs.
|
|
229
238
|
this.shutdown().catch((err) => {
|
|
230
|
-
log.
|
|
239
|
+
log.logWarn("tui.shutdown.failed", "Shutdown failed", {
|
|
240
|
+
channelId: this.deps.channelId,
|
|
241
|
+
reason: errorMessage(err),
|
|
242
|
+
});
|
|
231
243
|
this.exitResolve();
|
|
232
244
|
});
|
|
233
245
|
}
|
|
@@ -240,24 +252,24 @@ export class TurnController {
|
|
|
240
252
|
// Snapshot may be unavailable before the first turn; omit the model.
|
|
241
253
|
}
|
|
242
254
|
const meta = model ? `${this.deps.channelId} · ${model}` : this.deps.channelId;
|
|
243
|
-
return [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
return [`${bold("pipiclaw")} ${dim("· 终端对话")}`, dim(meta), dim("输入消息开始;/help 查看命令。")].join("\n");
|
|
256
|
+
}
|
|
257
|
+
/** One word per state; `idle` and `ready` used to name the same one. */
|
|
258
|
+
runStateLabel() {
|
|
259
|
+
return this.deps.runner.isBusy() ? "运行中" : "空闲";
|
|
248
260
|
}
|
|
249
261
|
updateStatus() {
|
|
250
262
|
try {
|
|
251
263
|
const snapshot = this.deps.runner.getStatusSnapshot();
|
|
252
264
|
let line = snapshot.model;
|
|
253
265
|
if (snapshot.contextTokens !== undefined && snapshot.contextWindow > 0) {
|
|
254
|
-
line += ` ·
|
|
266
|
+
line += ` · 上下文 ${((snapshot.contextTokens / snapshot.contextWindow) * 100).toFixed(0)}%`;
|
|
255
267
|
}
|
|
256
|
-
line += this.
|
|
268
|
+
line += ` · ${this.runStateLabel()}`;
|
|
257
269
|
this.deps.frontend.setStatus(`${this.deps.channelId} · ${line}`);
|
|
258
270
|
}
|
|
259
271
|
catch {
|
|
260
|
-
this.deps.frontend.setStatus(`${this.deps.channelId} · ${this.
|
|
272
|
+
this.deps.frontend.setStatus(`${this.deps.channelId} · ${this.runStateLabel()}`);
|
|
261
273
|
}
|
|
262
274
|
}
|
|
263
275
|
async shutdown() {
|
|
@@ -281,10 +293,13 @@ export class TurnController {
|
|
|
281
293
|
// pause without polluting stdout (which carries the answer in --print).
|
|
282
294
|
// Guaranteed via finally: a flush failure must not leave the terminal raw.
|
|
283
295
|
this.deps.frontend.stop();
|
|
284
|
-
process.stderr.write("
|
|
296
|
+
process.stderr.write("正在保存会话记忆…\n");
|
|
285
297
|
await Promise.race([
|
|
286
298
|
this.deps.runner.flushMemoryForShutdown().catch((err) => {
|
|
287
|
-
log.
|
|
299
|
+
log.logWarn("memory.flush.failed", "Memory flush on exit failed", {
|
|
300
|
+
channelId: this.deps.channelId,
|
|
301
|
+
reason: errorMessage(err),
|
|
302
|
+
});
|
|
288
303
|
}),
|
|
289
304
|
new Promise((resolve) => setTimeout(resolve, SHUTDOWN_FLUSH_WAIT_MS)),
|
|
290
305
|
]);
|
package/dist/usage/ledger.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The usage ledger: an append-only JSONL record of every model spend (turns, sub-agent runs, sidecar
|
|
3
|
+
* work) so the totals add up to real cost without double counting.
|
|
4
|
+
*/
|
|
1
5
|
import { readFile, stat } from "node:fs/promises";
|
|
2
6
|
import { join } from "node:path";
|
|
3
7
|
import * as log from "../log.js";
|
|
@@ -83,7 +87,9 @@ export function createUsageLedger(options = {}) {
|
|
|
83
87
|
if (!hasKnownSignal && !hasUnknownSignal)
|
|
84
88
|
return;
|
|
85
89
|
if (!entry.channelId) {
|
|
86
|
-
log.
|
|
90
|
+
log.logWarn("usage.entry.untracked", "Usage entry missing channelId; recorded as untracked", {
|
|
91
|
+
fields: { kind: entry.kind },
|
|
92
|
+
});
|
|
87
93
|
}
|
|
88
94
|
const full = {
|
|
89
95
|
ts: formatLocalTime(),
|
package/dist/usage/render.js
CHANGED
|
@@ -42,8 +42,10 @@ function topEntries(map, limit) {
|
|
|
42
42
|
.sort((a, b) => b[1] - a[1])
|
|
43
43
|
.slice(0, limit);
|
|
44
44
|
}
|
|
45
|
+
/** The ledger's kinds in the user's terms: a turn is the assistant itself, a sidecar is background memory work. */
|
|
46
|
+
const KIND_LABEL = { turn: "对话", subagent: "委派", sidecar: "后台整理" };
|
|
45
47
|
function renderKindBreakdown(summary) {
|
|
46
|
-
const parts = topEntries(summary.byKind, 3).map(([kind, cost]) => `${kind} ${money(cost)}`);
|
|
48
|
+
const parts = topEntries(summary.byKind, 3).map(([kind, cost]) => `${KIND_LABEL[kind] ?? kind} ${money(cost)}`);
|
|
47
49
|
return parts.length > 0 ? parts.join(" · ") : null;
|
|
48
50
|
}
|
|
49
51
|
/**
|
package/dist/web/client.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared HTTP client behind the web tools: request/response shapes, DNS pinning for
|
|
3
|
+
* validated targets, and proxy agent selection.
|
|
4
|
+
*/
|
|
1
5
|
import { Buffer } from "node:buffer";
|
|
6
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
2
7
|
import type { SecurityConfig } from "../security/types.js";
|
|
3
|
-
import type { PipiclawWebToolsConfig } from "../tools/config.js";
|
|
4
8
|
export declare const WEB_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Pipiclaw/0.5";
|
|
5
9
|
export interface WebRuntimeContext {
|
|
6
10
|
webConfig: PipiclawWebToolsConfig;
|
package/dist/web/client.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared HTTP client behind the web tools: request/response shapes, DNS pinning for
|
|
3
|
+
* validated targets, and proxy agent selection.
|
|
4
|
+
*/
|
|
1
5
|
import { Buffer } from "node:buffer";
|
|
2
6
|
import { Agent as HttpAgent } from "node:http";
|
|
3
7
|
import { Agent as HttpsAgent } from "node:https";
|
package/dist/web/config.d.ts
CHANGED
package/dist/web/fetch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
2
3
|
import type { SecurityConfig } from "../security/types.js";
|
|
3
4
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
4
|
-
import type { PipiclawWebToolsConfig } from "../tools/config.js";
|
|
5
5
|
import { type FormattedFetchDetails } from "./format.js";
|
|
6
6
|
export interface WebFetchExecutionContext {
|
|
7
7
|
webConfig: PipiclawWebToolsConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PipiclawWebSearchConfig, WebSearchProvider as WebSearchProviderName } from "../tools
|
|
1
|
+
import type { PipiclawWebSearchConfig, WebSearchProvider as WebSearchProviderName } from "../config/tools.js";
|
|
2
2
|
import type { WebHttpClient } from "./client.js";
|
|
3
3
|
import type { WebSearchResultItem } from "./format.js";
|
|
4
4
|
export declare class WebSearchProviderError extends Error {
|
package/dist/web/search.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
1
2
|
import type { SecurityConfig } from "../security/types.js";
|
|
2
|
-
import type { PipiclawWebToolsConfig } from "../tools/config.js";
|
|
3
3
|
import { type WebSearchResultItem } from "./format.js";
|
|
4
4
|
export interface WebSearchExecutionContext {
|
|
5
5
|
webConfig: PipiclawWebToolsConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyasmi/pipiclaw",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4-beta.2",
|
|
4
4
|
"description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
"playbooks:measure": "node --experimental-strip-types scripts/measure-playbooks.mjs",
|
|
29
29
|
"lint": "biome check .",
|
|
30
30
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
31
|
+
"arch": "node scripts/check-architecture.mjs",
|
|
31
32
|
"deadcode": "knip",
|
|
32
33
|
"test": "vitest --run",
|
|
33
|
-
"
|
|
34
|
+
"pretest:e2e": "npm run build",
|
|
35
|
+
"test:e2e": "vitest --run --config vitest.config.e2e.ts test/e2e/deterministic --fileParallelism --maxWorkers=2",
|
|
34
36
|
"test:e2e:live": "vitest --run --config vitest.config.e2e.ts test/e2e/live",
|
|
35
37
|
"test:e2e:external": "vitest --run --config vitest.config.e2e.ts test/e2e/external",
|
|
36
38
|
"eval:build": "tsc -p tsconfig.evals.json && node scripts/copy-md-assets.mjs dist-evals/src",
|
|
@@ -43,15 +45,15 @@
|
|
|
43
45
|
"eval:promote": "npm run eval:build && node dist-evals/evals/harness/promote.js",
|
|
44
46
|
"eval:prune": "node scripts/prune-eval-results.mjs",
|
|
45
47
|
"test:coverage": "vitest --run --coverage",
|
|
46
|
-
"check": "npm run lint && npm run typecheck && npm run deadcode && npm run test",
|
|
48
|
+
"check": "npm run lint && npm run typecheck && npm run arch && npm run deadcode && npm run test",
|
|
47
49
|
"prepublishOnly": "npm run clean && npm run build && npm run check",
|
|
48
50
|
"test:evals": "vitest --run --config vitest.config.evals.ts"
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@earendil-works/pi-agent-core": "
|
|
52
|
-
"@earendil-works/pi-ai": "
|
|
53
|
-
"@earendil-works/pi-coding-agent": "
|
|
54
|
-
"@earendil-works/pi-tui": "
|
|
53
|
+
"@earendil-works/pi-agent-core": "1.2.0",
|
|
54
|
+
"@earendil-works/pi-ai": "1.2.0",
|
|
55
|
+
"@earendil-works/pi-coding-agent": "1.2.0",
|
|
56
|
+
"@earendil-works/pi-tui": "1.2.0",
|
|
55
57
|
"@mozilla/readability": "^0.6.0",
|
|
56
58
|
"axios": "^1.7.0",
|
|
57
59
|
"croner": "^9.1.0",
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { clampThinkingLevel } from "@earendil-works/pi-ai/compat";
|
|
2
|
-
import { SettingsManager as SDKSettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import * as log from "../log.js";
|
|
4
|
-
export function asSdkSettingsManager(manager) {
|
|
5
|
-
// The upstream session needs its broad interactive SettingsManager surface, while
|
|
6
|
-
// Pipiclaw deliberately owns a small runtime-specific settings contract. Build a
|
|
7
|
-
// real upstream manager from that contract instead of making PipiclawSettingsManager
|
|
8
|
-
// pretend to implement dozens of unrelated no-op UI preferences.
|
|
9
|
-
return SDKSettingsManager.inMemory({
|
|
10
|
-
defaultProvider: manager.getDefaultProvider(),
|
|
11
|
-
defaultModel: manager.getDefaultModel(),
|
|
12
|
-
defaultThinkingLevel: manager.getDefaultThinkingLevel() ?? DEFAULT_MAIN_THINKING_LEVEL,
|
|
13
|
-
compaction: manager.getCompactionSettings(),
|
|
14
|
-
retry: manager.getRetrySettings(),
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export const DEFAULT_MAIN_THINKING_LEVEL = "medium";
|
|
18
|
-
/** Apply the pi 0.83 source-model thinking compatibility branch to one real AgentSession. */
|
|
19
|
-
export async function setModelWithThinkingPreservation(session, manager, model) {
|
|
20
|
-
const source = session.model;
|
|
21
|
-
if (!source?.reasoning) {
|
|
22
|
-
await session.setModel(model);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const previousDefault = manager.getDefaultThinkingLevel();
|
|
26
|
-
manager.setDefaultThinkingLevel(session.thinkingLevel);
|
|
27
|
-
try {
|
|
28
|
-
await session.setModel(model);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
manager.setDefaultThinkingLevel(previousDefault ?? DEFAULT_MAIN_THINKING_LEVEL);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function setThinkingLevelWithConditionalPersist(session, level) {
|
|
35
|
-
const before = session.thinkingLevel;
|
|
36
|
-
session.setThinkingLevel(level);
|
|
37
|
-
const effective = session.thinkingLevel;
|
|
38
|
-
if (effective === before)
|
|
39
|
-
return;
|
|
40
|
-
if (!session.model?.reasoning && effective === "off")
|
|
41
|
-
return;
|
|
42
|
-
session.setThinkingLevel(effective, { persist: true });
|
|
43
|
-
}
|
|
44
|
-
export function cycleThinkingLevelWithConditionalPersist(session) {
|
|
45
|
-
const before = session.thinkingLevel;
|
|
46
|
-
const next = session.cycleThinkingLevel();
|
|
47
|
-
const effective = session.thinkingLevel;
|
|
48
|
-
if (next && effective !== before && (session.model?.reasoning || effective !== "off")) {
|
|
49
|
-
session.setThinkingLevel(effective, { persist: true });
|
|
50
|
-
}
|
|
51
|
-
return next;
|
|
52
|
-
}
|
|
53
|
-
export function initializeThinkingLevelCompat(agent, model, sessionManager, configuredDefault) {
|
|
54
|
-
const branch = sessionManager.getBranch();
|
|
55
|
-
const hasThinkingEntry = branch.some((entry) => entry.type === "thinking_level_change");
|
|
56
|
-
const historical = sessionManager.buildSessionContext().thinkingLevel;
|
|
57
|
-
const requested = hasThinkingEntry ? historical : (configuredDefault ?? DEFAULT_MAIN_THINKING_LEVEL);
|
|
58
|
-
const effective = clampThinkingLevel(model, requested);
|
|
59
|
-
agent.state.thinkingLevel = effective;
|
|
60
|
-
if (!hasThinkingEntry)
|
|
61
|
-
sessionManager.appendThinkingLevelChange(effective);
|
|
62
|
-
return effective;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Overwrite the SDK session's `baseToolsOverride` map so a resource reload swaps in
|
|
66
|
-
* freshly-built tools. The SDK exposes no public setter for this, so we reach into the
|
|
67
|
-
* private `_baseToolsOverride` field. This is the single, isolated point of that coupling:
|
|
68
|
-
* if a future SDK renames or removes the field, the guard below warns loudly instead of
|
|
69
|
-
* silently leaving stale tools in place. Replace with a public setter once upstream adds one.
|
|
70
|
-
*/
|
|
71
|
-
export function setSessionBaseToolsOverride(session, tools, channelId) {
|
|
72
|
-
const target = session;
|
|
73
|
-
if (!("_baseToolsOverride" in target)) {
|
|
74
|
-
log.logWarning(`[${channelId}] AgentSession no longer exposes _baseToolsOverride; tool reloads may use stale tools (SDK change?)`);
|
|
75
|
-
}
|
|
76
|
-
target._baseToolsOverride = Object.fromEntries(tools.map((tool) => [tool.name, tool]));
|
|
77
|
-
}
|
package/dist/events/events.d.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import type { ChannelEvent } from "../channel/channel-event.js";
|
|
2
|
-
import type { Executor } from "../executor.js";
|
|
3
|
-
import type { DingTalkBot } from "../runtime/dingtalk.js";
|
|
4
|
-
import type { SecurityConfig } from "../security/types.js";
|
|
5
|
-
import { type TaskCreateInput } from "../tasks/contract-input.js";
|
|
6
|
-
export interface EventAction {
|
|
7
|
-
type: "bash";
|
|
8
|
-
command: string;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* What an event delivers when it fires: a chat `text`, or a `task` template that spawns a fresh
|
|
13
|
-
* task instance (spec 052, D2). Exactly one is present — `parseScheduledEventContent` enforces it.
|
|
14
|
-
*/
|
|
15
|
-
interface EventPayload {
|
|
16
|
-
text?: string;
|
|
17
|
-
task?: TaskCreateInput;
|
|
18
|
-
}
|
|
19
|
-
export interface OneShotEvent extends EventPayload {
|
|
20
|
-
type: "one-shot";
|
|
21
|
-
channelId: string;
|
|
22
|
-
at: string;
|
|
23
|
-
preAction?: EventAction;
|
|
24
|
-
}
|
|
25
|
-
export interface PeriodicEvent extends EventPayload {
|
|
26
|
-
type: "periodic";
|
|
27
|
-
channelId: string;
|
|
28
|
-
schedule: string;
|
|
29
|
-
preAction?: EventAction;
|
|
30
|
-
}
|
|
31
|
-
export type ScheduledEvent = OneShotEvent | PeriodicEvent;
|
|
32
|
-
export type EventHistoryAction = "loaded" | "scheduled" | "triggered" | "skipped" | "enqueued" | "queue_full" | "deleted" | "invalid" | "pre_action_started" | "pre_action_passed" | "pre_action_blocked" | "pre_action_failed" | "cancelled";
|
|
33
|
-
export type EventHistoryResult = "ok" | "error" | "skipped";
|
|
34
|
-
export interface EventHistoryRecord {
|
|
35
|
-
ts: string;
|
|
36
|
-
eventName: string;
|
|
37
|
-
eventPath: string;
|
|
38
|
-
eventType: ScheduledEvent["type"] | "unknown";
|
|
39
|
-
channelId?: string;
|
|
40
|
-
action: EventHistoryAction;
|
|
41
|
-
result: EventHistoryResult;
|
|
42
|
-
reason?: string;
|
|
43
|
-
schedule?: string;
|
|
44
|
-
at?: string;
|
|
45
|
-
nextRunAt?: string;
|
|
46
|
-
textPreview?: string;
|
|
47
|
-
preAction?: {
|
|
48
|
-
type: "bash";
|
|
49
|
-
command: string;
|
|
50
|
-
timeoutMs: number;
|
|
51
|
-
exitCode?: number | null;
|
|
52
|
-
durationMs?: number;
|
|
53
|
-
};
|
|
54
|
-
queue?: {
|
|
55
|
-
accepted: boolean;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/** One occurrence of a template event asking for a task instance (spec 052, D2). */
|
|
59
|
-
export interface SpawnTaskRequest {
|
|
60
|
-
/** The event's name (filename without `.json`); becomes the instance's `origin`. */
|
|
61
|
-
eventName: string;
|
|
62
|
-
channelId: string;
|
|
63
|
-
template: TaskCreateInput;
|
|
64
|
-
/** The moment this occurrence was due — deterministic per occurrence, so a replay maps to the same instance. */
|
|
65
|
-
occurrence: Date;
|
|
66
|
-
}
|
|
67
|
-
export type SpawnTaskResult =
|
|
68
|
-
/** A new instance was created. */
|
|
69
|
-
{
|
|
70
|
-
outcome: "spawned";
|
|
71
|
-
id: string;
|
|
72
|
-
}
|
|
73
|
-
/** This occurrence's instance already exists: an idempotent replay. */
|
|
74
|
-
| {
|
|
75
|
-
outcome: "exists";
|
|
76
|
-
id: string;
|
|
77
|
-
}
|
|
78
|
-
/** Another instance of the same event is still running; the user was told. */
|
|
79
|
-
| {
|
|
80
|
-
outcome: "skipped";
|
|
81
|
-
id: string;
|
|
82
|
-
};
|
|
83
|
-
export interface EventsWatcherOptions {
|
|
84
|
-
historyPath?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Creates the task instance a template event asks for. Injected by the runtime so the events
|
|
87
|
-
* subsystem never reads or writes task files (spec 052, INV-8).
|
|
88
|
-
*/
|
|
89
|
-
spawnTask?: (request: SpawnTaskRequest) => Promise<SpawnTaskResult>;
|
|
90
|
-
/** Persist synthetic work before it enters the in-memory channel queue. */
|
|
91
|
-
dispatch?: (event: ChannelEvent) => boolean | Promise<boolean>;
|
|
92
|
-
}
|
|
93
|
-
/** The one-line description of what an event delivers, for history records and listings. */
|
|
94
|
-
export declare function describeEventPayload(event: Pick<ScheduledEvent, "text" | "task">): string;
|
|
95
|
-
export declare function parseScheduledEventContent(content: string, filename: string): ScheduledEvent;
|
|
96
|
-
export declare class EventsWatcher {
|
|
97
|
-
private eventsDir;
|
|
98
|
-
private bot;
|
|
99
|
-
private executor;
|
|
100
|
-
private commandGuardConfig?;
|
|
101
|
-
private options;
|
|
102
|
-
private timers;
|
|
103
|
-
private crons;
|
|
104
|
-
private debounceTimers;
|
|
105
|
-
private startTime;
|
|
106
|
-
private watcher;
|
|
107
|
-
private started;
|
|
108
|
-
private knownFiles;
|
|
109
|
-
private readonly historyAppender?;
|
|
110
|
-
constructor(eventsDir: string, bot: DingTalkBot, executor: Executor, commandGuardConfig?: SecurityConfig["commandGuard"] | undefined, options?: EventsWatcherOptions);
|
|
111
|
-
start(): void;
|
|
112
|
-
stop(): void;
|
|
113
|
-
flush(): Promise<void>;
|
|
114
|
-
private ensureHistoryFile;
|
|
115
|
-
private appendHistory;
|
|
116
|
-
private appendEventHistory;
|
|
117
|
-
private debounce;
|
|
118
|
-
private scanExisting;
|
|
119
|
-
private handleFileChange;
|
|
120
|
-
/**
|
|
121
|
-
* Watch callbacks are the top of their own stack, so a rejection here reaches nobody — and
|
|
122
|
-
* `handleFile` can reject: reloading a due one-shot dispatches it inline, and dispatch
|
|
123
|
-
* writes to disk. `scanExisting` already wraps its own calls; this is the same guard for
|
|
124
|
-
* the live path. One bad file must not take the watcher, or the process, down with it.
|
|
125
|
-
*/
|
|
126
|
-
private handleFileSafely;
|
|
127
|
-
private handleDelete;
|
|
128
|
-
private cancelScheduled;
|
|
129
|
-
private handleFile;
|
|
130
|
-
private parseEvent;
|
|
131
|
-
/**
|
|
132
|
-
* The admission gate (spec 031, D4). `event_manage` applies the same rules first, but the
|
|
133
|
-
* events directory is agent-writable, so a file that arrived any other way is only ever
|
|
134
|
-
* stopped here. Returns the rejection reason, or undefined when the event may be scheduled.
|
|
135
|
-
*/
|
|
136
|
-
private admissionFailure;
|
|
137
|
-
private wasWrittenAfterStart;
|
|
138
|
-
private handleOneShot;
|
|
139
|
-
private handlePeriodic;
|
|
140
|
-
private execute;
|
|
141
|
-
/**
|
|
142
|
-
* Deliver a template event: ask the runtime for a fresh task instance (spec 052, D2). The
|
|
143
|
-
* occurrence is the one this trigger was *due* for — a one-shot's `at`, a periodic's cron tick —
|
|
144
|
-
* so a post-restart replay of the same occurrence lands on the same instance instead of making a
|
|
145
|
-
* second one.
|
|
146
|
-
*/
|
|
147
|
-
private spawnTaskInstance;
|
|
148
|
-
private runPreAction;
|
|
149
|
-
private deleteFile;
|
|
150
|
-
private getInvalidMarkerPath;
|
|
151
|
-
private markInvalid;
|
|
152
|
-
private clearInvalidMarker;
|
|
153
|
-
private sleep;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create and start an events watcher.
|
|
157
|
-
*/
|
|
158
|
-
export declare function createEventsWatcher(workspaceDir: string, bot: DingTalkBot, executor: Executor, commandGuardConfig?: SecurityConfig["commandGuard"], historyPath?: string, dispatch?: EventsWatcherOptions["dispatch"], spawnTask?: EventsWatcherOptions["spawnTask"]): EventsWatcher;
|
|
159
|
-
export {};
|