Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The artifacts service is services/artifacts, the Worker g1t-artifacts, bound as ARTIFACTS by the API, the site and the agents; its live rooms move to it with a Durable Object transfer from g1t-docs-service, and its database, bucket, indexes and queue keep their names. The git store's binding and settings are GITSTORE, its ops scripts gitstore-*, and workflow run artifacts keep their compatible API under run_artifacts modules. The deploy tool puts a Worker that has never deployed before the Workers in its stage that bind to it, and the deploy guide gives the cutover runbook. | 1 | /** |
| 2 | * What the artifacts service tells the rest of g1t: `doc.page.*` events on the | |
| 3 | * bus (packages/contracts events.ts), through the EVENTS binding when it | |
| 4 | * has one. Published with no `repoId`, so a page never reaches a | |
| 5 | * repository's timeline or webhooks. Never throws: an event that can't be | |
| 6 | * told is logged, and the change it is about still happened. | |
| 7 | */ | |
| 8 | import { eventsClient, type DocPageEventData, type EventPayloads, type ServiceBinding } from "@g1t/contracts"; | |
| 9 | ||
| 10 | type DocEventType = "doc.page.created" | "doc.page.updated" | "doc.page.archived" | "doc.page.stale"; | |
| 11 | ||
| 12 | /** The id in a member key (`user:<id>`, `agent:<id>`), as an event's actor. */ | |
| 13 | export function actorOf(key: string | null | undefined): string | null { | |
| 14 | if (!key) return null; | |
| 15 | const at = key.indexOf(":"); | |
| 16 | return at > 0 ? key.slice(at + 1) || null : null; | |
| 17 | } | |
| 18 | ||
| 19 | export async function publishDocEvent<T extends DocEventType>(events: ServiceBinding | undefined, type: T, data: EventPayloads[T] & DocPageEventData, actor: string | null): Promise<void> { | |
| 20 | if (!events) return; | |
| 21 | try { | |
| 22 | await eventsClient(events).publish([{ type, source: "docs", repoId: null, actor: actorOf(actor), data } as never]); | |
| 23 | } catch (error) { | |
| 24 | console.error("docs could not publish", type, String(error)); | |
| 25 | } | |
| 26 | } |