Skip to content

feat(debugger): add bot debugger web tool#2

Open
winrey wants to merge 71 commits intomainfrom
feat/tasks-module-preview
Open

feat(debugger): add bot debugger web tool#2
winrey wants to merge 71 commits intomainfrom
feat/tasks-module-preview

Conversation

@winrey
Copy link
Contributor

@winrey winrey commented Mar 17, 2026

Summary

  • Add standalone Bot Debugger web app at apps/debugger/ for testing bot/AI Staff WebSocket integration
  • Three-column layout: connection management (left), real-time event stream with virtual scrolling (center), action panel with Quick Actions/JSON Editor/Inspector tabs (right)
  • Connects to gateway's /im namespace using t9bot_ token authentication
  • Intercepts and displays all inbound/outbound WebSocket events with semantic rendering (messages, streaming, presence, typing)
  • Supports sending messages via REST API, streaming simulation (auto-chunk + manual), typing indicators, reactions, and freeform JSON events
  • Auto-loads channels after authentication, connection profile persistence

Tech Stack

Vite 7 + React 19 + TypeScript + Tailwind CSS 4 + Zustand 5 + socket.io-client + @tanstack/react-virtual

How to Run

pnpm dev:debugger  # opens at http://localhost:5174

Gateway must be running with CORS_ORIGIN including http://localhost:5174.

Test plan

  • pnpm dev:debugger starts without errors
  • Three-column layout renders correctly
  • Can connect to gateway with a valid bot token
  • Events appear in real-time in the event stream
  • Filters (direction, category, search) work correctly
  • Can send messages via Quick Actions
  • Streaming simulation works (auto-chunk mode)
  • JSON Editor sends arbitrary events
  • Inspector shows full payload of selected events
  • Disconnect/reconnect works cleanly

🤖 Generated with Claude Code

winrey and others added 30 commits March 13, 2026 18:12
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the standalone task-tracker service (port 3002) which was never
integrated into the gateway or frontend. TaskCast replaces it as the
real-time task tracking infrastructure.

- Delete apps/server/apps/task-tracker/ entirely
- Delete database schema (tracker/tasks.ts)
- Remove tracker export from schemas/index.ts
- Remove TASK_TRACKER_PORT from env.ts
- Remove task-tracker COPY from all Dockerfiles
- Update pnpm-lock.yaml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
14 tasks covering SDK installation, TaskCastService rewrite,
task-worker client, TaskBotService/TasksService integration,
webhook update, SSE proxy endpoint, and frontend SSE hook
with polling replacement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use `agent_task_exec_${execId}` as TaskCast task IDs, allowing all
services to compute the ID without DB lookups. Updates Tasks 2, 3,
5, 6, and 7 accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…erver-sdk calls

Uses deterministic IDs (agent_task_exec_{execId}) and fire-and-forget
error handling. All methods catch errors internally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r with real task creation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…publishing

Injects TaskCastService into TaskBotService and wires it into reportSteps,
updateStatus, createIntervention, and addDeliverable to publish real-time
progress, status transitions, interventions, and deliverable events to TaskCast.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sume/stop/resolve sync

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…en SSE active

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… SSE active

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Set up jest with ts-jest and ESM support in task-worker, and add 8 unit
tests covering secret validation, ID parsing, execution lookup, and the
full timeout status-update path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers auth (no-token 401, invalid-JWT 401, header token, query-param token),
execution NotFoundException, workspace membership 403, and deterministic
TaskCast ID format — skipping actual SSE proxy / fetch streaming.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover pause/resume/stop calling transitionStatus with the
deterministic ID and correct status, the null-executionId no-op paths,
and resolveIntervention calling both transitionStatus and publishEvent
in order with the correct payload and ID format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers all 8 TaskCast call sites in TaskBotService (reportSteps,
updateStatus, createIntervention, addDeliverable) — verifying both
the "taskcastTaskId is set → call TaskCast" and "null → skip" paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Register 'custom' executor strategy reusing openclaw strategy
- Fix refetchInterval in RunDetailView and TaskDetailPanel to use
  query callback pattern avoiding stale data reference
- Include task-worker in dev and dev:server:all scripts
…w strategy

Replace auto-incrementing execution version with a snapshot of the task's
version at execution time. Bump task version when its linked document is
updated. Implement the OpenClaw strategy to actually call the agent execute
API endpoint.
Cover secrets extraction fallback, bot lookup failures, version
snapshot behavior, strategy delegation, and channel naming logic.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Prerequisites section (namespace /im, CORS, bot token)
- Clarify messages sent via REST API, not WebSocket
- Document authenticated/auth_error connection lifecycle
- Note bot controller endpoints need uncommenting
- Add streaming channelId/streamId requirements
- Import types from @team9/shared instead of duplicating
- Fix pnpm workspace integration notes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 tasks covering project scaffolding, core services (DebugSocket, EventStore,
API client), three-column layout, semantic event renderers, action panel with
streaming simulation, and integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
winrey and others added 28 commits March 17, 2026 10:32
…lation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…spector

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r handling

- Clear ping interval on disconnect to prevent memory leak on reconnect
- Cap events array at 10,000 entries to prevent unbounded memory growth
- Fetch bot username from user profile after authentication
- Add res.ok checks and safe JSON parsing for all REST API calls

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add all/active/upcoming/finished filter tabs for easier task filtering
instead of static status groups.
Redesign task module UI to fix hierarchy confusion:
- Left panel tasks become expandable with inline run history
- Settings moves to modal dialog (hover gear icon)
- Right panel simplified to run details only (no tabs)
7-task plan covering: TaskRunItem, TaskSettingsDialog,
TaskCard rewrite, TaskRightPanel simplification, TaskList
state management, TaskHistoryTab removal, and manual testing.
TaskRunItem displays individual execution runs with status, version,
timestamp, trigger type and duration. TaskSettingsDialog wraps the
existing TaskSettingsTab in a modal dialog for the new UI hierarchy.
TaskCard now supports expand/collapse to show inline run history via
TaskRunItem, with a hover-visible settings gear icon per task card.
Remove tabs (settings, history) from right panel since settings moved
to a modal dialog and history is now inline in the task card.
… dialog

Replace flat task list with expandable TaskCards showing inline run
history. Add ExpandableTaskCard inner component for per-task execution
fetching and auto-selection. Wire up TaskSettingsDialog for modal settings.
Covers the end-to-end fix for OpenclawStrategy: new HTTP execute/stop
endpoints on OpenClaw side, AgentRunContext metadata extension, task
event bridge in Team9 plugin, and Team9 strategy rewrite with proper
request body, auth, and timeout.
…on fixes

- Refactor bot API routes to include executionId in path (/:taskId/executions/:executionId/*)
- Replace getActiveExecution with getExecutionDirect for direct lookup by executionId+taskId
- Add terminal status rejection (ConflictException for completed/failed/timeout/stopped)
- Add CAS (compare-and-swap) pattern in ExecutorService to prevent duplicate executions
- Add env fallbacks (OPENCLAW_INSTANCE_URL, OPENCLAW_GATEWAY_TOKEN) for local dev
- Change default OpenClaw agentId from 'default' to 'main'
- Fix frontend task expansion to set activeTaskId immediately for tasks with no runs
- Add retry to validated status transitions
…le as fallback

- Add pre-execution validation: reject tasks with no document content and no title
- Use task title as fallback message when documentContent is empty
- Add title field to ExecutionContext interface and wire it through ExecutorService
- Trim both documentContent and title to prevent blank prompts
- Update test baseContext with required title field
@winrey winrey requested a review from Copilot March 21, 2026 12:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a standalone “Bot Debugger” web app and, in parallel, removes the legacy Task Tracker service while integrating TaskCast-driven execution tracking across gateway/task-worker (including deterministic TaskCast IDs, execution/versioning updates, and SSE proxying).

Changes:

  • Add apps/debugger/ Vite + React tool for connecting to /im, capturing WS traffic, and sending actions (REST + WS).
  • Integrate TaskCast into gateway + task-worker (deterministic agent_task_exec_<execId> IDs, status syncing, SSE proxy endpoint, DB schema/migration updates).
  • Remove Task Tracker microservice and its DB schema exports and Docker image build steps.

Reviewed changes

Copilot reviewed 120 out of 130 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
docker/task-worker.Dockerfile Removes task-tracker package.json copy from worker build context
docker/task-tracker.Dockerfile Removes Task Tracker Dockerfile (service appears deprecated)
docker/im-worker.Dockerfile Removes task-tracker package.json copy from build context
docker/gateway.Dockerfile Removes task-tracker package.json copy from build context
docker/client.Dockerfile Removes task-tracker package.json copy from build context
apps/server/libs/shared/src/env.ts Removes TASK_TRACKER_PORT and adds OpenClaw URL/token env accessors
apps/server/libs/database/src/schemas/tracker/tasks.ts Removes tracker_tasks schema definition
apps/server/libs/database/src/schemas/tracker/index.ts Removes tracker schema re-export
apps/server/libs/database/src/schemas/task/tasks.ts Adds version column to agent tasks
apps/server/libs/database/src/schemas/task/task-executions.ts Renames execution version to taskVersion (task_version column)
apps/server/libs/database/src/schemas/index.ts Stops exporting tracker schemas
apps/server/libs/database/migrations/meta/_journal.json Adds migration 0024 entry
apps/server/libs/database/migrations/0024_ambitious_mentor.sql Drops tracker_tasks + task_status type; renames/creates task version columns/indexes
apps/server/apps/task-worker/src/webhook/webhook.controller.ts Parses deterministic TaskCast IDs; updates execution/task timeout by execution ID
apps/server/apps/task-worker/src/webhook/webhook.controller.spec.ts Adds tests around webhook secret validation, ID parsing and updates
apps/server/apps/task-worker/src/taskcast/taskcast.module.ts Adds TaskCast module wiring for task-worker
apps/server/apps/task-worker/src/taskcast/taskcast.client.ts Adds TaskCast SDK client wrapper for task-worker
apps/server/apps/task-worker/src/taskcast/taskcast.client.spec.ts Adds unit tests for TaskCast client wrapper
apps/server/apps/task-worker/src/executor/strategies/openclaw.strategy.ts Implements OpenClaw execute/stop with config resolution from DB/env
apps/server/apps/task-worker/src/executor/strategies/openclaw.strategy.spec.ts Adds unit tests for OpenClaw strategy behavior
apps/server/apps/task-worker/src/executor/executor.service.ts Adds CAS claim, TaskCast task creation, task version snapshot, and stopExecution
apps/server/apps/task-worker/src/executor/executor.service.spec.ts Adds unit tests for executor flow (needs alignment with new CAS update flow)
apps/server/apps/task-worker/src/executor/executor.module.ts Wires TaskCastModule and registers strategy for custom bots
apps/server/apps/task-worker/src/executor/execution-strategy.interface.ts Extends ExecutionContext with title and makes taskcastTaskId nullable
apps/server/apps/task-worker/src/consumer/task-command.consumer.ts Implements stop command via executor.stopExecution
apps/server/apps/task-worker/package.json Adds Jest ESM config flags and TaskCast deps
apps/server/apps/task-worker/jest.config.cjs Adds Jest config for task-worker tests
apps/server/apps/task-tracker/tsconfig.json Removes task-tracker TS config (service removal)
apps/server/apps/task-tracker/src/task/task.module.ts Removes task-tracker module
apps/server/apps/task-tracker/src/task/task.controller.ts Removes task-tracker REST/SSE controller
apps/server/apps/task-tracker/src/task/dto/update-status.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/task/dto/update-progress.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/task/dto/retry-task.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/task/dto/release-task.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/task/dto/register-task.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/task/dto/index.ts Removes task-tracker DTO exports
apps/server/apps/task-tracker/src/task/dto/claim-task.dto.ts Removes task-tracker DTOs
apps/server/apps/task-tracker/src/sse/sse.service.ts Removes task-tracker SSE service
apps/server/apps/task-tracker/src/shared/types/progress.ts Removes task-tracker SSE type definitions
apps/server/apps/task-tracker/src/shared/types/index.ts Removes task-tracker type exports
apps/server/apps/task-tracker/src/shared/constants/redis-keys.ts Removes task-tracker Redis keys
apps/server/apps/task-tracker/src/shared/constants/index.ts Removes task-tracker constant exports
apps/server/apps/task-tracker/src/main.ts Removes task-tracker bootstrap
apps/server/apps/task-tracker/src/load-env.ts Removes task-tracker dotenv loader
apps/server/apps/task-tracker/src/app.module.ts Removes task-tracker app module
apps/server/apps/task-tracker/package.json Removes task-tracker package
apps/server/apps/task-tracker/nest-cli.json Removes task-tracker Nest CLI config
apps/server/apps/task-tracker/CLAUDE.md Removes task-tracker documentation
apps/server/apps/gateway/src/tasks/tasks.service.ts Orders executions by createdAt; syncs pause/resume/stop + intervention resolve to TaskCast
apps/server/apps/gateway/src/tasks/tasks.module.ts Adds TasksStreamController to module controllers
apps/server/apps/gateway/src/tasks/tasks-stream.controller.ts Adds SSE proxy endpoint for TaskCast execution event stream
apps/server/apps/gateway/src/tasks/tasks-stream.controller.spec.ts Adds unit tests for SSE proxy auth + lookup logic
apps/server/apps/gateway/src/tasks/taskcast.service.ts Implements TaskCast SDK integration (create, transition, publish) and deterministic ID helper
apps/server/apps/gateway/src/tasks/taskcast.service.spec.ts Adds unit tests for TaskCastService mappings and behavior
apps/server/apps/gateway/src/tasks/task-bot.service.ts Uses executionId-scoped endpoints; publishes steps/interventions/deliverables + status to TaskCast
apps/server/apps/gateway/src/tasks/task-bot.controller.ts Changes bot endpoints to include executionId in route
apps/server/apps/gateway/src/documents/documents.service.ts Bumps linked task version on document version creation
apps/server/apps/gateway/package.json Adds TaskCast SDK dependency
apps/debugger/vite.config.ts Adds debugger Vite config (port 5174 + alias)
apps/debugger/tsconfig.json Adds debugger TS config
apps/debugger/src/styles/globals.css Adds Tailwind v4 globals/theme token
apps/debugger/src/stores/events.ts Adds event store w/ filtering + export
apps/debugger/src/stores/connection.ts Adds connection store w/ profile persistence
apps/debugger/src/services/debug-socket.ts Adds socket.io debug client with event interception + ping/latency
apps/debugger/src/services/api.ts Adds REST helpers for IM endpoints + event recording
apps/debugger/src/main.tsx Adds app bootstrap
apps/debugger/src/lib/utils.ts Adds helper utilities (ids, formatting, payload extraction)
apps/debugger/src/lib/types.ts Adds debugger domain types
apps/debugger/src/lib/events.ts Adds WS event constants + categorization/colors
apps/debugger/src/components/right/QuickActions.tsx Adds REST/WS quick actions (messages, streaming, typing, join/leave, etc.)
apps/debugger/src/components/right/JsonEditor.tsx Adds JSON event composer + presets
apps/debugger/src/components/right/Inspector.tsx Adds selected event inspector
apps/debugger/src/components/right/ActionPanel.tsx Adds right-side tabs container
apps/debugger/src/components/left/ConnectionPanel.tsx Adds connection UI + profile management
apps/debugger/src/components/left/ChannelList.tsx Adds channel list + channel filter wiring
apps/debugger/src/components/left/BotInfo.tsx Adds connected bot identity display
apps/debugger/src/components/center/renderers/index.tsx Adds semantic preview router
apps/debugger/src/components/center/renderers/StreamingRenderer.tsx Adds streaming preview renderer
apps/debugger/src/components/center/renderers/PresenceRenderer.tsx Adds presence/typing preview renderer
apps/debugger/src/components/center/renderers/MessageRenderer.tsx Adds message preview renderer
apps/debugger/src/components/center/renderers/GenericRenderer.tsx Adds fallback preview renderer
apps/debugger/src/components/center/EventStream.tsx Adds virtualized event stream with auto-scroll
apps/debugger/src/components/center/EventFilter.tsx Adds direction/category/search filtering UI
apps/debugger/src/components/center/EventCard.tsx Adds event card w/ raw JSON toggle + selection
apps/debugger/src/components/TopBar.tsx Adds top status bar + export/clear/disconnect
apps/debugger/src/components/Layout.tsx Adds 3-column layout skeleton
apps/debugger/src/components/BottomBar.tsx Adds stats bar incl. latency
apps/debugger/src/App.tsx Wires layout panels + loads profiles
apps/debugger/package.json Adds debugger app package definition & deps
apps/debugger/index.html Adds debugger HTML entry
apps/client/src/types/task.ts Adds task.version and renames execution version → taskVersion
apps/client/src/routes/_authenticated/tasks/index.tsx Simplifies tasks route page wrapper
apps/client/src/i18n/locales/zh/tasks.json Adds strings for new tabs/chat/history UI
apps/client/src/i18n/locales/en/tasks.json Adds strings for new tabs/chat/history UI
apps/client/src/hooks/useExecutionStream.ts Adds SSE hook for execution streams via gateway proxy
apps/client/src/components/tasks/TaskSettingsTab.tsx Adds settings tab (bot assignment, triggers, doc, delete)
apps/client/src/components/tasks/TaskSettingsDialog.tsx Adds settings modal wrapper
apps/client/src/components/tasks/TaskRunsTab.tsx Removes old runs tab
apps/client/src/components/tasks/TaskRunTab.tsx Adds run detail side panel tab w/ SSE + timeline
apps/client/src/components/tasks/TaskRunItem.tsx Adds compact run list item component
apps/client/src/components/tasks/TaskRightPanel.tsx Adds right-side run detail panel
apps/client/src/components/tasks/TaskDetailPanel.tsx Removes old detail panel
apps/client/src/components/tasks/TaskChatPlaceholder.tsx Adds placeholder for chat area before runs exist
apps/client/src/components/tasks/TaskChatArea.tsx Adds chat UI w/ run banners, controls, read-only mode
apps/client/src/components/tasks/TaskCard.tsx Reworks task card to expand runs + settings & selection
apps/client/src/components/tasks/RunDetailView.tsx Removes old run detail view
apps/client/src/components/channel/ChannelView.tsx Adds hideHeader + readOnly options
apps/client/package.json Adds @taskcast/client dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

const agentId =
(bot.extra as Record<string, any>)?.openclaw?.agentId ?? 'main';
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strategy defaults agentId to 'main', but the accompanying unit tests expect the default agent id to be 'default' (and assert URLs containing /api/agents/default/...). This will cause the tests to fail and is also ambiguous for runtime behavior. Either change the fallback here to 'default' or update the tests (and any dependent assumptions) to match the intended default.

Suggested change
(bot.extra as Record<string, any>)?.openclaw?.agentId ?? 'main';
(bot.extra as Record<string, any>)?.openclaw?.agentId ?? 'default';

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +46
const updateSets: any[] = [];
function makeChainableUpdate() {
const chain: any = {};
chain.set = jest.fn<any>().mockImplementation((v: any) => {
updateSets.push(v);
return chain;
});
chain.where = jest.fn<any>().mockResolvedValue([]);
return chain;
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ExecutorService flow uses db.update(...).set(...).where(...).returning(...) for the CAS claim, but this mock update chain does not implement returning() and also makes where() terminal (it resolves a Promise instead of returning the chain). This will throw at runtime in the spec and makes the unit tests unreliable. Update the mock so where() returns the chain and returning() resolves to the claimed rows needed by each test case (e.g., [] for not-claimed, [sampleTask] for claimed).

Copilot uses AI. Check for mistakes.
Comment on lines +315 to +329
// 4. Call strategy.stop()
const context: ExecutionContext = {
taskId,
executionId: execution.id,
botId: task.botId,
// channelId is nullable in DB but ExecutionContext requires string; guard checked above
channelId: execution.channelId ?? '',
title: task.title,
taskcastTaskId: execution.taskcastTaskId,
};

try {
await strategy.stop(context);
} catch (error) {
this.logger.warn(`Strategy stop failed for task ${taskId}: ${error}`);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructs an ExecutionContext with channelId: '' when execution.channelId is null, even though the comment implies it was guarded (it isn't). Passing an empty channel id can lead to incorrect downstream behavior (e.g., stop requests targeting the wrong session or failing silently). Prefer to (a) return early with a log if execution.channelId is null, or (b) change ExecutionContext.channelId to string | null and update strategies to handle the nullable case explicitly.

Suggested change
// 4. Call strategy.stop()
const context: ExecutionContext = {
taskId,
executionId: execution.id,
botId: task.botId,
// channelId is nullable in DB but ExecutionContext requires string; guard checked above
channelId: execution.channelId ?? '',
title: task.title,
taskcastTaskId: execution.taskcastTaskId,
};
try {
await strategy.stop(context);
} catch (error) {
this.logger.warn(`Strategy stop failed for task ${taskId}: ${error}`);
// 4. Call strategy.stop() (only if we have a valid channelId)
if (!execution.channelId) {
this.logger.warn(
`Execution ${execution.id} for task ${taskId} has no channelId; skipping strategy.stop`,
);
} else {
const context: ExecutionContext = {
taskId,
executionId: execution.id,
botId: task.botId,
channelId: execution.channelId,
title: task.title,
taskcastTaskId: execution.taskcastTaskId,
};
try {
await strategy.stop(context);
} catch (error) {
this.logger.warn(`Strategy stop failed for task ${taskId}: ${error}`);
}

Copilot uses AI. Check for mistakes.
async streamExecution(
@Param('taskId') taskId: string,
@Param('execId') execId: string,
@Query('token') queryToken: string | undefined,
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting JWTs via ?token= is risky because query strings are commonly logged (reverse proxies, browser history, analytics) and can leak via referrers. Prefer Authorization headers only for this SSE endpoint, or introduce a short-lived, single-purpose stream token (or signed URL) rather than reusing the primary auth JWT in the URL.

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +55
const headerToken = req.headers.authorization?.replace('Bearer ', '');
const token = headerToken || queryToken;

if (!token) {
res.status(401).json({ error: 'Unauthorized' });
return;
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting JWTs via ?token= is risky because query strings are commonly logged (reverse proxies, browser history, analytics) and can leak via referrers. Prefer Authorization headers only for this SSE endpoint, or introduce a short-lived, single-purpose stream token (or signed URL) rather than reusing the primary auth JWT in the URL.

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +170
// return process.env.OPENCLAW_INSTANCE_URL;
return process.env.OPENCLAW_API_URL;
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getter named OPENCLAW_INSTANCE_URL currently returns process.env.OPENCLAW_API_URL and has the expected env var commented out. This is likely to break configuration in environments that set OPENCLAW_INSTANCE_URL (per the getter name/comment) but not OPENCLAW_API_URL. Consider returning process.env.OPENCLAW_INSTANCE_URL ?? process.env.OPENCLAW_API_URL and removing the commented-out line to avoid confusion.

Suggested change
// return process.env.OPENCLAW_INSTANCE_URL;
return process.env.OPENCLAW_API_URL;
return process.env.OPENCLAW_INSTANCE_URL ?? process.env.OPENCLAW_API_URL;

Copilot uses AI. Check for mistakes.
},
],
},
collectCoverageFrom: ['src/**/*.(t|j)s'],
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collectCoverageFrom glob src/**/*.(t|j)s is not a standard glob pattern for matching .ts/.js files and may not collect any coverage (it tends to match literal filenames like foo.(t|j)s). Use a brace pattern like src/**/*.{ts,js} (or separate globs) so coverage collection works as intended.

Suggested change
collectCoverageFrom: ['src/**/*.(t|j)s'],
collectCoverageFrom: ['src/**/*.{ts,js}'],

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +7
ALTER TABLE "tracker_tasks" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
DROP TABLE "tracker_tasks" CASCADE;--> statement-breakpoint
ALTER TABLE "agent_task__executions" RENAME COLUMN "version" TO "task_version";--> statement-breakpoint
DROP INDEX "idx_agent_task__executions_task_version";--> statement-breakpoint
ALTER TABLE "agent_task__tasks" ADD COLUMN "version" integer DEFAULT 1 NOT NULL;--> statement-breakpoint
CREATE INDEX "idx_agent_task__executions_task_version" ON "agent_task__executions" USING btree ("task_id","task_version");--> statement-breakpoint
DROP TYPE "public"."task_status"; No newline at end of file
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description focuses on adding a Bot Debugger web tool, but this migration drops the entire tracker_tasks table/type and renames execution columns while adding task versioning. That’s a substantial behavioral/data-model change beyond the debugger scope. Consider updating the PR description/title to reflect the TaskCast + task-tracker removal work (or splitting these DB/service changes into a separate PR) to reduce review and rollout risk.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants