@qvac/core 0.2.0 → 0.2.2
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/.claude/skills/compaction/SKILL.md +9 -4
- package/.claude/skills/pr-create/SKILL.md +24 -3
- package/.claude/skills/pr-review/SKILL.md +248 -40
- package/CLAUDE.md +1 -3
- package/README.md +3 -1
- package/dist-lib/client.js +1 -1
- package/dist-lib/index.js +8 -8
- package/dist-lib/lib/api/agents.d.ts +1 -1
- package/dist-lib/lib/api/agents.js +10 -9
- package/dist-lib/lib/api/app-config.js +1 -1
- package/dist-lib/lib/api/approval-rules.js +9 -5
- package/dist-lib/lib/api/attachments.js +25 -3
- package/dist-lib/lib/api/chat-groups.d.ts +1 -1
- package/dist-lib/lib/api/chat-groups.js +5 -4
- package/dist-lib/lib/api/chat.js +8 -8
- package/dist-lib/lib/api/chunks.js +11 -11
- package/dist-lib/lib/api/config.js +1 -1
- package/dist-lib/lib/api/custom-models.js +2 -2
- package/dist-lib/lib/api/devices.d.ts +1 -1
- package/dist-lib/lib/api/devices.js +9 -9
- package/dist-lib/lib/api/diagnostics.js +1 -1
- package/dist-lib/lib/api/effective-ctx-size.js +1 -1
- package/dist-lib/lib/api/execution.js +4 -4
- package/dist-lib/lib/api/files.js +2 -2
- package/dist-lib/lib/api/index.d.ts +1 -0
- package/dist-lib/lib/api/index.js +33 -33
- package/dist-lib/lib/api/instrument.js +1 -1
- package/dist-lib/lib/api/knowledge.js +4 -4
- package/dist-lib/lib/api/logs.js +1 -1
- package/dist-lib/lib/api/members.d.ts +4 -1
- package/dist-lib/lib/api/members.js +88 -18
- package/dist-lib/lib/api/mesh.d.ts +13 -3
- package/dist-lib/lib/api/mesh.js +25 -2
- package/dist-lib/lib/api/model-download.js +1 -1
- package/dist-lib/lib/api/network.js +1 -1
- package/dist-lib/lib/api/notifications.js +3 -3
- package/dist-lib/lib/api/rag.js +7 -7
- package/dist-lib/lib/api/sync.js +1 -1
- package/dist-lib/lib/api/tool-activity.js +4 -4
- package/dist-lib/lib/api/tool-configs.js +5 -5
- package/dist-lib/lib/api/watchable.js +1 -1
- package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
- package/dist-lib/lib/assistant/fetch-body.js +36 -0
- package/dist-lib/lib/assistant/harness.d.ts +225 -0
- package/dist-lib/lib/assistant/harness.js +154 -0
- package/dist-lib/lib/assistant/history.d.ts +32 -0
- package/dist-lib/lib/assistant/history.js +232 -0
- package/dist-lib/lib/assistant/message.d.ts +45 -0
- package/dist-lib/lib/assistant/message.js +47 -0
- package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
- package/dist-lib/lib/assistant/skill-encode.js +71 -0
- package/dist-lib/lib/assistant-client.js +2 -2
- package/dist-lib/lib/assistant-tree.js +10 -4
- package/dist-lib/lib/assistant.d.ts +25 -285
- package/dist-lib/lib/assistant.js +250 -637
- package/dist-lib/lib/audio-format.js +2 -2
- package/dist-lib/lib/client.js +2 -2
- package/dist-lib/lib/collabora/convert.js +1 -1
- package/dist-lib/lib/collabora/entry.js +1 -1
- package/dist-lib/lib/collabora/worker.js +1 -1
- package/dist-lib/lib/compaction.d.ts +1 -2
- package/dist-lib/lib/compaction.js +8 -6
- package/dist-lib/lib/constants.js +1 -1
- package/dist-lib/lib/core/account-recovery.d.ts +19 -0
- package/dist-lib/lib/core/account-recovery.js +50 -0
- package/dist-lib/lib/core/agent.js +8 -4
- package/dist-lib/lib/core/app-build.d.ts +1 -1
- package/dist-lib/lib/core/approval-rules.d.ts +1 -0
- package/dist-lib/lib/core/approval-rules.js +3 -1
- package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
- package/dist-lib/lib/core/archived-mesh.js +162 -0
- package/dist-lib/lib/core/chat-activity.js +1 -1
- package/dist-lib/lib/core/chat-group.d.ts +1 -0
- package/dist-lib/lib/core/chat-group.js +24 -4
- package/dist-lib/lib/core/chat-search.js +2 -2
- package/dist-lib/lib/core/chat.js +5 -5
- package/dist-lib/lib/core/chunk.d.ts +1 -1
- package/dist-lib/lib/core/chunk.js +4 -4
- package/dist-lib/lib/core/contract/agents.js +1 -1
- package/dist-lib/lib/core/contract/approval-rules.js +6 -4
- package/dist-lib/lib/core/contract/attestations.js +1 -1
- package/dist-lib/lib/core/contract/chat-group.js +1 -1
- package/dist-lib/lib/core/contract/chat.js +1 -1
- package/dist-lib/lib/core/contract/chunks.js +2 -2
- package/dist-lib/lib/core/contract/compute.d.ts +11 -0
- package/dist-lib/lib/core/contract/compute.js +45 -0
- package/dist-lib/lib/core/contract/devices.js +16 -3
- package/dist-lib/lib/core/contract/index.d.ts +3 -1
- package/dist-lib/lib/core/contract/index.js +19 -16
- package/dist-lib/lib/core/contract/indexing.js +2 -2
- package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
- package/dist-lib/lib/core/contract/knowledge.js +2 -2
- package/dist-lib/lib/core/contract/members.js +2 -2
- package/dist-lib/lib/core/contract/seal.d.ts +2 -0
- package/dist-lib/lib/core/contract/seal.js +8 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
- package/dist-lib/lib/core/contract/tool-activity.js +1 -1
- package/dist-lib/lib/core/contract/tool-configs.js +3 -3
- package/dist-lib/lib/core/contract/writers.js +66 -42
- package/dist-lib/lib/core/departures.js +1 -1
- package/dist-lib/lib/core/device-invites.js +1 -1
- package/dist-lib/lib/core/document-attachment.js +2 -2
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +2 -2
- package/dist-lib/lib/core/files/index.js +19 -19
- package/dist-lib/lib/core/files/knowledge.js +3 -3
- package/dist-lib/lib/core/files/preview/image.js +1 -1
- package/dist-lib/lib/core/files/preview/index.js +6 -6
- package/dist-lib/lib/core/files/processing/claims.js +1 -1
- package/dist-lib/lib/core/files/processing/document.js +5 -5
- package/dist-lib/lib/core/files/processing/index.js +8 -8
- package/dist-lib/lib/core/files/processing/ownership.js +1 -1
- package/dist-lib/lib/core/files/processing/protocol.js +3 -3
- package/dist-lib/lib/core/files/processing/source.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
- package/dist-lib/lib/core/files/rag/build.js +2 -2
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
- package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
- package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
- package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/index.js +22 -22
- package/dist-lib/lib/core/files/rag/load.js +5 -5
- package/dist-lib/lib/core/files/rag/policy.js +2 -2
- package/dist-lib/lib/core/files/rag/produce.js +5 -5
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +6 -5
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/search.js +7 -4
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +32 -2
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
- package/dist-lib/lib/core/files/records/chunks.js +1 -1
- package/dist-lib/lib/core/files/records/index.js +8 -8
- package/dist-lib/lib/core/files/records/knowledge.js +2 -2
- package/dist-lib/lib/core/files/records/output.js +1 -1
- package/dist-lib/lib/core/files/records/reclaim.js +5 -5
- package/dist-lib/lib/core/files/records/routing.js +7 -7
- package/dist-lib/lib/core/files/store/blob.js +2 -2
- package/dist-lib/lib/core/files/store/index.js +7 -7
- package/dist-lib/lib/core/files/store/reference.js +2 -2
- package/dist-lib/lib/core/files/store/server.js +1 -1
- package/dist-lib/lib/core/files/store/sweep.js +1 -1
- package/dist-lib/lib/core/files/upload-input.js +2 -2
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/files/upload.js +6 -6
- package/dist-lib/lib/core/harness-loan.d.ts +29 -0
- package/dist-lib/lib/core/harness-loan.js +187 -0
- package/dist-lib/lib/core/helpers/index.d.ts +2 -1
- package/dist-lib/lib/core/helpers/index.js +4 -4
- package/dist-lib/lib/core/hosted-agents.js +2 -2
- package/dist-lib/lib/core/identity.d.ts +2 -0
- package/dist-lib/lib/core/identity.js +4 -2
- package/dist-lib/lib/core/invite.d.ts +1 -0
- package/dist-lib/lib/core/invite.js +4 -2
- package/dist-lib/lib/core/local/index.d.ts +12 -3
- package/dist-lib/lib/core/local/index.js +75 -16
- package/dist-lib/lib/core/membership.d.ts +3 -0
- package/dist-lib/lib/core/membership.js +15 -1
- package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
- package/dist-lib/lib/core/mesh.d.ts +9 -3
- package/dist-lib/lib/core/mesh.js +41 -26
- package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
- package/dist-lib/lib/core/migrations/index.js +5 -3
- package/dist-lib/lib/core/migrations/membership.js +2 -2
- package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
- package/dist-lib/lib/core/migrations/seal.js +30 -0
- package/dist-lib/lib/core/next-frame.js +1 -1
- package/dist-lib/lib/core/notification.js +1 -1
- package/dist-lib/lib/core/ota-config.js +1 -1
- package/dist-lib/lib/core/secret-handoff.js +1 -1
- package/dist-lib/lib/core/send.js +3 -3
- package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
- package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
- package/dist-lib/lib/core/skill-secrets.js +3 -3
- package/dist-lib/lib/core/sync/devices.js +1 -1
- package/dist-lib/lib/core/sync/index.js +8 -5
- package/dist-lib/lib/core/sync-status.js +1 -1
- package/dist-lib/lib/core/system-info.js +1 -1
- package/dist-lib/lib/core/tool-activity.js +2 -2
- package/dist-lib/lib/core/tool-configs.js +2 -2
- package/dist-lib/lib/core.d.ts +41 -3
- package/dist-lib/lib/core.js +525 -90
- package/dist-lib/lib/credential-pusher.js +4 -4
- package/dist-lib/lib/deadline.js +1 -1
- package/dist-lib/lib/fs-drive-bridge.js +4 -2
- package/dist-lib/lib/integrations/index.js +3 -3
- package/dist-lib/lib/integrations/oauth-providers.js +1 -1
- package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
- package/dist-lib/lib/integrations/setup-routes.js +3 -3
- package/dist-lib/lib/knowledge-search.js +1 -1
- package/dist-lib/lib/log.js +3 -3
- package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
- package/dist-lib/lib/mesh-scoped-engine.js +96 -0
- package/dist-lib/lib/model-context.d.ts +2 -2
- package/dist-lib/lib/model-context.js +1 -1
- package/dist-lib/lib/model-download.js +6 -6
- package/dist-lib/lib/oauth/asana.js +3 -3
- package/dist-lib/lib/oauth/browser-connect.js +1 -1
- package/dist-lib/lib/oauth/client.js +2 -2
- package/dist-lib/lib/oauth/common.d.ts +1 -1
- package/dist-lib/lib/oauth/common.js +1 -1
- package/dist-lib/lib/oauth/flow-core.js +3 -3
- package/dist-lib/lib/oauth/flow.js +2 -2
- package/dist-lib/lib/oauth/google.js +4 -4
- package/dist-lib/lib/oauth/host.js +3 -3
- package/dist-lib/lib/oauth/loopback.js +1 -1
- package/dist-lib/lib/oauth/notion.js +3 -3
- package/dist-lib/lib/oauth/providers.js +1 -1
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/spotify.js +3 -3
- package/dist-lib/lib/oauth/token-exchange.js +1 -1
- package/dist-lib/lib/oauth.client.js +2 -2
- package/dist-lib/lib/oauth.js +12 -12
- package/dist-lib/lib/run-notices.d.ts +7 -7
- package/dist-lib/lib/run-transcript.js +1 -1
- package/dist-lib/schema/build.js +12 -6
- package/dist-lib/schema/content.d.ts +11 -11
- package/dist-lib/schema/engine.js +193 -30
- package/dist-lib/schema/field-order.js +2 -2
- package/dist-lib/schema/local.js +18 -4
- package/dist-lib/schema/qvac.js +15 -6
- package/dist-lib/spec/bind.js +41 -0
- package/dist-lib/spec/calls.js +12 -0
- package/dist-lib/spec/capabilities.d.ts +36 -12
- package/dist-lib/spec/hrpc/hrpc.json +161 -5
- package/dist-lib/spec/hrpc/index.js +154 -9
- package/dist-lib/spec/hrpc/messages.js +549 -129
- package/dist-lib/spec/hyperschema/index.js +549 -129
- package/dist-lib/spec/hyperschema/schema.json +370 -40
- package/dist-lib/spec/hyperschema/types.d.ts +85 -1
- package/dist-lib/spec/local/hyperdb/db.json +15 -0
- package/dist-lib/spec/local/hyperdb/index.js +70 -1
- package/dist-lib/spec/local/hyperdb/messages.js +300 -117
- package/dist-lib/spec/local/hyperschema/index.js +97 -4
- package/dist-lib/spec/local/hyperschema/schema.json +58 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
- package/package.json +16 -10
- package/tui/README.md +7 -0
- package/tui/app.mjs +311 -14
- package/tui/lib/busy-words.mjs +57 -5
- package/tui/lib/export.mjs +1 -0
- package/tui/lib/render.mjs +9 -2
- package/tui/main.mjs +5 -2
|
@@ -76,10 +76,15 @@ What makes the fold legal under the rule above:
|
|
|
76
76
|
|
|
77
77
|
Triggers: proactively before a run on the previous round's numbers, at the end of
|
|
78
78
|
a run that filled the window itself, and reactively once the harness overflow
|
|
79
|
-
ladder is exhausted.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
ladder is exhausted. The proactive share is tiered by window — 75% under 12k, 82%
|
|
80
|
+
under 16k, 85% under 32k, 90% under 64k, 95% from there — because the band has
|
|
81
|
+
to hold a whole thinking turn and `cacheTokens` reports a turn with its thinking
|
|
82
|
+
stripped. The end-of-run fold's `compacting` status is not an attempt start in
|
|
83
|
+
`historyFromChunks`; reading it as one drops the kept turn's answer. All three
|
|
84
|
+
announce a `compacting` phase, which clients must exempt from any restart rule
|
|
85
|
+
that discards a streamed answer on a non-terminal status. Clearing the phase
|
|
86
|
+
stays conditional — only the before-run fold does it, because its run carries
|
|
87
|
+
on.
|
|
83
88
|
|
|
84
89
|
After the fact the fold is visible from its chunk (`thread.compactionMarkers`,
|
|
85
90
|
anchored before the user message the fold precedes). Only the device that ran the
|
|
@@ -61,6 +61,26 @@ Optional, and taken from what the diff actually touches — `lib`, `tui`, `schem
|
|
|
61
61
|
A scope that restates the type (`fix(fix)`) or names the whole repo adds
|
|
62
62
|
nothing; leave it off.
|
|
63
63
|
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
`examples/` is where a consumer meets this library: `mesh-peer.mjs` stands a
|
|
67
|
+
Core and a Client up from nothing, `mesh-lab.mjs` drives scenarios against it.
|
|
68
|
+
They are read before `lib/` is.
|
|
69
|
+
|
|
70
|
+
**A PR that adds public API ships an example with it.** Public API means a new
|
|
71
|
+
entry in `package.json#exports`, a new export from `index.ts` or `client.ts`,
|
|
72
|
+
or a new capability that reaches the `Client` surface through `schema/`. Extend
|
|
73
|
+
an existing script or add one, whichever shows the capability in the fewest
|
|
74
|
+
lines someone can actually run.
|
|
75
|
+
|
|
76
|
+
An example is a runnable `.mjs` under `examples/` that imports the package the
|
|
77
|
+
way a consumer does. Give it a `package.json#scripts` entry when it is a
|
|
78
|
+
scenario run by name, and name it in the PR body.
|
|
79
|
+
|
|
80
|
+
Nothing else needs one — an internal module, a `tui/` command, a refactor, a
|
|
81
|
+
fix. Do not pad `examples/` to clear a checklist: one script a reader can run
|
|
82
|
+
beats three that restate the types.
|
|
83
|
+
|
|
64
84
|
## Decision records
|
|
65
85
|
|
|
66
86
|
`docs/decisions/` holds the durable, non-obvious choices — why a boundary is
|
|
@@ -155,11 +175,12 @@ this is the only warning they get.
|
|
|
155
175
|
each one is a change you would defend on its own. A trail of `wip`,
|
|
156
176
|
`fixup` or `address review` commits is not history; reshape it before
|
|
157
177
|
opening.
|
|
158
|
-
3.
|
|
178
|
+
3. New public API? `examples/` shows it, and the body names the script.
|
|
179
|
+
4. `bun run lint` and ``bun run test` (node, bare and addon lanes)` pass locally. CI runs the same lanes; a
|
|
159
180
|
red PR wastes a reviewer's round trip.
|
|
160
|
-
|
|
181
|
+
5. Rebase on `main` rather than merging it in. A merge commit in the branch
|
|
161
182
|
makes the diff unreadable.
|
|
162
|
-
|
|
183
|
+
6. Open as a **draft** unless you are asking for review right now.
|
|
163
184
|
|
|
164
185
|
```bash
|
|
165
186
|
gh pr create --repo tetherto/qvac-core --draft --title "type(scope): subject" --body-file <path>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pr-review
|
|
3
|
-
description: Deep-dive review of a pull request in @qvac/core, or of local uncommitted/branch changes when invoked with `local`. Checks CI, the commit type and title,
|
|
3
|
+
description: Deep-dive review of a pull request in @qvac/core, or of local uncommitted/branch changes when invoked with `local`. Checks CI and the base branch, the commit type and title, correctness and state/derived-data bugs, contract and API mismatches, security, code quality against the house style, and missing tests. In PR mode it creates PENDING inline comments only after the user confirms them, and never submits the review event. In local mode it prints findings in chat and posts nothing. Use when reviewing a PR, given a PR link, or asked to review the working tree or current branch.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# PR review
|
|
@@ -41,14 +41,18 @@ PR mode:
|
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
43
|
gh pr view <num> --repo tetherto/qvac-core \
|
|
44
|
-
--json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable
|
|
44
|
+
--json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable,statusCheckRollup \
|
|
45
|
+
> /tmp/pr-<num>.json
|
|
45
46
|
gh pr diff <num> --repo tetherto/qvac-core --patch > /tmp/pr-<num>.patch
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
the same bytes every time and the
|
|
49
|
+
Two calls, then read both files with Read/Grep rather than re-running `gh` — it
|
|
50
|
+
is the same bytes every time and the files are greppable. `statusCheckRollup`
|
|
51
|
+
already carries every check, so **do not run `gh pr checks`**; it buys nothing
|
|
52
|
+
the JSON does not have.
|
|
50
53
|
|
|
51
|
-
Local mode
|
|
54
|
+
Local mode. The default scope is everything uncommitted — staged, unstaged and
|
|
55
|
+
untracked:
|
|
52
56
|
|
|
53
57
|
```bash
|
|
54
58
|
git diff --staged > /tmp/local-staged.patch
|
|
@@ -57,8 +61,17 @@ git status --porcelain=v1
|
|
|
57
61
|
git ls-files --others --exclude-standard # untracked, easy to miss
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
Scope overrides, when the user asks for one: `--staged` is `git diff --staged`
|
|
65
|
+
alone, `--unstaged` is `git diff` plus untracked, and `--branch [<base>]` is
|
|
66
|
+
`git diff <base>...HEAD` (three dots — the merge base, not the tip), with
|
|
67
|
+
`<base>` defaulting to `main`.
|
|
68
|
+
|
|
69
|
+
Untracked files are reviewed as wholly new content: read them from the working
|
|
70
|
+
tree, they appear in no patch.
|
|
71
|
+
|
|
72
|
+
**If the requested scope is empty, say so and stop.** An empty `--staged` is
|
|
73
|
+
not an invitation to review something else, and it is certainly not an
|
|
74
|
+
invitation to invent findings.
|
|
62
75
|
|
|
63
76
|
## CI
|
|
64
77
|
|
|
@@ -78,8 +91,10 @@ local `bun run test` does not:
|
|
|
78
91
|
A PR that touches `schema/` and leaves `spec/` stale is the most common red
|
|
79
92
|
here, and it looks nothing like a test failure.
|
|
80
93
|
|
|
94
|
+
Read the result from `statusCheckRollup` in `/tmp/pr-<num>.json`, and pull logs
|
|
95
|
+
only for a job that actually failed:
|
|
96
|
+
|
|
81
97
|
```bash
|
|
82
|
-
gh pr checks <num> --repo tetherto/qvac-core
|
|
83
98
|
gh run view --repo tetherto/qvac-core --log-failed --job <id> > /tmp/pr-<num>-<id>.log
|
|
84
99
|
```
|
|
85
100
|
|
|
@@ -87,6 +102,18 @@ A red `Integrate` is a blocking finding on its own. Read the failing job's log
|
|
|
87
102
|
before writing a single line of review — half of what looks like a design
|
|
88
103
|
problem is a lint rule.
|
|
89
104
|
|
|
105
|
+
### Base branch
|
|
106
|
+
|
|
107
|
+
`baseRefName` is in the JSON you already fetched. Per CLAUDE.md a PR targets
|
|
108
|
+
`main`; the one exception is a stacked PR, which branches from the PR below it
|
|
109
|
+
and targets that branch.
|
|
110
|
+
|
|
111
|
+
So a base other than `main` is only a finding when the PR is **not** part of a
|
|
112
|
+
stack — check whether the base branch is itself an open PR before raising it.
|
|
113
|
+
If it is, the stack is correct and there is nothing to say. If it is not, that
|
|
114
|
+
is a `[P2]`: the diff will contain the base branch's commits and the PR cannot
|
|
115
|
+
merge as it stands.
|
|
116
|
+
|
|
90
117
|
## What to check, in order
|
|
91
118
|
|
|
92
119
|
Stop at the first tier that produces findings worth the author's time; a review
|
|
@@ -97,7 +124,38 @@ end to end, including the error path. Look for: a promise not awaited, a
|
|
|
97
124
|
listener never removed, a resource opened on one path and closed on another, an
|
|
98
125
|
error swallowed into a default.
|
|
99
126
|
|
|
100
|
-
**
|
|
127
|
+
A **regression** belongs here too: a change that reads as additive but alters
|
|
128
|
+
what existing callers get — a signature widened, a default flipped, a branch
|
|
129
|
+
removed, a return value that is semantically different at the same type.
|
|
130
|
+
|
|
131
|
+
**2. State and derived data.** The class of bug a linter cannot see and a diff
|
|
132
|
+
skim misses. Walk any new stateful or arithmetic code against these four.
|
|
133
|
+
|
|
134
|
+
- **Two sources of truth.** The same value in two fields, or the same
|
|
135
|
+
expression computed twice, in one payload. Before writing the comment, read
|
|
136
|
+
the type declaration **and** the consumer: if the fields have distinct
|
|
137
|
+
documented meanings (per-item vs aggregate, raw vs normalised) and a reader
|
|
138
|
+
prefers one, this is a value written to the wrong channel — a contract
|
|
139
|
+
violation — not duplication. Say that, and cite the contract. Only call it
|
|
140
|
+
duplication when nothing distinguishes the fields. The two look identical in
|
|
141
|
+
a diff and have opposite fixes: one keeps both fields and moves a value, the
|
|
142
|
+
other deletes a field. Backwards, and you send the author to delete a channel
|
|
143
|
+
something depends on. `[P2]` either way.
|
|
144
|
+
- **Incremental accumulation.** A running total or offset advanced inside a
|
|
145
|
+
loop, where computing the whole table once would be correct by construction.
|
|
146
|
+
`[P2]` when a later edit could desynchronise it — and the fix shrinks the
|
|
147
|
+
code.
|
|
148
|
+
- **Closure over mutated state.** A callback capturing a variable a later step
|
|
149
|
+
reassigns, especially across an `await`. `[P1]` if a late or reordered
|
|
150
|
+
invocation yields a wrong value; say so plainly, because it will not
|
|
151
|
+
reproduce locally.
|
|
152
|
+
- **Laundered values.** `?? 0`, `|| 0`, `Math.max(x, 0)` turning an impossible
|
|
153
|
+
input into a plausible number instead of letting it fail. `[P2]` unless the
|
|
154
|
+
clamp buys a stated presentational guarantee. Watch an optional `uint` in
|
|
155
|
+
`schema/`: it decodes to `0`, not `null`, so `??` never sees the absent
|
|
156
|
+
value.
|
|
157
|
+
|
|
158
|
+
**3. Contract and API.** This is a published package, so an exported signature
|
|
101
159
|
is a promise to a consumer.
|
|
102
160
|
|
|
103
161
|
- Anything added to or changed in the export map, `index.ts`, `types/`, or
|
|
@@ -107,27 +165,56 @@ is a promise to a consumer.
|
|
|
107
165
|
- Does the change match its own type declarations, and do callers in this repo
|
|
108
166
|
still typecheck?
|
|
109
167
|
|
|
110
|
-
**
|
|
111
|
-
document, not your own taste
|
|
112
|
-
and shape, no defensive programming,
|
|
168
|
+
**4. House style.** Load **js-house-style** and run the changed files against
|
|
169
|
+
it — that document, not your own taste or your memory of it. Layering,
|
|
170
|
+
composition on primitives, module size and shape, no defensive programming,
|
|
171
|
+
comment density. A style point the document does not back is not a finding.
|
|
113
172
|
|
|
114
|
-
**
|
|
173
|
+
**5. Tests.** A behaviour change with no test is a finding. Name the missing
|
|
115
174
|
case rather than asking for "more tests": the tests live under `test/`, run on
|
|
116
175
|
both the node and bare lanes, and a fix without a regression guard will come
|
|
117
176
|
back.
|
|
118
177
|
|
|
119
|
-
**
|
|
178
|
+
**6. Examples.** This is a library, and `examples/` is where a consumer learns
|
|
179
|
+
its surface — `mesh-peer.mjs` for standing up a Core and a Client,
|
|
180
|
+
`mesh-lab.mjs` for scenarios on top. New public API with nothing in `examples/`
|
|
181
|
+
is a finding: `[P2]` for a new entry in `package.json#exports` or a new export
|
|
182
|
+
from `index.ts` / `client.ts`, `[P3]` for a capability folded into an area an
|
|
183
|
+
existing script already covers. Name the script that should have changed and
|
|
184
|
+
the one thing it should show; anchor the comment on the new export line, since
|
|
185
|
+
the absence itself has no line.
|
|
186
|
+
|
|
187
|
+
Nothing else triggers this. An internal module, a `tui/` command, a refactor, a
|
|
188
|
+
fix, a test — no example, no finding. Do not ask for an example because a diff
|
|
189
|
+
is large.
|
|
190
|
+
|
|
191
|
+
**7. Commit type and title.** Per **pr-create**: is this really a `fix` (a
|
|
120
192
|
defect a consumer of a released version could hit), or is it `chore` on code
|
|
121
193
|
that never shipped? Is the title imperative and specific? Does the branch name
|
|
122
194
|
avoid `codex` / `cursor` / `claude`?
|
|
123
195
|
|
|
124
|
-
**
|
|
196
|
+
**8. Scope.** Does the PR do one thing? A behaviour change mixed with an
|
|
125
197
|
unrelated rename is two PRs — say so, and say which commit to split out.
|
|
126
198
|
|
|
127
|
-
**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
199
|
+
**9. Security.** Not a sweep of the file — only what this diff introduces. A
|
|
200
|
+
secret or key material in code, a log line or an error message; a peer-supplied
|
|
201
|
+
value trusted without validation at a trust boundary; unsafe deserialization of
|
|
202
|
+
anything off the wire; crypto used in a way the primitive does not promise
|
|
203
|
+
(a reused nonce, a comparison that is not constant-time, a key derived from
|
|
204
|
+
something predictable); a new dependency pulled in for something small.
|
|
205
|
+
|
|
206
|
+
This is a P2P library, so "the input came from another device" is the normal
|
|
207
|
+
case, not the exceptional one. Where it matters, `[P1]`.
|
|
208
|
+
|
|
209
|
+
**10. Decision records.** Only when the diff **contradicts** a record in
|
|
210
|
+
`docs/decisions/` that you have actually read — then the record is updated or
|
|
211
|
+
superseded in the same PR rather than left to rot, and that is a `[P2]`.
|
|
212
|
+
|
|
213
|
+
A missing record is not a finding. Do not open `docs/decisions/INDEX.md`
|
|
214
|
+
looking for something to say, do not ask for an ADR because a change "feels
|
|
215
|
+
architectural", and never make "no decision record" the only thing a review
|
|
216
|
+
found. If you genuinely think a lasting choice went unrecorded, say it once in
|
|
217
|
+
the chat overview as a question, never inline.
|
|
131
218
|
|
|
132
219
|
### Do not over-engineer the review
|
|
133
220
|
|
|
@@ -155,17 +242,38 @@ corner nobody chose.
|
|
|
155
242
|
Each finding: the file and line, what breaks, and the concrete scenario that
|
|
156
243
|
breaks it. No finding without a failure mode you can state.
|
|
157
244
|
|
|
158
|
-
Drop anything you cannot defend as changing the code, the reviewer's decision,
|
|
159
|
-
or a consumer's experience. Style opinions the house style does not back are
|
|
160
|
-
noise. Say so plainly when the diff is clean: "no `[P1]` or `[P2]`
|
|
161
|
-
findings" is a complete review.
|
|
162
|
-
|
|
163
245
|
Lead with the findings, ordered by severity.
|
|
164
246
|
|
|
247
|
+
### Only raise what is worth the author's time
|
|
248
|
+
|
|
249
|
+
A review is not required to produce findings. **"Nothing to flag — the diff is
|
|
250
|
+
clean" is a complete, successful review**, and a good PR reviewed honestly is
|
|
251
|
+
the expected outcome most of the time. Never go hunting for something to say
|
|
252
|
+
because the output looks empty; an invented finding costs the author more than
|
|
253
|
+
a silent review ever could.
|
|
254
|
+
|
|
255
|
+
Every finding passes this bar before it is written down:
|
|
256
|
+
|
|
257
|
+
- You can name **what breaks**, and the concrete path that reaches it.
|
|
258
|
+
- Acting on it **changes the code, the reviewer's decision, or a consumer's
|
|
259
|
+
experience**.
|
|
260
|
+
- It is backed by the house style or a real contract, not your taste.
|
|
261
|
+
|
|
262
|
+
Drop everything else. Not "mention it as a `[P3]`" — **drop it**. A finding you
|
|
263
|
+
cannot defend at `[P2]` is not thereby a `[P3]`; it is noise wearing a smaller
|
|
264
|
+
tag. `[P3]` is for a real, small, correct observation, not a holding pen for
|
|
265
|
+
weak `[P1]`/`[P2]`s.
|
|
266
|
+
|
|
267
|
+
The failure mode this repo has actually seen: a clean PR comes back with four
|
|
268
|
+
`[P3]`s about naming, a speculative race nobody can reach, and a request for a
|
|
269
|
+
decision record. That review is worse than no review — it trains the author to
|
|
270
|
+
skim the next one, and the real finding gets skimmed with it.
|
|
271
|
+
|
|
165
272
|
### Severity tags
|
|
166
273
|
|
|
167
|
-
Tag every finding `[P1]`, `[P2]` or `[P3]
|
|
168
|
-
reviews of the same repo rank things the same
|
|
274
|
+
Tag every finding `[P1]`, `[P2]` or `[P3]` **in the chat overview**, using the
|
|
275
|
+
tag rather than a word, so two reviews of the same repo rank things the same
|
|
276
|
+
way. The tag never appears on the PR — see "Comment style".
|
|
169
277
|
|
|
170
278
|
- `[P1]` — almost-certain bug, data corruption, security issue, CI breaker, or a
|
|
171
279
|
break of behaviour a consumer relies on. In the overview, and **proposed inline
|
|
@@ -182,35 +290,135 @@ nits inline teaches the author to skim the next one.
|
|
|
182
290
|
|
|
183
291
|
**Severity is what the code does today, not what it might do.** A finding whose
|
|
184
292
|
only support is a scenario nobody has hit is not a `[P2]`: either find the path
|
|
185
|
-
that reaches it, or drop it. Zero findings is
|
|
293
|
+
that reaches it, or drop it — do not park it at `[P3]` instead. Zero findings is
|
|
294
|
+
a legitimate result.
|
|
186
295
|
|
|
187
296
|
If the user says this is a re-review, say explicitly which earlier concerns are
|
|
188
297
|
resolved and which still stand.
|
|
189
298
|
|
|
299
|
+
### The overview
|
|
300
|
+
|
|
301
|
+
The user's checkout is usually on a different branch or commit than the PR, so
|
|
302
|
+
a bare line number is worth nothing to them. Every `[P1]` and `[P2]` in the
|
|
303
|
+
overview therefore carries two things: a **3–8 line excerpt read at the head
|
|
304
|
+
SHA**, and a **link to that line on the PR**.
|
|
305
|
+
|
|
306
|
+
The excerpt comes from
|
|
307
|
+
`gh api -H "Accept: application/vnd.github.raw" repos/tetherto/qvac-core/contents/<path>?ref=<headRefOid>`,
|
|
308
|
+
never from the local tree. The link is the file-diff anchor:
|
|
309
|
+
|
|
310
|
+
`https://github.com/tetherto/qvac-core/pull/<num>/files#diff-<sha256(path)>R<line>`
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
printf '%s' 'lib/chat/compact.js' | shasum -a 256 | awk '{print $1}'
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
If the anchor will not compute, fall back to
|
|
317
|
+
`https://github.com/tetherto/qvac-core/blob/<headRefOid>/<path>#L<line>`.
|
|
318
|
+
|
|
319
|
+
````markdown
|
|
320
|
+
## PR #<num> — review overview
|
|
321
|
+
|
|
322
|
+
<one line: what this PR does>
|
|
323
|
+
|
|
324
|
+
### CI / base
|
|
325
|
+
|
|
326
|
+
<one line; omit entirely when both are clean>
|
|
327
|
+
|
|
328
|
+
### Findings
|
|
329
|
+
|
|
330
|
+
- **[P1]** <short title> — [`<path>:<line>`](link)
|
|
331
|
+
|
|
332
|
+
<one sentence, plus the repro when there is one>
|
|
333
|
+
|
|
334
|
+
```js
|
|
335
|
+
<3-8 line excerpt at the head SHA>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- **[P3]** <short title> — [`<path>:<line>`](link) — <one sentence, no excerpt>
|
|
339
|
+
|
|
340
|
+
### Re-review delta
|
|
341
|
+
|
|
342
|
+
<only when the user said this is a re-review>
|
|
343
|
+
|
|
344
|
+
- Resolved: <…>
|
|
345
|
+
- Still open: <…>
|
|
346
|
+
````
|
|
347
|
+
|
|
348
|
+
One sentence per finding here; the inline comment carries the reasoning. A
|
|
349
|
+
clean review is this same block with `Findings` reading "nothing to flag".
|
|
350
|
+
|
|
351
|
+
Local mode uses the same shape, headed `## Local review — <scope>`, with plain
|
|
352
|
+
`path:line` instead of links and the excerpt read from the working tree.
|
|
353
|
+
|
|
354
|
+
## Comment style
|
|
355
|
+
|
|
356
|
+
Write like a colleague leaving a note, not a static analyser filing a report.
|
|
357
|
+
If a human reviewer would not say it out loud, do not write it.
|
|
358
|
+
|
|
359
|
+
- **Brief.** A few lines, one point per comment. If it takes three paragraphs
|
|
360
|
+
to justify, it probably is not a finding.
|
|
361
|
+
- **Ask, don't lecture.** "Can this reuse the existing helper?" beats a
|
|
362
|
+
paragraph on why the new one duplicates knowledge the store already owns.
|
|
363
|
+
- **Link what you refer to.** An existing function, type or rule you want
|
|
364
|
+
reused gets a line link — `[name](<url>#L120)`. A reference the author has to
|
|
365
|
+
hunt for is one they skip.
|
|
366
|
+
- **Show the change in code.** A short before/after, or a `suggestion` block
|
|
367
|
+
whenever the fix is mechanical enough to apply as-is.
|
|
368
|
+
- **Never put a severity marker in a comment body.** No `[P1]`/`[P2]`/`[P3]`,
|
|
369
|
+
no "blocker", no "nit:". Severity is how _you_ decided what to raise; it
|
|
370
|
+
lives in the chat overview and nowhere else. On the PR it reads as grading
|
|
371
|
+
the author and it ages badly once the code moves. If something is minor, say
|
|
372
|
+
it in plain words — "not urgent", "while you're in there".
|
|
373
|
+
- One concrete repro line for a `[P1]`/`[P2]` when one exists. Not a test plan.
|
|
374
|
+
- No praise padding, no "LGTM but…", no restating what the diff does.
|
|
375
|
+
- **Sign off every comment with 🤖 on its own last line**, so it is
|
|
376
|
+
unmistakable that the review came from an AI. Every inline comment, no
|
|
377
|
+
exceptions — the emoji alone, nothing else on the line.
|
|
378
|
+
|
|
190
379
|
## Posting (PR mode only)
|
|
191
380
|
|
|
192
|
-
1. Print every proposed comment in chat first: file,
|
|
193
|
-
|
|
194
|
-
|
|
381
|
+
1. Print every proposed comment in chat first, as it will be posted: file,
|
|
382
|
+
line, then the verbatim body. Carry the severity in the chat line **outside**
|
|
383
|
+
the body. The default set is the `[P1]` and `[P2]` findings; name any `[P3]`
|
|
384
|
+
you are holding back so the user can pull it in. If there is nothing at
|
|
385
|
+
`[P1]`/`[P2]`, say so and stop — never assemble a payload out of `[P3]`s to
|
|
386
|
+
have something to post.
|
|
195
387
|
2. Ask the user to confirm the exact set. Wait for a clear yes.
|
|
196
|
-
3.
|
|
388
|
+
3. Write `/tmp/pr-<num>-review.json` from the confirmed set **only**. If the
|
|
389
|
+
confirmed set is empty, stop — never post an empty review.
|
|
390
|
+
4. Pre-flight, before the POST:
|
|
391
|
+
- The comment count matches the confirmed set **exactly**. If it does not,
|
|
392
|
+
stop and reconcile; do not post the larger set and mention it after.
|
|
393
|
+
- Every `line` is a **post-PR line** — the `+` side of the patch, as
|
|
394
|
+
numbered in the file at the head SHA. A line the patch does not touch is a
|
|
395
|
+
`422` that rejects the whole review, so anchor to a touched line or move
|
|
396
|
+
the point to the chat overview.
|
|
397
|
+
- Every body ends with a `🤖` line, and none contains `[P1]`, `[P2]`, `[P3]`,
|
|
398
|
+
"nit" or "blocker". Fix the bodies yourself; do not ask the user.
|
|
399
|
+
- Show the bodies as **rendered Markdown**, one per `file:line`, never raw
|
|
400
|
+
JSON — the user is approving what the author will read.
|
|
401
|
+
5. Create the review as **PENDING**, with no event:
|
|
197
402
|
|
|
198
403
|
```bash
|
|
199
404
|
gh api repos/tetherto/qvac-core/pulls/<num>/reviews \
|
|
200
|
-
--method POST --input /tmp/review.json
|
|
405
|
+
--method POST --input /tmp/pr-<num>-review.json
|
|
201
406
|
```
|
|
202
407
|
|
|
203
|
-
where
|
|
204
|
-
`comments` array of `{path, line, side, body}`, and **no `event` field**. A
|
|
205
|
-
with `event` submits the review; leaving it out is what makes it
|
|
408
|
+
where the payload has `commit_id` (the `headRefOid` you fetched) and a
|
|
409
|
+
`comments` array of `{path, line, side, body}`, and **no `event` field**. A
|
|
410
|
+
payload with `event` submits the review; leaving it out is what makes it
|
|
411
|
+
pending. No top-level `body` either, unless the user asks for one — the inline
|
|
412
|
+
comments are the review.
|
|
206
413
|
|
|
207
|
-
|
|
208
|
-
|
|
414
|
+
If the user edits the selection after the preview, rewrite the file before
|
|
415
|
+
running the command.
|
|
209
416
|
|
|
210
|
-
|
|
211
|
-
|
|
417
|
+
6. Hand the user the link and stop:
|
|
418
|
+
`https://github.com/tetherto/qvac-core/pull/<num>#pullrequestreview-<id>`
|
|
212
419
|
|
|
213
420
|
## Sibling skills
|
|
214
421
|
|
|
215
422
|
- Writing the PR being reviewed → **pr-create**.
|
|
216
|
-
- The rules tier
|
|
423
|
+
- The rules tier 4 reviews against → **js-house-style**. Load it; do not review
|
|
424
|
+
from memory of it.
|
package/CLAUDE.md
CHANGED
|
@@ -10,9 +10,7 @@ A P2P, multi-device AI workbench core. Three pieces, one duplex stream:
|
|
|
10
10
|
through the Client's capability surface, like any other client. **The only
|
|
11
11
|
place inference happens.**
|
|
12
12
|
|
|
13
|
-
The library runs on both Bare and Node
|
|
14
|
-
that works on only one is a bug. `tui/` is the exception: it imports `bare-tui`
|
|
15
|
-
directly and is Bare-only.
|
|
13
|
+
The library runs on both Bare and Node; the test suite runs under Bare only.
|
|
16
14
|
|
|
17
15
|
## Durable invariants
|
|
18
16
|
|
package/README.md
CHANGED
|
@@ -60,7 +60,9 @@ duck --help
|
|
|
60
60
|
The library is the three pieces above — start at
|
|
61
61
|
[Integrating a harness](#integrating-a-harness). `duck` is the fastest way to
|
|
62
62
|
watch them work, and what the examples here drive; it has its own section at
|
|
63
|
-
[The duck TUI](#the-duck-tui).
|
|
63
|
+
[The duck TUI](#the-duck-tui). Runnable examples live in
|
|
64
|
+
[`examples/`](./examples/README.md); `bun run mesh-two-people` is the shortest
|
|
65
|
+
one, and shows what a device invite does that a member invite does not.
|
|
64
66
|
|
|
65
67
|
## Integrating a harness
|
|
66
68
|
|
package/dist-lib/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Client } from
|
|
1
|
+
export { Client } from './lib/client.js';
|
package/dist-lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { setLogger } from
|
|
2
|
-
export { Core } from
|
|
3
|
-
export { Client } from
|
|
4
|
-
export { AssistantClient } from
|
|
5
|
-
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from
|
|
6
|
-
export { assistantChild, assistantTree } from
|
|
7
|
-
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from
|
|
1
|
+
export { setLogger } from './lib/logger.js';
|
|
2
|
+
export { Core } from './lib/core.js';
|
|
3
|
+
export { Client } from './lib/client.js';
|
|
4
|
+
export { AssistantClient } from './lib/assistant-client.js';
|
|
5
|
+
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from './lib/assistant.js';
|
|
6
|
+
export { assistantChild, assistantTree } from './lib/assistant-tree.js';
|
|
7
|
+
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from './lib/suspend-lifecycle.js';
|
|
8
8
|
export { default as Supervisor } from 'bare-supervisor';
|
|
9
9
|
export { clientSessions, duplexPair } from '@qvac/harness/transport';
|
|
10
|
-
export { groupAttachmentsByMessage, replyMessageId, REPLY_MESSAGE_PREFIX } from
|
|
10
|
+
export { groupAttachmentsByMessage, replyMessageId, REPLY_MESSAGE_PREFIX } from './lib/core/files/records/linkage.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CurrentMesh } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
3
|
type AgentCapabilities = Pick<CapabilityHandlers, 'createAgent' | 'listAgents' | 'getAgent' | 'updateAgent' | 'deleteAgent' | 'agentsWatch'>;
|
|
4
|
-
export declare function createAgentsApi(current: CurrentMesh, deviceId: Buffer | null): AgentCapabilities;
|
|
4
|
+
export declare function createAgentsApi(current: CurrentMesh, deviceId: Buffer | null, computeLender?: (() => Promise<Buffer | null>) | null): AgentCapabilities;
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createAgent, deleteAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from
|
|
2
|
-
import { requireMesh } from
|
|
3
|
-
import { watchable } from
|
|
4
|
-
export function createAgentsApi(current, deviceId) {
|
|
1
|
+
import { createAgent, deleteAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from '../core/agent.js';
|
|
2
|
+
import { requireMesh } from './current-mesh.js';
|
|
3
|
+
import { watchable } from './watchable.js';
|
|
4
|
+
export function createAgentsApi(current, deviceId, computeLender = null) {
|
|
5
5
|
const withOrphaned = async (mesh, agent) => ({
|
|
6
6
|
...agent,
|
|
7
7
|
orphaned: await isOrphaned(mesh, agent)
|
|
@@ -18,19 +18,20 @@ export function createAgentsApi(current, deviceId) {
|
|
|
18
18
|
return {
|
|
19
19
|
createAgent: async (input) => {
|
|
20
20
|
const mesh = await requireMesh(current, input.meshId);
|
|
21
|
-
|
|
21
|
+
const lenderDeviceId = input.lenderDeviceId ?? (await computeLender?.()) ?? undefined;
|
|
22
|
+
return withOrphaned(mesh, await createAgent(mesh, { ...input, lenderDeviceId }));
|
|
22
23
|
},
|
|
23
24
|
listAgents: async (request) => list(await requireMesh(current, request?.meshId)),
|
|
24
|
-
getAgent: async ({ id }) => {
|
|
25
|
-
const mesh = await requireMesh(current);
|
|
25
|
+
getAgent: async ({ id, meshId }) => {
|
|
26
|
+
const mesh = await requireMesh(current, meshId);
|
|
26
27
|
return withOrphaned(mesh, await mustGetActiveAgent(mesh, id));
|
|
27
28
|
},
|
|
28
29
|
updateAgent: async (input) => {
|
|
29
30
|
const mesh = await requireMesh(current);
|
|
30
31
|
return withOrphaned(mesh, await updateAgent(mesh, input));
|
|
31
32
|
},
|
|
32
|
-
deleteAgent: async ({ id }) => {
|
|
33
|
-
const mesh = await requireMesh(current);
|
|
33
|
+
deleteAgent: async ({ id, meshId }) => {
|
|
34
|
+
const mesh = await requireMesh(current, meshId);
|
|
34
35
|
return withOrphaned(mesh, await deleteAgent(mesh, deviceId, id));
|
|
35
36
|
},
|
|
36
37
|
agentsWatch: watchable('agentsWatch', (request) => requireMesh(current, request?.meshId), (_request, mesh) => list(mesh))
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { listApprovalRules } from
|
|
2
|
-
import { requireMesh } from
|
|
1
|
+
import { listApprovalRules } from '../core/approval-rules.js';
|
|
2
|
+
import { requireMesh } from './current-mesh.js';
|
|
3
3
|
export function createApprovalRulesApi(current) {
|
|
4
4
|
return {
|
|
5
|
-
listApprovalRules: async () =>
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
listApprovalRules: async (request) => {
|
|
6
|
+
const mesh = await requireMesh(current, request?.meshId);
|
|
7
|
+
return {
|
|
8
|
+
rules: await listApprovalRules(mesh),
|
|
9
|
+
ourMemberId: mesh.ourMemberId ?? undefined
|
|
10
|
+
};
|
|
11
|
+
}
|
|
8
12
|
};
|
|
9
13
|
}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { toAsyncIterable } from '../core/async-iterable.js';
|
|
2
|
+
import { requireMesh } from './current-mesh.js';
|
|
3
|
+
function rejoin(frames, first, rest) {
|
|
4
|
+
const replayed = (async function* () {
|
|
5
|
+
yield first;
|
|
6
|
+
while (true) {
|
|
7
|
+
const next = await rest.next();
|
|
8
|
+
if (next.done)
|
|
9
|
+
return;
|
|
10
|
+
yield next.value;
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
13
|
+
return 'writeStream' in frames
|
|
14
|
+
? Object.assign(replayed, { writeStream: frames.writeStream })
|
|
15
|
+
: replayed;
|
|
16
|
+
}
|
|
17
|
+
export { MAX_ATTACHMENT_BYTES } from '../core/files/attachments.js';
|
|
3
18
|
export function createAttachmentsApi(current, options = {}) {
|
|
4
19
|
return {
|
|
5
20
|
async *uploadAttachment(frames) {
|
|
6
|
-
|
|
21
|
+
const rest = toAsyncIterable(frames)[Symbol.asyncIterator]();
|
|
22
|
+
const first = await rest.next();
|
|
23
|
+
if (first.done)
|
|
24
|
+
return;
|
|
25
|
+
const mesh = await requireMesh(current, first.value.meshId);
|
|
26
|
+
yield* mesh.files
|
|
27
|
+
.attachments(options)
|
|
28
|
+
.uploadAttachment(rejoin(frames, first.value, rest));
|
|
7
29
|
},
|
|
8
30
|
async *downloadAttachment(request) {
|
|
9
31
|
yield* (await requireMesh(current)).files.attachments(options).downloadAttachment(request);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
2
|
import { type CurrentMesh } from './current-mesh.ts';
|
|
3
|
-
type ChatGroupCapabilities = Pick<CapabilityHandlers, 'createChatGroup' | 'listChatGroups' | 'renameChatGroup' | 'deleteChatGroup' | 'setChatGroup' | 'moveChat' | 'moveChatGroup'>;
|
|
3
|
+
type ChatGroupCapabilities = Pick<CapabilityHandlers, 'createChatGroup' | 'listChatGroups' | 'renameChatGroup' | 'deleteChatGroup' | 'setChatGroup' | 'moveChat' | 'moveChatGroup' | 'sortChatGroupsByName'>;
|
|
4
4
|
export declare function createChatGroupsApi(current: CurrentMesh): ChatGroupCapabilities;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createChatGroup, deleteChatGroup, listChatGroups, moveChatGroup, renameChatGroup } from
|
|
2
|
-
import { moveChat, setChatGroup } from
|
|
3
|
-
import { requireMesh } from
|
|
1
|
+
import { createChatGroup, deleteChatGroup, listChatGroups, moveChatGroup, renameChatGroup, sortChatGroupsByName } from '../core/chat-group.js';
|
|
2
|
+
import { moveChat, setChatGroup } from '../core/chat.js';
|
|
3
|
+
import { requireMesh } from './current-mesh.js';
|
|
4
4
|
export function createChatGroupsApi(current) {
|
|
5
5
|
return {
|
|
6
6
|
createChatGroup: async ({ name }) => createChatGroup(await requireMesh(current), { name }),
|
|
@@ -9,6 +9,7 @@ export function createChatGroupsApi(current) {
|
|
|
9
9
|
deleteChatGroup: async ({ id }) => deleteChatGroup(await requireMesh(current), id),
|
|
10
10
|
setChatGroup: async ({ id, groupId }) => setChatGroup(await requireMesh(current), id, groupId),
|
|
11
11
|
moveChat: async ({ id, groupId, afterId }) => moveChat(await requireMesh(current), id, { groupId, afterId }),
|
|
12
|
-
moveChatGroup: async ({ id, afterId }) => moveChatGroup(await requireMesh(current), id, { afterId })
|
|
12
|
+
moveChatGroup: async ({ id, afterId }) => moveChatGroup(await requireMesh(current), id, { afterId }),
|
|
13
|
+
sortChatGroupsByName: async () => sortChatGroupsByName(await requireMesh(current)).then((groups) => ({ groups }))
|
|
13
14
|
};
|
|
14
15
|
}
|