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>
289 lines
6.7 KiB
TypeScript
289 lines
6.7 KiB
TypeScript
/**
|
|
* Protocol-owned record types — TS mirrors of the Rust records in
|
|
* channel-gateway-core/src/records.rs.
|
|
*
|
|
* These are the wire shapes the gateway expects. They replace the
|
|
* opaque Record<string, unknown> placeholders in protocol.ts with
|
|
* real typed structures.
|
|
*/
|
|
|
|
// ── Task list ───────────────────────────────────────────────────────
|
|
|
|
export type TaskListStatus = 'pending' | 'in_progress' | 'completed'
|
|
|
|
export type TaskListRecord = {
|
|
id: string
|
|
subject: string
|
|
description: string
|
|
activeForm?: string
|
|
owner?: string
|
|
status: TaskListStatus
|
|
blocks: string[]
|
|
blockedBy: string[]
|
|
metadata?: Record<string, unknown>
|
|
internal: boolean
|
|
createdAt: number
|
|
updatedAt: number
|
|
}
|
|
|
|
// ── Runtime task ────────────────────────────────────────────────────
|
|
|
|
export type RuntimeTaskKind = 'agent' | 'shell'
|
|
export type RuntimeTaskStatus = 'running' | 'completed' | 'failed' | 'stopped'
|
|
|
|
export type RuntimeTaskRecord = {
|
|
task_id: string
|
|
kind: RuntimeTaskKind
|
|
status: RuntimeTaskStatus
|
|
description: string
|
|
prompt: string
|
|
output_file?: string
|
|
exit_code_file?: string
|
|
final_result?: string
|
|
error?: string
|
|
exit_code?: number
|
|
notified: boolean
|
|
pid?: number
|
|
agent_id?: string
|
|
agent_name?: string
|
|
team_name?: string
|
|
cwd?: string
|
|
worktree_path?: string
|
|
worktree_branch?: string
|
|
created_at: number
|
|
started_at: number
|
|
completed_at?: number
|
|
}
|
|
|
|
// ── Team ────────────────────────────────────────────────────────────
|
|
|
|
export type TeamMemberRecord = {
|
|
agent_id: string
|
|
name: string
|
|
agent_type?: string
|
|
model?: string
|
|
status?: string
|
|
joined_at: number
|
|
}
|
|
|
|
export type TeamRecord = {
|
|
team_name: string
|
|
description?: string
|
|
agent_type?: string
|
|
lead_agent_id: string
|
|
created_at: number
|
|
updated_at: number
|
|
deleted: boolean
|
|
members: TeamMemberRecord[]
|
|
}
|
|
|
|
// ── Mailbox ─────────────────────────────────────────────────────────
|
|
|
|
export type MessageEnvelope = {
|
|
id: string
|
|
from: string
|
|
to: string
|
|
summary?: string
|
|
message: unknown
|
|
timestamp: number
|
|
read: boolean
|
|
notified: boolean
|
|
}
|
|
|
|
export type MailboxMessage = {
|
|
recipient: string
|
|
envelope: MessageEnvelope
|
|
}
|
|
|
|
export type MailboxSummary = {
|
|
team_name?: string
|
|
recent_messages: MailboxMessage[]
|
|
}
|
|
|
|
// ── Background approval ─────────────────────────────────────────────
|
|
|
|
export type BackgroundApprovalDecision =
|
|
| { decision: 'approve_once' }
|
|
| { decision: 'approve_tool_for_session' }
|
|
| { decision: 'approve_all_for_session' }
|
|
| { decision: 'deny'; reason: string }
|
|
| { decision: 'cancel_turn' }
|
|
|
|
export type BackgroundApprovalRecord = {
|
|
approval_id: string
|
|
task_id: string
|
|
tool_name: string
|
|
input: string
|
|
current_mode: string
|
|
required_mode: string
|
|
reason?: string
|
|
created_at: number
|
|
notified: boolean
|
|
decision?: BackgroundApprovalDecision
|
|
}
|
|
|
|
// ── Feed ────────────────────────────────────────────────────────────
|
|
|
|
export type FeedItemKind =
|
|
| 'markdown'
|
|
| 'code'
|
|
| 'json'
|
|
| 'diff'
|
|
| 'image'
|
|
| 'html_preview'
|
|
| 'table'
|
|
| 'binary'
|
|
| 'deleted_file'
|
|
| 'app_published'
|
|
|
|
export type FeedItemSourceKind = 'generated' | 'workspace' | 'app_event'
|
|
export type FeedItemChangeKind = 'created' | 'modified' | 'deleted'
|
|
|
|
export type FeedItemSource = {
|
|
source_kind: FeedItemSourceKind
|
|
turn_id?: string
|
|
source_file_id?: string
|
|
source_files: string[]
|
|
change_kind?: FeedItemChangeKind
|
|
}
|
|
|
|
export type FeedItemRecord = {
|
|
feed_item_id: string
|
|
title: string
|
|
kind: FeedItemKind
|
|
source: FeedItemSource
|
|
linked_app_id?: string
|
|
media_type?: string
|
|
file_name?: string
|
|
stored_path?: string
|
|
preview_text?: string
|
|
deleted: boolean
|
|
created_at: number
|
|
updated_at: number
|
|
}
|
|
|
|
// ── App library ─────────────────────────────────────────────────────
|
|
|
|
export type AppKind =
|
|
| 'html_page'
|
|
| 'react_app'
|
|
| 'dashboard'
|
|
| 'document_experience'
|
|
| 'tool_app'
|
|
|
|
export type AppVisibility = 'family' | 'admin' | 'archived'
|
|
|
|
export type AppCapability =
|
|
| 'get_context'
|
|
| 'list_files'
|
|
| 'read_text'
|
|
| 'read_json'
|
|
| 'open_feed_item'
|
|
| 'open_app'
|
|
| 'publish_patch'
|
|
| 'request_action'
|
|
| 'emit_event'
|
|
|
|
export type AppRepoLink = {
|
|
url: string
|
|
branch?: string
|
|
commit?: string
|
|
}
|
|
|
|
export type LibraryAppManifestV2 = {
|
|
schema_version: string
|
|
app_id: string
|
|
title: string
|
|
name: string
|
|
description?: string
|
|
visibility: AppVisibility
|
|
created_at: number
|
|
updated_at: number
|
|
last_launched_at: number
|
|
created_from_feed_item_id?: string
|
|
current_version_id: string
|
|
published_commit?: string
|
|
default_branch: string
|
|
local_repo_path: string
|
|
remote_repo?: AppRepoLink
|
|
kind: AppKind
|
|
icon?: string
|
|
tags: string[]
|
|
capabilities: AppCapability[]
|
|
source_turn_id?: string
|
|
source_feed_item_ids: string[]
|
|
}
|
|
|
|
export type AppBundleManifestV1 = {
|
|
schema_version: string
|
|
app_id: string
|
|
name: string
|
|
title: string
|
|
description?: string
|
|
kind: AppKind
|
|
entry: string
|
|
files: string[]
|
|
icon?: string
|
|
capabilities: AppCapability[]
|
|
tags: string[]
|
|
}
|
|
|
|
export type LibraryAppVersionRecord = {
|
|
version_id: string
|
|
created_at: number
|
|
entry: string
|
|
files: string[]
|
|
branch: string
|
|
commit?: string
|
|
published_at?: number
|
|
source_turn_id?: string
|
|
source_feed_item_ids: string[]
|
|
changelog_summary?: string
|
|
}
|
|
|
|
export type LibraryAppRecord = {
|
|
manifest: LibraryAppManifestV2
|
|
bundle_manifest: AppBundleManifestV1
|
|
current_version: LibraryAppVersionRecord
|
|
}
|
|
|
|
export type AppWorkspaceRecord = {
|
|
app_id: string
|
|
cwd: string
|
|
branch: string
|
|
head_commit: string
|
|
dirty: boolean
|
|
bundle_manifest: AppBundleManifestV1
|
|
}
|
|
|
|
export type AppPackageRequest = {
|
|
feed_item_id: string
|
|
requested_app_id?: string
|
|
title?: string
|
|
description?: string
|
|
}
|
|
|
|
export type AppPackageResult = {
|
|
app: LibraryAppRecord
|
|
created: boolean
|
|
}
|
|
|
|
export type AppPublishRequest = {
|
|
message: string
|
|
}
|
|
|
|
export type AppPublishResult = {
|
|
app: LibraryAppRecord
|
|
workspace: AppWorkspaceRecord
|
|
}
|
|
|
|
export type AppHistoryEntry = {
|
|
commit: string
|
|
message: string
|
|
authored_at: number
|
|
}
|
|
|
|
export type AppHistoryResponse = {
|
|
entries: AppHistoryEntry[]
|
|
}
|