approval-md 0.3.0 → 0.4.1
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.md +83 -914
- package/SPEC.md +101 -13
- package/cli.js +134 -7
- package/dist/src/adapters/smtp.d.ts +18 -0
- package/dist/src/adapters/smtp.js +24 -3
- package/dist/src/adapters/smtp.js.map +1 -1
- package/dist/src/channels/contract.d.ts +72 -0
- package/dist/src/channels/contract.js +161 -1
- package/dist/src/channels/contract.js.map +1 -1
- package/dist/src/channels/relay-server.d.ts +90 -0
- package/dist/src/channels/relay-server.js +295 -0
- package/dist/src/channels/relay-server.js.map +1 -0
- package/dist/src/channels/relay.d.ts +273 -0
- package/dist/src/channels/relay.js +564 -0
- package/dist/src/channels/relay.js.map +1 -0
- package/dist/src/channels/tagging.d.ts +25 -0
- package/dist/src/channels/tagging.js +63 -6
- package/dist/src/channels/tagging.js.map +1 -1
- package/dist/src/channels/telegram-minimal.d.ts +251 -0
- package/dist/src/channels/telegram-minimal.js +618 -0
- package/dist/src/channels/telegram-minimal.js.map +1 -0
- package/dist/src/channels/telegram-webhook.d.ts +273 -0
- package/dist/src/channels/telegram-webhook.js +536 -0
- package/dist/src/channels/telegram-webhook.js.map +1 -0
- package/dist/src/channels/telegram.d.ts +725 -20
- package/dist/src/channels/telegram.js +1332 -123
- package/dist/src/channels/telegram.js.map +1 -1
- package/dist/src/cli/amend.js +358 -5
- package/dist/src/cli/amend.js.map +1 -1
- package/dist/src/cli/attest.js +43 -6
- package/dist/src/cli/attest.js.map +1 -1
- package/dist/src/cli/audit-card.d.ts +1 -1
- package/dist/src/cli/audit-card.js +40 -1
- package/dist/src/cli/audit-card.js.map +1 -1
- package/dist/src/cli/audit.d.ts +7 -5
- package/dist/src/cli/audit.js +22 -10
- package/dist/src/cli/audit.js.map +1 -1
- package/dist/src/cli/channel-relay.d.ts +108 -0
- package/dist/src/cli/channel-relay.js +334 -0
- package/dist/src/cli/channel-relay.js.map +1 -0
- package/dist/src/cli/channel-telegram-webhook.d.ts +275 -0
- package/dist/src/cli/channel-telegram-webhook.js +716 -0
- package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
- package/dist/src/cli/channel-telegram.d.ts +347 -28
- package/dist/src/cli/channel-telegram.js +648 -56
- package/dist/src/cli/channel-telegram.js.map +1 -1
- package/dist/src/cli/channel.d.ts +1 -1
- package/dist/src/cli/channel.js +5 -1
- package/dist/src/cli/channel.js.map +1 -1
- package/dist/src/cli/daemon.js +37 -5
- package/dist/src/cli/daemon.js.map +1 -1
- package/dist/src/cli/doctor.d.ts +63 -0
- package/dist/src/cli/doctor.js +856 -111
- package/dist/src/cli/doctor.js.map +1 -1
- package/dist/src/cli/execute.d.ts +29 -1
- package/dist/src/cli/execute.js +387 -21
- package/dist/src/cli/execute.js.map +1 -1
- package/dist/src/cli/exit-codes.d.ts +12 -0
- package/dist/src/cli/exit-codes.js +13 -0
- package/dist/src/cli/exit-codes.js.map +1 -1
- package/dist/src/cli/gate.d.ts +2 -0
- package/dist/src/cli/gate.js +233 -2
- package/dist/src/cli/gate.js.map +1 -1
- package/dist/src/cli/help.d.ts +10 -1
- package/dist/src/cli/help.js +283 -54
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/hook.d.ts +485 -6
- package/dist/src/cli/hook.js +2370 -70
- package/dist/src/cli/hook.js.map +1 -1
- package/dist/src/cli/init.js +16 -7
- package/dist/src/cli/init.js.map +1 -1
- package/dist/src/cli/instructions.js +24 -3
- package/dist/src/cli/instructions.js.map +1 -1
- package/dist/src/cli/log-anchor.d.ts +55 -0
- package/dist/src/cli/log-anchor.js +199 -60
- package/dist/src/cli/log-anchor.js.map +1 -1
- package/dist/src/cli/log-unlock.d.ts +23 -0
- package/dist/src/cli/log-unlock.js +109 -0
- package/dist/src/cli/log-unlock.js.map +1 -0
- package/dist/src/cli/main.d.ts +0 -12
- package/dist/src/cli/main.js +72 -4
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/cli/muse.d.ts +2 -0
- package/dist/src/cli/muse.js +62 -0
- package/dist/src/cli/muse.js.map +1 -0
- package/dist/src/cli/payload.js +79 -1
- package/dist/src/cli/payload.js.map +1 -1
- package/dist/src/cli/scaffold.js +6 -0
- package/dist/src/cli/scaffold.js.map +1 -1
- package/dist/src/cli/serve.d.ts +53 -0
- package/dist/src/cli/serve.js +270 -0
- package/dist/src/cli/serve.js.map +1 -0
- package/dist/src/cli/up.js +26 -2
- package/dist/src/cli/up.js.map +1 -1
- package/dist/src/cli/verb-registry.d.ts +2 -0
- package/dist/src/cli/verb-registry.js +338 -39
- package/dist/src/cli/verb-registry.js.map +1 -1
- package/dist/src/cli/wordmark.d.ts +2 -2
- package/dist/src/cli/wordmark.js +2 -2
- package/dist/src/core/attest-bootstrap.d.ts +95 -0
- package/dist/src/core/attest-bootstrap.js +135 -0
- package/dist/src/core/attest-bootstrap.js.map +1 -0
- package/dist/src/core/attest.d.ts +20 -3
- package/dist/src/core/attest.js +25 -0
- package/dist/src/core/attest.js.map +1 -1
- package/dist/src/core/audit.d.ts +153 -12
- package/dist/src/core/audit.js +415 -20
- package/dist/src/core/audit.js.map +1 -1
- package/dist/src/core/channel-lease.d.ts +322 -0
- package/dist/src/core/channel-lease.js +663 -0
- package/dist/src/core/channel-lease.js.map +1 -0
- package/dist/src/core/command-class.d.ts +51 -0
- package/dist/src/core/command-class.js +766 -8
- package/dist/src/core/command-class.js.map +1 -1
- package/dist/src/core/daemon-host.d.ts +178 -0
- package/dist/src/core/daemon-host.js +228 -0
- package/dist/src/core/daemon-host.js.map +1 -0
- package/dist/src/core/daemon-identity.d.ts +238 -0
- package/dist/src/core/daemon-identity.js +252 -0
- package/dist/src/core/daemon-identity.js.map +1 -0
- package/dist/src/core/gate.d.ts +364 -6
- package/dist/src/core/gate.js +802 -27
- package/dist/src/core/gate.js.map +1 -1
- package/dist/src/core/harness-version.d.ts +128 -4
- package/dist/src/core/harness-version.js +179 -12
- package/dist/src/core/harness-version.js.map +1 -1
- package/dist/src/core/harness-wait.d.ts +82 -3
- package/dist/src/core/harness-wait.js +89 -3
- package/dist/src/core/harness-wait.js.map +1 -1
- package/dist/src/core/log-lock.d.ts +435 -0
- package/dist/src/core/log-lock.js +1093 -0
- package/dist/src/core/log-lock.js.map +1 -0
- package/dist/src/core/log-subscribe.d.ts +21 -0
- package/dist/src/core/log-subscribe.js +16 -6
- package/dist/src/core/log-subscribe.js.map +1 -1
- package/dist/src/core/log-write-layer.d.ts +55 -0
- package/dist/src/core/log-write-layer.js +91 -0
- package/dist/src/core/log-write-layer.js.map +1 -0
- package/dist/src/core/log.d.ts +130 -22
- package/dist/src/core/log.js +473 -50
- package/dist/src/core/log.js.map +1 -1
- package/dist/src/core/payload-census.d.ts +51 -0
- package/dist/src/core/payload-census.js +125 -2
- package/dist/src/core/payload-census.js.map +1 -1
- package/dist/src/core/payload-store.d.ts +31 -0
- package/dist/src/core/payload-store.js +113 -8
- package/dist/src/core/payload-store.js.map +1 -1
- package/dist/src/core/payload.d.ts +18 -3
- package/dist/src/core/payload.js +20 -4
- package/dist/src/core/payload.js.map +1 -1
- package/dist/src/core/policy-diff.d.ts +10 -0
- package/dist/src/core/policy-diff.js +10 -2
- package/dist/src/core/policy-diff.js.map +1 -1
- package/dist/src/core/policy-explain.d.ts +7 -1
- package/dist/src/core/policy-explain.js +16 -1
- package/dist/src/core/policy-explain.js.map +1 -1
- package/dist/src/core/policy-load.d.ts +24 -0
- package/dist/src/core/policy-load.js.map +1 -1
- package/dist/src/core/policy-match.d.ts +38 -0
- package/dist/src/core/policy-match.js +35 -0
- package/dist/src/core/policy-match.js.map +1 -1
- package/dist/src/core/policy-proposal.d.ts +40 -0
- package/dist/src/core/policy-proposal.js +37 -16
- package/dist/src/core/policy-proposal.js.map +1 -1
- package/dist/src/core/prompt-layout.d.ts +186 -1
- package/dist/src/core/prompt-layout.js +345 -3
- package/dist/src/core/prompt-layout.js.map +1 -1
- package/dist/src/core/read-scope.d.ts +10 -0
- package/dist/src/core/read-scope.js +4 -0
- package/dist/src/core/read-scope.js.map +1 -1
- package/dist/src/core/run-payload.d.ts +160 -0
- package/dist/src/core/run-payload.js +304 -0
- package/dist/src/core/run-payload.js.map +1 -0
- package/dist/src/core/sender-identity.d.ts +59 -11
- package/dist/src/core/sender-identity.js +79 -11
- package/dist/src/core/sender-identity.js.map +1 -1
- package/dist/src/core/state.d.ts +52 -1
- package/dist/src/core/state.js +52 -6
- package/dist/src/core/state.js.map +1 -1
- package/dist/src/core/telegram-config.d.ts +79 -0
- package/dist/src/core/telegram-config.js +108 -0
- package/dist/src/core/telegram-config.js.map +1 -1
- package/dist/src/core/validate.d.ts +20 -6
- package/dist/src/core/validate.js +0 -0
- package/dist/src/core/validate.js.map +1 -1
- package/dist/src/core/verify.d.ts +23 -1
- package/dist/src/core/verify.js +20 -2
- package/dist/src/core/verify.js.map +1 -1
- package/dist/src/daemon/audit.d.ts +80 -5
- package/dist/src/daemon/audit.js +126 -6
- package/dist/src/daemon/audit.js.map +1 -1
- package/dist/src/daemon/daemon.d.ts +174 -2
- package/dist/src/daemon/daemon.js +298 -7
- package/dist/src/daemon/daemon.js.map +1 -1
- package/dist/src/daemon/git-evidence.d.ts +2 -2
- package/dist/src/daemon/git-evidence.js +1 -1
- package/dist/src/daemon/projection.d.ts +13 -2
- package/dist/src/daemon/projection.js +39 -6
- package/dist/src/daemon/projection.js.map +1 -1
- package/dist/src/mcp/server.d.ts +39 -3
- package/dist/src/mcp/server.js +22 -3
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/muse/server.d.ts +16 -0
- package/dist/src/muse/server.js +238 -0
- package/dist/src/muse/server.js.map +1 -0
- package/dist/src/serve/archive.d.ts +166 -0
- package/dist/src/serve/archive.js +363 -0
- package/dist/src/serve/archive.js.map +1 -0
- package/dist/src/serve/arguments.d.ts +93 -0
- package/dist/src/serve/arguments.js +228 -0
- package/dist/src/serve/arguments.js.map +1 -0
- package/dist/src/serve/credentials.d.ts +91 -0
- package/dist/src/serve/credentials.js +143 -0
- package/dist/src/serve/credentials.js.map +1 -0
- package/dist/src/serve/follow.d.ts +86 -0
- package/dist/src/serve/follow.js +101 -0
- package/dist/src/serve/follow.js.map +1 -0
- package/dist/src/serve/hook-thread.d.ts +134 -0
- package/dist/src/serve/hook-thread.js +333 -0
- package/dist/src/serve/hook-thread.js.map +1 -0
- package/dist/src/serve/hook-worker.d.ts +134 -0
- package/dist/src/serve/hook-worker.js +173 -0
- package/dist/src/serve/hook-worker.js.map +1 -0
- package/dist/src/serve/server.d.ts +412 -0
- package/dist/src/serve/server.js +1251 -0
- package/dist/src/serve/server.js.map +1 -0
- package/docs/README-extended.md +768 -0
- package/docs/cli-reference.md +2139 -67
- package/package.json +4 -2
- package/schema/event.schema.json +413 -30
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-age-without-created.json +19 -0
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-agent-actor.json +14 -0
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-lockfile-path.json +14 -0
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-operator-cleared-system-actor.json +14 -0
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-unknown-reason.json +14 -0
- package/schema/fixtures/event/invalid/audit-lock-reclaimed-without-age.json +13 -0
- package/schema/fixtures/event/invalid/audit-reviewed-agent-actor.json +6 -1
- package/schema/fixtures/event/invalid/audit-reviewed-bad-payload-hash.json +21 -0
- package/schema/fixtures/event/invalid/audit-reviewed-loved-no-note.json +5 -0
- package/schema/fixtures/event/invalid/audit-reviewed-no-subject-hash.json +19 -0
- package/schema/fixtures/event/invalid/audit-reviewed-no-subject-seq.json +19 -0
- package/schema/fixtures/event/invalid/audit-reviewed-no-verdict-source.json +19 -0
- package/schema/fixtures/event/invalid/audit-reviewed-no-verdict.json +19 -0
- package/schema/fixtures/event/invalid/audit-reviewed-system-actor.json +6 -1
- package/schema/fixtures/event/invalid/audit-sampled-no-policy-hash.json +14 -0
- package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
- package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
- package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
- package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
- package/schema/fixtures/event/valid/audit-lock-reclaimed-implausible-created.json +18 -0
- package/schema/fixtures/event/valid/audit-lock-reclaimed-legacy.json +14 -0
- package/schema/fixtures/event/valid/audit-lock-reclaimed-unlock.json +19 -0
- package/schema/fixtures/event/valid/audit-lock-reclaimed.json +19 -0
- package/schema/fixtures/event/valid/audit-reviewed-reaction.json +5 -0
- package/schema/fixtures/event/valid/audit-reviewed.json +6 -1
- package/schema/fixtures/event/valid/audit-sampled.json +2 -1
- package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
- package/schema/fixtures/event/valid/daemon-identity.json +16 -0
- package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
- package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
- package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
- package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
- package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
- package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
- package/schema/policy.schema.json +102 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-telegram-webhook.js","sourceRoot":"","sources":["../../../src/cli/channel-telegram-webhook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,UAAU,EAAE,OAAO,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C7D,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC;QAC/B,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC;QACjC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;QACnC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;QACrC,GAAG,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,IAAI,CAAC;QACrD,GAAG,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE;YAC1D,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CACrB,OAAO,CAAC,GAAG,CAAC,sCAAsC,MAAM,4BAA4B,CAAC;SACxF,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,2EAA2E;QAC3E,yEAAyE;QACzE,2DAA2D;QAC3D,OAAO,QAAQ,CAAC,IAAI,KAAK,gBAAgB,IAAI,QAAQ,CAAC,IAAI,KAAK,qBAAqB;YAClF,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;YAC1C,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -107,12 +107,13 @@
|
|
|
107
107
|
* a send failure: an operator who has just mistyped a chat id or a token should
|
|
108
108
|
* learn it immediately rather than watch a listener retry forever.
|
|
109
109
|
*/
|
|
110
|
-
import type
|
|
110
|
+
import { type DecideOptions } from "../core/gate.js";
|
|
111
111
|
import { type ChannelRequest, type DeliveryId } from "../channels/contract.js";
|
|
112
112
|
import { type ChannelTagRefusalCode, type TagOptions } from "../channels/tagging.js";
|
|
113
113
|
import { type CheckpointTap } from "./checkpoint-tap.js";
|
|
114
114
|
import { TelegramChannel, type CheckpointTapResponse, type ReviewCard, type ReviewTapResponse, type TelegramCommand, type TelegramTerminalState } from "../channels/telegram.js";
|
|
115
115
|
import { type TelegramDelivery } from "../core/telegram-config.js";
|
|
116
|
+
import { type ChannelLease, type ChannelLeaseMode } from "../core/channel-lease.js";
|
|
116
117
|
import { type InstanceFinding } from "../core/instance.js";
|
|
117
118
|
import { type ChannelSender } from "../core/sender-identity.js";
|
|
118
119
|
import { type ParsedFlags } from "./args.js";
|
|
@@ -213,33 +214,94 @@ export interface ListenSetup {
|
|
|
213
214
|
checkpoint: CheckpointTap;
|
|
214
215
|
}
|
|
215
216
|
/**
|
|
216
|
-
* Claim this listener's bot before it polls (APRV-390).
|
|
217
|
+
* Claim this listener's bot before it polls (APRV-390, extended by APRV-424).
|
|
217
218
|
*
|
|
218
|
-
*
|
|
219
|
-
* come out of it: the bot's identity, which is the only thing that can tell
|
|
220
|
-
* two instances holding two differently-named copies of one token apart; and
|
|
221
|
-
* a claim in the per-machine registry, which is what makes the SECOND such
|
|
222
|
-
* listener refuse instead of joining a 409 loop.
|
|
219
|
+
* Three questions, in order, and each one has its own authority:
|
|
223
220
|
*
|
|
224
|
-
*
|
|
221
|
+
* 1. **Does anything else in THIS gate already hold the Telegram transport?**
|
|
222
|
+
* A lockfile in the gate's own `daemon/` directory (`core/channel-lease.ts`)
|
|
223
|
+
* answers it, and the answer is per PROCESS. This is the check the review of
|
|
224
|
+
* APRV-424 added, and the hole it closes is the one neither of the other two
|
|
225
|
+
* could see: an `approval up` long-polling and an `approval channel telegram
|
|
226
|
+
* webhook` started in the same project pass both of them — `getWebhookInfo`
|
|
227
|
+
* is empty while the poller is the one running, and the ownership registry
|
|
228
|
+
* compares instance ids, which are equal because it IS the same instance —
|
|
229
|
+
* and then each runs its own dispatch cycle over its own state against one
|
|
230
|
+
* log, so every request reaches the phone twice under two nonces and only
|
|
231
|
+
* one copy can resolve a tap.
|
|
232
|
+
* 2. **What is the Bot API delivering this bot's updates to?** `getWebhookInfo`
|
|
233
|
+
* answers it, and it is the only thing that can see a webhook registered
|
|
234
|
+
* from another machine. A webhook beats a poller outright — `getUpdates` is
|
|
235
|
+
* refused while one is set — so any registration refuses a poller.
|
|
236
|
+
* 3. **Does another INSTANCE on this machine hold this bot?** `getMe` plus the
|
|
237
|
+
* per-machine registry answers it (APRV-390's incident: two gates, one
|
|
238
|
+
* token, two names, a 409 on every poll).
|
|
225
239
|
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
240
|
+
* ## An unreachable Bot API: fail-soft for a poller, fail-closed for a webhook
|
|
241
|
+
*
|
|
242
|
+
* A `getMe` or a `getWebhookInfo` that fails says nothing about ownership. The
|
|
243
|
+
* machine may be behind a captive portal, the API may be rate-limiting, the
|
|
244
|
+
* network may be down for four seconds. For a POLLER, refusing on that would
|
|
245
|
+
* mean a transient network fault took the phone channel down until somebody
|
|
246
|
+
* noticed, in exchange for no safety: an unreachable Bot API is also a
|
|
247
|
+
* `getUpdates` that cannot conflict with anything, and the HTTP 409 the loop
|
|
248
|
+
* already reports is the backstop. So the poller says what happened and starts.
|
|
249
|
+
*
|
|
250
|
+
* For the WEBHOOK VERB there is no such backstop, and the review of APRV-424
|
|
251
|
+
* turned this direction around. Its next act is `setWebhook`, which overwrites
|
|
252
|
+
* whatever registration exists without asking, so proceeding on an unknown
|
|
253
|
+
* answer is proceeding to take another host's taps with no error anywhere. A
|
|
254
|
+
* probe it could not make is therefore a refusal (`webhook-probe-failed`), and
|
|
255
|
+
* the operator retries or passes `--reclaim` deliberately.
|
|
235
256
|
*/
|
|
236
|
-
export declare function claimListenerBot(setup: ListenSetup, report: (message: string) => void
|
|
257
|
+
export declare function claimListenerBot(setup: ListenSetup, report: (message: string) => void, options?: {
|
|
258
|
+
/**
|
|
259
|
+
* The webhook URL THIS process is about to register, when it is a webhook
|
|
260
|
+
* runner rather than a poller (APRV-424).
|
|
261
|
+
*
|
|
262
|
+
* Absent for a poller. Present for the webhook verb, and then it is the
|
|
263
|
+
* url a `--reclaim` is measured against: `setWebhook` is idempotent, so a
|
|
264
|
+
* restart re-registering its own url is the ordinary case, while a
|
|
265
|
+
* DIFFERENT url is a second host about to take the first host's taps.
|
|
266
|
+
*/
|
|
267
|
+
webhookUrl?: string;
|
|
268
|
+
/**
|
|
269
|
+
* Register over an existing webhook (`--reclaim`, APRV-424 review finding
|
|
270
|
+
* 6).
|
|
271
|
+
*
|
|
272
|
+
* Without it, ANY registration refuses — including one at the same url,
|
|
273
|
+
* which used to be waved through on a bare string compare. Two hosts
|
|
274
|
+
* sharing one configuration both passed that check, the second overwrote
|
|
275
|
+
* the first's `secret_token`, and from then on every real tap arrived at
|
|
276
|
+
* the first host with a secret it did not recognise: a forgery, as far as
|
|
277
|
+
* it could tell, on every press of a button that had worked an hour
|
|
278
|
+
* earlier. So taking over is now a thing the operator says out loud.
|
|
279
|
+
*/
|
|
280
|
+
reclaim?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Which transport this process is about to run, for the lease.
|
|
283
|
+
*
|
|
284
|
+
* Derived from {@link webhookUrl} when it is not given, because the two
|
|
285
|
+
* callers that pass a url are the two that run a webhook.
|
|
286
|
+
*/
|
|
287
|
+
mode?: ChannelLeaseMode;
|
|
288
|
+
}): Promise<ClaimedListenerBot>;
|
|
289
|
+
/**
|
|
290
|
+
* What {@link claimListenerBot} answers.
|
|
291
|
+
*
|
|
292
|
+
* The lease travels with the success, because the caller is the only thing
|
|
293
|
+
* that knows when this process has stopped receiving: `runListener`,
|
|
294
|
+
* `approval up` and `runWebhook` each release it on their way out, and a
|
|
295
|
+
* refusal releases nothing because it took nothing.
|
|
296
|
+
*/
|
|
297
|
+
export type ClaimedListenerBot = {
|
|
237
298
|
ok: true;
|
|
299
|
+
lease: ChannelLease;
|
|
238
300
|
} | {
|
|
239
301
|
ok: false;
|
|
240
302
|
code: ListenRefusalCode;
|
|
241
303
|
message: string;
|
|
242
|
-
}
|
|
304
|
+
};
|
|
243
305
|
/**
|
|
244
306
|
* What to append to a runtime 409, naming the other instance if one is known.
|
|
245
307
|
*
|
|
@@ -279,7 +341,55 @@ export declare const LISTEN_REFUSAL_CODES: readonly [
|
|
|
279
341
|
* (APRV-390). Refused BEFORE the first `getUpdates`, so the operator reads
|
|
280
342
|
* which two gates are involved instead of an HTTP 409 loop.
|
|
281
343
|
*/
|
|
282
|
-
"bot-owned-elsewhere"
|
|
344
|
+
"bot-owned-elsewhere",
|
|
345
|
+
/**
|
|
346
|
+
* This bot's updates are being delivered to a webhook (APRV-424).
|
|
347
|
+
*
|
|
348
|
+
* The two transports are alternatives per bot: the Bot API refuses
|
|
349
|
+
* `getUpdates` outright while a webhook is set, so a listener that started
|
|
350
|
+
* here would print a 409 every few seconds and receive not one tap. Refused
|
|
351
|
+
* BEFORE the first poll, in the same preflight and for the same reason
|
|
352
|
+
* `bot-owned-elsewhere` is, so the operator reads which transport owns the
|
|
353
|
+
* bot instead of a status code.
|
|
354
|
+
*
|
|
355
|
+
* Since the review of APRV-424 it carries a second, local source: the
|
|
356
|
+
* transport lease in this gate's own `daemon/` directory, when the process
|
|
357
|
+
* holding it is a webhook runner. Same fact, same repair, so the same code.
|
|
358
|
+
*/
|
|
359
|
+
"webhook-registered",
|
|
360
|
+
/**
|
|
361
|
+
* A long-poll listener in THIS gate already holds the Telegram transport
|
|
362
|
+
* (APRV-424 review finding 1).
|
|
363
|
+
*
|
|
364
|
+
* The counterpart to `webhook-registered`, from the same lease. It is what
|
|
365
|
+
* the webhook verb meets when an `approval up` or an `approval channel
|
|
366
|
+
* telegram listen` is already running in the same project — the case
|
|
367
|
+
* `getWebhookInfo` cannot see (nothing is registered yet) and the ownership
|
|
368
|
+
* registry cannot see either (it is the same instance). Two of them on one
|
|
369
|
+
* log put every prompt on the phone twice, under two nonces, and only one
|
|
370
|
+
* copy can resolve a tap.
|
|
371
|
+
*/
|
|
372
|
+
"telegram-poller-running",
|
|
373
|
+
/**
|
|
374
|
+
* The transport lease could not be taken at all (APRV-424 review finding 1).
|
|
375
|
+
*
|
|
376
|
+
* A `daemon/` directory that cannot be created, a lockfile that cannot be
|
|
377
|
+
* written. Unlike the bot registry, whose absence is the status quo, this
|
|
378
|
+
* file is the only thing keeping one gate from running two transports, so a
|
|
379
|
+
* gate that cannot hold one does not start.
|
|
380
|
+
*/
|
|
381
|
+
"telegram-lease-unavailable",
|
|
382
|
+
/**
|
|
383
|
+
* The webhook verb could not learn what already holds this bot (APRV-424
|
|
384
|
+
* review finding 8).
|
|
385
|
+
*
|
|
386
|
+
* `getMe` or `getWebhookInfo` failed, and the next act would have been a
|
|
387
|
+
* `setWebhook` that overwrites a registration nobody saw. A poller keeps its
|
|
388
|
+
* fail-soft on the same failure, because an unreachable Bot API is also a
|
|
389
|
+
* `getUpdates` that cannot conflict and the HTTP 409 loop is its backstop;
|
|
390
|
+
* this verb has no backstop, so it refuses.
|
|
391
|
+
*/
|
|
392
|
+
"webhook-probe-failed"];
|
|
283
393
|
export type ListenRefusalCode = (typeof LISTEN_REFUSAL_CODES)[number];
|
|
284
394
|
/** Everything {@link prepareListen} needs, already resolved to absolute paths. */
|
|
285
395
|
export interface ListenRequest {
|
|
@@ -296,6 +406,11 @@ export interface ListenRequest {
|
|
|
296
406
|
payloads: string | null;
|
|
297
407
|
/** `--api-base`, or `null` for the Bot API. */
|
|
298
408
|
apiBase: string | null;
|
|
409
|
+
/**
|
|
410
|
+
* `--no-stale-copy` (APRV-456). The fallback is also off whenever
|
|
411
|
+
* {@link apiBase} names anything but the Bot API; see {@link staleCopyFor}.
|
|
412
|
+
*/
|
|
413
|
+
noStaleCopy?: boolean;
|
|
299
414
|
/** `--poll-timeout` as typed, or `null` for the channel's own default. */
|
|
300
415
|
pollTimeout: string | null;
|
|
301
416
|
once: boolean;
|
|
@@ -394,8 +509,31 @@ export declare const DISPATCH_RETENTION_MS: number;
|
|
|
394
509
|
* two apart, having deliberately kept nothing that would let it, and a first
|
|
395
510
|
* start that claimed to be a restart would be this channel's own text lying
|
|
396
511
|
* about the system's history.
|
|
512
|
+
*
|
|
513
|
+
* **With the stale-copy fallback off (APRV-456)** the second line says the
|
|
514
|
+
* opposite, because the earlier copies' buttons no longer decide anything: a
|
|
515
|
+
* relayed listener refuses a nonce it is not holding (`nonce-not-issued`), so
|
|
516
|
+
* the banner tells the approver to use the copies below it. A banner that kept
|
|
517
|
+
* promising working older copies would be this channel's own text sending the
|
|
518
|
+
* approver to a button that refuses them.
|
|
397
519
|
*/
|
|
398
|
-
export declare function bannerLines(pending: number): string[];
|
|
520
|
+
export declare function bannerLines(pending: number, staleCopy?: boolean): string[];
|
|
521
|
+
/**
|
|
522
|
+
* Whether APRV-196's stale-copy fallback is on for a listener launched with
|
|
523
|
+
* this `--api-base` and this `--no-stale-copy` (APRV-456).
|
|
524
|
+
*
|
|
525
|
+
* On only for the direct-bot shape: no `--api-base`, or one that names the
|
|
526
|
+
* Bot API itself, and no `--no-stale-copy`. Any other base is treated as a
|
|
527
|
+
* relay, because the fallback's safety rests on only the bot token being able
|
|
528
|
+
* to put a button in front of the approver, and a base this process does not
|
|
529
|
+
* recognise as Telegram's own is one where that cannot be assumed. A
|
|
530
|
+
* self-hosted Bot API server is therefore treated as a relay too: the strict
|
|
531
|
+
* reading, and the cost is only that earlier copies stop deciding.
|
|
532
|
+
*
|
|
533
|
+
* Launch configuration and nothing else. No policy key reads into it and
|
|
534
|
+
* nothing in an update can reach it.
|
|
535
|
+
*/
|
|
536
|
+
export declare function staleCopyFor(apiBase: string | null, noStaleCopy: boolean): boolean;
|
|
399
537
|
/**
|
|
400
538
|
* The summary line that precedes a paced send, and the body of `/queue`.
|
|
401
539
|
*
|
|
@@ -443,9 +581,15 @@ export interface PacedState {
|
|
|
443
581
|
/**
|
|
444
582
|
* Every pending action key, in the order this process will show them.
|
|
445
583
|
*
|
|
446
|
-
* Seeded from
|
|
447
|
-
*
|
|
448
|
-
*
|
|
584
|
+
* Seeded from `orderPending`'s order (live newest first, then stale oldest
|
|
585
|
+
* first, attestation prompts last — APRV-425; it was log order before that)
|
|
586
|
+
* and rearranged by `/skip` alone. Keys the log no longer calls pending are
|
|
587
|
+
* dropped on every cycle, and newly pending ones join the back.
|
|
588
|
+
*
|
|
589
|
+
* The ordering reaches this only through the SEEDING, which is the property
|
|
590
|
+
* that matters for `/skip`: a key already in the list keeps the place the
|
|
591
|
+
* approver's own navigation gave it, and only keys this process has not seen
|
|
592
|
+
* before are inserted in the new order.
|
|
449
593
|
*/
|
|
450
594
|
order: string[];
|
|
451
595
|
/**
|
|
@@ -483,6 +627,33 @@ export interface ReviewWalkthrough {
|
|
|
483
627
|
current: number | null;
|
|
484
628
|
/** Sample seq -> the message this process sent the card as. */
|
|
485
629
|
readonly delivered: Map<number, DeliveryId>;
|
|
630
|
+
/**
|
|
631
|
+
* Samples whose card could not be offered, left for a terminal review (PR
|
|
632
|
+
* #614 refutation F4). A sample lands here on a Bot API refusal of the card
|
|
633
|
+
* itself ({@link isDeterministicSendRefusal}: the card is built from the log,
|
|
634
|
+
* so the next cycle would build the same card and meet the same refusal), or
|
|
635
|
+
* once its retry budget is spent ({@link REVIEW_OFFER_ATTEMPTS}, PR #614
|
|
636
|
+
* recheck NF-2). The sample stays OPEN (in `approval audit list` and
|
|
637
|
+
* QUEUE.md); this listener only stops offering it. Process memory, pruned
|
|
638
|
+
* when the sample closes.
|
|
639
|
+
*/
|
|
640
|
+
readonly terminalOnly: Set<number>;
|
|
641
|
+
/**
|
|
642
|
+
* Failed offers per sample that did not (yet) make it terminal-only: a 429,
|
|
643
|
+
* a timeout, a 5xx, a network error, or any refusal not known to be about
|
|
644
|
+
* the card (PR #614 recheck NF-2). Process memory, cleared when the offer
|
|
645
|
+
* succeeds or the sample closes.
|
|
646
|
+
*/
|
|
647
|
+
readonly offerFailures: Map<number, number>;
|
|
648
|
+
/**
|
|
649
|
+
* No review card is offered before this instant (epoch ms), or `null`. Set by
|
|
650
|
+
* a transient offer failure to the larger of Telegram's `retry_after` and
|
|
651
|
+
* the backoff for that sample's attempt count (PR #614 recheck NF-2). The
|
|
652
|
+
* pause is the walkthrough's, not the sample's: a rate limit or an outage is
|
|
653
|
+
* the chat's, and offering the next sample into it would spend that sample's
|
|
654
|
+
* budget on the same outage.
|
|
655
|
+
*/
|
|
656
|
+
offersPausedUntilMs: number | null;
|
|
486
657
|
/** Whether any review summary has been sent yet. */
|
|
487
658
|
summarySent: boolean;
|
|
488
659
|
/** The open count the last summary named, so growth can be recognised. */
|
|
@@ -666,10 +837,12 @@ export interface DispatchResult {
|
|
|
666
837
|
* Action keys dropped from the delivery bookkeeping this cycle (APRV-196),
|
|
667
838
|
* with why. Neither kind can cost a re-send: the pending queue is the log's
|
|
668
839
|
* answer, and a dropped key that is still pending is simply re-delivered.
|
|
840
|
+
* `released` (APRV-442) is the one kind that is dropped BECAUSE it is still
|
|
841
|
+
* pending: a refused tap disarmed its card, and this cycle re-offers it.
|
|
669
842
|
*/
|
|
670
843
|
pruned: {
|
|
671
844
|
action_key: string;
|
|
672
|
-
reason: "settled" | "stale";
|
|
845
|
+
reason: "settled" | "stale" | "released";
|
|
673
846
|
}[];
|
|
674
847
|
/**
|
|
675
848
|
* The collapsed re-delivery this cycle sent, when it sent one (APRV-287):
|
|
@@ -729,6 +902,23 @@ export interface DispatchResult {
|
|
|
729
902
|
* from the derivation and so are never sent.
|
|
730
903
|
*/
|
|
731
904
|
export declare function dispatchPending(setup: ListenSetup, streams: Streams, state: DispatchState, now: string): Promise<DispatchResult>;
|
|
905
|
+
/**
|
|
906
|
+
* How many failed offers a sample gets before it is left for a terminal review
|
|
907
|
+
* (PR #614 recheck NF-2). With {@link reviewOfferBackoffMs} the budget spans
|
|
908
|
+
* about fifteen minutes of a dark or rate-limited chat (1 + 2 + 4 + 8 minutes
|
|
909
|
+
* between the five attempts), and a Bot API refusal of the card itself skips
|
|
910
|
+
* it.
|
|
911
|
+
*/
|
|
912
|
+
export declare const REVIEW_OFFER_ATTEMPTS = 5;
|
|
913
|
+
/**
|
|
914
|
+
* The longest review cards ever pause after one failed offer, whatever
|
|
915
|
+
* `retry_after` said (PR #614 recheck NF-5): one hour.
|
|
916
|
+
*/
|
|
917
|
+
export declare const REVIEW_OFFER_MAX_WAIT_MS = 3600000;
|
|
918
|
+
/** The first pause after a transient offer failure; it doubles per attempt. */
|
|
919
|
+
export declare const REVIEW_OFFER_BACKOFF_MS = 60000;
|
|
920
|
+
/** The pause after the `attempts`-th failed offer of one sample, before `retry_after`. */
|
|
921
|
+
export declare function reviewOfferBackoffMs(attempts: number): number;
|
|
732
922
|
/**
|
|
733
923
|
* How old a pending request must be, on a listener's first cycle, to be one
|
|
734
924
|
* nobody is waiting on (APRV-287).
|
|
@@ -748,8 +938,118 @@ export declare function dispatchPending(setup: ListenSetup, streams: Streams, st
|
|
|
748
938
|
* it takes to say they are there.
|
|
749
939
|
*/
|
|
750
940
|
export declare const COLLAPSE_STALE_AFTER_MS: number;
|
|
751
|
-
/**
|
|
752
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Pending requests a NEWER pending request has superseded (APRV-425).
|
|
943
|
+
*
|
|
944
|
+
* Two requests naming the same payload bytes and the same class are two askings
|
|
945
|
+
* of one question, and only the newer one has an asker. The shape that produces
|
|
946
|
+
* them is APRV-287's own: a hook whose wait ran out leaves its request open for
|
|
947
|
+
* the retry grace, the grace runs out, the hook withdraws it on its NEXT
|
|
948
|
+
* invocation — and if that next invocation never comes while a later session
|
|
949
|
+
* asks the same thing, both sit in the queue. Dogfooding produced exactly this
|
|
950
|
+
* complaint (APRV-118): a live prompt buried behind dead ones, and an approver
|
|
951
|
+
* rejecting the one they wanted.
|
|
952
|
+
*
|
|
953
|
+
* Keyed by `(payload_hash, class)` and not by task, because the task id a
|
|
954
|
+
* harness adapter mints is fresh per tool call (SPEC.md §10.2), so two askings
|
|
955
|
+
* of one command never share one. The bytes and the class are what a decision
|
|
956
|
+
* binds to, which is what makes them the right identity here.
|
|
957
|
+
*
|
|
958
|
+
* Computed from the pending set alone, which is re-derived from the verified log
|
|
959
|
+
* every cycle, so this decides nothing and remembers nothing. A superseded
|
|
960
|
+
* request is COLLAPSED, never closed: it stays pending in the log, listable, and
|
|
961
|
+
* decidable from any copy already delivered. Only a human's decision or the
|
|
962
|
+
* requester's own withdrawal ends it.
|
|
963
|
+
*/
|
|
964
|
+
export declare function supersededPending(requests: ChannelRequest[]): Set<string>;
|
|
965
|
+
/**
|
|
966
|
+
* The pending set in the order an approver should meet it (APRV-425).
|
|
967
|
+
*
|
|
968
|
+
* Three rules, in this order, and each is a complaint from running the gate:
|
|
969
|
+
*
|
|
970
|
+
* 1. **Attestation prompts last.** `buildPendingQueue` puts them there on
|
|
971
|
+
* purpose: a policy amendment changes the rules every entry above it was
|
|
972
|
+
* routed by, so an approver reading top to bottom answers the questions asked
|
|
973
|
+
* under the current policy before changing what the current policy is. That
|
|
974
|
+
* placement is not this function's to relitigate, so proposals are lifted
|
|
975
|
+
* out, ordered among themselves by nothing at all (log order), and put back
|
|
976
|
+
* at the end.
|
|
977
|
+
* 2. **Live requests first, newest first.** Live means younger than
|
|
978
|
+
* {@link COLLAPSE_STALE_AFTER_MS}, the hook's wait plus its retry grace,
|
|
979
|
+
* which is the same boundary the collapse uses — one number, one meaning of
|
|
980
|
+
* "somebody may still be holding this". Newest first because the newest is
|
|
981
|
+
* the one most likely to have a tool call blocked on it right now, and the
|
|
982
|
+
* observed failure was a live prompt buried behind dead ones.
|
|
983
|
+
* 3. **Stale requests after them, oldest first.** They are what the collapse
|
|
984
|
+
* takes on a first cycle, and where the collapse does not apply (fewer than
|
|
985
|
+
* {@link COLLAPSE_MIN} of them) oldest-first is the order to work through a
|
|
986
|
+
* backlog in.
|
|
987
|
+
*
|
|
988
|
+
* Stable inside each bucket, so log order breaks every tie and the result is
|
|
989
|
+
* deterministic for one log and one instant. It is an ORDER and nothing else:
|
|
990
|
+
* no request is dropped, none is decided, and the set that comes out is the set
|
|
991
|
+
* that went in.
|
|
992
|
+
*/
|
|
993
|
+
export declare function orderPending(requests: ChannelRequest[], now: string): ChannelRequest[];
|
|
994
|
+
/**
|
|
995
|
+
* The computed lines a collapsed re-delivery leads with (APRV-287).
|
|
996
|
+
*
|
|
997
|
+
* `superseded` is the subset a newer pending request replaced (APRV-425), and
|
|
998
|
+
* the first line states the split rather than claiming every member is old.
|
|
999
|
+
* Before this the line said "all older than the hook's wait plus its retry
|
|
1000
|
+
* grace", which stopped being true the moment the collapse widened: a message
|
|
1001
|
+
* that overstates what it collapsed is the stale-documentation failure in
|
|
1002
|
+
* message form, and this one is read by the person deciding.
|
|
1003
|
+
*/
|
|
1004
|
+
export declare function staleLines(requests: ChannelRequest[], now: string, superseded?: ReadonlySet<string>): string[];
|
|
1005
|
+
/**
|
|
1006
|
+
* Put the requests nobody is waiting on into ONE message, and hand back the
|
|
1007
|
+
* ones that still get a message each (APRV-287, widened by APRV-425).
|
|
1008
|
+
*
|
|
1009
|
+
* Called on a process's first cycle only, which is exactly a daemon start or a
|
|
1010
|
+
* listener reconnect. Everything it does is bookkeeping in the sense SPEC.md
|
|
1011
|
+
* §10.3 fixes: the pending set is re-derived from the verified log every cycle,
|
|
1012
|
+
* so a summary that fails to send, or a process that forgets it sent one,
|
|
1013
|
+
* degrades to showing those requests again, and never to a pending request
|
|
1014
|
+
* nobody is shown.
|
|
1015
|
+
*
|
|
1016
|
+
* ## Two ways in, one exit (APRV-425)
|
|
1017
|
+
*
|
|
1018
|
+
* A request is collapsed when it is older than the hook's wait plus its retry
|
|
1019
|
+
* grace (nobody is holding it), or when a NEWER pending request names the same
|
|
1020
|
+
* payload bytes and class ({@link supersededPending} — the newer one is the live
|
|
1021
|
+
* asking, whatever the age of either). The second is what answers the observed
|
|
1022
|
+
* complaint that a live prompt arrives buried behind dead ones.
|
|
1023
|
+
*
|
|
1024
|
+
* ## This is where the sent-record is rebuilt from the log (AC3)
|
|
1025
|
+
*
|
|
1026
|
+
* Every collapsed member is written into `state.delivered` and `state.sentAtMs`
|
|
1027
|
+
* below, and the set it is written from is the pending set re-derived from the
|
|
1028
|
+
* verified log. That is the whole of the rebuilding, and it is deliberately not
|
|
1029
|
+
* a second mechanism: the log is the only place the question "what is pending"
|
|
1030
|
+
* is answered.
|
|
1031
|
+
*
|
|
1032
|
+
* What it is NOT is evidence of delivery, and the difference is load-bearing.
|
|
1033
|
+
* Nothing reads this record to conclude that an approver saw anything: a
|
|
1034
|
+
* collapsed request stays pending in the log, is listed by `/queue`, and is
|
|
1035
|
+
* decidable from any copy already delivered, because APRV-196 made
|
|
1036
|
+
* `callback_data` carry a restart-stable action ref so a button on a
|
|
1037
|
+
* pre-restart copy still decides the request. Lose the record and the next
|
|
1038
|
+
* cycle shows the requests again, which is the degradation SPEC.md §10.3
|
|
1039
|
+
* requires and the one this code takes.
|
|
1040
|
+
*/
|
|
1041
|
+
/**
|
|
1042
|
+
* The members a first-cycle collapse would put into one message: stale or
|
|
1043
|
+
* superseded, and never a proposal (APRV-445 refutation, S2). Proposals are
|
|
1044
|
+
* long-lived by design, so after a six-minute outage every one of them would
|
|
1045
|
+
* otherwise land in one digest whose only bulk answer is reject-all.
|
|
1046
|
+
*/
|
|
1047
|
+
export declare function collapsibleStale(undecided: readonly ChannelRequest[], now: string, superseded?: ReadonlySet<string>): ChannelRequest[];
|
|
1048
|
+
/**
|
|
1049
|
+
* Report a steady-state cycle's problems on stderr. Startup reports its own,
|
|
1050
|
+
* as exit codes, in {@link runListener}.
|
|
1051
|
+
*/
|
|
1052
|
+
export declare function reportCycle(result: DispatchResult, streams: Streams): void;
|
|
753
1053
|
export declare function checkpointHandlerFor(setup: ListenSetup, streams: Streams): (tap: {
|
|
754
1054
|
sign: boolean;
|
|
755
1055
|
head: {
|
|
@@ -781,10 +1081,11 @@ export declare function checkpointHandlerFor(setup: ListenSetup, streams: Stream
|
|
|
781
1081
|
*/
|
|
782
1082
|
export declare function reviewHandlerFor(setup: ListenSetup, streams: Streams): (tap: {
|
|
783
1083
|
sampleSeq: number;
|
|
784
|
-
verdict
|
|
1084
|
+
verdict?: "ok" | "denied";
|
|
785
1085
|
reaction?: "disliked" | "indifferent" | "liked" | "loved";
|
|
786
1086
|
note?: string;
|
|
787
1087
|
sender?: ChannelSender;
|
|
1088
|
+
payloadHash?: string;
|
|
788
1089
|
}) => ReviewTapResponse;
|
|
789
1090
|
/**
|
|
790
1091
|
* `/queue`, `/skip`, `/next` — the paced walkthrough's three verbs (APRV-216).
|
|
@@ -857,6 +1158,24 @@ export interface RunningListener {
|
|
|
857
1158
|
* queue from the verified log and re-sends everything still pending, exactly as
|
|
858
1159
|
* a restarted process would. A duplicate on the phone, never a silence.
|
|
859
1160
|
*/
|
|
1161
|
+
/**
|
|
1162
|
+
* Give the channel every handler the runtime answers a gesture with, and hand
|
|
1163
|
+
* back the fresh dispatch bookkeeping (APRV-424).
|
|
1164
|
+
*
|
|
1165
|
+
* Extracted from {@link startListener} so the webhook runner wires the SAME
|
|
1166
|
+
* four handlers rather than a second set that looks like them. This is the
|
|
1167
|
+
* CLI-side half of the property APRV-424 is about: the transport decides where
|
|
1168
|
+
* an update arrives, and nothing else. A tap that arrives by webhook is
|
|
1169
|
+
* recorded by `handlerFor`'s `recordChannelDecision` — the same actor, the
|
|
1170
|
+
* same sender resolution, the same gate — because it is the same function
|
|
1171
|
+
* object, registered here.
|
|
1172
|
+
*
|
|
1173
|
+
* A FRESH {@link DispatchState} per call, which is the whole of the restart
|
|
1174
|
+
* story: a supervisor that restarts a fallen runner re-derives the pending
|
|
1175
|
+
* queue from the verified log and re-sends everything still pending. A
|
|
1176
|
+
* duplicate on the phone, never a silence.
|
|
1177
|
+
*/
|
|
1178
|
+
export declare function wireListener(setup: ListenSetup, streams: Streams): DispatchState;
|
|
860
1179
|
export declare function startListener(setup: ListenSetup, streams: Streams): RunningListener;
|
|
861
1180
|
/**
|
|
862
1181
|
* The listener verb. Returns a promise, which is why `main` treats `channel`
|