your-attention 0.1.0 → 0.1.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.
Files changed (97) hide show
  1. package/README.md +2 -0
  2. package/bin/your-attention.js +6 -2
  3. package/dist/src/adapters/files.js +66 -0
  4. package/dist/src/adapters/mdns.js +53 -0
  5. package/dist/src/adapters/mermaid.js +50 -0
  6. package/dist/src/adapters/openui-body.js +40 -0
  7. package/dist/src/adapters/openui-library.js +3 -0
  8. package/dist/src/adapters/sqlite.js +68 -0
  9. package/dist/src/cli.js +814 -0
  10. package/dist/src/client.js +459 -0
  11. package/dist/src/cloudflare/collector.js +53 -0
  12. package/dist/src/cloudflare/inbox-object.js +338 -0
  13. package/dist/src/cloudflare/storage.js +151 -0
  14. package/dist/src/cloudflare/worker.js +189 -0
  15. package/dist/src/core/crypto.js +23 -0
  16. package/dist/src/core/diagrams.js +225 -0
  17. package/dist/src/core/expr.js +125 -0
  18. package/dist/src/core/file-links.js +48 -0
  19. package/dist/src/core/hooks.js +74 -0
  20. package/dist/src/core/http.js +651 -0
  21. package/dist/src/core/inbox.js +2463 -0
  22. package/dist/src/core/pin.js +234 -0
  23. package/dist/src/core/sealed.js +167 -0
  24. package/dist/src/core/session-link.js +13 -0
  25. package/dist/src/core/socket.js +88 -0
  26. package/dist/src/core/storage.js +102 -0
  27. package/dist/src/core/summary.js +149 -0
  28. package/dist/src/core/telemetry.js +221 -0
  29. package/dist/src/core/types.js +470 -0
  30. package/dist/src/core/version.js +2 -0
  31. package/dist/src/core/widgets.js +128 -0
  32. package/dist/src/extensions/triage.js +232 -0
  33. package/dist/src/integrations/claude/ask-hook.js +84 -0
  34. package/dist/src/integrations/claude/channel-flag.js +102 -0
  35. package/dist/src/integrations/claude/channel.js +276 -0
  36. package/dist/src/integrations/claude/session-name.js +32 -0
  37. package/dist/src/integrations/claude/turn-end-hook.js +84 -0
  38. package/dist/src/integrations/herdr/approve.js +71 -0
  39. package/dist/src/integrations/herdr/blocked.js +210 -0
  40. package/dist/src/integrations/herdr/dialog.js +64 -0
  41. package/dist/src/integrations/herdr/focus.js +31 -0
  42. package/dist/src/integrations/herdr/place.js +22 -0
  43. package/dist/src/integrations/images.js +43 -0
  44. package/dist/src/integrations/opencode/install.js +24 -0
  45. package/dist/src/integrations/opencode/plugin.js +157 -0
  46. package/dist/src/integrations/pi/extension.js +166 -0
  47. package/dist/src/integrations/run-tool.js +157 -0
  48. package/dist/src/integrations/secrets.js +63 -0
  49. package/dist/src/integrations/tags.js +27 -0
  50. package/dist/src/integrations/tools.js +147 -0
  51. package/dist/src/node/home.js +20 -0
  52. package/dist/src/node/install.js +225 -0
  53. package/dist/src/node/links.js +249 -0
  54. package/dist/src/node/pin-prompt.js +125 -0
  55. package/dist/src/node/server.js +320 -0
  56. package/dist/src/node/service.js +74 -0
  57. package/dist/src/node/telemetry.js +127 -0
  58. package/dist/src/owner-watch.js +49 -0
  59. package/dist/src/tui/api.js +203 -0
  60. package/dist/src/tui/app.js +586 -0
  61. package/dist/src/tui/body.js +727 -0
  62. package/dist/src/tui/cardview.js +453 -0
  63. package/dist/src/tui/doc.js +157 -0
  64. package/dist/src/tui/edit.js +119 -0
  65. package/dist/src/tui/input.js +192 -0
  66. package/dist/src/tui/md.js +196 -0
  67. package/dist/src/tui/screen.js +225 -0
  68. package/dist/src/tui/terminal.js +130 -0
  69. package/dist/src/tui/text.js +103 -0
  70. package/dist/src/tui/theme.js +105 -0
  71. package/dist/src/tui/view.js +314 -0
  72. package/dist/src/watch.js +104 -0
  73. package/dist/web/age.js +16 -0
  74. package/dist/web/answers.js +485 -0
  75. package/dist/web/app.js +739 -0
  76. package/dist/web/body-faults.js +69 -0
  77. package/dist/web/components.js +923 -0
  78. package/dist/web/copy.js +118 -0
  79. package/dist/web/details.js +59 -0
  80. package/dist/web/env.js +97 -0
  81. package/dist/web/favicon-waiting.svg +1 -0
  82. package/dist/web/favicon.svg +1 -0
  83. package/dist/web/index.html +16 -0
  84. package/dist/web/library-spec.js +33 -0
  85. package/dist/web/markdown.js +142 -0
  86. package/dist/web/paste-images.js +193 -0
  87. package/dist/web/pin-key.js +125 -0
  88. package/dist/web/pin.js +126 -0
  89. package/dist/web/queue.js +97 -0
  90. package/dist/web/sealed.js +13 -0
  91. package/dist/web/search.js +70 -0
  92. package/dist/web/stories/cards.stories.js +144 -0
  93. package/dist/web/stories/page.stories.js +54 -0
  94. package/dist/web/stories/render.js +16 -0
  95. package/dist/web/style.css +417 -0
  96. package/package.json +4 -2
  97. package/src/core/version.ts +1 -1
@@ -0,0 +1,74 @@
1
+ // Hook points and their contract. Extensions use these messages, which are
2
+ // separate from the messages agents and cards exchange, so the extension
3
+ // contract can change without touching the agent protocol.
4
+
5
+
6
+ export const HOOK_VERSION = 1;
7
+
8
+ /** Each hook declares what an extension may do there. */
9
+ export const HOOKS = {
10
+ /** Before the person sees a new or revised card. An extension may pass it, hold it, or return it to its agent. */
11
+ 'card.created': { verdicts: ['pass', 'hold', 'return'] , defaultTimeoutMs: 30_000 },
12
+ /** After the person saves an answer. Observe only. */
13
+ 'answer.saved': { verdicts: [] , defaultTimeoutMs: 10_000 },
14
+ /** When the person opens or closes the inbox, comes back to it, or moves to another card. Observe only. */
15
+ 'person.changed': { verdicts: [] , defaultTimeoutMs: 10_000 },
16
+ } ;
17
+
18
+
19
+
20
+
21
+
22
+ /** What an extension receives for each hook call. */
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ export function isHook(name ) {
36
+ return Object.hasOwn(HOOKS, name);
37
+ }
38
+
39
+ const hex = (bytes ) => [...new Uint8Array(bytes)].map((b) => b.toString(16).padStart(2, '0')).join('');
40
+
41
+ /** HMAC-SHA256 of the body with the webhook secret, as the x-your-attention-signature header carries it. */
42
+ export async function sign(secret , body ) {
43
+ const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
44
+ return `sha256=${hex(await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(body)))}`;
45
+ }
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+ /** Send a signed observe-only hook call to an external service over HTTPS. A failure never reaches the caller. */
55
+ export async function deliverWebhook(hook , payload , fetcher = fetch) {
56
+ return (await postSigned(hook.url, hook.secret, { 'x-your-attention-hook': hook.hook }, payload, HOOKS[hook.hook].defaultTimeoutMs, fetcher)).ok;
57
+ }
58
+
59
+ /** POST a JSON body with its HMAC signature. The caller's headers go first, so they never replace the inbox's own.
60
+ * Returns whether the service answered 2xx, and why not. A failure never throws. */
61
+ export async function postSigned(url , secret , headers , payload , timeoutMs , fetcher = fetch) {
62
+ const body = JSON.stringify(payload);
63
+ try {
64
+ const res = await fetcher(url, {
65
+ method: 'POST',
66
+ headers: { ...headers, 'content-type': 'application/json', 'x-your-attention-signature': await sign(secret, body) },
67
+ body,
68
+ signal: AbortSignal.timeout(timeoutMs),
69
+ });
70
+ return res.ok ? { ok: true } : { ok: false, reason: `the webhook answered ${res.status}` };
71
+ } catch (e) {
72
+ return { ok: false, reason: `the webhook did not answer: ${(e ).name === 'TimeoutError' ? `no answer in ${timeoutMs / 1000} seconds` : (e ).message}`.slice(0, 300) };
73
+ }
74
+ }