Files
ARTEX-chixuweihu/agent/runinfo.go
T
ji ruo b23d1776c7 feat(settings): default-enable screenshot/evidence settings and fix container Playwright MCP
- Default-enable browser_screenshot_enabled, browser_screenshot_timestamp_enabled, agent_traffic_binding, and task_intelligence_enabled when unset in DB (preserving explicit user false values).
- Align db/credentials.go SQL checks and frontend defaults/copy with DefaultTaskIntelligence = true.
- Fix container Playwright MCP screenshot failures: ensure --browser chromium in seed/reconcile, install Chromium via playwright-mcp install-browser --with-deps chromium in Dockerfile, prefer local playwright-mcp binary over npx, and run stdio MCP servers in the active agent working directory with stderr capture.

Fixes #188
2026-11-26 00:54:12 +08:00

49 lines
1.7 KiB
Go

package agent
import (
"context"
"github.com/Autumn-27/artex/db"
)
// RunInfo identifies WHICH run a tool call belongs to. Tool assembly only receives
// (ctx, agentKey) — the task/exploration ids live in the caller's arguments, not the
// ctx — so anything wired at assembly time (currently the Skill ledger in
// server/assembly.go) has no way to attribute a call to a task. Each run attaches
// its own RunInfo before calling AugmentTools; the wiring closure reads it once and
// captures it, so per-run attribution stays correct without threading parameters
// through the tool layer. Same pattern as TaskClock (see taskclock.go).
//
// Zero value = attribution unknown; every consumer must treat it as optional.
type RunInfo struct {
TaskID int64 // task registry id; 0 for non-task runs (chat sessions)
ExplorationID int64 // exploration id; 0 when unknown
IntentID int64 // worker's intent node; 0 for planner/mainagent/chat
SessionID string // chat conversation id; empty for task runs
WorkDir string // active agent run working directory; used for stdio MCP CWD
}
// explorationID reads a store's exploration id, tolerating a nil store (planner and
// worker runs can be driven without one in tests).
func explorationID(ts *db.ExplorationStore) int64 {
if ts == nil {
return 0
}
return ts.ID()
}
type runInfoKey struct{}
// WithRunInfo attaches run attribution to ctx.
func WithRunInfo(ctx context.Context, ri RunInfo) context.Context {
return context.WithValue(ctx, runInfoKey{}, ri)
}
// RunInfoFrom reads the RunInfo (zero value if none attached).
func RunInfoFrom(ctx context.Context) RunInfo {
if v, ok := ctx.Value(runInfoKey{}).(RunInfo); ok {
return v
}
return RunInfo{}
}