akanjs 3.2.0-rc.31 → 3.2.0-rc.32
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/CHANGELOG.md +186 -10
- package/common/Logger.ts +4 -2
- package/common/clientAddress.ts +14 -0
- package/common/eventStream.ts +71 -19
- package/common/index.ts +1 -0
- package/common/loggedFailure.ts +11 -0
- package/common/types.ts +5 -0
- package/dictionary/agent.dictionary.ts +8 -0
- package/dictionary/base.dictionary.ts +4 -0
- package/document/dataLoader.ts +39 -19
- package/fetch/client/fetchClient.ts +5 -5
- package/fetch/client/wsClient.ts +71 -6
- package/package.json +1 -1
- package/server/akanApp.ts +5 -2
- package/server/akanOption.ts +15 -1
- package/server/akanServer.ts +14 -1
- package/server/gateway/childSupervisor.ts +3 -1
- package/server/gateway/gatewayChildren.ts +28 -2
- package/server/gateway/gatewayHttpProxy.ts +2 -2
- package/server/gateway/gatewayStatus.ts +8 -2
- package/server/gateway/listeningPort.ts +13 -0
- package/server/lifecycle/parentChannel.ts +1 -0
- package/server/logging/hubFileSink.ts +1 -0
- package/server/logging/logHub.ts +0 -0
- package/server/logging/logStdoutWriter.ts +3 -1
- package/server/logging/logStreamRoute.ts +28 -11
- package/server/resolver/CascadeRunner.ts +10 -4
- package/server/resolver/databaseModelInstance.ts +12 -3
- package/server/resolver/modelLoaders.ts +39 -7
- package/server/resolver/roomAdmission.ts +68 -0
- package/server/resolver/signal.resolver.ts +10 -18
- package/server/routing/apiRouter.ts +10 -4
- package/server/rscRenderFallbacks.ts +5 -3
- package/server/rscWorkerProcess.ts +1 -1
- package/service/agentLoop/agentLoop.ts +108 -25
- package/service/agentLoop/agentLoopTypes.ts +72 -22
- package/service/agentLoop/loopAnswer.ts +67 -0
- package/service/agentLoop/loopCompaction.ts +8 -1
- package/service/agentLoop/loopRemotes.ts +19 -3
- package/service/agentLoop/loopRequest.ts +30 -0
- package/service/agentLoop/loopStored.ts +24 -0
- package/service/agentLoop/loopToolOutput.ts +3 -3
- package/service/agentLoop/loopToolkits.ts +21 -8
- package/service/agentLoop/loopTranscript.ts +54 -18
- package/service/agentRelayPolicy.ts +39 -12
- package/service/endpointCacheKeys.ts +14 -2
- package/service/index.ts +2 -0
- package/service/ipcTypes.ts +5 -1
- package/service/liveRoomLimit.ts +68 -0
- package/service/liveRoomLimitError.ts +16 -0
- package/service/liveSyncHub.ts +24 -2
- package/service/predefinedAdaptor/anthropicLlm.ts +19 -7
- package/service/predefinedAdaptor/database.adaptor.ts +60 -19
- package/service/predefinedAdaptor/llm.adaptor.ts +19 -3
- package/service/predefinedAdaptor/openaiDialect.ts +33 -12
- package/service/predefinedAdaptor/openaiLlm.ts +1 -1
- package/service/predefinedAdaptor/sql/DocumentWriter.ts +7 -1
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +59 -19
- package/service/predefinedAdaptor/sql/TransactionScope.ts +14 -7
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +17 -6
- package/service/predefinedAdaptor/sql/types.ts +16 -2
- package/service/predefinedAdaptor/sseData.ts +76 -2
- package/signal/SignalFailure.ts +14 -1
- package/signal/agent.signal.ts +7 -5
- package/signal/agentTurnStream.ts +11 -5
- package/signal/endpointCache.ts +61 -6
- package/signal/endpointRateLimit.ts +84 -3
- package/signal/index.ts +6 -1
- package/signal/middleware.ts +4 -2
- package/signal/signalContext.ts +7 -7
- package/signal/trace.ts +41 -5
- package/signal/types.ts +11 -2
- package/store/actionErrorMessage.ts +20 -0
- package/store/sliceLiveActions.ts +10 -0
- package/store/storeInstance.ts +4 -18
- package/store/storeRegistry.ts +1 -1
- package/test/conformance.ts +25 -5
- package/types/common/clientAddress.d.ts +5 -0
- package/types/common/eventStream.d.ts +5 -1
- package/types/common/index.d.ts +1 -1
- package/types/common/loggedFailure.d.ts +2 -0
- package/types/common/types.d.ts +5 -0
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +4 -4
- package/types/document/dataLoader.d.ts +5 -0
- package/types/fetch/client/wsClient.d.ts +1 -0
- package/types/server/akanOption.d.ts +9 -1
- package/types/server/akanServer.d.ts +1 -1
- package/types/server/gateway/childSupervisor.d.ts +3 -1
- package/types/server/gateway/gatewayChildren.d.ts +4 -1
- package/types/server/gateway/gatewayStatus.d.ts +1 -0
- package/types/server/gateway/listeningPort.d.ts +5 -0
- package/types/server/logging/logHub.d.ts +5 -1
- package/types/server/logging/logStreamRoute.d.ts +2 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/resolver/CascadeRunner.d.ts +2 -2
- package/types/server/resolver/modelLoaders.d.ts +8 -2
- package/types/server/resolver/roomAdmission.d.ts +7 -0
- package/types/service/agentLoop/agentLoop.d.ts +1 -0
- package/types/service/agentLoop/agentLoopTypes.d.ts +71 -21
- package/types/service/agentLoop/loopAnswer.d.ts +13 -0
- package/types/service/agentLoop/loopRemotes.d.ts +4 -0
- package/types/service/agentLoop/loopRequest.d.ts +3 -0
- package/types/service/agentLoop/loopStored.d.ts +6 -0
- package/types/service/agentLoop/loopToolOutput.d.ts +1 -0
- package/types/service/agentLoop/loopTranscript.d.ts +4 -3
- package/types/service/agentRelayPolicy.d.ts +9 -4
- package/types/service/index.d.ts +2 -0
- package/types/service/ipcTypes.d.ts +4 -0
- package/types/service/liveRoomLimit.d.ts +26 -0
- package/types/service/liveRoomLimitError.d.ts +9 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +2 -2
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +9 -7
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +7 -2
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +2 -2
- package/types/service/predefinedAdaptor/sql/DocumentWriter.d.ts +2 -1
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +2 -1
- package/types/service/predefinedAdaptor/sql/TransactionScope.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +2 -1
- package/types/service/predefinedAdaptor/sql/types.d.ts +17 -2
- package/types/service/predefinedAdaptor/sseData.d.ts +9 -1
- package/types/signal/SignalFailure.d.ts +3 -0
- package/types/signal/agentTurnStream.d.ts +1 -0
- package/types/signal/endpointRateLimit.d.ts +12 -0
- package/types/signal/index.d.ts +1 -1
- package/types/signal/signalContext.d.ts +1 -1
- package/types/signal/trace.d.ts +9 -1
- package/types/signal/types.d.ts +5 -1
- package/types/store/actionErrorMessage.d.ts +1 -0
- package/types/test/conformance.d.ts +3 -1
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +3 -1
- package/vendor/@akanjs/native/CHANGELOG.md +5 -0
- package/vendor/@akanjs/native/native/desktop/src/linux/external.rs +94 -7
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +3 -1
- package/vendor/use-agentic/CHANGELOG.md +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -21,24 +21,70 @@
|
|
|
21
21
|
|
|
22
22
|
**Upgrading.** An `AgentChat` override that types `title` as `string` must take `ReactNode`. A modal an app mounted beside the Chat and opened from the panel's `header` still opens under the panel; mount it inside `header` to bring it above.
|
|
23
23
|
|
|
24
|
+
- 69a954c: `agentService.loop` takes the answer to a parked call as its own argument, `answer`, and accepts it only for the call the run parked on.
|
|
25
|
+
|
|
26
|
+
- `answer: { id, result }` or `{ id, error }` answers the call a run ended `awaiting` on with `client` or `question`: the first call of the last batch that nothing answered, and only when it is a client tool's or `askUser`'s. A page's `AgentClientTools.run(call)` result can be passed as it is.
|
|
27
|
+
- The run names the result after the call, whatever name was sent, hands it to `onMessage`, emits it as a `toolResult` event and runs the calls the batch has left.
|
|
28
|
+
- An endpoint tool's call is answered only by running it. An `answer` that names one, a call the run has not reached, or a call already answered ends the run with an `error` event whose `error` is `agent.error.answerRefused`, before anything runs. A resume without the `answer` carries on.
|
|
29
|
+
- Only `askUser`'s answer is exempt from the untrusted rule. A client tool's answer always taints the run.
|
|
30
|
+
- A run that ended `awaiting` with `connect`, on an `openToolkit` call for a remote the account has no connection to, is resumed in one of two ways. Once the user connected, resume with the stored messages and no `answer`: the run opens the remote itself. When the user declines, resume with `answer: { id, error }` for that call, which replaces appending `{ id, name: "openToolkit", error }` to the messages. The `error` only says that the user refused: the run stores a sentence of its own that names the remote, with the code `remoteDeclined`, as that call's result, and keeps none of the text sent. That sentence taints neither the run nor a later resume. A decline is accepted only for an `openToolkit` call that names a remote and is the first call of the last batch that nothing answered. The stored messages do not record why a run stopped there, so that holds whether the run parked on the connection, `approve` deferred the batch, or the run died before reaching the call. All a decline does is keep that open from running, with the run's own sentence as its result: it carries no text of the caller's, answers no other call and opens nothing, and the rest of the batch is judged as usual. An `answer` with a `result` for an `openToolkit` call is refused as `agent.error.answerRefused`: whether a connection exists is the server's to see.
|
|
31
|
+
- A stored result is read as the answer to the call its id names, under that call's name: a result stored under the name `askUser` no longer skips `untrusted` unless the call it answers is `askUser`'s.
|
|
32
|
+
- `messages` holds only the app's own user messages and what `onMessage` handed over. Never take `messages` from a request: store what `onMessage` hands out and pass from the client only `answer`, as a tool message a client wrote reads exactly like one the run stored.
|
|
33
|
+
- Pass `answer` only after an `awaiting` event with `client` or `question` named that call. `approve` is not asked about an answered call, as nothing runs on the server, so an answer given for a call `approve` deferred, or for one a run died before parking on, is stored as it stands.
|
|
34
|
+
|
|
35
|
+
**Upgrading.** An app built on a 3.2.0 release candidate that appends a tool message to `messages` before resuming must pass the answer instead:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// before
|
|
39
|
+
this.agentService.loop({
|
|
40
|
+
...request,
|
|
41
|
+
messages: [
|
|
42
|
+
...stored,
|
|
43
|
+
{ role: "tool", toolResults: [{ id, name, result }] },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
// after
|
|
47
|
+
this.agentService.loop({
|
|
48
|
+
...request,
|
|
49
|
+
messages: stored,
|
|
50
|
+
answer: { id, result },
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The run stores the answer through `onMessage`, so do not store it yourself. An appended result is still read as a stored one, but nothing checks which call it answers: remove the append. Code that expects no `toolResult` event before the first model call of a resume now receives one for the answer.
|
|
55
|
+
|
|
24
56
|
- 4538737: `agentService.loop` can now ask the member a question and wait for the answer between runs, the way the in-page chat's `askUser` does.
|
|
25
57
|
|
|
26
58
|
- `ask: true` lists `askUser({ question, choices?, multiple? })`, with the in-page chat's own description and parameters.
|
|
27
59
|
- A call ends the run as `awaiting`, with `question: true` on the event. Calls written before it in the same batch have already run; calls written after it wait for the resume.
|
|
28
|
-
- Put the question to the member over your own transport
|
|
60
|
+
- Put the question to the member over your own transport and resume with `answer: { id, result }`, or `{ id, error }` when they dismiss it. A resume without the answer parks the call again. A resume without `ask` answers it as an unknown tool.
|
|
29
61
|
- `askUser` never reaches `approve` and counts as no tool call. `untrusted` never sees the answer, which is the member's own input.
|
|
30
62
|
- A call with no question is answered with an error and the run goes on.
|
|
31
63
|
- With `ask: true`, a `clientTools` entry named `askUser` is dropped, and an `allow` naming `askUser` is refused as an invalid argument.
|
|
32
64
|
|
|
33
65
|
The option is new and off by default, so no upgrade step is needed.
|
|
34
66
|
|
|
67
|
+
- 69a954c: `agentService.loop` bounds what a page sends into a run through `clientTools` and `answer`, and what another server sends into one through `remotes`.
|
|
68
|
+
|
|
69
|
+
- **Tool definitions.** A run takes at most 128 client tools and 200,000 characters of their definitions, about twenty times what a screen lends today, nested at most 64 levels deep. Past any of the three, the run ends with an `error` event whose `error` is `agent.error.clientToolsRefused` (status 413), with `data.limit` `"tools"`, `"chars"` or `"depth"`, `data.max` and `data.sent`.
|
|
70
|
+
- **Writes.** A client tool counts as a write whatever `readOnly` it was sent with: `approve` sees `tool.readOnly: false`, and a run with no `approve` refuses it once tainted. Which client tools may run after a read is the app's to say, in `approve`, by name.
|
|
71
|
+
- **Answers.** Every part of an `answer` is bounded where it enters the transcript. Its `result`, its `error`, its `changes` taken as one value and a text attachment are each clipped at 20,000 characters, as a tool's result is. Its `code` is kept only when it is a failure code: a dictionary key or a camelCase token. Of its `attachments` the first four that carry `data` or `text` are kept, never a `url`, each with a `name` and a `mimeType` of at most 255 characters and under the 4 MiB ceiling a tool's file has.
|
|
72
|
+
- **Size caps.** A run that lists `clientTools` meets the relay's default size caps (`AgentRelayPolicy.defaultLimits`) on each of its turns, and ends with `agent.error.requestRefused` past them. `AgentTurnContext.loop` gains `client: true` on those turns, so a policy of the app's own can tell them apart. A run with neither `clientTools` nor `remotes` still skips the caps. A file a tool returned now counts under `attachmentChars` like a user's attachment, on relayed turns too, where it used to count under `chars`: two pictures of five million characters each no longer end a run. A file whose `data` or `text` is not a string is sized by its JSON, and a turn whose `toolResults` or `attachments` is not a list of objects is refused with `agent.error.requestRefused`.
|
|
73
|
+
- **Remotes.** A run that names `remotes` meets the same default size caps on each of its turns, which carry `loop.remote: true`. It keeps at most four remotes open, as each open listing of up to 120,000 characters rides every later round: the open of a fifth is answered with an error and that server is not contacted. A resume leaves closed a remote that a stored call found disconnected, as the run that stored that call did, so it does not count toward the four. A `view` on a `toolResult` event carries no `href` or `resourceUri` longer than 2,048 characters. Of what a remote's `call` returns, the run keeps only `result`, `error`, `code`, `changes` and `attachments`, each bounded as the parts of an `answer` are: `result`, `error` and `changes` as one value clipped at 20,000 characters, `code` only when it is a failure code, and the first four attachments that carry `data` or `text`, never a `url`. Any other field is dropped, where it used to be stored as sent.
|
|
74
|
+
|
|
75
|
+
**Upgrading.** An app built on a 3.2.0 release candidate changes nothing unless it relied on one of these:
|
|
76
|
+
|
|
77
|
+
- A page that marked a tool `readOnly: true` in what it sent, to keep it callable after a read in a run with no `approve`: pass `approve` and allow that tool by name.
|
|
78
|
+
- A request policy set with `option.setAgentRequestPolicy` that returns loop rounds untouched keeps doing so; to cap the rounds of a run with client tools or remotes, return `AgentRelayPolicy.capped(request)` when `context.loop?.client` or `context.loop?.remote` is set.
|
|
79
|
+
- An answer that carried a file by `url`: send its bytes as `data`, or have an endpoint tool return it.
|
|
80
|
+
|
|
35
81
|
- dcddea0: `agentService.loop` can now call the tools of a screen the member has open, without running them on the server. The run parks each such call, the way an approval parks one, until the page answers it.
|
|
36
82
|
|
|
37
83
|
- **Server.** `clientTools` takes the definitions the open page sent over the app's own transport. They are listed beside the endpoint tools.
|
|
38
|
-
- They are client input. Each definition is rebuilt from `name`, `description`, `parameters`, `readOnly`
|
|
39
|
-
- `approve` is still asked about each call. With no approver, a
|
|
84
|
+
- They are client input. Each definition is rebuilt from `name`, `description`, `parameters` and `needsConfirm`, and counts as a write whatever `readOnly` it carries. A name an endpoint tool holds is dropped, in a closed toolkit too, and so is `openToolkit`.
|
|
85
|
+
- `approve` is still asked about each call. With no approver, a client tool is refused once the run is tainted, and a `needsConfirm` one is always refused.
|
|
40
86
|
- An allowed call ends the run as `awaiting`, with `client: true` on the event. Calls written before it in the same batch have already run; calls written after it wait for the resume.
|
|
41
|
-
- The run never waits on a socket. The app delivers the call to the page
|
|
87
|
+
- The run never waits on a socket. The app delivers the call to the page and resumes with the page's result as `answer` (or `{ id, error }` when no page answers). A resume without it parks the call again. A resume without `clientTools` answers it as an unknown tool.
|
|
42
88
|
- **Browser.** `AgentClientTools` is new in `use-agentic` and re-exported from `akanjs/ui`, along with the `ToolRunnerHost` and `ToolApprovalRequest` types.
|
|
43
89
|
- `new AgentClientTools(surface?, host?).list()` gives the open screen's tools in the shape `clientTools` takes, each with `readOnly: false`.
|
|
44
90
|
- `run(call)` answers a parked call through the same `ToolRunner` as the in-page chat. A `confirm` still asks through `host.approve` and is refused without one, a card tool needs `host.card`, and the answer is clipped and fenced as the chat's would be.
|
|
@@ -56,6 +102,24 @@
|
|
|
56
102
|
|
|
57
103
|
A run without `compact` ends on the refusal as before. With `compact` set, a refused round now costs up to two more model calls (the summary and the retry) before the run ends. `AgentTurnStream.failure(...).overflow` and `RunnerEvent`'s error `overflow` gain an optional `requested`; code reading only `limit` needs no change.
|
|
58
104
|
|
|
105
|
+
- 69a954c: `agentService.loop` now counts what a run reads as untrusted unless the app says otherwise. With no `untrusted` option, every result of a call that ran taints the run: an endpoint tool's or a client tool's, an error included.
|
|
106
|
+
|
|
107
|
+
- A run with `approve` is asked with `tainted: true` for every call after the first result.
|
|
108
|
+
- A run with no `approve` writes only in the batch the model wrote before any result came back. A later write is not run: its result carries the code `writeAfterRead` and a sentence saying to pass `approve` or `untrusted`, and the server logs a warning naming the tool.
|
|
109
|
+
- `askUser`'s answer, `openToolkit`'s answer and a call the run refused without running taint nothing. A resume cannot tell a stored refusal from a stored result, so with no `untrusted` it counts every stored tool result.
|
|
110
|
+
- `untrusted` still decides for endpoint results when it is given: `() => false` trusts every one, and `(result) => !own.has(result.name)` trusts the endpoints the app names. No endpoint option says whose text a tool returns, so the predicate is where that is declared.
|
|
111
|
+
- A client tool's answer always taints the run and is never shown to `untrusted`: a page may lend a tool under the name of an endpoint the run does not list, which a predicate reading names would trust. `approve` receives `client: true` for a call to a page's tool, and only `approve` lets a write follow a page's answer. A resume reads this off the stored call, not off a stored mark: a stored result is judged by `untrusted` only when its call names an endpoint the resumed run lists, and any other, a page's tool or a tool the run no longer has, taints the run. The run's own answer to a tool name the model made up, `Unknown tool: <name>.` with nothing beside it, taints nothing. Keep `ask` and `toolkits` the same for the life of a transcript: a stored `askUser` or `openToolkit` answer whose name the page lends taints.
|
|
112
|
+
- With `remotes`, the open of a remote and any call into one taint the run whatever `untrusted` returns and with none given, a call the run refused included. A resume reads this off the stored call as well: a stored result whose call is `<remote>.<tool>`, or an `openToolkit` call that names a remote, taints the run unasked, with or without its mark. The one exception is the run's own sentence for a connection the user refused, stored with nothing beside it, which taints nothing; the error of an open that failed does. Keep `remotes` the same for the life of a transcript, like `ask` and `toolkits`.
|
|
113
|
+
- A compaction summary is now always written with its `tainted` field, and a stored summary without one counts as tainted in every run, where it used to count only in a run with `untrusted`.
|
|
114
|
+
|
|
115
|
+
**Upgrading.** This changes a default of the 3.2.0 release candidates. A `loop` call that passes neither `untrusted` nor `approve` and whose `allow` or `clientTools` hold a tool that changes data must now choose one of three:
|
|
116
|
+
|
|
117
|
+
- pass `approve`, and decide there what may run once `tainted` is `true`;
|
|
118
|
+
- pass `untrusted: (result) => …` returning `true` for the results that can carry text someone else wrote;
|
|
119
|
+
- pass `untrusted: () => false` to keep the release candidates' behaviour for endpoint tools, when nothing they return was written by anyone but the app and the member.
|
|
120
|
+
|
|
121
|
+
A run with `clientTools` and no `approve` refuses every write after a page's answer, whatever `untrusted` returns: pass `approve` and allow there what may follow. A resume whose `allow` no longer lists an endpoint that stored results came from starts tainted. A call that already passes `untrusted` otherwise changes nothing, with one exception for stored transcripts: a summary stored without a `tainted` field by a run that had no `untrusted` now taints the run that resumes from it. Set `tainted: false` on such a stored summary if what it replaced was the app's own data. A call that passes only `approve` now receives `tainted: true` after the first result, so an approver that denies or defers every tainted call does so from then on: pass `untrusted` as well to keep `tainted` for the results that warrant it.
|
|
122
|
+
|
|
59
123
|
- fd76e6f: `agentService.loop` can call other MCP servers as the run's account, each one a toolkit the model opens.
|
|
60
124
|
|
|
61
125
|
- `remotes: AgentLoopRemote[]` on the loop request. A remote is listed in `openToolkit` by its `name` and `description` and is not contacted until the model opens it; its tools then read `<name>.<tool>`. Opening one the account has no connection to ends the run `awaiting` with `connect: "<name>"`, and a resume with the stored messages opens it once connected.
|
|
@@ -83,19 +147,19 @@
|
|
|
83
147
|
- **Events.** It returns an async iterable of `text`, `toolCall`, `toolResult`, `usage`, `compacted` and `awaiting` events. The stream ends with exactly one `done { stop, rounds }` or `error`. `stop` is one of `end`, `maxRounds`, `budget`, `aborted`, `length`, `quota`, `unauthorized` or `awaiting`. The loop waits for the consumer at every event.
|
|
84
148
|
- **Accounts.** A request carries either `account`, a snapshot the server resolved, or `principal`, a stored id. A new `option.setAgentAccountResolver((principal) => account | null)` resolves the principal at the start and before every round. If it resolves to `null`, the run ends as `"unauthorized"`, as does a missing or falsy `account`: there is no anonymous run. The model is offered `allow` ∩ what the account sees on `/mcp`, and a call to a name that round did not list is answered as an unknown tool, neither asked about nor run. A request with no `allow` array is an `error`.
|
|
85
149
|
- **Approval and taint.**
|
|
86
|
-
- `untrusted(result)`
|
|
150
|
+
- `untrusted(result)` says which results are untrusted; with none given, every result of a call that ran is. Every later call reaches `approve(call, { tainted, tool })` with `tainted` set. `approve` returns `"allow"`, `"defer"` or `{ deny }`.
|
|
87
151
|
- Without `approve`, a `needsConfirm` tool is refused, and so is every write once the run is tainted. `AgentToolsRole`'s `listAs` now marks a mutation MCP calls destructive as `needsConfirm`. `purge`, `destroy`, `erase`, `wipe`, `drop`, `cancel`, `bulkRemove` and `bulkDelete` keys now count alongside `remove` and `delete`, which also changes those tools' `destructiveHint` on `/mcp`, and a new `destructive` endpoint option overrides the key.
|
|
88
152
|
- `"defer"` holds the whole batch, emits `awaiting`, and ends the run.
|
|
89
153
|
- **Resume.**
|
|
90
154
|
- `onMessage` is awaited for each message the run appends.
|
|
91
155
|
- Calling `loop` again with the stored messages asks `approve` again about any trailing calls nothing answered, and rebuilds the taint from the stored results.
|
|
92
156
|
- `compact { at, keep }` summarizes the head of the transcript. The `compacted` event names how many messages the summary replaced.
|
|
93
|
-
- A summary or tool message now carries `tainted`, new and optional on `AgentWireMessage`, so a resumed transcript stays tainted. Store each whole. A summary with no marker counts as tainted
|
|
157
|
+
- A summary or tool message now carries `tainted`, new and optional on `AgentWireMessage`, so a resumed transcript stays tainted. Store each whole. A summary with no marker counts as tainted, as what it replaced cannot be judged.
|
|
94
158
|
- A batch's results reach `onMessage` even when the consumer stops reading or a later call throws, so a resume runs only calls that never started.
|
|
95
159
|
- **Metering.**
|
|
96
160
|
- Each model call is its own turn for the request policy, the quota and the usage hook. That includes compactions.
|
|
97
161
|
- `AgentTurnContext` gains `loop { id, round }` and `meta`, which is copied from the request.
|
|
98
|
-
- A loop turn has empty headers and a `null` ip. The relay's default size caps do not apply to loop rounds
|
|
162
|
+
- A loop turn has empty headers and a `null` ip. The relay's default size caps do not apply to loop rounds, unless the run lists `clientTools` or names `remotes`.
|
|
99
163
|
- **Limits.**
|
|
100
164
|
- The run is bounded by `maxRounds` (default 12), `budget { tokens, toolCalls, wallMs }` and `signal`. A limit that is not a valid number is an `error` before any model call.
|
|
101
165
|
- `wallMs` and `signal` also end a run waiting on a tool or on `approve`. `callAs` cannot cancel a call, so the run stops waiting and answers it with an error saying it may still finish. A resume does not run it again, and the endpoint runs on with its outcome unreported.
|
|
@@ -216,6 +280,27 @@
|
|
|
216
280
|
|
|
217
281
|
**`Exception.<Status>.is(error)` type-checks.** `StatusException` now declares `is`, so `Exception.BadRequest.is(error)` narrows `error` to an `Exception` and checks its own class.
|
|
218
282
|
|
|
283
|
+
- b236476: A conformance suite built on `ConformanceEnv` from `akanjs/test` now fails instead of skipping when `AKAN_TEST_REQUIRE_BACKENDS=1` and the backend it asks for has no URL: `ConformanceEnv.has(suite, backend)` registers a failing test named `<suite>: <backend> backend is required`, which says which variable is missing. A CI job that sets the switch can no longer pass without running its Postgres or Redis cases. `ConformanceEnv.requireBackends` reads the switch.
|
|
284
|
+
|
|
285
|
+
**Upgrading.** Nothing to change. Without the variable a missing backend is announced and skipped, as before.
|
|
286
|
+
|
|
287
|
+
- a91a643: A failed call is now logged at a level that says how bad it was: a failure under 500 is `warn`, so it no longer looks like a crash, and a 5xx is one `error` record that carries the error's type and stack in its attributes. A crashed RSC worker now shows at `warn` instead of being hidden at `verbose`. This is minor because alerts and `--level error` filters see fewer lines. `SignalFailure.statusOf` and `SignalFailure.logAttrs` are new statics behind this.
|
|
288
|
+
|
|
289
|
+
**Upgrading.** These lines changed level or merged:
|
|
290
|
+
|
|
291
|
+
- `Error <type>-<key> / <ms>ms: …` from the `Logging` middleware, for an undeclared failure under 500: `warn` (was `error`). A declared error, a 429 and a by-id read that missed its own id stay `debug`. A 5xx no longer writes this line.
|
|
292
|
+
- `Error <type>-<key>: …` from the endpoint's logger is still `error`, and is now the only line a 5xx writes when `AKAN_LOG_CANONICAL` is off. It now also covers an `Exception` with a 5xx status, which used to get only the middleware line. Its message is the error's first line; `status`, `type`, `code` and `stack` are in its attributes instead of the message.
|
|
293
|
+
- `error <endpoint>` from `AKAN_LOG_CANONICAL`: `error` for a 5xx (was `warn`), with `type` and `stack`, and then the endpoint's line above is not written, so a 5xx is one record. Under 500 it stays `warn`. Its `status` is now the status HTTP answers, so an error that is not an `AkanError` reports 500 even if it sets its own `statusCode`.
|
|
294
|
+
- `[rsc] worker crashed, restarting in <n>ms (attempt <n>)`: `warn` (was `verbose`).
|
|
295
|
+
- The request line of a page (`<outcome> page:<route>`): a `redirect()` is now `ok page:<route>` at `info` with its 3xx status (was `error` at `warn` with status 500), and a `notFound()` is `warn` with status 404 (was 500). A page that crashes before its stream starts writes an `error` request line with `type` and `stack`, and then `render[<id>] failed url=…` is not written. Under 500 it stays `warn`.
|
|
296
|
+
- The request line of an internal job (cron, interval, timeout, init, destroy): a failure is `error` with `type` and `stack` (was `warn`). The `Schedule … error: …` line is still written too, so under `AKAN_LOG_CANONICAL` a failing job writes two `error` records. The Scheduler cannot tell whether a failure came from the traced job or from its own lease step, so it never skips its line.
|
|
297
|
+
- A call past its `timeout` answers 504 and is one `error` record like any 5xx. Its stack is the `Timeout` middleware's, not the handler's.
|
|
298
|
+
- A client that leaves mid-call writes no failure line: an agent turn answers 499 without throwing, so its request line is `ok` at `info`. A handler that throws because its abort signal fired is a 500 and is `error`, as before.
|
|
299
|
+
|
|
300
|
+
With `AKAN_LOG_CANONICAL` off, `render[<id>] failed url=…` is written as before, at `error`.
|
|
301
|
+
|
|
302
|
+
An alert on `error` that counted 4xx calls should match `warn` with a `status` under 500. A parser that read the stack out of the message should read `attrs.stack` in ndjson; the text format still prints the stack on its own lines, now under the record's line instead of inside its message.
|
|
303
|
+
|
|
219
304
|
- d79a206: A call a page makes while it renders on the server can leave the page in the route result cache.
|
|
220
305
|
|
|
221
306
|
A `fetch.*` call made during a server render forwards the visitor's session and address, so it reads the page request's headers and cookies. That marks the render dynamic, and the HTML and RSC result caches never store it, even for an anonymous visitor. A page whose only server data is an answer that is the same for everyone was therefore rendered on every request.
|
|
@@ -226,6 +311,10 @@
|
|
|
226
311
|
|
|
227
312
|
**Upgrading.** Nothing changes unless a call passes `forwardVisitor: false`.
|
|
228
313
|
|
|
314
|
+
- 374abac: **A gateway's `/_akan/app/ready` now answers 503 while no replica's RSC worker can render a page**, so a pod whose worker is booting or restarting leaves the Service after two failed probes (about 10–20 s with the chart's 10 s period and failure threshold of 2) instead of taking page requests it cannot render. Each replica now reports its RSC worker's state in every health pong (every 2 s) and in its `ready` message, and the gateway sends HTTP requests to a replica whose worker is ready while any is, falling back to the others when none is; websocket upgrades keep plain round-robin over every replica. A gateway with several replicas stays ready while at least one of them can render. The ready route's `children` entries now carry `rscWorker`.
|
|
315
|
+
|
|
316
|
+
No upgrade step is needed: `AkanIpcMessage` only gains an optional `rscWorker` on `ready` and `health.pong` (typed `AkanRscWorkerStatus`), and a replica of an earlier release that sends neither counts as ready, as before.
|
|
317
|
+
|
|
229
318
|
- d9f5ad5: Behind the gateway, a WebSocket subscribe is now acknowledged once the gateway routes the room to the replica that holds it. The gateway used to learn of the room in a message the replica sent without waiting, so an event or a live-list write handled by another replica right after the ack could reach the gateway first and be dropped.
|
|
230
319
|
|
|
231
320
|
- `SolidPubSub.joinRoom` sends its `pubsub.subscribe` with an `ack` number and resolves when the gateway answers `pubsub.subscribed`. A replica's messages reach the gateway in order, so the answer also covers the live models it reported before the subscribe.
|
|
@@ -242,6 +331,60 @@
|
|
|
242
331
|
|
|
243
332
|
Upgrade step: after every instance runs this release, run `prune-indexes` once to drop what earlier releases left; until then the warnings at boot list those indexes. `migrationActions` and `MigrationAction` gain `indexes` and `prune-indexes`, so code that switches over every action needs the two new cases; nothing else changes for a caller.
|
|
244
333
|
|
|
334
|
+
- e3a1d31: A websocket now holds at most 256 pubsub rooms at once, live or not. A subscribe past that is refused with a 429 error frame coded `liveRoomLimit` (`base.error.liveRoomLimit`, `data: { limit, per: "socket" }`).
|
|
335
|
+
|
|
336
|
+
- The rooms the socket already holds keep receiving their events.
|
|
337
|
+
- Subscribing a room the socket already holds does not count twice.
|
|
338
|
+
- Leaving a room frees its place, and closing the socket frees all of them.
|
|
339
|
+
|
|
340
|
+
A page holds one room per live slice and per feed it shows, so 256 is far above what a page uses.
|
|
341
|
+
|
|
342
|
+
A caller now holds at most 2,000 rooms on a server process across all its sockets. A caller is its account when signed in, else its address: an IPv4 address as itself (also when mapped into IPv6), an IPv6 address by its /64, since one host is handed a whole /64. A subscribe past that is refused with the same frame, carrying `per: "caller"`, and its rooms free their places as its sockets leave them or close. Twenty tabs of twenty rooms each come to 400, so the rest leaves room for visitors who share one address. A caller whose address is unknown is bounded by the per-socket cap only. The number of sockets per address stays unlimited, because this count bounds the rooms whatever the number of sockets.
|
|
343
|
+
|
|
344
|
+
A server process now holds at most 50,000 live rooms per model that every write evaluates, across every socket. These are the rooms no equality index files and the invalidating ones; a write reaches an indexed room only through its key, so indexed rooms never count. A new room of that kind past the ceiling is refused with the same frame, carrying `per: "model"`. Rooms already held keep working, and the server warns at most once a minute per model while it refuses.
|
|
345
|
+
|
|
346
|
+
Subscribe frames now have a budget, over every pubsub endpoint: 1,000 a minute per websocket, and 10,000 a minute per caller across its sockets. A caller is the same as for the room cap: its account, else its IPv4 address or its IPv6 /64. A subscribe past either budget is refused with the usual 429 `base.error.tooManyRequests` and `data: { seconds }`. A page's subscribes and a reconnect that resubscribes every room the socket held fit well inside both.
|
|
347
|
+
|
|
348
|
+
When the server refuses a subscribe with 429, the error frame names the room it refused (`requestRoomId`) and carries back the `token` the client numbered that subscribe frame with. A refusal whose token is not the room's latest subscribe answers an earlier one, and the client ignores it.
|
|
349
|
+
|
|
350
|
+
- Refused for a room limit (`liveRoomLimit`), the room is dropped, so a reconnect does not send it again, and the subscriber's new `onRefused(error)` fetch policy is called.
|
|
351
|
+
- Refused for a budget (`tooManyRequests`), the subscribe is sent again after the `seconds` the server named (counted as 1 to 60), plus up to a second of random wait per attempt. The ack of a retry resyncs the room as a reconnect's does, so a list refetches what was written while the room was refused. After five such tries without an ack, the room is dropped the same way.
|
|
352
|
+
- A refusal with any other status leaves the room as it was.
|
|
353
|
+
|
|
354
|
+
When its room is dropped, a live slice shows the error as a message, marks its list stale so the next mount refetches, and subscribes again only on its next watch, never in a loop.
|
|
355
|
+
|
|
356
|
+
**Upgrading.** Nothing changes for an app whose sockets hold 256 rooms or fewer, whose callers hold 2,000 rooms or fewer per server, whose models hold 50,000 scanned or invalidating live rooms or fewer per server, and that sends fewer than 1,000 subscribe frames a minute per socket and 10,000 per caller.
|
|
357
|
+
|
|
358
|
+
- The per-caller room cap and the per-model ceiling are counted per server process, so callers spread over several replicas get each limit once per replica. The per-model ceiling is a backstop: about 25 distinct callers at the default cap of 2,000 can reach it. Past it, new rooms on that model that no equality index files, and invalidating ones, are refused, while indexed rooms keep joining. Raise either with `roomsPerCaller` / `roomsPerModel` below, or with `AKAN_LIVE_ROOMS_PER_CALLER` / `AKAN_LIVE_ROOMS_PER_MODEL`.
|
|
359
|
+
- To raise or lift the room limits, call `option.setLiveRoomLimit({ roomsPerSocket: <count>, roomsPerCaller: <count>, roomsPerModel: <count> })` in `lib/option.ts`. Pass `false` for any of them to turn it off. Libs merge in mount order, with the app last. `AKAN_LIVE_ROOMS_PER_SOCKET`, `AKAN_LIVE_ROOMS_PER_CALLER` and `AKAN_LIVE_ROOMS_PER_MODEL`, set to a count or `off`, override the code for one deployment.
|
|
360
|
+
- To change the subscribe budgets, call `option.setRateLimit({ subscribe: { perSocket: { calls, windowMs }, perCaller: { calls, windowMs } } })`. Set either to `false` to lift it, or `subscribe: false` to lift both. Like every other budget, they are off in a `local` environment and under `AKAN_RATE_LIMIT=off`.
|
|
361
|
+
- The client retries a budget refusal at most five times, waiting the server's `seconds` (1 to 60) plus up to a second per try; this has no setting. A client of your own that speaks the websocket frames can send a numeric `token` on each subscribe frame to have it echoed on that subscribe's error frame.
|
|
362
|
+
|
|
363
|
+
- 876a2bd: The OpenAI-dialect and Anthropic adaptors read more of how a stream ends.
|
|
364
|
+
|
|
365
|
+
- A stream that closes on its end marker alone (`[DONE]`, or Anthropic's `message_stop`) with no finish reason, after a tool call whose arguments never arrived, now ends as `length` instead of running that call with `{}`. A tool that takes no arguments still runs: one with no `parameters`, or an object schema with no `properties` and no `$ref`, `anyOf`, `oneOf`, `allOf`, `patternProperties`, `required` entry or open `additionalProperties`, any of which may describe arguments. `OpenaiDialect.consumeStream` and `AnthropicLlm.consumeStream` take the turn's tools as a fourth argument to tell the two apart; called without them, every such call counts as cut.
|
|
366
|
+
- Tool-call arguments that are not one JSON object, in an answer the model finished, no longer end the turn as `length` with a "ran out of room" message. The model finished it when the finish reason is `tool_calls` or `stop`, or Anthropic's `tool_use` or `end_turn`. The call gets `argsError` (and `args: {}`), and `agentService.loop` answers it with that parse error and the code `invalidArgument` instead of running it, so the model can write it again. The loop stores that answer before anything else in the batch runs or parks, so the refusal is in the transcript as a result. Behind any other finish reason (`length`, `max_tokens`, `content_filter`) or none, the arguments were cut mid-way and the turn is still `length`; a whole (non-streamed) OpenAI-dialect answer follows the same rule, where it used to run such a call with `{}`. The in-page relay has no way to hand a call its error, so it still ends a turn with a malformed call as `length`.
|
|
367
|
+
- vLLM's bare `{"object":"error", ...}` frame and a `finish_reason` of `"error"` (OpenRouter's, for an upstream that failed mid-answer) now fail the turn as `agent.error.llmRequestFailed`, or `contextOverflow` when the message says the prompt did not fit, instead of reading as an empty or truncated answer. The failure carries the provider's counts, or an estimate of what was streamed.
|
|
368
|
+
- An error inside a stream keeps the status its type names in `agent.error.llmRequestFailed`'s `status`, where Anthropic's always read 500: `overloaded_error` is 529, `rate_limit_error` 429, `invalid_request_error` 400, and so on. An OpenAI-dialect error frame with no numeric code is read the same way from its `code` or `type` (`rate_limit_exceeded` is 429). A type no table names is still 500.
|
|
369
|
+
|
|
370
|
+
**Upgrading.** Code that calls `agentService.runTurn`, an adaptor's `chat` or a `consumeStream` itself, and runs the tool calls it gets back, must check `argsError` before running a call. An answer the model finished with arguments that do not parse used to stop as `length`; it now stops as `toolUse` with `args: {}` on that call, and a caller that ignores `argsError` would run it with no arguments. Answer such a call with its `argsError` as the error instead. `agentService.loop` and the in-page relay already do. Store an assistant message's tool calls whole, `argsError` included: a transcript the loop resumes from should carry the flag, though a malformed call the loop already answered is not run again without it. The new arguments are optional.
|
|
371
|
+
|
|
372
|
+
- 9928a8f: A model loader no longer shares a batch between a transaction and the requests outside it. `get<Model>`, `load<Model>`, `load<Model>Many` and every declared loader batch the loads of one tick into one query, and that query ran for whichever caller asked first: a load inside `this.transaction()` that joined a batch from another request read the committed row instead of its own write, and a load from another request that joined the transaction's batch read rows it had not committed. Each open transaction now gets a batch of its own, run on its own connection, on SQLite and Postgres alike. A load inside a transaction is never answered from a loader's `cache` and what it reads is not kept, since it may be rolled back.
|
|
373
|
+
|
|
374
|
+
**Upgrading.** Nothing to change. `DatabaseAdaptor` gains an optional `transactionKey()`, which a custom database adaptor implements to get the same separation, and `DataLoader` takes a `scopeFn` option; a `batchScheduleFn` must run its callback in the caller's async context, as `queueMicrotask` and `setImmediate` do.
|
|
375
|
+
|
|
376
|
+
- 9928a8f: A model loader that keeps its keys (`{ cache: true }` or a number of milliseconds) now forgets them when the model is written. A create, a `save()`, an update or a remove drops every key the document answers now or answered before the write; a write by query (`updateMany`, `updateOne`, `removeMany`, `bulkWrite`, `upsertById`, a purge or an import) names no document, so it drops every kept key of the model. Either happens once the write commits, ahead of every post hook and `afterCommit` callback, so none of them and no later load is answered from before the write, and a write that rolls back drops nothing. A kept key used to be answered in its old shape until it expired, or forever under `cache: true`. A `byQuery` loader's cache is keyed by the values of its query fields rather than by the query object, so an equal query is answered from it.
|
|
377
|
+
|
|
378
|
+
`cache: true` keeps the 10,000 keys used most recently instead of every key the process ever loaded.
|
|
379
|
+
|
|
380
|
+
**Upgrading.** Nothing to change, but check where `cache` is declared: a write by query clears every kept key of its model, so a model that takes `updateOne` or `updateMany` often gets little from a kept loader. Another instance keeps its own keys until they expire, as before. New, all optional: `DataLoader` takes `maxCacheSize`; a document store has `onWrite(listener)`, which hears of each committed write; and `afterCommit(fn, { first: true })` on a database adaptor queues `fn` ahead of the callbacks queued without it. A store listener that throws is logged and fails neither the write nor the other listeners. A custom database adaptor that ignores the option still runs the callback, in the order it was queued.
|
|
381
|
+
|
|
382
|
+
- a91a643: A client of the `/_akan/app/logs` SSE stream that stops reading no longer grows the server without limit. At most 4 MiB of live records waits for it, on top of what a `Last-Event-ID` resume replays, which always arrives whole; past that, records are dropped and counted, and when the client reads again it gets one `{ "type": "dropped", "count": n }` event before the next record. A client that misses more than 10,000 records in one stall is disconnected and has to reconnect, resuming from its `Last-Event-ID` as usual.
|
|
383
|
+
|
|
384
|
+
`EventStream` from `akanjs/common` takes the same bound as two new options, `maxQueuedBytes` and `maxDropped`. Without them a stream queues every event as before, which the MCP and agent-turn streams keep, since a dropped frame there would lose a reply.
|
|
385
|
+
|
|
386
|
+
No upgrade step is needed.
|
|
387
|
+
|
|
245
388
|
- d6b3619: Every `Err` is now one class, `Err` from `akanjs/common`. That covers the one an app's or lib's `lib/dict` builds, the one `useClient` returns, `akanjs/dictionary`'s own, and an error restored off the wire. Each is that class typed with its own dictionary's keys, so `Err.is` and the status classes behave the same in the browser and on the server. `instanceof Err` holds within one copy of the module. A page bundle and the framework each carry one, so check across them with `Err.is`.
|
|
246
389
|
|
|
247
390
|
- **`Err` is an `AkanError`.** `AkanError.is(err)` is true for every `Err`, and `err.forwarded` is true unless it was restored with a `code`, so the request path still sends its `toJSON()` as it is.
|
|
@@ -287,6 +430,15 @@
|
|
|
287
430
|
- **iOS and Android shells pick status bar icons that read on the color in effect**, from the variable or from `themeColor`: dark icons on a light color (relative luminance over 0.5), light ones on a dark color. The page still draws under the bar, so the bar gets no background of its own. `appearance.setThemeColor({ color })` carries the color, so add `"appearance"` to `native.plugins` for it. An app without the plugin keeps its status bar as before.
|
|
288
431
|
- **An app that names `appearance` needs new phone binaries.** The plugin gains a method, so the native API a phone's web updates are keyed by changes for that app: a binary built before it gets no web update built after it. An app that does not name `appearance` keeps its key.
|
|
289
432
|
|
|
433
|
+
- 9928a8f: On SQLite, work outside an open `this.transaction()` no longer sees its uncommitted rows on an in-memory database (`:memory:`, the `TestServer` default) or on a file with a journal mode other than WAL either. A read from another request now returns the last commit on every storage, without waiting for the transaction, so a transaction that awaits a read started outside it, or one that never ends, holds up no read.
|
|
434
|
+
|
|
435
|
+
- **A file with a rollback journal** gets the second, read-only connection a WAL file already had. The writer runs with `cache_spill` off, so that connection is never locked out, and a transaction's uncommitted pages stay in memory until it commits: one that writes 400 MB grows the process by about that much (456 MB measured) until then.
|
|
436
|
+
- **An in-memory database** cannot be opened twice, so before a transaction begins the adaptor copies the last commit, and reads from outside the transaction run on the copy. The copy costs one pass over the database per transaction: 0.02 ms at 0.3 MB (a test-sized database), 0.2 ms at 5 MB, 2.5 ms at 50 MB and 16 ms at 200 MB, measured, plus about half as much again when a read first uses it. It holds one more copy of the database in memory while the transaction is open and is freed when it ends: a 34 MB database grew the process by about 20 MB across 1,500 transactions, with or without reads on the copy. Past a few tens of megabytes, put the database in a file.
|
|
437
|
+
|
|
438
|
+
A write from another request still waits for the open transaction, as before, and now runs before any transaction that was asked for after it.
|
|
439
|
+
|
|
440
|
+
**Upgrading.** `SqliteDatabase.getMeta` and `listMeta` now return promises, as they already did on Postgres, so await them. `ConformanceEnv.openSqlDriver` takes a `sqlite` option, set over the file's default pragmas; nothing changes for a caller that does not pass it.
|
|
441
|
+
|
|
290
442
|
- 3d1d448: `Field.Switch` takes a `variant` prop, and its on position is now `primary`, as it is on `Switch`.
|
|
291
443
|
|
|
292
444
|
- **A `Field.Switch` without `variant` changes color:** the on position was `accent` and is now `primary`. Pass `variant="accent"` to keep the old look, or `"success"`.
|
|
@@ -326,6 +478,16 @@
|
|
|
326
478
|
- **The `akan-service` skill** carries a recipe for pages backed by an external HTTP API: an `adapt()` adapter in `srvkit/` that reads its base URL at boot, a `lib/_<service>` service, a `Public` `query(Any, { nullable: true })` endpoint and its dictionary label, and the page that calls it.
|
|
327
479
|
- **The README's "Inside an existing repository"** runs the creator through `npx -y bun@1.4.4 x …` on a host with only Node and npm, so nothing global is written. It also gives copy-ready `build` and `start` scripts, says a fresh clone builds without a committed env file, and says which environment a `.env`-less build is for and what a deployed host sets instead.
|
|
328
480
|
|
|
481
|
+
- 876a2bd: `agentService.loop` keeps one call's usage, results and answers from landing on another call.
|
|
482
|
+
|
|
483
|
+
- Two runs, or two turns, stopped by one `AbortController` no longer bill one call's usage to the other with `OpenaiLlm` and `AnthropicLlm`: a run stopped before its provider answered was reported with the tokens another run had streamed. `llmCallSignal` now stops each provider call under an `AbortError` of its own, which names the caller's reason as its `cause`, where it used to pass the caller's reason object on; the 120-second limit still ends a call as a `TimeoutError`, on a turn reported `failed`, not `aborted`. An app that shares one controller across runs changes nothing.
|
|
484
|
+
- A model that reuses a tool-call id from an earlier turn no longer ends the conversation when its later call goes unanswered. The earlier call's result made the later one look answered, so it got no "stopped before this call ran" result and the provider refused that request and every one after it. A result now answers the nearest call before it, and two calls a model gives one id in the same batch each keep a result of their own. The in-page chat's transcript in `use-agentic` still matches answers by id alone.
|
|
485
|
+
- A run that dies in the middle of a batch no longer runs the calls that had finished a second time when it is resumed. `onMessage` now receives a batch's results one tool message per call, as each call finishes and before its `toolResult` event, where it received one message per batch after the last call. A call that was still running when the run died cannot be told from one that never started: like any trailing call nothing answered, it goes to `approve` again and runs again, so a write that must not land twice needs an idempotent endpoint or an `approve` that defers it.
|
|
486
|
+
- A resume keeps the stricter taint rule it had. An uninterrupted run judges a batch before any of it runs, so a result of the batch never taints the calls beside it. A resumed run judges on everything stored: a result of the part-finished or parked batch that `untrusted` marks still taints the calls that batch has left, which are refused as writes or reach `approve` with `tainted: true`.
|
|
487
|
+
- `compact.keep` counts a batch's tool messages as one message, so a compaction keeps the rounds it kept before.
|
|
488
|
+
|
|
489
|
+
**Upgrading.** A caller that stores each message `onMessage` hands over, in order, and replays them changes nothing: a stored transcript with one tool message per batch still resumes. Code that expects exactly one tool message after an assistant message with tool calls, to render or pair them, must read every tool message up to the next message of another role. Code that calls a shipped adaptor's `chat` itself and compares the rejection with its own abort reason reads `error.cause` instead.
|
|
490
|
+
|
|
329
491
|
- 6fc8a60: A toast now shows above a modal the floating `Agent.Chat` opened, and a question from the agent leaves focus and Escape to that modal.
|
|
330
492
|
|
|
331
493
|
- **Toasts top every overlay but Reconnect.** `overlayZ.toast` moves from 140 to 180, above the agent panel (150), a modal the panel opened (160) and one a card opened (170), so a toast reporting what that modal's controls did is no longer hidden behind it.
|
|
@@ -512,6 +674,11 @@
|
|
|
512
674
|
- It sits behind the same gate as the other `/_akan` devtools routes, and `akan tunnel` / `akan start --share` refuse it.
|
|
513
675
|
|
|
514
676
|
- 96f9ff6: A `Binary` argument reaches `exec` typed as `Uint8Array<ArrayBuffer>`, so it can go straight to a service or a `fetch` body. Before, it was a copy of `Uint8Array` with every method stripped. A `Binary` return still takes any `Uint8Array`.
|
|
677
|
+
- 935bddf: A model's `bulkWrite` now runs its operations in one transaction, so an operation that fails leaves none of the batch applied; called inside an open transaction, it joins that one.
|
|
678
|
+
|
|
679
|
+
**Upgrading.** `bulkWrite` used to keep the operations before the one that failed, as MongoDB's ordered `bulkWrite` does. Code that relied on those earlier writes surviving a failure should split the batch, or catch per operation with `updateOne`.
|
|
680
|
+
|
|
681
|
+
- 935bddf: A cascade that removes the documents a long array field references in one query now removes them 200 ids at a time inside one transaction, so a large array no longer runs past Postgres's bound-parameter limit or builds one huge statement on SQLite.
|
|
515
682
|
- af7c411: The five child-process restart loops now share one restart schedule, `RestartSchedule` from `akanjs/common`: the gateway's replicas, the RSC worker, the incremental builder, and `akan start`'s backend and builder recovery. It counts failed restarts, waits before the next one and cancels a pending one on stop. Each loop keeps its own delays (200ms–30s for the RSC worker, 2s–60s for `akan start`'s builder recovery, 1s–30s for the rest), its own give-up rule and its own log lines.
|
|
516
683
|
|
|
517
684
|
Two stop races in those loops are fixed:
|
|
@@ -554,6 +721,16 @@
|
|
|
554
721
|
`akan tunnel` and `akan start --share` keep working: the tunnel agent now dials the local app under the app's own address and leaves the public host name in `x-forwarded-host`, which is where the app already reads it. A redirect a page raises during SSR now sends a same-origin target as a relative `Location`, so a tunnel or proxy caller lands on the host it used rather than the one the server was dialed as; a target on another origin stays absolute.
|
|
555
722
|
|
|
556
723
|
- 9f30e93: A dev page no longer loses its styles after a stylesheet change arrives together with a pages rebuild. The most common case was the first save after `akan start` released its builder for being idle: the waking builder announces a new pages bundle and a new stylesheet at once, and the SSR worker that had started importing the bundle put the old stylesheet back when the import finished. Pages kept linking that stylesheet, whose file the dev server had already deleted, so they rendered unstyled with a 404 until `akan start` was restarted. The same update also reaches an SSR worker that is still booting after a recycle, which used to keep the stylesheet it was started with.
|
|
724
|
+
- b5989d1: Concurrent misses of one `cache` endpoint key now share a single run in this process, so a burst of callers right after an invalidation no longer runs the endpoint once each. Every caller gets its own copy of the answer, as a cache hit does, a failed run is not cached and rejects every caller waiting on it, and a run older than the endpoint's `timeout` (60 seconds with none) is no longer joined.
|
|
725
|
+
|
|
726
|
+
A run in flight in this process when an endpoint is invalidated, whole or for given args, is not joined by later callers and does not write its answer to the cache. A run in flight on another instance can still write a stale answer after a per-args invalidation, as before.
|
|
727
|
+
|
|
728
|
+
**Upgrading.** The first caller of a miss now gets the same copy a cache hit returns, not the object the handler returned. A middleware or resolveField that read a method or an undeclared property of that object worked on a miss and failed on a hit; it now fails on both.
|
|
729
|
+
|
|
730
|
+
- a91a643: The ndjson stdout now gets every log record, and a request line (`AKAN_LOG_CANONICAL`) is never folded as a repeat anywhere, so counting request lines counts requests. Before, a line repeated more than 20 times a second was folded into one "suppressed" line before stdout saw it, and request lines folded too because their attrs were ignored: 101 requests wrote 21 lines and a summary.
|
|
731
|
+
|
|
732
|
+
The folding of other repeats now applies only to what the hub keeps in memory (the ring that `akan logs`, history and resumes read, and the live tails fed from it) and to the ndjson log file, which still needs it to keep up with a hot loop. The `seq` on a stdout line can now skip a number, where a fold line sits in the ring.
|
|
733
|
+
|
|
557
734
|
- ad09fac: Exports that nothing in akanjs, its tests or a consumer workspace uses are now marked. Thirteen that no code calls at all are `@deprecated` and leave in a later minor: `MAX_INT` (write `2 ** 31 - 1`), `isFilterModel` (`getFilterMeta(ref, { allowEmpty: true }) !== undefined`), `setFilterInfoByKey` (declare the query with `from(model, (filter) => …)`), `getDefaultSchemaOptions` (`new DocumentSchema()`), `runWithTrace` (`runTraced`, only where the caller owns the trace, since it finalizes it), `traceDbQuery` (`getCurrentTrace()?.countDbQuery(ms)`), `isSitemapPath` (`getSitemapBasePath(pathname, basePaths, headerBasePath) !== undefined`), `useRscNavigation` (`navigateRsc`, `clearRscNavigationCache`, `isRscNavigationFromCache`), `getSearchParam` and `getBaseSearchParam` (read `searchParams[key]`, taking the first value of an array), `dictionaryContext`, `groupByOwner` and `ServiceRegistry`. Eleven that only their own file uses, such as the console helpers in `akanjs/server` and `getClientRuntime` in `akanjs/client`, are `@internal`: they are not meant for use outside akanjs and may stop being exported in a later minor.
|
|
558
735
|
- ae045d8: No non-test file in an `akanjs` facet imports its own facet's barrel any more; each imports the sibling file that declares what it uses. Four value imports in `constant/` went through its barrel, so loading one of those files loaded the whole facet first. `ResolveFieldContext` moved to `signal/resolveFieldContext.ts`, and `akanjs/signal` still exports it. Every public import is unchanged.
|
|
559
736
|
- d9eaacc: A query takes `signal` in its `FetchPolicy`, joined with its deadline: an abort rejects the call with the signal's reason, stops the request, and ends the retries, including one waiting between tries. A signal already aborted sends nothing, over HTTP, inside a server render or through an MCP App view's host. A signal from `AbortSignal.timeout` rejects with the slow-server error (`base.error.gatewayTimeout`, 408), as the query's own deadline does. A mutation ignores it, since one already sent may have run. In an MCP App view an abort, or the query's own deadline running out, also asks the host to cancel the call it relayed (`notifications/cancelled`); a mutation that runs out of time is only given up on. A custom `FetchBridge` receives the signal as `signal`.
|
|
@@ -589,6 +766,7 @@
|
|
|
589
766
|
- **A form opened under the same draft scope while `create<Model>InForm` or `update<Model>InForm` waits for the server opens without that draft**, so a second new form is not refilled with what the first is creating. The draft stays in storage until the request succeeds, so a reload during the save still restores it, and it is kept when the request fails. On success it is deleted only while it still holds the saved form, so a draft that a form opened meanwhile wrote is kept. A form holding an `undefined` value now compares equal to its stored draft, which drops that value; before, the saved form's own draft was kept and refilled the next new form. A draft discarded or reset during the save stays gone when the save fails. A draft write still pending when the save starts is written first.
|
|
590
767
|
- **A failed `view<Model>` or `edit<Model>` that is still the latest open closes its modal**, unless the modal already shows that record, as when a page payload seeded it. Before, the modal stayed open over the previous record.
|
|
591
768
|
|
|
769
|
+
- 3a54335: The AkanApp gateway's start-up line now names the port it actually bound, so a gateway started on port 0 logs the port the system gave it instead of 0.
|
|
592
770
|
- e143263: The optional `happy-dom` and `@happy-dom/global-registrator` peers now ask for `^21.0.4`. Versions 17.0.0 through 21.0.3 compile a `<script type="module">` import alias into code unchecked, so a page loaded into a happy-dom window could run code on the host (GHSA-834v-8h66-3h79). UI tests register one through `akanjs/test/registerDom`; run `bun update happy-dom @happy-dom/global-registrator` in a workspace that pins an older one.
|
|
593
771
|
- e4f7876: A hidden field declared `.optional()` (`field.hidden(String).optional()`) is optional again in a service's `create<Model>` and `create<Model>Many` input, and in the document type `by()` makes of an input model or a scalar. It was typed there as a required, non-null value, though the model's own document already typed it optional, so a create that left it out needed a cast. A hidden field without `.optional()` stays required. Code that read such a field off a scalar's document as always present now handles its absence, as it already did on the model's document.
|
|
594
772
|
- cb0fd5b: Reading the client address from a forwarded header no longer stalls the server on a crafted hop. `IpLiteral.parse` matched a bracketed IPv6 hop with a pattern that backtracked quadratically, so an `X-Forwarded-For` or `X-Real-IP` entry of `[` and a long run of colons kept the event loop busy for about 100 ms per 16 KB of header, on every request that carried it. The bracket is now matched in linear time and the colon checked apart; every address parses as before.
|
|
@@ -1087,9 +1265,6 @@
|
|
|
1087
1265
|
- 91ccf38: Internal: `makeActions` and `useCsrValues` are composed from one file per action set and hook instead of two monoliths. Store actions, hook order, effects and their dependencies are unchanged.
|
|
1088
1266
|
- c2af76a: Internal: the web router's route table is built by one collaborator per route family instead of one 437-line method. Routes, their order, headers, caching and error answers are unchanged. The framework map now follows a send through a field that hands out its receiver (`this.#hub()?.broadcast(...)`), so `ARCHITECTURE.md` still names who sends each HMR message.
|
|
1089
1267
|
- df32c46: On SQLite, work outside an open `this.transaction()` no longer sees it or joins it. A read from another request ran on the one shared connection, inside the transaction, so it returned rows the transaction had not committed, including rows it then rolled back. It now runs on a second, read-only connection to the same WAL file and sees what is committed, as on Postgres, without waiting for the transaction; code inside the transaction still reads its own writes. A write from another request already waited for the open transaction, but when a second transaction began as the first committed, the waiting write could run inside the second one and be rolled back with it after its caller was told it had succeeded. It now runs between the two.
|
|
1090
|
-
|
|
1091
|
-
An in-memory database (`:memory:`, the `TestServer` default) and a journal mode other than WAL keep one connection: a second connection cannot read the same in-memory data, and outside WAL it would wait on the writer's lock and stall the event loop. There, writes from other requests still wait for the transaction and are never rolled back with it, but reads still see its uncommitted rows. Code that read another request's uncommitted write now sees the committed state instead.
|
|
1092
|
-
|
|
1093
1268
|
- 5f809e8: A server-rendered page now shows its content as soon as the HTML arrives. The response started before the layout and page bodies had rendered, so React put even a page whose data was ready into a hidden segment and revealed it with a script it throttles to 300ms after the first paint. A browser test that clicked in that gap failed now and then, and a URL with a fragment (`/books/OL45804W#editions`) missed its target. `ssr: "block"` did not fully help: React still showed the `.loading()` fallback in front of a large page it had already rendered.
|
|
1094
1269
|
|
|
1095
1270
|
- **The response waits for the levels above the first `.loading()`.** Every layout and page above a route's first `.loading()`, or the whole route when it declares none, renders before the first byte is sent and is written in place, with the client modules it uses loaded. Each level keeps its own boundary, so a client component that fails on the server, or a hydration mismatch, still client-renders only its level. A level with `.loading()` sends its fallback first and reveals its content together with the levels below it. A route whose data is slow and that declares no `.loading()` now sends nothing until the data is ready; give the slow level a `.loading()` to keep the fallback first. An async component a body renders that is still pending once the bodies are done streams in after the shell, as before. A client navigation's payload starts at the same point.
|
|
@@ -1100,6 +1275,7 @@
|
|
|
1100
1275
|
- fd125b0: `akanjs/server` exports `StageFailedError`, the error a failed DI startup stage throws, so `StageFailedError.is(error)` narrows to a type whose `errors` holds each failed task's error without a cast.
|
|
1101
1276
|
- a5c476a: A gateway stopped while `AkanApp.start()` was still preparing its runtime folder, logs or ops route no longer spawns replicas or listens afterwards, and its `start()` now returns instead of waiting for a stop that has already happened. A server without a gateway stopped while `AkanServer.start({ listen: false })` was opening its log control socket no longer runs its init schedules afterwards.
|
|
1102
1277
|
- 76705dd: `StoreRegistry.build` now reads a root store's state, actions and slices from the merged type rather than inferring them back out of it. That inference grew quadratically with the number of stores. In an app merging about 70 stores, `build` took most of the typecheck, and adding a few more stores failed it with TS2589 ("Type instantiation is excessively deep"). With this change the typecheck cost grows linearly with the store count, and the `st` type is unchanged.
|
|
1278
|
+
- 9292352: Store registration imports `attachAgentic` from its own file instead of the agentic barrel, so every route's client bundle loads one chunk fewer (about 0.4–0.6KB brotli).
|
|
1103
1279
|
- 206bb69: A store write now costs about one copy of the state, whatever else the root holds. Before, every `set` copied the state twice, compared every key, re-read every `search()` value, and walked every persisted key and every model form. That came to 173 µs at 1,740 keys and 364 µs at 3,480. Now `set` works out the changed keys from the patch and copies the state once. It then recomputes only the `search()` values (when `searchParams` changed) and the `computed()` values whose dependencies changed, and syncs only the persisted keys and form drafts the write touched. That is 38 µs at 1,740 keys and 78 µs at 3,480, the cost of the copy itself.
|
|
1104
1280
|
|
|
1105
1281
|
- **One `set` per model write.** `update<Model>`, `update<Model>InForm`, `merge<Model>`, `set<Model>`, `remove<Model>`, `create<Model>` and `create<Model>InForm` now write the model, every slice list that holds the row, and the stale stamps in one `set`. Before, they called `set` once per slice, plus once more. An update at 1,640 keys went from 488 µs to 47 µs.
|
package/common/Logger.ts
CHANGED
|
@@ -156,9 +156,11 @@ export class Logger {
|
|
|
156
156
|
const logLevelMsg = colorizeMap[level](level.toUpperCase().padStart(7, " "));
|
|
157
157
|
const contextMsg = record.context ? clc.yellow(`[${record.context}] `) : "";
|
|
158
158
|
const contentMsg = colorizeMap[level](record.message);
|
|
159
|
-
const
|
|
159
|
+
const { stack, ...inline } = record.attrs ?? {};
|
|
160
|
+
const attrsMsg = record.attrs ? Logger.formatAttrs(typeof stack === "string" ? inline : record.attrs) : "";
|
|
161
|
+
const stackMsg = typeof stack === "string" ? `${stack}\n` : "";
|
|
160
162
|
const timeDiffMsg = clc.yellow(`+${record.elapsedMs}ms`);
|
|
161
|
-
return `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg}${attrsMsg ? ` ${attrsMsg}` : ""} ${timeDiffMsg}\n`;
|
|
163
|
+
return `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg}${attrsMsg ? ` ${attrsMsg}` : ""} ${timeDiffMsg}\n${stackMsg}`;
|
|
162
164
|
}
|
|
163
165
|
static formatAttrs(attrs: LogAttrs): string {
|
|
164
166
|
return Object.entries(attrs)
|
package/common/clientAddress.ts
CHANGED
|
@@ -11,6 +11,20 @@ export const forwardedHeaders = [
|
|
|
11
11
|
|
|
12
12
|
export const normalizeIpAddress = (address: string): string => IpBytes.normalize(address);
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* An IPv6 address as its /64 (`2001:db8:1:2::/64`), since one host is handed a whole /64 and may use any address in
|
|
16
|
+
* it; an IPv4 address, also when mapped into IPv6, as itself.
|
|
17
|
+
*/
|
|
18
|
+
export const addressBlockOf = (address: string): string => {
|
|
19
|
+
const normalized = normalizeIpAddress(address);
|
|
20
|
+
const bytes = normalized.includes(":") ? IpBytes.of(normalized) : null;
|
|
21
|
+
if (!bytes) return normalized;
|
|
22
|
+
if (bytes.subarray(0, 10).every((byte) => byte === 0) && bytes[10] === 0xff && bytes[11] === 0xff)
|
|
23
|
+
return [...bytes.subarray(12)].join(".");
|
|
24
|
+
const groups = [0, 2, 4, 6].map((at) => (((bytes[at] ?? 0) << 8) | (bytes[at + 1] ?? 0)).toString(16));
|
|
25
|
+
return `${groups.join(":")}::/64`;
|
|
26
|
+
};
|
|
27
|
+
|
|
14
28
|
/**
|
|
15
29
|
* Without `isTrusted`: `x-real-ip`, else the leftmost `x-forwarded-for` entry. With it: `x-forwarded-for` walked from
|
|
16
30
|
* the nearest hop past every address it vouches for, and `x-real-ip` only when there is none. `null`, never a
|
package/common/eventStream.ts
CHANGED
|
@@ -2,6 +2,10 @@ export interface EventStreamOptions {
|
|
|
2
2
|
keepAliveMs?: number;
|
|
3
3
|
/** What the keep-alive sends; a line starting with `:` is a comment every SSE client discards. */
|
|
4
4
|
keepAliveChunk?: string;
|
|
5
|
+
/** Past this many queued bytes `write` drops and counts; the reader gets `{ type: "dropped", count }` on resuming. */
|
|
6
|
+
maxQueuedBytes?: number;
|
|
7
|
+
/** Drops in one stall past which the stream is errored and `onCancel` runs. */
|
|
8
|
+
maxDropped?: number;
|
|
5
9
|
}
|
|
6
10
|
|
|
7
11
|
export class EventStream {
|
|
@@ -11,24 +15,40 @@ export class EventStream {
|
|
|
11
15
|
readonly #stream: ReadableStream<Uint8Array>;
|
|
12
16
|
#controller: ReadableStreamDefaultController<Uint8Array> | null = null;
|
|
13
17
|
#keepAlive: ReturnType<typeof setInterval> | null = null;
|
|
18
|
+
readonly #onCancel: () => void;
|
|
19
|
+
readonly #maxQueuedBytes: number | null;
|
|
20
|
+
readonly #maxDropped: number | null;
|
|
21
|
+
#dropped = 0;
|
|
14
22
|
|
|
15
23
|
constructor(
|
|
16
24
|
onCancel: () => void,
|
|
17
|
-
{
|
|
25
|
+
{
|
|
26
|
+
keepAliveMs = EventStream.defaultKeepAliveMs,
|
|
27
|
+
keepAliveChunk = ":\r\n",
|
|
28
|
+
maxQueuedBytes,
|
|
29
|
+
maxDropped,
|
|
30
|
+
}: EventStreamOptions = {},
|
|
18
31
|
) {
|
|
19
|
-
this.#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
this.#onCancel = onCancel;
|
|
33
|
+
this.#maxQueuedBytes = maxQueuedBytes && maxQueuedBytes > 0 ? maxQueuedBytes : null;
|
|
34
|
+
this.#maxDropped = this.#maxQueuedBytes && maxDropped !== undefined && maxDropped >= 0 ? maxDropped : null;
|
|
35
|
+
this.#stream = new ReadableStream<Uint8Array>(
|
|
36
|
+
{
|
|
37
|
+
start: (controller) => {
|
|
38
|
+
this.#controller = controller;
|
|
39
|
+
this.#keepAlive = setInterval(() => this.#enqueue(keepAliveChunk, false), keepAliveMs);
|
|
40
|
+
|
|
41
|
+
this.#keepAlive.unref?.();
|
|
42
|
+
},
|
|
43
|
+
pull: () => this.#reportDropped(),
|
|
44
|
+
cancel: () => {
|
|
45
|
+
this.#stopKeepAlive();
|
|
46
|
+
this.#controller = null;
|
|
47
|
+
onCancel();
|
|
48
|
+
},
|
|
30
49
|
},
|
|
31
|
-
|
|
50
|
+
this.#maxQueuedBytes ? new ByteLengthQueuingStrategy({ highWaterMark: this.#maxQueuedBytes }) : undefined,
|
|
51
|
+
);
|
|
32
52
|
}
|
|
33
53
|
|
|
34
54
|
get open() {
|
|
@@ -49,15 +69,15 @@ export class EventStream {
|
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
write(message: object, id?: string | number) {
|
|
52
|
-
this.#enqueue(`${id === undefined ? "" : `id: ${id}\n`}data: ${JSON.stringify(message)}\n\n
|
|
72
|
+
this.#enqueue(`${id === undefined ? "" : `id: ${id}\n`}data: ${JSON.stringify(message)}\n\n`, true);
|
|
53
73
|
}
|
|
54
74
|
|
|
55
75
|
comment(text: string) {
|
|
56
|
-
this.#enqueue(`: ${text}\n\n
|
|
76
|
+
this.#enqueue(`: ${text}\n\n`, false);
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
retry(ms: number) {
|
|
60
|
-
this.#enqueue(`retry: ${ms}\n\n
|
|
80
|
+
this.#enqueue(`retry: ${ms}\n\n`, false);
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
close() {
|
|
@@ -70,10 +90,16 @@ export class EventStream {
|
|
|
70
90
|
}
|
|
71
91
|
}
|
|
72
92
|
|
|
73
|
-
#enqueue(chunk: string) {
|
|
74
|
-
|
|
93
|
+
#enqueue(chunk: string, counted: boolean) {
|
|
94
|
+
const controller = this.#controller;
|
|
95
|
+
if (!controller) return;
|
|
96
|
+
const bytes = this.#encoder.encode(chunk);
|
|
97
|
+
if (this.#overflows(controller, bytes.byteLength)) {
|
|
98
|
+
if (counted) this.#drop();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
75
101
|
try {
|
|
76
|
-
|
|
102
|
+
controller.enqueue(bytes);
|
|
77
103
|
} catch {
|
|
78
104
|
|
|
79
105
|
this.#stopKeepAlive();
|
|
@@ -81,6 +107,32 @@ export class EventStream {
|
|
|
81
107
|
}
|
|
82
108
|
}
|
|
83
109
|
|
|
110
|
+
#overflows(controller: ReadableStreamDefaultController<Uint8Array>, bytes: number) {
|
|
111
|
+
const max = this.#maxQueuedBytes;
|
|
112
|
+
if (!max) return false;
|
|
113
|
+
const queued = max - (controller.desiredSize ?? max);
|
|
114
|
+
return this.#dropped > 0 || (queued > 0 && queued + bytes > max);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#drop() {
|
|
118
|
+
this.#dropped += 1;
|
|
119
|
+
if (this.#maxDropped === null || this.#dropped <= this.#maxDropped) return;
|
|
120
|
+
const controller = this.#controller;
|
|
121
|
+
this.#stopKeepAlive();
|
|
122
|
+
this.#controller = null;
|
|
123
|
+
|
|
124
|
+
controller?.error(new Error(`event stream reader stalled past ${this.#maxDropped} dropped events`));
|
|
125
|
+
this.#onCancel();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#reportDropped() {
|
|
129
|
+
const controller = this.#controller;
|
|
130
|
+
if (!controller || !this.#dropped) return;
|
|
131
|
+
const count = this.#dropped;
|
|
132
|
+
this.#dropped = 0;
|
|
133
|
+
controller.enqueue(this.#encoder.encode(`data: ${JSON.stringify({ type: "dropped", count })}\n\n`));
|
|
134
|
+
}
|
|
135
|
+
|
|
84
136
|
#stopKeepAlive() {
|
|
85
137
|
if (this.#keepAlive) clearInterval(this.#keepAlive);
|
|
86
138
|
this.#keepAlive = null;
|
package/common/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ export { CodeTranscript, type CodeTranscriptPart } from "./CodeTranscript";
|
|
|
39
39
|
export { capitalize, lowerlize } from "./capitalize";
|
|
40
40
|
export { clamp } from "./clamp";
|
|
41
41
|
export {
|
|
42
|
+
addressBlockOf,
|
|
42
43
|
clientAddressFromHeaders,
|
|
43
44
|
clientPortFromHeaders,
|
|
44
45
|
forwardedHeaders,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
const store = globalThis as unknown as { __akanLoggedFailures?: WeakSet<object> };
|
|
3
|
+
store.__akanLoggedFailures ??= new WeakSet<object>();
|
|
4
|
+
const logged = store.__akanLoggedFailures;
|
|
5
|
+
|
|
6
|
+
export const markFailureLogged = (error: unknown): void => {
|
|
7
|
+
if (typeof error === "object" && error !== null) logged.add(error);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const wasFailureLogged = (error: unknown): boolean =>
|
|
11
|
+
typeof error === "object" && error !== null && logged.has(error);
|
package/common/types.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface FetchPolicy<_Returns = unknown> {
|
|
|
28
28
|
* for this socket, or once the server's link to the app's other servers returns — so refetch what the room shows.
|
|
29
29
|
*/
|
|
30
30
|
onResync?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* `pubsub` only: called once when the server refused the room for a limit (429), with the error it sent; the room is
|
|
33
|
+
* dropped, so a reconnect does not send it again, and subscribing anew tries again.
|
|
34
|
+
*/
|
|
35
|
+
onRefused?: (error: unknown) => void;
|
|
31
36
|
/**
|
|
32
37
|
* Tries again when the server is unreachable, restarting (502/503), too slow (504) or limiting (429, after its
|
|
33
38
|
* Retry-After). A mutation retries under one `Idempotency-Key`, which the server runs once; `false` turns a client's
|
|
@@ -39,6 +39,14 @@ export const agentDictionary = serviceDictionary(["en", "ko"])
|
|
|
39
39
|
"이 계정의 에이전트 사용 한도에 도달했습니다.",
|
|
40
40
|
],
|
|
41
41
|
requestRefused: ["This app's agent does not take this request", "이 앱의 에이전트는 이 요청을 받지 않습니다."],
|
|
42
|
+
answerRefused: [
|
|
43
|
+
"This agent run is not waiting on the call this answer names",
|
|
44
|
+
"이 에이전트 실행은 이 답이 가리키는 호출을 기다리고 있지 않습니다.",
|
|
45
|
+
],
|
|
46
|
+
clientToolsRefused: [
|
|
47
|
+
"A screen lent this agent run tool definitions past what a run takes: {limit} {sent}, limit {max}",
|
|
48
|
+
"화면이 빌려준 툴 정의가 이 에이전트 실행이 받는 한도를 넘었습니다: {limit} {sent}, 한도 {max}",
|
|
49
|
+
],
|
|
42
50
|
accountResolverMissing: [
|
|
43
51
|
"An agent loop named a principal, and this server has no account resolver to resolve it with",
|
|
44
52
|
"에이전트 루프에 principal이 주어졌지만 이 서버에는 이를 해석할 계정 resolver가 없습니다.",
|
|
@@ -44,6 +44,10 @@ export const baseDictionary = serviceDictionary(["en", "ko"])
|
|
|
44
44
|
"Too many requests. Please try again in {seconds} seconds.",
|
|
45
45
|
"요청이 너무 많습니다. {seconds}초 후 다시 시도해주세요.",
|
|
46
46
|
],
|
|
47
|
+
liveRoomLimit: [
|
|
48
|
+
"This list stopped updating live: the server follows as many live lists as it allows. Reload to see the latest.",
|
|
49
|
+
"이 목록의 실시간 갱신이 멈췄습니다. 서버가 허용하는 실시간 목록 수를 넘었습니다. 새로고침하면 최신 내용을 볼 수 있습니다.",
|
|
50
|
+
],
|
|
47
51
|
payloadTooLarge: [
|
|
48
52
|
"The request is too large for the server to accept.",
|
|
49
53
|
"요청이 너무 커서 서버가 받을 수 없습니다.",
|