@sideboard-ai/core 0.1.348 → 0.1.350
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.
- package/dist/{abletime-CGFJZB7L.js → abletime-TX7BTTR2.js} +5 -5
- package/dist/{abletime-3HRWLQZJ.js → abletime-URSRZW7P.js} +4 -4
- package/dist/{abletime-oauth-QNJQLHR4.js → abletime-oauth-QS3WPSCC.js} +3 -3
- package/dist/{abletime-oauth-JQDSH5OL.js → abletime-oauth-SL3NMNEC.js} +4 -4
- package/dist/{abletime-rest-TANL5TMY.js → abletime-rest-GGQLUO55.js} +3 -3
- package/dist/{abletime-rest-UQA2CRZN.js → abletime-rest-JZU6JJCV.js} +4 -4
- package/dist/agents/acp-runner.cjs +491 -0
- package/dist/agents/acp-runner.d.cts +46 -0
- package/dist/agents/acp-runner.d.ts +46 -0
- package/dist/agents/acp-runner.js +323 -0
- package/dist/agents/cursor-runner.js +3 -3
- package/dist/{agents-T4XBZZDA.js → agents-P5QIV24I.js} +38 -8
- package/dist/{agents-5MFGVK7C.js → agents-RGAV5OHD.js} +44 -13
- package/dist/{app-settings-SNOPJ7P5.js → app-settings-IA7ZZKWQ.js} +2 -2
- package/dist/{app-settings-PPIMYJKS.js → app-settings-XILTSD6L.js} +1 -1
- package/dist/{chunk-UGUWFONI.js → chunk-2E2HMJDU.js} +1 -1
- package/dist/{chunk-OH3BAUMC.js → chunk-2MESZ5XR.js} +273 -84
- package/dist/{chunk-RUIHNWRV.js → chunk-37ZBEBP6.js} +6 -6
- package/dist/{chunk-Y6VQX2LY.js → chunk-5AHWUJRT.js} +1927 -1718
- package/dist/{chunk-7B2OUQON.js → chunk-5TCMXEYL.js} +48 -3
- package/dist/{chunk-FDYMVJFU.js → chunk-5WF54R3B.js} +5 -5
- package/dist/{chunk-PVCECFJK.js → chunk-7ZD4OK6G.js} +1 -1
- package/dist/{chunk-RYPD7XWV.js → chunk-B4EFQTMP.js} +5 -5
- package/dist/chunk-BF6INES4.js +144 -0
- package/dist/{chunk-IVRWRYTH.js → chunk-BZK62VPT.js} +2 -2
- package/dist/{chunk-AJMERXZP.js → chunk-CCWQ65VD.js} +2 -2
- package/dist/{chunk-62ALWH3T.js → chunk-DL4OHDBV.js} +3 -3
- package/dist/{chunk-6TV6L2DD.js → chunk-EZ2MUWNW.js} +7 -6
- package/dist/{chunk-4NXGVJA6.js → chunk-F4RFFE2H.js} +48 -3
- package/dist/{chunk-E77SRVVO.js → chunk-FCKTBE26.js} +1 -1
- package/dist/{chunk-NTY5WGRD.js → chunk-FQ3JYUKI.js} +2 -2
- package/dist/{chunk-CEQ4Z32M.js → chunk-J4EA5SHF.js} +3 -3
- package/dist/{chunk-ORO4ENZR.js → chunk-LESWJ7L4.js} +1 -0
- package/dist/{chunk-XNGW4OYD.js → chunk-LFSTOECH.js} +7 -6
- package/dist/{chunk-OHUAAX3O.js → chunk-M45WGODR.js} +2 -2
- package/dist/{chunk-ZJMYCDYQ.js → chunk-MANERA6F.js} +55 -10
- package/dist/{chunk-Q4TZA4MN.js → chunk-NDEVAA34.js} +1629 -1486
- package/dist/{chunk-OPXEJJBM.js → chunk-PWOFUPYM.js} +1 -0
- package/dist/{chunk-UJMCTGV7.js → chunk-PXSWVZIL.js} +2 -2
- package/dist/{chunk-MOUAM6ZC.js → chunk-SMSD6U3N.js} +135 -3
- package/dist/{chunk-ATS7SYHG.js → chunk-TCEUNSLX.js} +135 -3
- package/dist/chunk-TRMPDDVL.js +232 -0
- package/dist/{chunk-6WMNIX2U.js → chunk-UFUAIVNV.js} +9 -5
- package/dist/{chunk-2HPVGTHF.js → chunk-VHQ6OG3U.js} +2 -2
- package/dist/{chunk-WWU4SYZR.js → chunk-VL6F2KRE.js} +5 -1
- package/dist/{chunk-WMD77UCY.js → chunk-W5GHFT7E.js} +279 -87
- package/dist/{chunk-5FUAOU3G.js → chunk-WB3G2LQO.js} +1 -1
- package/dist/{chunk-JCYGQKER.js → chunk-WFX4ZVSZ.js} +1 -1
- package/dist/{chunk-F7WP2U5I.js → chunk-WJURGCBR.js} +1 -1
- package/dist/{chunk-BIM24I3O.js → chunk-WWBPK7GB.js} +1 -1
- package/dist/chunk-YE7Z5WH3.js +142 -0
- package/dist/{chunk-5YCKATG6.js → chunk-YVN7L4KG.js} +1 -1
- package/dist/{chunk-GAGTEI6B.js → chunk-ZBSEJIOV.js} +56 -11
- package/dist/{conductor-LYQKONSA.js → conductor-HVOGBK63.js} +7 -6
- package/dist/{conductor-EMGMDNHL.js → conductor-VGCXUUG6.js} +9 -8
- package/dist/connected-teams-2YDE2EZ2.js +1 -1
- package/dist/{coordinator-prompt-DLY3FS2L.js → coordinator-prompt-DPO7L2JO.js} +5 -5
- package/dist/{coordinator-prompt-WALVMGKI.js → coordinator-prompt-E736TJBS.js} +4 -4
- package/dist/{global-workspace-UG2A3CEM.js → global-workspace-4RDPAOTT.js} +5 -5
- package/dist/{global-workspace-7OQ5O6JT.js → global-workspace-TG2TVLUF.js} +4 -4
- package/dist/index.cjs +2881 -1761
- package/dist/index.d.cts +140 -877
- package/dist/index.d.ts +140 -877
- package/dist/index.js +865 -559
- package/dist/{linear-PKYJH4WK.js → linear-E3BX5PX5.js} +2 -2
- package/dist/{linear-MIJO6DCV.js → linear-WG23LBCX.js} +3 -3
- package/dist/{linear-list-JPQ27RXG.js → linear-list-OINZWVV5.js} +1 -1
- package/dist/{linear-list-N57PR6JM.js → linear-list-VU47BNUV.js} +1 -1
- package/dist/mcp/run-stdio.cjs +2112 -1287
- package/dist/mcp/run-stdio.js +318 -230
- package/dist/{optional-cli-4GTEDEYJ.js → optional-cli-K6HX2X5O.js} +4 -3
- package/dist/{optional-cli-RPJIQBDX.js → optional-cli-SA3EQYML.js} +6 -5
- package/dist/{orchestrator-KNOMW5CZ.js → orchestrator-3I2FLEZL.js} +20 -18
- package/dist/{orchestrator-4SXTORD2.js → orchestrator-QDHZ56LA.js} +12 -11
- package/dist/thread-CJRchYLj.d.cts +856 -0
- package/dist/thread-CJRchYLj.d.ts +856 -0
- package/dist/{thread-store-R3G5VBII.js → thread-store-4YTOV2HL.js} +3 -3
- package/dist/{thread-store-MEUWZDVV.js → thread-store-LME2ICZP.js} +2 -2
- package/dist/{workspaces-KWGTP7DI.js → workspaces-4PA24IX6.js} +4 -4
- package/dist/{workspaces-35T6FW57.js → workspaces-6TMYV4N2.js} +5 -5
- package/dist/{worktree-ROJXGBWS.js → worktree-4ATMCYIE.js} +3 -3
- package/dist/{worktree-5P7SCST3.js → worktree-DA6SKIU5.js} +4 -4
- package/package.json +3 -3
- /package/dist/{chunk-XOEKCE6L.js → chunk-OHXNGBC4.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -17,13 +17,16 @@ import {
|
|
|
17
17
|
toAbleTimeIssueInfo,
|
|
18
18
|
updateAbleTimeTask,
|
|
19
19
|
verifyAbleTimeConnection
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-37ZBEBP6.js";
|
|
21
|
+
import {
|
|
22
|
+
looksLikeAbleTimeUlid
|
|
23
|
+
} from "./chunk-CCWQ65VD.js";
|
|
21
24
|
import {
|
|
22
25
|
clearOptionalCliPresenceCache,
|
|
23
26
|
detectOptionalServiceClis,
|
|
24
27
|
installOptionalServiceCli,
|
|
25
28
|
optionalCliPresence
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-PXSWVZIL.js";
|
|
27
30
|
import {
|
|
28
31
|
AGENT_GIT_ACTIONS,
|
|
29
32
|
BOARD_COLUMN_DEFS,
|
|
@@ -222,7 +225,7 @@ import {
|
|
|
222
225
|
worktreeCleanupSettings,
|
|
223
226
|
writeAgentBlock,
|
|
224
227
|
writeWorktreeFile
|
|
225
|
-
} from "./chunk-
|
|
228
|
+
} from "./chunk-W5GHFT7E.js";
|
|
226
229
|
import {
|
|
227
230
|
OPTIONAL_SERVICES,
|
|
228
231
|
OPTIONAL_SERVICE_IDS,
|
|
@@ -238,7 +241,7 @@ import {
|
|
|
238
241
|
optionalServiceConnected,
|
|
239
242
|
optionalServiceSpec,
|
|
240
243
|
verifyOptionalService
|
|
241
|
-
} from "./chunk-
|
|
244
|
+
} from "./chunk-BZK62VPT.js";
|
|
242
245
|
import {
|
|
243
246
|
LEGACY_PLAN_FILE_REL,
|
|
244
247
|
PLAN_FILE_NAME,
|
|
@@ -295,7 +298,7 @@ import {
|
|
|
295
298
|
startLinearOAuth,
|
|
296
299
|
updateLinearIssue,
|
|
297
300
|
validateLinearApiKey
|
|
298
|
-
} from "./chunk-
|
|
301
|
+
} from "./chunk-7ZD4OK6G.js";
|
|
299
302
|
import {
|
|
300
303
|
downloadAuthenticatedFile,
|
|
301
304
|
extractHttpUrls,
|
|
@@ -322,6 +325,9 @@ import {
|
|
|
322
325
|
WORKTREE_GITHUB_MCP_TOOLS,
|
|
323
326
|
WORKTREE_LINEAR_MCP_TOOLS,
|
|
324
327
|
WORKTREE_MCP_TOOLS,
|
|
328
|
+
acpAdapter,
|
|
329
|
+
acpHarnessDisplayName,
|
|
330
|
+
acpRunnerPath,
|
|
325
331
|
allAdapters,
|
|
326
332
|
brightsyAdapter,
|
|
327
333
|
brightsyMcpAllowedTools,
|
|
@@ -383,7 +389,7 @@ import {
|
|
|
383
389
|
userMcpNamesToDisable,
|
|
384
390
|
worktreeMcpToolNames,
|
|
385
391
|
writeInjectedMcpConfig
|
|
386
|
-
} from "./chunk-
|
|
392
|
+
} from "./chunk-NDEVAA34.js";
|
|
387
393
|
import {
|
|
388
394
|
getAgentSetupInfo,
|
|
389
395
|
installAgent,
|
|
@@ -395,7 +401,7 @@ import {
|
|
|
395
401
|
prepareTerminalCommand,
|
|
396
402
|
resolveLoginCommand,
|
|
397
403
|
whichOnPath
|
|
398
|
-
} from "./chunk-
|
|
404
|
+
} from "./chunk-F4RFFE2H.js";
|
|
399
405
|
import {
|
|
400
406
|
brightsyMcpServerName,
|
|
401
407
|
connectBrightsyTeam,
|
|
@@ -405,8 +411,21 @@ import {
|
|
|
405
411
|
listBrightsyAccounts,
|
|
406
412
|
listConnectedBrightsyTeams,
|
|
407
413
|
switchBrightsyAccount
|
|
408
|
-
} from "./chunk-
|
|
409
|
-
import
|
|
414
|
+
} from "./chunk-OHXNGBC4.js";
|
|
415
|
+
import {
|
|
416
|
+
BRIGHTSY_OAUTH_CLIENT_ID,
|
|
417
|
+
BRIGHTSY_OAUTH_REDIRECT,
|
|
418
|
+
brightsyAccessTokenNeedsRefresh,
|
|
419
|
+
brightsyConfigPath,
|
|
420
|
+
ensureBrightsyLocalConfigFresh,
|
|
421
|
+
ensureBrightsyOAuthClientId,
|
|
422
|
+
loadBrightsyConfig,
|
|
423
|
+
normalizeBrightsyEndpoint,
|
|
424
|
+
refreshBrightsyAccessToken,
|
|
425
|
+
registerBrightsyOAuthClient,
|
|
426
|
+
saveBrightsyConfig
|
|
427
|
+
} from "./chunk-RSA47QYR.js";
|
|
428
|
+
import "./chunk-WB3G2LQO.js";
|
|
410
429
|
import {
|
|
411
430
|
BRIGHTSY_SUMMARIZE_CONTEXT_TOOL,
|
|
412
431
|
CHARS_PER_CONTEXT_TOKEN,
|
|
@@ -442,6 +461,7 @@ import {
|
|
|
442
461
|
buildWorkspaceScriptEnv,
|
|
443
462
|
canReuseIdleWorktreeAgentForReview,
|
|
444
463
|
captureLoginEnv,
|
|
464
|
+
classifyTurnFailure,
|
|
445
465
|
compactArchiveProse,
|
|
446
466
|
copyConfiguredFiles,
|
|
447
467
|
createChatTab,
|
|
@@ -517,7 +537,7 @@ import {
|
|
|
517
537
|
workspaceAgentChatSummaries,
|
|
518
538
|
worktreeRunPortsPath,
|
|
519
539
|
wrapReviewSkillMarkdown
|
|
520
|
-
} from "./chunk-
|
|
540
|
+
} from "./chunk-ZBSEJIOV.js";
|
|
521
541
|
import {
|
|
522
542
|
STDERR_EVENT_MAX_CHARS,
|
|
523
543
|
STDOUT_EVENT_MAX_CHARS,
|
|
@@ -559,7 +579,20 @@ import {
|
|
|
559
579
|
visibleToolRowDetail,
|
|
560
580
|
withEventParentId,
|
|
561
581
|
withEventsParentId
|
|
562
|
-
} from "./chunk-
|
|
582
|
+
} from "./chunk-WWBPK7GB.js";
|
|
583
|
+
import {
|
|
584
|
+
ACP_HARNESSES,
|
|
585
|
+
ACP_HARNESS_IDS,
|
|
586
|
+
acpHarnessLabel,
|
|
587
|
+
acpHarnessLooksAuthenticated,
|
|
588
|
+
acpHarnessStatus,
|
|
589
|
+
agentSupportsAttach,
|
|
590
|
+
defaultAcpHarness,
|
|
591
|
+
detectAcpHarness,
|
|
592
|
+
detectAcpHarnesses,
|
|
593
|
+
isAcpHarnessId,
|
|
594
|
+
resolveAcpHarnessCommand
|
|
595
|
+
} from "./chunk-YE7Z5WH3.js";
|
|
563
596
|
import "./chunk-7H655NEW.js";
|
|
564
597
|
import {
|
|
565
598
|
ABLETIME_OAUTH_CALLBACK_PATH,
|
|
@@ -583,10 +616,7 @@ import {
|
|
|
583
616
|
parseAbleTimeOAuthCallbackUrl,
|
|
584
617
|
resolveAbleTimeOAuthHost,
|
|
585
618
|
startAbleTimeOAuth
|
|
586
|
-
} from "./chunk-
|
|
587
|
-
import {
|
|
588
|
-
looksLikeAbleTimeUlid
|
|
589
|
-
} from "./chunk-AJMERXZP.js";
|
|
619
|
+
} from "./chunk-J4EA5SHF.js";
|
|
590
620
|
import {
|
|
591
621
|
ABLETIME_MCP_PATH,
|
|
592
622
|
ABLETIME_MCP_PM_PATH,
|
|
@@ -607,7 +637,20 @@ import {
|
|
|
607
637
|
normalizeAbleTimeCredential,
|
|
608
638
|
normalizeAbleTimeHost,
|
|
609
639
|
rewriteAbleTimeError
|
|
610
|
-
} from "./chunk-
|
|
640
|
+
} from "./chunk-5WF54R3B.js";
|
|
641
|
+
import {
|
|
642
|
+
currentHttpFetch,
|
|
643
|
+
formatFetchError,
|
|
644
|
+
httpFetch,
|
|
645
|
+
setHttpFetchImpl
|
|
646
|
+
} from "./chunk-JAT3JFOS.js";
|
|
647
|
+
import {
|
|
648
|
+
caffeinateHoldPath,
|
|
649
|
+
getCaffeinateHold,
|
|
650
|
+
isThreadCaffeinated,
|
|
651
|
+
releaseCaffeinateHoldForThread,
|
|
652
|
+
setCaffeinateHold
|
|
653
|
+
} from "./chunk-LAWLUOWQ.js";
|
|
611
654
|
import {
|
|
612
655
|
CLOUD_COORDINATOR_BUSY_REPLY,
|
|
613
656
|
CLOUD_COORDINATOR_CANCELED_REPLY,
|
|
@@ -660,7 +703,7 @@ import {
|
|
|
660
703
|
stageBuffersAsAttachments,
|
|
661
704
|
syncWorkspacesFromThreads,
|
|
662
705
|
takenTeamSlugsForOrchestration
|
|
663
|
-
} from "./chunk-
|
|
706
|
+
} from "./chunk-LFSTOECH.js";
|
|
664
707
|
import {
|
|
665
708
|
GITHUB_PR_BODY_MAX_CHARS,
|
|
666
709
|
GITHUB_PR_BODY_SAFE_CHARS,
|
|
@@ -750,14 +793,16 @@ import {
|
|
|
750
793
|
suggestSlug,
|
|
751
794
|
switchWorktreeBranch,
|
|
752
795
|
warmGithubAgentAuth
|
|
753
|
-
} from "./chunk-
|
|
796
|
+
} from "./chunk-FQ3JYUKI.js";
|
|
754
797
|
import {
|
|
755
798
|
FAMOUS_SOCCER_TEAMS,
|
|
756
799
|
SCHEDULE_RUN_HISTORY_LIMIT,
|
|
757
800
|
WEEKDAY_LABELS,
|
|
801
|
+
addChatFollowUp,
|
|
758
802
|
allocateTeamName,
|
|
759
803
|
appendMessage,
|
|
760
804
|
branchDisplayLabel,
|
|
805
|
+
ciChecksSettled,
|
|
761
806
|
computeNextRunAt,
|
|
762
807
|
createEmptyThread,
|
|
763
808
|
createSchedule,
|
|
@@ -778,6 +823,7 @@ import {
|
|
|
778
823
|
listSchedules,
|
|
779
824
|
listThreads,
|
|
780
825
|
lookupSoccerTeam,
|
|
826
|
+
normalizeChatFollowUps,
|
|
781
827
|
normalizeThread,
|
|
782
828
|
normalizeWeekdays,
|
|
783
829
|
normalizeWeeklyTime,
|
|
@@ -807,27 +853,9 @@ import {
|
|
|
807
853
|
worktreeNameFromPath,
|
|
808
854
|
worktreeSlugForTicket,
|
|
809
855
|
writeThread
|
|
810
|
-
} from "./chunk-
|
|
856
|
+
} from "./chunk-TCEUNSLX.js";
|
|
811
857
|
import "./chunk-BMRJNRQK.js";
|
|
812
|
-
import
|
|
813
|
-
BRIGHTSY_OAUTH_CLIENT_ID,
|
|
814
|
-
BRIGHTSY_OAUTH_REDIRECT,
|
|
815
|
-
brightsyAccessTokenNeedsRefresh,
|
|
816
|
-
brightsyConfigPath,
|
|
817
|
-
ensureBrightsyLocalConfigFresh,
|
|
818
|
-
ensureBrightsyOAuthClientId,
|
|
819
|
-
loadBrightsyConfig,
|
|
820
|
-
normalizeBrightsyEndpoint,
|
|
821
|
-
refreshBrightsyAccessToken,
|
|
822
|
-
registerBrightsyOAuthClient,
|
|
823
|
-
saveBrightsyConfig
|
|
824
|
-
} from "./chunk-RSA47QYR.js";
|
|
825
|
-
import {
|
|
826
|
-
currentHttpFetch,
|
|
827
|
-
formatFetchError,
|
|
828
|
-
httpFetch,
|
|
829
|
-
setHttpFetchImpl
|
|
830
|
-
} from "./chunk-JAT3JFOS.js";
|
|
858
|
+
import "./chunk-TRMPDDVL.js";
|
|
831
859
|
import {
|
|
832
860
|
PLAN_QUESTION_ANSWERS_PREFIX,
|
|
833
861
|
askBlockStillWaiting,
|
|
@@ -858,7 +886,7 @@ import {
|
|
|
858
886
|
import {
|
|
859
887
|
clipMcpToolResult,
|
|
860
888
|
cursorToolErrorText
|
|
861
|
-
} from "./chunk-
|
|
889
|
+
} from "./chunk-YVN7L4KG.js";
|
|
862
890
|
import "./chunk-AXQ4ZWHK.js";
|
|
863
891
|
import {
|
|
864
892
|
AGENT_RUNNER_MAX_OLD_SPACE_MB,
|
|
@@ -876,8 +904,8 @@ import {
|
|
|
876
904
|
trustSystemCertificates,
|
|
877
905
|
turnCostUsdFromCursorUsage,
|
|
878
906
|
withMaxOldSpaceSize
|
|
879
|
-
} from "./chunk-
|
|
880
|
-
import "./chunk-
|
|
907
|
+
} from "./chunk-2E2HMJDU.js";
|
|
908
|
+
import "./chunk-PWOFUPYM.js";
|
|
881
909
|
import {
|
|
882
910
|
ATTACHMENTS_DIR,
|
|
883
911
|
CLI_DIR,
|
|
@@ -1100,7 +1128,10 @@ import {
|
|
|
1100
1128
|
withTurnScopedCost,
|
|
1101
1129
|
writeSecureJson,
|
|
1102
1130
|
writeViewerContext
|
|
1103
|
-
} from "./chunk-
|
|
1131
|
+
} from "./chunk-UFUAIVNV.js";
|
|
1132
|
+
import {
|
|
1133
|
+
writePrivateFile
|
|
1134
|
+
} from "./chunk-JT7R45JB.js";
|
|
1104
1135
|
import {
|
|
1105
1136
|
stripNestedElectronEnv
|
|
1106
1137
|
} from "./chunk-4TR3HZFT.js";
|
|
@@ -1128,16 +1159,6 @@ import {
|
|
|
1128
1159
|
withRemovedAccount,
|
|
1129
1160
|
withSelectedAccount
|
|
1130
1161
|
} from "./chunk-KI45T4DI.js";
|
|
1131
|
-
import {
|
|
1132
|
-
caffeinateHoldPath,
|
|
1133
|
-
getCaffeinateHold,
|
|
1134
|
-
isThreadCaffeinated,
|
|
1135
|
-
releaseCaffeinateHoldForThread,
|
|
1136
|
-
setCaffeinateHold
|
|
1137
|
-
} from "./chunk-LAWLUOWQ.js";
|
|
1138
|
-
import {
|
|
1139
|
-
writePrivateFile
|
|
1140
|
-
} from "./chunk-JT7R45JB.js";
|
|
1141
1162
|
import {
|
|
1142
1163
|
CONVENTION_SETUP_RELPATHS,
|
|
1143
1164
|
activeRunPreview,
|
|
@@ -1397,16 +1418,16 @@ function concat(parts) {
|
|
|
1397
1418
|
}
|
|
1398
1419
|
return out;
|
|
1399
1420
|
}
|
|
1400
|
-
function utf8(
|
|
1401
|
-
return new TextEncoder().encode(
|
|
1421
|
+
function utf8(text6) {
|
|
1422
|
+
return new TextEncoder().encode(text6);
|
|
1402
1423
|
}
|
|
1403
1424
|
function bytesToB64url(bytes) {
|
|
1404
1425
|
let binary = "";
|
|
1405
1426
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
1406
1427
|
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
1407
1428
|
}
|
|
1408
|
-
function b64urlToBytes(
|
|
1409
|
-
const padded =
|
|
1429
|
+
function b64urlToBytes(text6) {
|
|
1430
|
+
const padded = text6.replaceAll("-", "+").replaceAll("_", "/") + "=".repeat((4 - text6.length % 4) % 4);
|
|
1410
1431
|
const binary = atob(padded);
|
|
1411
1432
|
const out = new Uint8Array(binary.length);
|
|
1412
1433
|
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
@@ -1597,18 +1618,18 @@ function lastVisibleMessage(messages) {
|
|
|
1597
1618
|
const m = messages[i];
|
|
1598
1619
|
if (!m) continue;
|
|
1599
1620
|
if (m.role === "agent") {
|
|
1600
|
-
const
|
|
1601
|
-
if (
|
|
1621
|
+
const text6 = (lastAssistantMessageText(m.parts) || m.text || "").trim();
|
|
1622
|
+
if (text6 && !isInternalAgentStatusText(text6)) return m;
|
|
1602
1623
|
continue;
|
|
1603
1624
|
}
|
|
1604
1625
|
if (m.role === "user" && m.text?.trim()) return m;
|
|
1605
1626
|
}
|
|
1606
1627
|
return void 0;
|
|
1607
1628
|
}
|
|
1608
|
-
function agentStub(source,
|
|
1629
|
+
function agentStub(source, text6, usage) {
|
|
1609
1630
|
return {
|
|
1610
1631
|
role: "agent",
|
|
1611
|
-
text:
|
|
1632
|
+
text: text6,
|
|
1612
1633
|
ts: source.ts,
|
|
1613
1634
|
...usage ? { usage } : {}
|
|
1614
1635
|
};
|
|
@@ -2668,11 +2689,11 @@ function fenceLanguage(path2, language) {
|
|
|
2668
2689
|
}
|
|
2669
2690
|
function buildCodeRefAttachment(input) {
|
|
2670
2691
|
const path2 = input.path.trim();
|
|
2671
|
-
const
|
|
2692
|
+
const text6 = input.text.replace(/\n$/, "");
|
|
2672
2693
|
if (!path2) {
|
|
2673
2694
|
throw new Error("code reference requires a file path");
|
|
2674
2695
|
}
|
|
2675
|
-
if (!
|
|
2696
|
+
if (!text6.trim()) {
|
|
2676
2697
|
throw new Error("code reference requires selected text");
|
|
2677
2698
|
}
|
|
2678
2699
|
if (input.startLine < 1 || input.endLine < 1 || input.endLine < input.startLine) {
|
|
@@ -2685,7 +2706,7 @@ function buildCodeRefAttachment(input) {
|
|
|
2685
2706
|
`Referenced code from \`${path2}\` (${range}).`,
|
|
2686
2707
|
"",
|
|
2687
2708
|
fence,
|
|
2688
|
-
|
|
2709
|
+
text6,
|
|
2689
2710
|
"```"
|
|
2690
2711
|
].join("\n");
|
|
2691
2712
|
return {
|
|
@@ -2833,9 +2854,9 @@ function isArtifactTool(name) {
|
|
|
2833
2854
|
const short = name.split("__").pop() ?? name;
|
|
2834
2855
|
return /^(present_artifact|create_artifact|update_artifact)$/i.test(short);
|
|
2835
2856
|
}
|
|
2836
|
-
function phoneArtifactText(
|
|
2857
|
+
function phoneArtifactText(text6, parts, limit = Number.POSITIVE_INFINITY) {
|
|
2837
2858
|
const hints = /* @__PURE__ */ new Set();
|
|
2838
|
-
const body =
|
|
2859
|
+
const body = text6.replace(new RegExp(FENCE_RE.source, "g"), (full, language, content) => {
|
|
2839
2860
|
const kind = kindFor(language, content);
|
|
2840
2861
|
if (!kind) return full;
|
|
2841
2862
|
const hint = artifactHint(content);
|
|
@@ -3089,11 +3110,11 @@ function parsePhoneCodeRefs(value) {
|
|
|
3089
3110
|
const startLine = lineNumber(item, "startLine");
|
|
3090
3111
|
const endLine = lineNumber(item, "endLine");
|
|
3091
3112
|
const textRaw = item.text;
|
|
3092
|
-
const
|
|
3093
|
-
if (!path2 || !startLine || !endLine || endLine < startLine || !
|
|
3094
|
-
total +=
|
|
3113
|
+
const text6 = typeof textRaw === "string" ? textRaw.replace(/\n$/, "").slice(0, MAX_TEXT) : "";
|
|
3114
|
+
if (!path2 || !startLine || !endLine || endLine < startLine || !text6.trim()) return "invalid";
|
|
3115
|
+
total += text6.length;
|
|
3095
3116
|
if (total > MAX_TOTAL) return "invalid";
|
|
3096
|
-
refs.push({ path: path2, startLine, endLine, text:
|
|
3117
|
+
refs.push({ path: path2, startLine, endLine, text: text6 });
|
|
3097
3118
|
}
|
|
3098
3119
|
return refs;
|
|
3099
3120
|
}
|
|
@@ -3253,9 +3274,9 @@ async function getGitHubStatus() {
|
|
|
3253
3274
|
};
|
|
3254
3275
|
}
|
|
3255
3276
|
const status = await run("gh", ["auth", "status"], { reject: false });
|
|
3256
|
-
const
|
|
3277
|
+
const text6 = `${status.stdout}
|
|
3257
3278
|
${status.stderr}`;
|
|
3258
|
-
const loginMatch =
|
|
3279
|
+
const loginMatch = text6.match(/Logged in to ([^\s]+) account (\S+)/i) ?? text6.match(/Logged in to ([^\s]+) as (\S+)/i);
|
|
3259
3280
|
if (loginMatch) {
|
|
3260
3281
|
return {
|
|
3261
3282
|
connected: true,
|
|
@@ -3327,9 +3348,9 @@ function parsePhoneMcpUi(value, op, chatId) {
|
|
|
3327
3348
|
}
|
|
3328
3349
|
if (op === "mcp-ui-context") {
|
|
3329
3350
|
const reqId2 = controlText(value, "reqId");
|
|
3330
|
-
const
|
|
3331
|
-
if (!reqId2 || reqId2.length > 40 || !
|
|
3332
|
-
return { op, chatId, reqId: reqId2, text:
|
|
3351
|
+
const text6 = controlText(value, "text");
|
|
3352
|
+
if (!reqId2 || reqId2.length > 40 || !text6 || text6.length > 8e3) return "invalid";
|
|
3353
|
+
return { op, chatId, reqId: reqId2, text: text6 };
|
|
3333
3354
|
}
|
|
3334
3355
|
if (op !== "mcp-ui-call" && op !== "mcp-ui-read") return "invalid";
|
|
3335
3356
|
const reqId = controlText(value, "reqId");
|
|
@@ -3393,30 +3414,30 @@ var PHONE_USER_PREFIX = "Phone\n\n";
|
|
|
3393
3414
|
var TRANSCRIPT_LIMIT = 40;
|
|
3394
3415
|
var MESSAGE_LIMIT = 4e3;
|
|
3395
3416
|
var CRASH_CONTINUE_PREFIX = "The previous agent process ended before it finished.";
|
|
3396
|
-
function isHostContinuePrompt(
|
|
3397
|
-
const trimmed =
|
|
3417
|
+
function isHostContinuePrompt(text6) {
|
|
3418
|
+
const trimmed = text6.trim();
|
|
3398
3419
|
return isJobContinuePrompt(trimmed) || trimmed.startsWith(CRASH_CONTINUE_PREFIX);
|
|
3399
3420
|
}
|
|
3400
|
-
function phoneVisibleText(role,
|
|
3401
|
-
const trimmed =
|
|
3421
|
+
function phoneVisibleText(role, text6) {
|
|
3422
|
+
const trimmed = text6.trim();
|
|
3402
3423
|
if (role === "user" && trimmed.startsWith(PHONE_USER_PREFIX)) {
|
|
3403
3424
|
return trimmed.slice(PHONE_USER_PREFIX.length).trim();
|
|
3404
3425
|
}
|
|
3405
3426
|
return trimmed;
|
|
3406
3427
|
}
|
|
3407
|
-
function clip(
|
|
3408
|
-
if (
|
|
3409
|
-
return `${
|
|
3428
|
+
function clip(text6, limit) {
|
|
3429
|
+
if (text6.length <= limit) return text6;
|
|
3430
|
+
return `${text6.slice(0, limit - 1)}\u2026`;
|
|
3410
3431
|
}
|
|
3411
3432
|
function withLiveTail(thread, messages) {
|
|
3412
3433
|
if (thread.status !== "running" && thread.status !== "queued") return messages;
|
|
3413
|
-
const
|
|
3414
|
-
if (!
|
|
3434
|
+
const text6 = clip(phoneStreamFrame(readTurnLiveParts(thread.id)).text.trim(), MESSAGE_LIMIT);
|
|
3435
|
+
if (!text6) return messages;
|
|
3415
3436
|
const last = messages[messages.length - 1];
|
|
3416
|
-
if (last?.role === "agent" && last.text ===
|
|
3437
|
+
if (last?.role === "agent" && last.text === text6) {
|
|
3417
3438
|
return last.streaming ? messages : [...messages.slice(0, -1), { ...last, streaming: true }];
|
|
3418
3439
|
}
|
|
3419
|
-
return [...messages, { role: "agent", text:
|
|
3440
|
+
return [...messages, { role: "agent", text: text6, streaming: true }];
|
|
3420
3441
|
}
|
|
3421
3442
|
function listPhoneMessages(thread) {
|
|
3422
3443
|
const out = [];
|
|
@@ -3427,16 +3448,16 @@ function listPhoneMessages(thread) {
|
|
|
3427
3448
|
}
|
|
3428
3449
|
const names = (message.attachments ?? []).map((item) => item.name.trim()).filter(Boolean);
|
|
3429
3450
|
const visible = [phoneVisibleText(message.role, message.text), names.length ? names.join(", ") : ""].filter(Boolean).join("\n");
|
|
3430
|
-
const
|
|
3451
|
+
const text6 = message.role === "agent" ? phoneArtifactText(visible, message.parts, MESSAGE_LIMIT) : clip(visible, MESSAGE_LIMIT);
|
|
3431
3452
|
const apps = message.role === "agent" ? phoneMcpApps(thread.agent, message.parts) : [];
|
|
3432
|
-
if (!
|
|
3433
|
-
out.push({ role: message.role, text:
|
|
3453
|
+
if (!text6 && apps.length === 0) continue;
|
|
3454
|
+
out.push({ role: message.role, text: text6, ...apps.length ? { apps } : {} });
|
|
3434
3455
|
}
|
|
3435
3456
|
const live = withLiveTail(thread, out);
|
|
3436
3457
|
for (const prompt of thread.queue) {
|
|
3437
3458
|
if (isHostContinuePrompt(prompt)) continue;
|
|
3438
|
-
const
|
|
3439
|
-
if (
|
|
3459
|
+
const text6 = clip(phoneVisibleText("user", prompt), MESSAGE_LIMIT);
|
|
3460
|
+
if (text6) live.push({ role: "user", text: text6 });
|
|
3440
3461
|
}
|
|
3441
3462
|
return live.slice(-TRANSCRIPT_LIMIT);
|
|
3442
3463
|
}
|
|
@@ -3476,11 +3497,12 @@ function listPhoneHistory(opts) {
|
|
|
3476
3497
|
updatedAt: historyStamp(thread),
|
|
3477
3498
|
where: isGlobalThread(thread) ? "Orchestration" : repoName(thread.repoPath),
|
|
3478
3499
|
agent: thread.agent,
|
|
3500
|
+
...thread.agent === "acp" ? { acpHarness: thread.acpHarness === "copilot" ? "copilot" : "gemini" } : {},
|
|
3479
3501
|
...workspace ? { workspace } : {}
|
|
3480
3502
|
};
|
|
3481
3503
|
}).filter((chat) => {
|
|
3482
3504
|
if (!query) return true;
|
|
3483
|
-
return `${chat.title} ${chat.where} ${chat.agent} ${chat.workspace ?? ""} ${chat.preview}`.toLowerCase().includes(query);
|
|
3505
|
+
return `${chat.title} ${chat.where} ${chat.agent} ${chat.acpHarness ?? ""} ${chat.workspace ?? ""} ${chat.preview}`.toLowerCase().includes(query);
|
|
3484
3506
|
});
|
|
3485
3507
|
let start = 0;
|
|
3486
3508
|
if (after) {
|
|
@@ -3497,10 +3519,116 @@ function listPhoneHistory(opts) {
|
|
|
3497
3519
|
};
|
|
3498
3520
|
}
|
|
3499
3521
|
|
|
3522
|
+
// src/remote/phone-create.ts
|
|
3523
|
+
function phoneAcpHarness(agent, raw) {
|
|
3524
|
+
if (agent !== "acp") return null;
|
|
3525
|
+
if (raw === "gemini" || raw === "copilot") return raw;
|
|
3526
|
+
return defaultAcpHarness();
|
|
3527
|
+
}
|
|
3528
|
+
function draftAgentOptions(draft, defaults) {
|
|
3529
|
+
const agent = draft?.agent ?? defaults.agent;
|
|
3530
|
+
return {
|
|
3531
|
+
agent,
|
|
3532
|
+
acpHarness: phoneAcpHarness(agent, draft?.acpHarness),
|
|
3533
|
+
model: draft && "model" in draft ? draft.model ?? null : defaults.model,
|
|
3534
|
+
effort: draft?.effort ?? defaults.effort,
|
|
3535
|
+
fast: draft?.fast ?? defaults.fast,
|
|
3536
|
+
planMode: Boolean(draft?.planMode),
|
|
3537
|
+
autonomy: draft?.autonomy ?? defaults.autonomy
|
|
3538
|
+
};
|
|
3539
|
+
}
|
|
3540
|
+
function createPhoneChat(agent) {
|
|
3541
|
+
const defaults = resolveOrchestratorDefaults();
|
|
3542
|
+
const thread = createGlobalChat({
|
|
3543
|
+
agent: agent ?? defaults.agent,
|
|
3544
|
+
model: defaults.model,
|
|
3545
|
+
effort: defaults.effort,
|
|
3546
|
+
fast: defaults.fast
|
|
3547
|
+
});
|
|
3548
|
+
return openedFrom(thread, { kind: "orchestration" });
|
|
3549
|
+
}
|
|
3550
|
+
async function createPhoneOrchestration(draft) {
|
|
3551
|
+
const goal = (draft?.goal ?? draft?.prompt ?? "").trim();
|
|
3552
|
+
const attachments = phoneTurnAttachments(draft ?? {});
|
|
3553
|
+
if (!goal && attachments.length === 0) return createPhoneChat(draft?.agent);
|
|
3554
|
+
const defaults = resolveOrchestratorDefaults();
|
|
3555
|
+
const options = draftAgentOptions(draft, defaults);
|
|
3556
|
+
const thread = await startOrchestration({
|
|
3557
|
+
goal: goal || "See the attached files.",
|
|
3558
|
+
agent: options.agent,
|
|
3559
|
+
model: options.model,
|
|
3560
|
+
effort: options.effort,
|
|
3561
|
+
fast: options.fast,
|
|
3562
|
+
planMode: options.planMode,
|
|
3563
|
+
autonomy: options.autonomy,
|
|
3564
|
+
attachments
|
|
3565
|
+
});
|
|
3566
|
+
return openedFrom(thread, { kind: "orchestration" });
|
|
3567
|
+
}
|
|
3568
|
+
function createPhoneWorktreeAgent(fromChatId, draft) {
|
|
3569
|
+
const source = readPhoneThread(fromChatId);
|
|
3570
|
+
if (!source || isGlobalThread(source)) throw new Error("That worktree is not on this Mac.");
|
|
3571
|
+
const defaults = resolveNewThreadOptions();
|
|
3572
|
+
const options = draftAgentOptions(draft, defaults);
|
|
3573
|
+
const attachments = persistPendingFileAttachments(
|
|
3574
|
+
source.worktreePath,
|
|
3575
|
+
phoneTurnAttachments(draft ?? {})
|
|
3576
|
+
);
|
|
3577
|
+
const thread = createChatTab({
|
|
3578
|
+
fromThreadId: source.id,
|
|
3579
|
+
agent: options.agent,
|
|
3580
|
+
...options.agent === "acp" ? { acpHarness: options.acpHarness ?? void 0 } : {},
|
|
3581
|
+
model: options.model,
|
|
3582
|
+
effort: options.effort,
|
|
3583
|
+
fast: options.fast,
|
|
3584
|
+
autonomy: options.autonomy,
|
|
3585
|
+
attachments
|
|
3586
|
+
});
|
|
3587
|
+
if (draft?.planMode !== void 0) updateThread(thread.id, { planMode: draft.planMode });
|
|
3588
|
+
return openedFrom(thread, projectPlace(readThread(thread.id) ?? thread));
|
|
3589
|
+
}
|
|
3590
|
+
async function createPhoneProjectWorktree(repoPathOrInput) {
|
|
3591
|
+
const input = typeof repoPathOrInput === "string" ? { repoPath: repoPathOrInput } : repoPathOrInput;
|
|
3592
|
+
const path2 = assertKnownProject(input.repoPath);
|
|
3593
|
+
const defaults = resolveNewThreadOptions();
|
|
3594
|
+
const options = draftAgentOptions(input, defaults);
|
|
3595
|
+
const thread = await createThread({
|
|
3596
|
+
sourceType: input.sourceType ?? "branch",
|
|
3597
|
+
sourceRef: input.sourceRef || "default",
|
|
3598
|
+
repoPath: path2,
|
|
3599
|
+
title: input.title,
|
|
3600
|
+
cowboy: input.cowboy,
|
|
3601
|
+
agent: options.agent,
|
|
3602
|
+
...options.agent === "acp" ? { acpHarness: options.acpHarness ?? void 0 } : {},
|
|
3603
|
+
model: options.model,
|
|
3604
|
+
effort: options.effort,
|
|
3605
|
+
fast: options.fast,
|
|
3606
|
+
planMode: options.planMode,
|
|
3607
|
+
autonomy: options.autonomy,
|
|
3608
|
+
attachments: phoneTurnAttachments(input),
|
|
3609
|
+
prompt: input.prompt,
|
|
3610
|
+
reuseExisting: false
|
|
3611
|
+
});
|
|
3612
|
+
return openedFrom(thread, projectPlace(thread));
|
|
3613
|
+
}
|
|
3614
|
+
async function listPhoneModels(agent) {
|
|
3615
|
+
const catalogs = await listModelsForAgent(agent);
|
|
3616
|
+
return (catalogs[0]?.models ?? []).slice(0, 40).map((model) => ({
|
|
3617
|
+
id: model.id,
|
|
3618
|
+
label: model.displayName || model.id
|
|
3619
|
+
}));
|
|
3620
|
+
}
|
|
3621
|
+
function archivePhoneChat(chatId) {
|
|
3622
|
+
const thread = readPhoneThread(chatId);
|
|
3623
|
+
if (!thread) return false;
|
|
3624
|
+
updateThread(thread.id, { status: "archived" });
|
|
3625
|
+
return true;
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3500
3628
|
// src/remote/phone-chats.ts
|
|
3501
3629
|
var PHONE_CONTROL_PREFIX = "\0sb.phone\n";
|
|
3502
3630
|
var PREVIEW_LIMIT2 = 90;
|
|
3503
|
-
var AGENT_KINDS = /* @__PURE__ */ new Set(["claude", "codex", "opencode", "brightsy", "cursor"]);
|
|
3631
|
+
var AGENT_KINDS = /* @__PURE__ */ new Set(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]);
|
|
3504
3632
|
var MAX_PHONE_FILES = 8;
|
|
3505
3633
|
var MAX_PHONE_FILE_CHARS = Math.ceil(8 * 1024 * 1024 * 4 / 3);
|
|
3506
3634
|
var MAX_PHONE_FILES_CHARS = Math.ceil(20 * 1024 * 1024 * 4 / 3);
|
|
@@ -3508,11 +3636,11 @@ var MAX_DICTATION_CHARS = Math.ceil(12 * 1024 * 1024 * 4 / 3);
|
|
|
3508
3636
|
function encodePhoneControl(payload) {
|
|
3509
3637
|
return PHONE_CONTROL_PREFIX + JSON.stringify(payload);
|
|
3510
3638
|
}
|
|
3511
|
-
function takePhoneControl(
|
|
3512
|
-
if (!
|
|
3639
|
+
function takePhoneControl(text6) {
|
|
3640
|
+
if (!text6.startsWith(PHONE_CONTROL_PREFIX)) return null;
|
|
3513
3641
|
let parsed;
|
|
3514
3642
|
try {
|
|
3515
|
-
parsed = JSON.parse(
|
|
3643
|
+
parsed = JSON.parse(text6.slice(PHONE_CONTROL_PREFIX.length));
|
|
3516
3644
|
} catch {
|
|
3517
3645
|
return "invalid";
|
|
3518
3646
|
}
|
|
@@ -3582,10 +3710,10 @@ function parsePhoneControl(value) {
|
|
|
3582
3710
|
if (draft === "invalid") return "invalid";
|
|
3583
3711
|
if (op === "options") return { op: "options", chatId, ...draft };
|
|
3584
3712
|
if (op === "prompt") {
|
|
3585
|
-
const
|
|
3586
|
-
const hasPayload = Boolean(
|
|
3713
|
+
const text6 = typeof value.text === "string" ? value.text.trim() : "";
|
|
3714
|
+
const hasPayload = Boolean(text6 || draft.files?.length || draft.links?.length || draft.refs?.length);
|
|
3587
3715
|
if (!hasPayload) return "invalid";
|
|
3588
|
-
return { op: "prompt", chatId, text:
|
|
3716
|
+
return { op: "prompt", chatId, text: text6, ...draft };
|
|
3589
3717
|
}
|
|
3590
3718
|
return "invalid";
|
|
3591
3719
|
}
|
|
@@ -3615,6 +3743,12 @@ function parsePhoneDraft(value) {
|
|
|
3615
3743
|
if (!agent) return "invalid";
|
|
3616
3744
|
draft.agent = agent;
|
|
3617
3745
|
}
|
|
3746
|
+
if ("acpHarness" in value) {
|
|
3747
|
+
const harness = value.acpHarness;
|
|
3748
|
+
if (harness === null || harness === "") draft.acpHarness = null;
|
|
3749
|
+
else if (harness === "gemini" || harness === "copilot") draft.acpHarness = harness;
|
|
3750
|
+
else return "invalid";
|
|
3751
|
+
}
|
|
3618
3752
|
if ("model" in value) {
|
|
3619
3753
|
const model = value.model;
|
|
3620
3754
|
if (model === null || model === "") draft.model = null;
|
|
@@ -3737,6 +3871,7 @@ function summarize(thread) {
|
|
|
3737
3871
|
preview: previewOf2(thread),
|
|
3738
3872
|
updatedAt: thread.updatedAt,
|
|
3739
3873
|
agent: thread.agent,
|
|
3874
|
+
...thread.agent === "acp" ? { acpHarness: thread.acpHarness === "copilot" ? "copilot" : "gemini" } : {},
|
|
3740
3875
|
...pr?.url ? { prUrl: pr.url } : {},
|
|
3741
3876
|
...pr?.number ? { prNumber: pr.number } : {},
|
|
3742
3877
|
...pr?.status ? { prStatus: pr.status } : {},
|
|
@@ -3813,6 +3948,7 @@ function readPhoneThread(chatId) {
|
|
|
3813
3948
|
function phoneComposerOptions(thread) {
|
|
3814
3949
|
return {
|
|
3815
3950
|
agent: thread.agent,
|
|
3951
|
+
...thread.agent === "acp" ? { acpHarness: thread.acpHarness === "copilot" ? "copilot" : "gemini" } : {},
|
|
3816
3952
|
model: thread.model ?? null,
|
|
3817
3953
|
effort: thread.effort,
|
|
3818
3954
|
fast: Boolean(thread.fast),
|
|
@@ -3871,101 +4007,6 @@ function assertKnownProject(repoPath) {
|
|
|
3871
4007
|
if (!known) throw new Error("That project is not on this Mac.");
|
|
3872
4008
|
return path2;
|
|
3873
4009
|
}
|
|
3874
|
-
function draftAgentOptions(draft, defaults) {
|
|
3875
|
-
return {
|
|
3876
|
-
agent: draft?.agent ?? defaults.agent,
|
|
3877
|
-
model: draft && "model" in draft ? draft.model ?? null : defaults.model,
|
|
3878
|
-
effort: draft?.effort ?? defaults.effort,
|
|
3879
|
-
fast: draft?.fast ?? defaults.fast,
|
|
3880
|
-
planMode: Boolean(draft?.planMode),
|
|
3881
|
-
autonomy: draft?.autonomy ?? defaults.autonomy
|
|
3882
|
-
};
|
|
3883
|
-
}
|
|
3884
|
-
function createPhoneChat(agent) {
|
|
3885
|
-
const defaults = resolveOrchestratorDefaults();
|
|
3886
|
-
const thread = createGlobalChat({
|
|
3887
|
-
agent: agent ?? defaults.agent,
|
|
3888
|
-
model: defaults.model,
|
|
3889
|
-
effort: defaults.effort,
|
|
3890
|
-
fast: defaults.fast
|
|
3891
|
-
});
|
|
3892
|
-
return openedFrom(thread, { kind: "orchestration" });
|
|
3893
|
-
}
|
|
3894
|
-
async function createPhoneOrchestration(draft) {
|
|
3895
|
-
const goal = (draft?.goal ?? draft?.prompt ?? "").trim();
|
|
3896
|
-
const attachments = phoneTurnAttachments(draft ?? {});
|
|
3897
|
-
if (!goal && attachments.length === 0) return createPhoneChat(draft?.agent);
|
|
3898
|
-
const defaults = resolveOrchestratorDefaults();
|
|
3899
|
-
const options = draftAgentOptions(draft, defaults);
|
|
3900
|
-
const thread = await startOrchestration({
|
|
3901
|
-
goal: goal || "See the attached files.",
|
|
3902
|
-
agent: options.agent,
|
|
3903
|
-
model: options.model,
|
|
3904
|
-
effort: options.effort,
|
|
3905
|
-
fast: options.fast,
|
|
3906
|
-
planMode: options.planMode,
|
|
3907
|
-
autonomy: options.autonomy,
|
|
3908
|
-
attachments
|
|
3909
|
-
});
|
|
3910
|
-
return openedFrom(thread, { kind: "orchestration" });
|
|
3911
|
-
}
|
|
3912
|
-
function createPhoneWorktreeAgent(fromChatId, draft) {
|
|
3913
|
-
const source = readPhoneThread(fromChatId);
|
|
3914
|
-
if (!source || isGlobalThread(source)) throw new Error("That worktree is not on this Mac.");
|
|
3915
|
-
const defaults = resolveNewThreadOptions();
|
|
3916
|
-
const options = draftAgentOptions(draft, defaults);
|
|
3917
|
-
const attachments = persistPendingFileAttachments(
|
|
3918
|
-
source.worktreePath,
|
|
3919
|
-
phoneTurnAttachments(draft ?? {})
|
|
3920
|
-
);
|
|
3921
|
-
const thread = createChatTab({
|
|
3922
|
-
fromThreadId: source.id,
|
|
3923
|
-
agent: options.agent,
|
|
3924
|
-
model: options.model,
|
|
3925
|
-
effort: options.effort,
|
|
3926
|
-
fast: options.fast,
|
|
3927
|
-
autonomy: options.autonomy,
|
|
3928
|
-
attachments
|
|
3929
|
-
});
|
|
3930
|
-
if (draft?.planMode !== void 0) updateThread(thread.id, { planMode: draft.planMode });
|
|
3931
|
-
return openedFrom(thread, projectPlace(readThread(thread.id) ?? thread));
|
|
3932
|
-
}
|
|
3933
|
-
async function createPhoneProjectWorktree(repoPathOrInput) {
|
|
3934
|
-
const input = typeof repoPathOrInput === "string" ? { repoPath: repoPathOrInput } : repoPathOrInput;
|
|
3935
|
-
const path2 = assertKnownProject(input.repoPath);
|
|
3936
|
-
const defaults = resolveNewThreadOptions();
|
|
3937
|
-
const options = draftAgentOptions(input, defaults);
|
|
3938
|
-
const thread = await createThread({
|
|
3939
|
-
sourceType: input.sourceType ?? "branch",
|
|
3940
|
-
sourceRef: input.sourceRef || "default",
|
|
3941
|
-
repoPath: path2,
|
|
3942
|
-
title: input.title,
|
|
3943
|
-
cowboy: input.cowboy,
|
|
3944
|
-
agent: options.agent,
|
|
3945
|
-
model: options.model,
|
|
3946
|
-
effort: options.effort,
|
|
3947
|
-
fast: options.fast,
|
|
3948
|
-
planMode: options.planMode,
|
|
3949
|
-
autonomy: options.autonomy,
|
|
3950
|
-
attachments: phoneTurnAttachments(input),
|
|
3951
|
-
prompt: input.prompt,
|
|
3952
|
-
reuseExisting: false
|
|
3953
|
-
});
|
|
3954
|
-
return openedFrom(thread, projectPlace(thread));
|
|
3955
|
-
}
|
|
3956
|
-
async function listPhoneModels(agent) {
|
|
3957
|
-
const catalogs = await listModelsForAgent(agent);
|
|
3958
|
-
return (catalogs[0]?.models ?? []).slice(0, 40).map((model) => ({
|
|
3959
|
-
id: model.id,
|
|
3960
|
-
label: model.displayName || model.id
|
|
3961
|
-
}));
|
|
3962
|
-
}
|
|
3963
|
-
function archivePhoneChat(chatId) {
|
|
3964
|
-
const thread = readPhoneThread(chatId);
|
|
3965
|
-
if (!thread) return false;
|
|
3966
|
-
updateThread(thread.id, { status: "archived" });
|
|
3967
|
-
return true;
|
|
3968
|
-
}
|
|
3969
4010
|
|
|
3970
4011
|
// src/orchestrator/outbound-turn-reply.ts
|
|
3971
4012
|
function outboundReplyFromTurn(result, copy) {
|
|
@@ -3982,8 +4023,8 @@ function outboundReplyFromTurn(result, copy) {
|
|
|
3982
4023
|
case "working":
|
|
3983
4024
|
return copy.failed(`turn still ${result.taskState}`);
|
|
3984
4025
|
default: {
|
|
3985
|
-
const
|
|
3986
|
-
return
|
|
4026
|
+
const text6 = result.text.trim();
|
|
4027
|
+
return text6 || copy.completedEmpty(result.status);
|
|
3987
4028
|
}
|
|
3988
4029
|
}
|
|
3989
4030
|
}
|
|
@@ -4227,26 +4268,26 @@ var IMAGE_MIME = {
|
|
|
4227
4268
|
bmp: "image/bmp"
|
|
4228
4269
|
};
|
|
4229
4270
|
function phoneWorktreeRelative(worktreePath, raw) {
|
|
4230
|
-
let
|
|
4231
|
-
if (!
|
|
4232
|
-
if (/^file:\/\//i.test(
|
|
4271
|
+
let text6 = raw.trim();
|
|
4272
|
+
if (!text6) return null;
|
|
4273
|
+
if (/^file:\/\//i.test(text6)) {
|
|
4233
4274
|
try {
|
|
4234
|
-
|
|
4275
|
+
text6 = decodeURIComponent(new URL(text6).pathname);
|
|
4235
4276
|
} catch {
|
|
4236
4277
|
return null;
|
|
4237
4278
|
}
|
|
4238
4279
|
}
|
|
4239
|
-
|
|
4240
|
-
if (!
|
|
4280
|
+
text6 = (text6.split("#")[0] ?? text6).replace(/\\/g, "/");
|
|
4281
|
+
if (!text6 || text6.includes("\0") || text6.split("/").includes("..")) return null;
|
|
4241
4282
|
const root = worktreePath.replace(/\/+$/, "");
|
|
4242
4283
|
if (!root || root === "/") return null;
|
|
4243
|
-
if (
|
|
4244
|
-
if (
|
|
4245
|
-
|
|
4284
|
+
if (text6.startsWith("/")) {
|
|
4285
|
+
if (text6 !== root && !text6.startsWith(`${root}/`)) return null;
|
|
4286
|
+
text6 = text6 === root ? "" : text6.slice(root.length + 1);
|
|
4246
4287
|
}
|
|
4247
|
-
|
|
4248
|
-
if (!
|
|
4249
|
-
return
|
|
4288
|
+
text6 = text6.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
4289
|
+
if (!text6 || text6 === "." || text6.startsWith("/")) return null;
|
|
4290
|
+
return text6;
|
|
4250
4291
|
}
|
|
4251
4292
|
function phoneImageMime(relativePath) {
|
|
4252
4293
|
const ext = relativePath.split(".").pop()?.toLowerCase() ?? "";
|
|
@@ -4424,11 +4465,11 @@ function textField2(value, key) {
|
|
|
4424
4465
|
const raw = value[key];
|
|
4425
4466
|
return typeof raw === "string" ? raw.trim() : "";
|
|
4426
4467
|
}
|
|
4427
|
-
function takePhonePermission(
|
|
4428
|
-
if (!
|
|
4468
|
+
function takePhonePermission(text6) {
|
|
4469
|
+
if (!text6.startsWith(PHONE_CONTROL_PREFIX2)) return null;
|
|
4429
4470
|
let parsed;
|
|
4430
4471
|
try {
|
|
4431
|
-
parsed = JSON.parse(
|
|
4472
|
+
parsed = JSON.parse(text6.slice(PHONE_CONTROL_PREFIX2.length));
|
|
4432
4473
|
} catch {
|
|
4433
4474
|
return null;
|
|
4434
4475
|
}
|
|
@@ -4440,8 +4481,8 @@ function takePhonePermission(text5) {
|
|
|
4440
4481
|
if (!chatId || !id || !DECISIONS.has(decision)) return "invalid";
|
|
4441
4482
|
return { op: "permission", chatId, id, decision };
|
|
4442
4483
|
}
|
|
4443
|
-
function dispatchPhonePermission(
|
|
4444
|
-
const cmd = takePhonePermission(
|
|
4484
|
+
function dispatchPhonePermission(text6, emit) {
|
|
4485
|
+
const cmd = takePhonePermission(text6);
|
|
4445
4486
|
if (cmd == null) return false;
|
|
4446
4487
|
if (cmd === "invalid") {
|
|
4447
4488
|
emit({ op: "error", message: "invalid phone command" });
|
|
@@ -4498,7 +4539,7 @@ function extractGitHubIssueAttachments(issue) {
|
|
|
4498
4539
|
const texts = [issue.body ?? "", ...issue.comments.map((comment) => comment.body)];
|
|
4499
4540
|
return mergeIssueAttachments(
|
|
4500
4541
|
texts.flatMap(
|
|
4501
|
-
(
|
|
4542
|
+
(text6) => extractHttpUrls(text6).filter(isGitHubIssueAttachmentUrl).map((url) => ({
|
|
4502
4543
|
id: url,
|
|
4503
4544
|
name: url.split("/").pop() || "attachment",
|
|
4504
4545
|
url
|
|
@@ -4529,11 +4570,11 @@ async function downloadGitHubIssueAttachment(input, opts) {
|
|
|
4529
4570
|
|
|
4530
4571
|
// src/integrations/github-projects.ts
|
|
4531
4572
|
function rewriteGitHubProjectReadError(detail) {
|
|
4532
|
-
const
|
|
4533
|
-
if (/read:project|project scope|missing required scopes/i.test(
|
|
4534
|
-
return `${
|
|
4573
|
+
const text6 = detail.trim() || "gh could not read GitHub Projects";
|
|
4574
|
+
if (/read:project|project scope|missing required scopes/i.test(text6)) {
|
|
4575
|
+
return `${text6} \u2014 run \`gh auth refresh -s read:project\` so Sideboard can read GitHub Projects.`;
|
|
4535
4576
|
}
|
|
4536
|
-
return
|
|
4577
|
+
return text6;
|
|
4537
4578
|
}
|
|
4538
4579
|
function githubProjectsUnreadable(result) {
|
|
4539
4580
|
return /project|scope|unknown json field/i.test(`${result.stderr}
|
|
@@ -5281,13 +5322,13 @@ async function listPhoneSources(repoPath, query) {
|
|
|
5281
5322
|
}
|
|
5282
5323
|
|
|
5283
5324
|
// src/remote/phone-turn.ts
|
|
5284
|
-
function formatRemotePrompt(
|
|
5325
|
+
function formatRemotePrompt(text6) {
|
|
5285
5326
|
return `Phone
|
|
5286
5327
|
|
|
5287
|
-
${
|
|
5328
|
+
${text6.trim()}`;
|
|
5288
5329
|
}
|
|
5289
|
-
function isRemoteStopCommand(
|
|
5290
|
-
return
|
|
5330
|
+
function isRemoteStopCommand(text6) {
|
|
5331
|
+
return text6.trim().toLowerCase() === "stop";
|
|
5291
5332
|
}
|
|
5292
5333
|
function phoneFollowUpQueues(status) {
|
|
5293
5334
|
return followUpBehavior() === "queue" && (status === "running" || status === "queued");
|
|
@@ -5429,6 +5470,8 @@ function publishOpenedChat(opts, chatId) {
|
|
|
5429
5470
|
function applyPhoneOptions(chatId, draft) {
|
|
5430
5471
|
const patch = {};
|
|
5431
5472
|
if (draft.agent) patch.agent = draft.agent;
|
|
5473
|
+
if (draft.acpHarness !== void 0) patch.acpHarness = draft.acpHarness;
|
|
5474
|
+
else if (draft.agent) patch.acpHarness = draft.agent === "acp" ? "gemini" : null;
|
|
5432
5475
|
if ("model" in draft) patch.model = draft.model ?? null;
|
|
5433
5476
|
if (draft.effort) patch.effort = draft.effort;
|
|
5434
5477
|
if (draft.fast !== void 0) patch.fast = draft.fast;
|
|
@@ -5494,7 +5537,7 @@ function handlePhoneControl(cmd, opts) {
|
|
|
5494
5537
|
emitControl(opts, { op: "error", message: "Speech is not available on this Mac." });
|
|
5495
5538
|
return;
|
|
5496
5539
|
}
|
|
5497
|
-
void transcribe(cmd.audioBase64).then((
|
|
5540
|
+
void transcribe(cmd.audioBase64).then((text6) => emitControl(opts, { op: "dictated", id, text: text6.trim() })).catch((err) => {
|
|
5498
5541
|
emitControl(opts, { op: "error", message: phoneError(err) });
|
|
5499
5542
|
});
|
|
5500
5543
|
return;
|
|
@@ -5774,8 +5817,8 @@ function runPhonePrompt(opts, cmd, chatId, generation) {
|
|
|
5774
5817
|
const live = readPhoneThread(thread.id) ?? thread;
|
|
5775
5818
|
const followUp = followUpBehavior();
|
|
5776
5819
|
const staged = stagePhoneTurnFiles(live.worktreePath, cmd);
|
|
5777
|
-
const
|
|
5778
|
-
await getOrchestrator().send(thread.id, formatRemotePrompt(
|
|
5820
|
+
const text6 = cmd.text.trim() || (staged.length ? "See the attached files." : "");
|
|
5821
|
+
await getOrchestrator().send(thread.id, formatRemotePrompt(text6), {
|
|
5779
5822
|
attachments: staged,
|
|
5780
5823
|
followUp
|
|
5781
5824
|
});
|
|
@@ -5794,8 +5837,8 @@ function runPhonePrompt(opts, cmd, chatId, generation) {
|
|
|
5794
5837
|
emitChatTurn(opts, chatId, thread.id);
|
|
5795
5838
|
})();
|
|
5796
5839
|
}
|
|
5797
|
-
function handleRemoteInbound(
|
|
5798
|
-
const body =
|
|
5840
|
+
function handleRemoteInbound(text6, opts) {
|
|
5841
|
+
const body = text6.trim();
|
|
5799
5842
|
if (dispatchPhonePermission(body, (reply) => emitControl(opts, reply))) return;
|
|
5800
5843
|
const control = takePhoneControl(body);
|
|
5801
5844
|
if (control) {
|
|
@@ -5819,6 +5862,7 @@ function chatKey(row2) {
|
|
|
5819
5862
|
row2.title,
|
|
5820
5863
|
row2.status,
|
|
5821
5864
|
row2.agent,
|
|
5865
|
+
row2.acpHarness ?? "",
|
|
5822
5866
|
row2.preview,
|
|
5823
5867
|
row2.needsYou ? "1" : "0",
|
|
5824
5868
|
row2.blockedReason ?? ""
|
|
@@ -6140,12 +6184,12 @@ function runRemoteHost(opts) {
|
|
|
6140
6184
|
refreshViewerLogin: () => refreshPhoneViewerLogin(true)
|
|
6141
6185
|
});
|
|
6142
6186
|
};
|
|
6143
|
-
const
|
|
6187
|
+
const send4 = (msg) => {
|
|
6144
6188
|
if (!socket || socket.readyState !== socket.OPEN) return;
|
|
6145
6189
|
socket.send(JSON.stringify(msg));
|
|
6146
6190
|
};
|
|
6147
6191
|
const sendRegister = () => {
|
|
6148
|
-
|
|
6192
|
+
send4({
|
|
6149
6193
|
type: "host_register",
|
|
6150
6194
|
deviceId: opts.deviceId,
|
|
6151
6195
|
deviceLabel,
|
|
@@ -6210,11 +6254,11 @@ function runRemoteHost(opts) {
|
|
|
6210
6254
|
log(`Remote connected \xB7 ${deviceLabel}`);
|
|
6211
6255
|
opts.onStatus?.({ connected: true, phoneConnected: false });
|
|
6212
6256
|
sendRegister();
|
|
6213
|
-
if (wantPair)
|
|
6257
|
+
if (wantPair) send4({ type: "host_pair" });
|
|
6214
6258
|
keepalive = createRemoteKeepalive({
|
|
6215
6259
|
intervalMs: opts.pingIntervalMs ?? REMOTE_PING_INTERVAL_MS,
|
|
6216
6260
|
pongTimeoutMs: opts.pongTimeoutMs ?? REMOTE_PONG_TIMEOUT_MS,
|
|
6217
|
-
sendPing: () =>
|
|
6261
|
+
sendPing: () => send4({ type: "ping" }),
|
|
6218
6262
|
onTimeout: () => {
|
|
6219
6263
|
log("remote error: ping timeout");
|
|
6220
6264
|
finish(new Error("remote ping timeout"));
|
|
@@ -6266,8 +6310,8 @@ function runRemoteHost(opts) {
|
|
|
6266
6310
|
clientPublicKey: msg.clientPublicKey,
|
|
6267
6311
|
clientNonce: msg.clientNonce
|
|
6268
6312
|
});
|
|
6269
|
-
if (ready)
|
|
6270
|
-
else
|
|
6313
|
+
if (ready) send4({ type: "e2ee_ready", ...ready });
|
|
6314
|
+
else send4({ type: "e2ee_fail" });
|
|
6271
6315
|
return;
|
|
6272
6316
|
}
|
|
6273
6317
|
if (msg.type === "e2ee") {
|
|
@@ -6275,18 +6319,18 @@ function runRemoteHost(opts) {
|
|
|
6275
6319
|
if (!opened) return;
|
|
6276
6320
|
if (opened.reject) {
|
|
6277
6321
|
hostSeal.reset();
|
|
6278
|
-
|
|
6322
|
+
send4({ type: "e2ee_fail" });
|
|
6279
6323
|
return;
|
|
6280
6324
|
}
|
|
6281
6325
|
if (opened.okFrame) {
|
|
6282
|
-
|
|
6326
|
+
send4({ type: "e2ee", frame: opened.okFrame });
|
|
6283
6327
|
try {
|
|
6284
6328
|
startBoardSync();
|
|
6285
6329
|
} catch (err) {
|
|
6286
6330
|
log(`remote error: ${err instanceof Error ? err.message : err}`);
|
|
6287
6331
|
}
|
|
6288
6332
|
opts.onPairingCode?.(null);
|
|
6289
|
-
|
|
6333
|
+
send4({ type: "pairing_done" });
|
|
6290
6334
|
opts.onStatus?.({ connected: true, phoneConnected: true });
|
|
6291
6335
|
log("phone joined");
|
|
6292
6336
|
return;
|
|
@@ -6332,7 +6376,7 @@ function runRemoteHost(opts) {
|
|
|
6332
6376
|
outbound.type === "assistant" ? { type: "assistant", text: outbound.text } : { type: "ask_user", text: outbound.text, questions: outbound.questions }
|
|
6333
6377
|
);
|
|
6334
6378
|
if (!frame) return;
|
|
6335
|
-
|
|
6379
|
+
send4({ type: "e2ee", frame });
|
|
6336
6380
|
};
|
|
6337
6381
|
setPhonePermissionPush((chatId, prompt) => {
|
|
6338
6382
|
if (getPhoneOpenChat() !== chatId) return;
|
|
@@ -6340,7 +6384,7 @@ function runRemoteHost(opts) {
|
|
|
6340
6384
|
});
|
|
6341
6385
|
const stopPush = hostedPushRelay(opts.url) ? startPhonePushWatch({
|
|
6342
6386
|
enabled: () => Boolean(socket && socket.readyState === socket.OPEN),
|
|
6343
|
-
send: (note) =>
|
|
6387
|
+
send: (note) => send4({ type: "push_notify", chatId: note.chatId, kind: note.kind })
|
|
6344
6388
|
}) : null;
|
|
6345
6389
|
opts.signal?.addEventListener("abort", () => stopPush?.(), { once: true });
|
|
6346
6390
|
void loop();
|
|
@@ -6348,7 +6392,7 @@ function runRemoteHost(opts) {
|
|
|
6348
6392
|
requestPairingCode() {
|
|
6349
6393
|
pendingPhoneToken = { token: generatePhoneToken(), expiresAt: Date.now() + PAIR_TTL_MS };
|
|
6350
6394
|
wantPair = true;
|
|
6351
|
-
|
|
6395
|
+
send4({ type: "host_pair" });
|
|
6352
6396
|
},
|
|
6353
6397
|
updateIdentity(label) {
|
|
6354
6398
|
const next = label.trim();
|
|
@@ -6583,11 +6627,11 @@ async function slackApi(token, method, params, fetchImpl) {
|
|
|
6583
6627
|
// src/slack/socket-mode.ts
|
|
6584
6628
|
var BACKOFF_START_MS2 = 1e3;
|
|
6585
6629
|
var BACKOFF_MAX_MS2 = 3e4;
|
|
6586
|
-
function stripSlackMentions(
|
|
6587
|
-
return
|
|
6630
|
+
function stripSlackMentions(text6) {
|
|
6631
|
+
return text6.replace(/<@[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
6588
6632
|
}
|
|
6589
|
-
function isSlackStopCommand(
|
|
6590
|
-
const t = stripSlackMentions(
|
|
6633
|
+
function isSlackStopCommand(text6) {
|
|
6634
|
+
const t = stripSlackMentions(text6).toLowerCase();
|
|
6591
6635
|
return t === "stop" || t === "sideboard_force_stop";
|
|
6592
6636
|
}
|
|
6593
6637
|
function parseSlackSocketFrame(raw) {
|
|
@@ -6609,8 +6653,8 @@ function inboundFromSocketFrame(frame) {
|
|
|
6609
6653
|
const ts = event.ts?.trim();
|
|
6610
6654
|
if (!channelId || !ts) return null;
|
|
6611
6655
|
const rawText = event.text?.trim() ?? "";
|
|
6612
|
-
const
|
|
6613
|
-
if (!
|
|
6656
|
+
const text6 = stripSlackMentions(rawText);
|
|
6657
|
+
if (!text6) return null;
|
|
6614
6658
|
const teamId = (frame.payload?.team_id || event.team || "").trim();
|
|
6615
6659
|
if (!teamId) return null;
|
|
6616
6660
|
const isDm = event.type === "message" && (event.channel_type === "im" || event.channel_type === "mpim" || !event.channel_type && channelId.startsWith("D"));
|
|
@@ -6622,7 +6666,7 @@ function inboundFromSocketFrame(frame) {
|
|
|
6622
6666
|
ts,
|
|
6623
6667
|
threadTs: event.thread_ts?.trim() || void 0,
|
|
6624
6668
|
userId: event.user?.trim(),
|
|
6625
|
-
text:
|
|
6669
|
+
text: text6,
|
|
6626
6670
|
kind: isMention ? "mention" : "dm"
|
|
6627
6671
|
};
|
|
6628
6672
|
}
|
|
@@ -6881,9 +6925,9 @@ var SlackEventDeduper = class {
|
|
|
6881
6925
|
import { createCipheriv, createDecipheriv, randomBytes as randomBytes2 } from "crypto";
|
|
6882
6926
|
var VERSION = "v1";
|
|
6883
6927
|
function parseSlackTokenKey(raw) {
|
|
6884
|
-
const
|
|
6885
|
-
if (!
|
|
6886
|
-
const buf = /^[0-9a-fA-F]{64}$/.test(
|
|
6928
|
+
const text6 = raw.trim();
|
|
6929
|
+
if (!text6) throw new Error("SIDEBOARD_SLACK_TOKEN_KEY is empty");
|
|
6930
|
+
const buf = /^[0-9a-fA-F]{64}$/.test(text6) ? Buffer.from(text6, "hex") : Buffer.from(text6, "base64");
|
|
6887
6931
|
if (buf.length !== 32) {
|
|
6888
6932
|
throw new Error("SIDEBOARD_SLACK_TOKEN_KEY must be 32 bytes (base64 or 64 hex characters)");
|
|
6889
6933
|
}
|
|
@@ -7930,10 +7974,10 @@ async function publishSlackAppHome(opts) {
|
|
|
7930
7974
|
}
|
|
7931
7975
|
|
|
7932
7976
|
// src/slack/relay-hub.ts
|
|
7933
|
-
function parseSlackDeviceDestination(
|
|
7934
|
-
const m =
|
|
7935
|
-
if (!m) return { label: null, rest:
|
|
7936
|
-
return { label: m[1], rest:
|
|
7977
|
+
function parseSlackDeviceDestination(text6) {
|
|
7978
|
+
const m = text6.match(/^\s*(?:to\s+)?(?:@|#)?([A-Za-z][\w-]{0,63})\s*[::]\s*/);
|
|
7979
|
+
if (!m) return { label: null, rest: text6 };
|
|
7980
|
+
return { label: m[1], rest: text6.slice(m[0].length) };
|
|
7937
7981
|
}
|
|
7938
7982
|
var SlackRelayHub = class {
|
|
7939
7983
|
sessions = /* @__PURE__ */ new Map();
|
|
@@ -8420,9 +8464,49 @@ async function tryServeStatic(req, res, root) {
|
|
|
8420
8464
|
|
|
8421
8465
|
// src/remote/hub.ts
|
|
8422
8466
|
import { randomBytes as randomBytes8 } from "crypto";
|
|
8467
|
+
|
|
8468
|
+
// src/remote/hub-forget.ts
|
|
8469
|
+
function dropForgottenMac(deviceId, hosts, remembered, codes, phonesByToken, bySocket, pushTokenBySocket) {
|
|
8470
|
+
const id = deviceId.trim();
|
|
8471
|
+
if (!id) return;
|
|
8472
|
+
remembered.delete(id);
|
|
8473
|
+
for (const [code, row2] of codes) {
|
|
8474
|
+
if (row2.deviceId === id) codes.delete(code);
|
|
8475
|
+
}
|
|
8476
|
+
for (const [token, session] of phonesByToken) {
|
|
8477
|
+
if (session.deviceId === id) phonesByToken.delete(token);
|
|
8478
|
+
}
|
|
8479
|
+
const host = hosts.get(id);
|
|
8480
|
+
if (!host) return;
|
|
8481
|
+
const phone = host.phone;
|
|
8482
|
+
hosts.delete(id);
|
|
8483
|
+
bySocket.delete(host.socket);
|
|
8484
|
+
if (phone) {
|
|
8485
|
+
bySocket.delete(phone);
|
|
8486
|
+
pushTokenBySocket.delete(phone);
|
|
8487
|
+
send(phone, { type: "host_offline" });
|
|
8488
|
+
try {
|
|
8489
|
+
phone.close();
|
|
8490
|
+
} catch {
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
send(host.socket, { type: "error", message: "This Mac was removed from the account." });
|
|
8494
|
+
try {
|
|
8495
|
+
host.socket.close();
|
|
8496
|
+
} catch {
|
|
8497
|
+
}
|
|
8498
|
+
}
|
|
8499
|
+
function send(socket, msg) {
|
|
8500
|
+
try {
|
|
8501
|
+
socket.send(JSON.stringify(msg));
|
|
8502
|
+
} catch {
|
|
8503
|
+
}
|
|
8504
|
+
}
|
|
8505
|
+
|
|
8506
|
+
// src/remote/hub.ts
|
|
8423
8507
|
var CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
8424
8508
|
var CODE_TTL_MS = 10 * 60 * 1e3;
|
|
8425
|
-
function
|
|
8509
|
+
function send2(socket, msg) {
|
|
8426
8510
|
try {
|
|
8427
8511
|
socket.send(JSON.stringify(msg));
|
|
8428
8512
|
} catch {
|
|
@@ -8450,15 +8534,18 @@ var RemoteHub = class {
|
|
|
8450
8534
|
handleClientMessage(socket, raw) {
|
|
8451
8535
|
const msg = parseRemoteClientMessage(raw);
|
|
8452
8536
|
if (!msg) {
|
|
8453
|
-
|
|
8537
|
+
send2(socket, { type: "error", message: "invalid message" });
|
|
8454
8538
|
return;
|
|
8455
8539
|
}
|
|
8456
8540
|
if (msg.type === "ping") {
|
|
8457
|
-
|
|
8541
|
+
send2(socket, { type: "pong" });
|
|
8458
8542
|
return;
|
|
8459
8543
|
}
|
|
8460
8544
|
this.dispatch(socket, msg);
|
|
8461
8545
|
}
|
|
8546
|
+
forgetDevice(deviceId) {
|
|
8547
|
+
dropForgottenMac(deviceId, this.hosts, this.remembered, this.codes, this.phonesByToken, this.bySocket, this.pushTokenBySocket);
|
|
8548
|
+
}
|
|
8462
8549
|
detachSocket(socket) {
|
|
8463
8550
|
const bound = this.bySocket.get(socket);
|
|
8464
8551
|
if (!bound) return;
|
|
@@ -8467,7 +8554,7 @@ var RemoteHub = class {
|
|
|
8467
8554
|
if (!host) return;
|
|
8468
8555
|
if (bound.role === "host" && host.socket === socket) {
|
|
8469
8556
|
if (host.phone) {
|
|
8470
|
-
|
|
8557
|
+
send2(host.phone, { type: "host_offline" });
|
|
8471
8558
|
this.bySocket.delete(host.phone);
|
|
8472
8559
|
}
|
|
8473
8560
|
this.hosts.delete(bound.deviceId);
|
|
@@ -8476,7 +8563,7 @@ var RemoteHub = class {
|
|
|
8476
8563
|
if (bound.role === "phone" && host.phone === socket) {
|
|
8477
8564
|
host.phone = null;
|
|
8478
8565
|
this.pushTokenBySocket.delete(socket);
|
|
8479
|
-
|
|
8566
|
+
send2(host.socket, { type: "phone_left" });
|
|
8480
8567
|
}
|
|
8481
8568
|
}
|
|
8482
8569
|
dispatch(socket, msg) {
|
|
@@ -8529,36 +8616,36 @@ var RemoteHub = class {
|
|
|
8529
8616
|
const bound = this.bySocket.get(socket);
|
|
8530
8617
|
const host = bound ? this.hosts.get(bound.deviceId) : null;
|
|
8531
8618
|
if (!bound || !host) {
|
|
8532
|
-
|
|
8619
|
+
send2(socket, { type: "error", message: "pair this phone first" });
|
|
8533
8620
|
return;
|
|
8534
8621
|
}
|
|
8535
8622
|
if (bound.role === "phone") {
|
|
8536
8623
|
if (host.phone !== socket || msg.type === "e2ee_ready" || msg.type === "e2ee_fail") {
|
|
8537
|
-
|
|
8624
|
+
send2(socket, { type: "error", message: "pair this phone first" });
|
|
8538
8625
|
return;
|
|
8539
8626
|
}
|
|
8540
|
-
|
|
8627
|
+
send2(host.socket, msg);
|
|
8541
8628
|
return;
|
|
8542
8629
|
}
|
|
8543
8630
|
if (host.socket !== socket || !host.phone || msg.type === "e2ee_hello") return;
|
|
8544
8631
|
if (msg.type === "e2ee_fail") {
|
|
8545
|
-
|
|
8632
|
+
send2(host.phone, { type: "error", message: "phone session expired \u2014 pair again" });
|
|
8546
8633
|
return;
|
|
8547
8634
|
}
|
|
8548
|
-
|
|
8635
|
+
send2(host.phone, msg);
|
|
8549
8636
|
}
|
|
8550
8637
|
registerHost(socket, deviceId, deviceLabel, hostSecret, accountToken) {
|
|
8551
8638
|
if (this.opts.authorizeHost) {
|
|
8552
8639
|
const decision = this.opts.authorizeHost({ accountToken, deviceId, deviceLabel, hostSecret });
|
|
8553
8640
|
if (!decision.ok) {
|
|
8554
|
-
|
|
8641
|
+
send2(socket, { type: "error", message: decision.message });
|
|
8555
8642
|
return;
|
|
8556
8643
|
}
|
|
8557
8644
|
}
|
|
8558
8645
|
const prior = this.remembered.get(deviceId);
|
|
8559
8646
|
const existing = this.hosts.get(deviceId);
|
|
8560
8647
|
if (prior && prior.hostSecret !== hostSecret || existing && existing.hostSecret !== hostSecret) {
|
|
8561
|
-
|
|
8648
|
+
send2(socket, { type: "error", message: "host secret rejected" });
|
|
8562
8649
|
return;
|
|
8563
8650
|
}
|
|
8564
8651
|
if (existing && existing.socket !== socket) {
|
|
@@ -8568,7 +8655,7 @@ var RemoteHub = class {
|
|
|
8568
8655
|
} catch {
|
|
8569
8656
|
}
|
|
8570
8657
|
if (existing.phone) {
|
|
8571
|
-
|
|
8658
|
+
send2(existing.phone, { type: "host_offline" });
|
|
8572
8659
|
this.pushTokenBySocket.delete(existing.phone);
|
|
8573
8660
|
this.bySocket.delete(existing.phone);
|
|
8574
8661
|
}
|
|
@@ -8586,15 +8673,15 @@ var RemoteHub = class {
|
|
|
8586
8673
|
this.hosts.set(deviceId, host);
|
|
8587
8674
|
this.remembered.set(deviceId, { hostSecret, sessionToken, deviceLabel });
|
|
8588
8675
|
this.bySocket.set(socket, { role: "host", deviceId });
|
|
8589
|
-
|
|
8590
|
-
if (host.phone)
|
|
8676
|
+
send2(socket, { type: "registered", deviceId, deviceLabel });
|
|
8677
|
+
if (host.phone) send2(socket, { type: "phone_joined" });
|
|
8591
8678
|
this.opts.onAuthorized?.(socket);
|
|
8592
8679
|
}
|
|
8593
8680
|
issueCode(socket) {
|
|
8594
8681
|
const bound = this.bySocket.get(socket);
|
|
8595
8682
|
const host = bound?.role === "host" ? this.hosts.get(bound.deviceId) : null;
|
|
8596
8683
|
if (!host || host.socket !== socket) {
|
|
8597
|
-
|
|
8684
|
+
send2(socket, { type: "error", message: "register this Mac before pairing" });
|
|
8598
8685
|
return;
|
|
8599
8686
|
}
|
|
8600
8687
|
for (const [code2, row2] of this.codes) {
|
|
@@ -8603,18 +8690,18 @@ var RemoteHub = class {
|
|
|
8603
8690
|
const code = newCode();
|
|
8604
8691
|
const expiresAt = Date.now() + CODE_TTL_MS;
|
|
8605
8692
|
this.codes.set(code, { code, deviceId: host.deviceId, expiresAt });
|
|
8606
|
-
|
|
8693
|
+
send2(socket, { type: "pairing_code", code, expiresAt });
|
|
8607
8694
|
}
|
|
8608
8695
|
pairPhone(socket, code) {
|
|
8609
8696
|
const row2 = this.codes.get(code);
|
|
8610
8697
|
if (!row2 || row2.expiresAt < Date.now()) {
|
|
8611
8698
|
this.codes.delete(code);
|
|
8612
|
-
|
|
8699
|
+
send2(socket, { type: "error", message: "pairing code expired" });
|
|
8613
8700
|
return;
|
|
8614
8701
|
}
|
|
8615
8702
|
const host = this.hosts.get(row2.deviceId);
|
|
8616
8703
|
if (!host) {
|
|
8617
|
-
|
|
8704
|
+
send2(socket, { type: "error", message: "Mac is offline" });
|
|
8618
8705
|
return;
|
|
8619
8706
|
}
|
|
8620
8707
|
this.attachPhone(socket, host, void 0, code);
|
|
@@ -8663,12 +8750,12 @@ var RemoteHub = class {
|
|
|
8663
8750
|
resumePhone(socket, sessionToken) {
|
|
8664
8751
|
const known = this.knownSession(sessionToken);
|
|
8665
8752
|
if (!known) {
|
|
8666
|
-
|
|
8753
|
+
send2(socket, { type: "error", message: "phone session expired \u2014 pair again" });
|
|
8667
8754
|
return;
|
|
8668
8755
|
}
|
|
8669
8756
|
const host = this.hosts.get(known.deviceId);
|
|
8670
8757
|
if (!host) {
|
|
8671
|
-
|
|
8758
|
+
send2(socket, { type: "host_offline" });
|
|
8672
8759
|
return;
|
|
8673
8760
|
}
|
|
8674
8761
|
this.attachPhone(socket, host, sessionToken);
|
|
@@ -8686,7 +8773,7 @@ var RemoteHub = class {
|
|
|
8686
8773
|
};
|
|
8687
8774
|
});
|
|
8688
8775
|
if (hosts.some((host) => host.deviceId)) this.opts.onAuthorized?.(socket);
|
|
8689
|
-
|
|
8776
|
+
send2(socket, { type: "hosts", hosts });
|
|
8690
8777
|
}
|
|
8691
8778
|
releasePhoneSocket(socket) {
|
|
8692
8779
|
const bound = this.bySocket.get(socket);
|
|
@@ -8696,7 +8783,7 @@ var RemoteHub = class {
|
|
|
8696
8783
|
if (prev?.phone === socket) {
|
|
8697
8784
|
prev.phone = null;
|
|
8698
8785
|
this.pushTokenBySocket.delete(socket);
|
|
8699
|
-
|
|
8786
|
+
send2(prev.socket, { type: "phone_left" });
|
|
8700
8787
|
}
|
|
8701
8788
|
}
|
|
8702
8789
|
attachPhone(socket, host, sessionToken, pairingCode) {
|
|
@@ -8731,36 +8818,36 @@ var RemoteHub = class {
|
|
|
8731
8818
|
if (created) this.opts.phoneSessions?.save(host.deviceId, token);
|
|
8732
8819
|
this.bySocket.set(socket, { role: "phone", deviceId: host.deviceId });
|
|
8733
8820
|
this.opts.onAuthorized?.(socket);
|
|
8734
|
-
|
|
8821
|
+
send2(socket, {
|
|
8735
8822
|
type: "paired",
|
|
8736
8823
|
deviceId: host.deviceId,
|
|
8737
8824
|
deviceLabel: host.deviceLabel,
|
|
8738
8825
|
sessionToken: token
|
|
8739
8826
|
});
|
|
8740
|
-
if (!already)
|
|
8827
|
+
if (!already) send2(host.socket, { type: "phone_joined" });
|
|
8741
8828
|
}
|
|
8742
8829
|
fromPhone(socket, msg) {
|
|
8743
8830
|
const bound = this.bySocket.get(socket);
|
|
8744
8831
|
const host = bound?.role === "phone" ? this.hosts.get(bound.deviceId) : null;
|
|
8745
8832
|
if (!host || host.phone !== socket) {
|
|
8746
|
-
|
|
8833
|
+
send2(socket, { type: "error", message: "pair this phone first" });
|
|
8747
8834
|
return;
|
|
8748
8835
|
}
|
|
8749
8836
|
if (msg.type === "stop") {
|
|
8750
|
-
|
|
8837
|
+
send2(host.socket, { type: "stop" });
|
|
8751
8838
|
return;
|
|
8752
8839
|
}
|
|
8753
|
-
|
|
8840
|
+
send2(host.socket, { type: "inbound", text: msg.text });
|
|
8754
8841
|
}
|
|
8755
8842
|
fromHost(socket, msg) {
|
|
8756
8843
|
const bound = this.bySocket.get(socket);
|
|
8757
8844
|
const host = bound?.role === "host" ? this.hosts.get(bound.deviceId) : null;
|
|
8758
8845
|
if (!host || host.socket !== socket || !host.phone) return;
|
|
8759
8846
|
if (msg.type === "assistant") {
|
|
8760
|
-
|
|
8847
|
+
send2(host.phone, { type: "assistant", text: msg.text });
|
|
8761
8848
|
return;
|
|
8762
8849
|
}
|
|
8763
|
-
|
|
8850
|
+
send2(host.phone, { type: "ask_user", text: msg.text, questions: msg.questions });
|
|
8764
8851
|
}
|
|
8765
8852
|
registerPush(socket, token, sessionTokens) {
|
|
8766
8853
|
const deviceIds = [];
|
|
@@ -9021,6 +9108,47 @@ var RelayAccountStore = class {
|
|
|
9021
9108
|
throw err;
|
|
9022
9109
|
}
|
|
9023
9110
|
}
|
|
9111
|
+
/**
|
|
9112
|
+
* Macs registered on the account that owns `accountToken`.
|
|
9113
|
+
* `null` means the credential is missing or no longer valid.
|
|
9114
|
+
*/
|
|
9115
|
+
listMacs(accountToken) {
|
|
9116
|
+
const accountId = this.verifyCredential(accountToken);
|
|
9117
|
+
if (!accountId) return null;
|
|
9118
|
+
const rows = this.db.prepare(
|
|
9119
|
+
"SELECT device_id, device_label, created_at FROM devices WHERE account_id = ? ORDER BY created_at, device_id"
|
|
9120
|
+
).all(accountId);
|
|
9121
|
+
return rows.map((row2) => ({
|
|
9122
|
+
deviceId: row2.device_id,
|
|
9123
|
+
deviceLabel: row2.device_label,
|
|
9124
|
+
createdAt: row2.created_at
|
|
9125
|
+
}));
|
|
9126
|
+
}
|
|
9127
|
+
/**
|
|
9128
|
+
* Remove one Mac from the signed-in account. The row no longer counts
|
|
9129
|
+
* toward the cap. The account and its other credentials stay.
|
|
9130
|
+
*/
|
|
9131
|
+
forgetMac(accountToken, deviceId) {
|
|
9132
|
+
const id = deviceId.trim();
|
|
9133
|
+
const accountId = this.verifyCredential(accountToken);
|
|
9134
|
+
if (!accountId) return { ok: false, message: "sign in required" };
|
|
9135
|
+
if (!id) return { ok: false, message: "Mac not found" };
|
|
9136
|
+
this.db.exec("BEGIN");
|
|
9137
|
+
try {
|
|
9138
|
+
const device = this.db.prepare("SELECT account_id FROM devices WHERE device_id = ?").get(id);
|
|
9139
|
+
if (!device || device.account_id !== accountId) {
|
|
9140
|
+
this.db.exec("ROLLBACK");
|
|
9141
|
+
return { ok: false, message: "Mac not found" };
|
|
9142
|
+
}
|
|
9143
|
+
this.db.prepare("DELETE FROM push_tokens WHERE device_id = ?").run(id);
|
|
9144
|
+
this.db.prepare("DELETE FROM devices WHERE device_id = ?").run(id);
|
|
9145
|
+
this.db.exec("COMMIT");
|
|
9146
|
+
return { ok: true };
|
|
9147
|
+
} catch (err) {
|
|
9148
|
+
this.db.exec("ROLLBACK");
|
|
9149
|
+
throw err;
|
|
9150
|
+
}
|
|
9151
|
+
}
|
|
9024
9152
|
/** Store a phone pairing when it is created. A later process looks it up on a memory miss. */
|
|
9025
9153
|
savePhoneSession(deviceId, sessionToken) {
|
|
9026
9154
|
const id = deviceId.trim();
|
|
@@ -9204,10 +9332,10 @@ function entireAuthorizeUrl(clientId, redirectUri, state, codeChallenge) {
|
|
|
9204
9332
|
return url.toString();
|
|
9205
9333
|
}
|
|
9206
9334
|
async function readJson2(res) {
|
|
9207
|
-
const
|
|
9208
|
-
if (!
|
|
9335
|
+
const text6 = await res.text();
|
|
9336
|
+
if (!text6) return {};
|
|
9209
9337
|
try {
|
|
9210
|
-
return JSON.parse(
|
|
9338
|
+
return JSON.parse(text6);
|
|
9211
9339
|
} catch {
|
|
9212
9340
|
throw new Error("Entire returned a non-JSON response.");
|
|
9213
9341
|
}
|
|
@@ -9286,6 +9414,8 @@ var REMOTE_LOGIN_PATH = "/remote/login";
|
|
|
9286
9414
|
var REMOTE_OAUTH_CALLBACK_PATH = "/remote/oauth/callback";
|
|
9287
9415
|
var REMOTE_OAUTH_RESULT_PATH = "/remote/oauth/result";
|
|
9288
9416
|
var REMOTE_LOGOUT_PATH = "/remote/logout";
|
|
9417
|
+
var REMOTE_MACS_PATH = "/remote/macs";
|
|
9418
|
+
var REMOTE_MACS_FORGET_PATH = "/remote/macs/forget";
|
|
9289
9419
|
var STATE_RE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
9290
9420
|
var LOGIN_TTL_MS = 10 * 60 * 1e3;
|
|
9291
9421
|
var EMPTY_AUTH = { codeVerifier: null, issuer: null };
|
|
@@ -9357,10 +9487,10 @@ function relayAuthorizeUrl(provider, client, redirectUri, state, ctx = EMPTY_AUT
|
|
|
9357
9487
|
return GIT_HOST_AUTH[provider].authorizeUrl(client, redirectUri, state, ctx);
|
|
9358
9488
|
}
|
|
9359
9489
|
async function readJson3(res) {
|
|
9360
|
-
const
|
|
9361
|
-
if (!
|
|
9490
|
+
const text6 = await res.text();
|
|
9491
|
+
if (!text6) return {};
|
|
9362
9492
|
try {
|
|
9363
|
-
return JSON.parse(
|
|
9493
|
+
return JSON.parse(text6);
|
|
9364
9494
|
} catch {
|
|
9365
9495
|
throw new Error("Sign-in provider returned a non-JSON response.");
|
|
9366
9496
|
}
|
|
@@ -9417,9 +9547,9 @@ async function readBody2(req) {
|
|
|
9417
9547
|
if (size > 8192) throw new Error("body too large");
|
|
9418
9548
|
chunks.push(buf);
|
|
9419
9549
|
}
|
|
9420
|
-
const
|
|
9421
|
-
if (!
|
|
9422
|
-
return JSON.parse(
|
|
9550
|
+
const text6 = Buffer.concat(chunks).toString("utf8").trim();
|
|
9551
|
+
if (!text6) return {};
|
|
9552
|
+
return JSON.parse(text6);
|
|
9423
9553
|
}
|
|
9424
9554
|
function sendJson2(res, status, body) {
|
|
9425
9555
|
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
@@ -9429,6 +9559,12 @@ function sendHtml2(res, status, title, body) {
|
|
|
9429
9559
|
res.writeHead(status, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
9430
9560
|
res.end(oauthReturnPage(title, body));
|
|
9431
9561
|
}
|
|
9562
|
+
function bearerToken(req) {
|
|
9563
|
+
const header2 = req.headers.authorization;
|
|
9564
|
+
if (typeof header2 !== "string") return "";
|
|
9565
|
+
const match = /^Bearer\s+(\S+)/i.exec(header2.trim());
|
|
9566
|
+
return match?.[1]?.trim() ?? "";
|
|
9567
|
+
}
|
|
9432
9568
|
async function handleRelayAccountHttp(opts) {
|
|
9433
9569
|
const reqUrl = opts.req.url || "/";
|
|
9434
9570
|
const path2 = reqUrl.split("?")[0];
|
|
@@ -9553,6 +9689,38 @@ async function handleRelayAccountHttp(opts) {
|
|
|
9553
9689
|
});
|
|
9554
9690
|
return true;
|
|
9555
9691
|
}
|
|
9692
|
+
if (method === "GET" && path2 === REMOTE_MACS_PATH) {
|
|
9693
|
+
const macs = opts.store.listMacs(bearerToken(opts.req));
|
|
9694
|
+
if (!macs) {
|
|
9695
|
+
sendJson2(opts.res, 401, { ok: false, error: "sign in required" });
|
|
9696
|
+
return true;
|
|
9697
|
+
}
|
|
9698
|
+
sendJson2(opts.res, 200, { ok: true, macs });
|
|
9699
|
+
return true;
|
|
9700
|
+
}
|
|
9701
|
+
if (method === "POST" && path2 === REMOTE_MACS_FORGET_PATH) {
|
|
9702
|
+
let body;
|
|
9703
|
+
try {
|
|
9704
|
+
body = await readBody2(opts.req);
|
|
9705
|
+
} catch {
|
|
9706
|
+
sendJson2(opts.res, 400, { ok: false, error: "invalid request" });
|
|
9707
|
+
return true;
|
|
9708
|
+
}
|
|
9709
|
+
const token = (typeof body.accountToken === "string" ? body.accountToken.trim() : "") || bearerToken(opts.req);
|
|
9710
|
+
const deviceId = typeof body.deviceId === "string" ? body.deviceId : "";
|
|
9711
|
+
const result = opts.store.forgetMac(token, deviceId);
|
|
9712
|
+
if (!result.ok) {
|
|
9713
|
+
const status = result.message === "sign in required" ? 401 : 404;
|
|
9714
|
+
sendJson2(opts.res, status, { ok: false, error: result.message });
|
|
9715
|
+
return true;
|
|
9716
|
+
}
|
|
9717
|
+
try {
|
|
9718
|
+
opts.onMacForgotten?.(deviceId.trim());
|
|
9719
|
+
} catch {
|
|
9720
|
+
}
|
|
9721
|
+
sendJson2(opts.res, 200, { ok: true });
|
|
9722
|
+
return true;
|
|
9723
|
+
}
|
|
9556
9724
|
if (method === "POST" && path2 === REMOTE_LOGOUT_PATH) {
|
|
9557
9725
|
let body;
|
|
9558
9726
|
try {
|
|
@@ -9689,7 +9857,8 @@ async function startRelayServer(opts) {
|
|
|
9689
9857
|
oauth: relayOAuth,
|
|
9690
9858
|
sessions: accountSessions,
|
|
9691
9859
|
publicOrigin: publicOrigin(),
|
|
9692
|
-
fetchImpl: opts.fetchImpl
|
|
9860
|
+
fetchImpl: opts.fetchImpl,
|
|
9861
|
+
onMacForgotten: (deviceId) => remoteHub.forgetDevice(deviceId)
|
|
9693
9862
|
})) {
|
|
9694
9863
|
return;
|
|
9695
9864
|
}
|
|
@@ -9957,7 +10126,7 @@ async function startHeadlessHost(opts) {
|
|
|
9957
10126
|
};
|
|
9958
10127
|
const refreshRunning = async () => {
|
|
9959
10128
|
try {
|
|
9960
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
10129
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-3I2FLEZL.js");
|
|
9961
10130
|
agentsRunning = getOrchestrator2().getRuntime().running;
|
|
9962
10131
|
} catch {
|
|
9963
10132
|
agentsRunning = 0;
|
|
@@ -10045,9 +10214,9 @@ function flatInterfaces() {
|
|
|
10045
10214
|
}
|
|
10046
10215
|
|
|
10047
10216
|
// src/integrations/cursor-git.ts
|
|
10048
|
-
function parseOriginAuthStatus(
|
|
10049
|
-
const account =
|
|
10050
|
-
const authMethod =
|
|
10217
|
+
function parseOriginAuthStatus(text6) {
|
|
10218
|
+
const account = text6.match(/^Account:\s+(.+)$/m)?.[1]?.trim() || null;
|
|
10219
|
+
const authMethod = text6.match(/^Auth method:\s+(.+)$/m)?.[1]?.trim() || null;
|
|
10051
10220
|
return { account, authMethod };
|
|
10052
10221
|
}
|
|
10053
10222
|
async function getCursorGitStatus() {
|
|
@@ -10062,9 +10231,9 @@ async function getCursorGitStatus() {
|
|
|
10062
10231
|
};
|
|
10063
10232
|
}
|
|
10064
10233
|
const status = await run("origin", ["auth", "status"], { reject: false, timeoutMs: 15e3 });
|
|
10065
|
-
const
|
|
10234
|
+
const text6 = `${status.stdout}
|
|
10066
10235
|
${status.stderr}`;
|
|
10067
|
-
const parsed = parseOriginAuthStatus(
|
|
10236
|
+
const parsed = parseOriginAuthStatus(text6);
|
|
10068
10237
|
if (status.exitCode === 0 && parsed.account) {
|
|
10069
10238
|
return {
|
|
10070
10239
|
installed: true,
|
|
@@ -10116,8 +10285,8 @@ async function setupCursorGit() {
|
|
|
10116
10285
|
}
|
|
10117
10286
|
|
|
10118
10287
|
// src/integrations/entire-git.ts
|
|
10119
|
-
function parseEntireAuthContexts(
|
|
10120
|
-
for (const line of
|
|
10288
|
+
function parseEntireAuthContexts(text6) {
|
|
10289
|
+
for (const line of text6.split("\n")) {
|
|
10121
10290
|
if (!/\(active\)/i.test(line)) continue;
|
|
10122
10291
|
const cols = line.replace(/\(active\)/gi, "").trim().split(/\s{2,}/).map((part) => part.trim()).filter(Boolean);
|
|
10123
10292
|
const handle = cols[1] || cols[0] || null;
|
|
@@ -10491,16 +10660,16 @@ var PASTE_ATTACH_MIN_CHARS = 1200;
|
|
|
10491
10660
|
var PASTE_ATTACH_MIN_LINES = 15;
|
|
10492
10661
|
var PASTED_NAME_RE = /^Pasted text #(\d+)\.txt$/i;
|
|
10493
10662
|
var PASTED_NAME_ALT_RE = /^pasted-(\d+)\.txt$/i;
|
|
10494
|
-
function pastedTextStats(
|
|
10495
|
-
const chars =
|
|
10663
|
+
function pastedTextStats(text6) {
|
|
10664
|
+
const chars = text6.length;
|
|
10496
10665
|
if (chars === 0) return { chars: 0, lines: 0 };
|
|
10497
|
-
const lines =
|
|
10666
|
+
const lines = text6.split(/\r\n|\r|\n/).length;
|
|
10498
10667
|
return { chars, lines };
|
|
10499
10668
|
}
|
|
10500
|
-
function shouldAttachPastedText(
|
|
10501
|
-
const trimmed =
|
|
10669
|
+
function shouldAttachPastedText(text6) {
|
|
10670
|
+
const trimmed = text6.trim();
|
|
10502
10671
|
if (!trimmed) return false;
|
|
10503
|
-
const { chars, lines } = pastedTextStats(
|
|
10672
|
+
const { chars, lines } = pastedTextStats(text6);
|
|
10504
10673
|
return chars >= PASTE_ATTACH_MIN_CHARS || lines >= PASTE_ATTACH_MIN_LINES;
|
|
10505
10674
|
}
|
|
10506
10675
|
function nextPastedTextName(existing) {
|
|
@@ -10511,13 +10680,13 @@ function nextPastedTextName(existing) {
|
|
|
10511
10680
|
}
|
|
10512
10681
|
return `Pasted text #${max + 1}.txt`;
|
|
10513
10682
|
}
|
|
10514
|
-
function buildPastedTextAttachment(
|
|
10683
|
+
function buildPastedTextAttachment(text6, opts) {
|
|
10515
10684
|
return {
|
|
10516
10685
|
id: opts?.id ?? randomUUID5(),
|
|
10517
10686
|
name: opts?.name ?? "Pasted text #1.txt",
|
|
10518
10687
|
kind: "file",
|
|
10519
10688
|
path: opts?.path,
|
|
10520
|
-
content:
|
|
10689
|
+
content: text6
|
|
10521
10690
|
};
|
|
10522
10691
|
}
|
|
10523
10692
|
|
|
@@ -10537,8 +10706,8 @@ function parseChatLink(href) {
|
|
|
10537
10706
|
const match = CHAT_LINK_RE.exec(href.trim());
|
|
10538
10707
|
return match?.[1] ?? null;
|
|
10539
10708
|
}
|
|
10540
|
-
function linkifyChatUrls(
|
|
10541
|
-
return
|
|
10709
|
+
function linkifyChatUrls(text6) {
|
|
10710
|
+
return text6.replace(BARE_CHAT_LINK_RE, (url) => {
|
|
10542
10711
|
const id = parseChatLink(url);
|
|
10543
10712
|
if (!id) return url;
|
|
10544
10713
|
const label = id.length > 8 ? id.slice(0, 8) : id;
|
|
@@ -10594,7 +10763,7 @@ function createClippedMcpServer() {
|
|
|
10594
10763
|
}
|
|
10595
10764
|
|
|
10596
10765
|
// src/mcp/server.ts
|
|
10597
|
-
import { z as
|
|
10766
|
+
import { z as z10 } from "zod";
|
|
10598
10767
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
10599
10768
|
import { basename as basename3 } from "path";
|
|
10600
10769
|
|
|
@@ -10734,6 +10903,7 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
|
|
|
10734
10903
|
sourceType: args.sourceType,
|
|
10735
10904
|
sourceRef: args.sourceRef,
|
|
10736
10905
|
agent: opts.agent,
|
|
10906
|
+
...opts.agent === "acp" ? { acpHarness: args.acpHarness } : {},
|
|
10737
10907
|
model: opts.model,
|
|
10738
10908
|
effort: opts.effort,
|
|
10739
10909
|
fast: opts.fast,
|
|
@@ -10758,6 +10928,7 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
|
|
|
10758
10928
|
branchName: thread.branchName,
|
|
10759
10929
|
worktreePath: thread.worktreePath,
|
|
10760
10930
|
agent: thread.agent,
|
|
10931
|
+
...thread.acpHarness ? { acpHarness: thread.acpHarness } : {},
|
|
10761
10932
|
model: thread.model,
|
|
10762
10933
|
status: thread.status,
|
|
10763
10934
|
cowboy: Boolean(thread.cowboy),
|
|
@@ -10783,9 +10954,9 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
|
|
|
10783
10954
|
function lastMessagePreview(messages, max = 160) {
|
|
10784
10955
|
if (!messages?.length) return null;
|
|
10785
10956
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
10786
|
-
const
|
|
10787
|
-
if (!
|
|
10788
|
-
const flat =
|
|
10957
|
+
const text6 = messages[i]?.text?.trim();
|
|
10958
|
+
if (!text6 || isInternalAgentStatusText(text6) || isInjectedNoticeText(text6)) continue;
|
|
10959
|
+
const flat = text6.replace(/\s+/g, " ");
|
|
10789
10960
|
return flat.length > max ? `${flat.slice(0, max)}\u2026` : flat;
|
|
10790
10961
|
}
|
|
10791
10962
|
return null;
|
|
@@ -10815,15 +10986,15 @@ var CRUSH_COMMENT_MAX_CHARS = 16e3;
|
|
|
10815
10986
|
var CRUSH_BODY_MIN_CHARS = 12e3;
|
|
10816
10987
|
var CRUSH_BODY_MAX_CHARS = 8e3;
|
|
10817
10988
|
var NEAR_DUP_JACCARD = 0.92;
|
|
10818
|
-
function looksLikeMustKeep(
|
|
10819
|
-
return MUST_KEEP_TEXT_RE.test(
|
|
10989
|
+
function looksLikeMustKeep(text6) {
|
|
10990
|
+
return MUST_KEEP_TEXT_RE.test(text6);
|
|
10820
10991
|
}
|
|
10821
|
-
function normalizeText(
|
|
10822
|
-
return
|
|
10992
|
+
function normalizeText(text6) {
|
|
10993
|
+
return text6.replace(/\s+/g, " ").trim().toLowerCase();
|
|
10823
10994
|
}
|
|
10824
|
-
function wordSet(
|
|
10995
|
+
function wordSet(text6) {
|
|
10825
10996
|
return new Set(
|
|
10826
|
-
|
|
10997
|
+
text6.toLowerCase().split(/\W+/).filter((w) => w.length > 2)
|
|
10827
10998
|
);
|
|
10828
10999
|
}
|
|
10829
11000
|
function jaccard(a, b) {
|
|
@@ -10835,11 +11006,11 @@ function jaccard(a, b) {
|
|
|
10835
11006
|
const union = a.size + b.size - inter;
|
|
10836
11007
|
return union === 0 ? 0 : inter / union;
|
|
10837
11008
|
}
|
|
10838
|
-
function importance(
|
|
10839
|
-
let score =
|
|
10840
|
-
if (/```/.test(
|
|
10841
|
-
if (/https?:\/\//.test(
|
|
10842
|
-
if (looksLikeMustKeep(
|
|
11009
|
+
function importance(text6) {
|
|
11010
|
+
let score = text6.length;
|
|
11011
|
+
if (/```/.test(text6)) score += 400;
|
|
11012
|
+
if (/https?:\/\//.test(text6)) score += 50;
|
|
11013
|
+
if (looksLikeMustKeep(text6)) score += 1e4;
|
|
10843
11014
|
return score;
|
|
10844
11015
|
}
|
|
10845
11016
|
function meanStd(values) {
|
|
@@ -10853,15 +11024,15 @@ function dedupTextItems(items, getText) {
|
|
|
10853
11024
|
const keptNorm = [];
|
|
10854
11025
|
const keptWords = [];
|
|
10855
11026
|
for (const item of items) {
|
|
10856
|
-
const
|
|
10857
|
-
const norm = normalizeText(
|
|
11027
|
+
const text6 = getText(item);
|
|
11028
|
+
const norm = normalizeText(text6);
|
|
10858
11029
|
if (!norm) {
|
|
10859
11030
|
kept.push(item);
|
|
10860
11031
|
keptNorm.push(norm);
|
|
10861
|
-
keptWords.push(wordSet(
|
|
11032
|
+
keptWords.push(wordSet(text6));
|
|
10862
11033
|
continue;
|
|
10863
11034
|
}
|
|
10864
|
-
const words = wordSet(
|
|
11035
|
+
const words = wordSet(text6);
|
|
10865
11036
|
let dupAt = -1;
|
|
10866
11037
|
for (let i = 0; i < kept.length; i++) {
|
|
10867
11038
|
if (keptNorm[i] === norm) {
|
|
@@ -10879,7 +11050,7 @@ function dedupTextItems(items, getText) {
|
|
|
10879
11050
|
keptWords.push(words);
|
|
10880
11051
|
continue;
|
|
10881
11052
|
}
|
|
10882
|
-
if (
|
|
11053
|
+
if (text6.length > getText(kept[dupAt]).length) {
|
|
10883
11054
|
kept[dupAt] = item;
|
|
10884
11055
|
keptNorm[dupAt] = norm;
|
|
10885
11056
|
keptWords[dupAt] = words;
|
|
@@ -10920,8 +11091,8 @@ function crushTextItems(items, getText, opts = {}) {
|
|
|
10920
11091
|
const outlierFloor = mean + 2 * std;
|
|
10921
11092
|
const mustKeep = /* @__PURE__ */ new Set();
|
|
10922
11093
|
unique.forEach((item, i) => {
|
|
10923
|
-
const
|
|
10924
|
-
if (looksLikeMustKeep(
|
|
11094
|
+
const text6 = getText(item);
|
|
11095
|
+
if (looksLikeMustKeep(text6) || text6.length > outlierFloor) mustKeep.add(i);
|
|
10925
11096
|
});
|
|
10926
11097
|
const remainingIdx = unique.map((_, i) => i).filter((i) => !mustKeep.has(i));
|
|
10927
11098
|
let used = [...mustKeep].reduce((n, i) => n + lengths[i], 0);
|
|
@@ -10963,9 +11134,9 @@ function crushTextItems(items, getText, opts = {}) {
|
|
|
10963
11134
|
reason: "budget"
|
|
10964
11135
|
};
|
|
10965
11136
|
}
|
|
10966
|
-
function splitBlocks(
|
|
10967
|
-
if (/\n\n/.test(
|
|
10968
|
-
return
|
|
11137
|
+
function splitBlocks(text6) {
|
|
11138
|
+
if (/\n\n/.test(text6)) return text6.split(/\n\n+/);
|
|
11139
|
+
return text6.split("\n");
|
|
10969
11140
|
}
|
|
10970
11141
|
function capOversizedBlock(block, maxChars) {
|
|
10971
11142
|
if (block.length <= maxChars) return block;
|
|
@@ -10977,8 +11148,8 @@ function capOversizedBlock(block, maxChars) {
|
|
|
10977
11148
|
|
|
10978
11149
|
${block.slice(-tail)}`;
|
|
10979
11150
|
}
|
|
10980
|
-
function crushMarkdown(
|
|
10981
|
-
const original =
|
|
11151
|
+
function crushMarkdown(text6, opts) {
|
|
11152
|
+
const original = text6 ?? "";
|
|
10982
11153
|
const minChars = opts?.minChars ?? CRUSH_BODY_MIN_CHARS;
|
|
10983
11154
|
const maxChars = opts?.maxChars ?? CRUSH_BODY_MAX_CHARS;
|
|
10984
11155
|
if (original.length < minChars) {
|
|
@@ -11068,13 +11239,13 @@ function withComments(comments, meta) {
|
|
|
11068
11239
|
}
|
|
11069
11240
|
return { comments: crushed.items, meta };
|
|
11070
11241
|
}
|
|
11071
|
-
function withBody(
|
|
11072
|
-
const crushed = crushMarkdown(
|
|
11242
|
+
function withBody(text6, meta) {
|
|
11243
|
+
const crushed = crushMarkdown(text6);
|
|
11073
11244
|
if (crushed.truncated) {
|
|
11074
11245
|
meta.body = { originalChars: crushed.originalChars };
|
|
11075
11246
|
return { value: crushed.text, meta };
|
|
11076
11247
|
}
|
|
11077
|
-
return { value:
|
|
11248
|
+
return { value: text6, meta };
|
|
11078
11249
|
}
|
|
11079
11250
|
function attachCrush(payload, meta) {
|
|
11080
11251
|
if (!meta.comments && !meta.body) return payload;
|
|
@@ -11786,9 +11957,9 @@ async function runPosthogApi(input) {
|
|
|
11786
11957
|
body,
|
|
11787
11958
|
signal: AbortSignal.timeout(POSTHOG_TIMEOUT_MS)
|
|
11788
11959
|
});
|
|
11789
|
-
const
|
|
11790
|
-
const truncated =
|
|
11791
|
-
const slice = truncated ?
|
|
11960
|
+
const text6 = await res.text();
|
|
11961
|
+
const truncated = text6.length > POSTHOG_RESPONSE_MAX_CHARS;
|
|
11962
|
+
const slice = truncated ? text6.slice(0, POSTHOG_RESPONSE_MAX_CHARS) : text6;
|
|
11792
11963
|
let parsed = slice;
|
|
11793
11964
|
if (slice.trim()) {
|
|
11794
11965
|
try {
|
|
@@ -11931,7 +12102,7 @@ function registerArchiveTools(server, orch) {
|
|
|
11931
12102
|
);
|
|
11932
12103
|
server.tool(
|
|
11933
12104
|
"archive_chat",
|
|
11934
|
-
"Archive one agent chat: stop the turn and move that chat to Settings \u2192 History. Other agents on the workspace stay, and the worktree is removed only when this is the last agent. Orchestration chats archive without removing a project checkout. Refuses the cloud coordinator. To archive every agent on a checkout, use archive_workspace. Commit, push, and open PRs via ask_git before archiving when the work should be kept. Merge only when the user explicitly asked.",
|
|
12105
|
+
"Archive one agent chat: stop the turn and move that chat to Settings \u2192 History. Other agents on the workspace stay, and the worktree is removed only when this is the last agent. Uncommitted and untracked files are saved on a hidden git ref and put back uncommitted if that checkout is restored. If that snapshot fails, the checkout stays. History Delete does not keep the snapshot. Orchestration chats archive without removing a project checkout. Refuses the cloud coordinator. To archive every agent on a checkout, use archive_workspace. Commit, push, and open PRs via ask_git before archiving when the work should be kept. Merge only when the user explicitly asked.",
|
|
11935
12106
|
{ ref: z6.string().describe("Chat id to archive") },
|
|
11936
12107
|
async ({ ref }) => {
|
|
11937
12108
|
const t = orch.getThread(ref);
|
|
@@ -12234,10 +12405,82 @@ function registerScheduleTools(server) {
|
|
|
12234
12405
|
);
|
|
12235
12406
|
}
|
|
12236
12407
|
|
|
12237
|
-
// src/mcp/
|
|
12408
|
+
// src/mcp/follow-up-tools.ts
|
|
12238
12409
|
import { z as z8 } from "zod";
|
|
12239
|
-
|
|
12410
|
+
function text5(payload, isError = false) {
|
|
12411
|
+
return mcpJson(payload, isError);
|
|
12412
|
+
}
|
|
12240
12413
|
function callerThread() {
|
|
12414
|
+
const id = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim() || "";
|
|
12415
|
+
if (!id) return null;
|
|
12416
|
+
return findThreadByRef(id);
|
|
12417
|
+
}
|
|
12418
|
+
async function baselineCi(thread) {
|
|
12419
|
+
const selector = resolvePrSelector(thread);
|
|
12420
|
+
if (!selector) return "none";
|
|
12421
|
+
try {
|
|
12422
|
+
const checks = await getPrCiChecks(thread.worktreePath, selector);
|
|
12423
|
+
return ciChecksSettled(checks);
|
|
12424
|
+
} catch {
|
|
12425
|
+
return "unknown";
|
|
12426
|
+
}
|
|
12427
|
+
}
|
|
12428
|
+
function registerFollowUpTools(server) {
|
|
12429
|
+
server.tool(
|
|
12430
|
+
"list_follow_ups",
|
|
12431
|
+
"List follow-ups on this chat. kind=ci wakes when GitHub checks finish. kind=at wakes at a time. A running turn is not interrupted.",
|
|
12432
|
+
{},
|
|
12433
|
+
async () => {
|
|
12434
|
+
const thread = callerThread();
|
|
12435
|
+
if (!thread) return text5({ error: "This chat id is missing" }, true);
|
|
12436
|
+
return text5({ followUps: normalizeChatFollowUps(thread.followUps) });
|
|
12437
|
+
}
|
|
12438
|
+
);
|
|
12439
|
+
server.tool(
|
|
12440
|
+
"create_follow_up",
|
|
12441
|
+
"Register a follow-up on THIS chat. kind=ci sends the prompt when GitHub checks on this chat\u2019s PR finish (pass or fail). Checks that are already finished do not send until a later run finishes. A failed checks read does not count as finished or in progress. A CI follow-up that is still pending at deadline (default 7 days) ends silently. kind=at sends at `30m`, `2h`, `1d`, or an ISO time and waits behind a turn that is already running. Cap 10.",
|
|
12442
|
+
{
|
|
12443
|
+
kind: z8.enum(["ci", "at"]),
|
|
12444
|
+
prompt: z8.string(),
|
|
12445
|
+
at: z8.string().optional(),
|
|
12446
|
+
deadline: z8.string().optional()
|
|
12447
|
+
},
|
|
12448
|
+
async ({ kind, prompt, at, deadline }) => {
|
|
12449
|
+
const thread = callerThread();
|
|
12450
|
+
if (!thread) return text5({ error: "This chat id is missing" }, true);
|
|
12451
|
+
if (thread.status === "archived") return text5({ error: "This chat is archived" }, true);
|
|
12452
|
+
const existing = normalizeChatFollowUps(thread.followUps);
|
|
12453
|
+
const ciBaseline = kind === "ci" ? await baselineCi(thread) : void 0;
|
|
12454
|
+
const added = addChatFollowUp(
|
|
12455
|
+
existing,
|
|
12456
|
+
{ kind, prompt, at, deadline, ciBaseline },
|
|
12457
|
+
/* @__PURE__ */ new Date()
|
|
12458
|
+
);
|
|
12459
|
+
if (!added.ok) return text5({ error: added.error }, true);
|
|
12460
|
+
updateThread(thread.id, { followUps: added.followUps });
|
|
12461
|
+
return text5({ followUps: added.followUps });
|
|
12462
|
+
}
|
|
12463
|
+
);
|
|
12464
|
+
server.tool(
|
|
12465
|
+
"delete_follow_up",
|
|
12466
|
+
"Remove one follow-up from this chat by id.",
|
|
12467
|
+
{ id: z8.string() },
|
|
12468
|
+
async ({ id }) => {
|
|
12469
|
+
const thread = callerThread();
|
|
12470
|
+
if (!thread) return text5({ error: "This chat id is missing" }, true);
|
|
12471
|
+
const existing = normalizeChatFollowUps(thread.followUps);
|
|
12472
|
+
const followUps = existing.filter((item) => item.id !== id.trim());
|
|
12473
|
+
if (followUps.length === existing.length) return text5({ error: "Follow-up not found" }, true);
|
|
12474
|
+
updateThread(thread.id, { followUps });
|
|
12475
|
+
return text5({ followUps });
|
|
12476
|
+
}
|
|
12477
|
+
);
|
|
12478
|
+
}
|
|
12479
|
+
|
|
12480
|
+
// src/mcp/order-tools.ts
|
|
12481
|
+
import { z as z9 } from "zod";
|
|
12482
|
+
var kindSchema = z9.enum(["pr", "issue", "workspace", "orchestration"]);
|
|
12483
|
+
function callerThread2() {
|
|
12241
12484
|
const id = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim();
|
|
12242
12485
|
if (!id) return null;
|
|
12243
12486
|
return readThread(id);
|
|
@@ -12250,7 +12493,7 @@ function readCheckoutPlan(caller) {
|
|
|
12250
12493
|
return readPlanFile(root);
|
|
12251
12494
|
}
|
|
12252
12495
|
function orchestrationOwnerId(worktree) {
|
|
12253
|
-
const caller =
|
|
12496
|
+
const caller = callerThread2();
|
|
12254
12497
|
if (!caller) {
|
|
12255
12498
|
throw new Error(
|
|
12256
12499
|
worktree ? "No worktree chat is bound to this tool." : "No orchestration chat is bound to this tool."
|
|
@@ -12286,10 +12529,10 @@ function registerOrderTools(server) {
|
|
|
12286
12529
|
try {
|
|
12287
12530
|
const owner = orchestrationOwnerId(worktree);
|
|
12288
12531
|
const plan = getOrderPlan(owner);
|
|
12289
|
-
const caller =
|
|
12532
|
+
const caller = callerThread2();
|
|
12290
12533
|
if (!plan) {
|
|
12291
|
-
const
|
|
12292
|
-
return { content: [{ type: "text", text:
|
|
12534
|
+
const text6 = worktree ? "This checkout's orchestrator has no plan yet." : "This chat has no plan. set_plan drafts one. Then show_plan so the user sees it.";
|
|
12535
|
+
return { content: [{ type: "text", text: text6 }] };
|
|
12293
12536
|
}
|
|
12294
12537
|
const rows = listOrderRows(plan.id);
|
|
12295
12538
|
const place = worktree && caller ? `${formatOrderPlace(rows, orderSnapshotFromThread(caller))}
|
|
@@ -12308,16 +12551,16 @@ function registerOrderTools(server) {
|
|
|
12308
12551
|
worktree ? "Change what this checkout waits on. Omit subject to mean this workspace (hold=merge uses this PR; hold=start on a ticket uses this issue). gate=in-main (met when that PR is merged) or in-prod (stays waiting until satisfy_dependency). hold=start means do not begin; hold=merge means do not merge. You cannot set a dependency for a different checkout. show_plan so the user sees the change." : "Record a step on this orchestration plan. waitsOn must reach gate before subject can hold. gate=in-main is met when that PR is merged; gate=in-prod stays waiting until satisfy_dependency. hold=start blocks starting the subject; hold=merge blocks merging it. Example: PR 1 in prod before PR 2 can merge; PR 3 in main before issue 4 can start. Pass repoPath when the same PR number exists in more than one project. Worktree agents set their own checkout and can omit subject. Then show_plan so the user sees it.",
|
|
12309
12552
|
{
|
|
12310
12553
|
waitsOnKind: kindSchema.describe("What must happen first: pr, issue, workspace, or orchestration"),
|
|
12311
|
-
waitsOnRef:
|
|
12312
|
-
waitsOnRepoPath:
|
|
12313
|
-
waitsOnLabel:
|
|
12314
|
-
gate:
|
|
12315
|
-
hold:
|
|
12554
|
+
waitsOnRef: z9.string().describe("PR number (12), issue id (ENG-4), or workspace chat id / worktree path"),
|
|
12555
|
+
waitsOnRepoPath: z9.string().optional().describe("Project path when a PR or issue number is not unique"),
|
|
12556
|
+
waitsOnLabel: z9.string().optional().describe("Short label on the planner"),
|
|
12557
|
+
gate: z9.enum(["in-main", "in-prod"]).describe("in-main: merged to the default branch. in-prod: deployed; mark with satisfy_dependency"),
|
|
12558
|
+
hold: z9.enum(["start", "merge"]).describe("start: subject cannot begin. merge: subject cannot merge"),
|
|
12316
12559
|
subjectKind: kindSchema.optional().describe("What is held. Required from orchestration. Omit on a worktree to mean this checkout."),
|
|
12317
|
-
subjectRef:
|
|
12318
|
-
subjectRepoPath:
|
|
12319
|
-
subjectLabel:
|
|
12320
|
-
note:
|
|
12560
|
+
subjectRef: z9.string().optional().describe("PR number, issue id, or workspace ref for the subject"),
|
|
12561
|
+
subjectRepoPath: z9.string().optional(),
|
|
12562
|
+
subjectLabel: z9.string().optional(),
|
|
12563
|
+
note: z9.string().optional().describe("Why this order matters")
|
|
12321
12564
|
},
|
|
12322
12565
|
async (args) => {
|
|
12323
12566
|
try {
|
|
@@ -12326,7 +12569,7 @@ function registerOrderTools(server) {
|
|
|
12326
12569
|
if (hasKind !== hasRef) {
|
|
12327
12570
|
throw new Error("Pass subjectKind and subjectRef together, or omit both on a worktree.");
|
|
12328
12571
|
}
|
|
12329
|
-
const caller =
|
|
12572
|
+
const caller = callerThread2();
|
|
12330
12573
|
let subject;
|
|
12331
12574
|
const hold = parseOrderHold(args.hold);
|
|
12332
12575
|
if (!hasKind) {
|
|
@@ -12381,9 +12624,9 @@ function registerOrderTools(server) {
|
|
|
12381
12624
|
"set_plan",
|
|
12382
12625
|
"Draft or retitle this chat's plan. It stays draft until execute_plan. Pass goal for the outcome the steps are trying to reach. Then set_dependency for each gate. A step may loop back to an earlier one. Call show_plan so the user sees it. Do not paste the diagram in chat. Do not start workspaces while it is draft.",
|
|
12383
12626
|
{
|
|
12384
|
-
title:
|
|
12385
|
-
summary:
|
|
12386
|
-
goal:
|
|
12627
|
+
title: z9.string().describe("Short name for the plan"),
|
|
12628
|
+
summary: z9.string().optional().describe("What this order is for, in a sentence or two"),
|
|
12629
|
+
goal: z9.string().optional().describe("Outcome the steps are trying to reach")
|
|
12387
12630
|
},
|
|
12388
12631
|
async ({ title, summary, goal }) => {
|
|
12389
12632
|
try {
|
|
@@ -12403,7 +12646,7 @@ function registerOrderTools(server) {
|
|
|
12403
12646
|
"execute_plan",
|
|
12404
12647
|
"Mark the plan active after the user has seen it and told you to run it. Returns ready steps (start those with create_workspace or send_to_chat) and waiting steps (leave them alone). Does not create workspaces. Pass agreed: true only after they agree. Merge only if they asked.",
|
|
12405
12648
|
{
|
|
12406
|
-
agreed:
|
|
12649
|
+
agreed: z9.literal(true).describe("True only after the user has seen the plan and told you to run it")
|
|
12407
12650
|
},
|
|
12408
12651
|
async () => {
|
|
12409
12652
|
try {
|
|
@@ -12436,7 +12679,7 @@ function registerOrderTools(server) {
|
|
|
12436
12679
|
worktree ? "Open the plans for this checkout in the side column. That is the orchestration diagram, with this checkout marked, and this checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Change a step with set_dependency or clear_dependency, then show it again. Do not paste the diagram in chat." : "Open this chat's plan in the side column. Call it after set_plan or set_dependency so the user sees the plan. A worktree show_plan also opens that checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Do not paste the diagram in chat.",
|
|
12437
12680
|
{},
|
|
12438
12681
|
async () => {
|
|
12439
|
-
const caller =
|
|
12682
|
+
const caller = callerThread2();
|
|
12440
12683
|
let diagramHtml = null;
|
|
12441
12684
|
let diagramTitle = "Planner";
|
|
12442
12685
|
let diagramError = null;
|
|
@@ -12474,10 +12717,10 @@ function registerOrderTools(server) {
|
|
|
12474
12717
|
server.tool(
|
|
12475
12718
|
"clear_dependency",
|
|
12476
12719
|
worktree ? "Remove a planner step this checkout is part of. Pass id from list_order. Then show_plan so the user sees it." : "Remove one planner step. Pass id from list_order. Then show_plan so the user sees it.",
|
|
12477
|
-
{ id:
|
|
12720
|
+
{ id: z9.string().describe("Step id from list_order") },
|
|
12478
12721
|
async ({ id }) => {
|
|
12479
12722
|
try {
|
|
12480
|
-
const caller =
|
|
12723
|
+
const caller = callerThread2();
|
|
12481
12724
|
clearOrderDependency(
|
|
12482
12725
|
id,
|
|
12483
12726
|
worktree && caller ? orderSnapshotFromThread(caller) : null,
|
|
@@ -12493,8 +12736,8 @@ function registerOrderTools(server) {
|
|
|
12493
12736
|
"satisfy_dependency",
|
|
12494
12737
|
"Mark a planner gate met. Use this when a PR is in production \u2014 Sideboard cannot see deploys. in-main also clears on its own once that PR is merged. Pass satisfied=false to undo a manual mark. One mark covers every step waiting on that same gate.",
|
|
12495
12738
|
{
|
|
12496
|
-
id:
|
|
12497
|
-
satisfied:
|
|
12739
|
+
id: z9.string().describe("Step id from list_order"),
|
|
12740
|
+
satisfied: z9.boolean().optional().describe("false clears the manual mark. Default true.")
|
|
12498
12741
|
},
|
|
12499
12742
|
async ({ id, satisfied }) => {
|
|
12500
12743
|
try {
|
|
@@ -12504,7 +12747,7 @@ function registerOrderTools(server) {
|
|
|
12504
12747
|
const rows = listOrderRows(plan.id);
|
|
12505
12748
|
const hit = rows.find((row2) => row2.id === id || id.length >= 8 && row2.id.startsWith(id));
|
|
12506
12749
|
if (!hit) throw new Error("That step is on another orchestration chat's plan.");
|
|
12507
|
-
const caller =
|
|
12750
|
+
const caller = callerThread2();
|
|
12508
12751
|
if (worktree && caller && !orderEdgeTouches(hit, orderSnapshotFromThread(caller))) {
|
|
12509
12752
|
throw new Error("This checkout can only change a step it is part of.");
|
|
12510
12753
|
}
|
|
@@ -12691,7 +12934,7 @@ async function handleJobStop(params, _ctx) {
|
|
|
12691
12934
|
return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
|
|
12692
12935
|
}
|
|
12693
12936
|
async function defaultTurnWait(ref, timeoutMs) {
|
|
12694
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
12937
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-3I2FLEZL.js");
|
|
12695
12938
|
const orch = getOrchestrator2();
|
|
12696
12939
|
const thread = await orch.waitForTurn(ref, timeoutMs, {
|
|
12697
12940
|
resolveIfStillRunning: true
|
|
@@ -12738,7 +12981,8 @@ async function handleTurnWait(params, ctx, waitFn = defaultTurnWait) {
|
|
|
12738
12981
|
hint: "Child is still working after max hold. Call wait_for_turn again. Do not send_to_chat a check-in (that steers / interrupts).",
|
|
12739
12982
|
incomplete: false,
|
|
12740
12983
|
blockedReason: null,
|
|
12741
|
-
blockedSource: null
|
|
12984
|
+
blockedSource: null,
|
|
12985
|
+
failureClass: null
|
|
12742
12986
|
};
|
|
12743
12987
|
}
|
|
12744
12988
|
function createAgentRpcDispatcher() {
|
|
@@ -13044,7 +13288,7 @@ async function startMcpServer() {
|
|
|
13044
13288
|
);
|
|
13045
13289
|
}
|
|
13046
13290
|
try {
|
|
13047
|
-
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-
|
|
13291
|
+
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-IA7ZZKWQ.js");
|
|
13048
13292
|
orch.setMaxConcurrent(maxConcurrentAgents2());
|
|
13049
13293
|
} catch {
|
|
13050
13294
|
}
|
|
@@ -13128,16 +13372,16 @@ async function startMcpServer() {
|
|
|
13128
13372
|
"list_board",
|
|
13129
13373
|
"Home Kanban of workspaces (New, Draft, Review, Approved, Merged) \u2014 one card per checkout; sibling chats on that card are separate agents. Same cards as desktop Home. Path to merge: no PR \u2192 draft PR \u2192 open PR \u2192 approved \u2192 merged. Archive removes the card to Settings \u2192 History (list_archive to browse, restore_workspace to bring it back). Queued/running are activity on the card, not stages. Orchestration chats are not on the board. Filters: query, repoPath, kind (ticket/PR/branch source), ownership (mine = your PRs / WIP; reviewing = someone else's PR), column, limit (default 40). create_workspace adds a workspace (and a Home card), or returns the live checkout if that ticket/PR/named branch is already checked out. That reuse is one checkout, not one agent \u2014 fork_chat to add another.",
|
|
13130
13374
|
{
|
|
13131
|
-
query:
|
|
13132
|
-
repoPath:
|
|
13133
|
-
kind:
|
|
13134
|
-
ownership:
|
|
13375
|
+
query: z10.string().optional().describe("Case-insensitive token search across title, id, labels, workspace tags, repo"),
|
|
13376
|
+
repoPath: z10.string().optional().describe("Limit to one project path from list_projects"),
|
|
13377
|
+
kind: z10.enum(["all", "tickets", "prs", "branches", "threads"]).optional().describe("Filter by worktree source (default all)"),
|
|
13378
|
+
ownership: z10.enum(["all", "mine", "reviewing"]).optional().describe(
|
|
13135
13379
|
"Mine = PRs you authored or local WIP; reviewing = someone else's PR. Uses the gh login."
|
|
13136
13380
|
),
|
|
13137
|
-
column:
|
|
13381
|
+
column: z10.enum(["new", "draft", "review", "approved", "done", "needs_you"]).optional().describe(
|
|
13138
13382
|
"Return cards for this column only (totals still include the rest). approved is an open PR GitHub has approved. needs_you is a legacy alias for new."
|
|
13139
13383
|
),
|
|
13140
|
-
limit:
|
|
13384
|
+
limit: z10.number().int().positive().optional().describe("Max cards per column (default 40). hidden counts the remainder.")
|
|
13141
13385
|
},
|
|
13142
13386
|
async ({ query, repoPath, kind, ownership, column, limit }) => {
|
|
13143
13387
|
const workspaces = orch.listWorkspaces();
|
|
@@ -13167,7 +13411,7 @@ async function startMcpServer() {
|
|
|
13167
13411
|
server.tool(
|
|
13168
13412
|
"get_chat",
|
|
13169
13413
|
"Get a compact chat summary by id/ref. Includes last message preview, parentChatId, and child workspace chats (status + lastText). While running, includes progress (last tool/thinking) and lastActivityAt. Includes usage (billed token + costUsd totals when providers reported cost) and lastTurnUsage. blockedReason is why that agent is waiting on a person (question, plan approval, or a reported block).",
|
|
13170
|
-
{ ref:
|
|
13414
|
+
{ ref: z10.string() },
|
|
13171
13415
|
async ({ ref }) => {
|
|
13172
13416
|
const t = orch.getThread(ref);
|
|
13173
13417
|
if (!t) {
|
|
@@ -13214,17 +13458,17 @@ async function startMcpServer() {
|
|
|
13214
13458
|
"present_artifact",
|
|
13215
13459
|
"Show a document or live log in Sideboard\u2019s side column. For html/svg/markdown/react, pass the FULL document and do not also fence that same body in chat. For type=log, pass only NEW lines (same artifact_id appends). Prefer type=log for long-running job output \u2014 do not resend HTML. type=react is a single default-export component (JSX/TSX); only react/react-dom imports.",
|
|
13216
13460
|
{
|
|
13217
|
-
title:
|
|
13218
|
-
type:
|
|
13461
|
+
title: z10.string().describe("Short title shown in the artifact pane header"),
|
|
13462
|
+
type: z10.enum(["html", "svg", "markdown", "react", "log"]).describe(
|
|
13219
13463
|
"html/svg/markdown/react replace the pane. log appends content to the same artifact_id (new lines only)."
|
|
13220
13464
|
),
|
|
13221
|
-
content:
|
|
13465
|
+
content: z10.string().describe(
|
|
13222
13466
|
"html/svg/markdown/react: full document. log: only the new lines since the last call (empty is ok for a status-only update)."
|
|
13223
13467
|
),
|
|
13224
|
-
artifact_id:
|
|
13225
|
-
status:
|
|
13226
|
-
phase:
|
|
13227
|
-
mode:
|
|
13468
|
+
artifact_id: z10.string().optional().describe("Stable id. Required for type=log so later calls append to the same pane."),
|
|
13469
|
+
status: z10.enum(["running", "ok", "failed", "idle"]).optional().describe("Log header pill: running (working), ok (done), failed, idle"),
|
|
13470
|
+
phase: z10.string().optional().describe("Log subtitle (Signing, Notarizing, \u2026)"),
|
|
13471
|
+
mode: z10.enum(["append", "replace"]).optional().describe("log only: append (default) or replace the buffer")
|
|
13228
13472
|
},
|
|
13229
13473
|
async ({ title, type, artifact_id, status, phase, mode }) => {
|
|
13230
13474
|
return mcpJson(
|
|
@@ -13237,15 +13481,15 @@ async function startMcpServer() {
|
|
|
13237
13481
|
"ask_user",
|
|
13238
13482
|
"Ask the user a clarifying multiple-choice question in Sideboard\u2019s composer. Call only when work is blocked on choosing among a few concrete options (approach fork, which API, auth vs cookies). Do not call for greetings, check-ins, \u201Chello\u201D, open-ended how-can-I-help, or to invent a menu of possible next tasks \u2014 reply in chat instead. If one option is the obvious default, proceed without asking. Before calling, write a short chat message explaining the decision and what each option means. Include a description on every option. After calling, stop and wait for answers. Not for \u201Cis the plan ready?\u201D.",
|
|
13239
13483
|
{
|
|
13240
|
-
questions:
|
|
13241
|
-
|
|
13242
|
-
question:
|
|
13243
|
-
header:
|
|
13244
|
-
multiSelect:
|
|
13245
|
-
options:
|
|
13246
|
-
|
|
13247
|
-
label:
|
|
13248
|
-
description:
|
|
13484
|
+
questions: z10.array(
|
|
13485
|
+
z10.object({
|
|
13486
|
+
question: z10.string().describe("Full question text ending with ?"),
|
|
13487
|
+
header: z10.string().max(24).optional().describe("Short label shown above the question"),
|
|
13488
|
+
multiSelect: z10.boolean().optional().describe("Allow selecting multiple options"),
|
|
13489
|
+
options: z10.array(
|
|
13490
|
+
z10.object({
|
|
13491
|
+
label: z10.string(),
|
|
13492
|
+
description: z10.string().optional().describe("What this option means / when to choose it (strongly preferred)")
|
|
13249
13493
|
})
|
|
13250
13494
|
).min(2).max(6).describe("2\u20136 choices (Sideboard also offers Other)")
|
|
13251
13495
|
})
|
|
@@ -13271,9 +13515,9 @@ async function startMcpServer() {
|
|
|
13271
13515
|
"present_plan",
|
|
13272
13516
|
PRESENT_PLAN_TOOL_DESCRIPTION,
|
|
13273
13517
|
{
|
|
13274
|
-
title:
|
|
13275
|
-
content:
|
|
13276
|
-
thread_id:
|
|
13518
|
+
title: z10.string().optional().describe("Short plan title (defaults to Plan)"),
|
|
13519
|
+
content: z10.string().min(1).describe("Full plan markdown (headings, steps, risks, open questions)"),
|
|
13520
|
+
thread_id: z10.string().optional().describe("Sideboard thread id when cwd is not the worktree")
|
|
13277
13521
|
},
|
|
13278
13522
|
async ({ title, content, thread_id }) => {
|
|
13279
13523
|
const { writePlanFile: writePlanFile2 } = await import("./plan-file-7MMIPV7Y.js");
|
|
@@ -13302,15 +13546,15 @@ async function startMcpServer() {
|
|
|
13302
13546
|
"present_schema",
|
|
13303
13547
|
"Open Sideboard\u2019s schema-driven side column (filterable table and/or form) when the user needs to filter, edit, publish, or persist records. Do not call this just to re-display rows you already wrote as a markdown table. If the user asks for an editable / interactive table, call this even if chat already showed those rows. Pass JSON Schema + optional schemaUi. Prefer datasource=inline with embedded resource/records. Use datasource=brightsy with resource_id only when the user is logged into Brightsy.",
|
|
13304
13548
|
{
|
|
13305
|
-
title:
|
|
13306
|
-
mode:
|
|
13307
|
-
datasource:
|
|
13308
|
-
resource_id:
|
|
13309
|
-
record_id:
|
|
13310
|
-
resource:
|
|
13311
|
-
record:
|
|
13312
|
-
records:
|
|
13313
|
-
pane_id:
|
|
13549
|
+
title: z10.string().describe("Pane title"),
|
|
13550
|
+
mode: z10.enum(["table", "form"]).optional().describe("table = list/filter records; form = edit one record"),
|
|
13551
|
+
datasource: z10.enum(["brightsy", "inline"]).optional().describe("brightsy resolves via login; inline uses embedded resource/records"),
|
|
13552
|
+
resource_id: z10.string().optional().describe("Brightsy record type UUID (or generic resource id)"),
|
|
13553
|
+
record_id: z10.string().optional().describe("Record id when opening form mode"),
|
|
13554
|
+
resource: z10.record(z10.unknown()).optional().describe("Inline { id, title, schema, schemaUi?, slug? }"),
|
|
13555
|
+
record: z10.record(z10.unknown()).optional().describe("Inline record { id, data, published_at? }"),
|
|
13556
|
+
records: z10.array(z10.record(z10.unknown())).optional().describe("Inline records for table mode"),
|
|
13557
|
+
pane_id: z10.string().optional().describe("Stable pane id across updates")
|
|
13314
13558
|
},
|
|
13315
13559
|
async (args) => {
|
|
13316
13560
|
const id = args.pane_id?.trim() || `schema_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -13331,10 +13575,10 @@ async function startMcpServer() {
|
|
|
13331
13575
|
"present_files",
|
|
13332
13576
|
"Open Sideboard\u2019s Files column (CMS-style file manager: browse, upload, pick). Use datasource=brightsy when the user is logged into Brightsy account storage; datasource=memory for a session-local demo store. Prefer this over claiming a file manager UI is unavailable. Pair with present_schema when editing records that need media.",
|
|
13333
13577
|
{
|
|
13334
|
-
title:
|
|
13335
|
-
datasource:
|
|
13336
|
-
path:
|
|
13337
|
-
pane_id:
|
|
13578
|
+
title: z10.string().optional().describe("Pane title (default: Files)"),
|
|
13579
|
+
datasource: z10.enum(["brightsy", "memory"]).optional().describe("brightsy = account storage via login; memory = session demo store"),
|
|
13580
|
+
path: z10.string().optional().describe("Initial folder path (e.g. public)"),
|
|
13581
|
+
pane_id: z10.string().optional().describe("Stable pane id across updates")
|
|
13338
13582
|
},
|
|
13339
13583
|
async (args) => {
|
|
13340
13584
|
const id = args.pane_id?.trim() || `files_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -13354,8 +13598,8 @@ async function startMcpServer() {
|
|
|
13354
13598
|
"wait_for_job",
|
|
13355
13599
|
"Wait on a detached long job (tests, pack, deploy, connector CLI) started with detached-job.cjs. MCP clients kill tools around 60s, so this returns within 45s. Sideboard opens a type=log pane from this result (artifact_id = job id, content = delta). stillRunning is the source of truth \u2014 if true, call wait_for_job again. If the job is hanging, producing no useful output, or doing the wrong thing, call stop_job instead of looping forever. Do not end the turn or tell the user you will let them know later. If false, ok/failed is the result.",
|
|
13356
13600
|
{
|
|
13357
|
-
id:
|
|
13358
|
-
timeoutMs:
|
|
13601
|
+
id: z10.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
|
|
13602
|
+
timeoutMs: z10.number().optional()
|
|
13359
13603
|
},
|
|
13360
13604
|
async ({ id, timeoutMs }) => {
|
|
13361
13605
|
const result = await waitForDetachedJob(process.cwd(), id, {
|
|
@@ -13368,8 +13612,8 @@ async function startMcpServer() {
|
|
|
13368
13612
|
"stop_job",
|
|
13369
13613
|
"Stop a detached job you started with detached-job.cjs when it is hanging, producing no useful output, buffering forever, or doing the wrong thing (wrong project, infinite watch, huge dump). Do not stop a pack/test/deploy that is clearly making progress. The type=log pane updates to status=failed with the last delta. Then decide the next step.",
|
|
13370
13614
|
{
|
|
13371
|
-
id:
|
|
13372
|
-
reason:
|
|
13615
|
+
id: z10.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
|
|
13616
|
+
reason: z10.string().optional().describe("Why you are stopping (hanging, no progress, wrong output, already have the answer)")
|
|
13373
13617
|
},
|
|
13374
13618
|
async ({ id, reason }) => {
|
|
13375
13619
|
const result = await stopDetachedJob(process.cwd(), id, { reason });
|
|
@@ -13381,7 +13625,7 @@ async function startMcpServer() {
|
|
|
13381
13625
|
"list_run_scripts",
|
|
13382
13626
|
"List .sideboard/.conductor run scripts for this thread (same menu as the desktop Dev button) and which are active. Each script and active run includes preview: url (open http://localhost:<SIDEBOARD_PORT>) or window (Electron: native window is the app; url is renderer/HMR only). Never guess :3000. Worktree turns may omit ref (uses cwd).",
|
|
13383
13627
|
{
|
|
13384
|
-
ref:
|
|
13628
|
+
ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd).")
|
|
13385
13629
|
},
|
|
13386
13630
|
async ({ ref }) => {
|
|
13387
13631
|
try {
|
|
@@ -13411,8 +13655,8 @@ async function startMcpServer() {
|
|
|
13411
13655
|
"run_dev_script",
|
|
13412
13656
|
"Start a .sideboard/.conductor run script (same as the desktop Dev / play button). Several named scripts can run at once; each gets its own port, and starting one does not stop the others. Logs and Stop appear in the thread UI \u2014 do not detached-job or shell-spawn the same command. Returns {port, ports, url, preview}. preview=url \u2192 open url (browser, curl, Playwright). preview=window \u2192 Electron: the native window is the app; url is renderer/HMR only (no preload/IPC in a browser). The port is allocated SIDEBOARD_PORT, not 3000. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
|
|
13413
13657
|
{
|
|
13414
|
-
ref:
|
|
13415
|
-
name:
|
|
13658
|
+
ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
13659
|
+
name: z10.string().optional().describe("Script name from list_run_scripts (default script if omitted).")
|
|
13416
13660
|
},
|
|
13417
13661
|
async ({ ref, name }) => {
|
|
13418
13662
|
try {
|
|
@@ -13440,8 +13684,8 @@ async function startMcpServer() {
|
|
|
13440
13684
|
"stop_dev_script",
|
|
13441
13685
|
"Stop a run script started with run_dev_script or the desktop Dev button (same as UI Stop). Omit name to stop all scripts on this worktree. Worktree turns may omit ref (uses cwd).",
|
|
13442
13686
|
{
|
|
13443
|
-
ref:
|
|
13444
|
-
name:
|
|
13687
|
+
ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
13688
|
+
name: z10.string().optional().describe("Script name to stop; omit to stop all active scripts.")
|
|
13445
13689
|
},
|
|
13446
13690
|
async ({ ref, name }) => {
|
|
13447
13691
|
try {
|
|
@@ -13458,9 +13702,9 @@ async function startMcpServer() {
|
|
|
13458
13702
|
"get_run_log",
|
|
13459
13703
|
"Read the Run-tab terminal for a worktree script (same stdout/stderr as the desktop Dev pane). Default is a tail \u2014 raise `tail` only if the error is missing. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
|
|
13460
13704
|
{
|
|
13461
|
-
ref:
|
|
13462
|
-
name:
|
|
13463
|
-
tail:
|
|
13705
|
+
ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
13706
|
+
name: z10.string().optional().describe("Script name from list_run_scripts (default script if omitted)."),
|
|
13707
|
+
tail: z10.number().int().min(1).max(MAX_RUN_LOG_CHARS).optional().describe(
|
|
13464
13708
|
`Max characters to return from the end (default ${DEFAULT_RUN_LOG_TAIL_CHARS}). Do not request the full buffer unless the tail is truncated and you still need more.`
|
|
13465
13709
|
)
|
|
13466
13710
|
},
|
|
@@ -13514,8 +13758,8 @@ async function startMcpServer() {
|
|
|
13514
13758
|
}
|
|
13515
13759
|
});
|
|
13516
13760
|
} catch (err) {
|
|
13517
|
-
const
|
|
13518
|
-
return { content: [{ type: "text", text:
|
|
13761
|
+
const text6 = err instanceof Error ? err.message : String(err);
|
|
13762
|
+
return { content: [{ type: "text", text: text6 }], isError: true };
|
|
13519
13763
|
}
|
|
13520
13764
|
}
|
|
13521
13765
|
);
|
|
@@ -13523,8 +13767,8 @@ async function startMcpServer() {
|
|
|
13523
13767
|
"notify_orchestrator",
|
|
13524
13768
|
"Wake the parent Global orchestrator with a short status so it does not have to poll wait_for_turn. Use when you are blocked and the parent may have moved on (missing access, waiting on something the coordinator must handle). The message is shown on the sidebar and board until the next user message in this chat. ask_user already notifies for input-required \u2014 do not call this for the same question. Information only: never a git command. Do not use this to steer other worktrees.",
|
|
13525
13769
|
{
|
|
13526
|
-
message:
|
|
13527
|
-
reason:
|
|
13770
|
+
message: z10.string().min(1).max(1500).describe("Why you are blocked / what the parent should know (short)."),
|
|
13771
|
+
reason: z10.enum(["input-required", "blocked"]).optional().describe(
|
|
13528
13772
|
"input-required = waiting on the user in this chat; blocked = need the coordinator (default)."
|
|
13529
13773
|
)
|
|
13530
13774
|
},
|
|
@@ -13550,23 +13794,24 @@ async function startMcpServer() {
|
|
|
13550
13794
|
...result.deduped ? { deduped: true } : {}
|
|
13551
13795
|
});
|
|
13552
13796
|
} catch (err) {
|
|
13553
|
-
const
|
|
13554
|
-
return { content: [{ type: "text", text:
|
|
13797
|
+
const text6 = err instanceof Error ? err.message : String(err);
|
|
13798
|
+
return { content: [{ type: "text", text: text6 }], isError: true };
|
|
13555
13799
|
}
|
|
13556
13800
|
}
|
|
13557
13801
|
);
|
|
13558
13802
|
}
|
|
13559
13803
|
registerScheduleTools(server);
|
|
13804
|
+
registerFollowUpTools(server);
|
|
13560
13805
|
registerOrderTools(server);
|
|
13561
13806
|
server.tool(
|
|
13562
13807
|
"set_workspace_tags",
|
|
13563
13808
|
worktreeProfile ? "Update tags on this workspace (the checkout you are in). Omit ref to use this chat. mode=replace (default), add, or remove. Short labels \u2014 the same ones the orchestrator used for this task. You cannot retag a different checkout." : "Label a project workspace so related checkouts stay recognizable in the sidebar and on the phone. Pass any chat id on that workspace. Use the same tags on every workspace from one task. mode=replace is the default; add and remove change the set. create_workspace tags= sets them at create time. Not for orchestration chats.",
|
|
13564
13809
|
{
|
|
13565
|
-
ref:
|
|
13810
|
+
ref: z10.string().optional().describe(
|
|
13566
13811
|
worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace to label."
|
|
13567
13812
|
),
|
|
13568
|
-
tags:
|
|
13569
|
-
mode:
|
|
13813
|
+
tags: z10.union([z10.string(), z10.array(z10.string())]).describe("Labels to set. A string may be comma-separated."),
|
|
13814
|
+
mode: z10.enum(["replace", "add", "remove"]).optional()
|
|
13570
13815
|
},
|
|
13571
13816
|
async ({ ref, tags, mode }) => {
|
|
13572
13817
|
try {
|
|
@@ -13594,10 +13839,10 @@ async function startMcpServer() {
|
|
|
13594
13839
|
"set_wake_on_github_edges",
|
|
13595
13840
|
worktreeProfile ? "Opt this checkout into orchestrator wakes when CI starts failing or GitHub requests a review. Omit ref. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is on. Do not change that Advanced switch." : "Opt a project workspace into CI and review-request wakes. Pass any chat id on that checkout. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is already on. Do not change that Advanced switch. Not for orchestration chats.",
|
|
13596
13841
|
{
|
|
13597
|
-
ref:
|
|
13842
|
+
ref: z10.string().optional().describe(
|
|
13598
13843
|
worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace."
|
|
13599
13844
|
),
|
|
13600
|
-
enabled:
|
|
13845
|
+
enabled: z10.boolean().describe("True opts the checkout in. False turns it off.")
|
|
13601
13846
|
},
|
|
13602
13847
|
async ({ ref, enabled }) => {
|
|
13603
13848
|
try {
|
|
@@ -13623,14 +13868,14 @@ async function startMcpServer() {
|
|
|
13623
13868
|
if (!worktreeProfile) {
|
|
13624
13869
|
registerConnectedIssueVendorTools(server);
|
|
13625
13870
|
const { getCaffeinateHold: getCaffeinateHold2, setCaffeinateHold: setCaffeinateHold2 } = await import("./caffeinate-hold-ZNUEZGHB.js");
|
|
13626
|
-
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-
|
|
13871
|
+
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-IA7ZZKWQ.js");
|
|
13627
13872
|
const accountDefaults = resolveThreadDefaults2();
|
|
13628
13873
|
const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
|
|
13629
13874
|
server.tool(
|
|
13630
13875
|
"set_caffeinate",
|
|
13631
13876
|
"Keep this Mac awake with caffeinate across turns \u2014 independent of Settings toggles. A connected phone already holds caffeinate (lid can close on power), so do not turn this on just because they are on the phone. Turn ON when the user will be away and no phone is connected, or they ask you to keep the machine awake. Turn OFF when they say they are done, wrapping up, going to sleep, or no longer need the Mac awake. Closing or archiving this orchestration chat also releases the hold. macOS only.",
|
|
13632
13877
|
{
|
|
13633
|
-
enabled:
|
|
13878
|
+
enabled: z10.boolean().describe("true = hold caffeinate on; false = release and let the Mac sleep")
|
|
13634
13879
|
},
|
|
13635
13880
|
async ({ enabled }) => {
|
|
13636
13881
|
const threadId = process.env.SIDEBOARD_ORCHESTRATOR_THREAD_ID?.trim() || null;
|
|
@@ -13656,24 +13901,25 @@ async function startMcpServer() {
|
|
|
13656
13901
|
"create_workspace",
|
|
13657
13902
|
`Create a workspace (isolated git checkout + first chat) from branch, pr, or ticket. A ticket, PR, or named branch has one checkout \u2014 if one already matches, returns it (alreadyStarted=true) instead of a second checkout. That is not one agent: chats lists every agent on that checkout. Add another with fork_chat; send_to_chat only the chat that should do this job. Creating from the default branch still opens a new isolated checkout. Pass repoPath from list_projects. cowboy=true uses the project folder on the default branch (no isolated worktree; land is commit+push). From an orchestration chat, omit parentChatId (Sideboard binds the child to this chat) or pass the exact id from the turn reminder \u2014 never invent a uuid. Omit agent/model \u2014 Sideboard applies ${accountDefaultsHint}. Do not pass your own agent or agent=cursor; those are ignored. Setup (settings.toml, .cursor/worktrees.json, or script/setup) runs in the background in parallel with the first turn (skipped for cowboy). Pass the same tags on every workspace you open for one task (short labels such as "phone-sync") so they still match in the sidebar the next day. Reusing a checkout adds those tags. Each orchestration chat can create at most the Settings \u2192 Advanced \u201CMax orchestration threads\u201D cap of child workspaces (default 5). fork_chat on an existing checkout does not use a slot.`,
|
|
13658
13903
|
{
|
|
13659
|
-
sourceType:
|
|
13660
|
-
sourceRef:
|
|
13661
|
-
agent:
|
|
13662
|
-
`Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored.`
|
|
13904
|
+
sourceType: z10.enum(["branch", "pr", "ticket"]),
|
|
13905
|
+
sourceRef: z10.string(),
|
|
13906
|
+
agent: z10.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]).optional().describe(
|
|
13907
|
+
`Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored. Pass agent=acp and acpHarness=gemini or copilot for Gemini CLI or Copilot CLI.`
|
|
13663
13908
|
),
|
|
13664
|
-
|
|
13909
|
+
acpHarness: z10.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini (Gemini CLI) or copilot (GitHub Copilot CLI)."),
|
|
13910
|
+
model: z10.string().nullable().optional().describe(
|
|
13665
13911
|
`Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
|
|
13666
13912
|
),
|
|
13667
|
-
repoPath:
|
|
13668
|
-
title:
|
|
13669
|
-
cowboy:
|
|
13913
|
+
repoPath: z10.string(),
|
|
13914
|
+
title: z10.string().optional(),
|
|
13915
|
+
cowboy: z10.boolean().optional().describe(
|
|
13670
13916
|
"If true, work in the project folder on the default branch (no thread/* worktree). Requires Settings \u2192 Advanced \u2192 Cowboy mode. Land is commit+push to that branch. Archive does not delete the folder."
|
|
13671
13917
|
),
|
|
13672
|
-
parentChatId:
|
|
13918
|
+
parentChatId: z10.string().optional().describe(
|
|
13673
13919
|
"Orchestration: omit (preferred) or pass YOUR chat id from the turn reminder / AGENTS.md. Do not invent uuids."
|
|
13674
13920
|
),
|
|
13675
|
-
parentThreadId:
|
|
13676
|
-
tags:
|
|
13921
|
+
parentThreadId: z10.string().optional().describe("Legacy alias for parentChatId."),
|
|
13922
|
+
tags: z10.union([z10.string(), z10.array(z10.string())]).optional().describe(
|
|
13677
13923
|
"Short labels for this workspace (or a comma-separated string). Use the same tags on every checkout for one task. Added when the checkout already exists."
|
|
13678
13924
|
)
|
|
13679
13925
|
},
|
|
@@ -13689,11 +13935,11 @@ async function startMcpServer() {
|
|
|
13689
13935
|
"start_board_card",
|
|
13690
13936
|
"Same as create_workspace for a ticket, PR, or named branch (attaches issue text when Sideboard can resolve it). Does not create a second checkout when one already matches \u2014 returns that workspace (alreadyStarted) and its chats. A workspace can have many agents. fork_chat to add one; send_to_chat only the chat that should do this job.",
|
|
13691
13937
|
{
|
|
13692
|
-
kind:
|
|
13693
|
-
ref:
|
|
13694
|
-
repoPath:
|
|
13695
|
-
title:
|
|
13696
|
-
tags:
|
|
13938
|
+
kind: z10.enum(["ticket", "pr", "branch"]),
|
|
13939
|
+
ref: z10.string().describe("Ticket identifier (ENG-12), PR number (44), or branch name from list_board"),
|
|
13940
|
+
repoPath: z10.string().describe("Project path from list_projects / list_board"),
|
|
13941
|
+
title: z10.string().optional(),
|
|
13942
|
+
tags: z10.union([z10.string(), z10.array(z10.string())]).optional().describe(
|
|
13697
13943
|
"Short labels for this workspace. Same tags on every checkout for one task. Added when the checkout already exists."
|
|
13698
13944
|
)
|
|
13699
13945
|
},
|
|
@@ -13796,11 +14042,11 @@ async function startMcpServer() {
|
|
|
13796
14042
|
);
|
|
13797
14043
|
server.tool(
|
|
13798
14044
|
"send_to_chat",
|
|
13799
|
-
'
|
|
14045
|
+
'Send a prompt to a workspace chat. A second send joins that prompt only while it is still queued or not yet handed to the process. Once the process has started, the send waits behind the turn and does not stop it or change the prompt already running. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. The workspace composer still follows Settings \u2192 Follow-up. Use after create_workspace to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. Do not send_to_chat to check in, resume after a halt notice, or because wait_for_turn returned stillRunning. Call wait_for_turn again instead.',
|
|
13800
14046
|
{
|
|
13801
|
-
ref:
|
|
13802
|
-
prompt:
|
|
13803
|
-
force_stop:
|
|
14047
|
+
ref: z10.string(),
|
|
14048
|
+
prompt: z10.string(),
|
|
14049
|
+
force_stop: z10.boolean().optional()
|
|
13804
14050
|
},
|
|
13805
14051
|
async ({ ref, prompt, force_stop }) => {
|
|
13806
14052
|
if (force_stop) {
|
|
@@ -13810,7 +14056,7 @@ async function startMcpServer() {
|
|
|
13810
14056
|
}
|
|
13811
14057
|
}
|
|
13812
14058
|
const thread = await orch.send(ref, prompt, {
|
|
13813
|
-
followUp:
|
|
14059
|
+
followUp: force_stop ? "steer" : "join"
|
|
13814
14060
|
});
|
|
13815
14061
|
return mcpJson({
|
|
13816
14062
|
id: thread.id,
|
|
@@ -13823,10 +14069,10 @@ async function startMcpServer() {
|
|
|
13823
14069
|
if (shouldRegisterMcpWaitForTurn()) {
|
|
13824
14070
|
server.tool(
|
|
13825
14071
|
"wait_for_turn",
|
|
13826
|
-
"Wait until the chat finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. taskState is the A2A-style lifecycle: submitted (queued, not started), working, input-required (ask_user), completed, failed, canceled. stillRunning is true only for submitted/working. blockedReason is why the child is waiting on a person (the question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress and call wait_for_turn again. Do not send_to_chat a check-in
|
|
14072
|
+
"Wait until the chat finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. taskState is the A2A-style lifecycle: submitted (queued, not started), working, input-required (ask_user), completed, failed, canceled. stillRunning is true only for submitted/working. blockedReason is why the child is waiting on a person (the question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress and call wait_for_turn again. Do not send_to_chat a check-in. On failed, read failureClass: auth, quota, and refused are not a retry; timeout or runner can be one. lastError/text is the failure. On canceled, the child did not finish \u2014 resume with send_to_chat or tell the user. On input-required, wait for the user in that chat. When finished, text is this turn\u2019s assistant reply and usage is that turn\u2019s tokens + costUsd (this turn, not the Claude session total; sessionCostUsd is the provider session total when present).",
|
|
13827
14073
|
{
|
|
13828
|
-
ref:
|
|
13829
|
-
timeoutMs:
|
|
14074
|
+
ref: z10.string(),
|
|
14075
|
+
timeoutMs: z10.number().optional()
|
|
13830
14076
|
},
|
|
13831
14077
|
async ({ ref, timeoutMs }) => {
|
|
13832
14078
|
const thread = await orch.waitForTurn(ref, mcpWaitForTurnTimeoutMs(timeoutMs), {
|
|
@@ -13853,14 +14099,16 @@ async function startMcpServer() {
|
|
|
13853
14099
|
}
|
|
13854
14100
|
server.tool(
|
|
13855
14101
|
"get_turn_result",
|
|
13856
|
-
"Assistant message and last-turn usage when the turn finished. While stillRunning (submitted/working), text and usage are empty so a previous reply cannot be mistaken for this turn \u2014 use progress for tools/thinking. Not the full transcript. Includes taskState (A2A lifecycle) and blockedReason (why the agent is waiting on a person).",
|
|
13857
|
-
{ ref:
|
|
14102
|
+
"Assistant message and last-turn usage when the turn finished. While stillRunning (submitted/working), text and usage are empty so a previous reply cannot be mistaken for this turn \u2014 use progress for tools/thinking. Not the full transcript. Includes taskState (A2A lifecycle), failureClass when the turn failed (auth, quota, refused, timeout, runner, other), and blockedReason (why the agent is waiting on a person).",
|
|
14103
|
+
{ ref: z10.string() },
|
|
13858
14104
|
async ({ ref }) => {
|
|
13859
14105
|
const result = orch.getTurnResult(ref);
|
|
13860
|
-
const
|
|
14106
|
+
const failureClass = result.taskState === "failed" && result.status !== "broken" ? classifyTurnFailure(result.lastError || result.text) : null;
|
|
14107
|
+
const hint = mcpWaitTaskHint(result.taskState, result.status, result.blockedReason, failureClass);
|
|
13861
14108
|
const waiting = Boolean(result.blockedReason) && !result.stillRunning && result.taskState !== "failed" && result.taskState !== "canceled";
|
|
13862
14109
|
return mcpJson({
|
|
13863
14110
|
...result,
|
|
14111
|
+
failureClass,
|
|
13864
14112
|
hint,
|
|
13865
14113
|
incomplete: needsCoordinatorAction(result.taskState) || waiting
|
|
13866
14114
|
});
|
|
@@ -13870,9 +14118,9 @@ async function startMcpServer() {
|
|
|
13870
14118
|
"stop_chat",
|
|
13871
14119
|
"Force-stop a thread: kill any in-flight agent turn AND clear queued prompts so drainQueue cannot continue. Does not archive the worktree. Optional force defaults to true. Pass reason \u2014 a short note on why this chat is stopping. It is stored on the thread and kept when the turn unwinds. If you omit it, Sideboard still records that the queue was cleared.",
|
|
13872
14120
|
{
|
|
13873
|
-
ref:
|
|
13874
|
-
force:
|
|
13875
|
-
reason:
|
|
14121
|
+
ref: z10.string(),
|
|
14122
|
+
force: z10.boolean().optional(),
|
|
14123
|
+
reason: z10.string().optional().describe("Why this chat is stopping. Stored on the thread for the next session.")
|
|
13876
14124
|
},
|
|
13877
14125
|
async ({ ref, force, reason }) => {
|
|
13878
14126
|
const t = orch.getThread(ref);
|
|
@@ -13898,8 +14146,8 @@ async function startMcpServer() {
|
|
|
13898
14146
|
"get_diff",
|
|
13899
14147
|
"Compact diff summary (capped hunks, paginated)",
|
|
13900
14148
|
{
|
|
13901
|
-
ref:
|
|
13902
|
-
maxFiles:
|
|
14149
|
+
ref: z10.string(),
|
|
14150
|
+
maxFiles: z10.number().optional()
|
|
13903
14151
|
},
|
|
13904
14152
|
async ({ ref, maxFiles }) => {
|
|
13905
14153
|
const summary = await orch.diffSummary(ref);
|
|
@@ -13912,7 +14160,7 @@ async function startMcpServer() {
|
|
|
13912
14160
|
server.tool(
|
|
13913
14161
|
"get_pr_checks",
|
|
13914
14162
|
"Snapshot of GitHub PR checks for a worktree thread (`gh pr checks` plus merge/review gates). null = no PR. If the user gave a goal (Greptile 5/5, CI green), the worktree agent watches with `gh pr checks --watch` via /long-running \u2014 this tool is a snapshot, not a waiter. Coordinators: do not run gh from the orchestration cwd.",
|
|
13915
|
-
{ ref:
|
|
14163
|
+
{ ref: z10.string().describe("Worktree thread id/ref") },
|
|
13916
14164
|
async ({ ref }) => {
|
|
13917
14165
|
try {
|
|
13918
14166
|
const checks = await orch.getPrChecks(ref);
|
|
@@ -13926,7 +14174,7 @@ async function startMcpServer() {
|
|
|
13926
14174
|
server.tool(
|
|
13927
14175
|
"request_review",
|
|
13928
14176
|
'Start a merge-readiness Review on a worktree agent thread (same as the desktop Review button). If that worktree has a single unused idle agent (no messages), runs the review there; otherwise opens a new Review chat tab. Attaches .claude/skills/review/SKILL.md when present (else copies .sideboard/review.md into .context/review.md, or seeds that file from the stock template), and sends "Review changes in this workspace." Expect Approve / Approve with nits / Request changes / Needs more information in that chat. The review stays there so the user can read it and type next steps \u2014 do not comment on or update the PR or ticket, and do not ask_user after the review, until they ask. Pass a worktree thread ref \u2014 not the orchestrator. Then wait_for_turn (loop while stillRunning) / get_turn_result on the returned review thread id.',
|
|
13929
|
-
{ ref:
|
|
14177
|
+
{ ref: z10.string().describe("Worktree thread id/ref to review") },
|
|
13930
14178
|
async ({ ref }) => {
|
|
13931
14179
|
try {
|
|
13932
14180
|
const tab = await orch.requestReview(ref);
|
|
@@ -13948,8 +14196,8 @@ async function startMcpServer() {
|
|
|
13948
14196
|
"ask_git",
|
|
13949
14197
|
"Commit & push, open a draft PR, mark ready for review, resolve conflicts, or merge \u2014 same prompts as the desktop git buttons (including Resolve). Always steers the worktree agent; does not push or open the PR locally. Then wait_for_turn (loop while stillRunning). Do not start a checks loop on a plain push \u2014 only if the user gave a goal (CI green, a review score, until checks pass). A push can wake a third-party PR review; the worktree agent acknowledges it only inside that goal. Pass a worktree thread ref (not the orchestrator). action=ready-for-review and action=merge only when the user explicitly asked (or clicked the desktop button). Do not run git or gh from the orchestration cwd.",
|
|
13950
14198
|
{
|
|
13951
|
-
ref:
|
|
13952
|
-
action:
|
|
14199
|
+
ref: z10.string().describe("Worktree thread id/ref"),
|
|
14200
|
+
action: z10.enum(AGENT_GIT_ACTIONS).describe(
|
|
13953
14201
|
"commit-push | create-draft | create-web | resolve-conflicts | ready-for-review | merge"
|
|
13954
14202
|
)
|
|
13955
14203
|
},
|
|
@@ -13978,7 +14226,7 @@ async function startMcpServer() {
|
|
|
13978
14226
|
}
|
|
13979
14227
|
}
|
|
13980
14228
|
);
|
|
13981
|
-
const agentEnum =
|
|
14229
|
+
const agentEnum = z10.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]);
|
|
13982
14230
|
server.tool(
|
|
13983
14231
|
"list_models",
|
|
13984
14232
|
"List models for an agent. Prefer Auto: do not call this unless you have a reason to pin a specific model (user request, cost/latency, capability). Omit agent to list all.",
|
|
@@ -13999,13 +14247,14 @@ async function startMcpServer() {
|
|
|
13999
14247
|
"fork_workspace",
|
|
14000
14248
|
"Fork a worktree agent chat into a NEW git worktree + chat (desktop \u201CFork to new workspace\u201D). Seeds a transcript (through through_index, default all). Optional agent override. Leave model unset for Auto (default) \u2014 only pass model when you have a reason. Not for the orchestrator. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id.",
|
|
14001
14249
|
{
|
|
14002
|
-
ref:
|
|
14003
|
-
through_index:
|
|
14250
|
+
ref: z10.string().describe("Worktree thread id/ref to fork"),
|
|
14251
|
+
through_index: z10.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
|
|
14004
14252
|
agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
|
|
14005
|
-
|
|
14006
|
-
|
|
14253
|
+
acpHarness: z10.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini or copilot."),
|
|
14254
|
+
model: z10.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
|
|
14255
|
+
title: z10.string().optional()
|
|
14007
14256
|
},
|
|
14008
|
-
async ({ ref, through_index, agent, model, title }) => {
|
|
14257
|
+
async ({ ref, through_index, agent, model, title, acpHarness }) => {
|
|
14009
14258
|
try {
|
|
14010
14259
|
const source = orch.getThread(ref);
|
|
14011
14260
|
if (source) await orch.reconcile(source.repoPath, { drainQueues: false });
|
|
@@ -14013,6 +14262,7 @@ async function startMcpServer() {
|
|
|
14013
14262
|
threadId: ref,
|
|
14014
14263
|
throughIndex: through_index,
|
|
14015
14264
|
agent,
|
|
14265
|
+
acpHarness,
|
|
14016
14266
|
model,
|
|
14017
14267
|
title
|
|
14018
14268
|
});
|
|
@@ -14037,13 +14287,14 @@ async function startMcpServer() {
|
|
|
14037
14287
|
"fork_chat",
|
|
14038
14288
|
"Add another agent chat on the SAME workspace (same files, Run, and git). Also forks a Global orchestration chat into a new orchestration tab. Pass agent when the new chat should use a different harness. Leave model unset for Auto unless you have a reason. Orchestration forks require an MCP-capable agent (claude, cursor, codex, opencode \u2014 not brightsy). Use this for a second agent on a checkout (review, another harness, parallel work on the same branch). Do not create_workspace again for that \u2014 it returns the existing checkout. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id. Use fork_workspace only when the work needs its own git checkout.",
|
|
14039
14289
|
{
|
|
14040
|
-
ref:
|
|
14041
|
-
through_index:
|
|
14042
|
-
agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
|
|
14043
|
-
|
|
14044
|
-
|
|
14290
|
+
ref: z10.string().describe("Thread id/ref to fork (worktree agent or orchestration chat)"),
|
|
14291
|
+
through_index: z10.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
|
|
14292
|
+
agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source). agent=acp with acpHarness=gemini or copilot opens Gemini CLI or Copilot CLI. An orchestration fork cannot use acp."),
|
|
14293
|
+
acpHarness: z10.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini or copilot."),
|
|
14294
|
+
model: z10.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
|
|
14295
|
+
title: z10.string().optional()
|
|
14045
14296
|
},
|
|
14046
|
-
async ({ ref, through_index, agent, model, title }) => {
|
|
14297
|
+
async ({ ref, through_index, agent, model, title, acpHarness }) => {
|
|
14047
14298
|
try {
|
|
14048
14299
|
const source = orch.getThread(ref);
|
|
14049
14300
|
if (!source) {
|
|
@@ -14056,6 +14307,7 @@ async function startMcpServer() {
|
|
|
14056
14307
|
threadId: source.id,
|
|
14057
14308
|
throughIndex: through_index,
|
|
14058
14309
|
agent,
|
|
14310
|
+
acpHarness,
|
|
14059
14311
|
model,
|
|
14060
14312
|
title
|
|
14061
14313
|
});
|
|
@@ -14079,7 +14331,7 @@ async function startMcpServer() {
|
|
|
14079
14331
|
server.tool(
|
|
14080
14332
|
"run_setup",
|
|
14081
14333
|
"Re-run workspace setup (Sideboard/Conductor settings, .cursor/worktrees.json, or script/setup). New worktrees already run this automatically.",
|
|
14082
|
-
{ ref:
|
|
14334
|
+
{ ref: z10.string() },
|
|
14083
14335
|
async ({ ref }) => {
|
|
14084
14336
|
const result = await orch.runSetup(ref);
|
|
14085
14337
|
return mcpJson(result);
|
|
@@ -14088,7 +14340,7 @@ async function startMcpServer() {
|
|
|
14088
14340
|
server.tool(
|
|
14089
14341
|
"add_project",
|
|
14090
14342
|
"Register a git repo as a Sideboard workspace",
|
|
14091
|
-
{ repoPath:
|
|
14343
|
+
{ repoPath: z10.string() },
|
|
14092
14344
|
async ({ repoPath }) => {
|
|
14093
14345
|
const ws = await orch.addWorkspace(repoPath);
|
|
14094
14346
|
return mcpJson(ws);
|
|
@@ -14097,7 +14349,7 @@ async function startMcpServer() {
|
|
|
14097
14349
|
server.tool(
|
|
14098
14350
|
"remove_project",
|
|
14099
14351
|
"Unregister a Sideboard workspace and archive its chats",
|
|
14100
|
-
{ repoPath:
|
|
14352
|
+
{ repoPath: z10.string() },
|
|
14101
14353
|
async ({ repoPath }) => {
|
|
14102
14354
|
await orch.removeWorkspace(repoPath);
|
|
14103
14355
|
return { content: [{ type: "text", text: "ok" }] };
|
|
@@ -14107,12 +14359,12 @@ async function startMcpServer() {
|
|
|
14107
14359
|
"fanout",
|
|
14108
14360
|
"Best-of-n: create one thread per agent with the same prompt (parallel attempts)",
|
|
14109
14361
|
{
|
|
14110
|
-
prompt:
|
|
14111
|
-
agents:
|
|
14112
|
-
repoPath:
|
|
14113
|
-
sourceType:
|
|
14114
|
-
sourceRef:
|
|
14115
|
-
title:
|
|
14362
|
+
prompt: z10.string(),
|
|
14363
|
+
agents: z10.array(z10.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"])),
|
|
14364
|
+
repoPath: z10.string(),
|
|
14365
|
+
sourceType: z10.enum(["branch", "pr", "ticket"]).optional(),
|
|
14366
|
+
sourceRef: z10.string().optional(),
|
|
14367
|
+
title: z10.string().optional()
|
|
14116
14368
|
},
|
|
14117
14369
|
async (args) => {
|
|
14118
14370
|
const threads = await orch.bestOfN(args);
|
|
@@ -14130,8 +14382,8 @@ async function startMcpServer() {
|
|
|
14130
14382
|
"list_branches",
|
|
14131
14383
|
"List git branches in a registered workspace. Pass repoPath from list_projects (unmerged into the default branch by default \u2014 for create_workspace sourceType=branch).",
|
|
14132
14384
|
{
|
|
14133
|
-
repoPath:
|
|
14134
|
-
unmergedOnly:
|
|
14385
|
+
repoPath: z10.string(),
|
|
14386
|
+
unmergedOnly: z10.boolean().optional()
|
|
14135
14387
|
},
|
|
14136
14388
|
async ({ repoPath, unmergedOnly }) => {
|
|
14137
14389
|
const root = await resolveRepoRoot(repoPath);
|
|
@@ -14152,19 +14404,19 @@ async function startMcpServer() {
|
|
|
14152
14404
|
"list_prs",
|
|
14153
14405
|
`List GitHub PRs for a registered workspace (the review surface for assigned ticket work \u2014 not the tickets). Pass repoPath from list_projects. "Get me N tickets to review" \u2192 queue=review and limit=N: open non-draft PRs labeled with this project's ready-for-review GitHub label (Settings \u2192 Projects; default eng-review) with no individual user reviewer. Prefer teams that match Settings \u2192 Agents / Projects roles for this repo. A team like engineering-team is not a claim (you are on that team). Also: state (open|closed|merged|all|review), label, reviewer (me|unassigned|login), query, limit (default 40, max 250). Then create_workspace with sourceType=pr.`,
|
|
14154
14406
|
{
|
|
14155
|
-
repoPath:
|
|
14156
|
-
query:
|
|
14157
|
-
queue:
|
|
14407
|
+
repoPath: z10.string(),
|
|
14408
|
+
query: z10.string().optional().describe("GitHub search tokens (title, draft:true, \u2026)"),
|
|
14409
|
+
queue: z10.enum(["review", "mine", "approved", "changes"]).optional().describe(
|
|
14158
14410
|
"review = unclaimed ready-for-review inbox (Settings \u2192 Projects label, default eng-review). mine = review-requested:@me. approved / changes = eng-approved / eng-requested-changes."
|
|
14159
14411
|
),
|
|
14160
|
-
state:
|
|
14161
|
-
label:
|
|
14412
|
+
state: z10.enum(["open", "closed", "merged", "all", "review"]).optional().describe("GitHub PR state (default open). review is an alias for queue=review."),
|
|
14413
|
+
label: z10.string().optional().describe(
|
|
14162
14414
|
"GitHub label / workflow tag. Comma-separated AND. Examples: eng-review, eng-approved, eng-requested-changes"
|
|
14163
14415
|
),
|
|
14164
|
-
reviewer:
|
|
14416
|
+
reviewer: z10.string().optional().describe(
|
|
14165
14417
|
"me (review requested of you), unassigned (no individual reviewer; team queues like engineering-team still count), all, or a GitHub login"
|
|
14166
14418
|
),
|
|
14167
|
-
limit:
|
|
14419
|
+
limit: z10.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true.")
|
|
14168
14420
|
},
|
|
14169
14421
|
async ({ repoPath, query, queue, state, label, reviewer, limit }) => {
|
|
14170
14422
|
const root = await resolveRepoRoot(repoPath);
|
|
@@ -14197,7 +14449,7 @@ async function startMcpServer() {
|
|
|
14197
14449
|
server.tool(
|
|
14198
14450
|
"get_pr_stack",
|
|
14199
14451
|
"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 (and only merge when the user explicitly asked).",
|
|
14200
|
-
{ ref:
|
|
14452
|
+
{ ref: z10.string() },
|
|
14201
14453
|
async ({ ref }) => {
|
|
14202
14454
|
const stack = await orch.getPrStack(ref);
|
|
14203
14455
|
return mcpJson(stack);
|
|
@@ -14207,8 +14459,8 @@ async function startMcpServer() {
|
|
|
14207
14459
|
"open_pr_stack_layers",
|
|
14208
14460
|
"Materialize one worktree+thread per stack layer (or a single 1-based layer). Pass a thread ref already on the stack.",
|
|
14209
14461
|
{
|
|
14210
|
-
ref:
|
|
14211
|
-
layer:
|
|
14462
|
+
ref: z10.string(),
|
|
14463
|
+
layer: z10.number().int().positive().optional()
|
|
14212
14464
|
},
|
|
14213
14465
|
async ({ ref, layer }) => {
|
|
14214
14466
|
const result = await orch.openPrStackLayers(ref, { layer });
|
|
@@ -14231,9 +14483,9 @@ async function startMcpServer() {
|
|
|
14231
14483
|
"add_stack_layer",
|
|
14232
14484
|
"Add a branch on top of the current stack (`gh stack add`) and open a worktree+thread for it.",
|
|
14233
14485
|
{
|
|
14234
|
-
ref:
|
|
14235
|
-
branchName:
|
|
14236
|
-
title:
|
|
14486
|
+
ref: z10.string(),
|
|
14487
|
+
branchName: z10.string(),
|
|
14488
|
+
title: z10.string().optional()
|
|
14237
14489
|
},
|
|
14238
14490
|
async ({ ref, branchName, title }) => {
|
|
14239
14491
|
const result = await orch.addStackLayer(ref, branchName, { title });
|
|
@@ -14251,11 +14503,11 @@ async function startMcpServer() {
|
|
|
14251
14503
|
"create_pr_stack",
|
|
14252
14504
|
"Create a new GitHub PR stack with one Sideboard worktree per layer (bottom\u2192top branch names). Requires `gh extension install github/gh-stack`.",
|
|
14253
14505
|
{
|
|
14254
|
-
repoPath:
|
|
14255
|
-
branches:
|
|
14256
|
-
agent:
|
|
14257
|
-
base:
|
|
14258
|
-
title:
|
|
14506
|
+
repoPath: z10.string(),
|
|
14507
|
+
branches: z10.array(z10.string()).min(1),
|
|
14508
|
+
agent: z10.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]),
|
|
14509
|
+
base: z10.string().optional(),
|
|
14510
|
+
title: z10.string().optional()
|
|
14259
14511
|
},
|
|
14260
14512
|
async (args) => {
|
|
14261
14513
|
const result = await orch.createPrStack({
|
|
@@ -14283,10 +14535,10 @@ async function startMcpServer() {
|
|
|
14283
14535
|
"list_issues",
|
|
14284
14536
|
"List or search issues (Linear, AbleTime, or GitHub; falls back to GitHub). Cursor Origin has no issue tracker \u2014 a Cursor repo returns unavailableReason unless Linear or AbleTime is the source. Entire tickets are Trails (`entire trail`), not GitHub Issues, so an Entire repo does the same unless Linear or AbleTime is the source. Use Settings \u2192 Agents / Projects notes and roles to pick tickets relevant to the viewer (query + assignee=me or unassigned as the notes say). Default 40; pass query and/or limit (max 250) when truncated. assignee: me (Linear default), unassigned, all, or a user id. Pass updatedSince for new/updated tickets and new comments (\u201Cany updates since yesterday?\u201D). Then create_workspace with sourceType=ticket.",
|
|
14285
14537
|
{
|
|
14286
|
-
repoPath:
|
|
14287
|
-
query:
|
|
14288
|
-
assignee:
|
|
14289
|
-
limit:
|
|
14538
|
+
repoPath: z10.string(),
|
|
14539
|
+
query: z10.string().optional().describe("Search title, identifier, or description"),
|
|
14540
|
+
assignee: z10.string().optional().describe("me (Linear default), unassigned, all, a user id, or a GitHub login"),
|
|
14541
|
+
limit: z10.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true."),
|
|
14290
14542
|
updatedSince: mcpIssueUpdatedSinceSchema
|
|
14291
14543
|
},
|
|
14292
14544
|
async ({ repoPath, query, assignee, limit, updatedSince }) => {
|
|
@@ -14898,8 +15150,8 @@ var BrightsySideboardApi = class {
|
|
|
14898
15150
|
};
|
|
14899
15151
|
function taskMessageText(task) {
|
|
14900
15152
|
const parts = task.message?.parts ?? [];
|
|
14901
|
-
const
|
|
14902
|
-
return
|
|
15153
|
+
const text6 = parts.find((p) => p.kind === "text")?.text ?? "";
|
|
15154
|
+
return text6.trim();
|
|
14903
15155
|
}
|
|
14904
15156
|
|
|
14905
15157
|
// src/brightsy/cloud-connect.ts
|
|
@@ -15268,7 +15520,7 @@ function wait3(ms, signal) {
|
|
|
15268
15520
|
);
|
|
15269
15521
|
});
|
|
15270
15522
|
}
|
|
15271
|
-
function
|
|
15523
|
+
function send3(ws, msg) {
|
|
15272
15524
|
ws.send(JSON.stringify(msg));
|
|
15273
15525
|
}
|
|
15274
15526
|
async function runSlackRelayClient(opts) {
|
|
@@ -15378,7 +15630,7 @@ function connectSession2(ws, opts, log) {
|
|
|
15378
15630
|
};
|
|
15379
15631
|
const pingOnce = () => {
|
|
15380
15632
|
try {
|
|
15381
|
-
|
|
15633
|
+
send3(ws, { type: "ping" });
|
|
15382
15634
|
armPongTimeout();
|
|
15383
15635
|
} catch (err) {
|
|
15384
15636
|
finish(err instanceof Error ? err : new Error("relay ping failed"));
|
|
@@ -15388,7 +15640,7 @@ function connectSession2(ws, opts, log) {
|
|
|
15388
15640
|
const label = opts.deviceLabel?.trim() || opts.deviceId.trim();
|
|
15389
15641
|
log(`Relay connected \xB7 ${label}`);
|
|
15390
15642
|
for (const wsInfo of opts.workspaces) {
|
|
15391
|
-
|
|
15643
|
+
send3(ws, {
|
|
15392
15644
|
type: "register",
|
|
15393
15645
|
teamId: wsInfo.teamId,
|
|
15394
15646
|
userId: wsInfo.userId,
|
|
@@ -15441,7 +15693,7 @@ function connectSession2(ws, opts, log) {
|
|
|
15441
15693
|
return;
|
|
15442
15694
|
}
|
|
15443
15695
|
pending.set(msg.eventId, msg.message);
|
|
15444
|
-
|
|
15696
|
+
send3(ws, { type: "claim", eventId: msg.eventId });
|
|
15445
15697
|
if (!relayAnswersClaims) {
|
|
15446
15698
|
const eventId = msg.eventId;
|
|
15447
15699
|
const timer = setTimeout(() => {
|
|
@@ -15525,12 +15777,12 @@ function formatSlackInboundPrompt(msg) {
|
|
|
15525
15777
|
|
|
15526
15778
|
${msg.text}`;
|
|
15527
15779
|
}
|
|
15528
|
-
function isSlackInboundUserPrompt(
|
|
15529
|
-
return
|
|
15780
|
+
function isSlackInboundUserPrompt(text6) {
|
|
15781
|
+
return text6.startsWith("Slack DM\n") || text6.startsWith("Slack @mention\n");
|
|
15530
15782
|
}
|
|
15531
|
-
function formatSlackSignedReply(deviceLabel,
|
|
15783
|
+
function formatSlackSignedReply(deviceLabel, text6) {
|
|
15532
15784
|
const label = deviceLabel.trim();
|
|
15533
|
-
const body =
|
|
15785
|
+
const body = text6.trim();
|
|
15534
15786
|
if (!body) return body;
|
|
15535
15787
|
if (!label) return body;
|
|
15536
15788
|
const head = `${label}:`;
|
|
@@ -15539,8 +15791,8 @@ function formatSlackSignedReply(deviceLabel, text5) {
|
|
|
15539
15791
|
}
|
|
15540
15792
|
return `${label}: ${body}`;
|
|
15541
15793
|
}
|
|
15542
|
-
function signForThisMac(
|
|
15543
|
-
return formatSlackSignedReply(ensureSlackDeviceIdentity().deviceLabel,
|
|
15794
|
+
function signForThisMac(text6) {
|
|
15795
|
+
return formatSlackSignedReply(ensureSlackDeviceIdentity().deviceLabel, text6);
|
|
15544
15796
|
}
|
|
15545
15797
|
function slackReplyThreadTs(msg) {
|
|
15546
15798
|
if (msg.threadTs && msg.threadTs !== msg.ts) return msg.threadTs;
|
|
@@ -15601,9 +15853,9 @@ function replyStub(target) {
|
|
|
15601
15853
|
kind: "dm"
|
|
15602
15854
|
};
|
|
15603
15855
|
}
|
|
15604
|
-
async function postSlackText(target,
|
|
15856
|
+
async function postSlackText(target, text6, opts) {
|
|
15605
15857
|
if (opts.postReply) {
|
|
15606
|
-
const result = await opts.postReply(replyStub(target),
|
|
15858
|
+
const result = await opts.postReply(replyStub(target), text6);
|
|
15607
15859
|
const ts2 = result && typeof result === "object" && typeof result.ts === "string" ? result.ts.trim() : "";
|
|
15608
15860
|
return ts2 ? { ts: ts2 } : null;
|
|
15609
15861
|
}
|
|
@@ -15613,7 +15865,7 @@ async function postSlackText(target, text5, opts) {
|
|
|
15613
15865
|
"chat.postMessage",
|
|
15614
15866
|
{
|
|
15615
15867
|
channel: target.channelId,
|
|
15616
|
-
text:
|
|
15868
|
+
text: text6,
|
|
15617
15869
|
thread_ts: target.threadTs
|
|
15618
15870
|
},
|
|
15619
15871
|
opts.fetchImpl
|
|
@@ -15621,9 +15873,9 @@ async function postSlackText(target, text5, opts) {
|
|
|
15621
15873
|
const ts = json.ts?.trim();
|
|
15622
15874
|
return ts ? { ts } : null;
|
|
15623
15875
|
}
|
|
15624
|
-
async function updateSlackText(target, ts,
|
|
15876
|
+
async function updateSlackText(target, ts, text6, opts) {
|
|
15625
15877
|
if (opts.updateReply) {
|
|
15626
|
-
await opts.updateReply(replyStub(target), ts,
|
|
15878
|
+
await opts.updateReply(replyStub(target), ts, text6);
|
|
15627
15879
|
return;
|
|
15628
15880
|
}
|
|
15629
15881
|
const token = writeTokenForTeam(target.teamId);
|
|
@@ -15633,7 +15885,7 @@ async function updateSlackText(target, ts, text5, opts) {
|
|
|
15633
15885
|
{
|
|
15634
15886
|
channel: target.channelId,
|
|
15635
15887
|
ts,
|
|
15636
|
-
text:
|
|
15888
|
+
text: text6
|
|
15637
15889
|
},
|
|
15638
15890
|
opts.fetchImpl
|
|
15639
15891
|
);
|
|
@@ -15661,8 +15913,8 @@ function replyTargetOf(msg) {
|
|
|
15661
15913
|
threadTs: slackReplyThreadTs(msg)
|
|
15662
15914
|
};
|
|
15663
15915
|
}
|
|
15664
|
-
async function postSlackReply(msg,
|
|
15665
|
-
await postSlackText(replyTargetOf(msg), signForThisMac(
|
|
15916
|
+
async function postSlackReply(msg, text6, opts) {
|
|
15917
|
+
await postSlackText(replyTargetOf(msg), signForThisMac(text6), opts);
|
|
15666
15918
|
}
|
|
15667
15919
|
function startSlackTurnProgress(msg, threadId, opts) {
|
|
15668
15920
|
const log = opts.onLog ?? (() => void 0);
|
|
@@ -15745,10 +15997,10 @@ function startSlackTurnProgress(msg, threadId, opts) {
|
|
|
15745
15997
|
}
|
|
15746
15998
|
});
|
|
15747
15999
|
},
|
|
15748
|
-
finishWith: (
|
|
16000
|
+
finishWith: (text6) => {
|
|
15749
16001
|
stop();
|
|
15750
16002
|
return run2(async () => {
|
|
15751
|
-
const signed2 = signForThisMac(
|
|
16003
|
+
const signed2 = signForThisMac(text6.trim());
|
|
15752
16004
|
if (!signed2) {
|
|
15753
16005
|
if (!postedTs) return;
|
|
15754
16006
|
const ts = postedTs;
|
|
@@ -15776,11 +16028,11 @@ function startSlackTurnProgress(msg, threadId, opts) {
|
|
|
15776
16028
|
};
|
|
15777
16029
|
}
|
|
15778
16030
|
var lastRelayed = /* @__PURE__ */ new Map();
|
|
15779
|
-
function markRelayed(threadId,
|
|
15780
|
-
lastRelayed.set(threadId, `${threadId}:${
|
|
16031
|
+
function markRelayed(threadId, text6) {
|
|
16032
|
+
lastRelayed.set(threadId, `${threadId}:${text6}`);
|
|
15781
16033
|
}
|
|
15782
|
-
function alreadyRelayed(threadId,
|
|
15783
|
-
return lastRelayed.get(threadId) === `${threadId}:${
|
|
16034
|
+
function alreadyRelayed(threadId, text6) {
|
|
16035
|
+
return lastRelayed.get(threadId) === `${threadId}:${text6}`;
|
|
15784
16036
|
}
|
|
15785
16037
|
async function relayCoordinatorReplyToSlack(threadId, opts) {
|
|
15786
16038
|
const target = getSlackReplyTarget(threadId);
|
|
@@ -15791,14 +16043,14 @@ async function relayCoordinatorReplyToSlack(threadId, opts) {
|
|
|
15791
16043
|
return;
|
|
15792
16044
|
}
|
|
15793
16045
|
const result = getOrchestrator().getTurnResult(threadId);
|
|
15794
|
-
const
|
|
15795
|
-
if (!
|
|
15796
|
-
if (alreadyRelayed(threadId,
|
|
15797
|
-
markRelayed(threadId,
|
|
16046
|
+
const text6 = formatSlackTurnReply(result);
|
|
16047
|
+
if (!text6) return;
|
|
16048
|
+
if (alreadyRelayed(threadId, text6)) return;
|
|
16049
|
+
markRelayed(threadId, text6);
|
|
15798
16050
|
const log = opts.onLog ?? (() => void 0);
|
|
15799
16051
|
try {
|
|
15800
|
-
await postSlackText(target, signForThisMac(
|
|
15801
|
-
log(`replied ${target.threadTs ?? target.channelId} (${
|
|
16052
|
+
await postSlackText(target, signForThisMac(text6), opts);
|
|
16053
|
+
log(`replied ${target.threadTs ?? target.channelId} (${text6.length} chars)`);
|
|
15802
16054
|
} catch (err) {
|
|
15803
16055
|
lastRelayed.delete(threadId);
|
|
15804
16056
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
@@ -16114,13 +16366,13 @@ async function relayFetch(fetchImpl, url, init) {
|
|
|
16114
16366
|
throw relayFetchError(err, url);
|
|
16115
16367
|
}
|
|
16116
16368
|
}
|
|
16117
|
-
async function readJson4(res, url) {
|
|
16369
|
+
async function readJson4(res, url, what = "sign-in") {
|
|
16118
16370
|
try {
|
|
16119
16371
|
return await res.json();
|
|
16120
16372
|
} catch {
|
|
16121
16373
|
const kind = (res.headers.get("content-type") ?? "").includes("html") ? "an HTML page" : "a non-JSON body";
|
|
16122
16374
|
throw new Error(
|
|
16123
|
-
`Relay
|
|
16375
|
+
`Relay ${what} returned HTTP ${res.status} with ${kind} (${url}). A work proxy or allowlist often answers with a block page instead of the relay.`
|
|
16124
16376
|
);
|
|
16125
16377
|
}
|
|
16126
16378
|
}
|
|
@@ -16187,6 +16439,44 @@ async function disconnectRemoteAccount(opts) {
|
|
|
16187
16439
|
body: JSON.stringify({ accountToken: opts.accountToken })
|
|
16188
16440
|
});
|
|
16189
16441
|
}
|
|
16442
|
+
function macRows(value) {
|
|
16443
|
+
if (!Array.isArray(value)) return [];
|
|
16444
|
+
const macs = [];
|
|
16445
|
+
for (const row2 of value) {
|
|
16446
|
+
if (!row2 || typeof row2 !== "object") continue;
|
|
16447
|
+
const deviceId = "deviceId" in row2 && typeof row2.deviceId === "string" ? row2.deviceId.trim() : "";
|
|
16448
|
+
const deviceLabel = "deviceLabel" in row2 && typeof row2.deviceLabel === "string" ? row2.deviceLabel : "";
|
|
16449
|
+
const createdAt = "createdAt" in row2 && typeof row2.createdAt === "number" ? row2.createdAt : 0;
|
|
16450
|
+
if (!deviceId) continue;
|
|
16451
|
+
macs.push({ deviceId, deviceLabel, createdAt });
|
|
16452
|
+
}
|
|
16453
|
+
return macs;
|
|
16454
|
+
}
|
|
16455
|
+
async function listRemoteAccountMacs(opts) {
|
|
16456
|
+
const origin = (opts.origin ?? remoteAccountHttpOrigin()).replace(/\/+$/, "");
|
|
16457
|
+
const url = `${origin}${REMOTE_MACS_PATH}`;
|
|
16458
|
+
const res = await relayFetch(opts.fetchImpl, url, {
|
|
16459
|
+
headers: { Authorization: `Bearer ${opts.accountToken}` }
|
|
16460
|
+
});
|
|
16461
|
+
const body = await readJson4(res, url, "Mac list");
|
|
16462
|
+
if (!res.ok || !body.ok) {
|
|
16463
|
+
throw new Error(body.error || `Could not list Macs (HTTP ${res.status}).`);
|
|
16464
|
+
}
|
|
16465
|
+
return macRows(body.macs);
|
|
16466
|
+
}
|
|
16467
|
+
async function forgetRemoteAccountMac(opts) {
|
|
16468
|
+
const origin = (opts.origin ?? remoteAccountHttpOrigin()).replace(/\/+$/, "");
|
|
16469
|
+
const url = `${origin}${REMOTE_MACS_FORGET_PATH}`;
|
|
16470
|
+
const res = await relayFetch(opts.fetchImpl, url, {
|
|
16471
|
+
method: "POST",
|
|
16472
|
+
headers: { "Content-Type": "application/json" },
|
|
16473
|
+
body: JSON.stringify({ accountToken: opts.accountToken, deviceId: opts.deviceId })
|
|
16474
|
+
});
|
|
16475
|
+
const body = await readJson4(res, url, "forget Mac");
|
|
16476
|
+
if (!res.ok || !body.ok) {
|
|
16477
|
+
throw new Error(body.error || `Could not forget that Mac (HTTP ${res.status}).`);
|
|
16478
|
+
}
|
|
16479
|
+
}
|
|
16190
16480
|
|
|
16191
16481
|
// src/slack/outbound-watch.ts
|
|
16192
16482
|
import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
|
|
@@ -16243,8 +16533,8 @@ ${input.permalink}` : "";
|
|
|
16243
16533
|
|
|
16244
16534
|
${body}${link}`;
|
|
16245
16535
|
}
|
|
16246
|
-
function isSlackExternalReplyPrompt(
|
|
16247
|
-
return isSlackExternalReplyText(
|
|
16536
|
+
function isSlackExternalReplyPrompt(text6) {
|
|
16537
|
+
return isSlackExternalReplyText(text6);
|
|
16248
16538
|
}
|
|
16249
16539
|
function pendingSlackExternalReplies(messages) {
|
|
16250
16540
|
return pendingInjectedNotices(messages, isSlackExternalReplyText);
|
|
@@ -16265,7 +16555,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
16265
16555
|
await continueOnReply(threadId, prompt);
|
|
16266
16556
|
return;
|
|
16267
16557
|
}
|
|
16268
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
16558
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-3I2FLEZL.js");
|
|
16269
16559
|
await getOrchestrator2().send(threadId, prompt);
|
|
16270
16560
|
} catch {
|
|
16271
16561
|
}
|
|
@@ -16273,9 +16563,9 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
16273
16563
|
function listSlackOutboundWatches() {
|
|
16274
16564
|
return pruneWatches(readStore3());
|
|
16275
16565
|
}
|
|
16276
|
-
function formatOwnerSlackFyi(userName,
|
|
16566
|
+
function formatOwnerSlackFyi(userName, text6) {
|
|
16277
16567
|
const who = userName.trim() || "Someone";
|
|
16278
|
-
const body =
|
|
16568
|
+
const body = text6.trim() || "(no text)";
|
|
16279
16569
|
return `${who} replied in Slack:
|
|
16280
16570
|
${body}`;
|
|
16281
16571
|
}
|
|
@@ -16290,7 +16580,7 @@ async function relayExternalReply(opts) {
|
|
|
16290
16580
|
const thread = readThread(threadId);
|
|
16291
16581
|
if (!thread || thread.status === "archived") return "ignored";
|
|
16292
16582
|
try {
|
|
16293
|
-
const
|
|
16583
|
+
const text6 = formatSlackExternalReplyPrompt({
|
|
16294
16584
|
userName: opts.reply.userName,
|
|
16295
16585
|
kind: opts.watch.kind,
|
|
16296
16586
|
toLabel: opts.watch.toLabel,
|
|
@@ -16299,7 +16589,7 @@ async function relayExternalReply(opts) {
|
|
|
16299
16589
|
});
|
|
16300
16590
|
appendMessage(threadId, {
|
|
16301
16591
|
role: "agent",
|
|
16302
|
-
text:
|
|
16592
|
+
text: text6,
|
|
16303
16593
|
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
16304
16594
|
});
|
|
16305
16595
|
} catch {
|
|
@@ -16536,6 +16826,8 @@ export {
|
|
|
16536
16826
|
ABLETIME_ORG_KEY_PREFIX,
|
|
16537
16827
|
ABLETIME_PAT_PREFIX,
|
|
16538
16828
|
ABLETIME_PM_TOOL_NAMES,
|
|
16829
|
+
ACP_HARNESSES,
|
|
16830
|
+
ACP_HARNESS_IDS,
|
|
16539
16831
|
AGENT_DONE_CUSTOM_SOUND_EXTENSIONS,
|
|
16540
16832
|
AGENT_DONE_CUSTOM_SOUND_MAX_BYTES,
|
|
16541
16833
|
AGENT_DONE_SOUNDS,
|
|
@@ -16701,6 +16993,12 @@ export {
|
|
|
16701
16993
|
abletimeToolUsesPm,
|
|
16702
16994
|
accountIdToPin,
|
|
16703
16995
|
ackSlackInboundSeen,
|
|
16996
|
+
acpAdapter,
|
|
16997
|
+
acpHarnessDisplayName,
|
|
16998
|
+
acpHarnessLabel,
|
|
16999
|
+
acpHarnessLooksAuthenticated,
|
|
17000
|
+
acpHarnessStatus,
|
|
17001
|
+
acpRunnerPath,
|
|
16704
17002
|
activeAccountId,
|
|
16705
17003
|
activeRunPreview,
|
|
16706
17004
|
addBoardPin,
|
|
@@ -16714,6 +17012,7 @@ export {
|
|
|
16714
17012
|
agentDoneSoundsDir,
|
|
16715
17013
|
agentGitPrompt,
|
|
16716
17014
|
agentRpcConnectFromMetadata,
|
|
17015
|
+
agentSupportsAttach,
|
|
16717
17016
|
alignQueueAttachments,
|
|
16718
17017
|
allAdapters,
|
|
16719
17018
|
allocatePort,
|
|
@@ -16875,6 +17174,7 @@ export {
|
|
|
16875
17174
|
cursorIssuesUnavailableReason,
|
|
16876
17175
|
cursorSdkMessageToEvents,
|
|
16877
17176
|
decodeBrightsyTarget,
|
|
17177
|
+
defaultAcpHarness,
|
|
16878
17178
|
defaultOrderSubject,
|
|
16879
17179
|
defaultScheduleName,
|
|
16880
17180
|
deleteBranchOnPurgeEnabled,
|
|
@@ -16883,6 +17183,8 @@ export {
|
|
|
16883
17183
|
deleteThreadRecord,
|
|
16884
17184
|
deriveTaskState,
|
|
16885
17185
|
desktopHostPidPath,
|
|
17186
|
+
detectAcpHarness,
|
|
17187
|
+
detectAcpHarnesses,
|
|
16886
17188
|
detectAgents,
|
|
16887
17189
|
detectGhStack,
|
|
16888
17190
|
detectLocalMergeConflicts,
|
|
@@ -16960,6 +17262,7 @@ export {
|
|
|
16960
17262
|
flipLinearRelationType,
|
|
16961
17263
|
foldLegacyRolesIntoNotes,
|
|
16962
17264
|
followUpBehavior,
|
|
17265
|
+
forgetRemoteAccountMac,
|
|
16963
17266
|
forkChatTab,
|
|
16964
17267
|
forkMessageSlice,
|
|
16965
17268
|
forkThreadWorktree,
|
|
@@ -17128,6 +17431,7 @@ export {
|
|
|
17128
17431
|
isAbleTimeConnected,
|
|
17129
17432
|
isAbleTimeOAuthCancelled,
|
|
17130
17433
|
isAbleTimeRejectedCredential,
|
|
17434
|
+
isAcpHarnessId,
|
|
17131
17435
|
isAdoptableRunScriptRequest,
|
|
17132
17436
|
isAgentDoneSound,
|
|
17133
17437
|
isAskUserToolName,
|
|
@@ -17260,6 +17564,7 @@ export {
|
|
|
17260
17564
|
listOrderPlans,
|
|
17261
17565
|
listOrderRows,
|
|
17262
17566
|
listPrs,
|
|
17567
|
+
listRemoteAccountMacs,
|
|
17263
17568
|
listRunScripts,
|
|
17264
17569
|
listSchedules,
|
|
17265
17570
|
listSlackOutboundWatches,
|
|
@@ -17457,6 +17762,7 @@ export {
|
|
|
17457
17762
|
resolveAccountForThread,
|
|
17458
17763
|
resolveAccountProfile,
|
|
17459
17764
|
resolveAccountProfileFromSettings,
|
|
17765
|
+
resolveAcpHarnessCommand,
|
|
17460
17766
|
resolveAgentExecutable,
|
|
17461
17767
|
resolveAgentGitAuthEnv,
|
|
17462
17768
|
resolveClaudeExecutable,
|