@ultimat3/cli 31.25.0 → 31.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -29
- package/src/cmd-db-recount.ts +7 -0
- package/src/dispatch.ts +6 -1
- package/src/generate-factories.ts +4 -0
- package/wiki/Agents.md +2 -5
- package/wiki/Interface-Rules.md +5 -0
- package/wiki/MCP-And-AI.md +102 -1
- package/wiki/Mail.md +52 -0
- package/wiki/Scraping.md +19 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.26.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.26.0",
|
|
57
|
+
"@ultimat3/admin": "31.26.0",
|
|
58
|
+
"@ultimat3/ai": "31.26.0",
|
|
59
|
+
"@ultimat3/auth": "31.26.0",
|
|
60
|
+
"@ultimat3/cache": "31.26.0",
|
|
61
|
+
"@ultimat3/core": "31.26.0",
|
|
62
|
+
"@ultimat3/db": "31.26.0",
|
|
63
|
+
"@ultimat3/entity": "31.26.0",
|
|
64
|
+
"@ultimat3/flags": "31.26.0",
|
|
65
|
+
"@ultimat3/http": "31.26.0",
|
|
66
|
+
"@ultimat3/i18n": "31.26.0",
|
|
67
|
+
"@ultimat3/jobs": "31.26.0",
|
|
68
|
+
"@ultimat3/mail": "31.26.0",
|
|
69
|
+
"@ultimat3/manifest": "31.26.0",
|
|
70
|
+
"@ultimat3/mcp": "31.26.0",
|
|
71
|
+
"@ultimat3/money": "31.26.0",
|
|
72
|
+
"@ultimat3/notify": "31.26.0",
|
|
73
|
+
"@ultimat3/policy": "31.26.0",
|
|
74
|
+
"@ultimat3/pwa": "31.26.0",
|
|
75
|
+
"@ultimat3/query": "31.26.0",
|
|
76
|
+
"@ultimat3/realtime": "31.26.0",
|
|
77
|
+
"@ultimat3/render": "31.26.0",
|
|
78
|
+
"@ultimat3/schema": "31.26.0",
|
|
79
|
+
"@ultimat3/scraping": "31.26.0",
|
|
80
|
+
"@ultimat3/seo": "31.26.0",
|
|
81
|
+
"@ultimat3/storage": "31.26.0",
|
|
82
|
+
"@ultimat3/testing": "31.26.0",
|
|
83
|
+
"@ultimat3/time": "31.26.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/cmd-db-recount.ts
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
import { finiteCount } from '@ultimat3/core';
|
|
7
7
|
import type { CounterDescriptionLike, DbClient } from '@ultimat3/db';
|
|
8
8
|
import {
|
|
9
|
+
baseClient,
|
|
9
10
|
CROSS_TENANT_SETTING,
|
|
11
|
+
dbClientInstalled,
|
|
10
12
|
recountBatchSql,
|
|
11
13
|
recountDriftBatchSql,
|
|
12
14
|
recountLockSql,
|
|
13
15
|
recountWindowSql,
|
|
16
|
+
setDbClient,
|
|
14
17
|
setLocal,
|
|
15
18
|
withTransaction,
|
|
16
19
|
} from '@ultimat3/db';
|
|
@@ -153,6 +156,9 @@ async function recount(ctx: CommandContext, root: string): Promise<CommandResult
|
|
|
153
156
|
});
|
|
154
157
|
}
|
|
155
158
|
}
|
|
159
|
+
// `startDb` installs its client as the process's `db()`, and this command closes it: what was
|
|
160
|
+
// there before goes back (`undefined`: lazy construction), as `db-diagnostics.ts` does.
|
|
161
|
+
const previous = dbClientInstalled() ? baseClient() : undefined;
|
|
156
162
|
const started = startDb(services, ctx.env);
|
|
157
163
|
try {
|
|
158
164
|
const report = await recountInBatches(started.client, parent.$table, counter, { write });
|
|
@@ -186,6 +192,7 @@ async function recount(ctx: CommandContext, root: string): Promise<CommandResult
|
|
|
186
192
|
},
|
|
187
193
|
};
|
|
188
194
|
} finally {
|
|
195
|
+
setDbClient(previous);
|
|
189
196
|
await started.client.close();
|
|
190
197
|
await started.replica?.close();
|
|
191
198
|
}
|
package/src/dispatch.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// why: a synchronous bin probe at the one place a result is rendered; Bun has no path helpers.
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
8
|
-
import { setLogStream } from '@ultimat3/core';
|
|
8
|
+
import { currentLogStream, setLogStream } from '@ultimat3/core';
|
|
9
9
|
import { requireAppRoot, requireBunVersion } from './app-root';
|
|
10
10
|
import { createHelpCommand } from './cmd-help';
|
|
11
11
|
import { plannedCommandError, plannedCommandFor } from './cmd-planned';
|
|
@@ -166,6 +166,9 @@ export async function dispatch(options: DispatchOptions): Promise<number> {
|
|
|
166
166
|
...(options.invocation === undefined ? {} : { invocation: options.invocation }),
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
// Put back in the `finally`: the stream is process-wide, so a dispatch that left `stderr` behind
|
|
170
|
+
// moved every later line of an embedding process — the next test file's, on a shared worker.
|
|
171
|
+
const callerStream = currentLogStream();
|
|
169
172
|
try {
|
|
170
173
|
// `--json` means fd 1 carries ONE document, and every command that boots an app logs through
|
|
171
174
|
// core's module-scope `logger`, whose default writer is stdout: `x db migrate --json` printed
|
|
@@ -197,5 +200,7 @@ export async function dispatch(options: DispatchOptions): Promise<number> {
|
|
|
197
200
|
const result = errorResult(args.command, error);
|
|
198
201
|
sinkFor(result, options)(render(result, args.json, false, reader));
|
|
199
202
|
return 1;
|
|
203
|
+
} finally {
|
|
204
|
+
setLogStream(callerStream);
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -123,6 +123,10 @@ export const FACTORY_GENERATORS: readonly FactoryGenerator[] = [
|
|
|
123
123
|
none: 'one signed delivery to an endpoint the app stores, with its ledger; deferred (plan 101 U6) until x g plants the endpoint table and the ledger it needs',
|
|
124
124
|
},
|
|
125
125
|
{ factory: 'webhookReceiver', generator: 'webhook-receiver' },
|
|
126
|
+
{
|
|
127
|
+
factory: 'inboundMail',
|
|
128
|
+
none: 'a receiver over a provider the app has an account with — which provider, its secret and where a message goes are choices x g cannot read off the disk; the wiki Mail page has the one call to paste',
|
|
129
|
+
},
|
|
126
130
|
];
|
|
127
131
|
|
|
128
132
|
/** `x g llm` or `x g agent-job`: the factory a word names, when it is one no generator writes. */
|
package/wiki/Agents.md
CHANGED
|
@@ -414,11 +414,8 @@ export const kbAgent = agent({
|
|
|
414
414
|
| `openAiProvider()` | any other `baseUrl` | any | none | nowhere |
|
|
415
415
|
|
|
416
416
|
**Your own endpoint is a row on its provider**, read before the table, first match by model prefix
|
|
417
|
-
(`As of 2026-11`):
|
|
418
|
-
|
|
419
|
-
for a proxy that rejects `cache_control`. The budget's estimate follows the row. A mark or session
|
|
420
|
-
carrier the wire cannot speak — `parts` or a session on the Messages wire, `blocks` on
|
|
421
|
-
chat-completions — is `X_AI_REQUEST_INVALID` when the provider is built.
|
|
417
|
+
(`As of 2026-11`): the rule shapes, the order and the refusal are in
|
|
418
|
+
[MCP and AI](MCP-And-AI#prompt-caching-on-your-own-endpoint). The budget's estimate follows the row.
|
|
422
419
|
|
|
423
420
|
| Rule | Detail |
|
|
424
421
|
|---|---|
|
package/wiki/Interface-Rules.md
CHANGED
|
@@ -150,6 +150,9 @@ can see.
|
|
|
150
150
|
| An icon with no `label` is decorative and hidden | `Icon` emits `aria-hidden="true"` unless given one |
|
|
151
151
|
| A live region exists before the message does | `AppShell` renders both `liveRegionAttrs` regions into the server response |
|
|
152
152
|
| One announcement path per message: `announce()` for a state change with no surface, a toast for a notification | **judgement** — two paths make a screen reader read it twice |
|
|
153
|
+
| A listbox, option, menuitem or treeitem is named, and by its OWN name: a tree branch never by its loading text, an option never by its description (`aria-describedby`), an open listbox by the field's own `<label>`s | `components/a11y-roles.test.ts`; Chrome's accessibility tree in `ui-a11y-roles.e2e.test.ts` |
|
|
154
|
+
| Nothing a Tab lands on is a nameless box: a `Table`'s scroll stop is a region named with its caption | `components/a11y-roles.test.ts` (every component that sets a `tabindex`) |
|
|
155
|
+
| Tab or Escape from an open `Menu` closes it, focus back on the trigger (the APG menu button) | `components/a11y-roles.test.ts`, `ui-a11y-roles.e2e.test.ts` |
|
|
153
156
|
| Text meets 4.5:1 and the focus ring 3:1, in **both** themes | `packages/ui/src/tokens/contrast.test.ts`, `x verify`'s `unit` step. Shipped pairings only |
|
|
154
157
|
|
|
155
158
|
**No ARIA is better than bad ARIA** — the WAI-ARIA Authoring Practices Guide's own line, and the
|
|
@@ -237,6 +240,8 @@ them: [Testing](Testing#seeing-what-you-built).
|
|
|
237
240
|
| A drag is Pointer Events with capture from a handle; never HTML5 drag events | `drag/pointer-drag.ts` is the one gesture; `ui-drag.e2e.test.ts` (keyboard, pointer, rtl) |
|
|
238
241
|
| A drop is a request: `onMove` once, the row held until it settles, a rejection restores and is announced | `sort-controller.test.ts`, `drag-interaction.test.ts` |
|
|
239
242
|
| Reordering works by keyboard alone and with scripting off | Space/arrows/Esc in `drag-interaction.test.ts`; the per-row `<form>` in `posts/board/page.test.ts` |
|
|
243
|
+
| Only the handle and a separator refuse the browser's pan, so a phone page still scrolls from a card's body | a REAL finger (`E2eTab.touchDrag`) in `ui-drag-touch.e2e.test.ts`: the handle moves a card across columns, the separator resizes, a body drag scrolls and is cancelled with no lift |
|
|
244
|
+
| A drag survives its row moving lists under the pointer | `pointer-drag.ts` takes back a capture the move released; `pointer-drag-bind.test.ts`, and the finger drag above |
|
|
240
245
|
| A business rule on a drop is `canDrop`, never a fork | **judgement** — the one seam the components take |
|
|
241
246
|
| Text a model or member wrote renders as a tree, never HTML; only http/https/mailto/relative links | `viewers-no-html.test.ts`, `markdown-parse.test.ts`, no alert under CSP in `ui-viewers.e2e.test.ts` |
|
|
242
247
|
| A remote image in a body is a link to its alt unless `resolveImage` reserves its box | `viewers.test.ts` |
|
package/wiki/MCP-And-AI.md
CHANGED
|
@@ -639,7 +639,8 @@ export const summarize = llm({
|
|
|
639
639
|
| Caching | semantic cache from [Caching and invalidation](Caching-And-Invalidation) |
|
|
640
640
|
| Provider prompt caching | the provider keeps a request's stable prefix; on by default for `agent()`, off for `llm()` → [Agents](Agents#provider-prompt-caching) |
|
|
641
641
|
| Tracing | one OTel span per call with model, tokens, cache hit, prompt version |
|
|
642
|
-
| Fallback | ordered provider list per model; the provider that answered is on the span as `gen_ai.provider.name`, never silent. A refusal names a more capable model for the declaration to adopt —
|
|
642
|
+
| Fallback | ordered provider list per model; the provider that answered is on the span as `gen_ai.provider.name`, never silent. Across models only through a declared `fallbackModels` chain → [Model fallback](#model-fallback-fallbackmodels). A refusal names a more capable model for the declaration to adopt — never an automatic swap |
|
|
643
|
+
| Provider parameters | `providerOptions: { openai: { top_p: 0.9 } }` — one bag per wire, keys screened → [Provider parameters](#provider-parameters-provideroptions) |
|
|
643
644
|
| Money | `Money = { minor, currency }` — never a float → [Money](Money) |
|
|
644
645
|
|
|
645
646
|
**A stream is the same action over a different transport, with one difference that is forced rather than chosen: there is no repair turn.** The non-streaming call retries once on a parse failure; a stream cannot, because the tokens are already on the reader's screen and a second answer is two answers to one question. So a stream yields **unvalidated** text increments plus one final `done` carrying the value that did satisfy `output`, and a schema disagreement is `X_LLM_STREAM_INVALID` naming the non-streaming call as the fix. A structured schema wants the non-streaming call.
|
|
@@ -664,6 +665,106 @@ and usage records are `JsonView`; a model's proposed edit against the original i
|
|
|
664
665
|
|
|
665
666
|
Long or multi-call chains are `job`s with steps, so a model call that fails on step 4 retries step 4 only. See [Jobs and workflows](Jobs-And-Workflows).
|
|
666
667
|
|
|
668
|
+
### Model fallback: `fallbackModels`
|
|
669
|
+
|
|
670
|
+
**A second model is asked only when the first fails with a declared class, and only because the
|
|
671
|
+
declaration named it** — on `llm()`, on `agent()` (every turn walks the chain; a run's own
|
|
672
|
+
`model()` pick is left out of it), or on a raw `GenerateRequest`. `As of 2026-11`.
|
|
673
|
+
|
|
674
|
+
```ts
|
|
675
|
+
import { definePrompt, llm, t } from '@ultimat3/ai';
|
|
676
|
+
import { allow } from '@ultimat3/policy';
|
|
677
|
+
|
|
678
|
+
const digestPrompt = definePrompt<{ postId: string }>({
|
|
679
|
+
id: 'digest',
|
|
680
|
+
version: '1.0.0',
|
|
681
|
+
template: 'Summarise post {{postId}} in one sentence.',
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
export const digest = llm({
|
|
685
|
+
model: 'claude-sonnet-5-5',
|
|
686
|
+
fallbackModels: ['gpt-5.6-terra'], // tried in order; each one registerModel-ed
|
|
687
|
+
providerOptions: { openai: { top_p: 0.9 } }, // read only by a chat-completions provider
|
|
688
|
+
input: t.object({ postId: t.uuid }),
|
|
689
|
+
output: t.object({ summary: t.string }),
|
|
690
|
+
prompt: digestPrompt,
|
|
691
|
+
vars: ({ input }) => ({ postId: input.postId }),
|
|
692
|
+
policy: allow(),
|
|
693
|
+
});
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
| Falls over (`MODEL_FALLBACK_ON`) | Read from |
|
|
697
|
+
|---|---|
|
|
698
|
+
| `rate_limited` | 429 |
|
|
699
|
+
| `overloaded` | 529 |
|
|
700
|
+
| `timeout` | 408, 504, `ETIMEDOUT` |
|
|
701
|
+
| `unavailable` | any other 5xx, a refused or dropped socket, every provider's breaker open |
|
|
702
|
+
|
|
703
|
+
Never on a 4xx, a refusal, a truncation, a budget refusal, an abort, or a model no provider lists:
|
|
704
|
+
each fails the same way on every model. The verdict is reached after the gateway's provider retries
|
|
705
|
+
for that model ran out, and only when **every** failure had a class.
|
|
706
|
+
|
|
707
|
+
| Rule | Detail |
|
|
708
|
+
|---|---|
|
|
709
|
+
| billed per attempt | each model reserves its own estimate and settles on its own; the run meter (`meteredRun`, `meta.billed`) counts a failed model as an `unsettled` attempt, never as free — also when the chain's last model fails outside the class and that error is thrown as it stands |
|
|
710
|
+
| priced per model | a fallback's answer is billed at its own model's rate, never folded into the primary's; `onCall` / `onTurn` name the model that answered |
|
|
711
|
+
| one trace | the caller's span is the one parent; each model is an `ai.model.attempt` child with `gen_ai.request.model`, `ultimate.llm.fallback.index` and, on failure, `ultimate.llm.fallback.reason`. A call with no chain opens none |
|
|
712
|
+
| visible | `GenerateResult.fallbacks` lists each failed model, its class and cause |
|
|
713
|
+
| streams | fall over only before the first chunk reaches the reader; after it, the failure is thrown as it stands |
|
|
714
|
+
| the chain | screened before any request: an unregistered id is `X_AI_MODEL_UNKNOWN`, a repeated one `X_AI_REQUEST_INVALID` |
|
|
715
|
+
| all fail | one `X_AI_PROVIDER_UNAVAILABLE` naming every model, `a → b` |
|
|
716
|
+
| `retry.timeBudgetMs` | one clock for the whole chain, checked before every call after the first — the next provider, the next model; a call that ran out of time does not fall over |
|
|
717
|
+
|
|
718
|
+
### Provider parameters: `providerOptions`
|
|
719
|
+
|
|
720
|
+
**A wire parameter the framework does not model passes through one typed bag per wire, screened
|
|
721
|
+
key by key before any request.** The keys are the wire's own names. `As of 2026-11`.
|
|
722
|
+
|
|
723
|
+
| Wire | Keys (`PROVIDER_OPTION_KEYS`) |
|
|
724
|
+
|---|---|
|
|
725
|
+
| `anthropic` | `metadata` (`{ user_id }`), `service_tier` (`'auto'`, `'standard_only'`) |
|
|
726
|
+
| `openai` | `frequency_penalty`, `presence_penalty` (-2 to 2), `top_p` (0 to 1), `user`, `parallel_tool_calls`, `service_tier` (`'auto'`, `'default'`, `'flex'`, `'priority'`) |
|
|
727
|
+
|
|
728
|
+
An unknown wire, an unknown key, a wrong type or an out-of-range number is `X_AI_REQUEST_INVALID`:
|
|
729
|
+
at declaration on `llm()` and `agent()`, in the gateway for a raw `generate`/`stream`, and in each body builder for
|
|
730
|
+
a direct provider call. Each provider sends its own wire's bag only, so one request may carry both
|
|
731
|
+
when its `fallbackModels` cross formats. The bag is part of the response cache key. A key the
|
|
732
|
+
framework sets itself (`temperature`, `seed`, `max_tokens`, `tools`, …) is not in the table.
|
|
733
|
+
|
|
734
|
+
## Prompt caching on your own endpoint
|
|
735
|
+
|
|
736
|
+
**An endpoint the built-in table does not name gets no cache mark until its provider declares
|
|
737
|
+
one.** A self-hosted or company gateway speaking the OpenAI format says how it is told on its own
|
|
738
|
+
provider, never in a process-wide registry: the provider already is the wire and the host. `As of
|
|
739
|
+
2026-11`.
|
|
740
|
+
|
|
741
|
+
```ts
|
|
742
|
+
import { openAiProvider } from '@ultimat3/ai';
|
|
743
|
+
|
|
744
|
+
export const internalProvider = openAiProvider({
|
|
745
|
+
baseUrl: 'https://llm.internal.example/v1',
|
|
746
|
+
models: ['family/large'],
|
|
747
|
+
promptCache: { rules: [{ model: 'family/', marks: 'parts', session: 'x-session-id' }] },
|
|
748
|
+
});
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
| Step | What decides the marks for one request |
|
|
752
|
+
|---|---|
|
|
753
|
+
| 1. the provider's rows | `promptCache.rules`, first match by model-id prefix (`''` is every model) |
|
|
754
|
+
| 2. the built-in table | `PROMPT_CACHE_RULES`: any Anthropic Messages endpoint, `openrouter.ai`, `api.openai.com` → [Agents](Agents#provider-prompt-caching) |
|
|
755
|
+
| 3. nothing | no mark and no session field: a field a self-hosted server has never heard of can be a 400 |
|
|
756
|
+
|
|
757
|
+
| Row field | `openAiProvider()` | `anthropicProvider()` |
|
|
758
|
+
|---|---|---|
|
|
759
|
+
| `marks` | `'parts'` (stable system part + the tail message's last part) or `'none'` | `'blocks'` or `'none'` |
|
|
760
|
+
| `session` | `'x-session-id'` header, `'prompt_cache_key'` body field, or `'none'` | `'none'` only |
|
|
761
|
+
|
|
762
|
+
A row the wire cannot speak — `blocks` on chat-completions, `parts` or a session on the Messages
|
|
763
|
+
wire, a row that is not `{ model, marks, session }` — is `X_AI_REQUEST_INVALID` when the provider
|
|
764
|
+
is built, never a 400 on every hinted call. The rows only say *how*; *whether* a call asks is still
|
|
765
|
+
`promptCache` on the declaration (`agent()` `'auto'`, `llm()` `'off'`), and the budget reserves the
|
|
766
|
+
cache-write rate exactly where a mark is sent.
|
|
767
|
+
|
|
667
768
|
## Agents, hives and agent jobs → [Agents](Agents)
|
|
668
769
|
|
|
669
770
|
`llm()` is one model call. A **tool-using loop** is `agent()`, and it is the same kind of thing — an action factory, not a ninth primitive. Everything the loop needs is a factory over a primitive already in the vocabulary:
|
package/wiki/Mail.md
CHANGED
|
@@ -107,6 +107,58 @@ an hour later is not refused by the signature window. Declaring it is its regist
|
|
|
107
107
|
mounts its route. `api/` holds no route file.
|
|
108
108
|
`SES_CONFIGURATION_SET` names the SES configuration set sent on every message (`ConfigurationSetName`) — the set whose event destination publishes to that SNS topic.
|
|
109
109
|
|
|
110
|
+
## Inbound mail: `@ultimat3/mail/inbound`
|
|
111
|
+
|
|
112
|
+
`As of 2026-11-15`. Rule: received email is `inboundMail()`, a factory over
|
|
113
|
+
[`webhookReceiver()`](Jobs-And-Workflows#inbound-webhooks) — never a ninth primitive, never a route
|
|
114
|
+
file. Declared in `defineApi({ jobs })`, the boot mounts its `POST path`.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { inboundMail, resendInbound } from '@ultimat3/mail/inbound';
|
|
118
|
+
|
|
119
|
+
export const supportInbox = inboundMail({
|
|
120
|
+
name: 'support.inbound',
|
|
121
|
+
path: '/hooks/mail/inbound',
|
|
122
|
+
// A thunk, built on the first delivery: every role imports this, only the web role receives.
|
|
123
|
+
provider: () =>
|
|
124
|
+
resendInbound({
|
|
125
|
+
secret: Bun.env['RESEND_INBOUND_SECRET'] ?? '',
|
|
126
|
+
apiKey: Bun.env['RESEND_API_KEY'] ?? '',
|
|
127
|
+
}),
|
|
128
|
+
tenant: 'none',
|
|
129
|
+
handle: async ({ message }) => ({ subject: message.subject }),
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| Step | Where | What |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| verify | the door | the provider's signature over the exact bytes — before any parse. SNS via `sesEventReceiver`'s verifier, Svix via `resendEventReceiver`'s. A forgery is `X_MAIL_EVENT_UNVERIFIED` (401) and queues nothing |
|
|
136
|
+
| queue | the door | the verified envelope (`recipients`, and SES's `content` or Resend's email id), `.sensitive()` |
|
|
137
|
+
| fetch | the job | SES: the row's `content`. Resend: `GET /emails/receiving/:id` with the API key, then the signed `raw.download_url` without it |
|
|
138
|
+
| parse | the job | in-tree, bounded MIME: multipart trees, base64 / quoted-printable, RFC 2047 words, RFC 2231 filenames, address groups |
|
|
139
|
+
| store | the job | each attachment through storage's `validateUpload` (size, allowlist, sniff) and `put`, at a key derived from the message id |
|
|
140
|
+
| handle | the job | your function, with one `InboundMessage`, at least once per `eventId` |
|
|
141
|
+
|
|
142
|
+
| Bound | Default | Refusal |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| `limits.maxBytes` | 10 MiB | `X_MAIL_INBOUND_TOO_LARGE` (`meta.limit`) — refused whole, never truncated |
|
|
145
|
+
| `limits.maxParts` · `maxDepth` | 100 · 8 | the same |
|
|
146
|
+
| `limits.maxAttachments` · `maxHeaderBytes` | 20 · 64 KiB | the same |
|
|
147
|
+
| unreadable MIME | — | `X_MAIL_INBOUND_MALFORMED` (`meta.problem`), terminal |
|
|
148
|
+
|
|
149
|
+
**Sender-controlled, unsanitised:** `html`, every `filename`, every `contentId`, `subject`, the
|
|
150
|
+
address names. Never render `html` on the app's origin (a sandboxed frame, or text); never use a
|
|
151
|
+
`filename` as a path. `recipients` comes from the provider's signed payload, never a header: SES's
|
|
152
|
+
is the SMTP envelope; Resend's is its `to`, not documented as the envelope — route only on your
|
|
153
|
+
own receiving domain. An SES virus verdict of `FAIL` stores no attachment (`refusal: 'verdict'`)
|
|
154
|
+
unless `attachments: { keepOnVirusFail: true }`.
|
|
155
|
+
|
|
156
|
+
An attachment the upload policy refuses (HTML, SVG, a type the sniff contradicts) arrives
|
|
157
|
+
`stored: false` with storage's code — or `X_MAIL_INBOUND_MALFORMED` when its transfer encoding does
|
|
158
|
+
not decode; the message is still delivered (only an undecodable text or HTML BODY refuses it). `attachments: { disk, policy,
|
|
159
|
+
prefix }` overrides each part; `attachments: false` stores nothing. SES's spam/virus/SPF/DKIM/DMARC
|
|
160
|
+
verdicts ride on `message.verdicts` — what to do about a `FAIL` is the app's decision.
|
|
161
|
+
|
|
110
162
|
## Previews
|
|
111
163
|
|
|
112
164
|
`As of 2026-11-06`. `defineMail({ preview })` declares the data a template is checked by: a value,
|
package/wiki/Scraping.md
CHANGED
|
@@ -89,13 +89,13 @@ One interface, three drivers, no driver type in it.
|
|
|
89
89
|
| `frame(nameOrSelector)` | re-resolves on every call; nothing hands out a stale handle |
|
|
90
90
|
| `screenshot` | `{ fullPage }` or `{ clip }`, never both |
|
|
91
91
|
| `pdf` | the print layout: `format` (`a4`, `letter`, …) or `widthMm` + `heightMm`, `marginMm`, `printBackground`, `preferCssPageSize`, `headerHtml` / `footerHtml`. Two sizes, half a size or a size beside `preferCssPageSize` is `X_SCRAPE_PDF_OPTIONS_INVALID` (422), before any driver |
|
|
92
|
-
| `download({ timeout })` |
|
|
92
|
+
| `download({ timeout })` | the file the **last** click, key or navigation produced — the newest since it, older ones cleared — or `X_SCRAPE_DOWNLOAD_TIMEOUT`. A file from an earlier trigger, or one that landed after its own `download()` timed out, never answers a later one. Off the wire on the browser driver, never a download directory, capped at `maxDownloadBytes` — see [The port is complete](#the-port-is-complete) |
|
|
93
93
|
| `cookies` / `session` | the handoff to the HTTP leg, as a value you can inspect |
|
|
94
94
|
| `query(selector)` | every match as a snapshot — tag, attributes, text, **and `visible`**. The one definition of "visible" in the framework; nothing else may compute it |
|
|
95
95
|
| `offline(enabled)` | the browser's own offline mode. **Not** `@ultimat3/testing`'s sealed network, which patches `fetch` in the *test process* and a browser's requests never traverse — a test built on that would pass against a fully online app |
|
|
96
96
|
| `focus(selector, { timeout })` | waits for `actionable`, then moves focus — the setup for a `press()` |
|
|
97
97
|
| `press(chord)` | `'Meta+K'`, `'Escape'`, `'Shift+Tab'` on whatever holds focus. Modifiers are `Meta`, `Control`, `Alt`, `Shift` in the browser's own spelling; `'Ctrl+K'` is `X_SCRAPE_KEY_INVALID` on **every** driver, offline included — the parse is the one thing an offline driver can be wrong about, so it runs there too, then stops |
|
|
98
|
-
| `accessibility(selector, { max })` | what a screen reader is told about each match —
|
|
98
|
+
| `accessibility(selector, { max })` | what a screen reader is told about each match — role and name after ARIA and label association, at most `max` (default 25) nodes, from **this handle's document**: on a `frame(…)` handle, the frame's. The browser driver answers what Chrome computed; the offline drivers answer the HTML-AAM mapping of the markup, never `role=` read alone: a `<div onclick>` maps to no role *on every driver*, and that *is* the finding |
|
|
99
99
|
| `console()` / `network()` | bounded rings, 200 entries each |
|
|
100
100
|
| `pageErrors()` / `pageErrorsDropped()` | uncaught exceptions, a **third** ring — not console lines |
|
|
101
101
|
| `activity()` | tells the wedge watchdog the run is working on a channel this page cannot see — your own CDP session, a long warm-up. Every verb above already reports; this touches the idle clock only and counts no usage. On every driver |
|
|
@@ -158,10 +158,25 @@ Response bodies are counted **as they arrive**, capped at `DEFAULT_HTTP_MAX_BYTE
|
|
|
158
158
|
| `fixtureBrowser(dir)` | committed page recordings | none |
|
|
159
159
|
| `fakeBrowser(pages)` | inline pages, for a unit test | none |
|
|
160
160
|
|
|
161
|
-
**The launcher is passed in, never imported.** `CdpLauncherLike` is two methods — `launch` and `connect` — so `puppeteer`, `puppeteer-core` or anything with the same shape satisfies it, and this package declares no browser dependency at all. A launcher with no `launch` is `X_SCRAPE_REMOTE_REQUIRED`, not a crash. The browser it hands back must expose `target().createCDPSession()` — puppeteer's does — because `allowHosts` is enforced at the browser too, on every tab a scraped page opens;
|
|
161
|
+
**The launcher is passed in, never imported.** `CdpLauncherLike` is two methods — `launch` and `connect` — so `puppeteer`, `puppeteer-core` or anything with the same shape satisfies it, and this package declares no browser dependency at all. A launcher with no `launch` is `X_SCRAPE_REMOTE_REQUIRED`, not a crash. The browser it hands back must expose `target().createCDPSession()` — puppeteer's does — because `allowHosts` is enforced at the browser too, on every tab a scraped page opens; its pages and the browser must carry every verb the page forwards to, checked when the session opens (`X_SCRAPE_LAUNCHER_INCOMPLETE`, see [The port is complete](#the-port-is-complete)).
|
|
162
162
|
|
|
163
163
|
`driver-parity.test.ts` runs one suite against all three and pins the single honest divergence: the offline drivers have no layout engine, so `ElementSnapshot.box` and `hitTarget` are absent rather than faked.
|
|
164
164
|
|
|
165
|
+
## The port is complete
|
|
166
|
+
|
|
167
|
+
**Every page verb answers on every driver; none is `X_NOT_IMPLEMENTED`** (`As of 2026-11-15`). Thirteen refusals came out of `cdp-target.ts` and `html-target.ts`: a port method one driver cannot honour is a second path, so each one was implemented there — or, for a launcher missing a method, moved to a check when the session opens. `port-complete.test.ts` calls every `ScrapeTarget` member on the offline and the browser driver, on the page and on a frame, keyed by the port's own members — a member added without a row does not compile.
|
|
168
|
+
|
|
169
|
+
| Verb | Browser driver | Offline drivers |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `download()` | the file's bytes off the wire: the browser-level `Fetch` pause at the Response stage streams the body (`Fetch.takeResponseBodyAsStream` + `IO.read`) under a byte cap — `localBrowser({ maxDownloadBytes })`, default `DEFAULT_MAX_DOWNLOAD_BYTES` (25 MiB) — and fulfils the response with the bytes read; `Browser.downloadWillBegin` names it, and Chrome's own copy is denied. Over the cap nothing is buffered: a declared `Content-Length` over it is left to Chrome (`download()` times out), an undeclared attachment is abandoned at the cap and failed, an undeclared non-attachment is never read. Works on `remoteBrowser()`, whose disk is not yours. A script-made `blob:` download is read through the page, its size checked first | the recorded `downloads` entry the LAST click armed — a click that downloads nothing, or a key, disarms it |
|
|
172
|
+
| `offline(enabled)` | the browser's own network condition | every navigation — `goto`, a link's click — fails `X_SCRAPE_BROWSER_UNREACHABLE` while set, the code a browser's failed navigation carries. No JS runs, so an assertion on what the app's offline code renders fails rather than passing |
|
|
173
|
+
| `accessibility()` | what the browser computed — on a frame handle, scoped to the frame's document, found through the page's own session (`Page.getFrameTree` → `DOM.getFrameOwner` → its `contentDocument`). A cross-site frame under site isolation renders in another process the page session cannot read: `X_SCRAPE_FRAME_OUT_OF_PROCESS`, fixed by `localBrowser({ launcher, options: { args: ['--disable-site-isolation-trials'] } })` (measured on Chrome 157) | the HTML-AAM mapping of the markup — the frame's own markup on a frame handle: explicit `role`, else the implicit one; the name from `aria-labelledby`, `aria-label`, `<label for>`, `alt`, content, `title`, `placeholder`. CSS and script are not seen. A `<div onclick>` answers no role and no name |
|
|
174
|
+
| `press` / `focus` / `colorScheme` / `prepare` / `cookies` / `session` | `CdpPageLike` and `CdpBrowserLike` keep `keyboard`, `focus`, `createCDPSession`, `setOfflineMode`, `emulateMediaFeatures`, `evaluateOnNewDocument`, `cookies`, `setCookie` optional in the type, so a launcher written against 31.x still compiles — and checks every one **when the session opens**: a missing one is `X_SCRAPE_LAUNCHER_INCOMPLETE` naming each, and the launched browser is closed. Never a refusal on the first run that reached the verb. `CompleteLauncher` is the same shape with each required, which the built-in launchers are declared as | unchanged |
|
|
175
|
+
|
|
176
|
+
**A frame handle reads its frame.** `page.frame(…).accessibility()` answers from the frame's document on every driver; it was `X_NOT_IMPLEMENTED` on all three until 2026-11-15.
|
|
177
|
+
|
|
178
|
+
**What a browser dependency beside `scraping` still buys.** A direct `puppeteer` import for a download, an offline toggle, a keyboard chord, an accessibility read, an init script, a theme, cookies or a frame's form is now a page verb, on every driver, with `allowHosts`, robots, pacing, redaction and the wedge watchdog applied. What the port does not cover, and a direct import still does: request/response bodies of subresources, a download Chrome makes from an HTML response with no `Content-Disposition`, file uploads, and multiple tabs.
|
|
179
|
+
|
|
165
180
|
## The silent-green alarm
|
|
166
181
|
|
|
167
182
|
A scraper that returns zero rows because the site changed its markup is the failure that does not look like one.
|
|
@@ -440,7 +455,7 @@ Every owned code is split by whether the same request can succeed unchanged. `x
|
|
|
440
455
|
| `X_SCRAPE_HTTP_FAILED` | 408, 409, 425, 429, any 5xx, a deploy — transient far more often than not. **Which 4xx are permanent is `@ultimat3/core`'s `isRetryableStatus`, not this package's**, `As of 2026-08-23`: a private copy here called 408 and 425 terminal while the rest of the framework called them retryable, and a terminal classification dead-letters the run on the attempt that failed rather than spending its declared `attempts` |
|
|
441
456
|
| `X_SCRAPE_BLOCKED` | retryable **and it burns the session first**: retrying a block on the same flagged cookies re-trips it every time |
|
|
442
457
|
|
|
443
|
-
Everything else is terminal, including `X_SCRAPE_SELECTOR_MISSING` (the markup changed), `X_SCRAPE_OUTPUT_INVALID` (the rows are the wrong shape), `X_SCRAPE_YIELD_COLLAPSED`, `X_SCRAPE_SECRET_EXPOSED`, `X_SCRAPE_KEY_INVALID` (the chord is the caller's own literal), `X_SCRAPE_PROMPT_UNANSWERED`, `X_SCRAPE_BROWSER_MISSING` (there is no browser binary to launch), `X_SCRAPE_EGRESS_UNSUPPORTED` (the exit is the run's input and the driver is the deploy's constant)
|
|
458
|
+
Everything else is terminal, including `X_SCRAPE_SELECTOR_MISSING` (the markup changed), `X_SCRAPE_OUTPUT_INVALID` (the rows are the wrong shape), `X_SCRAPE_YIELD_COLLAPSED`, `X_SCRAPE_SECRET_EXPOSED`, `X_SCRAPE_KEY_INVALID` (the chord is the caller's own literal), `X_SCRAPE_PROMPT_UNANSWERED`, `X_SCRAPE_BROWSER_MISSING` (there is no browser binary to launch), `X_SCRAPE_EGRESS_UNSUPPORTED` (the exit is the run's input and the driver is the deploy's constant) `X_SCRAPE_LAUNCH_ARGS_INVALID` (the args are the deploy's literal), `X_SCRAPE_LAUNCHER_INCOMPLETE` (the launcher is the deploy's library) and `X_SCRAPE_FRAME_OUT_OF_PROCESS` (site isolation is the browser's configuration).
|
|
444
459
|
|
|
445
460
|
## Testing offline
|
|
446
461
|
|