Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apfelkern/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## Unreleased

- Allow edits to completed one-time automations without changing their trigger or rerunning them. Preserve the saved timestamp, and expose `AutomationBoard.draftPreviewProblem` for both apps' Save buttons.
- Keep job history updating when a read takes longer than the polling interval. Polling waits for the current history load; explicit refreshes still supersede older loads.
- Update the contract copy for the server's file library. Messages no longer carry inline base64 attachments: `APIClient.uploadFile(_:_:)` and `uploadGroupFile(_:_:)` upload a `PendingAttachment`'s raw bytes with its name and MIME type and return a file ID, and `sendChatMessage` and `sendGroupMessage` take `files`. `file(_:fileID:)` and `groupFile(_:fileID:)` download by file ID; `groupAttachment` is gone, and `attachment(_:entryID:index:)` remains for desktop screenshots. `OutgoingAttachment`, `OutgoingGroupAttachment`, and `PendingAttachment.outgoing` are gone.
- `AttachmentInfo` gains `id` and `deleted` and loses `kind`; `isImage` follows the MIME type, and `.deleted(_:)` stands for a file deleted from its library. Add `DeletedFiles`, which carries a deletion to every message in the chat that lists the file, and `GroupChatHost.deletedFiles` and `selectedAgentID`.
- `BotChatDelivery` keeps each pending send's uploaded file IDs, so a retry uploads only what an earlier attempt missed. `fail(botID:requestID:error:)` drops them when the server rejects the send because a file was deleted or isn't in the library, so the next retry uploads again under the same request ID. Add `uploadedFile`, `recordUpload`, and `isPending`.
- `GroupChatHost` gains `uploadFiles(_:chat:requestID:generation:upload:)`, which both apps' bot and group sends use and which stops when the connection changes, `conversationKey`, `attachmentKey(_:index:)`, and `downloadAttachment(entryID:index:cached:)`, which drops a download whose file was deleted or whose chat or connection changed meanwhile.
- Adopt the server's chat attention contract. `APIClient.pushPresence` is gone, and `reportChatAttention(view:chat:)` and `markRepliesSeen(_:in:)` take its place. Add `ChatAttention`, which reports one view's `ChatAttentionChat` only while the app is active, its route shows that chat, and the chat is mounted; refreshes every 30 seconds; sends one report at a time with the newest state, so a refresh can't land after a clear; gives each connection a new view ID and clears the old view through the old session; and `disconnect(_:)` clears within two seconds before sign-out. It acknowledges replies whose surface is ready and on screen, in batches of up to 100 per chat that keep their chat across navigation, retry while the connection lasts, split a refused batch to drop only the refused events, and stop when the session ends.
- `Message` gains `replyReferences`, `ReplyReference`s with their `ReplySurface`, over HTTP and both event streams, and `attentionEventIDs(for:)`, `showsReplyText`, and `replyCard(heldActions:botRequests:callRequests:botSecrets:)`, which names a waiting card's surface and whether its board has the server's state. Add `ReplySurfaces`, `replySurfaceVisible(ready:frame:viewport:)`, `Route.attentionChat`, `ActivityEvent.attentionChat`, `HeldActionBoard.isReady(_:)`, `BotRequestBoard.isLoaded(_:)`, `CallRequestBoard.isLoaded(_:)`, and `BotSecretBoard.isReady(_:)`.
- `GroupChatHost` requires `snapshotRevision` and `applySnapshot(_:)` and gains `refreshReplyReferences(after:active:)`, which reloads the chat on screen after a live reply and drops the reload when a snapshot, a newer reload, a new selection, or a new connection lands first.
- Automations use the server's timing. `Schedule` gains `description`, `timing`, and `nextRunLabel`, and `cadence`, `automationTiming`, `cronPhrase`, `humanRun`, `nextRunLabel(_:now:)`, `CronExpression`, `AutomationDraft.preview(now:)`, and the draft's trigger and time zone checks in `problem` are gone. `APIClient.previewAutomation(_:)` previews an `AutomationDraft.previewRequest`. `AutomationBoard` gains `draftPreview`; `loadPreview(client:after:)`, which waits for the trigger to settle and drops an answer for an older trigger, another draft, or another connection; and `follow(client:every:)`, which rereads the list each minute while it shows. For a new or changed trigger, `saveDraft` stops at a preview's problem; without a preview, the server checks the trigger as it saves. A row waiting for the server reads **Saving…**, and a paused one says so at once.
- Reasoning uses the server's preview. `APIClient.previewReasoning(provider:model:level:)` returns a `ReasoningPreview` with its `ReasoningOption`s and the level a turn runs at. `ReasoningBoard` keeps previews per connection, with `preview(provider:model:level:)`, `preview(of:)`, and `load`, which waits for its inputs to settle, in place of `load(provider:client:)`, `levels(of:)`, and `level(of:)`. `ThinkingLevel.clamped(to:)`, `available(for:in:)`, and `title` are gone, and `ReasoningField` takes a preview.
- `Message.blocks` is `[TranscriptBlock]`, the generated type that HTTP and the event stream share. `Message` gains `presentation`, `presentedText`, and `citations`, the server's reply text without citation links and the pages it cited, and `sources`, `MessageSource`, `SourceChip`, and `SourceCitations` are gone. `ChatSnapshot` gains `working`, which `isRunning` follows, and `Working(snapshot:messages:)` is gone.
- Job history is a `JobHistoryPage` with the server's `JobHistoryItem`s. `JobHistory.items` replaces `messages`, `CodingJobItem` is gone, and `mergeJobItems(_:_:)` joins pages. A refresh rereads older pages for steps still waiting on their result.

- Add outside calls: `CallRequest` (a bot's proposal to call someone other than the owner, read from a `request_call` result or `APIClient.callRequests(_:)`), `approveCallRequest`, `declineCallRequest`, and `callRequestTranscript`, and `CallRequestBoard`, whose decisions show pending until the server confirms and whose refused approval exposes the server's text. `CallEvent` gains `callee`, and `shownInChat(_:)` hides the `call-started` event of an outside call and shows a call request card. Add `CallRequest.stateLabel`, `callRequest(for:in:)`, `callNoticeDetail(_:request:)`, and `callTranscriptLines(_:)`. `noticeTitle(_:)` names a `call_request` notice **Call request**.
- Update the contract copy for the voice gateway. `Message` gains `call`, a `CallEvent` with the call's ID and direction. Add `CallMarker`, which reads a `call-started` or `call-ended` event and the `call` notice whose end woke the bot, and `gatewayOrigin(_:)`, which reads "Spoken on a call" for a spoken message. `noticeTitle(_:)` names a `call` notice **Call**. `BotAvatar` gains `CallMarkerView`, and `GatewayOriginLabel` shows a phone for a spoken message.
- `scripts/contract.py --update DIRECTORY` copies the contract files from a directory such as `bot/openapi/`. `Contract/` no longer carries `pin.json`, `SHA256SUMS`, `CHANGELOG.md`, or `source-commit.txt`, and the weekly contract update workflow is gone.
Expand Down
303 changes: 275 additions & 28 deletions apfelkern/Contract/chat-snapshot.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"content": {
"type": "string"
},
"blocks": {},
"blocks": {
"type": "array",
"items": {
"$ref": "#/$defs/TranscriptBlock"
}
},
"stopReason": {
"type": "string"
},
Expand All @@ -38,6 +43,76 @@
"replyPreview": {
"type": "string"
},
"replyReferences": {
"type": "array",
"items": {
"type": "object",
"properties": {
"eventId": {
"type": "string",
"minLength": 1
},
"surface": {
"oneOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "text"
}
},
"required": [
"kind"
],
"additionalProperties": true
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "tool-card"
},
"toolCallId": {
"type": "string",
"minLength": 1
}
},
"required": [
"kind",
"toolCallId"
],
"additionalProperties": true
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "held-action"
},
"actionId": {
"type": "string",
"minLength": 1
}
},
"required": [
"kind",
"actionId"
],
"additionalProperties": true
}
]
}
},
"required": [
"eventId",
"surface"
],
"additionalProperties": true
}
},
"origin": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -168,35 +243,52 @@
],
"additionalProperties": true
},
"attachments": {
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"mimeType": {
"type": "string"
},
"size": {
"type": "number"
"anyOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"mimeType": {
"type": "string"
},
"size": {
"type": "number"
}
},
"required": [
"id",
"name",
"mimeType",
"size"
],
"additionalProperties": true
},
"kind": {
"type": "string",
"enum": [
"image",
"text"
]
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"deleted": {
"type": "boolean",
"const": true
}
},
"required": [
"id",
"deleted"
],
"additionalProperties": true
}
},
"required": [
"name",
"mimeType",
"size",
"kind"
],
"additionalProperties": true
]
}
},
"toolCallId": {
Expand All @@ -209,6 +301,9 @@
"type": "boolean"
},
"toolDetails": {},
"presentation": {
"$ref": "#/$defs/MessagePresentation"
},
"sources": {
"type": "array",
"items": {
Expand All @@ -233,7 +328,8 @@
"id",
"entryId",
"role",
"content"
"content",
"replyReferences"
],
"additionalProperties": true
}
Expand Down Expand Up @@ -297,6 +393,19 @@
"failed"
]
},
"working": {
"type": "string",
"enum": [
"idle",
"thinking",
"writing",
"searching",
"remembering",
"tinkering",
"struggling",
"failed"
]
},
"updatedAt": {
"type": "number"
},
Expand All @@ -316,8 +425,146 @@
"conversation",
"partial",
"status",
"working",
"updatedAt",
"error"
],
"additionalProperties": true
"additionalProperties": true,
"$defs": {
"TranscriptBlock": {
"oneOf": [
{
"$ref": "#/$defs/TranscriptTextBlock"
},
{
"$ref": "#/$defs/TranscriptThinkingBlock"
},
{
"$ref": "#/$defs/TranscriptImageBlock"
},
{
"$ref": "#/$defs/TranscriptToolCallBlock"
}
]
},
"TranscriptTextBlock": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "text"
},
"text": {
"type": "string"
}
},
"required": [
"type",
"text"
],
"additionalProperties": true
},
"TranscriptThinkingBlock": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "thinking"
},
"thinking": {
"type": "string"
},
"redacted": {
"type": "boolean"
}
},
"required": [
"type",
"thinking"
],
"additionalProperties": true
},
"TranscriptImageBlock": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "image"
},
"mimeType": {
"type": "string"
}
},
"required": [
"type",
"mimeType"
],
"additionalProperties": true
},
"TranscriptToolCallBlock": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "toolCall"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"arguments": {
"type": "object",
"additionalProperties": {}
}
},
"required": [
"type",
"id",
"name",
"arguments"
],
"additionalProperties": true
},
"MessagePresentation": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"citations": {
"type": "array",
"items": {
"$ref": "#/$defs/Citation"
}
}
},
"required": [
"text",
"citations"
],
"additionalProperties": true
},
"Citation": {
"type": "object",
"properties": {
"href": {
"type": "string"
},
"title": {
"type": "string"
},
"site": {
"type": "string"
}
},
"required": [
"href",
"title",
"site"
],
"additionalProperties": true
}
}
}
Loading
Loading