Add attachments: TagAttachment, Slack file normalization, fileLookup - #11
Merged
TheGreatAxios merged 1 commit intoAug 2, 2026
Conversation
TagAttachment (new in @corbits/tag-core) travels on PriorTurn.attachments and TagEvent.attachments — the platform package normalizes whatever file metadata it has without downloading anything itself. TagEvent also gains messageId, riding the same toEvent() touch (adjacent, not itself attachment-specific). tag-slack normalizes Chat SDK's message.attachments against the Chat SDK's own attachment shape, then recovers Slack file ids and stronger metadata from the raw Slack event's message.files by URL/name/index match (resolveRawFile/toAttachment/resolveAttachmentId in wire.ts). A new slack-files.ts adds createSlackFileLookup — an authenticated, host-validated Slack files.info client with a small dedup cache — for enriching id-only file events past what the Chat SDK attachment already carries. mountSlackTag auto-wires it whenever a bot token is present, mirroring the existing userLookup auto-wire. Adds a real arktype dependency (tag-slack/package.json + bun.lock) for the untyped-JSON validation both slack-files.ts and the raw-file recovery in wire.ts do; arktype@2.2.3 and its transitive deps were already resolved in this repo's lockfile via @intx/db, so no new package needed adding to the lock, just the new edge from tag-slack.
TheGreatAxios
force-pushed
the
cl-5108-corbits-tag-attachments-tagattachment-slack-file
branch
from
August 2, 2026 20:54
ce07b81 to
96d5c9f
Compare
TheGreatAxios
deleted the
cl-5108-corbits-tag-attachments-tagattachment-slack-file
branch
August 2, 2026 20:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TagAttachment(new in@corbits/tag-core) rides onPriorTurn.attachmentsandTagEvent.attachments. The platform package normalizes whatever file metadata it has onto this shape; it never downloads —url, when present, is a platform-specific download URL requiring platform auth.TagEventalso gainsmessageId(adjacent addition riding the sametoEvent()touch, not itself attachment-specific — called out since it wasn't separately enumerated when this work was scoped).tag-slack:wire.tsnormalizes Chat SDK'smessage.attachments, then recovers Slack file ids and stronger metadata (name/mimetype/url) from the raw Slack event'smessage.filesby URL → name → index match (resolveRawFile/toAttachment/resolveAttachmentId). Newslack-files.tsaddscreateSlackFileLookup— an authenticatedfiles.infoclient with host-validated URLs (rejects anything not*.slack.com/*.slack-files.combefore ever sending the bot token) and a small dedup cache — for enriching id-only file events past what the Chat SDK attachment already carries.mountSlackTagauto-wiresfileLookupwhenever a bot token is present, mirroring the existinguserLookupauto-wire (shouldAutoWireFileLookup, same "explicitundefineddisables it" contract).arktypedependency totag-slack/package.jsonfor the untyped-JSON validation bothslack-files.tsand the raw-file recovery use.arktype@2.2.3and its transitive deps (@ark/schema,@ark/util,arkregex) were already resolved in this repo's lockfile (pulled in via@intx/db/@intx/typesintag-interchange) at the exact same version, sobun.lockonly needed the new dependency edge fromtag-slack, not a new package resolution.Test plan
bun run typecheck && bun run testpackages/tag-slack/src/wire.test.ts: newwireBot attachmentssuite — Chat SDK attachments merged with raw Slack file metadata, synthetic ids when raw files are absent, raw files replacing placeholder metadata by index,fileLookupenrichment of an id-only event, no-attachments leaves the field absent, tolerating an opaquerawpayload, prior-turn attachments, andmessageIdpresence/absence.packages/tag-slack/src/slack-files.test.ts: new —createSlackFileFetcher/createSlackFileLookupcoverage (auth header, URL host validation rejecting non-Slack origins,files.infosuccess/not-found/error/malformed-response handling, result caching).packages/tag-slack/src/index.test.ts: newshouldAutoWireFileLookupsuite mirroring the existingshouldAutoWireUserLookupcoverage.