@mitralab.io/sdk-core 0.3.0-beta.2 → 0.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,107 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## 0.3.0
6
+
7
+ This release consolidates the work published to npm as `0.3.0-beta.1` and `0.3.0-beta.2` (below)
8
+ with what came after them. The history keeps the format of 0.2.13; against a box that predates
9
+ this release the new functions (queue, steer, background tasks) find nothing to show.
10
+
11
+ - `session.history` is the conversation as it happens: while a turn runs, the box's frames grow it
12
+ with the same items the Copilot records, in the box's order. The question enters where the box
13
+ took it (its turn's `stepStart` or the `steer` that took it in), as the person wrote it, as the
14
+ Copilot records it: after a box that died, the box ran it with the recovered context ahead of it,
15
+ and the live question no longer shows that context. Each stretch of text or reasoning grows on
16
+ the item of its `itemId`. A tool's call and its result are two items, each where it came, as the
17
+ stream sends them and the reload (and 0.2.13) has them; an app that shows a tool as one line
18
+ joins them by `toolId`, as T3's own screen does. The call that spawned a subagent carries its
19
+ last state. An approval or a question T3 asks mid-turn (the box's `approval` and
20
+ `user_input_request` frames) enters as an `approval` or `userInputRequest` item with the frame's
21
+ payload, where it came, as the reload has it; it still reaches the app as a `raw` event too. A
22
+ piece the loaded history already has grows in place, and a frame it already holds
23
+ (a replay after a reconnect or an F5) changes nothing. The reload at the turn's end brings back
24
+ the same pieces in the same order. An app draws `history`, `queue` and `subagents` and keeps
25
+ nothing of its own.
26
+ - A message sent while a turn runs no longer waits in a local queue of the SDK: it goes to the box
27
+ at once, with no mode by default. T3 decides, as its own composer does, steering it into the
28
+ running turn when the provider takes a steer and queueing it otherwise.
29
+ `send(prompt, { mode: "steer" })` takes it into the running turn on purpose (T3 refuses a steer
30
+ while the turn is not running yet) and `send(prompt, { mode: "queue" })` waits in T3's queue for
31
+ a turn of its own. This replaces the `mode: "steer"` that 0.3.0-beta.1 put on every message of
32
+ the direct channel. A box before this release ignores the field and lets T3 decide.
33
+ - `queue` and `queueChange` mirror T3's queue of the chat from the box's `messageQueued` frames (the
34
+ ones with a `position`), with `position`, `queueHeld`, `sequence` and `turnId` as optional
35
+ fields. A message leaves when a turn takes it (`stepStart` or `steer` naming its
36
+ `clientMessageId`), when the box takes it out on a cancel (`messageQueued` with `position: null`
37
+ and `cancelled: true`, no terminal) or when it ends before running; that end rejects only its
38
+ own `sendAndWait` and ends no turn, as in T3: when it is the message that opened this session's
39
+ turn, the session follows its next queued message once the box starts it, or goes back to
40
+ `idle` with no `turnEnd` when none is left. A refusal of a queue command (an `error` with
41
+ `command`) is only emitted as `error` and fails no turn. On the direct channel, a queued
42
+ message's frames and a terminal naming another turn than the followed one never change the turn
43
+ a redial resumes or the one closed as interrupted when the box goes away. The queue methods are
44
+ no longer deprecated and their signatures are unchanged: `removeQueueItem` sends
45
+ `queued-run.cancel`, `editQueueItem` sends `queued-run.edit` and `clearQueue` sends one cancel
46
+ per queued message, on the box channel only. `steerQueueItem(id)` moves a queued message into
47
+ the running turn with T3's `queued-message.promote-to-steer`. A Stop holds the queue, as T3's
48
+ Stop does, until `resumeQueue()` (T3's `queue.resume`).
49
+ - `backgroundTasks` (and the event of the same name) is the work the provider keeps going in the
50
+ background as T3 shows it waiting: a background command, a Monitor, a subagent. It is state, not
51
+ history.
52
+ - `send` returns the `clientMessageId` the message goes out with, the id the box echoes when it
53
+ takes the message; `undefined` for a blank prompt, which is not sent. A caller that ignores the
54
+ return is unaffected. The id also goes in the `POST /inputs` body when the message goes to the
55
+ Copilot, which keeps it and hands it to the box: `send` returns the id on every path.
56
+ - The history is the stream as the Copilot recorded it, one row per piece: `loadHistory` asks for
57
+ every row with `kinds=all` (new `AgentMessageListOptions.kinds`, which `listMessages` sends as a
58
+ query parameter), and each row becomes its own item. A `REASONING` row is an item of the new
59
+ kind `reasoning`; a `SUBAGENT_TEXT` row is an `agent` item with `parentToolId`; a subagent's
60
+ tools are `tool` items; `APPROVAL` and `USER_INPUT_REQUEST` rows are items of the new kinds
61
+ `approval` and `userInputRequest`, with the payload of the box frame as it came (the same that
62
+ reaches the session live as `raw`). History items carry what the Copilot recorded: `sequence`,
63
+ `lastSequence`, `boxLog`, `itemId`, `parentToolId`, `clientMessageId`, `subagent` and `reason`.
64
+ `subagent` has the shape of the box's `subagentUpdate` (`AgentSubagentFrame`, partial); a tool
65
+ item keeps `parentToolId` on `tool` only. A lost turn is recovered with `kinds=all` too, and
66
+ reads its answer only from the chat's own `TEXT`, `ERROR` and `TOOL_USE` rows. A question still
67
+ waiting in the queue is not in the history: it shows in `queue` until its turn starts. Without
68
+ the parameter the Copilot answers the rows 0.2.13 read. Nothing is derived or attached: a frame
69
+ or row without a field leaves it out.
70
+ - The events the session already emits carry, as optional fields, what the box frame named:
71
+ `sequence`, `itemId`, `turnId` (the frame's `lifecycle.turnId`) and `parentToolId` on a
72
+ subagent's text and tools. `delta` and `subagentDelta` also carry `itemDelta`, the frame's piece
73
+ of its item without the separator 0.2.13 joined two text items with. `steered` also carries the
74
+ steered message's `turnId`, `sequence` and `clientMessageId`; `turnEnd` carries the `sequence`
75
+ and `turnId` of its `stepFinish`. `turnStart` opened by the box's `stepStart` carries the `text`
76
+ and `clientMessageId` of the message whose turn it is, with `sequence`, `itemId` and `turnId`:
77
+ the question reaches the app there also when the history does not have it yet.
78
+ - `session({ taskId })` opened in the middle of a run asks the box for the replay from where the
79
+ loaded history ends (the highest `lastSequence ?? sequence` of its newest `boxLog`), with the
80
+ request the redial already makes, before any live frame: what the Copilot has not recorded yet
81
+ reaches the session and nothing the history has comes twice. When the channel's `boxLog` (new
82
+ optional field of `AgentTaskChannel`) is another log than the history's newest, the replay
83
+ starts at the box log's beginning. On the socket the same decision as the redial is made from
84
+ the box's `hello`: a `lastSequence` short of the history's end is another log too. The channel
85
+ cursor starts at the replay point, so a drop in the middle of the replay asks again for what did
86
+ not arrive. A history without `sequence` asks for no replay, as before. A turn the replay opens
87
+ keeps the session `streaming` after the open. The event source gets the cursor as a fifth,
88
+ optional `open` argument, which a concrete SDK may ignore.
89
+ - The queue and subagent state the box sends again after a replay, each a copy of the line that
90
+ said it last with that line's `sequence`, is taken as state: a copy of what the session already
91
+ holds emits no `queueChange` or `subagent` again, and on a fresh open it fills `queue` and
92
+ `subagents`.
93
+ - A `toolResult` that comes after its turn ended (a background subagent settling later, sent by the
94
+ box under the turn that called it) is emitted as that tool's `tool` result. It opens no turn,
95
+ leaves `status` and `content` alone and, on the direct channel, does not mark the chat as in a
96
+ turn: it used to be dropped.
97
+ - A `stepStart` naming a turn while no turn runs starts that turn with its content clean, and
98
+ `accepted` is emitted at the frame that names the message (`stepStart`, `steer` or
99
+ `messageQueued`). A message sent right after a `turnEnd`, before the previous admission was
100
+ heard, no longer takes the text of the turn that ended, and a turn whose frames arrive in one
101
+ tick gives the same events as one whose frames arrive spaced out. A turn the agent opens by
102
+ itself no longer carries the previous turn's text in `turnEnd.content`. A message sent once the
103
+ box took the opening one, before that admission reached the sending code, goes out as a message
104
+ of its own.
105
+
5
106
  ## 0.3.0-beta.2
6
107
 
7
108
  - `messenger.sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` sends an email through
@@ -21,7 +122,7 @@ All notable changes to this project are documented in this file.
21
122
  validator accepts their absence, as a Code Studio that predates them sends, and rejects a value
22
123
  that is not a boolean.
23
124
 
24
- ## 0.3.0
125
+ ## 0.3.0-beta.1
25
126
 
26
127
  Rollout gate: this version goes into the app SDKs (`@mitralab.io/platform-sdk` and the Functions
27
128
  SDK) only once the environment has no old agent box left, that is, no box still running on the
@@ -59,9 +160,19 @@ exact version.
59
160
  event is emitted and the turn and the messages waiting for the box are left alone. With the box
60
161
  channel down, the answer is not sent and an `error` says so; the Copilot does not take it.
61
162
  - A turn whose box went away while the socket redialed (the Copilot points the chat to another
62
- box, or the same address comes back with an empty log) ends as `interrupted` with the text it
63
- had, so the next message opens a turn of its own. A terminal the new box sends for that turn
64
- is ignored.
163
+ box, the same address comes back with an empty log, or the box's `hello` names another T3
164
+ thread or a log short of the session's cursor) ends as `interrupted` with the text it had, so
165
+ the next message opens a turn of its own. A terminal the new box sends for that turn is
166
+ ignored. On the socket, once the box said which thread it serves, the redial asks for the
167
+ replay only after the new box's `hello`: behind the dev proxy every box of a chat has the same
168
+ address, and asking a new box for the old cursor ended the next message's turn as an empty
169
+ `interrupted`. On the socket, the new box is then replayed from the start of its log, which
170
+ may already hold the start of the next message's turn; over HTTP the stream still opens from
171
+ the sequence the Copilot reported.
172
+ - A box `stepFinish` whose `lifecycle` names no turn no longer ends a turn whose `turnId` the
173
+ session already got from the box. A box asked to replay past its log sends such a terminal for
174
+ the turn of a box that is gone; it used to end the running turn as an empty `interrupted` and
175
+ the real terminal right after it was ignored.
65
176
  - The box's `steer` frame marks where T3 took a message into the running turn, with no turn of
66
177
  its own: the session answers that message with the running turn and emits the new `steered`
67
178
  event with its `text` and `messageId`, for the app to show it at that point. The frame also
@@ -69,7 +180,9 @@ exact version.
69
180
  into a turn another client opened follows that turn from the `steer` on.
70
181
  - A turn whose `sendAndWait` already gave up on `timeoutMs` or `signal` is still closed from the
71
182
  history when the stream drops: the recovery no longer stops with the waiter, and the session
72
- does not stay `streaming` forever.
183
+ does not stay `streaming` forever. A `sendAndWait` that gives up before the message went out,
184
+ while the task or the box channel is still on its way, no longer drops it: the message goes
185
+ out and the session follows its turn.
73
186
  - A turn the session closes from the history after the stream dropped closes only on the row
74
187
  that ends it: the agent row carrying the turn's usage, or an `ERROR` row. The Copilot writes a
75
188
  turn's rows while it runs, so the first new row was often a comment from the middle of the
@@ -91,8 +204,9 @@ exact version.
91
204
  `progress`, `startedAt`, `endedAt` (epoch ms) and `childThreadId` from the box's
92
205
  `subagentUpdate` frame; an update with no status keeps the one before. Frames of the child
93
206
  thread, marked with `parentToolId`, come as `subagentDelta` and `subagentTool` and never touch
94
- the chat's turn: they open none, end none, admit no message, stay out of `content` and do not
95
- change the redial. `stopSubagent(subagentId)` stops one over the box channel; without it an
207
+ the chat's turn: they open none, end none, admit no message and do not change the redial. Their
208
+ text and tools also reach `delta`, `content` and `tool` (with `parentToolId`), as they did in
209
+ 0.2.13, so an app that only bumps the version keeps seeing them. `stopSubagent(subagentId)` stops one over the box channel; without it an
96
210
  `error` says so and nothing goes out. `AgentTaskInput` gains `mode` and `subagent.stop`,
97
211
  `AgentToolEvent` gains `parentToolId`, and `AgentSubagent` and `AgentSubagentStatus` are
98
212
  exported.
package/README.md CHANGED
@@ -99,10 +99,13 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
99
99
  - `sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` não tem `from`: o Messenger usa o remetente do app do token. Por isso só o backend do app manda e-mail, com o token trocado pela API key ou o token da Server Function; token de usuário final do app recebe `403`. `to`, `cc` e `bcc` são listas com um endereço por item. Os limites ficam no Messenger e chegam como erro do seu `Transport`: `400` acima do limite de destinatários dele somando os três campos e `429` acima da cota diária do app, com o header `Retry-After` e `retry_after_seconds` no corpo.
100
100
  - `sendAndWait` com `timeoutMs` ou `signal` só para de esperar; o turno continua no servidor. Para interromper, chame `cancel()`. A sessão continua acompanhando esse turno: se o canal cair depois do prazo, ela ainda fecha o turno pelo histórico, como faz com um `send`. Pelo histórico, o turno só fecha na linha que o termina: a do agente com o uso do turno, ou uma linha `ERROR`. As linhas que o Copilot grava com o turno rodando e a resposta atrasada da pergunta anterior não fecham nada. O stream do Copilot repete o turno em andamento a partir do que o histórico dele tem; o que a sessão já viu, pelo `sequence` da box, não sai de novo.
101
101
  - `cancel()` chamado antes de a box aceitar o prompt espera esse aceite e só então manda o stop; a promise resolve depois disso. Se o prompt não chegar a virar turno, nada é enviado e o status não passa por `cancelled`. Mensagem mandada depois do `cancel()`, com o stop ainda sem resposta, sai como qualquer outra; a box espera o turno parado terminar e dá a ela um turno próprio, e o `sendAndWait` dela resolve com esse turno. Turno parado que a sessão fecha pelo histórico termina com `reason` `interrupted`.
102
- - Toda mensagem sai na hora, com ou sem turno rodando; a sessão não guarda fila. Com turno rodando, a box coloca a mensagem dentro do turno em andamento (steering nativo do provedor), põe na fila do provedor para um turno próprio, ou dá a ela um turno próprio se o turno já acabou; o `sendAndWait` de cada mensagem resolve com o turno que a respondeu. No canal direto ela vai pelo socket com `mode: "steer"` (sem ele, a box põe a mensagem na fila do T3) e um `clientMessageId`, que a box devolve no frame que a aceita (`stepStart` ou `messageQueued`, este sem o prazo de 35 s). Quando o T3 entrega a mensagem ao turno em andamento, a box marca o ponto com um frame `steer`, sem turno novo: a sessão emite `steered` com `text` e `messageId`, para o app mostrar a mensagem ali, e o `turnEnd` daquele turno responde a ela. Se o turno acabar antes, ela ganha turno próprio, que abre com `stepStart`. O `clientMessageId` também volta no `error` que a recusa, que rejeita só aquela mensagem. Com o socket reconectando, ou sem canal direto, vai ao Copilot (`POST /inputs`), que a guarda como pendente enquanto a box liga. A mensagem mandada com turno rodando leva `agentType` e `reasoningEffort` para a box, que não troca o modelo do turno em andamento e os usa se a mensagem virar turno próprio; só quando vai ao Copilot com turno rodando eles são tirados, porque o Copilot reinicia a sessão viva para outro modelo. Recusa do Copilot com status de erro rejeita aquela mensagem e emite `error`. Falha no envio rejeita o `sendAndWait` e emite `error`; mensagem que ainda não saiu quando a sessão fecha é rejeitada e não é enviada. `queue`, `editQueueItem`, `removeQueueItem`, `clearQueue` e `queueChange` continuam na API só por compatibilidade, marcados como deprecated: a fila é sempre vazia, os métodos não fazem nada e o evento não é emitido.
103
- - Subagentes: o evento `subagent` traz `subagentId`, `toolId` (o `toolId` do `tool` que o criou), `status` (os do T3: `pending`, `running`, `waiting`, `completed`, `failed`, `cancelled`, `interrupted`, `idle`; quando o T3 não manda status, fica o anterior), `progress`, `startedAt`, `endedAt` (epoch ms) e `childThreadId`; `session.subagents` guarda o último estado de cada um. A conversa do subagente vem em `subagentDelta` e `subagentTool`, com `parentToolId`, e nunca entra em `delta`, `content` nem no ciclo do turno do chat. `stopSubagent(subagentId)` para só ele e deixa o turno seguir; vai só pelo canal direto, e sem ele sai um `error` e nada é enviado.
102
+ - Toda mensagem sai na hora, com ou sem turno rodando; a sessão não guarda fila. Com turno rodando, a box coloca a mensagem dentro do turno em andamento (steering nativo do provedor), põe na fila do provedor para um turno próprio, ou dá a ela um turno próprio se o turno já acabou; o `sendAndWait` de cada mensagem resolve com o turno que a respondeu. No canal direto ela vai pelo socket sem `mode` por padrão, e o T3 decide como no composer dele: entra no turno em andamento quando o provedor aceita steer, ou espera na fila do T3. `send(prompt, { mode: "steer" })` pede o steer de propósito (o T3 recusa enquanto o turno ainda não está rodando) e `send(prompt, { mode: "queue" })` pede a fila; `steerQueueItem(id)` leva um item da fila para o turno em andamento e `resumeQueue()` retoma a fila que o Stop segurou. A mensagem leva também um `clientMessageId`, que a box devolve no frame que a aceita (`stepStart` ou `messageQueued`, este sem o prazo de 35 s). O `send` devolve esse `clientMessageId` (ou `undefined` para texto em branco, que não sai). Quando o T3 entrega a mensagem ao turno em andamento, a box marca o ponto com um frame `steer`, sem turno novo: a sessão emite `steered` com `text` e `messageId`, para o app mostrar a mensagem ali, e o `turnEnd` daquele turno responde a ela. Se o turno acabar antes, ela ganha turno próprio, que abre com `stepStart`. O `clientMessageId` também volta no `error` que a recusa, que rejeita só aquela mensagem. Com o socket reconectando, ou sem canal direto, vai ao Copilot (`POST /inputs`) com o mesmo `clientMessageId`, que o Copilot guarda com a mensagem pendente enquanto a box liga e entrega à box, que o devolve igual. A mensagem mandada com turno rodando leva `agentType` e `reasoningEffort` para a box, que não troca o modelo do turno em andamento e os usa se a mensagem virar turno próprio; só quando vai ao Copilot com turno rodando eles são tirados, porque o Copilot reinicia a sessão viva para outro modelo. Recusa do Copilot com status de erro rejeita aquela mensagem e emite `error`. Falha no envio rejeita o `sendAndWait` e emite `error`; mensagem que ainda não saiu quando a sessão fecha é rejeitada e não é enviada. A sessão não guarda fila própria: `queue` e `queueChange` mostram a fila do T3 que a box informa com `messageQueued` (só os que têm `position`), de qualquer cliente do chat, com `id` (o `clientMessageId`), `text`, `position`, `queueHeld`, `sequence` e `turnId`. A mensagem sai da fila quando um turno a pega (`stepStart` ou `steer` com o mesmo `clientMessageId`), quando a box a tira da fila por um `queued-run.cancel` (`messageQueued` com `position: null` e `cancelled: true`, sem `stepFinish`) ou quando ela termina antes de rodar; a saída sem turno rejeita só o `sendAndWait` dela e não mexe no turno em andamento. Como no T3, cancelar um item da fila só tira aquele item: nenhum turno termina por isso. Se ele era a mensagem que abriu o turno desta sessão, ainda esperando atrás do turno de outro cliente, a sessão segue a próxima mensagem dela na fila quando a box a começa, ou volta a `idle` se não sobrou nenhuma, sem `turnEnd`. Frame de mensagem da fila nunca troca o turno que o canal acompanha para reconectar. `removeQueueItem(id)` manda `queued-run.cancel`, `editQueueItem(id, text)` manda `queued-run.edit` e `clearQueue()` manda um `queued-run.cancel` por item; a fila muda quando a box responde, não antes. A recusa de um desses comandos chega como `error` com `command` (`queued-run.cancel` ou `queued-run.edit`): a sessão só emite o `error`, a mensagem fica onde está e nenhum turno falha. Os três vão só pelo canal direto; sem ele sai um `error` e nada é enviado. Depois do replay a box manda de novo a fila e os subagentes como estão, com o `sequence` da linha que os disse por último: o que a sessão já tem não sai de novo em `queueChange` nem em `subagent`, e numa abertura nova isso preenche `queue` e `subagents`.
103
+ - Subagentes: o evento `subagent` traz `subagentId`, `toolId` (o `toolId` do `tool` que o criou), `status` (os do T3: `pending`, `running`, `waiting`, `completed`, `failed`, `cancelled`, `interrupted`, `idle`; quando o T3 não manda status, fica o anterior), `progress`, `startedAt`, `endedAt` (epoch ms) e `childThreadId`; `session.subagents` guarda o último estado de cada um. A conversa do subagente vem em `subagentDelta` e `subagentTool`, com `parentToolId`, e não abre nem fecha o turno do chat. Como na 0.2.13, o texto dela também entra em `delta` e `content`, e as ferramentas também saem em `tool`, com `parentToolId`. O resultado de subagente em segundo plano que termina depois do turno dono chega como `tool` de fase `result` com o `toolId` da chamada, sem abrir turno nem mexer em `status` e `content`. `stopSubagent(subagentId)` para só ele e deixa o turno seguir; vai só pelo canal direto, e sem ele sai um `error` e nada é enviado.
104
+ - Peças e ordem: cada evento que já existe leva, como campos opcionais, o que o frame da box trouxe: `sequence` (a ordem do log da box), `itemId` (o id do item no T3), `turnId` (o `lifecycle.turnId`) e, no texto e nas ferramentas de subagente, `parentToolId`. O `delta` (e o `subagentDelta`) traz também `itemDelta`, o pedaço do item como a box mandou: igual ao `delta`, menos no primeiro pedaço de um item de texto que vem depois de outro, em que o `delta` começa com o separador de linha dupla que a 0.2.13 usava para juntar os dois. Quem desenha por item usa `itemDelta`. O `steered` traz também o `turnId` da mensagem (o `id` do item dela no histórico), `sequence` e `clientMessageId`; o `turnEnd` traz o `sequence` e o `turnId` do `stepFinish`. O item do `history` traz o que o Copilot gravou: `sequence` (o do primeiro pedaço da peça, igual ao do evento ao vivo), `lastSequence` (o do último pedaço, só quando a peça veio em mais de um), `boxLog` (qual log da box conta o `sequence`; box que sobe sem o log recomeça), `itemId`, `parentToolId`, `clientMessageId` na pergunta, `subagent` na ferramenta que criou o subagente e `reason` na linha que fechou o turno. O `subagent` tem o formato do frame `subagentUpdate` da box, sem conversão. Na ferramenta, o `parentToolId` fica em `tool.parentToolId`. O histórico é o streaming gravado, uma linha por peça: o `loadHistory` pede todas as linhas com `kinds=all` e cada linha vira um item, como veio. Linha `REASONING` vira item `reasoning` (raciocínio, com `itemId` e, no do subagente, `parentToolId`); linha `SUBAGENT_TEXT` vira item `agent` com `parentToolId`; ferramenta de subagente é item `tool` com `tool.parentToolId`; linha `APPROVAL` vira item `approval` e linha `USER_INPUT_REQUEST` vira item `userInputRequest`, os dois com o `payload` do frame da box como veio (o mesmo que chega ao vivo como evento `raw`). Ao vivo, os frames `approval` e `user_input_request` entram no `history` como esses mesmos itens, na posição em que vieram, igual ao recarregado. A recuperação de turno perdido também pede `kinds=all`, para o `history` seguir com todas as peças, e lê a resposta só das linhas do próprio chat (`TEXT`, `ERROR` e `TOOL_USE` sem `parentToolId`). Com `kinds=all`, a pergunta que ainda espera na fila não vem no histórico: ela aparece em `queue` até o turno dela começar. O `turnStart` aberto pelo `stepStart` da box traz o `text` e o `clientMessageId` da mensagem daquele turno, com `sequence`, `itemId` e `turnId`: é ali que o app mostra a pergunta, também quando o histórico ainda não a tem (F5 logo depois do envio). Sem o parâmetro, o Copilot devolve só as linhas que a 0.2.13 lia. A SDK só repassa: não ordena, não agrupa e não deduz nada. Frame ou linha sem o campo deixa o campo de fora.
105
+ - Turno e tempo de entrega: quem decide se a mensagem entra no turno em andamento ou ganha turno próprio é a box, não o tempo local da SDK. Um `stepStart` com `turnId` sem turno rodando abre o turno com o `content` limpo, e o `accepted` sai no frame que nomeia a mensagem. Frames que chegam juntos num tick dão os mesmos eventos que frames espaçados.
104
106
  - Pergunta do agente no meio do turno: o T3 pode pedir uma resposta à pessoa. O pedido chega como evento `raw` de tipo `user_input_request`, com o item do T3 no `payload` (perguntas e `requestId`); o turno fica esperando, sem prazo da SDK. Responda com `session.respondUserInput(requestId, answers, attachmentsByQuestionId?)`, que vai direto para a box. Se a box recusar a resposta, sai um `error` e o turno continua; com o canal direto fora (reconectando ou chat sem box), a resposta não é enviada e sai um `error` dizendo isso, para o app mandar de novo depois do `channelConnected`.
105
107
  - Portão de rollout da 0.3.0: ela só entra nas SDKs de app (`platform-sdk` e SDK de Functions) quando o ambiente tiver zero box antiga (template do fork `experimental`). A box antiga trata a mensagem do meio do turno como início de turno novo, zera o uso e a identidade do turno, e nada disso aparece como erro. A SDK não distingue box antiga de box nova; o portão é o bump nas SDKs de app, que fixam a versão exata desta.
108
+ - Abrir o chat no meio de uma run (F5): o `session({ taskId })` carrega o histórico e pede à box o replay a partir de onde ele termina, o maior `lastSequence` (ou `sequence`, quando a linha não traz `lastSequence`) do `boxLog` mais novo, com o mesmo pedido que o redial já faz e antes de qualquer frame ao vivo. O que o Copilot ainda não gravou chega no replay, e nada do histórico vem duas vezes. No socket, a decisão é a mesma do redial, pelo `hello` da box: se o `boxLog` do canal for outro que o do histórico (o Copilot sobe o `boxLog` quando a box troca de thread) ou o `lastSequence` do `hello` for menor que esse ponto, o log é outro e o replay começa do início dele. No HTTP, decide só pelo `boxLog`, antes de abrir o stream. O cursor do canal começa no ponto do replay, então uma queda no meio dele pede de novo só o que faltou. Histórico sem `sequence` não pede replay, como antes.
106
109
  - O `open()` do seu `eventSource` só deve resolver depois que o stream estiver conectado, para nenhum evento do turno se perder.
107
110
 
108
111
  ## Desenvolvimento
@@ -24,6 +24,12 @@ publishes.
24
24
 
25
25
  ## Versions
26
26
 
27
+ - `0.3.0` is the stable release of the `0.3.0-beta.2` surface with the agent session that follows
28
+ T3: the live `history`, the queue mirrored from the box, `steerQueueItem`, `resumeQueue` and
29
+ `backgroundTasks`, which the parity cases do not cover. Same parity cases; the version exists so a
30
+ consumer pinning the stable package can pin a corpus with the same number. Its directory was
31
+ committed before the betas and was never published, so this release ships it as it is.
32
+
27
33
  - `0.3.0-beta.2` is the `0.3.0-beta.1` parity surface republished with `messenger.sendEmail()` and the
28
34
  `emailLoginEnabled` and `passwordLoginEnabled` fields of `apps.update()`, which the parity cases do
29
35
  not cover. Same parity cases; the version exists so a consumer pinning the package can pin a corpus
@@ -34,11 +40,6 @@ publishes.
34
40
  corpus with the same number. `0.3.0-beta.0` shipped the same code without its own corpus and has
35
41
  no entry here.
36
42
 
37
- - `0.3.0` is the `0.2.13` parity surface republished with the agent session that holds no
38
- messages: every message goes out at once and the queue API is deprecated and always empty.
39
- Same parity cases; the version exists so a consumer pinning the package can pin a corpus with
40
- the same number.
41
-
42
43
  - `0.2.13` is the `0.2.12` parity surface republished with the occupied context of the chat:
43
44
  `contextTokens` and `contextWindow` on `AgentTurnUsage`, which the parity cases do not cover.
44
45
  Same parity cases; the version exists so a consumer pinning the package can pin a corpus with
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contract": "SDK-PARITY-001",
3
- "current": "0.3.0-beta.2",
3
+ "current": "0.3.0",
4
4
  "versions": [
5
5
  {
6
6
  "version": "0.1.0",