mirror of
https://github.com/bitbaum/threadkit.git
synced 2026-12-04 06:17:31 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9008c180c0 | ||
|
|
d944eaf3aa | ||
|
|
234d424707 | ||
|
|
2f5acf54e4 | ||
|
|
5f39ada053 | ||
|
|
cb2a422317 | ||
|
|
7740fc63f0 | ||
|
|
b586a9ea08 | ||
|
|
c039905b28 | ||
|
|
bbb3d6a014 | ||
|
|
70ffefca62 | ||
|
|
ca551c205d | ||
|
|
63d6afcfda | ||
|
|
bfb969cb5b | ||
|
|
8d2ef7f9a4 | ||
|
|
90ee7b1fb1 | ||
|
|
162bf52eca | ||
|
|
a4a450f3c4 | ||
|
|
b4636d5263 | ||
|
|
f7a8c04a27 | ||
|
|
7ccc759bb1 | ||
|
|
997b65e2e4 | ||
|
|
8508451596 | ||
|
|
31099dcab8 | ||
|
|
e59f7a2383 | ||
|
|
6e61fd79c0 | ||
|
|
a6036b4912 | ||
|
|
90672b2759 | ||
|
|
6b9cef3e25 | ||
|
|
6ac2b19818 | ||
|
|
7d6902454f | ||
|
|
4ee72a7013 | ||
|
|
d6151ddb41 | ||
|
|
65a56148f2 | ||
|
|
4bb266ca88 | ||
|
|
714b0da614 | ||
|
|
dbc607d7d8 | ||
|
|
f0fd2d12c6 | ||
|
|
b53fbf0e15 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Bulk reformats. `git config blame.ignoreRevsFile .git-blame-ignore-revs`
|
||||
6e12c84d059bb4f261a25a27a57c44e58f658bca # prettier, 12 files
|
||||
@@ -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
|
||||
@@ -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 }}
|
||||
@@ -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
|
||||
@@ -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
|
||||
+202
-46
@@ -1,82 +1,238 @@
|
||||
# prettier-ignore
|
||||
name: Publish
|
||||
|
||||
# Releasing is not a thing anyone does. Merge a version bump to main and the
|
||||
# package ships: this workflow asks the registry whether package.json's version
|
||||
# already exists, and publishes it if not.
|
||||
# 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.
|
||||
#
|
||||
# Why that check rather than a tag trigger: a tag pushed by GITHUB_TOKEN does
|
||||
# not start another workflow, so "push a tag, let publish.yml notice" silently
|
||||
# never runs. Asking npm what is published is also idempotent — re-running this,
|
||||
# or pushing a tag by hand, cannot double-publish or fail confusingly.
|
||||
# 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*"]
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
# The reconciler, and the reason this is reliable. A merge made by auto-merge
|
||||
# uses GITHUB_TOKEN, and a push with that token starts no workflow — so the
|
||||
# push trigger above silently does not fire for exactly the merges that matter.
|
||||
# The schedule asks the registry the same idempotent question on a timer: is
|
||||
# package.json's version published? If a release was missed by any means, it
|
||||
# goes out within the hour without anyone noticing it was missed.
|
||||
schedule:
|
||||
- cron: '43 * * * *'
|
||||
# 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:
|
||||
# Tagging the released commit, so a version on the registry can always be
|
||||
# traced back to the tree it was built from.
|
||||
# write: tag the released commit v<version> when the release came from
|
||||
# main rather than from a pushed tag.
|
||||
contents: write
|
||||
# npm provenance: proves on the registry that this tarball was built by
|
||||
# this workflow from this commit.
|
||||
# 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
|
||||
|
||||
- name: Is this version already on the registry?
|
||||
# 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 "→ $name@$version is already published; nothing to do."
|
||||
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "→ $name@$version is not on the registry; releasing it."
|
||||
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: npm ci --ignore-scripts
|
||||
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.
|
||||
- if: steps.check.outputs.publish == 'true'
|
||||
run: npm run verify
|
||||
run: pnpm run verify
|
||||
|
||||
# Auth is trusted publishing (OIDC): npm accepts this job's identity token
|
||||
# because the package's Trusted Publisher is pinned to exactly this repo
|
||||
# and workflow. No npm token exists anywhere, so none can leak or expire.
|
||||
- if: steps.check.outputs.publish == 'true'
|
||||
run: npm publish
|
||||
# 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")
|
||||
if [ "$tag" != "$pkg" ]; then
|
||||
echo "Tag v$tag does not match package.json version $pkg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Tag the released commit
|
||||
- name: Publish to npm
|
||||
if: steps.check.outputs.publish == 'true'
|
||||
env:
|
||||
TAG: v${{ steps.check.outputs.version }}
|
||||
NAME: ${{ steps.check.outputs.name }}
|
||||
VERSION: ${{ steps.check.outputs.version }}
|
||||
MODE: ${{ steps.check.outputs.mode }}
|
||||
FIRST_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }}
|
||||
run: |
|
||||
# Tag after a successful publish, so a tag never claims a release that
|
||||
# did not happen. Skipped silently if it already exists.
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "→ tag $TAG already exists"
|
||||
else
|
||||
git tag "$TAG"
|
||||
git push origin "$TAG"
|
||||
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
|
||||
@@ -0,0 +1,69 @@
|
||||
# The release a package merged is told to the fleet once its tag exists.
|
||||
#
|
||||
# release-notify.yml asks on CI's completion. When a version bump is merged
|
||||
# by pull request (how ai-kit and chatkit ship), git-release.yml starts on
|
||||
# that same completion and creates the tag a few seconds later, so the notice
|
||||
# found no tag and stood down. Publish, which finishes after the tag, cannot
|
||||
# repeat it: a run started by GITHUB_TOKEN chains no further. ai-kit 1.26,
|
||||
# 1.27 and 1.28 (12-13 Nov 2026) all reached the fleet only on its six-hourly
|
||||
# schedule. This file asks again when the tag workflow finishes: by then the
|
||||
# tag exists. CI -> Verified Git release -> this is three levels, which
|
||||
# GitHub allows. The step below is release-notify.yml's, byte for byte
|
||||
# (scripts/packages/test-release-notify.mjs holds them equal); a release the
|
||||
# first notice already reported is asked twice, and the fleet resolves
|
||||
# releases itself rather than trusting either notice.
|
||||
# No checkout or execution of the completed workflow's code: metadata only.
|
||||
# prettier-ignore
|
||||
name: Notify Fleet once the release is tagged
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Verified Git release]
|
||||
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.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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -1,83 +0,0 @@
|
||||
name: Token health
|
||||
|
||||
# NPM_TOKEN expires. Without this, the thing that discovers that fact is a
|
||||
# release failing months from now, at which point someone has to work out why —
|
||||
# an npm auth error does not say "your token expired", it says 403 or ENEEDAUTH,
|
||||
# which reads like a permissions problem.
|
||||
#
|
||||
# So the token is checked on a schedule and the failure is turned into an issue
|
||||
# with the fix written in it, instead of a surprise during a release.
|
||||
on:
|
||||
schedule:
|
||||
# Weekly, Monday 06:00 UTC.
|
||||
- cron: '0 6 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Can the token still authenticate?
|
||||
id: probe
|
||||
continue-on-error: true
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
# `npm whoami` is the cheapest call that proves the credential is live.
|
||||
# It does not publish, and it does not need a package to exist.
|
||||
if who=$(npm whoami 2>&1); then
|
||||
echo "→ token is valid (authenticated as $who)"
|
||||
echo "ok=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "→ token did NOT authenticate: $who"
|
||||
echo "ok=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Open an issue if the token is dead
|
||||
if: steps.probe.outputs.ok != 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const title = 'NPM_TOKEN cannot authenticate — releases are blocked';
|
||||
// One open issue, not one per week.
|
||||
const existing = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner, repo: context.repo.repo,
|
||||
state: 'open', labels: 'release-blocked',
|
||||
});
|
||||
if (existing.data.some(i => i.title === title)) {
|
||||
core.info('issue already open');
|
||||
return;
|
||||
}
|
||||
await github.rest.issues.create({
|
||||
owner: context.repo.owner, repo: context.repo.repo,
|
||||
title,
|
||||
labels: ['release-blocked'],
|
||||
body: [
|
||||
'`npm whoami` failed with the `NPM_TOKEN` secret, so **publishing is broken**.',
|
||||
'Nothing is wrong with the package — the credential is.',
|
||||
'',
|
||||
'Most likely the token expired. npm tokens are created with an expiry,',
|
||||
'and an expired one fails with `403`/`ENEEDAUTH`, which reads like a',
|
||||
'permissions problem rather than an expiry.',
|
||||
'',
|
||||
'**Two ways to fix it, cheapest first:**',
|
||||
'',
|
||||
'1. **Configure trusted publishing and delete the token entirely.**',
|
||||
' npmjs.com → this package → Settings → Trusted Publisher →',
|
||||
' GitHub Actions → this org/repo → `publish.yml` → allow `npm publish`.',
|
||||
' Then remove the `NODE_AUTH_TOKEN` line from `publish.yml`.',
|
||||
' Tokens stop existing, so they stop expiring.',
|
||||
' https://docs.npmjs.com/trusted-publishers',
|
||||
'',
|
||||
'2. Create a new granular token and re-set the secret:',
|
||||
' `gh secret set NPM_TOKEN --repo ' + context.repo.owner + '/' + context.repo.repo + '`',
|
||||
' (the secret NAME is `NPM_TOKEN`; the token itself is pasted at the prompt)',
|
||||
].join('\n'),
|
||||
});
|
||||
@@ -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
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "all",
|
||||
"arrowParens": "always",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
@@ -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`.
|
||||
@@ -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,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
@@ -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 } },
|
||||
},
|
||||
)
|
||||
);
|
||||
Generated
-1531
File diff suppressed because it is too large.
Load diff
+19
-14
@@ -1,30 +1,32 @@
|
||||
{
|
||||
"name": "threadkit",
|
||||
"version": "0.1.1",
|
||||
"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.10.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.68.0"
|
||||
}
|
||||
}
|
||||
Generated
+901
@@ -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.10.0
|
||||
version: 3.10.0
|
||||
typescript:
|
||||
specifier: ^6.0.3
|
||||
version: 6.0.3
|
||||
typescript-eslint:
|
||||
specifier: ^8.68.0
|
||||
version: 8.72.2(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.2':
|
||||
resolution: {integrity: sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
'@typescript-eslint/parser': ^8.72.2
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/parser@8.72.2':
|
||||
resolution: {integrity: sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==}
|
||||
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.2':
|
||||
resolution: {integrity: sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==}
|
||||
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.2':
|
||||
resolution: {integrity: sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript-eslint/tsconfig-utils@8.72.2':
|
||||
resolution: {integrity: sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==}
|
||||
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.2':
|
||||
resolution: {integrity: sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==}
|
||||
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.2':
|
||||
resolution: {integrity: sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript-eslint/typescript-estree@8.72.2':
|
||||
resolution: {integrity: sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/utils@8.72.2':
|
||||
resolution: {integrity: sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==}
|
||||
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.2':
|
||||
resolution: {integrity: sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==}
|
||||
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.10.0:
|
||||
resolution: {integrity: sha512-mBi4765LgjO1PFjlEs7pUeK0nb1bw71c+N4/ItfeUWNdY5cV2pRKaFpbbFRYmDJMO+5ZwzGxHRqHxFZna7iv5w==}
|
||||
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.2:
|
||||
resolution: {integrity: sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==}
|
||||
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.2(@typescript-eslint/parser@8.72.2(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.2(eslint@10.14.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/scope-manager': 8.72.2
|
||||
'@typescript-eslint/type-utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
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.2(eslint@10.14.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 8.72.2
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
debug: 4.4.3
|
||||
eslint: 10.14.0
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/project-service@8.72.2(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
debug: 4.4.3
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/scope-manager@8.72.2':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
|
||||
'@typescript-eslint/tsconfig-utils@8.72.2(typescript@6.0.3)':
|
||||
dependencies:
|
||||
typescript: 6.0.3
|
||||
|
||||
'@typescript-eslint/type-utils@8.72.2(eslint@10.14.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(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.2': {}
|
||||
|
||||
'@typescript-eslint/typescript-estree@8.72.2(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/project-service': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
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.2(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.2
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3)
|
||||
eslint: 10.14.0
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/visitor-keys@8.72.2':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
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.10.0: {}
|
||||
|
||||
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.2(eslint@10.14.0)(typescript@6.0.3):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.14.0)(typescript@6.0.3))(eslint@10.14.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.14.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(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: {}
|
||||
@@ -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' };
|
||||
|
||||
@@ -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
@@ -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';
|
||||
@@ -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
@@ -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
@@ -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 };
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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'));
|
||||
});
|
||||
|
||||
@@ -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
@@ -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),
|
||||
[],
|
||||
);
|
||||
});
|
||||
@@ -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
@@ -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
@@ -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`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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
@@ -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',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user