@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
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import type { FinalDelivery, MediaSender, MediaSendResult, OutboundMedia, ProgressStyle } from "../channel/channel-context.js";
|
|
2
|
-
import type { ChannelEvent, InboundImage } from "../channel/channel-event.js";
|
|
3
|
-
import type { ChannelObservation } from "../channel/channel-index.js";
|
|
4
|
-
import { type RuntimeCommandName } from "../commands/catalog.js";
|
|
5
|
-
export type BusyMessageMode = "steer" | "followUp";
|
|
6
|
-
export type BusyMessageDefaultConfig = BusyMessageMode | "followup";
|
|
7
|
-
export type ResponseMode = "full_progress_then_plain_final" | "rolling_progress_then_plain_final" | "final_card_only";
|
|
8
|
-
export declare function progressStyleOf(mode: ResponseMode): ProgressStyle;
|
|
9
|
-
export declare function finalDeliveryOf(mode: ResponseMode): FinalDelivery;
|
|
10
|
-
export declare function isBusyMessageDefaultConfig(value: unknown): value is BusyMessageDefaultConfig;
|
|
11
|
-
export declare function isResponseModeConfig(value: unknown): value is ResponseMode;
|
|
12
|
-
export declare function normalizeBusyMessageDefault(value: unknown): BusyMessageMode;
|
|
13
|
-
export declare function normalizeResponseMode(value: unknown): ResponseMode;
|
|
14
|
-
export interface DingTalkConfig {
|
|
15
|
-
clientId: string;
|
|
16
|
-
clientSecret: string;
|
|
17
|
-
robotCode?: string;
|
|
18
|
-
cardTemplateId?: string;
|
|
19
|
-
cardTemplateKey?: string;
|
|
20
|
-
allowFrom?: string[];
|
|
21
|
-
stateDir?: string;
|
|
22
|
-
busyMessageDefault?: BusyMessageDefaultConfig;
|
|
23
|
-
responseMode?: ResponseMode;
|
|
24
|
-
cardAutoLayout?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* `DingTalkEvent` is kept as the public name (spec 035 D4: `src/index.ts`'s barrel is a
|
|
28
|
-
* compatibility promise, so exported names there stay stable). Internally the type now lives in
|
|
29
|
-
* `channel-event.ts` as `ChannelEvent`: most producers of this shape are not DingTalk at all
|
|
30
|
-
* (job-manager, task-driver, events, subagents/runs all synthesize wakes), so `ChannelEvent` is
|
|
31
|
-
* what the rest of the runtime imports.
|
|
32
|
-
*/
|
|
33
|
-
export type DingTalkEvent = ChannelEvent;
|
|
34
|
-
export type BusyMessageResult = {
|
|
35
|
-
kind: "handled";
|
|
36
|
-
} | {
|
|
37
|
-
kind: "requeue";
|
|
38
|
-
text: string;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* What `/stop` actually did. Stopping a task-driven turn also pauses that task, which the user
|
|
42
|
-
* has to be told: a disabled task is never picked up again until `/tasks resume <id>`, so silence
|
|
43
|
-
* here reads as "the turn was interrupted" while the whole task has in fact gone quiet.
|
|
44
|
-
*/
|
|
45
|
-
export interface StopOutcome {
|
|
46
|
-
pausedTaskId?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface DingTalkHandler {
|
|
49
|
-
isRunning(channelId: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Note that a real person just wrote in this channel. Called once per accepted inbound
|
|
52
|
-
* message, before any busy/command routing, and never for synthetic wakes — see the
|
|
53
|
-
* maintenance contract in `channel-index.ts`. Must stay synchronous and cheap.
|
|
54
|
-
*/
|
|
55
|
-
noteChannelActivity?(observation: ChannelObservation): void;
|
|
56
|
-
/**
|
|
57
|
-
* Synchronously reserve an inbound turn before the queued async body yields.
|
|
58
|
-
* The transport calls this hook, when provided, immediately before `handleEvent`.
|
|
59
|
-
*/
|
|
60
|
-
reserveEvent?(event: DingTalkEvent): void;
|
|
61
|
-
handleEvent(event: DingTalkEvent, bot: DingTalkBot, isEvent?: boolean): Promise<void>;
|
|
62
|
-
handleStop(channelId: string, bot: DingTalkBot): Promise<StopOutcome>;
|
|
63
|
-
/** `/new` bypasses the old per-channel queue and live SDK session. */
|
|
64
|
-
handleNewSession(event: DingTalkEvent, bot: DingTalkBot): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Render one of the stateless report commands (events/tasks/status/usage/context/subagents) to
|
|
67
|
-
* text. Single dispatch point shared by the busy-turn switch below and bootstrap's idle-turn
|
|
68
|
-
* switch — both used to hand-copy the same six-case table.
|
|
69
|
-
*/
|
|
70
|
-
runRuntimeCommand(event: DingTalkEvent, name: RuntimeCommandName, args: string): Promise<string>;
|
|
71
|
-
handleBusyMessage(event: DingTalkEvent, bot: DingTalkBot, mode: BusyMessageMode, queueText: string): Promise<BusyMessageResult>;
|
|
72
|
-
/**
|
|
73
|
-
* Persist one downloaded inbound image under the channel's `inbox/` (spec 049). Owned by
|
|
74
|
-
* bootstrap — it holds the workspace root — not the transport, which only knows how to fetch
|
|
75
|
-
* bytes over the DingTalk API. `mimeType` is `null` when magic-byte sniffing did not recognize
|
|
76
|
-
* a supported image format; the file is still persisted (for the archive/record) but the
|
|
77
|
-
* transport excludes it from the model-facing text marker. Returns `null` on a local I/O
|
|
78
|
-
* failure, surfaced to the user as "保存失败" — the rest of the message is still delivered.
|
|
79
|
-
*/
|
|
80
|
-
persistInboundImage?(channelId: string, image: {
|
|
81
|
-
data: Buffer;
|
|
82
|
-
mimeType: string | null;
|
|
83
|
-
}): Promise<InboundImage | null>;
|
|
84
|
-
}
|
|
85
|
-
export declare class DingTalkBot implements MediaSender {
|
|
86
|
-
private handler;
|
|
87
|
-
private config;
|
|
88
|
-
private accessToken;
|
|
89
|
-
private tokenExpiry;
|
|
90
|
-
private tokenRefreshPromise;
|
|
91
|
-
private activeCards;
|
|
92
|
-
private cardGenerations;
|
|
93
|
-
private cardCreationAttempted;
|
|
94
|
-
private cardCreationInFlight;
|
|
95
|
-
private convMeta;
|
|
96
|
-
private channelLastActiveAt;
|
|
97
|
-
private queues;
|
|
98
|
-
private inboundIngestQueue;
|
|
99
|
-
private pendingInboundIngestCount;
|
|
100
|
-
private client;
|
|
101
|
-
private lastSocketAvailableTime;
|
|
102
|
-
private activeMessageProcessing;
|
|
103
|
-
private keepAliveTimer;
|
|
104
|
-
private reconnectTimer;
|
|
105
|
-
private reconnectDelayTimer;
|
|
106
|
-
private reconnectDelayResolve;
|
|
107
|
-
private channelCacheSweepTimer;
|
|
108
|
-
private isReconnecting;
|
|
109
|
-
private isStopped;
|
|
110
|
-
private reconnectAttempts;
|
|
111
|
-
private hasReportedReady;
|
|
112
|
-
private processedIds;
|
|
113
|
-
private processedIdsOrder;
|
|
114
|
-
constructor(handler: DingTalkHandler, config: DingTalkConfig);
|
|
115
|
-
get busyMessageDefault(): BusyMessageMode;
|
|
116
|
-
get responseMode(): ResponseMode;
|
|
117
|
-
get progressStyle(): ProgressStyle;
|
|
118
|
-
get finalDelivery(): FinalDelivery;
|
|
119
|
-
/**
|
|
120
|
-
* Mark an ID as processed. Returns true if this is a new ID, false if already seen.
|
|
121
|
-
* Maintains a FIFO buffer of at most 200 entries.
|
|
122
|
-
*/
|
|
123
|
-
private markProcessed;
|
|
124
|
-
private getSocket;
|
|
125
|
-
private isSocketLike;
|
|
126
|
-
private setTrackedTimeout;
|
|
127
|
-
private setTrackedInterval;
|
|
128
|
-
private clearKeepAliveTimer;
|
|
129
|
-
private clearReconnectTimer;
|
|
130
|
-
private clearReconnectDelay;
|
|
131
|
-
private clearAllTimers;
|
|
132
|
-
private waitForDelay;
|
|
133
|
-
private waitForSocketState;
|
|
134
|
-
private markClientDisconnected;
|
|
135
|
-
private clearClientSocketReference;
|
|
136
|
-
private cleanupSocket;
|
|
137
|
-
private connectWithTimeout;
|
|
138
|
-
private scheduleReconnect;
|
|
139
|
-
start(): Promise<void>;
|
|
140
|
-
private handleRawMessage;
|
|
141
|
-
private doReconnect;
|
|
142
|
-
stop(): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* Enqueue an event for processing.
|
|
145
|
-
* Returns true if enqueued, false if queue is full (max 5).
|
|
146
|
-
*/
|
|
147
|
-
enqueueEvent(event: DingTalkEvent): boolean;
|
|
148
|
-
private enqueueStreamMessage;
|
|
149
|
-
/** Capture the current turn's identity; close, /stop and /new invalidate it. */
|
|
150
|
-
getCardGeneration(channelId: string): symbol;
|
|
151
|
-
isCardGenerationCurrent(channelId: string, generation: symbol): boolean;
|
|
152
|
-
/** Get or create an AI card without joining an earlier turn's in-flight creation. */
|
|
153
|
-
ensureCard(channelId: string, generation?: symbol): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Replace the active card content with a full snapshot.
|
|
156
|
-
*/
|
|
157
|
-
replaceCard(channelId: string, content: string, finalize?: boolean, failed?: boolean, generation?: symbol): Promise<boolean>;
|
|
158
|
-
/**
|
|
159
|
-
* Append a delta to the active card transcript.
|
|
160
|
-
*/
|
|
161
|
-
appendToCard(channelId: string, content: string, finalize?: boolean, failed?: boolean, generation?: symbol): Promise<boolean>;
|
|
162
|
-
/**
|
|
163
|
-
* Shared body of `replaceCard`/`appendToCard`: whether to open a fresh card differs between the
|
|
164
|
-
* two (a full-snapshot replace opens one for a finalize/failed close too; a delta append only
|
|
165
|
-
* opens one for genuinely new content), so that predicate stays keyed on `append` rather than
|
|
166
|
-
* being collapsed away — everything after it (stream, then drop the card on finalize/failed/a
|
|
167
|
-
* failed stream) is identical either way.
|
|
168
|
-
*/
|
|
169
|
-
private writeCard;
|
|
170
|
-
/**
|
|
171
|
-
* Finalize and remove the active card for a channel.
|
|
172
|
-
*/
|
|
173
|
-
finalizeCard(channelId: string, content: string, generation?: symbol): Promise<boolean>;
|
|
174
|
-
/** Finish progress only: never create a card or send a fallback chat message. */
|
|
175
|
-
finalizeExistingCard(channelId: string, content: string, generation?: symbol): Promise<boolean>;
|
|
176
|
-
/** Invalidate this turn's local state. This is not a remote message deletion. */
|
|
177
|
-
discardCard(channelId: string, generation?: symbol | undefined): void;
|
|
178
|
-
/**
|
|
179
|
-
* Send a normal message natively mapping DM and Group to correct endpoints (fallback when no card).
|
|
180
|
-
*
|
|
181
|
-
* Only the message shape is decided here; the DM-vs-group routing and the POST itself belong to
|
|
182
|
-
* `sendRobotMessage`, which every other outbound message type already goes through.
|
|
183
|
-
*
|
|
184
|
-
* `opts` lets a caller that already knows what it produced (a command reply) state the format
|
|
185
|
-
* and a real title instead of the regex guess below, which exists only for callers — free-form
|
|
186
|
-
* notices, `replaceWithFinal` — that do not know their own content ahead of time (review
|
|
187
|
-
* 2026-08-24 §1.3c).
|
|
188
|
-
*/
|
|
189
|
-
sendPlain(channelId: string, text: string, opts?: {
|
|
190
|
-
title?: string;
|
|
191
|
-
markdown?: boolean;
|
|
192
|
-
}): Promise<boolean>;
|
|
193
|
-
/**
|
|
194
|
-
* Deliver a local file to a channel as a native attachment. Uploads the bytes
|
|
195
|
-
* to get a `media_id`, then sends a `sampleImageMsg` (inline image) or
|
|
196
|
-
* `sampleFile` (downloadable file) robot message. `channelId` is supplied by
|
|
197
|
-
* the runtime (the tool is bound to its channel at build time), never by the
|
|
198
|
-
* model, so an agent cannot target a channel other than its own.
|
|
199
|
-
*/
|
|
200
|
-
sendMedia(channelId: string, media: OutboundMedia): Promise<MediaSendResult>;
|
|
201
|
-
/**
|
|
202
|
-
* Upload raw bytes to DingTalk and return the reusable `media_id`, or null on
|
|
203
|
-
* failure. The upload endpoint lives on the legacy oapi host and answers 200
|
|
204
|
-
* with a non-zero `errcode` on failure, so the body is inspected explicitly.
|
|
205
|
-
*/
|
|
206
|
-
private uploadMedia;
|
|
207
|
-
/**
|
|
208
|
-
* Two-step DingTalk inbound file download (spec 049): `messageFiles/download` exchanges the
|
|
209
|
-
* message's `downloadCode` for a short-lived `downloadUrl`, then that URL is fetched for the
|
|
210
|
-
* actual bytes. Both hops reuse `getAccessToken()` — the same app access token works across
|
|
211
|
-
* DingTalk's hosts, as the comment on `DINGTALK_OAPI` above explains for the outbound side.
|
|
212
|
-
*
|
|
213
|
-
* This runs from `onStreamMessage`'s per-channel ingestion queue, never from inside a turn: a
|
|
214
|
-
* busy channel can queue a message for minutes (`USER_MESSAGE_QUEUE_LIMIT`), and by the time a
|
|
215
|
-
* queued turn actually ran, a `downloadCode`/`downloadUrl` fetched only then could easily have
|
|
216
|
-
* already expired.
|
|
217
|
-
*
|
|
218
|
-
* `protected` so the deterministic e2e harness can override it and run this path with zero
|
|
219
|
-
* network, the same pattern `HarnessDingTalkBot` already uses for outbound calls.
|
|
220
|
-
*/
|
|
221
|
-
protected downloadMessageFile(downloadCode: string): Promise<{
|
|
222
|
-
data: Buffer;
|
|
223
|
-
} | null>;
|
|
224
|
-
/**
|
|
225
|
-
* Resolve one parsed message's image credentials into persisted `InboundImage`s and a text
|
|
226
|
-
* with every `[图片N]` marker either left as-is (success) or replaced with a reason (spec 049
|
|
227
|
-
* D8): a download failure, an unrecognized format, an oversized file, or a message that
|
|
228
|
-
* simply carried more images than `MAX_INBOUND_IMAGES_PER_MESSAGE` allows. A failure on one
|
|
229
|
-
* image never drops the rest of the message — only that one marker changes.
|
|
230
|
-
*
|
|
231
|
-
* No-op (no network call at all) when the message carries no image credentials, so a plain
|
|
232
|
-
* text message never pays for this method's existence.
|
|
233
|
-
*/
|
|
234
|
-
private resolveInboundAttachments;
|
|
235
|
-
/**
|
|
236
|
-
* POST a robot message with an arbitrary msgKey/msgParam, routing DM vs group
|
|
237
|
-
* to the correct endpoint. The single outbound path for every non-card message:
|
|
238
|
-
* plain text/markdown, images, and files.
|
|
239
|
-
*/
|
|
240
|
-
private sendRobotMessage;
|
|
241
|
-
private createCard;
|
|
242
|
-
private createCardUncached;
|
|
243
|
-
private streamCard;
|
|
244
|
-
private streamCardRequest;
|
|
245
|
-
private getAccessToken;
|
|
246
|
-
private refreshAccessToken;
|
|
247
|
-
private onStreamMessage;
|
|
248
|
-
/**
|
|
249
|
-
* Command / busy / `/new` routing for one inbound event, ending in `enqueueStreamMessage`
|
|
250
|
-
* for a normal message. Split out of `onStreamMessage` so the deterministic e2e harness
|
|
251
|
-
* (spec 048) can exercise the real transport queue and busy semantics without a socket.
|
|
252
|
-
*/
|
|
253
|
-
routeInboundEvent(event: DingTalkEvent): Promise<void>;
|
|
254
|
-
/**
|
|
255
|
-
* Drop queued-but-not-started messages for a channel (e.g. on /stop) so they
|
|
256
|
-
* do not run after the user halts the current task. Returns dropped count.
|
|
257
|
-
*/
|
|
258
|
-
clearPendingMessages(channelId: string): number;
|
|
259
|
-
/**
|
|
260
|
-
* Detach all queued work from the previous session generation. The in-flight callback may
|
|
261
|
-
* still unwind on its old queue object, while subsequent messages get a fresh queue.
|
|
262
|
-
*/
|
|
263
|
-
resetChannelQueue(channelId: string): number;
|
|
264
|
-
/** Test seam (spec 048): true when no channel queue has pending or in-flight work. */
|
|
265
|
-
allChannelQueuesIdle(): boolean;
|
|
266
|
-
private getQueue;
|
|
267
|
-
private getConversationMeta;
|
|
268
|
-
private setConversationMeta;
|
|
269
|
-
private getConversationMetaPath;
|
|
270
|
-
private touchChannel;
|
|
271
|
-
private cleanupIdleChannelCaches;
|
|
272
|
-
}
|