@sideboard-ai/core 0.1.336 → 0.1.338
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/{agents-ISEAOZD5.js → agents-4ZABRO2T.js} +2 -2
- package/dist/{agents-VTLFLMMT.js → agents-MM6VNDOI.js} +2 -2
- package/dist/{chunk-B6TPN624.js → chunk-2QN74PVY.js} +54 -13
- package/dist/{chunk-MGEUXR6E.js → chunk-BR3C3EX5.js} +3 -2
- package/dist/{chunk-EKI7D2AJ.js → chunk-JGJIR66Z.js} +75 -14
- package/dist/{chunk-NB4U75TJ.js → chunk-LJESHMFJ.js} +2 -2
- package/dist/{chunk-4O7436ZH.js → chunk-QJGAWDAX.js} +54 -13
- package/dist/{chunk-CDRGQ6GX.js → chunk-T76WCIQN.js} +3 -2
- package/dist/{chunk-PSXBOMXI.js → chunk-UPZD4SYD.js} +74 -13
- package/dist/{chunk-54GBJC6J.js → chunk-X3W3HBLK.js} +2 -2
- package/dist/{conductor-JH26KU3W.js → conductor-HKZKX2JD.js} +2 -2
- package/dist/{conductor-77L3QTZ2.js → conductor-OTYQMFNT.js} +2 -2
- package/dist/{coordinator-prompt-WVVC2TLP.js → coordinator-prompt-AHR54RWJ.js} +1 -1
- package/dist/{coordinator-prompt-UKJJAMBG.js → coordinator-prompt-GMGYQ5XT.js} +1 -1
- package/dist/{global-workspace-QDIPRW6G.js → global-workspace-TDR6OHL6.js} +1 -1
- package/dist/{global-workspace-B5IHENCP.js → global-workspace-WRME3OJ5.js} +1 -1
- package/dist/index.cjs +345 -171
- package/dist/index.d.cts +3 -10
- package/dist/index.d.ts +3 -10
- package/dist/index.js +207 -157
- package/dist/mcp/run-stdio.cjs +140 -20
- package/dist/mcp/run-stdio.js +4 -4
- package/dist/{orchestrator-ZUIU667R.js → orchestrator-CJBYJVD7.js} +4 -4
- package/dist/{orchestrator-BOLYQZO7.js → orchestrator-NXLV3FF4.js} +4 -4
- package/dist/{workspaces-VXE2MBKD.js → workspaces-7ZB6GUXB.js} +1 -1
- package/dist/{workspaces-WZZNNUJL.js → workspaces-XXO2T45C.js} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
worktreeCleanupSettings,
|
|
220
220
|
writeAgentBlock,
|
|
221
221
|
writeWorktreeFile
|
|
222
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-JGJIR66Z.js";
|
|
223
223
|
import {
|
|
224
224
|
OPTIONAL_SERVICES,
|
|
225
225
|
OPTIONAL_SERVICE_IDS,
|
|
@@ -380,7 +380,7 @@ import {
|
|
|
380
380
|
userMcpNamesToDisable,
|
|
381
381
|
worktreeMcpToolNames,
|
|
382
382
|
writeInjectedMcpConfig
|
|
383
|
-
} from "./chunk-
|
|
383
|
+
} from "./chunk-LJESHMFJ.js";
|
|
384
384
|
import {
|
|
385
385
|
getAgentSetupInfo,
|
|
386
386
|
installAgent,
|
|
@@ -483,6 +483,7 @@ import {
|
|
|
483
483
|
messagesForCompactArchive,
|
|
484
484
|
messagesSinceLastBrightsyContextSummary,
|
|
485
485
|
needsCoordinatorAction,
|
|
486
|
+
orchestratorPromisedLaterReport,
|
|
486
487
|
readExistingReviewRequestFile,
|
|
487
488
|
readWorktreeInclude,
|
|
488
489
|
requestReview,
|
|
@@ -513,7 +514,7 @@ import {
|
|
|
513
514
|
workspaceAgentChatSummaries,
|
|
514
515
|
worktreeRunPortsPath,
|
|
515
516
|
wrapReviewSkillMarkdown
|
|
516
|
-
} from "./chunk-
|
|
517
|
+
} from "./chunk-2QN74PVY.js";
|
|
517
518
|
import {
|
|
518
519
|
STDERR_EVENT_MAX_CHARS,
|
|
519
520
|
STDOUT_EVENT_MAX_CHARS,
|
|
@@ -656,7 +657,7 @@ import {
|
|
|
656
657
|
stageBuffersAsAttachments,
|
|
657
658
|
syncWorkspacesFromThreads,
|
|
658
659
|
takenTeamSlugsForOrchestration
|
|
659
|
-
} from "./chunk-
|
|
660
|
+
} from "./chunk-T76WCIQN.js";
|
|
660
661
|
import {
|
|
661
662
|
GITHUB_PR_BODY_MAX_CHARS,
|
|
662
663
|
GITHUB_PR_BODY_SAFE_CHARS,
|
|
@@ -2233,7 +2234,8 @@ function row(resolved) {
|
|
|
2233
2234
|
function phoneAccountDefaults() {
|
|
2234
2235
|
return {
|
|
2235
2236
|
orchestration: row(resolveOrchestratorDefaults()),
|
|
2236
|
-
worktree: row(resolveThreadDefaults())
|
|
2237
|
+
worktree: row(resolveThreadDefaults()),
|
|
2238
|
+
followUp: followUpBehavior()
|
|
2237
2239
|
};
|
|
2238
2240
|
}
|
|
2239
2241
|
|
|
@@ -4843,7 +4845,10 @@ function phoneBoardKey(sidebar) {
|
|
|
4843
4845
|
${trees}`;
|
|
4844
4846
|
}).join("\n---\n");
|
|
4845
4847
|
const defaults = sidebar.defaults;
|
|
4846
|
-
const defaultsKey = defaults ? [
|
|
4848
|
+
const defaultsKey = defaults ? [
|
|
4849
|
+
defaults.followUp,
|
|
4850
|
+
[defaults.orchestration, defaults.worktree].map((row2) => [row2.agent, row2.model ?? "", row2.effort, row2.fast ? "1" : "0"].join(" ")).join("\n")
|
|
4851
|
+
].join("\n") : "";
|
|
4847
4852
|
return `${orchestration}
|
|
4848
4853
|
===
|
|
4849
4854
|
${projects}
|
|
@@ -5243,6 +5248,77 @@ function runRemoteHost(opts) {
|
|
|
5243
5248
|
import { createServer } from "http";
|
|
5244
5249
|
import { WebSocketServer } from "ws";
|
|
5245
5250
|
|
|
5251
|
+
// src/relay/oauth-return-page.ts
|
|
5252
|
+
function oauthReturnPage(title, body) {
|
|
5253
|
+
return `<!DOCTYPE html>
|
|
5254
|
+
<html lang="en">
|
|
5255
|
+
<head>
|
|
5256
|
+
<meta charset="utf-8">
|
|
5257
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5258
|
+
<meta name="robots" content="noindex">
|
|
5259
|
+
<title>${escapeHtml(title)}</title>
|
|
5260
|
+
<style>
|
|
5261
|
+
:root {
|
|
5262
|
+
--bg: #09090b;
|
|
5263
|
+
--card: #16171b;
|
|
5264
|
+
--line: rgba(255, 255, 255, 0.08);
|
|
5265
|
+
--text: #f4f5f7;
|
|
5266
|
+
--muted: #9aa3ad;
|
|
5267
|
+
--blue: #3b9eff;
|
|
5268
|
+
--blue-fill: #0f7ed4;
|
|
5269
|
+
}
|
|
5270
|
+
* { box-sizing: border-box }
|
|
5271
|
+
body {
|
|
5272
|
+
margin: 0;
|
|
5273
|
+
min-height: 100vh;
|
|
5274
|
+
display: grid;
|
|
5275
|
+
place-items: center;
|
|
5276
|
+
padding: 48px 24px;
|
|
5277
|
+
background:
|
|
5278
|
+
radial-gradient(closest-side, rgba(15, 126, 212, 0.22), transparent 72%) center -120px / 720px 480px no-repeat,
|
|
5279
|
+
var(--bg);
|
|
5280
|
+
color: var(--text);
|
|
5281
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
|
|
5282
|
+
-webkit-font-smoothing: antialiased;
|
|
5283
|
+
}
|
|
5284
|
+
main {
|
|
5285
|
+
width: min(28rem, 100%);
|
|
5286
|
+
background: var(--card);
|
|
5287
|
+
border: 1px solid var(--line);
|
|
5288
|
+
border-radius: 16px;
|
|
5289
|
+
padding: 28px 28px 32px;
|
|
5290
|
+
}
|
|
5291
|
+
.brand {
|
|
5292
|
+
display: flex;
|
|
5293
|
+
align-items: center;
|
|
5294
|
+
gap: 10px;
|
|
5295
|
+
margin: 0 0 22px;
|
|
5296
|
+
font-weight: 650;
|
|
5297
|
+
font-size: 17px;
|
|
5298
|
+
letter-spacing: -0.02em;
|
|
5299
|
+
}
|
|
5300
|
+
.mark { position: relative; display: inline-block; width: 26px; height: 26px; flex: none }
|
|
5301
|
+
.mark i { position: absolute; width: 18px; height: 18px; border-radius: 3px; transform: rotate(14deg) }
|
|
5302
|
+
.mark i:first-child { left: 6px; top: 6px; background: var(--blue-fill) }
|
|
5303
|
+
.mark i:last-child { left: 1px; top: 1px; border: 2px solid #d7dbdf }
|
|
5304
|
+
h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.03em; font-weight: 650 }
|
|
5305
|
+
p { margin: 10px 0 0; line-height: 1.55; color: var(--muted) }
|
|
5306
|
+
strong { color: var(--text); font-weight: 650 }
|
|
5307
|
+
a { color: var(--blue) }
|
|
5308
|
+
</style>
|
|
5309
|
+
</head>
|
|
5310
|
+
<body>
|
|
5311
|
+
<main>
|
|
5312
|
+
<div class="brand"><span class="mark" aria-hidden="true"><i></i><i></i></span>Sideboard</div>
|
|
5313
|
+
${body}
|
|
5314
|
+
</main>
|
|
5315
|
+
</body>
|
|
5316
|
+
</html>`;
|
|
5317
|
+
}
|
|
5318
|
+
function escapeHtml(value) {
|
|
5319
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5246
5322
|
// src/slack/oauth-redirect.ts
|
|
5247
5323
|
var SLACK_OAUTH_CALLBACK_PATH = "/slack/callback";
|
|
5248
5324
|
var SLACK_OAUTH_RESULT_PATH = "/slack/oauth/result";
|
|
@@ -5253,13 +5329,11 @@ var SLACK_OAUTH_REDIRECT = `https://relay.sideboard.build${SLACK_OAUTH_CALLBACK_
|
|
|
5253
5329
|
function slackOAuthRedirectUri() {
|
|
5254
5330
|
return process.env.SIDEBOARD_SLACK_OAUTH_REDIRECT?.trim() || SLACK_OAUTH_REDIRECT;
|
|
5255
5331
|
}
|
|
5256
|
-
function
|
|
5332
|
+
function escapeHtml2(value) {
|
|
5257
5333
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5258
5334
|
}
|
|
5259
5335
|
function slackOAuthHtmlPage(title, body) {
|
|
5260
|
-
return
|
|
5261
|
-
<style>body{font-family:ui-sans-serif,system-ui,sans-serif;padding:48px 24px;max-width:36rem;margin:0 auto;color:#1a1a1a}
|
|
5262
|
-
h1{font-size:1.25rem}p{line-height:1.5;color:#444}</style></head><body>${body}</body></html>`;
|
|
5336
|
+
return oauthReturnPage(title, body);
|
|
5263
5337
|
}
|
|
5264
5338
|
|
|
5265
5339
|
// src/slack/baked-app.ts
|
|
@@ -5389,9 +5463,6 @@ async function slackApi(token, method, params, fetchImpl) {
|
|
|
5389
5463
|
}
|
|
5390
5464
|
return json;
|
|
5391
5465
|
}
|
|
5392
|
-
async function slackAuthTest(token) {
|
|
5393
|
-
return slackApi(token, "auth.test");
|
|
5394
|
-
}
|
|
5395
5466
|
|
|
5396
5467
|
// src/slack/socket-mode.ts
|
|
5397
5468
|
var BACKOFF_START_MS2 = 1e3;
|
|
@@ -5809,41 +5880,6 @@ function disconnectSlackWorkspace(teamId) {
|
|
|
5809
5880
|
writeStore(readStore().filter((ws) => ws.team_id !== id));
|
|
5810
5881
|
return listSlackWorkspaces();
|
|
5811
5882
|
}
|
|
5812
|
-
function tokenKind(token) {
|
|
5813
|
-
if (token.startsWith("xoxb-")) return "bot";
|
|
5814
|
-
if (token.startsWith("xoxp-") || token.startsWith("xoxe.xoxp-")) return "user";
|
|
5815
|
-
return "unknown";
|
|
5816
|
-
}
|
|
5817
|
-
async function connectSlackToken(rawToken) {
|
|
5818
|
-
const token = rawToken.trim();
|
|
5819
|
-
if (!token) throw new Error("Paste a Slack bot (xoxb-) or user (xoxp-) token");
|
|
5820
|
-
const auth = await slackAuthTest(token);
|
|
5821
|
-
const teamId = auth.team_id?.trim();
|
|
5822
|
-
if (!teamId) throw new Error("Slack auth.test did not return a team_id");
|
|
5823
|
-
const existing = getSlackWorkspace(teamId);
|
|
5824
|
-
const kind = tokenKind(token);
|
|
5825
|
-
const authUserId = auth.user_id?.trim();
|
|
5826
|
-
const userId = kind === "bot" ? existing?.user_id || authUserId : authUserId || existing?.user_id;
|
|
5827
|
-
const next = {
|
|
5828
|
-
team_id: teamId,
|
|
5829
|
-
team_name: auth.team?.trim() || existing?.team_name || teamId,
|
|
5830
|
-
user_id: userId,
|
|
5831
|
-
bot_token: kind === "bot" ? token : existing?.bot_token,
|
|
5832
|
-
user_token: kind === "user" || kind === "unknown" ? token : existing?.user_token,
|
|
5833
|
-
listen_grant: existing?.user_id && userId && existing.user_id !== userId ? void 0 : existing?.listen_grant,
|
|
5834
|
-
scopes: existing?.scopes,
|
|
5835
|
-
connected_at: existing?.connected_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
5836
|
-
};
|
|
5837
|
-
if (kind === "unknown" && auth.bot_id) {
|
|
5838
|
-
next.bot_token = token;
|
|
5839
|
-
next.user_token = existing?.user_token;
|
|
5840
|
-
next.user_id = existing?.user_id || authUserId;
|
|
5841
|
-
if (existing?.user_id && next.user_id && existing.user_id !== next.user_id) {
|
|
5842
|
-
next.listen_grant = void 0;
|
|
5843
|
-
}
|
|
5844
|
-
}
|
|
5845
|
-
return upsertSlackWorkspace(next);
|
|
5846
|
-
}
|
|
5847
5883
|
function slackTokenFor(ws, _kind = "read") {
|
|
5848
5884
|
const token = (ws.bot_token || ws.user_token)?.trim();
|
|
5849
5885
|
if (!token) {
|
|
@@ -5876,7 +5912,7 @@ function slackOAuthCredentials() {
|
|
|
5876
5912
|
const clientSecret = process.env.SIDEBOARD_SLACK_CLIENT_SECRET?.trim() || settings.integrations.slackClientSecret?.trim() || "";
|
|
5877
5913
|
if (!clientId) {
|
|
5878
5914
|
throw new Error(
|
|
5879
|
-
"Slack browser sign-in needs a Slack app Client ID (Settings \u2192 Collaboration, or SIDEBOARD_SLACK_CLIENT_ID).
|
|
5915
|
+
"Slack browser sign-in needs a Slack app Client ID (Settings \u2192 Collaboration, or SIDEBOARD_SLACK_CLIENT_ID)."
|
|
5880
5916
|
);
|
|
5881
5917
|
}
|
|
5882
5918
|
return { clientId, clientSecret: clientSecret || null };
|
|
@@ -6016,7 +6052,7 @@ function slackOrgManifest(opts) {
|
|
|
6016
6052
|
|
|
6017
6053
|
features:
|
|
6018
6054
|
app_home:
|
|
6019
|
-
home_tab_enabled:
|
|
6055
|
+
home_tab_enabled: false
|
|
6020
6056
|
messages_tab_enabled: true
|
|
6021
6057
|
messages_tab_read_only_enabled: false
|
|
6022
6058
|
bot_user:
|
|
@@ -6194,7 +6230,7 @@ async function handleCallback(ctx, url) {
|
|
|
6194
6230
|
const code = url.searchParams.get("code")?.trim() ?? "";
|
|
6195
6231
|
if (error) {
|
|
6196
6232
|
if (state) ctx.pending.put(state, { ok: false, error: `Slack OAuth: ${error}` });
|
|
6197
|
-
sendHtml(ctx.res, 400, "Slack", `<h1>Authorization cancelled</h1><p>${
|
|
6233
|
+
sendHtml(ctx.res, 400, "Slack", `<h1>Authorization cancelled</h1><p>${escapeHtml2(error)}</p>`);
|
|
6198
6234
|
return true;
|
|
6199
6235
|
}
|
|
6200
6236
|
if (!state || !code) {
|
|
@@ -6239,7 +6275,7 @@ async function handleCallback(ctx, url) {
|
|
|
6239
6275
|
} catch (err) {
|
|
6240
6276
|
const message = err instanceof Error ? err.message : String(err);
|
|
6241
6277
|
ctx.pending.put(state, { ok: false, error: message });
|
|
6242
|
-
sendHtml(ctx.res, 400, "Slack", `<h1>Could not connect Slack</h1><p>${
|
|
6278
|
+
sendHtml(ctx.res, 400, "Slack", `<h1>Could not connect Slack</h1><p>${escapeHtml2(message)}</p>`);
|
|
6243
6279
|
}
|
|
6244
6280
|
return true;
|
|
6245
6281
|
}
|
|
@@ -8199,74 +8235,9 @@ function sendJson2(res, status, body) {
|
|
|
8199
8235
|
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
8200
8236
|
res.end(JSON.stringify(body));
|
|
8201
8237
|
}
|
|
8202
|
-
function relayOAuthReturnPage(title, body) {
|
|
8203
|
-
return `<!DOCTYPE html>
|
|
8204
|
-
<html lang="en">
|
|
8205
|
-
<head>
|
|
8206
|
-
<meta charset="utf-8">
|
|
8207
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8208
|
-
<meta name="robots" content="noindex">
|
|
8209
|
-
<title>${escapeHtml(title)}</title>
|
|
8210
|
-
<style>
|
|
8211
|
-
:root {
|
|
8212
|
-
--bg: #09090b;
|
|
8213
|
-
--card: #16171b;
|
|
8214
|
-
--line: rgba(255, 255, 255, 0.08);
|
|
8215
|
-
--text: #f4f5f7;
|
|
8216
|
-
--muted: #9aa3ad;
|
|
8217
|
-
--blue: #3b9eff;
|
|
8218
|
-
--blue-fill: #0f7ed4;
|
|
8219
|
-
}
|
|
8220
|
-
* { box-sizing: border-box }
|
|
8221
|
-
body {
|
|
8222
|
-
margin: 0;
|
|
8223
|
-
min-height: 100vh;
|
|
8224
|
-
display: grid;
|
|
8225
|
-
place-items: center;
|
|
8226
|
-
padding: 48px 24px;
|
|
8227
|
-
background:
|
|
8228
|
-
radial-gradient(closest-side, rgba(15, 126, 212, 0.22), transparent 72%) center -120px / 720px 480px no-repeat,
|
|
8229
|
-
var(--bg);
|
|
8230
|
-
color: var(--text);
|
|
8231
|
-
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
|
|
8232
|
-
-webkit-font-smoothing: antialiased;
|
|
8233
|
-
}
|
|
8234
|
-
main {
|
|
8235
|
-
width: min(28rem, 100%);
|
|
8236
|
-
background: var(--card);
|
|
8237
|
-
border: 1px solid var(--line);
|
|
8238
|
-
border-radius: 16px;
|
|
8239
|
-
padding: 28px 28px 32px;
|
|
8240
|
-
}
|
|
8241
|
-
.brand {
|
|
8242
|
-
display: flex;
|
|
8243
|
-
align-items: center;
|
|
8244
|
-
gap: 10px;
|
|
8245
|
-
margin: 0 0 22px;
|
|
8246
|
-
font-weight: 650;
|
|
8247
|
-
font-size: 17px;
|
|
8248
|
-
letter-spacing: -0.02em;
|
|
8249
|
-
}
|
|
8250
|
-
.mark { position: relative; display: inline-block; width: 26px; height: 26px; flex: none }
|
|
8251
|
-
.mark i { position: absolute; width: 18px; height: 18px; border-radius: 3px; transform: rotate(14deg) }
|
|
8252
|
-
.mark i:first-child { left: 6px; top: 6px; background: var(--blue-fill) }
|
|
8253
|
-
.mark i:last-child { left: 1px; top: 1px; border: 2px solid #d7dbdf }
|
|
8254
|
-
h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.03em; font-weight: 650 }
|
|
8255
|
-
p { margin: 10px 0 0; line-height: 1.55; color: var(--muted) }
|
|
8256
|
-
a { color: var(--blue) }
|
|
8257
|
-
</style>
|
|
8258
|
-
</head>
|
|
8259
|
-
<body>
|
|
8260
|
-
<main>
|
|
8261
|
-
<div class="brand"><span class="mark" aria-hidden="true"><i></i><i></i></span>Sideboard</div>
|
|
8262
|
-
${body}
|
|
8263
|
-
</main>
|
|
8264
|
-
</body>
|
|
8265
|
-
</html>`;
|
|
8266
|
-
}
|
|
8267
8238
|
function sendHtml2(res, status, title, body) {
|
|
8268
8239
|
res.writeHead(status, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
8269
|
-
res.end(
|
|
8240
|
+
res.end(oauthReturnPage(title, body));
|
|
8270
8241
|
}
|
|
8271
8242
|
async function handleRelayAccountHttp(opts) {
|
|
8272
8243
|
const reqUrl = opts.req.url || "/";
|
|
@@ -8329,7 +8300,7 @@ async function handleRelayAccountHttp(opts) {
|
|
|
8329
8300
|
if (providerError || !credential) {
|
|
8330
8301
|
const message = providerError || "Sign-in was cancelled.";
|
|
8331
8302
|
opts.sessions.putResult(state, { ok: false, error: message });
|
|
8332
|
-
sendHtml2(opts.res, 400, "Sideboard", `<h1>Could not sign in</h1><p>${
|
|
8303
|
+
sendHtml2(opts.res, 400, "Sideboard", `<h1>Could not sign in</h1><p>${escapeHtml2(message)}</p>`);
|
|
8333
8304
|
return true;
|
|
8334
8305
|
}
|
|
8335
8306
|
const client = opts.oauth[pending.provider];
|
|
@@ -8364,7 +8335,7 @@ async function handleRelayAccountHttp(opts) {
|
|
|
8364
8335
|
} catch (err) {
|
|
8365
8336
|
const message = err instanceof Error ? err.message : String(err);
|
|
8366
8337
|
opts.sessions.putResult(state, { ok: false, error: message });
|
|
8367
|
-
sendHtml2(opts.res, 400, "Sideboard", `<h1>Could not sign in</h1><p>${
|
|
8338
|
+
sendHtml2(opts.res, 400, "Sideboard", `<h1>Could not sign in</h1><p>${escapeHtml2(message)}</p>`);
|
|
8368
8339
|
}
|
|
8369
8340
|
return true;
|
|
8370
8341
|
}
|
|
@@ -8414,10 +8385,23 @@ function sendJson3(res, status, body) {
|
|
|
8414
8385
|
res.end(JSON.stringify(body));
|
|
8415
8386
|
}
|
|
8416
8387
|
function relayClientIp(req) {
|
|
8388
|
+
if (process.env.SIDEBOARD_RELAY_TRUST_PROXY === "1") {
|
|
8389
|
+
const forwarded = req.headers["x-forwarded-for"];
|
|
8390
|
+
const raw = Array.isArray(forwarded) ? forwarded.join(",") : forwarded;
|
|
8391
|
+
const hop = raw?.split(",").map((part) => part.trim()).filter(Boolean).pop();
|
|
8392
|
+
if (hop) return hop;
|
|
8393
|
+
}
|
|
8417
8394
|
const fly = req.headers["fly-client-ip"];
|
|
8418
8395
|
if (typeof fly === "string" && fly.trim()) return fly.trim();
|
|
8419
8396
|
return req.socket.remoteAddress ?? "unknown";
|
|
8420
8397
|
}
|
|
8398
|
+
function assertRelayPublicOrigin(env = process.env) {
|
|
8399
|
+
if (env.NODE_ENV !== "production") return;
|
|
8400
|
+
if (env.SIDEBOARD_RELAY_PUBLIC_ORIGIN?.trim()) return;
|
|
8401
|
+
throw new Error(
|
|
8402
|
+
"SIDEBOARD_RELAY_PUBLIC_ORIGIN is required in production. Set it to the public https origin with no path, for example https://relay.example.com."
|
|
8403
|
+
);
|
|
8404
|
+
}
|
|
8421
8405
|
function startRelaySocketPing(ws, intervalMs) {
|
|
8422
8406
|
const ping = setInterval(() => {
|
|
8423
8407
|
if (ws.readyState !== ws.OPEN) {
|
|
@@ -8436,6 +8420,7 @@ function startRelaySocketPing(ws, intervalMs) {
|
|
|
8436
8420
|
return stop;
|
|
8437
8421
|
}
|
|
8438
8422
|
async function startRelayServer(opts) {
|
|
8423
|
+
assertRelayPublicOrigin();
|
|
8439
8424
|
const log = opts.onLog ?? console.log;
|
|
8440
8425
|
const appToken = opts.appToken?.trim() ?? "";
|
|
8441
8426
|
if (!opts.skipSocketMode && !appToken.startsWith("xapp-")) {
|
|
@@ -8482,6 +8467,19 @@ async function startRelayServer(opts) {
|
|
|
8482
8467
|
onAuthorized: (socket) => authMarks.get(socket)?.()
|
|
8483
8468
|
});
|
|
8484
8469
|
const publicOrigin = () => opts.relayPublicOrigin?.trim() || process.env.SIDEBOARD_RELAY_PUBLIC_ORIGIN?.trim() || `http://127.0.0.1:${boundPort}`;
|
|
8470
|
+
const healthBody = () => ({
|
|
8471
|
+
ok: true,
|
|
8472
|
+
service: "sideboard-relay",
|
|
8473
|
+
sessions: hub.listSessions().length,
|
|
8474
|
+
oauth: Boolean(clientSecret),
|
|
8475
|
+
phoneSockets: remoteSockets,
|
|
8476
|
+
accounts: Boolean(accountStore),
|
|
8477
|
+
providers: {
|
|
8478
|
+
github: Boolean(relayOAuth.github),
|
|
8479
|
+
cursor: Boolean(relayOAuth.cursor),
|
|
8480
|
+
entire: Boolean(relayOAuth.entire)
|
|
8481
|
+
}
|
|
8482
|
+
});
|
|
8485
8483
|
const httpServer = createServer((req, res) => {
|
|
8486
8484
|
void (async () => {
|
|
8487
8485
|
const reqUrl = req.url || "/";
|
|
@@ -8526,12 +8524,7 @@ async function startRelayServer(opts) {
|
|
|
8526
8524
|
return;
|
|
8527
8525
|
}
|
|
8528
8526
|
if (req.url === "/health") {
|
|
8529
|
-
sendJson3(res, 200,
|
|
8530
|
-
ok: true,
|
|
8531
|
-
service: "sideboard-relay",
|
|
8532
|
-
sessions: hub.listSessions().length,
|
|
8533
|
-
oauth: Boolean(clientSecret)
|
|
8534
|
-
});
|
|
8527
|
+
sendJson3(res, 200, healthBody());
|
|
8535
8528
|
return;
|
|
8536
8529
|
}
|
|
8537
8530
|
if (opts.staticRoot && await serveMarketingSite(req, res, {
|
|
@@ -8543,12 +8536,7 @@ async function startRelayServer(opts) {
|
|
|
8543
8536
|
return;
|
|
8544
8537
|
}
|
|
8545
8538
|
if (req.url === "/") {
|
|
8546
|
-
sendJson3(res, 200,
|
|
8547
|
-
ok: true,
|
|
8548
|
-
service: "sideboard-relay",
|
|
8549
|
-
sessions: hub.listSessions().length,
|
|
8550
|
-
oauth: Boolean(clientSecret)
|
|
8551
|
-
});
|
|
8539
|
+
sendJson3(res, 200, healthBody());
|
|
8552
8540
|
return;
|
|
8553
8541
|
}
|
|
8554
8542
|
res.writeHead(404);
|
|
@@ -8574,7 +8562,10 @@ async function startRelayServer(opts) {
|
|
|
8574
8562
|
const ip = relayClientIp(req);
|
|
8575
8563
|
const count = remoteByIp.get(ip) ?? 0;
|
|
8576
8564
|
if (count >= 20 || remoteSockets >= 4e3) {
|
|
8577
|
-
|
|
8565
|
+
log(`remote rate limit: ${ip} (${count} on this address, ${remoteSockets} open)`);
|
|
8566
|
+
target.handleUpgrade(req, socket, head, (ws) => {
|
|
8567
|
+
ws.close(4029, "too many connections");
|
|
8568
|
+
});
|
|
8578
8569
|
return;
|
|
8579
8570
|
}
|
|
8580
8571
|
}
|
|
@@ -8766,7 +8757,7 @@ async function startHeadlessHost(opts) {
|
|
|
8766
8757
|
};
|
|
8767
8758
|
const refreshRunning = async () => {
|
|
8768
8759
|
try {
|
|
8769
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
8760
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
|
|
8770
8761
|
agentsRunning = getOrchestrator2().getRuntime().running;
|
|
8771
8762
|
} catch {
|
|
8772
8763
|
agentsRunning = 0;
|
|
@@ -10917,7 +10908,7 @@ async function handleJobStop(params, _ctx) {
|
|
|
10917
10908
|
return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
|
|
10918
10909
|
}
|
|
10919
10910
|
async function defaultTurnWait(ref, timeoutMs) {
|
|
10920
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
10911
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
|
|
10921
10912
|
const orch = getOrchestrator2();
|
|
10922
10913
|
const thread = await orch.waitForTurn(ref, timeoutMs, {
|
|
10923
10914
|
resolveIfStillRunning: true
|
|
@@ -13351,6 +13342,70 @@ async function saveSlackOrgCredentials(opts) {
|
|
|
13351
13342
|
if (!res.ok) throw new Error(await readError(res));
|
|
13352
13343
|
}
|
|
13353
13344
|
|
|
13345
|
+
// src/slack/deferred-reply.ts
|
|
13346
|
+
var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
|
|
13347
|
+
var SLACK_LISTEN_TIMEOUT_REPLY = [
|
|
13348
|
+
"Sideboard timed out waiting for the local agent turn to finish.",
|
|
13349
|
+
'Send another message to interrupt and retry, or send "stop".'
|
|
13350
|
+
].join(" ");
|
|
13351
|
+
var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
|
|
13352
|
+
"Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
|
|
13353
|
+
"The picker is in the Sideboard app \u2014 not in Slack.",
|
|
13354
|
+
'Reply here after you answer it on the Mac, or send "stop".'
|
|
13355
|
+
].join(" ");
|
|
13356
|
+
function slackShouldHoldDeferredReply(opts) {
|
|
13357
|
+
if (!orchestratorPromisedLaterReport(opts.reply)) return false;
|
|
13358
|
+
if (opts.queue.some((item) => isJobContinuePrompt(item))) return true;
|
|
13359
|
+
return opts.status === "running" || opts.status === "queued";
|
|
13360
|
+
}
|
|
13361
|
+
var SLACK_DEFERRED_HOLD_LIMIT = 3;
|
|
13362
|
+
async function waitUntilOrchestratorContinueSettles(orch, threadId, timeoutMs) {
|
|
13363
|
+
const start = Date.now();
|
|
13364
|
+
while (Date.now() - start < timeoutMs) {
|
|
13365
|
+
const thread = readThread(threadId);
|
|
13366
|
+
if (!thread || thread.status === "stopped" || thread.status === "archived") return;
|
|
13367
|
+
if (thread.status === "running" || thread.status === "queued") {
|
|
13368
|
+
const remaining = Math.max(1, timeoutMs - (Date.now() - start));
|
|
13369
|
+
await orch.waitForTurn(threadId, remaining);
|
|
13370
|
+
return;
|
|
13371
|
+
}
|
|
13372
|
+
if (!thread.queue.some((item) => isJobContinuePrompt(item))) return;
|
|
13373
|
+
await new Promise((resolve) => setTimeout(resolve, 40));
|
|
13374
|
+
}
|
|
13375
|
+
throw new Error("wait_for_turn timed out");
|
|
13376
|
+
}
|
|
13377
|
+
async function awaitDeferredOrchestratorReply(orch, threadId, initial, timeoutMs, aborted) {
|
|
13378
|
+
let reply = initial;
|
|
13379
|
+
const deadline = Date.now() + timeoutMs;
|
|
13380
|
+
for (let i = 0; i < SLACK_DEFERRED_HOLD_LIMIT; i++) {
|
|
13381
|
+
if (aborted?.()) return { reply: "", interrupted: true };
|
|
13382
|
+
const thread = readThread(threadId);
|
|
13383
|
+
if (!thread || thread.status === "stopped" || thread.status === "archived") {
|
|
13384
|
+
return { reply: "", interrupted: true };
|
|
13385
|
+
}
|
|
13386
|
+
if (!slackShouldHoldDeferredReply({ reply, queue: thread.queue, status: thread.status })) {
|
|
13387
|
+
return { reply, interrupted: false };
|
|
13388
|
+
}
|
|
13389
|
+
const remaining = deadline - Date.now();
|
|
13390
|
+
if (remaining <= 0) return { reply, interrupted: false };
|
|
13391
|
+
await waitUntilOrchestratorContinueSettles(orch, threadId, remaining);
|
|
13392
|
+
const latest = readThread(threadId);
|
|
13393
|
+
if (!latest || latest.status === "stopped" || latest.status === "archived") {
|
|
13394
|
+
return { reply: "", interrupted: true };
|
|
13395
|
+
}
|
|
13396
|
+
reply = formatSlackTurnReply(orch.getTurnResult(threadId));
|
|
13397
|
+
}
|
|
13398
|
+
return { reply, interrupted: false };
|
|
13399
|
+
}
|
|
13400
|
+
function formatSlackTurnReply(result) {
|
|
13401
|
+
return outboundReplyFromTurn(result, {
|
|
13402
|
+
inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
|
|
13403
|
+
canceled: SLACK_LISTEN_STOPPED_REPLY,
|
|
13404
|
+
completedEmpty: () => "",
|
|
13405
|
+
failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
|
|
13406
|
+
});
|
|
13407
|
+
}
|
|
13408
|
+
|
|
13354
13409
|
// src/slack/reply-target.ts
|
|
13355
13410
|
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
|
|
13356
13411
|
import { join as join9 } from "path";
|
|
@@ -13609,24 +13664,6 @@ function connectSession2(ws, opts, log) {
|
|
|
13609
13664
|
}
|
|
13610
13665
|
|
|
13611
13666
|
// src/slack/listen.ts
|
|
13612
|
-
var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
|
|
13613
|
-
var SLACK_LISTEN_TIMEOUT_REPLY = [
|
|
13614
|
-
"Sideboard timed out waiting for the local agent turn to finish.",
|
|
13615
|
-
'Send another message to interrupt and retry, or send "stop".'
|
|
13616
|
-
].join(" ");
|
|
13617
|
-
var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
|
|
13618
|
-
"Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
|
|
13619
|
-
"The picker is in the Sideboard app \u2014 not in Slack.",
|
|
13620
|
-
'Reply here after you answer it on the Mac, or send "stop".'
|
|
13621
|
-
].join(" ");
|
|
13622
|
-
function formatSlackTurnReply(result) {
|
|
13623
|
-
return outboundReplyFromTurn(result, {
|
|
13624
|
-
inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
|
|
13625
|
-
canceled: SLACK_LISTEN_STOPPED_REPLY,
|
|
13626
|
-
completedEmpty: () => "",
|
|
13627
|
-
failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
|
|
13628
|
-
});
|
|
13629
|
-
}
|
|
13630
13667
|
var handleChain2 = Promise.resolve();
|
|
13631
13668
|
function enqueueHandle(fn) {
|
|
13632
13669
|
const run2 = handleChain2.then(fn, fn);
|
|
@@ -13936,7 +13973,9 @@ async function relayCoordinatorReplyToSlack(threadId, opts) {
|
|
|
13936
13973
|
if (!target) return;
|
|
13937
13974
|
const thread = readThread(threadId);
|
|
13938
13975
|
const lastUser = thread ? [...thread.messages].reverse().find((m) => m.role === "user") : void 0;
|
|
13939
|
-
if (lastUser && isSlackInboundUserPrompt(lastUser.text))
|
|
13976
|
+
if (lastUser && (isSlackInboundUserPrompt(lastUser.text) || isJobContinuePrompt(lastUser.text))) {
|
|
13977
|
+
return;
|
|
13978
|
+
}
|
|
13940
13979
|
const result = getOrchestrator().getTurnResult(threadId);
|
|
13941
13980
|
const text5 = formatSlackTurnReply(result);
|
|
13942
13981
|
if (!text5) return;
|
|
@@ -14060,6 +14099,18 @@ async function handleSlackInbound(msg, opts) {
|
|
|
14060
14099
|
}
|
|
14061
14100
|
}
|
|
14062
14101
|
reply = formatSlackTurnReply(orch.getTurnResult(fresh.id));
|
|
14102
|
+
const held = await awaitDeferredOrchestratorReply(
|
|
14103
|
+
orch,
|
|
14104
|
+
fresh.id,
|
|
14105
|
+
reply,
|
|
14106
|
+
14 * 60 * 1e3,
|
|
14107
|
+
() => slackInboundSuperseded(opts)
|
|
14108
|
+
);
|
|
14109
|
+
if (held.interrupted) {
|
|
14110
|
+
await dropProgress(`turn finished ${msg.ts} (deferred reply interrupted)`);
|
|
14111
|
+
return;
|
|
14112
|
+
}
|
|
14113
|
+
reply = held.reply;
|
|
14063
14114
|
} catch (err) {
|
|
14064
14115
|
if (slackInboundSuperseded(opts)) {
|
|
14065
14116
|
await dropProgress(`turn error ${msg.ts} (superseded)`);
|
|
@@ -14155,7 +14206,7 @@ async function runSlackListen(opts = {}) {
|
|
|
14155
14206
|
const withIdentity = connected.filter(slackWorkspaceCanListen);
|
|
14156
14207
|
if (withIdentity.length === 0) {
|
|
14157
14208
|
throw new Error(
|
|
14158
|
-
"Slack Listen needs Add via browser so this Mac can prove which Slack user it is. A
|
|
14209
|
+
"Slack Listen needs Add via browser so this Mac can prove which Slack user it is. A bot token alone cannot."
|
|
14159
14210
|
);
|
|
14160
14211
|
}
|
|
14161
14212
|
const device = ensureSlackDeviceIdentity();
|
|
@@ -14400,7 +14451,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
14400
14451
|
await continueOnReply(threadId, prompt);
|
|
14401
14452
|
return;
|
|
14402
14453
|
}
|
|
14403
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
14454
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
|
|
14404
14455
|
await getOrchestrator2().send(threadId, prompt);
|
|
14405
14456
|
} catch {
|
|
14406
14457
|
}
|
|
@@ -14962,7 +15013,6 @@ export {
|
|
|
14962
15013
|
confirmLand,
|
|
14963
15014
|
connectBrightsyTeam,
|
|
14964
15015
|
connectOptionalService,
|
|
14965
|
-
connectSlackToken,
|
|
14966
15016
|
connectedOptionalServices,
|
|
14967
15017
|
connectedOrchestratorTurnReminder,
|
|
14968
15018
|
connectedPrSelectors,
|