f7c23fb325
Add ts-worker/ with the Bun/TypeScript worker that replaces claw-profile-worker. The Dockerfile now builds a single image containing both the Rust gateway (claw-telegram) and the TS worker. The image defaults to worker mode (bun run ts-worker/main.ts). The gateway Unraid XML overrides with --entrypoint claw-telegram. Worker containers use the same image with the default CMD. - Add ts-worker/ (12 files): HTTP/SSE server, Anthropic SDK engine, approval broker, event translator, state stores - Add package.json with @anthropic-ai/sdk dependency - Rewrite Dockerfile: three-stage build (Rust + Bun + runtime) - Revert CLAW_GATEWAY_WORKER_IMAGE to claw-telegram:latest - Remove image pull from docker_worker_manager (same image, already local) - Add ts-worker paths to CI trigger Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
/**
|
|
* TeamStore — manages team state and mailbox.
|
|
*/
|
|
|
|
import type {
|
|
TeamRecord,
|
|
MailboxMessage,
|
|
MailboxSummary,
|
|
} from './records.js'
|
|
|
|
export class TeamStore {
|
|
private team: TeamRecord | null = null
|
|
private messages: MailboxMessage[] = []
|
|
|
|
getTeam(): TeamRecord | null {
|
|
return this.team
|
|
}
|
|
|
|
setTeam(team: TeamRecord): void {
|
|
this.team = team
|
|
}
|
|
|
|
deleteTeam(teamName: string): boolean {
|
|
if (this.team?.team_name === teamName) {
|
|
this.team = { ...this.team, deleted: true }
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ── Mailbox ───────────────────────────────────────────────────────
|
|
|
|
addMessage(msg: MailboxMessage): void {
|
|
this.messages.push(msg)
|
|
}
|
|
|
|
getMailboxSummary(): MailboxSummary {
|
|
return {
|
|
team_name: this.team?.team_name,
|
|
recent_messages: this.messages.slice(-50),
|
|
}
|
|
}
|
|
|
|
getPendingMessages(recipient: string): MailboxMessage[] {
|
|
return this.messages.filter(
|
|
(m) => m.recipient === recipient && !m.envelope.read,
|
|
)
|
|
}
|
|
|
|
markRead(messageId: string): void {
|
|
const msg = this.messages.find((m) => m.envelope.id === messageId)
|
|
if (msg) msg.envelope.read = true
|
|
}
|
|
|
|
reset(): void {
|
|
this.team = null
|
|
this.messages = []
|
|
}
|
|
}
|