41 Commits
Author SHA1 Message Date
CatoandClaude 234d424707 Files on a message: an attachment policy, read receipts that ignore an assistant, whole-word mentions (#54)
A messenger's costs live in its files, so what may be attached is a rule
this package can answer: checkAttachment (allowlist, a ceiling per kind,
a count per message, a quota per person), the lifetime predicates, and
the Attachment type a Message can carry. Nothing is stored or signed
here.

readState answers none/some/all over the humans a message was for. In
OrangeCat an assistant that had joined a conversation never read
anything, so every later message stayed at delivered.

mentionsAny/mentionMatcher export the whole-word matcher whenMentioned
used, now aware of letters outside ASCII.

mergeMessages, visibleMessages and unreadMessages are generic over the
caller's message type.

Released as 0.1.2: additive, inside every consumer's ^0.1.1 range.


Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:13:19 +01:00
dependabot[bot] 2f5acf54e4 chore(deps-dev): bump the minor-and-patch group with 2 updates (#53)
Bumps the minor-and-patch group with 2 updates: [eslint](https://github.com/eslint/eslint) and [globals](https://github.com/sindresorhus/globals).


Updates `eslint` from 10.13.0 to 10.14.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.13.0...v10.14.0)

Updates `globals` from 17.13.0 to 17.14.0
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v17.13.0...v17.14.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 10.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: globals
  dependency-version: 17.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-07 23:50:32 +01:00
CatoandClaude 5f39ada053 ci(publish): the current Publish workflow, which can make a package's first npm release (#52)
@bitbaum/threadkit is a new npm name; npm trusts a publisher only for an
existing package, so the first version is published with the org token and
tokenless publishing is linked afterwards. The old copy here was OIDC-only and
failed on the merge of the rename (run 42220558994).


Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 13:53:59 +01:00
CatoandClaude cb2a422317 feat: publish as @bitbaum/threadkit (same code, same version) (#51)
Owner, 2026-11-06: the fleet's packages belong under the @bitbaum npm
organization; this one was published earlier, unscoped, and never moved
(fleet docs/package-scope-migration-plan.md). Name, imports in tests, examples
and docs change; no API changes. The old name stays installable and is
deprecated once no adopter uses it.


Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 13:48:59 +01:00
Catoandbitbaum-fleet 7740fc63f0 docs(agents): the org rules block, generated from bitbaum/fleet (#50)
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-11-06 10:16:41 +01:00
dependabot[bot] b586a9ea08 chore(deps-dev): bump the minor-and-patch group with 2 updates (#49)
Bumps the minor-and-patch group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.6.5 to 26.6.6
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `typescript-eslint` from 8.72.0 to 8.72.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.1/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.72.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-31 22:58:32 +01:00
CatoandClaude c039905b28 chore(deps): clear dev-toolchain audit findings inside existing ranges (#48)
pnpm audit critical/high (all deps):
  .: 0/2 -> 0/0


Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 22:26:43 +01:00
Catoandbitbaum-fleet bbb3d6a014 docs(agents): the org rules block, generated from bitbaum/fleet (#47)
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-30 10:39:16 +01:00
Cato 70ffefca62 fix(release): apply verified build-output staging contract (#46) 2026-10-29 01:33:42 +01:00
Cato ca551c205d chore(deps): dependabot leaves TypeScript 7 alone until typescript-eslint supports it (#45) 2026-10-28 03:35:37 +01:00
Catoandbitbaum-fleet 63d6afcfda docs(agents): the org rules block, generated from bitbaum/fleet (#44)
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-28 02:53:42 +01:00
Catoandbitbaum-fleet bfb969cb5b chore: add the fleet package template files this repo is missing (git-release.yml, release-notify.yml, release.yml, AGENTS.md, CLAUDE.md) (#42)
* chore: add the fleet package template files this repo is missing (git-release.yml, release-notify.yml, release.yml, AGENTS.md, CLAUDE.md)

Files from bitbaum/fleet `templates/package` that this repository does not have yet:

- `.github/workflows/git-release.yml`
- `.github/workflows/release-notify.yml`
- `.github/workflows/release.yml`
- `AGENTS.md`
- `CLAUDE.md`

Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.

Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.

* chore: current release.yml template, prettier-stable under this repo's config

---------

Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-28 02:30:17 +01:00
Cato 8d2ef7f9a4 docs: record verified release history and its evidence limits (#43) 2026-10-28 00:21:02 +01:00
dependabot[bot] 90ee7b1fb1 chore(deps-dev): bump the minor-and-patch group with 2 updates (#41)
Bumps the minor-and-patch group with 2 updates: [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `eslint` from 10.12.0 to 10.13.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.12.0...v10.13.0)

Updates `typescript-eslint` from 8.71.2 to 8.72.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 10.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.72.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-24 23:54:58 +02:00
dependabot[bot] 162bf52eca chore(deps-dev): bump the minor-and-patch group with 3 updates (#40)
Bumps the minor-and-patch group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [prettier](https://github.com/prettier/prettier) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.6.4 to 26.6.5
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `prettier` from 3.9.9 to 3.9.10
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.9...3.9.10)

Updates `typescript-eslint` from 8.71.1 to 8.71.2
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.2/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.10
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.71.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-18 01:29:56 +02:00
dependabot[bot] a4a450f3c4 chore(deps-dev): bump the minor-and-patch group with 4 updates (#39)
Bumps the minor-and-patch group with 4 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint), [globals](https://github.com/sindresorhus/globals) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.6.2 to 26.6.4
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.11.0 to 10.12.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.11.0...v10.12.0)

Updates `globals` from 17.12.0 to 17.13.0
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v17.12.0...v17.13.0)

Updates `typescript-eslint` from 8.70.1 to 8.71.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.1/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.12.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: globals
  dependency-version: 17.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.71.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-10 14:25:56 -07:00
dependabot[bot] b4636d5263 chore(deps-dev): bump the minor-and-patch group across 1 directory with 4 updates (#38)
Bumps the minor-and-patch group with 4 updates in the / directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint), [prettier](https://github.com/prettier/prettier) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.5.1 to 26.6.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.10.0 to 10.11.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.10.0...v10.11.0)

Updates `prettier` from 3.9.6 to 3.9.9
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.6...3.9.9)

Updates `typescript-eslint` from 8.70.0 to 8.70.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.70.1/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.11.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.9
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.70.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-08 06:18:42 -07:00
CatoandClaude Opus 5 f7a8c04a27 docs: link back to bitbaum, and to who uses this package (#36)
Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 01:04:12 -07:00
CatoandClaude Fable 5.1 7ccc759bb1 chore: rename FleetCrown to Loki (#35)
The product was renamed on 2026-09-14: bitbaum/loki, loki.orangecat.ch,
LOKI_* env keys, loki-* units. This repo referenced the old name in
1 file changed, 1 insertion(+), 1 deletion(-).
Email addresses at the old sending domain stay until the new domain is
verified in Resend.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:33:19 -07:00
dependabot[bot] 997b65e2e4 chore(deps-dev): bump the minor-and-patch group with 3 updates (#34)
Bumps the minor-and-patch group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.4.1 to 26.5.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.9.1 to 10.10.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.9.1...v10.10.0)

Updates `typescript-eslint` from 8.69.0 to 8.70.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.70.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.5.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.10.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.70.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-12 14:24:13 -07:00
CatoandClaude Fable 5.1 8508451596 ci(publish): make publishing idempotent so a second run is green, not E403 (#33)
One merge starts Publish twice — the PAT-made push and the auto-merge
sweep's workflow_dispatch re-arm, seconds apart. Both ask the registry
before either publishes, both build, and the loser gets E403 "cannot
publish over previously published versions" (bip-kit 0.2.6, 0.2.7 on
2026-09-11). A red run that means nothing is wrong teaches everyone to
ignore the workflow.

- concurrency group "publish", never cancelled: the second run waits,
  then sees the version on the registry and skips
- registry check writes a green step summary ("already published —
  nothing to do") and gates install/verify/publish
- npm publish failure is re-checked against the registry: if the
  version is there, that is the goal state, not an error

OIDC trusted publishing, verify-before-publish, tag checks and the
re-arm list are unchanged.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 18:05:23 -07:00
CatoandClaude Opus 5 31099dcab8 ci(auto-merge): correct the reason this repo passes a PAT (#32)
The comment added a few hours ago says GITHUB_TOKEN cannot merge a PR that
touches .github/workflows. That is contradicted by this fleet's own history:
github-actions[bot] merged datacat#253 and ai-kit#42 today, and both change a
workflow file. I asserted it from the reusable workflow's docstring without
checking, then found the counter-evidence while looking for something else.

Two stalled PRs were offered as proof and neither survives either. ai-kit#11
opened 2026-08-29 and this repo's sweep was not added until 2026-09-04, so for
most of that PR's life nothing was sweeping at all. aoz-housing#122 is still
unexplained — I merged it before diagnosing it, which destroyed the evidence.

The THROUGHPUT reason is unaffected and is why the line stays. A dispatch made
with GITHUB_TOKEN triggers no workflows — the same rule the deploy reconciler
exists for — so after a merge the re-armed CI run's completion fires no
workflow_run and nothing wakes the sweep for the next PR. It waits for the
cron, which GitHub throttles: fleetcrown's sweeps land 50-65 minutes apart
against a */10 schedule. A PAT-created dispatch does emit workflow_run.

The wrong claim is recorded in the file rather than quietly deleted, so the
next reader does not re-derive it from the same docstring I did.

No behaviour change: an undefined secret still resolves to empty and the
reusable workflow still falls back to github.token.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 15:55:02 +00:00
CatoandClaude Opus 5 e59f7a2383 ci(auto-merge): hand the sweep a PAT so workflow PRs stop stalling (#31)
GITHUB_TOKEN cannot merge a PR that touches .github/workflows. The sweep tries,
the merge API refuses, it logs "leaving for the next sweep", and repeats — while
still exiting 0. So the failure is invisible: every run reports success and the
PR simply never merges.

That is not hypothetical. ai-kit #11 (bump actions/checkout) sat green, CLEAN
and MERGEABLE for nine days; aoz-housing #122 (bump actions/upload-artifact)
for nine more. Both had to be merged by hand today. Every Dependabot
`github_actions` bump in the fleet is in this class, permanently.

A PAT fixes a second thing that costs more: THROUGHPUT. A dispatch made with
GITHUB_TOKEN emits no workflow_run, so after each merge nothing wakes the sweep
to take the next PR — it waits for the cron, and GitHub throttles scheduled
workflows to roughly hourly regardless of what the cron says. Observed in
fleetcrown: sweeps ~50-65 minutes apart against a */10 schedule. A PAT-created
dispatch does emit workflow_run, so the queue drains at CI speed instead.

The reusable workflow has always supported this — GH_TOKEN is
`secrets.token || github.token`. This just passes it.

SAFE BEFORE THE SECRET EXISTS: an undefined secret resolves to empty, and the
fallback picks github.token. So this changes nothing until FLEET_PAT is created
as an organisation secret, and needs no second pass afterwards.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 15:09:24 +00:00
dependabot[bot] 6e61fd79c0 chore(deps-dev): bump globals from 15.15.0 to 17.12.0 (#30)
Bumps [globals](https://github.com/sindresorhus/globals) from 15.15.0 to 17.12.0.
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v15.15.0...v17.12.0)

---
updated-dependencies:
- dependency-name: globals
  dependency-version: 17.12.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-05 22:55:06 +00:00
dependabot[bot] a6036b4912 chore(deps-dev): bump the minor-and-patch group with 2 updates (#29)
Bumps the minor-and-patch group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.4.0 to 26.4.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `typescript-eslint` from 8.68.0 to 8.69.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.69.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.4.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.69.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-05 21:24:39 +00:00
90672b2759 chore(ci): add workflow_dispatch so the sweep can re-arm CI on main (#28)
A GITHUB_TOKEN merge fires no push workflows, and without a
workflow_dispatch trigger the auto-merge sweep's re-arm cannot start CI
either — PR #27 merged green but left main's tip with no CI run.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 08:10:25 -07:00
6b9cef3e25 chore(ci): test on Node 24, the fleet toolchain (#27)
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 14:41:13 +00:00
6ac2b19818 chore(ci): adopt the fleet auto-merge sweep — green PRs merge themselves (#26)
This repo had no auto-merge workflow; green PRs waited for a human.
Thin caller of bitbaum/fleet auto-merge-sweep.yml, same as ai-forms.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 09:37:48 -07:00
7d6902454f docs: sync docs with actual stack (#25)
README's install line still said `npm install`; the fleet's one package
manager is pnpm (packageManager: pnpm@11.25.0). Package name `threadkit`
verified live on the npm registry at 0.1.1 — unchanged.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 07:52:00 -07:00
4ee72a7013 chore: pnpm — the fleet has one package manager (#24)
Convert from npm to pnpm (fleet standard, STACK.md):
- packageManager pin pnpm@11.25.0 (corepack SSOT)
- pnpm-lock.yaml via `pnpm import` from package-lock.json (resolutions
  preserved), then package-lock.json deleted
- CI + publish workflows: pnpm/action-setup@v6, cache: pnpm,
  `pnpm install --frozen-lockfile`, `pnpm run verify`
- package.json scripts and contributor docs use pnpm; consumer install
  lines stay npm — consumers choose their own package manager
- npm publish invocation unchanged (works from a pnpm-managed tree)

Clean-room proven: rm -rf node_modules && pnpm install --frozen-lockfile
&& tests green.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-03 08:05:28 -07:00
d6151ddb41 chore(deps): typescript 6 (#23)
TS 7.0.2 exists but typescript-eslint rejects it — canaried and blocked;
revisit when support ships.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 15:36:05 +02:00
65a56148f2 chore(deps): currency sweep — eslint 10, @types/node 26, CI actions v7 (#22)
Bumps (devDependencies):
- eslint ^9.39.5 -> ^10.9.1
- @eslint/js ^9.39.5 -> ^10.0.1
- @types/node ^22.10.2 -> ^26.4.0
- typescript-eslint ^8.67.0 -> ^8.68.0

CI workflows (ci.yml, publish.yml):
- actions/checkout v4 -> v7
- actions/setup-node v4 -> v7

Full verify (format, lint, typecheck, build, 31 tests) green.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 10:52:23 +02:00
GandClaude Opus 5 4bb266ca88 chore: add a formatter (#21)
* chore: add a formatter, matching the style this repo already writes

singleQuote=true was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.

Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* style: format with prettier (12 files)

Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore: teach git blame to skip the reformat

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-31 10:33:02 +02:00
GandClaude Opus 5 714b0da614 chore: declare node >=20, the version the box actually runs (#20)
Was: >=18.

Eighteen of thirty repos declared no Node version at all, and the twelve
that did used five spellings of the same intent - >=18, >=20, >=20.0.0,
>=22, >=22.19.0. The box runs 20.20.2, so >=22 was a claim nothing could
satisfy and nothing would have caught.

One spelling, matching the machine that runs it, turns an invisible
mismatch into a loud one.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 09:07:17 +02:00
GandClaude Opus 5 dbc607d7d8 chore: add a dependency watcher (#12)
23 of 30 repos in the fleet had none. The symptom looks like neglect and
is not: aoz-housing had 100 commits in August, features landing daily, and
was still on Next 14 / React 18 / Tailwind 3 — because nothing ever OPENED
the upgrade PR. Version drift here is the absence of a mechanism.

npm directory: /. Minor and patch grouped so the sweep spends one
cycle on them; majors stay separate because they deserve reading.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 08:26:11 +02:00
GandClaude Opus 5 f0fd2d12c6 chore: retire the maonakamoto handle (#11)
The account was renamed to `catomean` and the repos then moved to the
`bitbaum` org, so `maonakamoto` now names nothing: github.com/maonakamoto
and maonakamoto.github.io both return 404, and @maonakamoto no longer
resolves as a user.

Three different targets, because these are not the same reference:
  repo links  -> bitbaum/<repo>   (the repos live in the org)
  the person  -> catomean        (profile links, @mentions, CODEOWNERS)
  pages site  -> bitbaum.github.io

Deliberately NOT changed:
  .mailmap keeps the old noreply address as an ALIAS. It is what maps
  historical commits onto the current identity; deleting it would
  silently unmap them. Only the canonical side moved to catomean.
  Files that explain the outage by naming the old account keep it,
  since the name is the content.

Files: package.json


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 10:26:25 +02:00
GandClaude Fable 5 b53fbf0e15 chore(ci): drop token-health — there is no token left to watch (#10)
Publishing is trusted publishing (OIDC) since #9; the NPM_TOKEN secret is
being deleted. Without this, the weekly probe would fail on the missing
secret and open a false "releases are blocked" issue.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 01:32:22 +02:00
GandClaude Fable 5 047dc691e2 chore(release): 0.1.1 — reconcile releases, publish via trusted publishing (#9)
Ports ai-forms' publish reconciler: merging a version bump to main is the
whole release. The workflow (on push, hourly, or by hand) asks the registry
whether package.json's version exists and publishes it if not — idempotent,
and immune to the tag-pushed-by-GITHUB_TOKEN trigger gap.

Auth is OIDC via the package's Trusted Publisher (this repo + publish.yml),
so no npm token exists to leak or expire. The bump to 0.1.1 makes the merge
itself prove the tokenless path live.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 01:25:50 +02:00
6b24a59011 chore: ignore per-session worktrees (#2)
A worktree under .claude/ is a full copy of the repo, dist/ included.
Left untracked it gets picked up as source — in ai-forms an identical
setup made the lint gate report 10 errors that were all in a stale
worktree, and blocked a release for reasons that had nothing to do with
the code being released.

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 01:03:49 +02:00
GandClaude Opus 5 743c8f62dd ci: make the release a reconciler, not a trigger (#8)
Mirrors ai-forms#17, where this was not theoretical: that repo's merge to main
started no publish run, because auto-merge merges with GITHUB_TOKEN and a push
with that token starts no workflow. The identical change fired here only
because I merged this repo's PR by hand with a user token.

threadkit has no auto-merge today, which is exactly why the schedule belongs
here now — rather than being added after auto-merge arrives and a release
quietly goes missing.

The question the workflow asks — "is package.json's version on the registry?" —
is idempotent, so asking it hourly costs one `npm view` when there is nothing to
do and repairs a missed release when there is.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 20:19:13 +02:00
GandClaude Opus 5 a6687547b6 ci: release without anyone running a release (#7)
Mirrors ai-forms#16 so both libraries release identically.

Cutting a release meant `npm version && git push --tags` by hand. Now merging a
version bump to main ships the package: the workflow asks the registry whether
package.json's version already exists and publishes it if not.

That check rather than a tag trigger, because a tag pushed by GITHUB_TOKEN does
not start another workflow — "push a tag, let publish.yml notice" silently never
runs — and because asking npm what is published is idempotent, so a re-run or a
hand-pushed tag cannot double-publish. The tag is created after a successful
publish, so it never claims a release that did not happen.

NPM_TOKEN expires 2026-11-14. token-health.yml probes `npm whoami` weekly and
opens a single issue when it fails, with the fix in it — rather than letting a
release three months from now be the thing that discovers the expiry, reported
as a 403 that reads like a permissions problem.

Verified: both files parse, and the registry check answers correctly against the
real registry for threadkit@0.1.0 (already published → skip).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 18:26:35 +02:00
35 changed files with 2526 additions and 1667 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Bulk reformats. `git config blame.ignoreRevsFile .git-blame-ignore-revs`
6e12c84d059bb4f261a25a27a57c44e58f658bca # prettier, 12 files
+32
View File
@@ -0,0 +1,32 @@
# Dependency updates, weekly.
#
# Added 2026-08-29 after a fleet audit found 23 of 30 repos had no watcher at
# all. The symptom looked like neglect and was not: aoz-housing had 100 commits
# that month and was still on Next 14, because nothing ever opened the PR.
# Drift here is the absence of a mechanism, not the absence of attention.
#
# Minor and patch are grouped into one PR so the auto-merge sweep spends one
# cycle on them instead of five; majors stay separate because they deserve to
# be read.
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 5
ignore:
# typescript-eslint does not support TypeScript 7 yet (CI: "typescript-eslint
# does not support TS 7.0"), so every dev-dependency PR that carries it is red.
# Take it when typescript-eslint does.
- dependency-name: typescript
update-types: ['version-update:semver-major']
groups:
minor-and-patch:
update-types: [minor, patch]
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 3
+60
View File
@@ -0,0 +1,60 @@
# Auto-merge — nobody is in the merge loop.
#
# Green, ready PRs merge themselves. The policy lives in ONE place for the
# whole fleet — bitbaum/fleet, scripts/ci/auto-merge-sweep.sh — and this file
# only says "run it, with these settings". Added 2026-09-04: this repo had NO
# auto-merge at all, so green PRs sat until a human merged them by hand —
# the docs truth-sweep found five lib repos in that state.
#
# The triggers stay here because they are genuinely per-repo: workflow_run
# must name the CI workflow exactly.
#
# To stop all of this: delete this file, or add a `hold` label to a PR.
name: Auto-merge
on:
workflow_run:
workflows: ['CI']
types: [completed]
schedule:
- cron: '*/10 * * * *'
workflow_dispatch: {}
# Declared on the CALLER as well as inside the reusable workflow: a called
# workflow's token is capped by what the caller grants.
permissions:
contents: write # merge the PR
pull-requests: write # read PR state, delete the branch
actions: write # dispatch the re-arm workflows
checks: read # statusCheckRollup — only load-bearing on private repos
statuses: read
jobs:
sweep:
uses: bitbaum/fleet/.github/workflows/auto-merge-sweep.yml@main
with:
base_branch: main
ci_workflow: ci.yml
# SPACE-separated: the sweep word-splits this.
rearm_workflows: 'ci.yml publish.yml'
secrets:
# Why a PAT and not the default token: THROUGHPUT.
#
# A dispatch made with GITHUB_TOKEN triggers no workflows — the same rule
# that makes the deploy reconciler necessary. So after the sweep merges a
# PR and re-arms CI, that CI run's completion fires no workflow_run, and
# nothing wakes the sweep to take the next PR. It waits for the cron, and
# GitHub throttles scheduled workflows regardless of what the cron says:
# measured in loki, sweeps land 50-65 minutes apart against */10.
# A PAT-created dispatch does emit workflow_run, so a queue drains at CI
# speed instead.
#
# NOT the reason, though an earlier version of this comment said so:
# "GITHUB_TOKEN cannot merge a PR touching .github/workflows". That is
# contradicted here — github-actions[bot] merged datacat#253 and
# ai-kit#42, both of which change a workflow file. Recorded so the wrong
# reason does not get re-derived from this file.
#
# Undefined resolves to empty and the reusable workflow falls back to
# github.token, so this line is inert until the org secret exists.
token: ${{ secrets.FLEET_PAT }}
+13 -5
View File
@@ -5,15 +5,23 @@ on:
branches: [main]
pull_request:
branches: [main]
# Lets the auto-merge sweep re-arm CI after a GITHUB_TOKEN merge (which
# fires no push workflows) — without this, merged commits strand with no
# CI run on main.
workflow_dispatch:
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v7
# pnpm version comes from "packageManager" in package.json (SSOT);
# pnpm/action-setup@v6 errors if both are specified.
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: '22'
- run: npm ci --ignore-scripts
node-version: '24'
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
# build + the full test suite, identical to what runs locally
- run: npm run verify
- run: pnpm run verify
+45
View File
@@ -0,0 +1,45 @@
name: Verified Git release
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
permissions:
contents: write
concurrency:
group: verified-git-release
cancel-in-progress: false
jobs:
release:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.event != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Tag the verified immutable artifact, even before npm bootstrap
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERIFIED_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
set -euo pipefail
version=$(node -p "require('./package.json').version")
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Only stable package versions get a Git release" >&2
exit 1
fi
tag="v$version"
if git show-ref --verify --quiet "refs/tags/$tag"; then
echo "$tag already exists; immutable tags are never moved."
exit 0
fi
git tag "$tag" "$VERIFIED_SHA"
git push origin "refs/tags/$tag"
gh release create "$tag" --repo "$GITHUB_REPOSITORY" \
--verify-tag --title "$tag" --generate-notes
+211 -27
View File
@@ -1,35 +1,146 @@
# prettier-ignore
name: Publish
# Publishing is driven by a version tag, so the released artifact is always
# traceable to a commit. `npm version` creates the tag; pushing it ships.
# The same file in every @bitbaum package. A merged version bump releases
# itself; so does a pushed v* tag, and "Run workflow" re-tries by hand.
#
# Two ways to npm, picked per run:
#
# - The package is already on npm → tokenless. npmjs.com trusts exactly THIS
# workflow in THIS repo (Trusted Publishing, OIDC): no token exists, nothing
# to leak or rotate, and every release carries a signed provenance statement.
#
# - The package is NOT on npm yet → npm will not trust a publisher for a
# package that does not exist, so the first version needs the account once.
# Put a short-lived npm token in the org secret NPM_BOOTSTRAP_TOKEN (made on
# npmjs.com from a phone; see docs in bitbaum/fleet) and this job publishes
# the first version with it. Without the token it skips GREEN and says so, so
# a new package never paints CI red.
# NOTE (npm docs, `npm trust`): trust commands do NOT accept a granular token,
# not even one with "bypass 2FA" — they need the account's interactive 2FA.
# So the auto-link step below is best-effort and is EXPECTED to fall through
# to the printed fallback. The human step is then ONE form per package on
# npmjs.com (repo + "publish.yml"), or one local `npm trust` loop
# (bootstrap-local.sh, step 2). After that, every release is tokenless.
#
# Publishing is idempotent: a version already on the registry is a green
# no-op, so re-runs and repeat merges are harmless.
on:
push:
tags: ['v*']
tags: ["v*"]
branches: [main]
# The auto-merge sweep re-arms this after a GITHUB_TOKEN merge, which
# starts no push workflow on its own (rearm_workflows in auto-merge.yml).
workflow_dispatch:
inputs:
diagnose_auth:
description: Test the npm trusted-publisher link without publishing anything.
type: boolean
default: false
# Never two at once, never cancelled: a cancelled publish is a half-shipped
# release.
concurrency:
group: publish
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
# Required for npm provenance — proves on the registry that this tarball
# was built by this workflow from this commit.
# write: tag the released commit v<version> when the release came from
# main rather than from a pushed tag.
contents: write
# Required for OIDC publishing and npm provenance.
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# npm >= 11.5.1 is required for trusted publishing (OIDC); Node 24 ships it.
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@v7
- run: npm ci --ignore-scripts
# pnpm version comes from "packageManager" in package.json (SSOT).
- uses: pnpm/action-setup@v6
# No registry-url: setup-node would write an _authToken line that makes
# npm skip the OIDC exchange whenever no token is set.
- uses: actions/setup-node@v7
with:
node-version: "24"
# Trusted publishing and `npm trust` need npm >= 11.10; do not trust
# whatever the runner's Node happens to bundle.
- run: npm install -g npm@11
# "Run workflow" with diagnose_auth ticked asks npm whether it trusts
# THIS workflow for this package, and publishes nothing. HTTP 200 =
# linked; 404 = the one form on npmjs.com is still to be filled in. The
# response body holds a short-lived token, so it is never printed.
- name: Is the npm trusted publisher linked? (no publish)
if: inputs.diagnose_auth == true
run: |
node --input-type=module <<'NODE'
const url = new URL(process.env.ACTIONS_ID_TOKEN_REQUEST_URL);
url.searchParams.set('audience', 'npm:registry.npmjs.org');
const identity = await fetch(url, {
headers: { authorization: `Bearer ${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}` },
signal: AbortSignal.timeout(30000),
});
if (!identity.ok) throw new Error(`GitHub OIDC request failed: HTTP ${identity.status}`);
const { value: jwt } = await identity.json();
const claims = JSON.parse(Buffer.from(jwt.split('.')[1], 'base64url'));
console.log('Publisher identity:', JSON.stringify({ repository: claims.repository, workflow_ref: claims.workflow_ref, ref: claims.ref }));
const name = JSON.parse(await (await import('node:fs/promises')).readFile('package.json', 'utf8')).name;
const exchange = await fetch(`https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/${encodeURIComponent(name)}`, {
method: 'POST', headers: { authorization: `Bearer ${jwt}` },
signal: AbortSignal.timeout(30000),
});
console.log(`npm trust exchange for ${name}: HTTP ${exchange.status}`);
await exchange.body?.cancel();
if (!exchange.ok) throw new Error('npm does not trust this workflow for this package yet');
NODE
- name: What does npm have?
id: check
if: inputs.diagnose_auth != true
env:
BOOTSTRAP: ${{ secrets.NPM_BOOTSTRAP_TOKEN != '' }}
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
echo "name=$name" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
if npm view "$name@$version" version >/dev/null 2>&1; then
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "✅ \`$name@$version\` is already on npm — nothing to do." >> "$GITHUB_STEP_SUMMARY"
elif npm view "$name" version >/dev/null 2>&1; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "mode=oidc" >> "$GITHUB_OUTPUT"
elif [ "$BOOTSTRAP" = "true" ]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "mode=first" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
{
echo "⏸ \`$name\` is not on npm yet, and its first version needs the account once."
echo "Add the org secret NPM_BOOTSTRAP_TOKEN (a short-lived npm token) and run this workflow again."
echo "Meanwhile it installs from GitHub: \`pnpm add github:${GITHUB_REPOSITORY}\`"
} >> "$GITHUB_STEP_SUMMARY"
fi
- if: steps.check.outputs.publish == 'true'
run: pnpm install --frozen-lockfile --ignore-scripts
# verify includes the real-browser test (test/browser.mjs) where a
# package has one; without the browser it fails before reaching npm.
- if: steps.check.outputs.publish == 'true' && hashFiles('test/browser.mjs') != ''
run: pnpm exec playwright install --with-deps chromium
# Never publish something that would not have passed CI.
- run: npm run verify
- if: steps.check.outputs.publish == 'true'
run: pnpm run verify
# Refuse to publish a tag whose version does not match package.json,
# rather than silently shipping the wrong number.
- name: Check tag matches package version
if: steps.check.outputs.publish == 'true' && github.ref_type == 'tag'
run: |
tag="${GITHUB_REF_NAME#v}"
pkg=$(node -p "require('./package.json').version")
@@ -38,17 +149,90 @@ jobs:
exit 1
fi
# OIDC (id-token above) is the preferred credential and needs no secret.
# But trusted publishing is configured per package on npmjs.com, and a
# package that has never been published cannot have it configured — so
# OIDC alone cannot do the FIRST publish. Confirmed on ai-forms: the
# provenance statement was signed and logged to sigstore, then the PUT
# returned E404 "could not be found or you do not have permission",
# which reads like a missing package rather than a missing credential.
#
# NPM_TOKEN covers only that first publish. Once this package exists and
# a trusted publisher is configured, npm prefers OIDC and the secret can
# be deleted.
- run: npm publish
- name: Publish to npm
if: steps.check.outputs.publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NAME: ${{ steps.check.outputs.name }}
VERSION: ${{ steps.check.outputs.version }}
MODE: ${{ steps.check.outputs.mode }}
FIRST_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }}
run: |
if [ "$MODE" = "first" ]; then
# The one token-based publish in a package's life.
echo "//registry.npmjs.org/:_authToken=${FIRST_TOKEN}" > "$RUNNER_TEMP/.npmrc"
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/.npmrc"
fi
if npm publish --access public --provenance; then
echo "🚀 Published \`$NAME@$VERSION\`." >> "$GITHUB_STEP_SUMMARY"
elif npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
# Another run slipped in between the check and this publish: the
# version is on the registry, which is the goal state.
echo "✅ \`$NAME@$VERSION\` was published by a concurrent run." >> "$GITHUB_STEP_SUMMARY"
else
exit 1
fi
if [ "$MODE" = "first" ]; then
# From now on this workflow publishes without any token.
if npm trust github "$NAME" --file publish.yml --repo "$GITHUB_REPOSITORY" --allow-publish --yes; then
echo "🔗 Linked \`$NAME\` to this workflow — later releases need no token." >> "$GITHUB_STEP_SUMMARY"
else
{
echo "⚠️ Published. npm does not let a token link the workflow (expected)."
echo "Link it once on https://www.npmjs.com/package/$NAME/access → Trusted Publisher → GitHub Actions:"
echo "repository \`$GITHUB_REPOSITORY\`, workflow \`publish.yml\`, tick *Allow npm publish*."
} >> "$GITHUB_STEP_SUMMARY"
fi
fi
rm -f "$RUNNER_TEMP/.npmrc"
- name: Wait for published registry metadata
if: steps.check.outputs.publish == 'true'
env:
NAME: ${{ steps.check.outputs.name }}
VERSION: ${{ steps.check.outputs.version }}
run: |
# npm accepts a release before its public metadata is readable. Keep
# this serialized job open until read-back succeeds, so the tag/main
# duplicate cannot try publishing a version still being processed.
node --input-type=module <<'NODE'
const { NAME: name, VERSION: version } = process.env;
const url = `https://registry.npmjs.org/${encodeURIComponent(name)}`;
let ready = false;
for (let attempt = 0; attempt < 60; attempt++) {
try {
const response = await fetch(url, {
headers: { 'cache-control': 'no-cache' },
signal: AbortSignal.timeout(10000),
});
if (response.ok) {
const metadata = await response.json();
const record = metadata.versions?.[version];
ready = record?.name === name && record.version === version &&
Boolean(record.dist?.integrity && record.dist?.tarball);
if (ready) break;
}
} catch {
// Network errors and temporarily incomplete metadata can settle.
}
if (attempt < 59) {
console.log(`Waiting for ${name}@${version} registry read-back (${attempt + 1}/60)`);
await new Promise(resolve => setTimeout(resolve, 10000));
}
}
if (!ready) throw new Error(`Publication accepted, but ${name}@${version} registry read-back did not become ready`);
console.log(`Verified registry metadata and artifact coordinates for ${name}@${version}`);
NODE
# A release from main gets its tag here, so every published version is
# still traceable to a commit by name.
- name: Tag the released commit
if: steps.check.outputs.publish == 'true' && github.ref_type != 'tag'
env:
VERSION: ${{ steps.check.outputs.version }}
run: |
if git ls-remote --exit-code --tags origin "refs/tags/v$VERSION" >/dev/null; then
echo "→ v$VERSION already tagged."
else
git tag "v$VERSION" "$GITHUB_SHA"
git push origin "v$VERSION"
fi
+55
View File
@@ -0,0 +1,55 @@
# A release is useful only when the registry and consumers learn about it.
# No checkout or execution of the completed workflow's code: metadata only.
name: Notify Fleet of verified release
on:
workflow_run:
workflows: [CI, Release, Publish]
types: [completed]
permissions:
contents: read
actions: read
concurrency:
group: release-notify
cancel-in-progress: false
jobs:
notify:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'pull_request' && github.event.workflow_run.head_repository.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Resolve a verified immutable release before requesting reconciliation
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.event.workflow_run.head_sha }}
FLEET_TOKEN: ${{ secrets.FLEET_PAT }}
shell: bash
run: |
set -euo pipefail
manifest="$(gh api "repos/$GH_REPO/contents/package.json?ref=$SHA" --jq .content | base64 --decode)"
version="$(jq -r .version <<< "$manifest")"
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo 'No stable version; no reconciliation requested.'
exit 0
fi
# Source commits with no matching release tag are not releases.
if ! tagged="$(gh api "repos/$GH_REPO/commits/v$version" --jq .sha 2>/dev/null)" || [ "$tagged" != "$SHA" ]; then
echo 'This commit is not the versioned release; no reconciliation requested.'
exit 0
fi
ci="$(gh api "repos/$GH_REPO/actions/runs?head_sha=$SHA&per_page=100" --jq '[.workflow_runs[] | select(.path == ".github/workflows/ci.yml" and (.event == "push" or .event == "workflow_dispatch"))] | first | .conclusion')"
if [ "$ci" != success ]; then
echo 'Release CI is not successful yet; its completion will retry notification.'
exit 0
fi
if [ -z "$FLEET_TOKEN" ]; then
echo '::error::FLEET_PAT is required to notify Fleet; scheduled reconciliation remains the fallback.'
exit 1
fi
payload="$(jq -n --arg repository "$GH_REPO" --arg version "$version" --arg commit "$SHA" '{event_type:"shared-package-release",client_payload:{repository:$repository,version:$version,commit:$commit}}')"
GH_TOKEN="$FLEET_TOKEN" gh api --method POST repos/bitbaum/fleet/dispatches --input - <<< "$payload"
echo "Requested authoritative registry and consumer reconciliation for $GH_REPO v$version ($SHA)." >> "$GITHUB_STEP_SUMMARY"
+218
View File
@@ -0,0 +1,218 @@
# Release — a new version of this package, from one button.
#
# Rendered from bitbaum/fleet templates/package. Loki's package page starts it
# ("Release vX.Y.Z"), and so can anyone from the Actions tab. It:
#
# 1. refuses unless main's CI is green on the exact commit it starts from,
# 2. raises the version in package.json (the bump, or the exact version
# asked for) — `npm version --no-git-tag-version`, so npm makes no commit
# and no tag of its own,
# 3. runs the package's own `verify`, which rebuilds the configured package outputs,
# 4. commits "release vX.Y.Z" with tracked build output, tags vX.Y.Z, and pushes
# both in one atomic push,
# 5. creates a GitHub release with generated notes.
#
# Consumers pick the tag up through Dependabot (`github:bitbaum/{{name}}#vX.Y.Z`),
# and publish.yml ships it to npm once npm publishing is switched on.
#
# WHY THE PUSH USES FLEET_PAT. A push made with GITHUB_TOKEN starts no workflow.
# publish.yml listens for the tag push, and CI must run on the release commit
# (the auto-merge sweep merges nothing onto a main whose CI it cannot see). So
# the release commit and tag are pushed with FLEET_PAT, the org secret every
# bitbaum repo already has (auto-merge.yml passes it to the sweep), and both
# workflows fire exactly as they would for a person's push. Calling publish.yml
# from here instead was the other option and is not the honest one: package
# repos keep the publish.yml they were created with (the template sync adds
# missing files and never rewrites one), so the tag push is the only path every
# repo's publish.yml is guaranteed to answer. No FLEET_PAT → no release, said
# plainly, rather than a tag that silently publishes nothing.
#
# If main is ever protected against direct pushes, FLEET_PAT's identity must be
# allowed to bypass it, or this fails at the push — after verify, before any
# tag exists, so nothing half-ships.
# prettier-ignore
name: Release
run-name: Release ${{ inputs.version != '' && format('v{0}', inputs.version) || inputs.bump }}
on:
workflow_dispatch:
inputs:
bump:
description: Which part of the version to raise (ignored when an exact version is given)
type: choice
options: [patch, minor, major]
default: patch
version:
description: Exact version to release, e.g. 0.3.0 (optional — wins over bump)
type: string
required: false
default: ""
# One release at a time, never cancelled: a cancelled release is a commit
# without its tag, or a tag without its notes.
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write # the GitHub release (the push itself uses FLEET_PAT)
actions: read # main's CI runs
checks: read
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Only from main
run: |
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "::error::A release starts from main, not $GITHUB_REF."
exit 1
fi
- name: FLEET_PAT is available
env:
PAT: ${{ secrets.FLEET_PAT }}
run: |
if [ -z "$PAT" ]; then
echo "::error::FLEET_PAT is not available to this repo. A tag pushed without it starts no workflow, so publish.yml would never run — refusing instead."
exit 1
fi
# The commit this run would release is github.sha: main's head when the
# run was started. Its CI must have FINISHED green — running is not green,
# and no run at all is not green either.
- name: Main's CI is green on this commit
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.sha }}
run: |
set -euo pipefail
run="$(gh run list --workflow ci.yml --branch main --commit "$SHA" --limit 1 \
--json status,conclusion,url --jq '.[0] // empty')"
if [ -z "$run" ]; then
echo "::error::CI has not run on main at ${SHA:0:7}. Nothing proves this commit works, so it is not released."
exit 1
fi
status="$(jq -r .status <<<"$run")"
conclusion="$(jq -r .conclusion <<<"$run")"
url="$(jq -r .url <<<"$run")"
if [ "$status" != "completed" ]; then
echo "::error::CI is still running on ${SHA:0:7} ($url). Start the release again when it finishes."
exit 1
fi
if [ "$conclusion" != "success" ]; then
echo "::error::CI on ${SHA:0:7} ended '$conclusion' ($url). Fix main first; a red commit is not released."
exit 1
fi
echo "CI on ${SHA:0:7} is green: $url"
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
token: ${{ secrets.FLEET_PAT }}
fetch-depth: 0
fetch-tags: true
# pnpm version comes from "packageManager" in package.json (SSOT).
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: "24"
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Install Chromium when the package uses Playwright
run: |
if node -e 'const p = require("./package.json"); const d = { ...p.dependencies, ...p.devDependencies }; process.exit(d.playwright || d["@playwright/test"] ? 0 : 1)'; then
pnpm exec playwright install --with-deps chromium
fi
# Inputs reach the shell as environment variables, never pasted into the
# script: a `version` is free text typed by whoever started the run.
- name: Decide the version
id: version
env:
BUMP: ${{ inputs.bump }}
EXACT: ${{ inputs.version }}
run: |
set -euo pipefail
next="$(node -e '
const cur = require("./package.json").version;
const bump = process.env.BUMP, exact = process.env.EXACT.trim().replace(/^v/, "");
const parse = (v) => /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(v)?.slice(1).map(Number);
const c = parse(cur);
if (!c) { console.error(`package.json version "${cur}" is not x.y.z`); process.exit(1); }
let n;
if (exact) {
n = parse(exact);
if (!n) { console.error(`"${exact}" is not a version like 0.3.0`); process.exit(1); }
} else if (bump === "major") n = [c[0] + 1, 0, 0];
else if (bump === "minor") n = [c[0], c[1] + 1, 0];
else if (bump === "patch") n = [c[0], c[1], c[2] + 1];
else { console.error(`bump must be patch, minor or major, not "${bump}"`); process.exit(1); }
const cmp = n[0] - c[0] || n[1] - c[1] || n[2] - c[2];
if (cmp <= 0) { console.error(`${n.join(".")} is not newer than ${cur}`); process.exit(1); }
console.log(n.join("."));
')"
if git rev-parse -q --verify "refs/tags/v$next" >/dev/null \
|| [ -n "$(git ls-remote --tags origin "refs/tags/v$next")" ]; then
echo "::error::v$next is already tagged. Nothing to do — Loki shows it on the next read."
exit 1
fi
echo "next=$next" >> "$GITHUB_OUTPUT"
echo "Releasing v$next (package.json was $(node -p 'require("./package.json").version'))."
- name: Raise the version
env:
NEXT: ${{ steps.version.outputs.next }}
run: npm version "$NEXT" --no-git-tag-version
# The package's own gate. Stage tracked build output only; packages
# with ignored output rebuild it during verified publication.
- run: pnpm run verify
- name: Commit, tag and push
env:
NEXT: ${{ steps.version.outputs.next }}
run: |
set -euo pipefail
# Only the version and the build it implies may change. Anything else
# means verify rewrote source, and that is a change to review, not to
# release.
stray="$(git status --porcelain --untracked-files=all | awk '{print $2}' | grep -v -E '^(package\.json|dist/)' || true)"
if [ -n "$stray" ]; then
echo "::error::verify changed files outside package.json and dist/: $stray"
exit 1
fi
git config user.name "bitbaum-fleet"
git config user.email "fleet@bitbaum.invalid"
git add package.json
# Update tracked build output, but respect packages that ignore dist.
git ls-files -z -- dist | xargs -0 -r git add -u --
if [ -d dist ] && ! git check-ignore --no-index -q dist; then
git add -- dist
fi
git commit -q -m "release v$NEXT"
git tag -a "v$NEXT" -m "v$NEXT"
# Atomic: the commit and the tag land together or not at all. A main
# that moved since this run started refuses the push (not a fast
# forward), and the release is simply started again.
git push --atomic origin "HEAD:refs/heads/main" "refs/tags/v$NEXT"
- name: GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
NEXT: ${{ steps.version.outputs.next }}
run: |
set -euo pipefail
gh release create "v$NEXT" --verify-tag --title "v$NEXT" --generate-notes
{
echo "## Released v$NEXT"
echo
echo "Install: \`github:$GITHUB_REPOSITORY#v$NEXT\`. Dependabot proposes it to every project that uses this package."
} >> "$GITHUB_STEP_SUMMARY"
+3
View File
@@ -1,3 +1,6 @@
node_modules/
dist/
*.tgz
# Per-session git worktrees. Never lint, test, or publish from these — a stale
# copy of the repo here is otherwise picked up as if it were source.
.claude/
+31
View File
@@ -0,0 +1,31 @@
# Build output and vendored trees — formatting these is noise.
node_modules
.next
dist
build
out
coverage
.turbo
.vercel
*.min.js
*.min.css
# Generated during a build, so it is absent locally and present in CI — which
# makes a clean local --check no evidence at all. Contentlayer's output also
# uses import assertions, which prettier's parser rejects outright.
.contentlayer
.astro
.svelte-kit
storybook-static
test-results
playwright-report
# Lockfiles are generated; prettier would rewrite them wholesale.
package-lock.json
pnpm-lock.yaml
yarn.lock
# Markdown is deliberately out of scope for now. Prettier rewraps prose, which
# is where it is most opinionated and least useful, and it would bury the real
# diff. Remove this line when you want docs formatted too.
*.md
+9
View File
@@ -0,0 +1,9 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "all",
"arrowParens": "always",
"endOfLine": "lf"
}
+63
View File
@@ -0,0 +1,63 @@
# Agents
<!-- fleet:rules:begin — generated from bitbaum/fleet templates/agent-rules.md; edit it there, not here -->
## Org rules
Read `bitbaum/fleet` `AGENTS.md`, `SHARED.md` and the registers it names before
inventing a host, a name, a page or a shared behaviour. Do not copy their facts
into this file.
- **Packages first.** If a `@bitbaum/*` package (or `bip-kit`, `limitkit`,
`threadkit`, `ai-forms`) already does it, use it and fix a defect in the
package, not in this app. Every chat is `@bitbaum/chatkit`, every search box
`@bitbaum/searchkit`, every chart `@bitbaum/chartkit`, accounts
`@bitbaum/accountkit`, model calls `@bitbaum/ai-kit`. Review this product's
`package-plan.json` before building anything. When a second product needs
what one product built (a map, a globe, a calculator), extract it into a
package before writing the second copy.
- **The experience belongs to the package.** Anywhere a person types words
there is a microphone (`@bitbaum/chatkit`: `Composer`, `DictationField`);
articles are `@bitbaum/writingkit/react`, comments are chatkit's
`CommentThread`, header, menu, tab bar and footer are `@bitbaum/sitekit`.
Apps own brand, words and backend, not the behaviour or the layout. If a
component cannot do what the product needs, extend the package in the same
session (fleet `AGENTS.md`, "The experience belongs to the package").
- **A gap is a task, not an answer.** Never end the work, or a reply, at "not
supported" or "not available". When a source cannot be read or a case does
not fit the model, find another way (another format or publisher, the
official tool measured, the model extended) and do it. What truly cannot be
done yet is tracked with its plan, never presented as a limit of the product.
- **Every page leads to an action.** What a reader learns, they can act on
from the same screen: file, pay, apply, compare, ask, contact.
- **One shape per kind.** Things of the same kind look the same and sit in the
same place (fleet `AGENTS.md`, "One shape per kind").
- **Finished work ships by itself.** Open a non-draft pull request; the fleet
auto-merge sweep is the only merge path. Never merge by hand, through the
merge API, with `--auto` or with an admin bypass, and never force-push a
shared branch.
- **Nothing made up.** A fact on a page or in a doc needs a source that was
opened; where there is none, the line is removed or softened. A gap is
filled with sourced data, never with a guess.
- **Bitcoin orange is for Bitcoin and top-of-funnel actions only.**
- **No model identifier** in anything pushed to a repository.
- Before you finish, run `node <fleet>/scripts/ci/docs-truth-audit.mjs --dir .`:
the same check the sweep runs on every pull request.
<!-- fleet:rules:end -->
Read `bitbaum/fleet` `AGENTS.md` and `SHARED.md` for shared-package ownership,
release and merge policy. Repository-specific instructions belong below.
This repository owns a reusable package. Fix shared defects here, verify the
package's public exports and affected consumer behavior, release through its
verified release workflow, then update consumers. Preserve product-specific
roles, tenancy, provider configuration and domain behavior in app adapters.
Before adding another implementation, inspect Fleet's package registry for an
existing owner. Shared authentication belongs to `@bitbaum/accountkit`, chat
behavior to `@bitbaum/chatkit`, and model/provider transport to `@bitbaum/ai-kit`.
Read `package.json` for this package's verification command and run it before
publishing changes. Use Fleet's auto-merge sweep; do not bypass its required
checks or rollout holds with manual merging or built-in `--auto`.
+30
View File
@@ -0,0 +1,30 @@
# Changelog
## 0.1.2 — Files on a message, read receipts with an assistant in the room
Additive: nothing that compiled against 0.1.1 changes.
- **Attachments.** `Message.attachments` (an `Attachment`: kind, name, type, bytes, and pixels or duration where it has them) and the policy that decides what may be attached: `checkAttachment` answers with the kind or with the reason and its number (`type`, `size`, `count`, `quota`, `empty`). The policy is an allowlist; a type it does not name is refused, and `image/svg+xml` and `text/html` are left out of the default because both can carry script. `attachmentExpiresAt`, `isAttachmentExpired` and `isAbandonedUpload` are the lifetime rules, `storedBytes` is what a quota counts. The package still stores and signs nothing.
- **`readState(thread, message)`**: `none`, `some` or `all`, over the humans the message was for. Found in OrangeCat, 2026-11-12: once its assistant had answered in a conversation it stayed as a participant, never "read" anything, and every later message was stuck at delivered, because the receipt waited for a reader that does not read.
- **`mentionsAny` / `mentionMatcher`**: the whole-word matcher `whenMentioned` already used, exported so an interface and a server share one definition. It now treats letters outside ASCII as letters (`aiü` no longer matches the alias `ai`).
- **Your own message type comes back.** `mergeMessages`, `visibleMessages` and `unreadMessages` are generic over the message, so rows that carry more than this package knows (a sender's name, an edited-at) no longer have to be looked up again by id after a merge.
## Renamed — `threadkit` is now `@bitbaum/threadkit`
Same code, same version, same repository; the package now lives under the
`@bitbaum` npm organization like the rest of the fleet's packages. Install
`@bitbaum/threadkit` and import from it (`threadkit` stays installable and is deprecated
once no adopter uses it). No API changed.
This retrospective record was added on 2026-10-27 from the immutable sources
linked below. Git commit dates are source dates, not inferred npm publication
dates. A GitHub release does not itself establish npm publication.
Application adoption and deployment evidence are tracked separately.
## 0.1.1
- [Tagged source `v0.1.1`](https://github.com/bitbaum/threadkit/tree/047dc691e20d14b014032e7ba5d0726415d99758)
- [Source commit](https://github.com/bitbaum/threadkit/commit/047dc691e20d14b014032e7ba5d0726415d99758), dated 2026-08-20.
No authored release notes were found for this tag when this record was made.
The links identify the verified source; missing feature history is not invented.
+1
View File
@@ -0,0 +1 @@
Read and follow [AGENTS.md](AGENTS.md).
+53 -4
View File
@@ -1,11 +1,11 @@
# threadkit
# @bitbaum/threadkit
Headless multi-participant message threads, with AI participants that obey the same rules as everyone else.
No UI, no database, no SDK. Pure functions over data you already loaded, so the rules that decide who can read what are things you can unit-test instead of things buried in a `WHERE` clause.
```bash
npm install threadkit
pnpm add @bitbaum/threadkit
```
## The idea
@@ -31,7 +31,7 @@ That is correct while the clinic has exactly one doctor. On the day it has two,
Participation-based access cannot express that bug, because there is no role to check:
```ts
import { canRead, visibleMessages } from 'threadkit'
import { canRead, visibleMessages } from '@bitbaum/threadkit'
if (!canRead(thread, actorId)) return forbidden()
const messages = visibleMessages(thread, actorId, allMessages)
@@ -63,7 +63,7 @@ unreadThreadCount(entries, 'dr-b') // the nav badge
An AI is a participant, not an exception. It reads through the same visibility window as every human, so a model added to an existing thread sees what it was granted and nothing earlier.
```ts
import { runAiTurn } from 'threadkit'
import { runAiTurn } from '@bitbaum/threadkit'
const result = await runAiTurn(thread, messages, {
actorId: 'assistant-1',
@@ -93,6 +93,43 @@ Defaults that keep it usable:
Every reply carries `generatedBy`, so a record can say honestly which model wrote what.
## Files on a message
A message can carry files: `attachments` is a list of what was sent, never of where it is kept.
```ts
{ id: 'a1', kind: 'image', name: 'cat.jpg', mimeType: 'image/jpeg', bytes: 184_000, width: 1600, height: 1200 }
```
There is deliberately no URL on it. A link to a private file is a grant with an expiry, decided per reader at the moment of reading; whoever may see the message may see what was sent with it, and that question is `canSeeMessage`.
Files are also where a messenger's costs live, so what may be attached is a policy, checked in the same words in the browser (before an upload starts) and on the server (because the browser can be anyone):
```ts
import { checkAttachment, DEFAULT_ATTACHMENT_POLICY } from '@bitbaum/threadkit'
const check = checkAttachment(
{ mimeType: file.type, bytes: file.size },
{ onMessage: staged.length, usedBytes: storedByThisPerson },
)
if (!check.ok) return say(check) // 'type' | 'size' | 'count' | 'quota' | 'empty', each with its number
```
- **An allowlist, not a blocklist.** A type the policy does not name is refused. `image/svg+xml` and `text/html` are absent from the default on purpose: both can carry script, and a file opened from your storage origin runs there.
- **A ceiling per kind.** A photo and a video are not the same risk.
- **A quota per person**, counted over what is still stored, so deleting something frees room.
- **A lifetime.** `isAbandonedUpload` finds the upload that never became a message; `attachmentExpiresAt` / `isAttachmentExpired` say when a sent file stops being kept, if your policy sets `retentionDays`.
The package still stores nothing and signs nothing. It answers the questions; your storage does the work.
## Read receipts that survive a third participant
`readState(thread, message)` answers `'none' | 'some' | 'all'`, with the readers and the size of the audience. The audience is the people the message was for — humans who can see it and have not left. A model is left out: it has no reading to report, and counting it means a message in a room with an assistant can never be read by everyone.
## Was it addressed?
`mentionsAny(text, ['@cat'])` matches whole words only — `@catalogue` is somebody else, and an alias like `ai` does not fire inside "again". `whenMentioned` uses the same matcher, so a server deciding whether the assistant answers and an interface showing that it is about to cannot disagree.
## Bring your own storage
There is no database adapter and no ORM. Load a thread and its messages however you already do, call the functions, write the result back. That is the whole integration surface — which is also why it works the same on Drizzle, Prisma, Supabase, or a JSON file.
@@ -111,9 +148,21 @@ There is no database adapter and no ORM. Load a thread and its messages however
| `unreadThreadCount(entries, actorId)` | threads with anything unread |
| `mergeMessages(existing, incoming)` | dedupe, reconcile optimistic, order |
| `compareMessages` / `isPending` | ordering and pending-state helpers |
| `readState(thread, message)` | read by nobody else, some, or everyone it was for |
| `checkAttachment(file, usage?, policy?)` | may this file be attached, and if not, why |
| `attachmentKind(mimeType, policy?)` | image, video, audio, file — or `null` when refused |
| `attachmentExpiresAt` / `isAttachmentExpired` / `isAbandonedUpload` | the lifetime rules |
| `storedBytes(attachments)` | what a quota is compared against |
| `mentionsAny(text, aliases)` / `mentionMatcher(aliases)` | whole-word mentions |
| `runAiTurn(thread, messages, config)` | decide whether the AI speaks, and what it says |
| `afterEveryMessage` / `whenMentioned` / `defaultRespondPolicy` | response policies |
## Licence
MIT
---
Part of **[bitbaum](https://bitbaum.orangecat.ch)** — AI-native products on open
infrastructure, built in Zürich. Every package here lists the apps that use it:
**[which apps use threadkit](https://bitbaum.orangecat.ch/packages/#threadkit)**.
+4 -4
View File
@@ -2,9 +2,9 @@
// library code, and a bespoke rule set would be a second opinion to maintain
// for no benefit. The floor is "lint runs and can fail", not "lint encodes
// taste".
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
@@ -22,4 +22,4 @@ export default tseslint.config(
files: ['test/**/*.js', 'scripts/**/*.{js,mjs}'],
languageOptions: { globals: { ...globals.node, ...globals.nodeBuiltin } },
},
)
);
-1531
View File
File diff suppressed because it is too large. Load diff
+19 -14
View File
@@ -1,30 +1,32 @@
{
"name": "threadkit",
"version": "0.1.0",
"name": "@bitbaum/threadkit",
"version": "0.1.2",
"description": "Headless multi-participant message threads. Permission is participation, unread is per-person, and an AI can be a participant subject to the same visibility rules as everyone else.",
"license": "MIT",
"author": "Mao Nakamoto",
"homepage": "https://github.com/maonakamoto/threadkit#readme",
"homepage": "https://github.com/bitbaum/threadkit#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/maonakamoto/threadkit.git"
"url": "git+https://github.com/bitbaum/threadkit.git"
},
"bugs": {
"url": "https://github.com/maonakamoto/threadkit/issues"
"url": "https://github.com/bitbaum/threadkit/issues"
},
"keywords": [
"messaging",
"chat",
"threads",
"group-chat",
"attachments",
"ai",
"authorization",
"headless"
],
"type": "module",
"sideEffects": false,
"packageManager": "pnpm@11.25.0",
"engines": {
"node": ">=18"
"node": ">=20"
},
"publishConfig": {
"access": "public",
@@ -44,15 +46,18 @@
"lint": "eslint .",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "node --test test/*.test.js",
"verify": "npm run lint && npm run typecheck && npm run build && npm test",
"prepare": "npm run build"
"verify": "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm run build && pnpm test",
"prepare": "pnpm run build",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"devDependencies": {
"@eslint/js": "^9.39.5",
"@types/node": "^22.10.2",
"eslint": "^9.39.5",
"globals": "^15.15.0",
"typescript": "^5.8.2",
"typescript-eslint": "^8.67.0"
"@eslint/js": "^10.0.1",
"@types/node": "^26.4.0",
"eslint": "^10.9.1",
"globals": "^17.12.0",
"prettier": "3.9.10",
"typescript": "^6.0.3",
"typescript-eslint": "^8.68.0"
}
}
+901
View File
@@ -0,0 +1,901 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
devDependencies:
'@eslint/js':
specifier: ^10.0.1
version: 10.0.1(eslint@10.14.0)
'@types/node':
specifier: ^26.4.0
version: 26.6.6
eslint:
specifier: ^10.9.1
version: 10.14.0
globals:
specifier: ^17.12.0
version: 17.14.0
prettier:
specifier: 3.9.10
version: 3.9.10
typescript:
specifier: ^6.0.3
version: 6.0.3
typescript-eslint:
specifier: ^8.68.0
version: 8.72.1(eslint@10.14.0)(typescript@6.0.3)
packages:
'@cacheable/memory@2.2.0':
resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==}
'@cacheable/utils@2.5.0':
resolution: {integrity: sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==}
'@eslint-community/eslint-utils@4.10.1':
resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
'@eslint-community/regexpp@4.12.2':
resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
'@eslint/config-array@0.23.5':
resolution: {integrity: sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/config-helpers@0.7.0':
resolution: {integrity: sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/core@1.2.1':
resolution: {integrity: sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/js@10.0.1':
resolution: {integrity: sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
peerDependencies:
eslint: ^10.0.0
peerDependenciesMeta:
eslint:
optional: true
'@eslint/object-schema@3.0.5':
resolution: {integrity: sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/plugin-kit@0.7.3':
resolution: {integrity: sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@humanfs/core@0.19.2':
resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==}
engines: {node: '>=18.18.0'}
'@humanfs/node@0.16.8':
resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==}
engines: {node: '>=18.18.0'}
'@humanfs/types@0.15.0':
resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==}
engines: {node: '>=18.18.0'}
'@humanwhocodes/module-importer@1.0.1':
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
engines: {node: '>=12.22'}
'@humanwhocodes/retry@0.4.3':
resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==}
engines: {node: '>=18.18'}
'@keyv/bigmap@1.3.1':
resolution: {integrity: sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==}
engines: {node: '>= 18'}
peerDependencies:
keyv: ^5.6.0
'@keyv/serialize@1.1.1':
resolution: {integrity: sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==}
'@types/esrecurse@4.3.1':
resolution: {integrity: sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==}
'@types/estree@1.0.9':
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
'@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@types/node@26.6.6':
resolution: {integrity: sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==}
'@typescript-eslint/eslint-plugin@8.72.1':
resolution: {integrity: sha512-5CokTWXpmbylfFabsbvHC0CAw3XLaGnoa+nFJX5FR592h/LoZsENUE6p/rg5xvkKrFEXz6pYmgI29AgXc2N3BQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/parser': ^8.72.1
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/parser@8.72.1':
resolution: {integrity: sha512-ZGwZP4OCfyA0AQTpEAMWz+rtX01DRhQWW5hB0ucKDEIX5U7jdmPSaMx94rQfaPAQzIYz2BimOgKOJtjfpRFQ9g==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/project-service@8.72.1':
resolution: {integrity: sha512-fAuVMkwdO/huI8nyo/WKnNKf6Gag93S56Rh3Ts5mGcavwSdaN8tRg1gCeIGX8PF+nzp1BjGfO4gHhGzW1J6jTg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/scope-manager@8.72.1':
resolution: {integrity: sha512-lC/t6eMCZZQAAKZEYGL6RDVSuFehpdmMT6h+nJIjIa6oylN/PwDgDVtEIbB7O9xFfZYtZAYLoLlDNWKJhtF+uQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/tsconfig-utils@8.72.1':
resolution: {integrity: sha512-e4D5R5vpeAEPBxT2BAzsFQL3sbwyeeeo5+aczgNSRK1V734jE7pTqaGFU+fXapWEQwnZbpFaTn32+Z8DwS6OTg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/type-utils@8.72.1':
resolution: {integrity: sha512-iY2wlmyrXJmx4yxUGP3aYCFF3cA/6ShddOKmLU2dx7LnEykbAM8WThlxZEfd1NddqceF6eJmZUayxx9oKIYNlg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/types@8.72.1':
resolution: {integrity: sha512-LmE5IhQet1BWOWEXqBrVtBPsMAOQ6Nzk35d+WLh3mk4EUF33sqlfxjio1MdYeSvKSG5skactKKuixBIKXhL4Rw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/typescript-estree@8.72.1':
resolution: {integrity: sha512-DAlUoUV93hIvrtIQLwCbmZQYVZwOMhiHJrOVUUIWicFZaIYjTRqlY3I/NZevfkLmSqkNHRu2qYDcq9lrn16oOQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/utils@8.72.1':
resolution: {integrity: sha512-5v5liypurJBFHCBNqh/RjsymAD+VWcE0djuGY/BUqp5fC3Qn+luWDEksjuTtWjPn6i5zQlUtkZCRG/CYG0yCkA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/visitor-keys@8.72.1':
resolution: {integrity: sha512-SB8xqipSzZHUePCCLNeYxqnxq83X61/qzNhjQGbTfjxGZIeOEP7tBgWYX05Tcd6CgE02WdTJnh5b8kMZJ/+bnQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
acorn: ^6.0.0 || ^7.0.0 || ^8.0.0
acorn@8.18.0:
resolution: {integrity: sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==}
engines: {node: '>=0.4.0'}
hasBin: true
ajv@6.15.0:
resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==}
balanced-match@4.0.4:
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
engines: {node: 18 || 20 || >=22}
brace-expansion@5.0.12:
resolution: {integrity: sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==}
engines: {node: 20 || >=22}
cacheable@2.5.0:
resolution: {integrity: sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==}
cross-spawn@7.0.6:
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
engines: {node: '>= 8'}
debug@4.4.3:
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
deep-is@0.1.4:
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
escape-string-regexp@4.0.0:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
eslint-scope@9.1.2:
resolution: {integrity: sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
eslint-visitor-keys@3.4.3:
resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
eslint-visitor-keys@5.0.1:
resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
eslint@10.14.0:
resolution: {integrity: sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
hasBin: true
peerDependencies:
jiti: '*'
peerDependenciesMeta:
jiti:
optional: true
espree@11.2.0:
resolution: {integrity: sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
esquery@1.7.0:
resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==}
engines: {node: '>=0.10'}
esrecurse@4.3.0:
resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==}
engines: {node: '>=4.0'}
estraverse@5.3.0:
resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
engines: {node: '>=4.0'}
esutils@2.0.3:
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
fast-deep-equal@3.1.3:
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
fast-json-stable-stringify@2.1.0:
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
fast-levenshtein@2.0.6:
resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==}
fdir@6.5.0:
resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}
engines: {node: '>=12.0.0'}
peerDependencies:
picomatch: ^3 || ^4
peerDependenciesMeta:
picomatch:
optional: true
file-entry-cache@11.1.5:
resolution: {integrity: sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==}
find-up@5.0.0:
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
engines: {node: '>=10'}
flat-cache@6.1.23:
resolution: {integrity: sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==}
flatted@3.4.4:
resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==}
glob-parent@6.0.2:
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
engines: {node: '>=10.13.0'}
globals@17.14.0:
resolution: {integrity: sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==}
engines: {node: '>=18'}
hashery@1.5.1:
resolution: {integrity: sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==}
engines: {node: '>=20'}
hookified@1.15.1:
resolution: {integrity: sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==}
hookified@2.2.0:
resolution: {integrity: sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==}
ignore@5.3.2:
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
engines: {node: '>= 4'}
ignore@7.0.7:
resolution: {integrity: sha512-dML0wP6oak21rsNYCJpJB6O1BJIEwNpGrTw0URPfAk4hm0e3pRfCtzkfB6olBcXcVlU2rouCyz7lCyRB0OMVCA==}
engines: {node: '>= 4'}
imurmurhash@0.1.4:
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
engines: {node: '>=0.8.19'}
is-extglob@2.1.1:
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'}
is-glob@4.0.3:
resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
engines: {node: '>=0.10.0'}
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
json-schema-traverse@0.4.1:
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
json-stable-stringify-without-jsonify@1.0.1:
resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}
keyv@5.6.0:
resolution: {integrity: sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==}
levn@0.4.1:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
locate-path@6.0.0:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
engines: {node: '>=10'}
minimatch@10.2.6:
resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==}
engines: {node: 18 || 20 || >=22}
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
optionator@0.9.4:
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
engines: {node: '>= 0.8.0'}
p-limit@3.1.0:
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
engines: {node: '>=10'}
p-locate@5.0.0:
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
engines: {node: '>=10'}
path-exists@4.0.0:
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
path-key@3.1.1:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'}
picomatch@4.0.7:
resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
engines: {node: '>=12'}
prelude-ls@1.2.1:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
prettier@3.9.10:
resolution: {integrity: sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==}
engines: {node: '>=14'}
hasBin: true
punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
qified@0.10.1:
resolution: {integrity: sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==}
engines: {node: '>=20'}
semver@7.8.5:
resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==}
engines: {node: '>=10'}
hasBin: true
shebang-command@2.0.0:
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'}
shebang-regex@3.0.0:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
ts-api-utils@2.5.0:
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
peerDependencies:
typescript: '>=4.8.4'
type-check@0.4.0:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
engines: {node: '>= 0.8.0'}
typescript-eslint@8.72.1:
resolution: {integrity: sha512-3Li9FfPmQp45nxEtFD1ZCrYFI3cYK5kpyNtmm1H7lMagm8u9sy6PTjy3ytwQZs7KNukOyKFHAZ6z6GjYFeaeXw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
typescript@6.0.3:
resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@8.9.0:
resolution: {integrity: sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==}
uri-js@4.4.1:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
which@2.0.2:
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
hasBin: true
word-wrap@1.2.5:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
yocto-queue@0.1.0:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
snapshots:
'@cacheable/memory@2.2.0':
dependencies:
'@cacheable/utils': 2.5.0
'@keyv/bigmap': 1.3.1(keyv@5.6.0)
hookified: 1.15.1
keyv: 5.6.0
'@cacheable/utils@2.5.0':
dependencies:
hashery: 1.5.1
keyv: 5.6.0
'@eslint-community/eslint-utils@4.10.1(eslint@10.14.0)':
dependencies:
eslint: 10.14.0
eslint-visitor-keys: 3.4.3
'@eslint-community/regexpp@4.12.2': {}
'@eslint/config-array@0.23.5':
dependencies:
'@eslint/object-schema': 3.0.5
debug: 4.4.3
minimatch: 10.2.6
transitivePeerDependencies:
- supports-color
'@eslint/config-helpers@0.7.0':
dependencies:
'@eslint/core': 1.2.1
'@eslint/core@1.2.1':
dependencies:
'@types/json-schema': 7.0.15
'@eslint/js@10.0.1(eslint@10.14.0)':
optionalDependencies:
eslint: 10.14.0
'@eslint/object-schema@3.0.5': {}
'@eslint/plugin-kit@0.7.3':
dependencies:
'@eslint/core': 1.2.1
levn: 0.4.1
'@humanfs/core@0.19.2':
dependencies:
'@humanfs/types': 0.15.0
'@humanfs/node@0.16.8':
dependencies:
'@humanfs/core': 0.19.2
'@humanfs/types': 0.15.0
'@humanwhocodes/retry': 0.4.3
'@humanfs/types@0.15.0': {}
'@humanwhocodes/module-importer@1.0.1': {}
'@humanwhocodes/retry@0.4.3': {}
'@keyv/bigmap@1.3.1(keyv@5.6.0)':
dependencies:
hashery: 1.5.1
hookified: 1.15.1
keyv: 5.6.0
'@keyv/serialize@1.1.1': {}
'@types/esrecurse@4.3.1': {}
'@types/estree@1.0.9': {}
'@types/json-schema@7.0.15': {}
'@types/node@26.6.6':
dependencies:
undici-types: 8.9.0
'@typescript-eslint/eslint-plugin@8.72.1(@typescript-eslint/parser@8.72.1(eslint@10.14.0)(typescript@6.0.3))(eslint@10.14.0)(typescript@6.0.3)':
dependencies:
'@eslint-community/regexpp': 4.12.2
'@typescript-eslint/parser': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
'@typescript-eslint/scope-manager': 8.72.1
'@typescript-eslint/type-utils': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.72.1
eslint: 10.14.0
ignore: 7.0.7
natural-compare: 1.4.0
ts-api-utils: 2.5.0(typescript@6.0.3)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.72.1(eslint@10.14.0)(typescript@6.0.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.72.1
'@typescript-eslint/types': 8.72.1
'@typescript-eslint/typescript-estree': 8.72.1(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.72.1
debug: 4.4.3
eslint: 10.14.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/project-service@8.72.1(typescript@6.0.3)':
dependencies:
'@typescript-eslint/tsconfig-utils': 8.72.1(typescript@6.0.3)
'@typescript-eslint/types': 8.72.1
debug: 4.4.3
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/scope-manager@8.72.1':
dependencies:
'@typescript-eslint/types': 8.72.1
'@typescript-eslint/visitor-keys': 8.72.1
'@typescript-eslint/tsconfig-utils@8.72.1(typescript@6.0.3)':
dependencies:
typescript: 6.0.3
'@typescript-eslint/type-utils@8.72.1(eslint@10.14.0)(typescript@6.0.3)':
dependencies:
'@typescript-eslint/types': 8.72.1
'@typescript-eslint/typescript-estree': 8.72.1(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
debug: 4.4.3
eslint: 10.14.0
ts-api-utils: 2.5.0(typescript@6.0.3)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/types@8.72.1': {}
'@typescript-eslint/typescript-estree@8.72.1(typescript@6.0.3)':
dependencies:
'@typescript-eslint/project-service': 8.72.1(typescript@6.0.3)
'@typescript-eslint/tsconfig-utils': 8.72.1(typescript@6.0.3)
'@typescript-eslint/types': 8.72.1
'@typescript-eslint/visitor-keys': 8.72.1
debug: 4.4.3
minimatch: 10.2.6
semver: 7.8.5
tinyglobby: 0.2.17
ts-api-utils: 2.5.0(typescript@6.0.3)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.72.1(eslint@10.14.0)(typescript@6.0.3)':
dependencies:
'@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0)
'@typescript-eslint/scope-manager': 8.72.1
'@typescript-eslint/types': 8.72.1
'@typescript-eslint/typescript-estree': 8.72.1(typescript@6.0.3)
eslint: 10.14.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/visitor-keys@8.72.1':
dependencies:
'@typescript-eslint/types': 8.72.1
eslint-visitor-keys: 5.0.1
acorn-jsx@5.3.2(acorn@8.18.0):
dependencies:
acorn: 8.18.0
acorn@8.18.0: {}
ajv@6.15.0:
dependencies:
fast-deep-equal: 3.1.3
fast-json-stable-stringify: 2.1.0
json-schema-traverse: 0.4.1
uri-js: 4.4.1
balanced-match@4.0.4: {}
brace-expansion@5.0.12:
dependencies:
balanced-match: 4.0.4
cacheable@2.5.0:
dependencies:
'@cacheable/memory': 2.2.0
'@cacheable/utils': 2.5.0
hookified: 1.15.1
keyv: 5.6.0
qified: 0.10.1
cross-spawn@7.0.6:
dependencies:
path-key: 3.1.1
shebang-command: 2.0.0
which: 2.0.2
debug@4.4.3:
dependencies:
ms: 2.1.3
deep-is@0.1.4: {}
escape-string-regexp@4.0.0: {}
eslint-scope@9.1.2:
dependencies:
'@types/esrecurse': 4.3.1
'@types/estree': 1.0.9
esrecurse: 4.3.0
estraverse: 5.3.0
eslint-visitor-keys@3.4.3: {}
eslint-visitor-keys@5.0.1: {}
eslint@10.14.0:
dependencies:
'@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0)
'@eslint-community/regexpp': 4.12.2
'@eslint/config-array': 0.23.5
'@eslint/config-helpers': 0.7.0
'@eslint/core': 1.2.1
'@eslint/plugin-kit': 0.7.3
'@humanfs/node': 0.16.8
'@humanwhocodes/module-importer': 1.0.1
'@humanwhocodes/retry': 0.4.3
'@types/estree': 1.0.9
ajv: 6.15.0
cross-spawn: 7.0.6
debug: 4.4.3
escape-string-regexp: 4.0.0
eslint-scope: 9.1.2
eslint-visitor-keys: 5.0.1
espree: 11.2.0
esquery: 1.7.0
esutils: 2.0.3
fast-deep-equal: 3.1.3
file-entry-cache: 11.1.5
find-up: 5.0.0
glob-parent: 6.0.2
ignore: 5.3.2
imurmurhash: 0.1.4
is-glob: 4.0.3
json-stable-stringify-without-jsonify: 1.0.1
minimatch: 10.2.6
natural-compare: 1.4.0
optionator: 0.9.4
transitivePeerDependencies:
- supports-color
espree@11.2.0:
dependencies:
acorn: 8.18.0
acorn-jsx: 5.3.2(acorn@8.18.0)
eslint-visitor-keys: 5.0.1
esquery@1.7.0:
dependencies:
estraverse: 5.3.0
esrecurse@4.3.0:
dependencies:
estraverse: 5.3.0
estraverse@5.3.0: {}
esutils@2.0.3: {}
fast-deep-equal@3.1.3: {}
fast-json-stable-stringify@2.1.0: {}
fast-levenshtein@2.0.6: {}
fdir@6.5.0(picomatch@4.0.7):
optionalDependencies:
picomatch: 4.0.7
file-entry-cache@11.1.5:
dependencies:
flat-cache: 6.1.23
find-up@5.0.0:
dependencies:
locate-path: 6.0.0
path-exists: 4.0.0
flat-cache@6.1.23:
dependencies:
cacheable: 2.5.0
flatted: 3.4.4
hookified: 1.15.1
flatted@3.4.4: {}
glob-parent@6.0.2:
dependencies:
is-glob: 4.0.3
globals@17.14.0: {}
hashery@1.5.1:
dependencies:
hookified: 1.15.1
hookified@1.15.1: {}
hookified@2.2.0: {}
ignore@5.3.2: {}
ignore@7.0.7: {}
imurmurhash@0.1.4: {}
is-extglob@2.1.1: {}
is-glob@4.0.3:
dependencies:
is-extglob: 2.1.1
isexe@2.0.0: {}
json-schema-traverse@0.4.1: {}
json-stable-stringify-without-jsonify@1.0.1: {}
keyv@5.6.0:
dependencies:
'@keyv/serialize': 1.1.1
levn@0.4.1:
dependencies:
prelude-ls: 1.2.1
type-check: 0.4.0
locate-path@6.0.0:
dependencies:
p-locate: 5.0.0
minimatch@10.2.6:
dependencies:
brace-expansion: 5.0.12
ms@2.1.3: {}
natural-compare@1.4.0: {}
optionator@0.9.4:
dependencies:
deep-is: 0.1.4
fast-levenshtein: 2.0.6
levn: 0.4.1
prelude-ls: 1.2.1
type-check: 0.4.0
word-wrap: 1.2.5
p-limit@3.1.0:
dependencies:
yocto-queue: 0.1.0
p-locate@5.0.0:
dependencies:
p-limit: 3.1.0
path-exists@4.0.0: {}
path-key@3.1.1: {}
picomatch@4.0.7: {}
prelude-ls@1.2.1: {}
prettier@3.9.10: {}
punycode@2.3.1: {}
qified@0.10.1:
dependencies:
hookified: 2.2.0
semver@7.8.5: {}
shebang-command@2.0.0:
dependencies:
shebang-regex: 3.0.0
shebang-regex@3.0.0: {}
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.7)
picomatch: 4.0.7
ts-api-utils@2.5.0(typescript@6.0.3):
dependencies:
typescript: 6.0.3
type-check@0.4.0:
dependencies:
prelude-ls: 1.2.1
typescript-eslint@8.72.1(eslint@10.14.0)(typescript@6.0.3):
dependencies:
'@typescript-eslint/eslint-plugin': 8.72.1(@typescript-eslint/parser@8.72.1(eslint@10.14.0)(typescript@6.0.3))(eslint@10.14.0)(typescript@6.0.3)
'@typescript-eslint/parser': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
'@typescript-eslint/typescript-estree': 8.72.1(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.1(eslint@10.14.0)(typescript@6.0.3)
eslint: 10.14.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
typescript@6.0.3: {}
undici-types@8.9.0: {}
uri-js@4.4.1:
dependencies:
punycode: 2.3.1
which@2.0.2:
dependencies:
isexe: 2.0.0
word-wrap@1.2.5: {}
yocto-queue@0.1.0: {}
+9 -14
View File
@@ -1,5 +1,6 @@
import type { AiProvenance, CompleteFn, Message, Participant, Thread } from './types.js';
import { canWrite, findParticipant, visibleMessages } from './participants.js';
import { mentionMatcher } from './mentions.js';
/**
* An AI that participates in a thread rather than owning one.
@@ -62,16 +63,13 @@ export const afterEveryMessage: RespondPolicy = ({ visible, self }) => {
* turn is noise and, between a doctor and a patient, an interruption.
*/
export function whenMentioned(aliases: readonly string[]): RespondPolicy {
// Whole words only. A substring test looks fine until an alias like "ai"
// matches "again" or "wait" and the assistant starts answering turns nobody
// addressed to it.
const patterns = aliases
.filter(Boolean)
.map(a => new RegExp(`(^|\\W)${a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\W|$)`, 'i'));
// Whole words only — see `mentionMatcher`, which an interface can share so
// "will the assistant answer this?" has one definition on both sides.
const mentioned = mentionMatcher(aliases);
return ({ visible, self }) => {
const last = visible[visible.length - 1];
if (!last || last.authorId === self.actorId) return false;
return patterns.some(re => re.test(last.body));
return mentioned(last.body);
};
}
@@ -84,7 +82,7 @@ export function whenMentioned(aliases: readonly string[]): RespondPolicy {
* clinical thread unusable the moment an assistant joined.
*/
export function defaultRespondPolicy(ctx: AiTurnContext): boolean {
const active = ctx.thread.participants.filter(p => !p.leftAt);
const active = ctx.thread.participants.filter((p) => !p.leftAt);
if (active.length <= 2) return afterEveryMessage(ctx);
return whenMentioned([ctx.self.role ?? 'assistant', 'ai'])(ctx);
}
@@ -98,12 +96,9 @@ function trailingSelfMessages(visible: readonly Message[], actorId: string): num
return n;
}
function renderTranscript(
ctx: AiTurnContext,
label: (p: Participant) => string
): string {
function renderTranscript(ctx: AiTurnContext, label: (p: Participant) => string): string {
return ctx.visible
.map(m => {
.map((m) => {
const author = findParticipant(ctx.thread, m.authorId);
const who = author ? label(author) : 'unknown';
return `${who}: ${m.body}`;
@@ -124,7 +119,7 @@ function renderTranscript(
export async function runAiTurn(
thread: Thread,
allMessages: readonly Message[],
config: AiParticipantConfig
config: AiParticipantConfig,
): Promise<AiTurnResult> {
const self = findParticipant(thread, config.actorId);
if (!self) return { status: 'skipped', reason: 'not a participant in this thread' };
+253
View File
@@ -0,0 +1,253 @@
import type { AttachmentKind } from './types.js';
/**
* What may be attached, how big, how much, and for how long.
*
* Files are where a messenger's costs live. Text is bytes; one phone video is
* megabytes, kept until somebody decides otherwise — and usually nobody does.
* So the decisions are a policy, stated once and enforced in the same words on
* the client (to refuse before an upload starts) and on the server (because
* the client can be anyone):
*
* - **An allowlist, not a blocklist.** A type that is not named is refused. A
* blocklist is correct until the first type nobody thought of, and the type
* nobody thought of is the one that runs script when a reader opens it.
* - **A ceiling per kind**, because a photo and a video are not the same risk.
* - **A quota per person**, counted over what is still stored, so deleting
* something frees room for something else.
* - **A lifetime.** An upload that never became a message is swept after a few
* hours; a sent file may expire after a stated number of days, or be kept
* as long as its message. Either way the rule is written down, not implied.
*
* Pure functions over numbers you already have. This file stores nothing,
* signs nothing and never sees a byte.
*/
export interface AttachmentPolicy {
/** Files on one message. */
readonly maxPerMessage: number;
/** Largest file of each kind, in bytes. 0 refuses the kind outright. */
readonly maxBytes: Readonly<Record<AttachmentKind, number>>;
/**
* MIME types accepted for each kind: exact (`image/png`) or a whole family
* (`audio/*`). Anything not listed is refused, whatever its extension says.
*/
readonly accept: Readonly<Record<AttachmentKind, readonly string[]>>;
/**
* Bytes one person may keep stored at a time, across every thread.
* `null` means no ceiling — say so on purpose.
*/
readonly quotaBytes: number | null;
/**
* Days a sent attachment is kept. `null` keeps it as long as its message.
* The message outlives its files: words stay, the file is gone, and a
* reader is told so rather than shown a broken picture.
*/
readonly retentionDays: number | null;
/** Hours an uploaded file may wait to be sent before it is swept as abandoned. */
readonly orphanHours: number;
}
const MB = 1024 * 1024;
/**
* Defaults sized for a messenger whose pictures are shrunk in the browser
* before they are sent: a photo arrives well under the image ceiling, and the
* ceiling is there for the animated GIF and the picture nothing could shrink.
*
* `image/svg+xml` and `text/html` are deliberately absent. Both can carry
* script, and a file a reader opens from your storage origin runs there.
*/
export const DEFAULT_ATTACHMENT_POLICY: AttachmentPolicy = {
maxPerMessage: 10,
maxBytes: {
image: 10 * MB,
video: 50 * MB,
audio: 20 * MB,
file: 25 * MB,
},
accept: {
image: ['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'image/avif'],
video: ['video/mp4', 'video/webm', 'video/quicktime'],
audio: [
'audio/mpeg',
'audio/mp4',
'audio/aac',
'audio/ogg',
'audio/webm',
'audio/wav',
'audio/x-wav',
'audio/x-m4a',
],
file: [
'application/pdf',
'text/plain',
'text/csv',
'text/markdown',
'application/json',
'application/zip',
'application/rtf',
'application/msword',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.spreadsheet',
'application/epub+zip',
],
},
quotaBytes: 1024 * MB,
retentionDays: null,
orphanHours: 24,
};
/** The parameters of a MIME type (`; charset=utf-8`) say nothing about what it is. */
function bareMime(mimeType: string): string {
return mimeType.split(';')[0].trim().toLowerCase();
}
function matches(mime: string, pattern: string): boolean {
const p = pattern.toLowerCase();
if (p.endsWith('/*')) return mime.startsWith(p.slice(0, -1));
return mime === p;
}
const KINDS: readonly AttachmentKind[] = ['image', 'video', 'audio', 'file'];
/**
* Which kind a MIME type is under this policy, or `null` when the policy does
* not accept it at all.
*
* The policy decides, not the type's first word: `image/svg+xml` is an image
* by name and a document that can run script by nature, so unless a policy
* lists it under `image` it is never shown in place.
*/
export function attachmentKind(
mimeType: string,
policy: AttachmentPolicy = DEFAULT_ATTACHMENT_POLICY,
): AttachmentKind | null {
const mime = bareMime(mimeType);
if (!mime) return null;
for (const kind of KINDS) {
if (policy.accept[kind].some((pattern) => matches(mime, pattern))) return kind;
}
return null;
}
/** Why a file was refused. Every reason carries the number a person needs to hear. */
export type AttachmentRefusal =
| { readonly ok: false; readonly reason: 'empty' }
| { readonly ok: false; readonly reason: 'type' }
| {
readonly ok: false;
readonly reason: 'size';
readonly kind: AttachmentKind;
readonly maxBytes: number;
}
| { readonly ok: false; readonly reason: 'count'; readonly maxPerMessage: number }
| {
readonly ok: false;
readonly reason: 'quota';
readonly quotaBytes: number;
readonly usedBytes: number;
};
export type AttachmentCheck =
{ readonly ok: true; readonly kind: AttachmentKind } | AttachmentRefusal;
/** What is already there when a new file asks to join. */
export interface AttachmentUsage {
/** Files already on the message being written. */
readonly onMessage?: number;
/** Bytes this person already has stored. Only consulted when the policy has a quota. */
readonly usedBytes?: number;
}
/**
* May this file be attached?
*
* Returns rather than throws, and says why — a refusal is the normal outcome
* of somebody picking a two-gigabyte video, and the caller's job is to say the
* limit back to them. Checks run cheapest-first, so the answer for a wrong
* type never depends on a quota lookup.
*
* Run it twice: in the browser before the upload starts (to save the person
* the wait), and on the server before a storage URL is issued (because the
* first check proves nothing about a request you did not write).
*/
export function checkAttachment(
file: { readonly mimeType: string; readonly bytes: number },
usage: AttachmentUsage = {},
policy: AttachmentPolicy = DEFAULT_ATTACHMENT_POLICY,
): AttachmentCheck {
if (!Number.isFinite(file.bytes) || file.bytes <= 0) return { ok: false, reason: 'empty' };
const kind = attachmentKind(file.mimeType, policy);
if (!kind) return { ok: false, reason: 'type' };
const maxBytes = policy.maxBytes[kind];
// A ceiling of 0 turns the kind off: it is a type this thread does not take.
if (maxBytes <= 0) return { ok: false, reason: 'type' };
if (file.bytes > maxBytes) return { ok: false, reason: 'size', kind, maxBytes };
if ((usage.onMessage ?? 0) >= policy.maxPerMessage) {
return { ok: false, reason: 'count', maxPerMessage: policy.maxPerMessage };
}
if (policy.quotaBytes !== null) {
const usedBytes = usage.usedBytes ?? 0;
if (usedBytes + file.bytes > policy.quotaBytes) {
return { ok: false, reason: 'quota', quotaBytes: policy.quotaBytes, usedBytes };
}
}
return { ok: true, kind };
}
/** Bytes a set of attachments occupies — what a quota is compared against. */
export function storedBytes(attachments: readonly { readonly bytes: number }[]): number {
let total = 0;
for (const a of attachments) total += Math.max(0, a.bytes);
return total;
}
const HOUR_MS = 60 * 60 * 1000;
const DAY_MS = 24 * HOUR_MS;
/**
* When a sent attachment stops being kept, or `null` when the policy keeps it
* as long as its message.
*/
export function attachmentExpiresAt(
sentAt: Date,
policy: AttachmentPolicy = DEFAULT_ATTACHMENT_POLICY,
): Date | null {
if (policy.retentionDays === null) return null;
return new Date(sentAt.getTime() + policy.retentionDays * DAY_MS);
}
/** Has a sent attachment outlived the policy's retention? Never true without one. */
export function isAttachmentExpired(
sentAt: Date,
now: Date = new Date(),
policy: AttachmentPolicy = DEFAULT_ATTACHMENT_POLICY,
): boolean {
const expiresAt = attachmentExpiresAt(sentAt, policy);
return expiresAt !== null && expiresAt.getTime() <= now.getTime();
}
/**
* Is an uploaded file that was never sent old enough to sweep?
*
* Uploading and sending are two steps, and the second does not always happen:
* a tab closes, a person changes their mind. Without this rule every abandoned
* upload is stored — and counted against its owner's quota — forever.
*/
export function isAbandonedUpload(
uploadedAt: Date,
now: Date = new Date(),
policy: AttachmentPolicy = DEFAULT_ATTACHMENT_POLICY,
): boolean {
return now.getTime() - uploadedAt.getTime() >= policy.orphanHours * HOUR_MS;
}
+21 -10
View File
@@ -1,6 +1,8 @@
export type {
ActorKind,
AiProvenance,
Attachment,
AttachmentKind,
CompleteFn,
Message,
Participant,
@@ -14,6 +16,7 @@ export {
canWrite,
findParticipant,
readersOf,
readState,
visibilityWindow,
visibleMessages,
} from './participants.js';
@@ -22,15 +25,23 @@ export { unreadCount, unreadMessages, unreadThreadCount } from './unread.js';
export { compareMessages, isPending, mergeMessages } from './merge.js';
export { afterEveryMessage, defaultRespondPolicy, runAiTurn, whenMentioned } from './ai.js';
export type { AiParticipantConfig, AiTurnContext, AiTurnResult, RespondPolicy } from './ai.js';
export {
afterEveryMessage,
defaultRespondPolicy,
runAiTurn,
whenMentioned,
} from './ai.js';
DEFAULT_ATTACHMENT_POLICY,
attachmentExpiresAt,
attachmentKind,
checkAttachment,
isAbandonedUpload,
isAttachmentExpired,
storedBytes,
} from './attachments.js';
export type {
AiParticipantConfig,
AiTurnContext,
AiTurnResult,
RespondPolicy,
} from './ai.js';
AttachmentCheck,
AttachmentPolicy,
AttachmentRefusal,
AttachmentUsage,
} from './attachments.js';
export { mentionMatcher, mentionsAny } from './mentions.js';
+36
View File
@@ -0,0 +1,36 @@
/**
* Was somebody addressed by name?
*
* Whole words only. A substring test looks fine until an alias like "ai"
* matches "again" or "wait" and an assistant starts answering turns nobody
* addressed to it — or a "@cat" tag fires on "@catalogue". The same matcher
* decides it on the server (does the agent answer?) and in the interface
* (is the agent about to answer?), so the two cannot disagree.
*/
function escapeRegExp(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
/**
* A matcher for a fixed set of aliases, compiled once.
*
* A word character on either side of the alias means it is part of a longer
* word and is not a mention; anything else — a space, punctuation, the start
* or the end of the text — is a boundary. Case is ignored. Empty aliases are
* dropped, so a blank handle can never match everything.
*/
export function mentionMatcher(aliases: readonly string[]): (text: string) => boolean {
const patterns = aliases
.map((alias) => alias.trim())
.filter(Boolean)
.map(
(alias) => new RegExp(`(^|[^\\p{L}\\p{N}_])${escapeRegExp(alias)}(?![\\p{L}\\p{N}_])`, 'iu'),
);
return (text) => patterns.some((re) => re.test(text));
}
/** Does `text` mention any of `aliases` as a whole word? */
export function mentionsAny(text: string, aliases: readonly string[]): boolean {
return mentionMatcher(aliases)(text);
}
+9 -6
View File
@@ -23,15 +23,18 @@ export function compareMessages(a: Message, b: Message): number {
* Identity is `id` first, then `clientId`. The `clientId` pass is what retires
* an optimistic bubble: the stored row carries the same `clientId`, so it
* replaces the placeholder in place instead of arriving as a second message.
*
* Generic over your own message type: rows that carry more than this package
* knows about (a sender's name, an edited-at) come back as what they were.
*/
export function mergeMessages(
existing: readonly Message[],
incoming: readonly Message[]
): Message[] {
const byId = new Map<string, Message>();
export function mergeMessages<M extends Message>(
existing: readonly M[],
incoming: readonly M[],
): M[] {
const byId = new Map<string, M>();
const idByClientId = new Map<string, string>();
const put = (m: Message) => {
const put = (m: M) => {
// A confirmed row supersedes the optimistic one that shares its clientId.
if (m.clientId) {
const placeholderId = idByClientId.get(m.clientId);
+45 -10
View File
@@ -10,11 +10,8 @@ import type { Message, Participant, Thread } from './types.js';
* thread does not have that failure mode.
*/
export function findParticipant(
thread: Thread,
actorId: string
): Participant | undefined {
return thread.participants.find(p => p.actorId === actorId);
export function findParticipant(thread: Thread, actorId: string): Participant | undefined {
return thread.participants.find((p) => p.actorId === actorId);
}
/** Has this actor ever been part of the thread? Necessary, never sufficient — see `canSeeMessage`. */
@@ -60,14 +57,14 @@ export function canSeeMessage(p: Participant, message: Message): boolean {
* that forgets to check `canRead` first still leaks nothing. Failing closed is
* the entire point.
*/
export function visibleMessages(
export function visibleMessages<M extends Message>(
thread: Thread,
actorId: string,
messages: readonly Message[]
): Message[] {
messages: readonly M[],
): M[] {
const p = findParticipant(thread, actorId);
if (!p) return [];
return messages.filter(m => m.threadId === thread.id && canSeeMessage(p, m));
return messages.filter((m) => m.threadId === thread.id && canSeeMessage(p, m));
}
/**
@@ -78,10 +75,48 @@ export function visibleMessages(
* access that does not exist.
*/
export function readersOf(thread: Thread, message: Message): Participant[] {
return thread.participants.filter(p => {
return thread.participants.filter((p) => {
if (p.actorId === message.authorId) return false;
if (!canSeeMessage(p, message)) return false;
if (!p.lastReadAt) return false;
return p.lastReadAt.getTime() >= message.createdAt.getTime();
});
}
/**
* How far a message has been read: by nobody else, by some, or by everyone
* who could have.
*
* `audience` is the people the message was *for*: every human participant
* other than its author who can see it and has not left. A model is left out
* on purpose — it has no reading to report, and counting it would mean a
* message in a room with an assistant could never be "read by all".
*
* This is what a tick is drawn from. One grey tick, two, or two coloured is a
* presentation choice; which of the three states a message is in is a rule,
* and it has to be the same rule for two participants and for ten.
*/
export function readState(
thread: Thread,
message: Message,
): {
readonly state: 'none' | 'some' | 'all';
readonly readers: readonly Participant[];
readonly audience: number;
} {
const audience = thread.participants.filter(
(p) =>
p.kind === 'human' &&
p.actorId !== message.authorId &&
!p.leftAt &&
canSeeMessage(p, message),
);
const readers = readersOf(thread, message).filter((p) => p.kind === 'human' && !p.leftAt);
const state =
audience.length === 0 || readers.length === 0
? 'none'
: readers.length >= audience.length
? 'all'
: 'some';
return { state, readers, audience: audience.length };
}
+37
View File
@@ -61,6 +61,37 @@ export interface Participant {
readonly lastReadAt?: Date | null;
}
/**
* What a file on a message is, as a reader meets it.
*
* `image`, `video` and `audio` are shown in place; `file` is something to
* open or download. The split is by how it is used, not by where it is kept.
*/
export type AttachmentKind = 'image' | 'video' | 'audio' | 'file';
/**
* A file that travels with a message.
*
* The thread knows what it is and how big it is; the bytes live in your object
* storage, under whatever key you gave them. Deliberately no URL here: a URL
* to a private file is a grant with an expiry, and that is decided per reader
* at the moment of reading, never stored on the message.
*/
export interface Attachment {
readonly id: string;
readonly kind: AttachmentKind;
/** The name the sender's device gave it. Shown to readers; never used as a path. */
readonly name: string;
readonly mimeType: string;
/** Size as stored, in bytes. What a quota counts. */
readonly bytes: number;
/** Pixels, for an image or a video — lets a reader lay it out before it loads. */
readonly width?: number;
readonly height?: number;
/** Length of a video or a recording, in milliseconds. */
readonly durationMs?: number;
}
/** Where an AI message came from, so a clinical record can say so honestly. */
export interface AiProvenance {
readonly model: string;
@@ -81,6 +112,12 @@ export interface Message {
readonly clientId?: string;
/** Present iff a model wrote this. Absent means a human or your system did. */
readonly generatedBy?: AiProvenance;
/**
* Files sent with these words. A message may be only files: `body` is then
* the empty string. Visibility is the message's — whoever may see the
* message may see what was sent with it, and nobody else.
*/
readonly attachments?: readonly Attachment[];
}
export interface Thread {
+7 -11
View File
@@ -12,15 +12,15 @@ import { findParticipant, canSeeMessage } from './participants.js';
*/
/** Messages this actor can see, did not write, and has not caught up to. */
export function unreadMessages(
export function unreadMessages<M extends Message>(
thread: Thread,
actorId: string,
messages: readonly Message[]
): Message[] {
messages: readonly M[],
): M[] {
const p = findParticipant(thread, actorId);
if (!p) return [];
const since = p.lastReadAt?.getTime() ?? null;
return messages.filter(m => {
return messages.filter((m) => {
if (m.threadId !== thread.id) return false;
if (m.authorId === actorId) return false;
if (!canSeeMessage(p, m)) return false;
@@ -30,11 +30,7 @@ export function unreadMessages(
});
}
export function unreadCount(
thread: Thread,
actorId: string,
messages: readonly Message[]
): number {
export function unreadCount(thread: Thread, actorId: string, messages: readonly Message[]): number {
return unreadMessages(thread, actorId, messages).length;
}
@@ -46,7 +42,7 @@ export function unreadCount(
*/
export function unreadThreadCount(
entries: readonly { thread: Thread; messages: readonly Message[] }[],
actorId: string
actorId: string,
): number {
return entries.filter(e => unreadCount(e.thread, actorId, e.messages) > 0).length;
return entries.filter((e) => unreadCount(e.thread, actorId, e.messages) > 0).length;
}
+2 -2
View File
@@ -18,7 +18,7 @@ function msg(id, authorId, createdAt, body = 'hello') {
/** Records what the model was shown, so the test can assert on the prompt itself. */
function spyComplete(reply = 'a reply') {
const seen = [];
const complete = async input => {
const complete = async (input) => {
seen.push(input);
return reply;
};
@@ -47,7 +47,7 @@ test('the AI sees only what it was granted, not the whole transcript', async ()
assert.equal(seen.length, 1);
assert.ok(
!seen[0].prompt.includes('private history'),
'a model added later must not be handed the history it was not granted'
'a model added later must not be handed the history it was not granted',
);
assert.ok(seen[0].prompt.includes('summarise my sleep'));
});
+152
View File
@@ -0,0 +1,152 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import {
DEFAULT_ATTACHMENT_POLICY,
attachmentExpiresAt,
attachmentKind,
checkAttachment,
isAbandonedUpload,
isAttachmentExpired,
storedBytes,
} from '../dist/index.js';
const MB = 1024 * 1024;
test('a type the policy does not name is refused, whatever it is called', () => {
// The two that matter: both can carry script, and a reader opens them from
// the storage origin.
assert.equal(attachmentKind('image/svg+xml'), null);
assert.equal(attachmentKind('text/html'), null);
assert.equal(attachmentKind('application/x-msdownload'), null);
assert.deepEqual(checkAttachment({ mimeType: 'image/svg+xml', bytes: 10 }), {
ok: false,
reason: 'type',
});
});
test('a missing type is refused rather than guessed from the name', () => {
assert.equal(attachmentKind(''), null);
assert.equal(checkAttachment({ mimeType: '', bytes: 10 }).ok, false);
});
test('each accepted type lands in the kind a reader will meet it as', () => {
assert.equal(attachmentKind('image/jpeg'), 'image');
assert.equal(attachmentKind('IMAGE/PNG'), 'image');
assert.equal(attachmentKind('video/mp4'), 'video');
assert.equal(attachmentKind('audio/webm'), 'audio');
assert.equal(attachmentKind('application/pdf'), 'file');
// Parameters say nothing about what the file is.
assert.equal(attachmentKind('text/plain; charset=utf-8'), 'file');
});
test('a family pattern accepts the whole family and nothing beside it', () => {
const policy = {
...DEFAULT_ATTACHMENT_POLICY,
accept: { ...DEFAULT_ATTACHMENT_POLICY.accept, audio: ['audio/*'] },
};
assert.equal(attachmentKind('audio/flac', policy), 'audio');
assert.equal(attachmentKind('audiobook/flac', policy), null);
});
test('a file over its kind’s ceiling is refused with the ceiling', () => {
const check = checkAttachment({ mimeType: 'video/mp4', bytes: 51 * MB });
assert.deepEqual(check, { ok: false, reason: 'size', kind: 'video', maxBytes: 50 * MB });
assert.deepEqual(checkAttachment({ mimeType: 'video/mp4', bytes: 50 * MB }), {
ok: true,
kind: 'video',
});
});
test('a photo and a video do not share a ceiling', () => {
assert.equal(checkAttachment({ mimeType: 'image/jpeg', bytes: 11 * MB }).ok, false);
assert.equal(checkAttachment({ mimeType: 'video/mp4', bytes: 11 * MB }).ok, true);
});
test('a ceiling of zero turns a kind off', () => {
const policy = {
...DEFAULT_ATTACHMENT_POLICY,
maxBytes: { ...DEFAULT_ATTACHMENT_POLICY.maxBytes, video: 0 },
};
assert.deepEqual(checkAttachment({ mimeType: 'video/mp4', bytes: 1 }, {}, policy), {
ok: false,
reason: 'type',
});
});
test('an empty file is refused before anything else is asked', () => {
assert.deepEqual(checkAttachment({ mimeType: 'image/png', bytes: 0 }), {
ok: false,
reason: 'empty',
});
assert.deepEqual(checkAttachment({ mimeType: 'image/png', bytes: Number.NaN }), {
ok: false,
reason: 'empty',
});
});
test('a message takes only so many files', () => {
const full = checkAttachment({ mimeType: 'image/png', bytes: 10 }, { onMessage: 10 });
assert.deepEqual(full, { ok: false, reason: 'count', maxPerMessage: 10 });
assert.equal(checkAttachment({ mimeType: 'image/png', bytes: 10 }, { onMessage: 9 }).ok, true);
});
test('the quota counts what is already stored, and says how much that is', () => {
const quota = DEFAULT_ATTACHMENT_POLICY.quotaBytes;
const over = checkAttachment({ mimeType: 'image/png', bytes: 2 * MB }, { usedBytes: quota - MB });
assert.deepEqual(over, {
ok: false,
reason: 'quota',
quotaBytes: quota,
usedBytes: quota - MB,
});
// Exactly filling the quota is allowed; one byte more is not.
assert.equal(
checkAttachment({ mimeType: 'image/png', bytes: MB }, { usedBytes: quota - MB }).ok,
true,
);
});
test('a policy with no quota never refuses for room', () => {
const policy = { ...DEFAULT_ATTACHMENT_POLICY, quotaBytes: null };
const check = checkAttachment(
{ mimeType: 'image/png', bytes: MB },
{ usedBytes: Number.MAX_SAFE_INTEGER - 2 * MB },
policy,
);
assert.equal(check.ok, true);
});
test('the wrong type is the answer even when the quota is also full', () => {
// Cheapest-first: a person is told the thing they can actually change.
const check = checkAttachment(
{ mimeType: 'text/html', bytes: MB },
{ usedBytes: DEFAULT_ATTACHMENT_POLICY.quotaBytes },
);
assert.equal(check.reason, 'type');
});
test('stored bytes add up, and a negative size counts for nothing', () => {
assert.equal(storedBytes([]), 0);
assert.equal(storedBytes([{ bytes: 10 }, { bytes: 5 }, { bytes: -3 }]), 15);
});
test('with no retention a sent file is kept as long as its message', () => {
const sentAt = new Date('2026-01-01T00:00:00Z');
assert.equal(attachmentExpiresAt(sentAt), null);
assert.equal(isAttachmentExpired(sentAt, new Date('2036-01-01T00:00:00Z')), false);
});
test('with a retention a sent file expires on the day the policy names', () => {
const policy = { ...DEFAULT_ATTACHMENT_POLICY, retentionDays: 90 };
const sentAt = new Date('2026-01-01T00:00:00Z');
assert.equal(attachmentExpiresAt(sentAt, policy).toISOString(), '2026-04-01T00:00:00.000Z');
assert.equal(isAttachmentExpired(sentAt, new Date('2026-03-31T23:59:59Z'), policy), false);
assert.equal(isAttachmentExpired(sentAt, new Date('2026-04-01T00:00:00Z'), policy), true);
});
test('an upload that was never sent is abandoned after the policy’s hours, not before', () => {
const uploadedAt = new Date('2026-01-01T00:00:00Z');
assert.equal(isAbandonedUpload(uploadedAt, new Date('2026-01-01T23:59:59Z')), false);
assert.equal(isAbandonedUpload(uploadedAt, new Date('2026-01-02T00:00:00Z')), true);
});
+11 -11
View File
@@ -1,13 +1,7 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import {
canRead,
canWrite,
readersOf,
unreadCount,
visibleMessages,
} from '../dist/index.js';
import { canRead, canWrite, readersOf, unreadCount, visibleMessages } from '../dist/index.js';
const T0 = new Date('2026-01-01T09:00:00Z');
const T1 = new Date('2026-01-01T10:00:00Z');
@@ -40,7 +34,7 @@ test('a clinician added later does not see what was said before they joined', ()
const t = thread([patient, drA, drB]);
const messages = [msg('m1', 'patient-1', T1), msg('m2', 'dr-a', T3)];
const seen = visibleMessages(t, 'dr-b', messages).map(m => m.id);
const seen = visibleMessages(t, 'dr-b', messages).map((m) => m.id);
assert.deepEqual(seen, ['m2'], 'history before joining is not granted by default');
});
@@ -55,7 +49,7 @@ test('granting thread-start hands over the whole history, on purpose', () => {
const t = thread([patient, drA, drB]);
const messages = [msg('m1', 'patient-1', T1), msg('m2', 'dr-a', T3)];
const seen = visibleMessages(t, 'dr-b', messages).map(m => m.id);
const seen = visibleMessages(t, 'dr-b', messages).map((m) => m.id);
assert.deepEqual(seen, ['m1', 'm2']);
});
@@ -70,7 +64,10 @@ test('someone who left keeps their history and stops receiving what comes next',
const t = thread([patient, locum]);
const messages = [msg('m1', 'patient-1', T1), msg('m2', 'patient-1', T3)];
assert.deepEqual(visibleMessages(t, 'locum', messages).map(m => m.id), ['m1']);
assert.deepEqual(
visibleMessages(t, 'locum', messages).map((m) => m.id),
['m1'],
);
assert.equal(canWrite(t, 'locum', T3), false, 'a departed participant loses their voice');
assert.equal(canRead(t, 'locum'), true, 'but not what they already saw');
});
@@ -112,5 +109,8 @@ test('a read receipt never implies access the reader does not have', () => {
const early = msg('m1', 'patient-1', T1);
// dr-b's clock says they have read up to T3, but m1 predates their window.
assert.deepEqual(readersOf(t, early).map(p => p.actorId), []);
assert.deepEqual(
readersOf(t, early).map((p) => p.actorId),
[],
);
});
+49
View File
@@ -0,0 +1,49 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { mentionMatcher, mentionsAny } from '../dist/index.js';
test('a handle is matched as a whole word', () => {
assert.equal(mentionsAny('@cat who is right?', ['@cat']), true);
assert.equal(mentionsAny('who is right, @cat?', ['@cat']), true);
assert.equal(mentionsAny('ask @cat', ['@cat']), true);
assert.equal(mentionsAny('@Cat', ['@cat']), true, 'case is ignored');
});
test('a longer handle that starts the same way is somebody else', () => {
assert.equal(mentionsAny('see the @catalogue', ['@cat']), false);
assert.equal(mentionsAny('@cats are great', ['@cat']), false);
assert.equal(mentionsAny('@cat_2', ['@cat']), false);
});
test('an address is not a mention', () => {
assert.equal(mentionsAny('write to me@cat.example', ['@cat']), false);
});
test('a short alias does not fire inside ordinary words', () => {
assert.equal(mentionsAny('I had to wait again', ['ai']), false);
assert.equal(mentionsAny('ask the AI.', ['ai']), true);
});
test('letters outside ASCII are still letters', () => {
// \W would call "ü" a boundary and match "ai" inside "aiü".
assert.equal(mentionsAny('aiü', ['ai']), false);
assert.equal(mentionsAny('über @käthe!', ['@käthe']), true);
});
test('punctuation in an alias is literal', () => {
assert.equal(mentionsAny('ping a.b now', ['a.b']), true);
assert.equal(mentionsAny('ping axb now', ['a.b']), false);
});
test('an empty alias matches nothing', () => {
assert.equal(mentionsAny('anything at all', ['', ' ']), false);
assert.equal(mentionsAny('anything at all', []), false);
});
test('a matcher is reusable', () => {
const mentioned = mentionMatcher(['@cat', 'assistant']);
assert.equal(mentioned('hello assistant'), true);
assert.equal(mentioned('hello @cat'), true);
assert.equal(mentioned('hello'), false);
});
+6 -3
View File
@@ -41,8 +41,8 @@ test('messages sharing a timestamp keep a stable order', () => {
const a = { id: 'b', threadId: 't1', authorId: 'x', body: 'a', createdAt: T1 };
const b = { id: 'a', threadId: 't1', authorId: 'x', body: 'b', createdAt: T1 };
const once = mergeMessages([a, b], []).map(m => m.id);
const twice = mergeMessages([b, a], []).map(m => m.id);
const once = mergeMessages([a, b], []).map((m) => m.id);
const twice = mergeMessages([b, a], []).map((m) => m.id);
assert.deepEqual(once, twice, 'insertion order must not change what the user sees');
assert.deepEqual(once, ['a', 'b']);
});
@@ -51,7 +51,10 @@ test('merging is ordered by time, not by arrival', () => {
const late = { id: 'm2', threadId: 't1', authorId: 'x', body: 'second', createdAt: T2 };
const early = { id: 'm1', threadId: 't1', authorId: 'x', body: 'first', createdAt: T1 };
assert.deepEqual(mergeMessages([late], [early]).map(m => m.id), ['m1', 'm2']);
assert.deepEqual(
mergeMessages([late], [early]).map((m) => m.id),
['m1', 'm2'],
);
});
test('a pending message is distinguishable from a confirmed one', () => {
+20 -10
View File
@@ -20,17 +20,27 @@ import { join } from 'node:path';
*/
const PUBLIC_API = [
'DEFAULT_ATTACHMENT_POLICY',
'afterEveryMessage',
'attachmentExpiresAt',
'attachmentKind',
'canRead',
'canSeeMessage',
'canWrite',
'checkAttachment',
'compareMessages',
'defaultRespondPolicy',
'findParticipant',
'isAbandonedUpload',
'isAttachmentExpired',
'isPending',
'mentionMatcher',
'mentionsAny',
'mergeMessages',
'readState',
'readersOf',
'runAiTurn',
'storedBytes',
'unreadCount',
'unreadMessages',
'unreadThreadCount',
@@ -45,14 +55,14 @@ let probe;
before(() => {
workspace = mkdtempSync(join(tmpdir(), 'threadkit-pack-'));
installed = join(workspace, 'node_modules', 'threadkit');
installed = join(workspace, 'node_modules', '@bitbaum/threadkit');
mkdirSync(installed, { recursive: true });
execFileSync('npm', ['pack', '--silent', '--pack-destination', workspace], {
cwd: process.cwd(),
stdio: ['ignore', 'ignore', 'inherit'],
});
const tarball = readdirSync(workspace).find(f => f.endsWith('.tgz'));
const tarball = readdirSync(workspace).find((f) => f.endsWith('.tgz'));
assert.ok(tarball, 'npm pack produced no tarball');
execFileSync('tar', ['-xzf', join(workspace, tarball), '-C', installed, '--strip-components=1']);
@@ -64,26 +74,26 @@ before(() => {
join(workspace, 'probe.mjs'),
[
'const out = {};',
'try { out.resolved = import.meta.resolve("threadkit"); } catch { out.resolved = null; }',
'try { out.exports = Object.keys(await import("threadkit")).sort(); } catch { out.exports = null; }',
'try { out.resolved = import.meta.resolve("@bitbaum/threadkit"); } catch { out.resolved = null; }',
'try { out.exports = Object.keys(await import("@bitbaum/threadkit")).sort(); } catch { out.exports = null; }',
'console.log(JSON.stringify(out));',
].join('\n')
].join('\n'),
);
probe = JSON.parse(
execFileSync('node', [join(workspace, 'probe.mjs')], {
cwd: workspace,
encoding: 'utf8',
})
}),
);
});
test('the package resolves from a consumer install', () => {
assert.ok(probe.resolved, '"threadkit" did not resolve through its own exports map');
assert.ok(probe.resolved, '"@bitbaum/threadkit" did not resolve through its own exports map');
});
test('the entry point exposes its whole public API', () => {
assert.ok(probe.exports, 'importing "threadkit" from a consumer install threw');
assert.ok(probe.exports, 'importing "@bitbaum/threadkit" from a consumer install threw');
for (const name of PUBLIC_API) {
assert.ok(probe.exports.includes(name), `"${name}" is missing from the published entry point`);
}
@@ -94,12 +104,12 @@ test('the type declarations it advertises are actually in the tarball', () => {
execFileSync('node', ['-p', 'JSON.stringify(require("./package.json"))'], {
cwd: installed,
encoding: 'utf8',
})
}),
);
const types = pkg.exports['.'].types;
assert.ok(
existsSync(join(installed, types)),
`the package advertises types at ${types}, which is not in the tarball`
`the package advertises types at ${types}, which is not in the tarball`,
);
});
+110
View File
@@ -0,0 +1,110 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { mergeMessages, readState, unreadMessages, visibleMessages } from '../dist/index.js';
const T0 = new Date('2026-01-01T09:00:00Z');
const T1 = new Date('2026-01-01T10:00:00Z');
const T2 = new Date('2026-01-01T11:00:00Z');
const person = (actorId, extra = {}) => ({
actorId,
kind: 'human',
joinedAt: T0,
visibleFrom: 'thread-start',
...extra,
});
const message = { id: 'm1', threadId: 't1', authorId: 'ada', body: 'hello', createdAt: T1 };
test('nobody else has read it yet', () => {
const thread = { id: 't1', createdAt: T0, participants: [person('ada'), person('ben')] };
const state = readState(thread, message);
assert.equal(state.state, 'none');
assert.equal(state.audience, 1);
});
test('read by the only other person is read by all', () => {
const thread = {
id: 't1',
createdAt: T0,
participants: [person('ada'), person('ben', { lastReadAt: T2 })],
};
assert.equal(readState(thread, message).state, 'all');
});
test('in a group, one reader of two is some, not all', () => {
const thread = {
id: 't1',
createdAt: T0,
participants: [person('ada'), person('ben', { lastReadAt: T2 }), person('cy')],
};
const state = readState(thread, message);
assert.equal(state.state, 'some');
assert.deepEqual(
state.readers.map((p) => p.actorId),
['ben'],
);
assert.equal(state.audience, 2);
});
test('an assistant in the room does not hold a message at unread', () => {
const thread = {
id: 't1',
createdAt: T0,
participants: [
person('ada'),
person('ben', { lastReadAt: T2 }),
{ actorId: 'cat', kind: 'ai', joinedAt: T0, visibleFrom: 'thread-start' },
],
};
const state = readState(thread, message);
assert.equal(state.state, 'all');
assert.equal(state.audience, 1);
});
test('somebody who left is not waited for', () => {
const thread = {
id: 't1',
createdAt: T0,
participants: [person('ada'), person('ben', { lastReadAt: T2 }), person('cy', { leftAt: T2 })],
};
assert.equal(readState(thread, message).state, 'all');
});
test('a message nobody else can see has no audience and no readers', () => {
const thread = {
id: 't1',
createdAt: T0,
participants: [person('ada'), person('ben', { visibleFrom: T2, lastReadAt: T2 })],
};
const state = readState(thread, message);
assert.equal(state.state, 'none');
assert.equal(state.audience, 0);
});
test('rows that carry more than the package knows come back as they were', () => {
// The generic signatures: a consumer's own fields survive every function.
const thread = { id: 't1', createdAt: T0, participants: [person('ada'), person('ben')] };
const rich = { ...message, senderName: 'Ada', attachments: [] };
const [merged] = mergeMessages([], [rich]);
assert.equal(merged.senderName, 'Ada');
assert.equal(visibleMessages(thread, 'ben', [rich])[0].senderName, 'Ada');
assert.equal(unreadMessages(thread, 'ben', [rich])[0].senderName, 'Ada');
});
test('a message of only files is a message', () => {
const thread = { id: 't1', createdAt: T0, participants: [person('ada'), person('ben')] };
const photo = {
id: 'm2',
threadId: 't1',
authorId: 'ada',
body: '',
createdAt: T1,
attachments: [
{ id: 'a1', kind: 'image', name: 'cat.jpg', mimeType: 'image/jpeg', bytes: 1200 },
],
};
assert.equal(unreadMessages(thread, 'ben', [photo]).length, 1);
assert.equal(visibleMessages(thread, 'ben', [photo])[0].attachments[0].name, 'cat.jpg');
});
+9 -5
View File
@@ -41,8 +41,8 @@ test('a participant who has never read owes every visible message from someone e
const messages = [msg('m1', 'patient-1', T1), msg('m2', 'patient-1', T2)];
assert.deepEqual(
unreadMessages(thread, 'dr-a', messages).map(m => m.id),
['m1', 'm2']
unreadMessages(thread, 'dr-a', messages).map((m) => m.id),
['m1', 'm2'],
);
});
@@ -55,14 +55,14 @@ test('unread never reaches back past the day you joined', () => {
assert.equal(
unreadCount(thread, 'dr-b', messages),
0,
'a message from before dr-b joined is not theirs to owe'
'a message from before dr-b joined is not theirs to owe',
);
});
test('the nav badge counts threads that want you, not messages to read', () => {
const me = { actorId: 'me', kind: 'human', joinedAt: T0, lastReadAt: null };
const other = { actorId: 'other', kind: 'human', joinedAt: T0 };
const mk = id => ({ id, participants: [me, other], createdAt: T0 });
const mk = (id) => ({ id, participants: [me, other], createdAt: T0 });
const entries = [
{
@@ -75,5 +75,9 @@ test('the nav badge counts threads that want you, not messages to read', () => {
{ thread: mk('t2'), messages: [] },
];
assert.equal(unreadThreadCount(entries, 'me'), 1, 'two unread messages in one thread is one badge');
assert.equal(
unreadThreadCount(entries, 'me'),
1,
'two unread messages in one thread is one badge',
);
});