@sideboard-ai/core 0.1.73 → 0.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/agents/cursor-runner.cjs +1 -1
  2. package/dist/agents/cursor-runner.js +1 -1
  3. package/dist/{agents-77GE7VRW.js → agents-2S2JVLZ6.js} +3 -3
  4. package/dist/{agents-GUFUYXKP.js → agents-H7M5CQY2.js} +4 -4
  5. package/dist/{chunk-POW7JCB5.js → chunk-2NKSHIRI.js} +1 -1
  6. package/dist/{chunk-WSFZPOPH.js → chunk-5KJMNNCB.js} +17 -11
  7. package/dist/{chunk-NF6Y4GTE.js → chunk-77W62MTX.js} +1 -1
  8. package/dist/{chunk-CYKPUTXN.js → chunk-DG3S2UXP.js} +1 -1
  9. package/dist/{chunk-CXT2PLO7.js → chunk-GJ2LZQJI.js} +1 -1
  10. package/dist/{chunk-V4ACEJX2.js → chunk-HCWAIEBU.js} +11 -10
  11. package/dist/{chunk-AFW3M6LU.js → chunk-KBKPVKYZ.js} +17 -11
  12. package/dist/{chunk-3WJAUKIL.js → chunk-SEOICVGB.js} +1 -1
  13. package/dist/{chunk-6RFPKZNC.js → chunk-XA2FQJTN.js} +11 -10
  14. package/dist/{coordinator-prompt-4U2QNHGT.js → coordinator-prompt-3XXSG7M2.js} +1 -1
  15. package/dist/{coordinator-prompt-ZHBDHMZB.js → coordinator-prompt-RTUCCPCI.js} +1 -1
  16. package/dist/{global-workspace-S3B6ESZS.js → global-workspace-CSIS62Z4.js} +2 -2
  17. package/dist/{global-workspace-VF56FTPY.js → global-workspace-PJU6HISJ.js} +2 -2
  18. package/dist/index.cjs +155 -32
  19. package/dist/index.d.cts +34 -3
  20. package/dist/index.d.ts +34 -3
  21. package/dist/index.js +134 -23
  22. package/dist/mcp/run-stdio.cjs +141 -32
  23. package/dist/mcp/run-stdio.js +124 -22
  24. package/dist/{workspaces-ZJ45O4CD.js → workspaces-L4TXMUNM.js} +3 -3
  25. package/dist/{workspaces-R66324S7.js → workspaces-W72KZL4B.js} +3 -3
  26. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -49,6 +49,11 @@ interface TokenUsage {
49
49
  outputTokens: number;
50
50
  cacheReadTokens?: number;
51
51
  cacheWriteTokens?: number;
52
+ /**
53
+ * Tokens occupying the context window on the last API request of this turn
54
+ * (input + cache). Distinct from billed totals, which sum every tool round.
55
+ */
56
+ lastRequestTokens?: number;
52
57
  }
53
58
  interface ThreadMessage {
54
59
  role: 'user' | 'agent' | 'summary';
@@ -411,6 +416,8 @@ type AgentEvent = {
411
416
  } | {
412
417
  type: 'usage';
413
418
  data: TokenUsage;
419
+ /** `request` = one API call; `turn` = billed total for the whole agent turn. */
420
+ scope?: 'request' | 'turn';
414
421
  } | {
415
422
  type: 'exit';
416
423
  data: number | null;
@@ -1325,6 +1332,13 @@ declare function submitPrStack(cwd: string, opts?: {
1325
1332
  /** Check out a stack layer by PR number, stack number, URL, or branch. */
1326
1333
  declare function checkoutPrStackLayer(cwd: string, target: string | number): Promise<void>;
1327
1334
 
1335
+ /** Canonical git prompts the desktop buttons and orchestration `ask_git` send. */
1336
+ declare const AGENT_GIT_ACTIONS: readonly ["commit-push", "create-draft", "create-web", "resolve-conflicts", "merge"];
1337
+ type AgentGitAction = (typeof AGENT_GIT_ACTIONS)[number];
1338
+ declare function agentGitPrompt(action: AgentGitAction, opts?: {
1339
+ prBase?: string | null;
1340
+ }): string;
1341
+
1328
1342
  interface GitHubStatus {
1329
1343
  connected: boolean;
1330
1344
  login: string | null;
@@ -1793,10 +1807,21 @@ declare function isBrightsyNdjsonLine(line: string): boolean;
1793
1807
  declare function finalizeParts(parts: MessagePart[]): MessagePart[];
1794
1808
  declare function normalizeParseResult(parsed: AgentEvent | AgentEvent[] | null): AgentEvent[];
1795
1809
 
1810
+ /** Prompt tokens occupying the context window for a single API call. */
1811
+ declare function requestOccupancy(u: TokenUsage): number;
1796
1812
  /** Accumulate incremental usage (one CLI turn may report usage in several steps). */
1797
1813
  declare function mergeUsage(a: TokenUsage | null, b: TokenUsage): TokenUsage;
1814
+ type UsageScope = 'request' | 'turn';
1815
+ /**
1816
+ * Fold a usage event into the turn total.
1817
+ * Request-scoped events are one API call (sum for billing; last occupancy for the meter).
1818
+ * Turn-scoped events replace billed totals (Claude/Codex result) without wiping last-request size.
1819
+ */
1820
+ declare function applyTurnUsage(current: TokenUsage | null, incoming: TokenUsage, scope?: UsageScope): TokenUsage;
1798
1821
  /** Total tokens processed for a turn (input + output + cache reads/writes). */
1799
1822
  declare function totalTokens(u: TokenUsage): number;
1823
+ /** Context-window fill: last API request when known, else billed input + cache. */
1824
+ declare function contextTokens(u: TokenUsage): number;
1800
1825
 
1801
1826
  interface McpServerStatus {
1802
1827
  name: string;
@@ -2711,6 +2736,11 @@ declare class Orchestrator {
2711
2736
  * and send the merge-readiness prefill.
2712
2737
  */
2713
2738
  requestReview(threadRef: string): Promise<Thread>;
2739
+ /**
2740
+ * Queue a desktop-git-button prompt on a worktree agent (commit/push/PR/merge).
2741
+ * Orchestrators use this instead of running git/gh from the synthetic home.
2742
+ */
2743
+ askGit(threadRef: string, action: AgentGitAction): Promise<Thread>;
2714
2744
  setThreadOptions(threadRef: string, patch: ThreadOptionsPatch): Thread;
2715
2745
  createChatTab(input: {
2716
2746
  fromThreadId: string;
@@ -2986,8 +3016,9 @@ declare function cloneRepoIntoSideboard(opts: {
2986
3016
 
2987
3017
  /**
2988
3018
  * Sideboard MCP server — agent-facing judgment surface.
2989
- * Deliberately excludes ready-for-review confirm_land, purge_thread, and
2990
- * host-owned draft PR creation. Orchestrators ask worktree agents to open PRs.
3019
+ * Deliberately excludes ready-for-review confirm_land and purge_thread.
3020
+ * Orchestrators commit, push, open PRs, and merge by telling worktree agents
3021
+ * (`ask_git` / `send_to_thread`) — they do not run git/gh from the synthetic home.
2991
3022
  */
2992
3023
  declare function startMcpServer(): Promise<void>;
2993
3024
 
@@ -4062,4 +4093,4 @@ interface SlackRelayClientOptions {
4062
4093
  */
4063
4094
  declare function runSlackRelayClient(opts: SlackRelayClientOptions): Promise<void>;
4064
4095
 
4065
- export { ATTACHMENTS_DIR, type ActiveRun, type AddStackLayerInput, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentInstructionFile, type AgentKind, type AgentModelCatalog, type AgentModelInfo, type AgentSetupActionResult, type AgentSetupInfo, type AgentSetupKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BAKED_SLACK_RELAY_URL, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLAUDE_MODEL_CATALOG, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type CaffeinateHoldState, type ClaudeHarnessSettings, type CleanupOrphansResult, type CliAgentKind, type CliExecutableSettings, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ComposerFileBuffer, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateStackInput, type CreateThreadInput, type CreateWorktreeResult, type CursorModelInfo, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DefaultsAppSettings, type DevServerHandle, type DiffCommentInput, type DiffCommentLine, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GhStackStatus, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type InitStackFromThreadInput, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, LEGACY_ATTACHMENTS_DIR, LEGACY_PLAN_FILE_REL, LEGACY_REVIEW_REQUEST_PATH, LINEAR_OAUTH_CANCELLED, LINEAR_OAUTH_PORT, LINEAR_OAUTH_REDIRECT, LINEAR_OAUTH_SCOPES, type LandPreview, type LandResult, LinearOAuthCancelledError, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, ORCHESTRATOR_AGENT_KINDS, type OpenPrStackLayersInput, type OpenStackLayerInput, type OpenStackLayerResult, type OrchestrationQuotaOnLimit, Orchestrator, type OrchestratorAgentKind, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PASTE_ATTACH_MIN_CHARS, PASTE_ATTACH_MIN_LINES, PLAN_FILE_NAME, PLAN_FILE_REL, PLAN_MODE_INSTRUCTION, type PendingPlanQuestions, type PlanQuestion, type PlanQuestionAnswer, type PlanQuestionOption, type PlanToolPartLike, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type PrStack, type PrStackLayer, type PresentedPlan, type PublicAppSettings, type PublicIntegrationsSettings, REPO_REVIEW_NAME, REPO_REVIEW_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PATH, REVIEW_REQUEST_PREFILL, type RepoSettings, type RepoSetupInfo, type RequestReviewResult, type ResolvedReviewGuidelines, type ReviewGuidelinesSource, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_MCP_PROFILE_ENV, SLACK_LISTEN_BUSY_REPLY, SLACK_LISTEN_STOPPED_REPLY, SLACK_LISTEN_TIMEOUT_REPLY, SLACK_OAUTH_CANCELLED, SLACK_OAUTH_LOCAL_CALLBACK, SLACK_OAUTH_PORT, SLACK_OAUTH_REDIRECT, SLACK_REPLY_FORMATTING, SLACK_SEEN_REACTION, type ScriptHandle, type SideboardMcpProfile, type SkillInfo, type SlackInboundMessage, type SlackListenOptions, type SlackListenStatus, SlackOAuthCancelledError, type SlackOutboundReply, type SlackOutboundWatch, type SlackRelayClientMessage, type SlackRelayClientOptions, SlackRelayHub, type SlackRelayServerHandle, type SlackRelayServerMessage, type SlackRelayServerOptions, type SlackReplyBadge, type SlackWorkspaceInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, THINKING_EFFORTS, type TeamName, type ThinkingEffort, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type ToolPartLike, type TranscriptToolDetail, type TurnCommand, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, ackSlackInboundSeen, addPrStackLayer, addStackLayerFromThread, addWorkspace, adoptThread, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, assertOrchestratorCapableAgent, attachmentFromAbsolutePath, attachmentsFromBuffers, attachmentsFromWorktreePaths, attachmentsGitignoreBody, autoArchiveOnMergeEnabled, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyInjectWorktreeMcpEnabled, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildDiffCommentAttachment, buildForkTranscriptAttachment, buildPastedTextAttachment, buildReviewRequestAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateHoldPath, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, caffeinateWhileSlackListenEnabled, captureLoginEnv, captureTurnBaseline, checkoutPrStackLayer, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, coerceOrchestratorAgent, collectTakenTeamSlugs, commitAll, conductorBundledBinDir, conductorDbPath, confirmLand, connectBrightsyTeam, connectSlackToken, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createExistingBranchWorktree, createGlobalChat, createLinearPkce, createOrUpdatePr, createPrStack, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectGhStack, detectLocalMergeConflicts, disconnectBrightsyTeam, disconnectLinear, disconnectLinearConnection, disconnectSlackWorkspace, discoverSkills, dismissSlackReplyBadge, dropCachedPrefixOnResume, encodeBrightsyTarget, enrichPathWithNpmGlobalBin, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGhPreferOrigin, ensureGlobalCoordinatorCwd, ensureReviewRequestFile, ensureSlackCoordinator, ensureSlackDeviceIdentity, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractPendingPlanQuestions, extractPresentedPlan, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, findThreadForStackLayer, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatArtifactDirective, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatPlanQuestionAnswers, formatPlanQuestionsForChat, formatRateLimitResetHint, formatRenameBranchDirective, formatSlackExternalReplyPrompt, formatSlackInboundPrompt, formatSlackRepliesForTurn, formatSlackSignedReply, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, formatWorktreeReminder, getAdapter, getAgentSetupInfo, getBrightsySession, getCaffeinateHold, getDefaultAgent, getDefaultEffort, getDefaultFast, getDefaultModel, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getLinearAuthToken, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getPrStack, getRepoSetupInfo, getRunMode, getRunScript, getSlackWorkspace, gh, ghHeadRef, ghRepoSelectArgs, git, globalAgentCwd, handleSlackInbound, harnessEnvKey, hasBakedLinearOAuth, hasBakedSlackOAuth, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initPrStack, initStackFromThread, initializeGitRepository, inspectGitWorktree, installAgent, isAskUserToolName, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isConductorBundledCli, isCursorAutoModel, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isImageFilePath, isInPrStack, isInboundForThisDesktop, isLinearConnected, isLinearOAuthCancelled, isOrchestratorCapableAgent, isOrchestratorThread, isPidAlive, isPlaceholderBranch, isPresentPlanToolName, isSessionQuotaLimit, isSideboardScratchPath, isSlackCoordinatorThread, isSlackExternalReplyPrompt, isSlackOAuthCancelled, isThinkingEffort, isWorkspaceScratchPath, linearAuthorizationHeader, linearOAuthAuthorizeUrl, linearOAuthCredentials, listAgentSetupInfo, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listCodexModels, listConductorWorkspaces, listConnectedBrightsyTeams, listCursorModels, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listModelsForAgent, listOpencodeModels, listPrs, listRunScripts, listSlackOutboundWatches, listSlackReplyBadges, listSlackWorkspaces, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, loginAgent, lookupSoccerTeam, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergePrStack, mergeUsage, nextPastedTextName, nextThinkingEffort, normalizeParseResult, normalizeThinkingEffort, normalizeThread, normalizeTurnInput, normalizeWorktreePath, openInSystemTerminal, openPrStackLayers, openStackLayer, opencodeAdapter, orchestrationQuotaFallbackAgent, orchestrationQuotaOnLimit, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, originGhRepoEnv, parseCursorRunnerLine, parseForceStopMessage, parseGhStackViewJson, parseGithubSlugFromRemoteUrl, parseMcpList, parsePlanQuestionsInput, parseSessionQuotaResetAt, parseSlackRelayClientMessage, parseSlackRelayServerMessage, partsToAssistantText, pastedTextStats, pendingSlackExternalReplies, permalinkForSlackReplyBadge, permissionMode, persistVaultKeyInKeychain, planFileAbs, posixShellSingleQuote, prepareTerminalCommand, previewLand, promptMentionsBrightsy, pushBranch, readExistingReviewRequestFile, readKeychainVaultKey, readPlanFile, readSkillBody, readThread, readWorktreeFile, readWorktreeFileForUpload, readWorktreeInclude, recordSlackOutboundWatch, refreshGitHubAuth, refreshSlackReplyBadges, removeWorkspace, removeWorktree, repoSlug, requestReview, requireAgent, resetGhStackDetectCache, resolveAgentExecutable, resolveClaudeExecutable, resolveCommandBinarySync, resolveConductorCursorAgentId, resolveCursorModelId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGhAuthToken, resolveGithubRepoSlug, resolveLoginCommand, resolveNewThreadOptions, resolvePlanMarkdown, resolvePrSelector, resolveQuotaFallbackAgent, resolveRepoRoot, resolveReviewGuidelines, resolveSlackListenMode, resolveThreadDefaults, resolveThreadEffort, resolveVaultKey, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, runSlackListen, runSlackRelayClient, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, saveLinearOAuth, secureFileUnlocksWith, setCaffeinateHold, setStatus, setVaultMasterKey, settingsSourceLabel, shouldAttachPastedText, shouldCompactContext, shouldInjectBrightsyMcp, shouldRefreshReviewRequestTemplate, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardMcpProfile, sideboardReposDir, sideboardWorkspacesDir, slackAppLevelToken, slackArchiveUrl, slackCoordinatorSourceRef, slackListenEnabled, slackOAuthCredentials, slackRelayUrl, slugify, spawnAgentTurn, splitForCompaction, stackAgentDefaultsFrom, stackIdFrom, stackMergeReadiness, stageAbsolutePathsAsAttachments, stageBuffersAsAttachments, startDevServer, startLinearOAuth, startMcpServer, startOrchestration, startSlackOAuth, startSlackRelayServer, stripBrightsyNdjsonNoise, submitPrStack, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, thinkingEffortBars, thinkingEffortLabel, threadDisplayLabel, threadFilePath, threadLockPath, threadRequestsBrightsyMcp, threadsDir, threadsSharingWorktree, toPublicAppSettings, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAgentExecutable, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateCodexSettings, updateDefaultsSettings, updateIntegrationsSettings, updateOpencodeSettings, updateThread, validateLinearApiKey, withAgentInstructions, withExportedPath, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writePlanFile, writeThread, writeWorktreeFile };
4096
+ export { AGENT_GIT_ACTIONS, ATTACHMENTS_DIR, type ActiveRun, type AddStackLayerInput, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentGitAction, type AgentInstructionFile, type AgentKind, type AgentModelCatalog, type AgentModelInfo, type AgentSetupActionResult, type AgentSetupInfo, type AgentSetupKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BAKED_SLACK_RELAY_URL, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLAUDE_MODEL_CATALOG, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type CaffeinateHoldState, type ClaudeHarnessSettings, type CleanupOrphansResult, type CliAgentKind, type CliExecutableSettings, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ComposerFileBuffer, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateStackInput, type CreateThreadInput, type CreateWorktreeResult, type CursorModelInfo, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DefaultsAppSettings, type DevServerHandle, type DiffCommentInput, type DiffCommentLine, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GhStackStatus, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type InitStackFromThreadInput, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, LEGACY_ATTACHMENTS_DIR, LEGACY_PLAN_FILE_REL, LEGACY_REVIEW_REQUEST_PATH, LINEAR_OAUTH_CANCELLED, LINEAR_OAUTH_PORT, LINEAR_OAUTH_REDIRECT, LINEAR_OAUTH_SCOPES, type LandPreview, type LandResult, LinearOAuthCancelledError, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, ORCHESTRATOR_AGENT_KINDS, type OpenPrStackLayersInput, type OpenStackLayerInput, type OpenStackLayerResult, type OrchestrationQuotaOnLimit, Orchestrator, type OrchestratorAgentKind, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PASTE_ATTACH_MIN_CHARS, PASTE_ATTACH_MIN_LINES, PLAN_FILE_NAME, PLAN_FILE_REL, PLAN_MODE_INSTRUCTION, type PendingPlanQuestions, type PlanQuestion, type PlanQuestionAnswer, type PlanQuestionOption, type PlanToolPartLike, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type PrStack, type PrStackLayer, type PresentedPlan, type PublicAppSettings, type PublicIntegrationsSettings, REPO_REVIEW_NAME, REPO_REVIEW_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PATH, REVIEW_REQUEST_PREFILL, type RepoSettings, type RepoSetupInfo, type RequestReviewResult, type ResolvedReviewGuidelines, type ReviewGuidelinesSource, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_MCP_PROFILE_ENV, SLACK_LISTEN_BUSY_REPLY, SLACK_LISTEN_STOPPED_REPLY, SLACK_LISTEN_TIMEOUT_REPLY, SLACK_OAUTH_CANCELLED, SLACK_OAUTH_LOCAL_CALLBACK, SLACK_OAUTH_PORT, SLACK_OAUTH_REDIRECT, SLACK_REPLY_FORMATTING, SLACK_SEEN_REACTION, type ScriptHandle, type SideboardMcpProfile, type SkillInfo, type SlackInboundMessage, type SlackListenOptions, type SlackListenStatus, SlackOAuthCancelledError, type SlackOutboundReply, type SlackOutboundWatch, type SlackRelayClientMessage, type SlackRelayClientOptions, SlackRelayHub, type SlackRelayServerHandle, type SlackRelayServerMessage, type SlackRelayServerOptions, type SlackReplyBadge, type SlackWorkspaceInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, THINKING_EFFORTS, type TeamName, type ThinkingEffort, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type ToolPartLike, type TranscriptToolDetail, type TurnCommand, type UsageScope, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, ackSlackInboundSeen, addPrStackLayer, addStackLayerFromThread, addWorkspace, adoptThread, agentGitPrompt, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, applyTurnUsage, assertOrchestratorCapableAgent, attachmentFromAbsolutePath, attachmentsFromBuffers, attachmentsFromWorktreePaths, attachmentsGitignoreBody, autoArchiveOnMergeEnabled, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyInjectWorktreeMcpEnabled, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildDiffCommentAttachment, buildForkTranscriptAttachment, buildPastedTextAttachment, buildReviewRequestAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateHoldPath, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, caffeinateWhileSlackListenEnabled, captureLoginEnv, captureTurnBaseline, checkoutPrStackLayer, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, coerceOrchestratorAgent, collectTakenTeamSlugs, commitAll, conductorBundledBinDir, conductorDbPath, confirmLand, connectBrightsyTeam, connectSlackToken, contextTokens, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createExistingBranchWorktree, createGlobalChat, createLinearPkce, createOrUpdatePr, createPrStack, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectGhStack, detectLocalMergeConflicts, disconnectBrightsyTeam, disconnectLinear, disconnectLinearConnection, disconnectSlackWorkspace, discoverSkills, dismissSlackReplyBadge, dropCachedPrefixOnResume, encodeBrightsyTarget, enrichPathWithNpmGlobalBin, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGhPreferOrigin, ensureGlobalCoordinatorCwd, ensureReviewRequestFile, ensureSlackCoordinator, ensureSlackDeviceIdentity, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractPendingPlanQuestions, extractPresentedPlan, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, findThreadForStackLayer, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatArtifactDirective, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatPlanQuestionAnswers, formatPlanQuestionsForChat, formatRateLimitResetHint, formatRenameBranchDirective, formatSlackExternalReplyPrompt, formatSlackInboundPrompt, formatSlackRepliesForTurn, formatSlackSignedReply, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, formatWorktreeReminder, getAdapter, getAgentSetupInfo, getBrightsySession, getCaffeinateHold, getDefaultAgent, getDefaultEffort, getDefaultFast, getDefaultModel, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getLinearAuthToken, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getPrStack, getRepoSetupInfo, getRunMode, getRunScript, getSlackWorkspace, gh, ghHeadRef, ghRepoSelectArgs, git, globalAgentCwd, handleSlackInbound, harnessEnvKey, hasBakedLinearOAuth, hasBakedSlackOAuth, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initPrStack, initStackFromThread, initializeGitRepository, inspectGitWorktree, installAgent, isAskUserToolName, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isConductorBundledCli, isCursorAutoModel, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isImageFilePath, isInPrStack, isInboundForThisDesktop, isLinearConnected, isLinearOAuthCancelled, isOrchestratorCapableAgent, isOrchestratorThread, isPidAlive, isPlaceholderBranch, isPresentPlanToolName, isSessionQuotaLimit, isSideboardScratchPath, isSlackCoordinatorThread, isSlackExternalReplyPrompt, isSlackOAuthCancelled, isThinkingEffort, isWorkspaceScratchPath, linearAuthorizationHeader, linearOAuthAuthorizeUrl, linearOAuthCredentials, listAgentSetupInfo, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listCodexModels, listConductorWorkspaces, listConnectedBrightsyTeams, listCursorModels, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listModelsForAgent, listOpencodeModels, listPrs, listRunScripts, listSlackOutboundWatches, listSlackReplyBadges, listSlackWorkspaces, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, loginAgent, lookupSoccerTeam, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergePrStack, mergeUsage, nextPastedTextName, nextThinkingEffort, normalizeParseResult, normalizeThinkingEffort, normalizeThread, normalizeTurnInput, normalizeWorktreePath, openInSystemTerminal, openPrStackLayers, openStackLayer, opencodeAdapter, orchestrationQuotaFallbackAgent, orchestrationQuotaOnLimit, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, originGhRepoEnv, parseCursorRunnerLine, parseForceStopMessage, parseGhStackViewJson, parseGithubSlugFromRemoteUrl, parseMcpList, parsePlanQuestionsInput, parseSessionQuotaResetAt, parseSlackRelayClientMessage, parseSlackRelayServerMessage, partsToAssistantText, pastedTextStats, pendingSlackExternalReplies, permalinkForSlackReplyBadge, permissionMode, persistVaultKeyInKeychain, planFileAbs, posixShellSingleQuote, prepareTerminalCommand, previewLand, promptMentionsBrightsy, pushBranch, readExistingReviewRequestFile, readKeychainVaultKey, readPlanFile, readSkillBody, readThread, readWorktreeFile, readWorktreeFileForUpload, readWorktreeInclude, recordSlackOutboundWatch, refreshGitHubAuth, refreshSlackReplyBadges, removeWorkspace, removeWorktree, repoSlug, requestOccupancy, requestReview, requireAgent, resetGhStackDetectCache, resolveAgentExecutable, resolveClaudeExecutable, resolveCommandBinarySync, resolveConductorCursorAgentId, resolveCursorModelId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGhAuthToken, resolveGithubRepoSlug, resolveLoginCommand, resolveNewThreadOptions, resolvePlanMarkdown, resolvePrSelector, resolveQuotaFallbackAgent, resolveRepoRoot, resolveReviewGuidelines, resolveSlackListenMode, resolveThreadDefaults, resolveThreadEffort, resolveVaultKey, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, runSlackListen, runSlackRelayClient, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, saveLinearOAuth, secureFileUnlocksWith, setCaffeinateHold, setStatus, setVaultMasterKey, settingsSourceLabel, shouldAttachPastedText, shouldCompactContext, shouldInjectBrightsyMcp, shouldRefreshReviewRequestTemplate, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardMcpProfile, sideboardReposDir, sideboardWorkspacesDir, slackAppLevelToken, slackArchiveUrl, slackCoordinatorSourceRef, slackListenEnabled, slackOAuthCredentials, slackRelayUrl, slugify, spawnAgentTurn, splitForCompaction, stackAgentDefaultsFrom, stackIdFrom, stackMergeReadiness, stageAbsolutePathsAsAttachments, stageBuffersAsAttachments, startDevServer, startLinearOAuth, startMcpServer, startOrchestration, startSlackOAuth, startSlackRelayServer, stripBrightsyNdjsonNoise, submitPrStack, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, thinkingEffortBars, thinkingEffortLabel, threadDisplayLabel, threadFilePath, threadLockPath, threadRequestsBrightsyMcp, threadsDir, threadsSharingWorktree, toPublicAppSettings, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAgentExecutable, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateCodexSettings, updateDefaultsSettings, updateIntegrationsSettings, updateOpencodeSettings, updateThread, validateLinearApiKey, withAgentInstructions, withExportedPath, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writePlanFile, writeThread, writeWorktreeFile };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  listWorkspaces,
5
5
  removeWorkspace,
6
6
  syncWorkspacesFromThreads
7
- } from "./chunk-CYKPUTXN.js";
7
+ } from "./chunk-DG3S2UXP.js";
8
8
  import {
9
9
  BRIGHTSY_MCP_ALLOWED_TOOLS,
10
10
  CLAUDE_MODEL_CATALOG,
@@ -58,7 +58,7 @@ import {
58
58
  sideboardMcpProfile,
59
59
  threadRequestsBrightsyMcp,
60
60
  writeInjectedMcpConfig
61
- } from "./chunk-WSFZPOPH.js";
61
+ } from "./chunk-5KJMNNCB.js";
62
62
  import {
63
63
  CLOUD_COORDINATOR_BUSY_REPLY,
64
64
  CLOUD_COORDINATOR_STOPPED_REPLY,
@@ -85,7 +85,7 @@ import {
85
85
  parseForceStopMessage,
86
86
  slackCoordinatorSourceRef,
87
87
  takenTeamSlugsForOrchestration
88
- } from "./chunk-NF6Y4GTE.js";
88
+ } from "./chunk-77W62MTX.js";
89
89
  import {
90
90
  COORDINATOR_TOOL_PLAYBOOK,
91
91
  SLACK_REPLY_FORMATTING,
@@ -94,7 +94,7 @@ import {
94
94
  enrichWorkspacesWithGithub,
95
95
  ensureGlobalCoordinatorCwd,
96
96
  formatWorkspaceInventory
97
- } from "./chunk-V4ACEJX2.js";
97
+ } from "./chunk-HCWAIEBU.js";
98
98
  import {
99
99
  brightsyConfigPath,
100
100
  brightsyMcpServerName,
@@ -128,7 +128,7 @@ import {
128
128
  parseCursorRunnerLine,
129
129
  pushTurnStderr,
130
130
  summarizeTurnStderr
131
- } from "./chunk-3WJAUKIL.js";
131
+ } from "./chunk-SEOICVGB.js";
132
132
  import {
133
133
  HARNESS_ENV_KEYS,
134
134
  appSettingsPath,
@@ -324,6 +324,31 @@ import {
324
324
  withExportedPath
325
325
  } from "./chunk-D4DPQ552.js";
326
326
 
327
+ // src/git/agent-git-actions.ts
328
+ var AGENT_GIT_ACTIONS = [
329
+ "commit-push",
330
+ "create-draft",
331
+ "create-web",
332
+ "resolve-conflicts",
333
+ "merge"
334
+ ];
335
+ function agentGitPrompt(action, opts) {
336
+ switch (action) {
337
+ case "commit-push":
338
+ return "Commit and push.";
339
+ case "create-draft":
340
+ return "Commit, push, and open a draft PR.";
341
+ case "create-web":
342
+ return "Commit, push, and open a PR in the browser.";
343
+ case "resolve-conflicts": {
344
+ const base = opts?.prBase?.trim().replace(/^refs\/heads\//, "");
345
+ return base ? `Merge origin/${base} into this branch. Then push.` : "Fix merge conflicts.";
346
+ }
347
+ case "merge":
348
+ return "Merge PR.";
349
+ }
350
+ }
351
+
327
352
  // src/integrations/github.ts
328
353
  async function getGitHubStatus() {
329
354
  const which = await run("which", ["gh"], { reject: false });
@@ -1002,17 +1027,35 @@ function sumOptional(a, b) {
1002
1027
  if (a == null && b == null) return void 0;
1003
1028
  return (a ?? 0) + (b ?? 0);
1004
1029
  }
1030
+ function requestOccupancy(u) {
1031
+ return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
1032
+ }
1005
1033
  function mergeUsage(a, b) {
1006
1034
  return {
1007
1035
  inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
1008
1036
  outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
1009
1037
  cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
1010
- cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens)
1038
+ cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
1039
+ lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
1011
1040
  };
1012
1041
  }
1042
+ function applyTurnUsage(current, incoming, scope = "request") {
1043
+ if (scope === "turn") {
1044
+ return {
1045
+ ...incoming,
1046
+ lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
1047
+ };
1048
+ }
1049
+ const merged = mergeUsage(current, incoming);
1050
+ return { ...merged, lastRequestTokens: requestOccupancy(incoming) };
1051
+ }
1013
1052
  function totalTokens(u) {
1014
1053
  return u.inputTokens + u.outputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
1015
1054
  }
1055
+ function contextTokens(u) {
1056
+ if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
1057
+ return requestOccupancy(u);
1058
+ }
1016
1059
 
1017
1060
  // src/agents/spawn.ts
1018
1061
  async function spawnAgentTurn(thread, input, onEvent) {
@@ -1022,9 +1065,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
1022
1065
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
1023
1066
  );
1024
1067
  }
1025
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-S3B6ESZS.js");
1068
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-CSIS62Z4.js");
1026
1069
  if (isGlobalThread2(thread)) {
1027
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-4U2QNHGT.js");
1070
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-3XXSG7M2.js");
1028
1071
  ensureGlobalCoordinatorCwd2(
1029
1072
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
1030
1073
  );
@@ -1086,7 +1129,7 @@ async function spawnAgentTurn(thread, input, onEvent) {
1086
1129
  continue;
1087
1130
  }
1088
1131
  if (parsed.type === "usage") {
1089
- usage = mergeUsage(usage, parsed.data);
1132
+ usage = applyTurnUsage(usage, parsed.data, parsed.scope ?? "request");
1090
1133
  onEvent(parsed);
1091
1134
  continue;
1092
1135
  }
@@ -1141,7 +1184,7 @@ function formatRenameBranchDirective(thread, opts) {
1141
1184
  "- Rename the git branch to a short kebab-case name that describes this task (what you are changing), e.g. `fix/panel-width` or `feat/dark-mode`:",
1142
1185
  " `git branch -m <new-name>`",
1143
1186
  "- Prefer Conventional Commits style prefixes when they fit (`fix/`, `feat/`, `chore/`, `docs/`).",
1144
- "- Never push or merge to main/master from here."
1187
+ "- Never push this placeholder to main/master."
1145
1188
  ];
1146
1189
  const custom = opts?.customPrompt?.trim();
1147
1190
  if (custom) {
@@ -1184,7 +1227,7 @@ function formatWorktreeDirective(thread, opts) {
1184
1227
  "- Prefer a concise imperative title (Conventional Commits style when it fits: feat:/fix:/chore:/docs:). Body should summarize intent, key changes, and test notes."
1185
1228
  );
1186
1229
  lines.push(
1187
- "- Commit with messages that state the purpose of the change (same standard as the PR). Stay on this thread branch; never push or merge to main/master from here."
1230
+ "- Commit with messages that state the purpose of the change (same standard as the PR). Stay on this thread branch. Never push directly to main/master or merge locally into the main checkout. When asked to merge the PR, use GitHub from this worktree (`gh pr merge` / `gh stack merge`)."
1188
1231
  );
1189
1232
  if (thread.prUrl) {
1190
1233
  lines.push(
@@ -1216,13 +1259,13 @@ function formatWorktreeDirective(thread, opts) {
1216
1259
  '- "Fix CI: <name>." \u2192 investigate that failing check, fix it, commit, and push.'
1217
1260
  );
1218
1261
  lines.push(
1219
- '- "Update the branch." / "Fix merge conflicts." \u2192 sync with the PR base (merge or rebase), resolve conflicts carefully, commit, and push until the PR is mergeable.'
1262
+ '- "Update the branch." / "Fix merge conflicts." / "Merge origin/<base> into this branch. Then push." \u2192 sync with the PR base (merge or rebase), resolve conflicts carefully, commit, and push until the PR is mergeable.'
1220
1263
  );
1221
1264
  lines.push(
1222
1265
  '- "Address review comments." \u2192 read PR review feedback, make the requested changes, commit, and push.'
1223
1266
  );
1224
1267
  lines.push(
1225
- '- "Merge PR." \u2192 merge this thread\'s open pull request with `gh pr merge` (respect repo defaults / squash vs merge); do not force-push main/master.'
1268
+ '- "Merge PR." \u2192 merge this thread\'s open pull request on GitHub. If `gh stack view` shows a stack, use `gh stack merge`; otherwise `gh pr merge` (respect repo defaults / squash vs merge). Do not force-push main/master or merge locally into the main checkout.'
1226
1269
  );
1227
1270
  return lines.join("\n");
1228
1271
  }
@@ -2254,10 +2297,10 @@ async function getDiff(worktreePath, repoPath, opts) {
2254
2297
  listBranchCommits(worktreePath, repoPath, { base: baseLabel }),
2255
2298
  isDirty(worktreePath),
2256
2299
  countUnpushedCommits(worktreePath)
2257
- ]).then(([scopeStats, commits, dirty, unpushed]) => ({
2300
+ ]).then(([scopeStats, commits, dirty2, unpushed]) => ({
2258
2301
  scopeStats,
2259
2302
  commits,
2260
- dirty,
2303
+ dirty: dirty2,
2261
2304
  unpushed
2262
2305
  })) : Promise.resolve({
2263
2306
  scopeStats: emptyScopeStats(),
@@ -2334,13 +2377,14 @@ async function getDiff(worktreePath, repoPath, opts) {
2334
2377
  }
2335
2378
  }
2336
2379
  const files = [...filesMap.values()].sort((a, b) => a.path.localeCompare(b.path));
2380
+ const dirty = includeMeta ? meta.dirty : scope === "commits" ? false : files.length > 0;
2337
2381
  return {
2338
2382
  scope,
2339
2383
  commitSha: scope === "commits" ? commitSha : null,
2340
2384
  base: labelBase,
2341
2385
  files,
2342
2386
  stat: formatStat(files),
2343
- dirty: fileOnly || !includeMeta ? files.length > 0 : meta.dirty,
2387
+ dirty,
2344
2388
  unpushed: meta.unpushed,
2345
2389
  hasLastTurnBase,
2346
2390
  commits: meta.commits,
@@ -3501,7 +3545,7 @@ async function createThread(input, _onSetupLine) {
3501
3545
  return readThread(thread.id) ?? thread;
3502
3546
  }
3503
3547
  async function listLinearIssues(agent, repoPath) {
3504
- const { getAdapter: getAdapter2 } = await import("./agents-GUFUYXKP.js");
3548
+ const { getAdapter: getAdapter2 } = await import("./agents-H7M5CQY2.js");
3505
3549
  await requireAgent(agent, { requireLinear: true });
3506
3550
  const adapter = getAdapter2(agent);
3507
3551
  if (!adapter.listLinearIssues) {
@@ -4044,7 +4088,7 @@ async function adoptThread(input) {
4044
4088
  messages: input.messages ?? []
4045
4089
  });
4046
4090
  writeThread(thread);
4047
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-R66324S7.js");
4091
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-W72KZL4B.js");
4048
4092
  await ensureWorkspace2(repoPath);
4049
4093
  return thread;
4050
4094
  }
@@ -6831,6 +6875,36 @@ var Orchestrator = class {
6831
6875
  this.emit({ type: "status_changed", threadId: tab.id, status: tab.status });
6832
6876
  return tab;
6833
6877
  }
6878
+ /**
6879
+ * Queue a desktop-git-button prompt on a worktree agent (commit/push/PR/merge).
6880
+ * Orchestrators use this instead of running git/gh from the synthetic home.
6881
+ */
6882
+ async askGit(threadRef, action) {
6883
+ if (!AGENT_GIT_ACTIONS.includes(action)) {
6884
+ throw new Error(`Unknown git action: ${action}`);
6885
+ }
6886
+ const thread = this.requireThread(threadRef);
6887
+ this.assertNotGlobal(thread, "ask_git");
6888
+ if (isOrchestratorThread(thread)) {
6889
+ throw new Error(
6890
+ "ask_git targets a worktree agent thread (not the orchestrator). Pass a child/worktree thread ref."
6891
+ );
6892
+ }
6893
+ if (action === "merge" && !thread.prUrl) {
6894
+ throw new Error(
6895
+ "No pull request linked. Ask the worktree agent to open a draft PR first (ask_git create-draft)."
6896
+ );
6897
+ }
6898
+ let prBase;
6899
+ if (action === "resolve-conflicts") {
6900
+ try {
6901
+ const details = await this.getPrDetails(threadRef);
6902
+ prBase = details?.baseRefName?.trim() || void 0;
6903
+ } catch {
6904
+ }
6905
+ }
6906
+ return this.send(threadRef, agentGitPrompt(action, { prBase }));
6907
+ }
6834
6908
  setThreadOptions(threadRef, patch) {
6835
6909
  const thread = this.requireThread(threadRef);
6836
6910
  const next = {};
@@ -6925,7 +6999,7 @@ var Orchestrator = class {
6925
6999
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
6926
7000
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
6927
7001
  try {
6928
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-R66324S7.js");
7002
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-W72KZL4B.js");
6929
7003
  await ensureWorkspace2(thread.repoPath);
6930
7004
  } catch {
6931
7005
  }
@@ -8099,7 +8173,7 @@ async function startMcpServer() {
8099
8173
  );
8100
8174
  server.tool(
8101
8175
  "send_to_thread",
8102
- "Queue a prompt on a worktree thread chat (runs under concurrency cap). Use after create_thread to start or continue a conversation. Set force_stop=true to interrupt an in-flight/queued turn (kill + clear queue) before queueing this prompt \u2014 use when the thread is mid-turn or has stale queued prompts you need to replace.",
8176
+ "Queue a prompt on a worktree thread chat (runs under concurrency cap). Use after create_thread to start or continue a conversation. For commit/push/PR/merge, prefer ask_git (canonical desktop-button phrases). Set force_stop=true to interrupt an in-flight/queued turn (kill + clear queue) before queueing this prompt \u2014 use when the thread is mid-turn or has stale queued prompts you need to replace.",
8103
8177
  {
8104
8178
  ref: z2.string(),
8105
8179
  prompt: z2.string(),
@@ -8130,7 +8204,7 @@ async function startMcpServer() {
8130
8204
  );
8131
8205
  server.tool(
8132
8206
  "wait_for_turn",
8133
- "Block until the thread finishes its current/queued turn (avoids polling). Use after send_to_thread to read the agent reply.",
8207
+ "Block until the thread finishes its current/queued turn (avoids polling). Use after send_to_thread or ask_git to read the agent reply.",
8134
8208
  {
8135
8209
  ref: z2.string(),
8136
8210
  timeoutMs: z2.number().optional()
@@ -8195,7 +8269,7 @@ async function startMcpServer() {
8195
8269
  );
8196
8270
  server.tool(
8197
8271
  "archive_thread",
8198
- "Archive a thread (stops agent/dev, runs archive script, removes worktree when last chat tab). Coordinators open PRs only by asking the worktree agent.",
8272
+ "Archive a thread (stops agent/dev, runs archive script, removes worktree when last chat tab). Coordinators commit, push, open PRs, and merge only by asking the worktree agent (ask_git).",
8199
8273
  { ref: z2.string() },
8200
8274
  async ({ ref }) => {
8201
8275
  const t = orch.getThread(ref);
@@ -8301,6 +8375,38 @@ async function startMcpServer() {
8301
8375
  }
8302
8376
  }
8303
8377
  );
8378
+ server.tool(
8379
+ "ask_git",
8380
+ "Tell a worktree agent to commit & push, open a draft PR, resolve conflicts, or merge the linked PR \u2014 same short prompts as the desktop git buttons. The worktree agent runs git/gh (`gh pr merge`); this only queues the prompt. Pass a worktree thread ref (not the orchestrator). Then wait_for_turn / get_turn_result. Do not run git or gh from the orchestration cwd.",
8381
+ {
8382
+ ref: z2.string().describe("Worktree thread id/ref"),
8383
+ action: z2.enum(AGENT_GIT_ACTIONS).describe(
8384
+ "commit-push | create-draft | create-web | resolve-conflicts | merge"
8385
+ )
8386
+ },
8387
+ async ({ ref, action }) => {
8388
+ try {
8389
+ const thread = await orch.askGit(ref, action);
8390
+ return {
8391
+ content: [
8392
+ {
8393
+ type: "text",
8394
+ text: JSON.stringify({
8395
+ id: thread.id,
8396
+ status: thread.status,
8397
+ queueLength: thread.queue.length,
8398
+ action,
8399
+ link: `sideboard://thread/${thread.id}`
8400
+ })
8401
+ }
8402
+ ]
8403
+ };
8404
+ } catch (err) {
8405
+ const message = err instanceof Error ? err.message : String(err);
8406
+ return { content: [{ type: "text", text: message }], isError: true };
8407
+ }
8408
+ }
8409
+ );
8304
8410
  const agentEnum = z2.enum(["claude", "codex", "opencode", "brightsy", "cursor"]);
8305
8411
  server.tool(
8306
8412
  "list_models",
@@ -8572,7 +8678,7 @@ async function startMcpServer() {
8572
8678
  );
8573
8679
  server.tool(
8574
8680
  "get_pr_stack",
8575
- "Load the GitHub PR stack for a thread worktree (`gh stack view --json`). Returns null JSON when the branch is not stacked. Prefer this before mergePr on stacked PRs.",
8681
+ "Load the GitHub PR stack for a thread worktree (`gh stack view --json`). Returns null JSON when the branch is not stacked. Prefer this before ask_git merge on stacked PRs.",
8576
8682
  { ref: z2.string() },
8577
8683
  async ({ ref }) => {
8578
8684
  const stack = await orch.getPrStack(ref);
@@ -10370,6 +10476,7 @@ async function startSlackRelayServer(opts) {
10370
10476
  };
10371
10477
  }
10372
10478
  export {
10479
+ AGENT_GIT_ACTIONS,
10373
10480
  ATTACHMENTS_DIR,
10374
10481
  BAKED_SLACK_RELAY_URL,
10375
10482
  BRIGHTSY_MCP_ALLOWED_TOOLS,
@@ -10428,6 +10535,7 @@ export {
10428
10535
  addStackLayerFromThread,
10429
10536
  addWorkspace,
10430
10537
  adoptThread,
10538
+ agentGitPrompt,
10431
10539
  allAdapters,
10432
10540
  allocatePort,
10433
10541
  allocatePortRange,
@@ -10440,6 +10548,7 @@ export {
10440
10548
  applyAppEnvironment,
10441
10549
  applyCompaction,
10442
10550
  applyThreadIntoMain,
10551
+ applyTurnUsage,
10443
10552
  assertOrchestratorCapableAgent,
10444
10553
  attachmentFromAbsolutePath,
10445
10554
  attachmentsFromBuffers,
@@ -10487,6 +10596,7 @@ export {
10487
10596
  confirmLand,
10488
10597
  connectBrightsyTeam,
10489
10598
  connectSlackToken,
10599
+ contextTokens,
10490
10600
  coordinatorSystemPrompt,
10491
10601
  coordinatorTurnReminder,
10492
10602
  copyConfiguredFiles,
@@ -10730,6 +10840,7 @@ export {
10730
10840
  removeWorkspace,
10731
10841
  removeWorktree,
10732
10842
  repoSlug,
10843
+ requestOccupancy,
10733
10844
  requestReview,
10734
10845
  requireAgent,
10735
10846
  resetGhStackDetectCache,