approval-md 0.4.3 → 0.4.6

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.
Files changed (52) hide show
  1. package/SPEC.md +13 -2
  2. package/dist/src/channels/telegram.d.ts +105 -31
  3. package/dist/src/channels/telegram.js +157 -81
  4. package/dist/src/channels/telegram.js.map +1 -1
  5. package/dist/src/cli/channel-telegram.d.ts +100 -35
  6. package/dist/src/cli/channel-telegram.js +216 -119
  7. package/dist/src/cli/channel-telegram.js.map +1 -1
  8. package/dist/src/cli/doctor.js +33 -13
  9. package/dist/src/cli/doctor.js.map +1 -1
  10. package/dist/src/cli/help.js +3 -3
  11. package/dist/src/cli/hook-exec-code.d.ts +150 -0
  12. package/dist/src/cli/hook-exec-code.js +357 -0
  13. package/dist/src/cli/hook-exec-code.js.map +1 -0
  14. package/dist/src/cli/hook.d.ts +125 -1
  15. package/dist/src/cli/hook.js +2177 -107
  16. package/dist/src/cli/hook.js.map +1 -1
  17. package/dist/src/cli/wordmark.d.ts +2 -2
  18. package/dist/src/cli/wordmark.js +2 -2
  19. package/dist/src/core/command-class.d.ts +368 -1
  20. package/dist/src/core/command-class.js +2830 -93
  21. package/dist/src/core/command-class.js.map +1 -1
  22. package/dist/src/core/date-argv.d.ts +83 -0
  23. package/dist/src/core/date-argv.js +212 -0
  24. package/dist/src/core/date-argv.js.map +1 -0
  25. package/dist/src/core/exec-code.d.ts +77 -0
  26. package/dist/src/core/exec-code.js +60 -0
  27. package/dist/src/core/exec-code.js.map +1 -0
  28. package/dist/src/core/git-push-argv.d.ts +111 -0
  29. package/dist/src/core/git-push-argv.js +375 -0
  30. package/dist/src/core/git-push-argv.js.map +1 -0
  31. package/dist/src/core/harness-version.d.ts +71 -30
  32. package/dist/src/core/harness-version.js +101 -34
  33. package/dist/src/core/harness-version.js.map +1 -1
  34. package/dist/src/core/policy-load.d.ts +8 -0
  35. package/dist/src/core/policy-load.js.map +1 -1
  36. package/dist/src/core/read-scope.js +1 -0
  37. package/dist/src/core/read-scope.js.map +1 -1
  38. package/dist/src/core/sysinfo-argv.d.ts +48 -0
  39. package/dist/src/core/sysinfo-argv.js +340 -0
  40. package/dist/src/core/sysinfo-argv.js.map +1 -0
  41. package/dist/src/daemon/git-evidence.d.ts +2 -2
  42. package/dist/src/daemon/git-evidence.js +1 -1
  43. package/docs/README-extended.md +3 -2
  44. package/docs/cli-reference.md +20 -7
  45. package/package.json +2 -2
  46. package/schema/event.schema.json +1 -1
  47. package/schema/fixtures/policy/invalid/exec-code-custody-boolean.json +11 -0
  48. package/schema/fixtures/policy/invalid/exec-code-execute-code-value.json +11 -0
  49. package/schema/fixtures/policy/invalid/exec-code-unknown-key.json +12 -0
  50. package/schema/fixtures/policy/valid/exec-code-both.json +17 -0
  51. package/schema/fixtures/policy/valid/exec-code-custody.json +11 -0
  52. package/schema/policy.schema.json +23 -0
@@ -489,7 +489,8 @@ export declare const DISPATCH_LOUD_ATTEMPTS = 3;
489
489
  */
490
490
  export declare const DISPATCH_RETENTION_MS: number;
491
491
  /**
492
- * The line that introduces the first batch a listener process sends (APRV-196).
492
+ * The one message that introduces the first batch a listener process sends
493
+ * (APRV-196). Two lines, sent together by `announce`, the first in bold.
493
494
  *
494
495
  * **Why a banner and not an edit of the earlier copies.** The incident was a
495
496
  * restart re-sending five pending requests with no warning, on top of five
@@ -505,19 +506,42 @@ export declare const DISPATCH_RETENTION_MS: number;
505
506
  * (`actionRefOf` in `channels/telegram.ts`), so a human who taps the copy they
506
507
  * can see decides the request they meant.
507
508
  *
508
- * It says "started" rather than "restarted" because a listener cannot tell the
509
- * two apart, having deliberately kept nothing that would let it, and a first
510
- * start that claimed to be a restart would be this channel's own text lying
511
- * about the system's history.
509
+ * **The words are a resident's, not the system's.** The reader is whoever
510
+ * holds the phone, so the banner is one short message in plain words: how many
511
+ * requests are still waiting, and whether the buttons on the older messages
512
+ * above still work. It names no process, no log and no cycle, and it says
513
+ * neither "started" nor "restarted": a listener cannot tell the two apart,
514
+ * having deliberately kept nothing that would let it, so the text claims only
515
+ * what is true either way (these requests are still waiting). The old third
516
+ * line, about where the pending set is read from, is gone; it described the
517
+ * runtime to someone who only needs to know which button to press.
512
518
  *
513
519
  * **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
520
+ * opposite, because the earlier copies' buttons no longer work: a relayed
521
+ * listener refuses a nonce it is not holding (`nonce-not-issued`), so the
522
+ * banner tells the approver to use the buttons below it. A banner that kept
517
523
  * promising working older copies would be this channel's own text sending the
518
524
  * approver to a button that refuses them.
519
525
  */
520
526
  export declare function bannerLines(pending: number, staleCopy?: boolean): string[];
527
+ /**
528
+ * The reminder a collapsed re-delivery opens with, in place of the banner
529
+ * (P-9).
530
+ *
531
+ * Before this, a restart with two stale requests and one live one sent the
532
+ * stale summary first and the {@link bannerLines} banner second, and the banner
533
+ * counted only the cards after it: "1 request is still waiting" with three
534
+ * pending and the summary of the other two directly above. Two reminders, the
535
+ * more verbose one first, and a count that read as wrong. Now the summary IS the
536
+ * reminder: its first line counts everything this cycle re-sends (`pending`,
537
+ * collapsed and carded together), and the banner is skipped.
538
+ *
539
+ * `following` is how many requests get their own card after the summary. When
540
+ * there are any, the second line says so and says whether the buttons on older
541
+ * messages still work, which is what the banner it replaces said (APRV-456).
542
+ * When there are none, the summary is the whole restart and nothing follows.
543
+ */
544
+ export declare function staleReminderLines(pending: number, following: number, staleCopy?: boolean): string[];
521
545
  /**
522
546
  * Whether APRV-196's stale-copy fallback is on for a listener launched with
523
547
  * this `--api-base` and this `--no-stale-copy` (APRV-456).
@@ -535,34 +559,59 @@ export declare function bannerLines(pending: number, staleCopy?: boolean): strin
535
559
  */
536
560
  export declare function staleCopyFor(apiBase: string | null, noStaleCopy: boolean): boolean;
537
561
  /**
538
- * The summary line that precedes a paced send, and the body of `/queue`.
539
- *
540
- * One message, and everything in it is arithmetic on the verified log at the
541
- * instant it is written: how many requests are pending, how long the oldest has
542
- * waited, and which classes they are. Nothing is remembered between calls, so
543
- * two summaries a minute apart can disagree only because the log moved.
544
- *
545
- * The class tally is the part worth the space. The count alone says how much
546
- * work is waiting; the classes say what KIND of work, which is what tells an
547
- * approver whether the queue is six identical `network.call`s they can walk
548
- * through or one `policy.edit` they should read carefully.
562
+ * The count line a paced cycle sends when the pending set has grown, and the
563
+ * header of `/queue` (APRV-216), in a resident's words (P-9).
564
+ *
565
+ * One line, and everything in it is arithmetic on the verified log at the
566
+ * instant it is written: how many requests are waiting and how long the oldest
567
+ * has waited. Nothing is remembered between calls, so two summaries a minute
568
+ * apart can disagree only because the log moved.
569
+ *
570
+ * Before P-9 it also carried a class tally ("communicate.email.external ×3").
571
+ * The tally told an operator what kind of work was queued, and told a resident
572
+ * nothing they could read; the kind of each request is on its own card, and
573
+ * `/queue` now lists each by the agent's own summary ({@link queueLines}).
574
+ *
575
+ * The oldest is the one asked longest ago, whatever order `requests` is in:
576
+ * `/queue` passes the set in presentation order ({@link orderPending}, live
577
+ * newest first), where the first entry is the NEWEST, and a header that read
578
+ * the first entry's age called the newest one the oldest.
549
579
  */
550
580
  export declare function summaryLines(requests: ChannelRequest[], now: string): string[];
581
+ /**
582
+ * The reminder a paced listener's first cycle opens with (P-9).
583
+ *
584
+ * Paced is the product default (APRV-216), and a restart there used to open
585
+ * with the bare count line and then one card. Nothing in it said this was a
586
+ * reminder, or whether the buttons on older messages above still worked, which
587
+ * matters most behind a relay, where they do not (APRV-456). So the first
588
+ * cycle's line is a reminder in the burst banner's words ({@link bannerLines}):
589
+ * how many are waiting, how many are below, and what the older buttons do.
590
+ *
591
+ * `shown` is how many requests this cycle puts below it: one, or a digest
592
+ * group. With the stale-copy fallback on, older buttons decide only while their
593
+ * request is the one being shown, so when fewer are shown than are pending the
594
+ * line says only the ones below work right now (fold round 1, S1). Later cycles that find the set has grown send {@link summaryLines}
595
+ * instead, which is a count and not a reminder.
596
+ */
597
+ export declare function pacedReminderLines(pending: number, shown: number, staleCopy?: boolean): string[];
551
598
  /**
552
599
  * `/queue`'s reply: the summary, then one numbered line per pending request.
553
600
  *
554
601
  * Derived, like the summary, from the verified log at reply time and not from
555
602
  * anything this process is holding: the numbering is positional and names no
556
603
  * button, so a stale copy of this list cannot be used to decide anything. The
557
- * marker says which one this listener has selected and once delivered, because
558
- * the question `/queue` is usually asked to answer is "what else is there
559
- * besides the one I am looking at" — and, since APRV-256, its unhappy twin,
560
- * "where is the one I am supposed to be looking at".
561
- *
562
- * The footer answers that second question the only honest way available to a
563
- * process whose knowledge of the chat ends at "a send returned success": it
564
- * says what was sent, says it cannot tell whether the card survived, and then
565
- * spends its remaining words on recovery rather than reassurance.
604
+ * marker says which one was sent earlier, because the question `/queue` is
605
+ * usually asked to answer is "what else is there besides the one I am looking
606
+ * at" and, since APRV-256, its unhappy twin, "where is the one I am supposed to
607
+ * be looking at".
608
+ *
609
+ * P-9: each line is the agent's own summary and its age, under the label that
610
+ * says the summary is the agent's and unchecked. Before P-9 each line was the
611
+ * action key, the task id, the class and the age, and in real use the first
612
+ * two are `hook:<session uuid>:<tool_use_id>…`, two long raw ids per line. The
613
+ * three recovery paragraphs are two short lines: what /skip and /next do, and
614
+ * that neither answers anything.
566
615
  */
567
616
  export declare function queueLines(requests: ChannelRequest[], now: string, shown: readonly string[]): string[];
568
617
  /**
@@ -992,16 +1041,32 @@ export declare function supersededPending(requests: ChannelRequest[]): Set<strin
992
1041
  */
993
1042
  export declare function orderPending(requests: ChannelRequest[], now: string): ChannelRequest[];
994
1043
  /**
995
- * The computed lines a collapsed re-delivery leads with (APRV-287).
1044
+ * The computed lines a collapsed re-delivery leads with (APRV-287), in a
1045
+ * resident's words (P-9).
996
1046
  *
997
1047
  * `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.
1048
+ * the line states the split rather than claiming every member is old. Before
1049
+ * APRV-425 it said every member was past the hook's wait, which stopped being
1050
+ * true the moment the collapse widened: a message that overstates what it
1051
+ * collapsed is the stale-documentation failure in message form, and this one is
1052
+ * read by the person deciding.
1053
+ *
1054
+ * Before P-9 these lines also spelled out the hook's wait and retry grace in
1055
+ * seconds and minutes, a tally of class names, and a sentence about log events
1056
+ * and identical retries. The reader is whoever holds the phone, so what is left
1057
+ * is the one thing they need: how many are listed, and why nobody needs an
1058
+ * answer to them now. The age of each one moves onto its own line
1059
+ * ({@link staleAges}).
1060
+ */
1061
+ export declare function staleLines(requests: ChannelRequest[], _now: string, superseded?: ReadonlySet<string>): string[];
1062
+ /**
1063
+ * How long ago each collapsed request was asked, in the order given (P-9).
1064
+ *
1065
+ * Computed from the verified log's own `requested_ts`, like the rest of the
1066
+ * summary, and rendered beside each member's claimed summary line so the
1067
+ * resident can tell the requests apart without an action key.
1003
1068
  */
1004
- export declare function staleLines(requests: ChannelRequest[], now: string, superseded?: ReadonlySet<string>): string[];
1069
+ export declare function staleAges(requests: readonly ChannelRequest[], now: string): string[];
1005
1070
  /**
1006
1071
  * Put the requests nobody is waiting on into ONE message, and hand back the
1007
1072
  * ones that still get a message each (APRV-287, widened by APRV-425).