@north-light/crouter 0.3.197 → 0.3.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +19 -19
- package/dist/api/client.js +29 -37
- package/dist/api/dto/broker-ops.d.ts +3 -1
- package/dist/api/dto/broker.d.ts +13 -2
- package/dist/api/dto/broker.js +4 -4
- package/dist/api/dto/human.d.ts +6 -5
- package/dist/api/dto/inbox.d.ts +126 -33
- package/dist/api/dto/nodes.d.ts +8 -2
- package/dist/api/dto/profiles.d.ts +23 -0
- package/dist/api/dto/profiles.js +2 -2
- package/dist/api/dto/worktree.d.ts +3 -5
- package/dist/api/routes.d.ts +3 -5
- package/dist/api/routes.js +4 -6
- package/dist/builtin-memory/00-runtime-base.md +8 -8
- package/dist/builtin-memory/01-spine/01-no-manager.md +1 -1
- package/dist/builtin-memory/02-lifecycle/00-terminal.md +3 -3
- package/dist/builtin-memory/04-orchestration-kernel.md +6 -6
- package/dist/builtin-memory/05-kinds/design/00-base.md +1 -1
- package/dist/builtin-memory/05-kinds/plan/reviewers/security.md +2 -2
- package/dist/builtin-memory/05-kinds/review/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/review/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/spec/01-orchestrator.md +1 -1
- package/dist/builtin-memory/insights/capture.md +2 -2
- package/dist/builtin-memory/insights/init.md +3 -3
- package/dist/builtin-memory/internal/INDEX.md +1 -1
- package/dist/builtin-memory/internal/memory-loading.md +1 -1
- package/dist/builtin-memory/internal/nodes-and-canvas.md +3 -3
- package/dist/builtin-memory/internal/plugins.md +59 -2
- package/dist/builtin-memory/internal/storage-tiers.md +3 -1
- package/dist/builtin-memory/spec/roadmap.md +2 -2
- package/dist/builtin-memory/testing.md +1 -1
- package/dist/builtin-memory/wedged-child-on-runaway-bash.md +1 -1
- package/dist/clients/attach/chrome/bash-jobs.js +3 -3
- package/dist/clients/attach/render/chat-view.d.ts +29 -9
- package/dist/clients/attach/render/chat-view.js +64 -35
- package/dist/clients/attach/render/markdown-source.js +0 -6
- package/dist/clients/attach/render/page-block.d.ts +34 -0
- package/dist/clients/attach/render/page-block.js +226 -0
- package/dist/clients/attach/render/tool-calls.js +16 -2
- package/dist/clients/attach/session/whip.d.ts +2 -0
- package/dist/clients/attach/session/whip.js +2 -0
- package/dist/clients/attach/viewer.js +1419 -982
- package/dist/clients/conversation/projection.js +18 -3
- package/dist/clients/inbox/__tests__/serial/inbox-controller.test.js +9 -6
- package/dist/clients/inbox/__tests__/serial/mount-panel.test.js +13 -14
- package/dist/clients/inbox/controller.js +10 -16
- package/dist/clients/inbox/page-adapter.d.ts +3 -4
- package/dist/clients/inbox/page-adapter.js +3 -4
- package/dist/clients/inbox/resolve.d.ts +1 -1
- package/dist/clients/inbox/resolve.js +3 -3
- package/dist/clients/inbox/review/document-surface.js +3 -1
- package/dist/clients/inbox/review/state.d.ts +2 -1
- package/dist/clients/inbox/review/state.js +5 -16
- package/dist/clients/inbox/tui/input.js +37 -19
- package/dist/clients/inbox/tui/panel.js +5 -31
- package/dist/clients/inbox/tui/render.d.ts +11 -0
- package/dist/clients/inbox/tui/render.js +101 -36
- package/dist/clients/inbox/tui/slots.d.ts +4 -4
- package/dist/clients/inbox/tui/slots.js +19 -44
- package/dist/clients/inbox/tui/types.d.ts +6 -10
- package/dist/clients/inbox/tui.js +2 -2
- package/dist/commands/__tests__/human.test.js +118 -24
- package/dist/commands/__tests__/node-message.test.js +14 -0
- package/dist/commands/attention.js +4 -4
- package/dist/commands/canvas-browse.js +1 -1
- package/dist/commands/canvas-snapshot.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/human/{doc.d.ts → components.d.ts} +1 -1
- package/dist/commands/human/components.js +77 -0
- package/dist/commands/human/feedback.d.ts +2 -0
- package/dist/commands/human/feedback.js +108 -0
- package/dist/commands/human/prompts.d.ts +17 -8
- package/dist/commands/human/prompts.js +217 -226
- package/dist/commands/human/queue.js +57 -88
- package/dist/commands/human/shared.d.ts +4 -15
- package/dist/commands/human/shared.js +19 -61
- package/dist/commands/human.js +32 -19
- package/dist/commands/memory/origin.js +2 -2
- package/dist/commands/node/bash.js +4 -4
- package/dist/commands/node/inspect.js +3 -3
- package/dist/commands/node/lifecycle.js +1 -1
- package/dist/commands/node/message.js +2 -2
- package/dist/commands/node-worktree.js +8 -8
- package/dist/commands/pkg/browse.js +1 -1
- package/dist/commands/pkg/plugin-manage.js +129 -10
- package/dist/commands/profile/delete.js +41 -15
- package/dist/commands/profile.js +1 -1
- package/dist/commands/push.js +1 -1
- package/dist/commands/surface/node/focus.js +29 -14
- package/dist/commands/surface-edit.js +3 -3
- package/dist/commands/surface-inbox.d.ts +2 -0
- package/dist/commands/{human/inbox.js → surface-inbox.js} +14 -18
- package/dist/commands/surface.js +2 -1
- package/dist/commands/sys/doctor.js +60 -3
- package/dist/commands/sys/feedback.js +79 -25
- package/dist/commands/sys/settings.js +1 -1
- package/dist/core/__tests__/cron-broker-capacity.test.js +1 -1
- package/dist/core/__tests__/daemon-boot.test.js +7 -4
- package/dist/core/__tests__/dead-node-policy-table.test.js +20 -36
- package/dist/core/__tests__/extension-abort.test.js +5 -2
- package/dist/core/__tests__/fixtures/fake-engine.d.ts +13 -2
- package/dist/core/__tests__/fixtures/fake-engine.js +47 -3
- package/dist/core/__tests__/human-cancel-guard.test.js +31 -10
- package/dist/core/__tests__/human-deliver.test.js +41 -45
- package/dist/core/__tests__/human-node-not-supervised.test.js +1 -1
- package/dist/core/__tests__/plugin-page-components.test.js +157 -0
- package/dist/core/__tests__/seam/broker-crash-teardown.test.js +13 -11
- package/dist/core/__tests__/seam/dormancy-release.test.js +103 -4
- package/dist/core/__tests__/serial/flagship-lifecycle.test.js +2 -2
- package/dist/core/__tests__/serial/human-deliver-e2e.test.js +12 -16
- package/dist/core/__tests__/serial/live-mutation.test.js +1 -1
- package/dist/core/__tests__/serial/tmux-surface.test.js +4 -2
- package/dist/core/__tests__/serial/worktree.test.js +24 -198
- package/dist/core/__tests__/session-cycles.test.js +22 -0
- package/dist/core/__tests__/stop-guard.test.js +4 -4
- package/dist/core/__tests__/watchdog-abort-arms-retry.test.js +19 -4
- package/dist/core/bash-jobs.d.ts +6 -0
- package/dist/core/bash-jobs.js +10 -0
- package/dist/core/canvas/__tests__/attention.test.js +8 -5
- package/dist/core/canvas/__tests__/render-remote.test.js +5 -5
- package/dist/core/canvas/attention.js +8 -6
- package/dist/core/canvas/browse/app.d.ts +1 -1
- package/dist/core/canvas/browse/app.js +21 -3
- package/dist/core/canvas/browse/model.d.ts +8 -2
- package/dist/core/canvas/browse/model.js +11 -4
- package/dist/core/canvas/browse/render.d.ts +4 -0
- package/dist/core/canvas/browse/render.js +5 -1
- package/dist/core/canvas/canvas.d.ts +33 -0
- package/dist/core/canvas/canvas.js +92 -0
- package/dist/core/canvas/crons.d.ts +9 -0
- package/dist/core/canvas/crons.js +51 -0
- package/dist/core/canvas/node-order.d.ts +22 -1
- package/dist/core/canvas/node-order.js +26 -1
- package/dist/core/canvas/render-source.d.ts +5 -0
- package/dist/core/canvas/render-source.js +1 -0
- package/dist/core/canvas/types.d.ts +9 -3
- package/dist/core/command-plugins/bundle.d.ts +6 -1
- package/dist/core/command-plugins/bundle.js +26 -13
- package/dist/core/command.js +8 -12
- package/dist/core/config.d.ts +47 -1
- package/dist/core/config.js +138 -4
- package/dist/core/help.d.ts +3 -0
- package/dist/core/help.js +1 -1
- package/dist/core/human/__tests__/page-catalog.test.d.ts +1 -0
- package/dist/core/human/__tests__/page-catalog.test.js +20 -0
- package/dist/core/human/__tests__/page-tickets.test.js +68 -34
- package/dist/core/human/__tests__/page.test.js +60 -119
- package/dist/core/human/__tests__/serial/inbox-core.test.js +6 -16
- package/dist/core/human/answer-text.d.ts +3 -0
- package/dist/core/human/answer-text.js +98 -0
- package/dist/core/human/answer.d.ts +53 -0
- package/dist/core/human/answer.js +119 -0
- package/dist/core/human/component-docs.d.ts +18 -0
- package/dist/core/human/component-docs.js +434 -0
- package/dist/core/human/convention.d.ts +17 -3
- package/dist/core/human/convention.js +36 -5
- package/dist/core/human/feedback-companion.d.ts +20 -0
- package/dist/core/human/feedback-companion.js +98 -0
- package/dist/core/human/feedback.d.ts +65 -0
- package/dist/core/human/feedback.js +116 -0
- package/dist/core/human/page-catalog.d.ts +56 -5
- package/dist/core/human/page-catalog.js +151 -22
- package/dist/core/human/page-errors.d.ts +4 -0
- package/dist/core/human/page-errors.js +7 -0
- package/dist/core/human/page-eval.d.ts +20 -0
- package/dist/core/human/page-eval.js +123 -0
- package/dist/core/human/page-schema.d.ts +48 -116
- package/dist/core/human/page-schema.js +100 -72
- package/dist/core/human/page-synth.d.ts +2 -4
- package/dist/core/human/page-synth.js +20 -7
- package/dist/core/human/page.d.ts +13 -21
- package/dist/core/human/page.js +147 -391
- package/dist/core/human/review-schema.d.ts +1 -0
- package/dist/core/human/review-schema.js +1 -1
- package/dist/core/human/root.d.ts +6 -2
- package/dist/core/human/root.js +12 -4
- package/dist/core/human/scan.d.ts +3 -3
- package/dist/core/human/scan.js +21 -21
- package/dist/core/human/summary.d.ts +2 -6
- package/dist/core/human/summary.js +3 -59
- package/dist/core/human/tickets.d.ts +22 -15
- package/dist/core/human/tickets.js +90 -28
- package/dist/core/human/types.d.ts +14 -2
- package/dist/core/keybindings/catalog.d.ts +2 -2
- package/dist/core/keybindings/catalog.js +1 -0
- package/dist/core/preview-registry.js +8 -10
- package/dist/core/profiles/default-binding.d.ts +4 -0
- package/dist/core/profiles/default-binding.js +24 -0
- package/dist/core/profiles/deletion-reservation.d.ts +8 -0
- package/dist/core/profiles/deletion-reservation.js +38 -0
- package/dist/core/profiles/manifest.d.ts +3 -0
- package/dist/core/profiles/manifest.js +12 -0
- package/dist/core/profiles/select.js +2 -2
- package/dist/core/review/realize.js +12 -4
- package/dist/core/review/store.d.ts +6 -0
- package/dist/core/review/store.js +31 -0
- package/dist/core/runtime/bearings.d.ts +0 -4
- package/dist/core/runtime/bearings.js +4 -62
- package/dist/core/runtime/bin-contributions.d.ts +44 -0
- package/dist/core/runtime/bin-contributions.js +186 -0
- package/dist/core/runtime/boot-root.js +6 -1
- package/dist/core/runtime/broker/client-registry.d.ts +4 -0
- package/dist/core/runtime/broker/client-registry.js +13 -1
- package/dist/core/runtime/broker/extension-abort.d.ts +1 -1
- package/dist/core/runtime/broker/extension-abort.js +4 -2
- package/dist/core/runtime/broker/fault-retry.js +4 -0
- package/dist/core/runtime/broker/frame-dispatch.d.ts +3 -1
- package/dist/core/runtime/broker/frame-dispatch.js +5 -6
- package/dist/core/runtime/broker/read-ops.d.ts +1 -1
- package/dist/core/runtime/broker/read-ops.js +2 -2
- package/dist/core/runtime/broker/rebind.d.ts +1 -0
- package/dist/core/runtime/broker/rebind.js +6 -1
- package/dist/core/runtime/broker-extension-render.js +19 -0
- package/dist/core/runtime/broker-protocol.d.ts +14 -0
- package/dist/core/runtime/broker.d.ts +1 -1
- package/dist/core/runtime/broker.js +25 -12
- package/dist/core/runtime/busy.d.ts +4 -3
- package/dist/core/runtime/busy.js +4 -3
- package/dist/core/runtime/front-door-env.d.ts +5 -0
- package/dist/core/runtime/front-door-env.js +16 -0
- package/dist/core/runtime/front-door.d.ts +1 -5
- package/dist/core/runtime/front-door.js +2 -5
- package/dist/core/runtime/host.d.ts +1 -1
- package/dist/core/runtime/invocation.d.ts +6 -0
- package/dist/core/runtime/invocation.js +10 -0
- package/dist/core/runtime/kickoff.js +34 -0
- package/dist/core/runtime/launch.d.ts +2 -6
- package/dist/core/runtime/node-read.js +4 -1
- package/dist/core/runtime/nodes.js +2 -0
- package/dist/core/runtime/promote.d.ts +1 -0
- package/dist/core/runtime/promote.js +3 -1
- package/dist/core/runtime/session-cycles.d.ts +6 -0
- package/dist/core/runtime/session-cycles.js +15 -1
- package/dist/core/runtime/session-visibility.d.ts +17 -8
- package/dist/core/runtime/session-visibility.js +19 -10
- package/dist/core/runtime/spawn-env.d.ts +9 -1
- package/dist/core/runtime/spawn-env.js +62 -2
- package/dist/core/runtime/spawn.js +4 -4
- package/dist/core/runtime/stop-guard.d.ts +2 -2
- package/dist/core/runtime/stop-guard.js +2 -2
- package/dist/core/runtime/stop-signals.d.ts +1 -1
- package/dist/core/runtime/stop-signals.js +2 -2
- package/dist/core/runtime/tmux-bindings.js +1 -1
- package/dist/core/session-model/session-state.d.ts +4 -3
- package/dist/core/session-model/session-state.js +14 -1
- package/dist/core/user-settings.d.ts +36 -2
- package/dist/core/user-settings.js +56 -14
- package/dist/core/worktree.d.ts +15 -45
- package/dist/core/worktree.js +59 -261
- package/dist/daemon/api/__tests__/seam/profile-delete.test.d.ts +1 -0
- package/dist/daemon/api/__tests__/seam/profile-delete.test.js +386 -0
- package/dist/daemon/api/handlers/bash-jobs.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +9 -5
- package/dist/daemon/api/handlers/feedback-comments.d.ts +2 -0
- package/dist/daemon/api/handlers/feedback-comments.js +207 -0
- package/dist/daemon/api/handlers/human.js +24 -20
- package/dist/daemon/api/handlers/inbox.d.ts +10 -0
- package/dist/daemon/api/handlers/inbox.js +48 -109
- package/dist/daemon/api/handlers/profiles.js +11 -29
- package/dist/daemon/api/map.d.ts +6 -1
- package/dist/daemon/api/map.js +23 -0
- package/dist/daemon/api/server.js +3 -1
- package/dist/daemon/companion-retire.d.ts +2 -0
- package/dist/daemon/companion-retire.js +33 -0
- package/dist/daemon/cron-run.js +29 -17
- package/dist/daemon/crtrd.js +1 -1
- package/dist/daemon/fleet.d.ts +22 -10
- package/dist/daemon/fleet.js +43 -24
- package/dist/daemon/human/finish.d.ts +12 -6
- package/dist/daemon/human/finish.js +134 -54
- package/dist/daemon/human/sweep.js +9 -3
- package/dist/daemon/profile-delete.d.ts +7 -0
- package/dist/daemon/profile-delete.js +306 -0
- package/dist/daemon/reconcilers/broker-supervision.js +14 -9
- package/dist/daemon/reconcilers/dormant-inbox.js +11 -6
- package/dist/daemon/reconcilers/live-obligation.d.ts +21 -1
- package/dist/daemon/reconcilers/live-obligation.js +30 -2
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +5 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +28 -1
- package/dist/daemon/review/deliver.js +3 -3
- package/dist/daemon/review/finish.d.ts +0 -2
- package/dist/daemon/review/finish.js +1 -29
- package/dist/daemon/review/sweep.js +12 -1
- package/dist/pi-extensions/__tests__/canvas-bash-valve.test.js +56 -1
- package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +4 -4
- package/dist/pi-extensions/canvas-bash-valve.d.ts +9 -1
- package/dist/pi-extensions/canvas-bash-valve.js +31 -13
- package/dist/pi-extensions/canvas-inbox-watcher.js +1 -1
- package/dist/pi-extensions/canvas-review-boundary.d.ts +4 -0
- package/dist/pi-extensions/canvas-review-boundary.js +18 -9
- package/dist/pi-extensions/canvas-stophook.js +4 -4
- package/dist/shared/generated-context.js +2 -2
- package/dist/types.d.ts +61 -5
- package/dist/types.js +8 -2
- package/package.json +4 -4
- package/runtime.lock.json +5 -33
- package/scripts/install-runtime.mjs +19 -24
- package/dist/builtin-memory/init.md +0 -38
- package/dist/builtin-memory/plan.md +0 -19
- package/dist/builtin-memory/spec.md +0 -19
- package/dist/clients/attach/render/html-markdown.d.ts +0 -13
- package/dist/clients/attach/render/html-markdown.js +0 -206
- package/dist/commands/human/doc.js +0 -144
- package/dist/commands/human/inbox.d.ts +0 -2
- package/dist/core/human/__tests__/page-render.test.js +0 -49
- package/dist/core/human/markdown-html.d.ts +0 -8
- package/dist/core/human/markdown-html.js +0 -581
- package/dist/core/human/page-render.d.ts +0 -3
- package/dist/core/human/page-render.js +0 -131
- package/dist/pages/bundle.css +0 -1
- package/dist/pages/bundle.js +0 -1347
- package/dist/pages/comments.d.ts +0 -43
- package/dist/pages/comments.js +0 -125
- package/dist/pages/elements/cards.d.ts +0 -17
- package/dist/pages/elements/cards.js +0 -802
- package/dist/pages/elements/chart.js +0 -648
- package/dist/pages/elements/options.d.ts +0 -21
- package/dist/pages/elements/options.js +0 -629
- package/dist/pages/elements/pages.d.ts +0 -24
- package/dist/pages/elements/pages.js +0 -355
- package/dist/pages/elements/slot.d.ts +0 -21
- package/dist/pages/elements/slot.js +0 -105
- package/dist/pages/elements/table.d.ts +0 -19
- package/dist/pages/elements/table.js +0 -935
- package/dist/pages/elements/text.d.ts +0 -25
- package/dist/pages/elements/text.js +0 -968
- package/dist/pages/entry.d.ts +0 -8
- package/dist/pages/entry.js +0 -8
- package/dist/pages/host.d.ts +0 -158
- package/dist/pages/host.js +0 -182
- package/dist/pages/register.d.ts +0 -2
- package/dist/pages/register.js +0 -3
- package/dist/pages/slot-config.d.ts +0 -36
- package/dist/pages/slot-config.js +0 -50
- package/dist/pages/types.d.ts +0 -98
- package/dist/pages/types.js +0 -23
- /package/dist/{core/human/__tests__/page-render.test.d.ts → commands/__tests__/node-message.test.d.ts} +0 -0
- /package/dist/{pages/elements/chart.d.ts → core/__tests__/plugin-page-components.test.d.ts} +0 -0
package/dist/pages/comments.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comment list algebra, shared by every element in the bundle so commenting is one
|
|
3
|
-
* behaviour and not five near-identical ones.
|
|
4
|
-
*
|
|
5
|
-
* The editing model is **one comment per anchor**: an option, a row, a column, a card or a
|
|
6
|
-
* range holds at most one comment, and re-commenting edits it. The response type still
|
|
7
|
-
* carries a list with ids, because a `range` anchor on a long document naturally grows
|
|
8
|
-
* several and the contract should not have to change when it does.
|
|
9
|
-
*
|
|
10
|
-
* Every function here is pure over the array it is given — elements hold their own comment
|
|
11
|
-
* list in local state, replace it with the returned one, and hand the whole response to
|
|
12
|
-
* `respond()`.
|
|
13
|
-
*/
|
|
14
|
-
import type { Comment, CommentAnchor } from './types.js';
|
|
15
|
-
/** A stable string identity for an anchor, used to find and key comments. */
|
|
16
|
-
export declare function anchorKey(anchor: CommentAnchor): string;
|
|
17
|
-
/** The comment on `anchor`, if the user has left one. */
|
|
18
|
-
export declare function findComment(comments: Comment[], anchor: CommentAnchor): Comment | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Write a comment at `anchor`, replacing any comment already there. Empty or whitespace-only
|
|
21
|
-
* text removes it — clearing the box is how you delete, so the popover never needs a separate
|
|
22
|
-
* destructive path for "I changed my mind". An edit keeps the existing comment's id, so the
|
|
23
|
-
* response is stable across retyping.
|
|
24
|
-
*/
|
|
25
|
-
export declare function setComment(comments: Comment[], anchor: CommentAnchor, text: string): Comment[];
|
|
26
|
-
/**
|
|
27
|
-
* Take over a comment list the host saved earlier (`savedResponse`), as this element's own
|
|
28
|
-
* local state. Malformed entries are dropped rather than thrown on — hydration must never be
|
|
29
|
-
* the reason a page fails to render — and the one-comment-per-anchor rule is re-imposed.
|
|
30
|
-
*
|
|
31
|
-
* Adopting also advances the id counter past every `cN` id taken from the saved list, so a
|
|
32
|
-
* comment written after a reopen cannot be minted with an id a saved comment already holds.
|
|
33
|
-
*/
|
|
34
|
-
export declare function adoptComments(value: unknown): Comment[];
|
|
35
|
-
/**
|
|
36
|
-
* Comment ids are frame-local: the host does not mint them, and nothing downstream keys off
|
|
37
|
-
* their value — `validatePageResponses` only requires a non-empty string. One counter is
|
|
38
|
-
* shared by every element in the bundle, so ids are unique across a whole page and stay
|
|
39
|
-
* legible in a response the human reads.
|
|
40
|
-
*/
|
|
41
|
-
export declare function newCommentId(): string;
|
|
42
|
-
/** A short, human label for what a comment is attached to. */
|
|
43
|
-
export declare function anchorLabel(anchor: CommentAnchor): string;
|
package/dist/pages/comments.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comment list algebra, shared by every element in the bundle so commenting is one
|
|
3
|
-
* behaviour and not five near-identical ones.
|
|
4
|
-
*
|
|
5
|
-
* The editing model is **one comment per anchor**: an option, a row, a column, a card or a
|
|
6
|
-
* range holds at most one comment, and re-commenting edits it. The response type still
|
|
7
|
-
* carries a list with ids, because a `range` anchor on a long document naturally grows
|
|
8
|
-
* several and the contract should not have to change when it does.
|
|
9
|
-
*
|
|
10
|
-
* Every function here is pure over the array it is given — elements hold their own comment
|
|
11
|
-
* list in local state, replace it with the returned one, and hand the whole response to
|
|
12
|
-
* `respond()`.
|
|
13
|
-
*/
|
|
14
|
-
/** A stable string identity for an anchor, used to find and key comments. */
|
|
15
|
-
export function anchorKey(anchor) {
|
|
16
|
-
switch (anchor.kind) {
|
|
17
|
-
case 'whole':
|
|
18
|
-
return 'whole';
|
|
19
|
-
case 'option':
|
|
20
|
-
return `option:${anchor.optionId}`;
|
|
21
|
-
case 'row':
|
|
22
|
-
return `row:${anchor.rowId}`;
|
|
23
|
-
case 'column':
|
|
24
|
-
return `column:${anchor.columnId}`;
|
|
25
|
-
case 'card':
|
|
26
|
-
return `card:${anchor.cardId}`;
|
|
27
|
-
case 'range':
|
|
28
|
-
return `range:${anchor.start}:${anchor.end}`;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** The comment on `anchor`, if the user has left one. */
|
|
32
|
-
export function findComment(comments, anchor) {
|
|
33
|
-
const key = anchorKey(anchor);
|
|
34
|
-
return comments.find((comment) => anchorKey(comment.anchor) === key);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Write a comment at `anchor`, replacing any comment already there. Empty or whitespace-only
|
|
38
|
-
* text removes it — clearing the box is how you delete, so the popover never needs a separate
|
|
39
|
-
* destructive path for "I changed my mind". An edit keeps the existing comment's id, so the
|
|
40
|
-
* response is stable across retyping.
|
|
41
|
-
*/
|
|
42
|
-
export function setComment(comments, anchor, text) {
|
|
43
|
-
const key = anchorKey(anchor);
|
|
44
|
-
const rest = comments.filter((comment) => anchorKey(comment.anchor) !== key);
|
|
45
|
-
const trimmed = text.trim();
|
|
46
|
-
if (trimmed === '')
|
|
47
|
-
return rest;
|
|
48
|
-
const existing = comments.find((comment) => anchorKey(comment.anchor) === key);
|
|
49
|
-
return [...rest, { id: existing?.id ?? newCommentId(), anchor, text: trimmed }];
|
|
50
|
-
}
|
|
51
|
-
let counter = 0;
|
|
52
|
-
/** Whether a value read back from a host is a comment anchor this bundle understands. */
|
|
53
|
-
function isAnchor(value) {
|
|
54
|
-
if (typeof value !== 'object' || value === null)
|
|
55
|
-
return false;
|
|
56
|
-
const anchor = value;
|
|
57
|
-
switch (anchor.kind) {
|
|
58
|
-
case 'whole':
|
|
59
|
-
return true;
|
|
60
|
-
case 'option':
|
|
61
|
-
return typeof anchor.optionId === 'string';
|
|
62
|
-
case 'row':
|
|
63
|
-
return typeof anchor.rowId === 'string';
|
|
64
|
-
case 'column':
|
|
65
|
-
return typeof anchor.columnId === 'string';
|
|
66
|
-
case 'card':
|
|
67
|
-
return typeof anchor.cardId === 'string';
|
|
68
|
-
case 'range':
|
|
69
|
-
return typeof anchor.start === 'number' && typeof anchor.end === 'number' && typeof anchor.quote === 'string';
|
|
70
|
-
default:
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Take over a comment list the host saved earlier (`savedResponse`), as this element's own
|
|
76
|
-
* local state. Malformed entries are dropped rather than thrown on — hydration must never be
|
|
77
|
-
* the reason a page fails to render — and the one-comment-per-anchor rule is re-imposed.
|
|
78
|
-
*
|
|
79
|
-
* Adopting also advances the id counter past every `cN` id taken from the saved list, so a
|
|
80
|
-
* comment written after a reopen cannot be minted with an id a saved comment already holds.
|
|
81
|
-
*/
|
|
82
|
-
export function adoptComments(value) {
|
|
83
|
-
if (!Array.isArray(value))
|
|
84
|
-
return [];
|
|
85
|
-
const adopted = [];
|
|
86
|
-
for (const entry of value) {
|
|
87
|
-
if (typeof entry !== 'object' || entry === null)
|
|
88
|
-
continue;
|
|
89
|
-
const { id, anchor, text } = entry;
|
|
90
|
-
if (typeof id !== 'string' || id === '')
|
|
91
|
-
continue;
|
|
92
|
-
if (typeof text !== 'string' || text.trim() === '')
|
|
93
|
-
continue;
|
|
94
|
-
if (!isAnchor(anchor))
|
|
95
|
-
continue;
|
|
96
|
-
if (findComment(adopted, anchor) !== undefined)
|
|
97
|
-
continue;
|
|
98
|
-
adopted.push({ id, anchor: { ...anchor }, text });
|
|
99
|
-
const minted = /^c(\d+)$/.exec(id);
|
|
100
|
-
if (minted !== null)
|
|
101
|
-
counter = Math.max(counter, Number(minted[1]));
|
|
102
|
-
}
|
|
103
|
-
return adopted;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Comment ids are frame-local: the host does not mint them, and nothing downstream keys off
|
|
107
|
-
* their value — `validatePageResponses` only requires a non-empty string. One counter is
|
|
108
|
-
* shared by every element in the bundle, so ids are unique across a whole page and stay
|
|
109
|
-
* legible in a response the human reads.
|
|
110
|
-
*/
|
|
111
|
-
export function newCommentId() {
|
|
112
|
-
counter += 1;
|
|
113
|
-
return `c${counter}`;
|
|
114
|
-
}
|
|
115
|
-
/** A short, human label for what a comment is attached to. */
|
|
116
|
-
export function anchorLabel(anchor) {
|
|
117
|
-
switch (anchor.kind) {
|
|
118
|
-
case 'whole':
|
|
119
|
-
return 'this';
|
|
120
|
-
case 'range':
|
|
121
|
-
return `\u201c${anchor.quote}\u201d`;
|
|
122
|
-
default:
|
|
123
|
-
return anchorKey(anchor);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `<crtr-cards>` — the choice `options` makes, when each candidate has enough body to
|
|
3
|
-
* deserve its own surface: a meeting slot, a vendor, a search result.
|
|
4
|
-
*
|
|
5
|
-
* This is a port of the agent interaction kit's `cards` component, not a new design. The
|
|
6
|
-
* selection treatment is the kit's selectable-surface recipe — a hairline surface that
|
|
7
|
-
* answers the pointer and goes accent-toned once chosen — carrying the kit's selection
|
|
8
|
-
* control and the kit's comment affordance. Navigation is the kit's classic list grammar
|
|
9
|
-
* (`j`/`k` move, `x` selects, `c` comments), so a card grid, an option list and a table
|
|
10
|
-
* are all driven the same way.
|
|
11
|
-
*
|
|
12
|
-
* Data arrives one of two ways: inline `cards`, or a `source` the host resolves through
|
|
13
|
-
* `artifactData()`. The element never touches the network, and anything it cannot render —
|
|
14
|
-
* a malformed config, an unreachable source, source data that is not a card list — becomes
|
|
15
|
-
* a named unavailable state rather than an exception.
|
|
16
|
-
*/
|
|
17
|
-
export {};
|