botmux 2.33.0 → 2.34.0
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/README.en.md +12 -1
- package/README.md +45 -1
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +11 -0
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/cli/bots-list-output.d.ts +21 -0
- package/dist/cli/bots-list-output.d.ts.map +1 -0
- package/dist/cli/bots-list-output.js +23 -0
- package/dist/cli/bots-list-output.js.map +1 -0
- package/dist/cli/workflow.d.ts +13 -0
- package/dist/cli/workflow.d.ts.map +1 -0
- package/dist/cli/workflow.js +781 -0
- package/dist/cli/workflow.js.map +1 -0
- package/dist/cli.js +69 -14
- package/dist/cli.js.map +1 -1
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +219 -6
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/session-manager.d.ts +6 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +22 -12
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/worker-pool.d.ts +13 -0
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +100 -6
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +3 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +884 -3
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/auth.d.ts +36 -0
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +22 -0
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/web/app.js +20 -1
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +356 -0
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/workflow-catalog.d.ts +2 -0
- package/dist/dashboard/web/workflow-catalog.d.ts.map +1 -0
- package/dist/dashboard/web/workflow-catalog.js +323 -0
- package/dist/dashboard/web/workflow-catalog.js.map +1 -0
- package/dist/dashboard/web/workflows.d.ts +2 -0
- package/dist/dashboard/web/workflows.d.ts.map +1 -0
- package/dist/dashboard/web/workflows.js +1618 -0
- package/dist/dashboard/web/workflows.js.map +1 -0
- package/dist/dashboard/workflow-api.d.ts +23 -0
- package/dist/dashboard/workflow-api.d.ts.map +1 -0
- package/dist/dashboard/workflow-api.js +463 -0
- package/dist/dashboard/workflow-api.js.map +1 -0
- package/dist/dashboard-web/app.js +494 -199
- package/dist/dashboard-web/index.html +1 -0
- package/dist/dashboard-web/style.css +160 -6
- package/dist/dashboard-web/terminal-replay.html +227 -0
- package/dist/dashboard.js +29 -12
- package/dist/dashboard.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +12 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +12 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts +3 -0
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +27 -1
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +19 -2
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +21 -2
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/workflow-card-handler.d.ts +50 -0
- package/dist/im/lark/workflow-card-handler.d.ts.map +1 -0
- package/dist/im/lark/workflow-card-handler.js +152 -0
- package/dist/im/lark/workflow-card-handler.js.map +1 -0
- package/dist/im/lark/workflow-cards.d.ts +46 -0
- package/dist/im/lark/workflow-cards.d.ts.map +1 -0
- package/dist/im/lark/workflow-cards.js +226 -0
- package/dist/im/lark/workflow-cards.js.map +1 -0
- package/dist/im/lark/workflow-progress-card.d.ts +76 -0
- package/dist/im/lark/workflow-progress-card.d.ts.map +1 -0
- package/dist/im/lark/workflow-progress-card.js +279 -0
- package/dist/im/lark/workflow-progress-card.js.map +1 -0
- package/dist/im/lark/workflow-slash-command.d.ts +92 -0
- package/dist/im/lark/workflow-slash-command.d.ts.map +1 -0
- package/dist/im/lark/workflow-slash-command.js +185 -0
- package/dist/im/lark/workflow-slash-command.js.map +1 -0
- package/dist/services/group-creator.d.ts.map +1 -1
- package/dist/services/group-creator.js +17 -4
- package/dist/services/group-creator.js.map +1 -1
- package/dist/services/groups-store.d.ts +11 -0
- package/dist/services/groups-store.d.ts.map +1 -1
- package/dist/services/groups-store.js +26 -0
- package/dist/services/groups-store.js.map +1 -1
- package/dist/services/jsonl-cursor.d.ts +12 -0
- package/dist/services/jsonl-cursor.d.ts.map +1 -0
- package/dist/services/jsonl-cursor.js +45 -0
- package/dist/services/jsonl-cursor.js.map +1 -0
- package/dist/services/schedule-store.d.ts +35 -0
- package/dist/services/schedule-store.d.ts.map +1 -1
- package/dist/services/schedule-store.js +108 -1
- package/dist/services/schedule-store.js.map +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +399 -0
- package/dist/skills/definitions.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cli-usage-limit.d.ts.map +1 -1
- package/dist/utils/cli-usage-limit.js +4 -0
- package/dist/utils/cli-usage-limit.js.map +1 -1
- package/dist/worker.js +118 -14
- package/dist/worker.js.map +1 -1
- package/dist/workflows/attempt-resume.d.ts +114 -0
- package/dist/workflows/attempt-resume.d.ts.map +1 -0
- package/dist/workflows/attempt-resume.js +385 -0
- package/dist/workflows/attempt-resume.js.map +1 -0
- package/dist/workflows/attempt-terminal.d.ts +21 -0
- package/dist/workflows/attempt-terminal.d.ts.map +1 -0
- package/dist/workflows/attempt-terminal.js +7 -0
- package/dist/workflows/attempt-terminal.js.map +1 -0
- package/dist/workflows/blob.d.ts +27 -0
- package/dist/workflows/blob.d.ts.map +1 -0
- package/dist/workflows/blob.js +39 -0
- package/dist/workflows/blob.js.map +1 -0
- package/dist/workflows/cancel-run.d.ts +45 -0
- package/dist/workflows/cancel-run.d.ts.map +1 -0
- package/dist/workflows/cancel-run.js +99 -0
- package/dist/workflows/cancel-run.js.map +1 -0
- package/dist/workflows/cancel.d.ts +111 -0
- package/dist/workflows/cancel.d.ts.map +1 -0
- package/dist/workflows/cancel.js +120 -0
- package/dist/workflows/cancel.js.map +1 -0
- package/dist/workflows/catalog.d.ts +60 -0
- package/dist/workflows/catalog.d.ts.map +1 -0
- package/dist/workflows/catalog.js +119 -0
- package/dist/workflows/catalog.js.map +1 -0
- package/dist/workflows/cold-attach.d.ts +30 -0
- package/dist/workflows/cold-attach.d.ts.map +1 -0
- package/dist/workflows/cold-attach.js +40 -0
- package/dist/workflows/cold-attach.js.map +1 -0
- package/dist/workflows/cold-scan.d.ts +21 -0
- package/dist/workflows/cold-scan.d.ts.map +1 -0
- package/dist/workflows/cold-scan.js +70 -0
- package/dist/workflows/cold-scan.js.map +1 -0
- package/dist/workflows/daemon-spawn.d.ts +117 -0
- package/dist/workflows/daemon-spawn.d.ts.map +1 -0
- package/dist/workflows/daemon-spawn.js +551 -0
- package/dist/workflows/daemon-spawn.js.map +1 -0
- package/dist/workflows/definition.d.ts +1309 -0
- package/dist/workflows/definition.d.ts.map +1 -0
- package/dist/workflows/definition.js +334 -0
- package/dist/workflows/definition.js.map +1 -0
- package/dist/workflows/effect-input.d.ts +4 -0
- package/dist/workflows/effect-input.d.ts.map +1 -0
- package/dist/workflows/effect-input.js +18 -0
- package/dist/workflows/effect-input.js.map +1 -0
- package/dist/workflows/events/append.d.ts +77 -0
- package/dist/workflows/events/append.d.ts.map +1 -0
- package/dist/workflows/events/append.js +214 -0
- package/dist/workflows/events/append.js.map +1 -0
- package/dist/workflows/events/idempotency.d.ts +77 -0
- package/dist/workflows/events/idempotency.d.ts.map +1 -0
- package/dist/workflows/events/idempotency.js +116 -0
- package/dist/workflows/events/idempotency.js.map +1 -0
- package/dist/workflows/events/index.d.ts +7 -0
- package/dist/workflows/events/index.d.ts.map +1 -0
- package/dist/workflows/events/index.js +7 -0
- package/dist/workflows/events/index.js.map +1 -0
- package/dist/workflows/events/payloads.d.ts +917 -0
- package/dist/workflows/events/payloads.d.ts.map +1 -0
- package/dist/workflows/events/payloads.js +337 -0
- package/dist/workflows/events/payloads.js.map +1 -0
- package/dist/workflows/events/replay.d.ts +238 -0
- package/dist/workflows/events/replay.d.ts.map +1 -0
- package/dist/workflows/events/replay.js +608 -0
- package/dist/workflows/events/replay.js.map +1 -0
- package/dist/workflows/events/schema.d.ts +5242 -0
- package/dist/workflows/events/schema.d.ts.map +1 -0
- package/dist/workflows/events/schema.js +295 -0
- package/dist/workflows/events/schema.js.map +1 -0
- package/dist/workflows/events/types.d.ts +34 -0
- package/dist/workflows/events/types.d.ts.map +1 -0
- package/dist/workflows/events/types.js +2 -0
- package/dist/workflows/events/types.js.map +1 -0
- package/dist/workflows/fanout.d.ts +36 -0
- package/dist/workflows/fanout.d.ts.map +1 -0
- package/dist/workflows/fanout.js +114 -0
- package/dist/workflows/fanout.js.map +1 -0
- package/dist/workflows/hostExecutors/botmux-schedule.d.ts +41 -0
- package/dist/workflows/hostExecutors/botmux-schedule.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/botmux-schedule.js +121 -0
- package/dist/workflows/hostExecutors/botmux-schedule.js.map +1 -0
- package/dist/workflows/hostExecutors/feishu-im.d.ts +12 -0
- package/dist/workflows/hostExecutors/feishu-im.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/feishu-im.js +49 -0
- package/dist/workflows/hostExecutors/feishu-im.js.map +1 -0
- package/dist/workflows/hostExecutors/feishu-reply.d.ts +24 -0
- package/dist/workflows/hostExecutors/feishu-reply.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/feishu-reply.js +88 -0
- package/dist/workflows/hostExecutors/feishu-reply.js.map +1 -0
- package/dist/workflows/hostExecutors/feishu-send.d.ts +23 -0
- package/dist/workflows/hostExecutors/feishu-send.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/feishu-send.js +124 -0
- package/dist/workflows/hostExecutors/feishu-send.js.map +1 -0
- package/dist/workflows/hostExecutors/index.d.ts +8 -0
- package/dist/workflows/hostExecutors/index.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/index.js +8 -0
- package/dist/workflows/hostExecutors/index.js.map +1 -0
- package/dist/workflows/hostExecutors/protocol.d.ts +42 -0
- package/dist/workflows/hostExecutors/protocol.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/protocol.js +181 -0
- package/dist/workflows/hostExecutors/protocol.js.map +1 -0
- package/dist/workflows/hostExecutors/registry.d.ts +10 -0
- package/dist/workflows/hostExecutors/registry.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/registry.js +36 -0
- package/dist/workflows/hostExecutors/registry.js.map +1 -0
- package/dist/workflows/hostExecutors/types.d.ts +78 -0
- package/dist/workflows/hostExecutors/types.d.ts.map +1 -0
- package/dist/workflows/hostExecutors/types.js +2 -0
- package/dist/workflows/hostExecutors/types.js.map +1 -0
- package/dist/workflows/loader.d.ts +16 -0
- package/dist/workflows/loader.d.ts.map +1 -0
- package/dist/workflows/loader.js +56 -0
- package/dist/workflows/loader.js.map +1 -0
- package/dist/workflows/loop.d.ts +50 -0
- package/dist/workflows/loop.d.ts.map +1 -0
- package/dist/workflows/loop.js +350 -0
- package/dist/workflows/loop.js.map +1 -0
- package/dist/workflows/ops-projection.d.ts +168 -0
- package/dist/workflows/ops-projection.d.ts.map +1 -0
- package/dist/workflows/ops-projection.js +707 -0
- package/dist/workflows/ops-projection.js.map +1 -0
- package/dist/workflows/orchestrator.d.ts +107 -0
- package/dist/workflows/orchestrator.d.ts.map +1 -0
- package/dist/workflows/orchestrator.js +197 -0
- package/dist/workflows/orchestrator.js.map +1 -0
- package/dist/workflows/output-binding.d.ts +70 -0
- package/dist/workflows/output-binding.d.ts.map +1 -0
- package/dist/workflows/output-binding.js +265 -0
- package/dist/workflows/output-binding.js.map +1 -0
- package/dist/workflows/params.d.ts +61 -0
- package/dist/workflows/params.d.ts.map +1 -0
- package/dist/workflows/params.js +195 -0
- package/dist/workflows/params.js.map +1 -0
- package/dist/workflows/resume.d.ts +263 -0
- package/dist/workflows/resume.d.ts.map +1 -0
- package/dist/workflows/resume.js +808 -0
- package/dist/workflows/resume.js.map +1 -0
- package/dist/workflows/run-id.d.ts +2 -0
- package/dist/workflows/run-id.d.ts.map +1 -0
- package/dist/workflows/run-id.js +7 -0
- package/dist/workflows/run-id.js.map +1 -0
- package/dist/workflows/run-init.d.ts +48 -0
- package/dist/workflows/run-init.d.ts.map +1 -0
- package/dist/workflows/run-init.js +99 -0
- package/dist/workflows/run-init.js.map +1 -0
- package/dist/workflows/runs-dir.d.ts +4 -0
- package/dist/workflows/runs-dir.d.ts.map +1 -0
- package/dist/workflows/runs-dir.js +15 -0
- package/dist/workflows/runs-dir.js.map +1 -0
- package/dist/workflows/runtime.d.ts +211 -0
- package/dist/workflows/runtime.d.ts.map +1 -0
- package/dist/workflows/runtime.js +594 -0
- package/dist/workflows/runtime.js.map +1 -0
- package/dist/workflows/spawn-bot.d.ts +165 -0
- package/dist/workflows/spawn-bot.d.ts.map +1 -0
- package/dist/workflows/spawn-bot.js +215 -0
- package/dist/workflows/spawn-bot.js.map +1 -0
- package/dist/workflows/system.d.ts +49 -0
- package/dist/workflows/system.d.ts.map +1 -0
- package/dist/workflows/system.js +48 -0
- package/dist/workflows/system.js.map +1 -0
- package/dist/workflows/trigger-run.d.ts +70 -0
- package/dist/workflows/trigger-run.d.ts.map +1 -0
- package/dist/workflows/trigger-run.js +88 -0
- package/dist/workflows/trigger-run.js.map +1 -0
- package/dist/workflows/wait.d.ts +120 -0
- package/dist/workflows/wait.d.ts.map +1 -0
- package/dist/workflows/wait.js +181 -0
- package/dist/workflows/wait.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume + reconcile algorithm (events doc v0.1.2 §4.3 + §4.3.1).
|
|
3
|
+
*
|
|
4
|
+
* Entry point for daemon restart / hand-off. Walks the event log,
|
|
5
|
+
* replays a snapshot, then drives reconcile decisions for each dangling
|
|
6
|
+
* `effectAttempted` and writes terminal events for `pure skill`
|
|
7
|
+
* activities that crashed mid-flight (workerLost path).
|
|
8
|
+
*
|
|
9
|
+
* Step 7 boundaries:
|
|
10
|
+
* - Resume DOES NOT execute activity logic; reconcile uses provider
|
|
11
|
+
* capabilities (`readOnlyLookup` / `idempotentSubmit`) to decide
|
|
12
|
+
* terminal state without re-issuing user-visible work beyond what
|
|
13
|
+
* idempotency guarantees.
|
|
14
|
+
* - Resume DOES NOT decide retry policy. A `freshRetry` decision
|
|
15
|
+
* leaves the attempt dangling — the scheduler (Step 8+) is
|
|
16
|
+
* responsible for spawning the actual replacement attempt.
|
|
17
|
+
* - Dangling waits are left alone (waiting for external signal).
|
|
18
|
+
*
|
|
19
|
+
* Round 1 fixes (codex review of `1d14081`):
|
|
20
|
+
* F1 — replay surfaces the latest reconcileResult per attempt; resume
|
|
21
|
+
* consumes it before re-running the decision tree, so a crash
|
|
22
|
+
* between reconcileResult and the terminal event is recoverable.
|
|
23
|
+
* F2 — reconcilers receive the materialized effect input via the
|
|
24
|
+
* caller-supplied `loadEffectInput` callback. Reconcilers that
|
|
25
|
+
* require input (e.g. Feishu — chatId/rootMessageId/content can't
|
|
26
|
+
* be reconstructed from idempotencyKey alone) fail explicitly
|
|
27
|
+
* when input is unrecoverable.
|
|
28
|
+
* F3 — `retryable` failures from idempotentSubmit do NOT terminate
|
|
29
|
+
* the attempt; the activity stays dangling and is surfaced in
|
|
30
|
+
* `ResumeResult.transientFailures` for the caller to retry.
|
|
31
|
+
* F4 — `resumeStarted` is written ONLY after a preflight validates
|
|
32
|
+
* the log is replayable; bad inputs throw without polluting the
|
|
33
|
+
* run event log.
|
|
34
|
+
*/
|
|
35
|
+
import type { EventLog } from './events/append.js';
|
|
36
|
+
import { type Snapshot, type AttemptState } from './events/replay.js';
|
|
37
|
+
import type { ActivityCanceledEvent, ActivityFailedEvent, ActivitySucceededEvent, ReconcileResultEvent, ResumeStartedEvent } from './events/types.js';
|
|
38
|
+
export type ReconcileCapability = 'readOnlyLookup' | 'idempotentSubmit' | 'none';
|
|
39
|
+
export type ReconcileDecision = 'replayed' | 'completedByIdempotentSubmit' | 'manual' | 'freshRetry';
|
|
40
|
+
export type ReadOnlyLookupResult = {
|
|
41
|
+
found: true;
|
|
42
|
+
externalRefs: Record<string, unknown>;
|
|
43
|
+
evidence?: Record<string, unknown>;
|
|
44
|
+
} | {
|
|
45
|
+
found: false;
|
|
46
|
+
evidence?: Record<string, unknown>;
|
|
47
|
+
};
|
|
48
|
+
export type IdempotentSubmitResult = {
|
|
49
|
+
ok: true;
|
|
50
|
+
externalRefs: Record<string, unknown>;
|
|
51
|
+
evidence?: Record<string, unknown>;
|
|
52
|
+
} | {
|
|
53
|
+
ok: false;
|
|
54
|
+
errorCode: string;
|
|
55
|
+
errorClass: 'retryable' | 'fatal' | 'userFault' | 'manual';
|
|
56
|
+
errorMessage: string;
|
|
57
|
+
evidence?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Per-provider capability bundle. Resume looks up the reconciler by the
|
|
61
|
+
* `effectAttempted.provider` field; missing entries fall through to
|
|
62
|
+
* manual/UnknownProviderError.
|
|
63
|
+
*
|
|
64
|
+
* Reconcilers receive the materialized effect input alongside the
|
|
65
|
+
* idempotencyKey: providers like Feishu can't re-construct the request
|
|
66
|
+
* body from the key alone (the key is a hash, not the body). When the
|
|
67
|
+
* caller doesn't supply `loadEffectInput`, resume treats the input as
|
|
68
|
+
* `undefined`; reconcilers that NEED input MUST declare so via
|
|
69
|
+
* `requiresEffectInput` so resume can fail fast with a clear error
|
|
70
|
+
* instead of letting the reconciler silently misbehave.
|
|
71
|
+
*/
|
|
72
|
+
export interface ProviderReconciler {
|
|
73
|
+
readonly provider: string;
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, resume refuses to call this reconciler without a
|
|
76
|
+
* materialized effect input — i.e. it writes manual/InputUnrecoverable
|
|
77
|
+
* if `loadEffectInput` is absent or throws. Feishu sets this; schedule
|
|
78
|
+
* does not (idempotencyKey is the full key).
|
|
79
|
+
*/
|
|
80
|
+
readonly requiresEffectInput?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Pure read against the provider keyed by `idempotencyKey`. Has no
|
|
83
|
+
* side effects; safe to call from resume even when we don't intend to
|
|
84
|
+
* complete the effect. Schedule has it (`getTask(id)`); Feishu does
|
|
85
|
+
* not (no uuid-reverse-lookup API).
|
|
86
|
+
*/
|
|
87
|
+
readOnlyLookup?(idempotencyKey: string, input: unknown): Promise<ReadOnlyLookupResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Re-submit the effect with the same `idempotencyKey`. MAY produce
|
|
90
|
+
* the side effect for real (if the original pre-invoke crash never
|
|
91
|
+
* reached the provider); provider dedupe inside TTL guarantees the
|
|
92
|
+
* second submit returns the original ref instead of a duplicate.
|
|
93
|
+
*/
|
|
94
|
+
idempotentSubmit?(idempotencyKey: string, input: unknown): Promise<IdempotentSubmitResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Canonical form of the loaded effect input — used at resume time to
|
|
97
|
+
* recompute `inputHash` and compare against `effectAttempted.inputHash`.
|
|
98
|
+
* MUST mirror the executor's `canonicalInput` exactly; mismatched
|
|
99
|
+
* canonicalization across resume/dispatch silently breaks idempotency.
|
|
100
|
+
*
|
|
101
|
+
* Reconcilers with `requiresEffectInput=true` SHOULD implement this;
|
|
102
|
+
* resume writes `IdempotencyInputMismatch/manual` if a tampered or
|
|
103
|
+
* drifted sidecar would otherwise reach the provider with a different
|
|
104
|
+
* body than the original attempt promised.
|
|
105
|
+
*/
|
|
106
|
+
canonicalInput?(input: unknown): unknown;
|
|
107
|
+
}
|
|
108
|
+
export type ResumeContext = {
|
|
109
|
+
/** Authoritative event log for this run. Resume writes events into it. */
|
|
110
|
+
log: EventLog;
|
|
111
|
+
/** Match `log.runId`; passed explicitly so the contract is visible. */
|
|
112
|
+
runId: string;
|
|
113
|
+
/** Daemon identifier for the resumeStarted audit event. */
|
|
114
|
+
daemonId: string;
|
|
115
|
+
/** Reconcilers keyed by provider name (`feishu-im`, `botmux-schedule`). */
|
|
116
|
+
reconcilers: Map<string, ProviderReconciler>;
|
|
117
|
+
/**
|
|
118
|
+
* Load the materialized effect input that was passed to the original
|
|
119
|
+
* attempt. Required for providers that re-submit (Feishu). Resume
|
|
120
|
+
* passes the returned value to the reconciler's readOnlyLookup /
|
|
121
|
+
* idempotentSubmit.
|
|
122
|
+
*
|
|
123
|
+
* v0: the caller (daemon) decides where to persist or recover this —
|
|
124
|
+
* in-memory while alive, or some external storage on cold start.
|
|
125
|
+
* Resume only consumes the callback.
|
|
126
|
+
*
|
|
127
|
+
* Returning `undefined` is treated as "input unrecoverable" and
|
|
128
|
+
* triggers the manual/InputUnrecoverable path for reconcilers that
|
|
129
|
+
* declared `requiresEffectInput`.
|
|
130
|
+
*/
|
|
131
|
+
loadEffectInput?(activityId: string, attemptId: string): Promise<unknown>;
|
|
132
|
+
/** Injectable clock for deterministic tests. Defaults to Date.now. */
|
|
133
|
+
now?: () => number;
|
|
134
|
+
};
|
|
135
|
+
export type ReconcileOutcome = {
|
|
136
|
+
activityId: string;
|
|
137
|
+
attemptId: string;
|
|
138
|
+
idempotencyKey: string;
|
|
139
|
+
provider: string;
|
|
140
|
+
capability: ReconcileCapability;
|
|
141
|
+
decision: ReconcileDecision;
|
|
142
|
+
evidence: Record<string, unknown>;
|
|
143
|
+
/**
|
|
144
|
+
* Terminal event written as a consequence. null for `replayed` (the
|
|
145
|
+
* pre-existing terminal IS the consequence) and `freshRetry` (scheduler
|
|
146
|
+
* issues a new attempt later, not Step 7's job).
|
|
147
|
+
*/
|
|
148
|
+
terminalEvent: ActivitySucceededEvent | ActivityFailedEvent | null;
|
|
149
|
+
/** The reconcileResult event written, or null if this outcome reused
|
|
150
|
+
* a pre-existing reconcileResult (recovery path — codex F1). */
|
|
151
|
+
reconcileEvent: ReconcileResultEvent | null;
|
|
152
|
+
/** True when this outcome recovered a prior crashed reconcile cycle
|
|
153
|
+
* rather than running the decision tree from scratch. */
|
|
154
|
+
recovered: boolean;
|
|
155
|
+
};
|
|
156
|
+
export type WorkerCrashedOutcome = {
|
|
157
|
+
activityId: string;
|
|
158
|
+
attemptId: string;
|
|
159
|
+
terminalEvent: ActivityFailedEvent;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Recovery of a wait whose resolution event landed but whose activity
|
|
163
|
+
* terminal was never written (crash between `waitResolved` /
|
|
164
|
+
* `waitDeadlineExceeded` and the terminal). Step 8: replay surfaces
|
|
165
|
+
* these as `Snapshot.danglingWaitResolutions`; resume materializes the
|
|
166
|
+
* terminal from the recorded resolution.
|
|
167
|
+
*/
|
|
168
|
+
export type WaitRecoveryOutcome = {
|
|
169
|
+
activityId: string;
|
|
170
|
+
attemptId: string;
|
|
171
|
+
/** What the recovery decided to write. */
|
|
172
|
+
kind: 'succeeded' | 'failed';
|
|
173
|
+
source: 'resolved' | 'deadlineExceeded';
|
|
174
|
+
terminalEvent: ActivitySucceededEvent | ActivityFailedEvent;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Recovery of a cancel whose request landed but whose activity
|
|
178
|
+
* terminal was never written (crash between `cancelRequested` /
|
|
179
|
+
* `cancelDelivered` and the terminal). Step 9: replay surfaces these
|
|
180
|
+
* as `Snapshot.danglingCancels`.
|
|
181
|
+
*
|
|
182
|
+
* The terminal resume writes depends on whether the cancelled
|
|
183
|
+
* attempt also had a dangling `effectAttempted` (Step 9 round 1
|
|
184
|
+
* finding 1):
|
|
185
|
+
*
|
|
186
|
+
* - **No effectAttempted** (plain cancel): resume writes
|
|
187
|
+
* `activityCanceled` directly, with `cancelOriginEventId`
|
|
188
|
+
* pointing at the originating `cancelRequested`.
|
|
189
|
+
* - **effectAttempted present** (cancel + effect): resume FIRST
|
|
190
|
+
* runs reconcile to capture provider evidence (writes
|
|
191
|
+
* `reconcileResult` with cancel-coupled keys — see
|
|
192
|
+
* payloads.ts `ReconcileResultPayload` doc), THEN decides:
|
|
193
|
+
* - `completedByIdempotentSubmit` / `freshRetry` →
|
|
194
|
+
* `activityCanceled` (cancel wins as terminal reason; the
|
|
195
|
+
* provider's outcome is preserved in reconcileResult evidence)
|
|
196
|
+
* - `manual` (TTL expired / unknown provider / submit errored
|
|
197
|
+
* fatally) → `activityFailed{manual}` — we deliberately do
|
|
198
|
+
* NOT write `activityCanceled` because provider state is
|
|
199
|
+
* unknown and pretending the cancel cleanly succeeded would
|
|
200
|
+
* lie to forensics
|
|
201
|
+
* - `transient` → NO terminal; the activity stays dangling and
|
|
202
|
+
* the next resume cycle retries (surfaces as a
|
|
203
|
+
* `TransientReconcileFailure` on `ResumeResult.transientFailures`)
|
|
204
|
+
*/
|
|
205
|
+
export type CancelRecoveryOutcome = {
|
|
206
|
+
activityId: string;
|
|
207
|
+
attemptId: string;
|
|
208
|
+
cancelOriginEventId: string;
|
|
209
|
+
/** True if cancelDelivered was already written; false means we
|
|
210
|
+
* short-circuited a never-delivered cancel. Both still terminate
|
|
211
|
+
* the activity (cancel intent is authoritative). */
|
|
212
|
+
delivered: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* What terminal we ended up writing. `cancelled` is the regular
|
|
215
|
+
* cancel terminal; `failed` is the "manual escalation" path when
|
|
216
|
+
* reconcile evidence is non-conclusive (Step 9 finding 1).
|
|
217
|
+
*/
|
|
218
|
+
kind: 'cancelled' | 'failed';
|
|
219
|
+
/** Present when reconcile ran alongside cancel — i.e. the activity
|
|
220
|
+
* had a dangling effectAttempted. Pure cancels (no effect) leave
|
|
221
|
+
* this undefined. */
|
|
222
|
+
reconcileEvent?: ReconcileResultEvent;
|
|
223
|
+
/**
|
|
224
|
+
* The reconcile decision that informed the cancel terminal (only
|
|
225
|
+
* populated when the activity had a dangling effectAttempted).
|
|
226
|
+
* - For `completedByIdempotentSubmit` and `freshRetry`, terminal is
|
|
227
|
+
* `activityCanceled`.
|
|
228
|
+
* - For `manual`, terminal is `activityFailed{manual}`.
|
|
229
|
+
*/
|
|
230
|
+
reconcileDecision?: ReconcileDecision;
|
|
231
|
+
terminalEvent: ActivityCanceledEvent | ActivityFailedEvent;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Reconcile failures that resume DELIBERATELY does not terminate (codex
|
|
235
|
+
* F3): a retryable provider failure during idempotentSubmit might mean
|
|
236
|
+
* "request landed, response lost", and writing a manual terminal there
|
|
237
|
+
* would freeze the activity in a wrong terminal state. Resume reports
|
|
238
|
+
* these back to the caller and leaves the activity dangling so the next
|
|
239
|
+
* resume cycle can retry.
|
|
240
|
+
*/
|
|
241
|
+
export type TransientReconcileFailure = {
|
|
242
|
+
activityId: string;
|
|
243
|
+
attemptId: string;
|
|
244
|
+
provider: string;
|
|
245
|
+
idempotencyKey: string;
|
|
246
|
+
errorCode: string;
|
|
247
|
+
errorClass: 'retryable';
|
|
248
|
+
errorMessage: string;
|
|
249
|
+
};
|
|
250
|
+
export type ResumeResult = {
|
|
251
|
+
resumeStartedEvent: ResumeStartedEvent;
|
|
252
|
+
/** Snapshot captured after `resumeStarted` is appended. Returned for
|
|
253
|
+
* observability — caller can inspect dangling sets it consumed. */
|
|
254
|
+
snapshot: Snapshot;
|
|
255
|
+
reconcileOutcomes: ReconcileOutcome[];
|
|
256
|
+
workerCrashedOutcomes: WorkerCrashedOutcome[];
|
|
257
|
+
transientFailures: TransientReconcileFailure[];
|
|
258
|
+
waitRecoveryOutcomes: WaitRecoveryOutcome[];
|
|
259
|
+
cancelRecoveryOutcomes: CancelRecoveryOutcome[];
|
|
260
|
+
};
|
|
261
|
+
export declare function resume(ctx: ResumeContext): Promise<ResumeResult>;
|
|
262
|
+
export type { AttemptState };
|
|
263
|
+
//# sourceMappingURL=resume.d.ts.map
|
|
@@ -0,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