@sideboard-ai/core 0.1.345 → 0.1.347
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-MSIMJKKQ.js → abletime-3HRWLQZJ.js} +4 -4
- package/dist/{abletime-X2TJ6PPK.js → abletime-CGFJZB7L.js} +4 -4
- package/dist/{abletime-oauth-DEIENLHC.js → abletime-oauth-JQDSH5OL.js} +3 -3
- package/dist/{abletime-oauth-2RUKRZYZ.js → abletime-oauth-QNJQLHR4.js} +3 -3
- package/dist/{abletime-rest-UBLSGMSA.js → abletime-rest-TANL5TMY.js} +3 -3
- package/dist/{abletime-rest-HWBUPI4R.js → abletime-rest-UQA2CRZN.js} +3 -3
- package/dist/{agents-AQM7NLXD.js → agents-5MFGVK7C.js} +7 -7
- package/dist/{agents-7CHZO3K3.js → agents-T4XBZZDA.js} +7 -7
- package/dist/{app-settings-Q2F57NVK.js → app-settings-PPIMYJKS.js} +3 -1
- package/dist/{app-settings-A6JUT2SF.js → app-settings-SNOPJ7P5.js} +3 -1
- package/dist/{chunk-5IMXA563.js → chunk-27XWAI7S.js} +22 -22
- package/dist/{chunk-RTZO2YJC.js → chunk-2HPVGTHF.js} +2 -2
- package/dist/{chunk-GHKJBZW5.js → chunk-4NXGVJA6.js} +2 -2
- package/dist/{chunk-O5WRVQFT.js → chunk-5FUAOU3G.js} +1 -1
- package/dist/{chunk-3J3XOIHF.js → chunk-62ALWH3T.js} +3 -3
- package/dist/{chunk-J3BQHHDZ.js → chunk-6TV6L2DD.js} +4 -4
- package/dist/{chunk-4PHOJMZI.js → chunk-6WMNIX2U.js} +35 -2
- package/dist/{chunk-4PXHJA5K.js → chunk-7B2OUQON.js} +2 -2
- package/dist/{chunk-TD76ORBJ.js → chunk-AJMERXZP.js} +2 -2
- package/dist/{chunk-QTDCPMOW.js → chunk-ATS7SYHG.js} +1 -1
- package/dist/{chunk-AG2RM3DF.js → chunk-CEQ4Z32M.js} +3 -3
- package/dist/{chunk-5TS3KVGI.js → chunk-E77SRVVO.js} +1 -1
- package/dist/{chunk-5SJGR3VS.js → chunk-F7WP2U5I.js} +12 -9
- package/dist/{chunk-YFPSTG52.js → chunk-FDYMVJFU.js} +5 -5
- package/dist/{chunk-IYX53WZY.js → chunk-GAGTEI6B.js} +5 -5
- package/dist/{chunk-JZKNRDKF.js → chunk-IJNTTVFH.js} +23 -23
- package/dist/{chunk-MB3GOWB3.js → chunk-IVRWRYTH.js} +19 -10
- package/dist/{chunk-3DMRQB4Y.js → chunk-JCYGQKER.js} +1 -1
- package/dist/{chunk-JHT3CYLT.js → chunk-MOUAM6ZC.js} +1 -1
- package/dist/{chunk-Z54FI4VL.js → chunk-NTY5WGRD.js} +2 -2
- package/dist/{chunk-LHU6ZBFB.js → chunk-OHUAAX3O.js} +2 -2
- package/dist/{chunk-NQHEEGTH.js → chunk-PVCECFJK.js} +1 -1
- package/dist/{chunk-MHRU743Z.js → chunk-Q4TZA4MN.js} +2247 -2155
- package/dist/{chunk-4SNEW63T.js → chunk-RUIHNWRV.js} +3 -3
- package/dist/{chunk-NDBMDHQ5.js → chunk-RYPD7XWV.js} +5 -5
- package/dist/{chunk-FNAP6CCS.js → chunk-UJMCTGV7.js} +2 -2
- package/dist/{chunk-S3UGLMGE.js → chunk-WWU4SYZR.js} +35 -2
- package/dist/{chunk-4YGVJRXY.js → chunk-XNGW4OYD.js} +4 -4
- package/dist/{chunk-TW63CYUA.js → chunk-Y6VQX2LY.js} +2679 -2587
- package/dist/{chunk-BD7KUYJA.js → chunk-ZJMYCDYQ.js} +5 -5
- package/dist/{conductor-DUHRZUQY.js → conductor-EMGMDNHL.js} +5 -5
- package/dist/{conductor-3A2TNWUW.js → conductor-LYQKONSA.js} +5 -5
- package/dist/{coordinator-prompt-OX6A4MDA.js → coordinator-prompt-DLY3FS2L.js} +4 -4
- package/dist/{coordinator-prompt-7QALNDIV.js → coordinator-prompt-WALVMGKI.js} +4 -4
- package/dist/{global-workspace-HM2RKBCT.js → global-workspace-7OQ5O6JT.js} +4 -4
- package/dist/{global-workspace-6GGS3DWU.js → global-workspace-UG2A3CEM.js} +4 -4
- package/dist/index.cjs +1090 -640
- package/dist/index.d.cts +62 -8
- package/dist/index.d.ts +62 -8
- package/dist/index.js +325 -32
- package/dist/{linear-WYI64BMX.js → linear-MIJO6DCV.js} +2 -2
- package/dist/{linear-JE4WAZ3W.js → linear-PKYJH4WK.js} +2 -2
- package/dist/{linear-list-I4NAOWPN.js → linear-list-JPQ27RXG.js} +1 -1
- package/dist/{linear-list-CGUCPWTV.js → linear-list-N57PR6JM.js} +1 -1
- package/dist/mcp/run-stdio.cjs +500 -224
- package/dist/mcp/run-stdio.js +106 -21
- package/dist/{optional-cli-7QXXPEN6.js → optional-cli-4GTEDEYJ.js} +3 -3
- package/dist/{optional-cli-YHLVTVRK.js → optional-cli-RPJIQBDX.js} +4 -4
- package/dist/{orchestrator-OWO6LQ5U.js → orchestrator-AJZNVREM.js} +10 -10
- package/dist/{orchestrator-POMFVZLB.js → orchestrator-BUEPWNCF.js} +10 -10
- package/dist/{thread-store-HETUMDVA.js → thread-store-MEUWZDVV.js} +2 -2
- package/dist/{thread-store-V5IDUJ4L.js → thread-store-R3G5VBII.js} +2 -2
- package/dist/{workspaces-DTMPNDPW.js → workspaces-35T6FW57.js} +4 -4
- package/dist/{workspaces-V6IIBSKA.js → workspaces-KWGTP7DI.js} +4 -4
- package/dist/{worktree-FX5FT6BI.js → worktree-5P7SCST3.js} +3 -3
- package/dist/{worktree-BD3EJE24.js → worktree-ROJXGBWS.js} +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,13 +17,13 @@ import {
|
|
|
17
17
|
toAbleTimeIssueInfo,
|
|
18
18
|
updateAbleTimeTask,
|
|
19
19
|
verifyAbleTimeConnection
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RUIHNWRV.js";
|
|
21
21
|
import {
|
|
22
22
|
clearOptionalCliPresenceCache,
|
|
23
23
|
detectOptionalServiceClis,
|
|
24
24
|
installOptionalServiceCli,
|
|
25
25
|
optionalCliPresence
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-UJMCTGV7.js";
|
|
27
27
|
import {
|
|
28
28
|
AGENT_GIT_ACTIONS,
|
|
29
29
|
BOARD_COLUMN_DEFS,
|
|
@@ -222,7 +222,7 @@ import {
|
|
|
222
222
|
worktreeCleanupSettings,
|
|
223
223
|
writeAgentBlock,
|
|
224
224
|
writeWorktreeFile
|
|
225
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-IJNTTVFH.js";
|
|
226
226
|
import {
|
|
227
227
|
OPTIONAL_SERVICES,
|
|
228
228
|
OPTIONAL_SERVICE_IDS,
|
|
@@ -238,7 +238,7 @@ import {
|
|
|
238
238
|
optionalServiceConnected,
|
|
239
239
|
optionalServiceSpec,
|
|
240
240
|
verifyOptionalService
|
|
241
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-IVRWRYTH.js";
|
|
242
242
|
import {
|
|
243
243
|
LEGACY_PLAN_FILE_REL,
|
|
244
244
|
PLAN_FILE_NAME,
|
|
@@ -295,7 +295,7 @@ import {
|
|
|
295
295
|
startLinearOAuth,
|
|
296
296
|
updateLinearIssue,
|
|
297
297
|
validateLinearApiKey
|
|
298
|
-
} from "./chunk-
|
|
298
|
+
} from "./chunk-PVCECFJK.js";
|
|
299
299
|
import {
|
|
300
300
|
downloadAuthenticatedFile,
|
|
301
301
|
extractHttpUrls,
|
|
@@ -383,7 +383,7 @@ import {
|
|
|
383
383
|
userMcpNamesToDisable,
|
|
384
384
|
worktreeMcpToolNames,
|
|
385
385
|
writeInjectedMcpConfig
|
|
386
|
-
} from "./chunk-
|
|
386
|
+
} from "./chunk-Q4TZA4MN.js";
|
|
387
387
|
import {
|
|
388
388
|
getAgentSetupInfo,
|
|
389
389
|
installAgent,
|
|
@@ -395,7 +395,7 @@ import {
|
|
|
395
395
|
prepareTerminalCommand,
|
|
396
396
|
resolveLoginCommand,
|
|
397
397
|
whichOnPath
|
|
398
|
-
} from "./chunk-
|
|
398
|
+
} from "./chunk-4NXGVJA6.js";
|
|
399
399
|
import {
|
|
400
400
|
brightsyMcpServerName,
|
|
401
401
|
connectBrightsyTeam,
|
|
@@ -406,7 +406,7 @@ import {
|
|
|
406
406
|
listConnectedBrightsyTeams,
|
|
407
407
|
switchBrightsyAccount
|
|
408
408
|
} from "./chunk-XOEKCE6L.js";
|
|
409
|
-
import "./chunk-
|
|
409
|
+
import "./chunk-5FUAOU3G.js";
|
|
410
410
|
import {
|
|
411
411
|
BRIGHTSY_SUMMARIZE_CONTEXT_TOOL,
|
|
412
412
|
CHARS_PER_CONTEXT_TOKEN,
|
|
@@ -517,7 +517,7 @@ import {
|
|
|
517
517
|
workspaceAgentChatSummaries,
|
|
518
518
|
worktreeRunPortsPath,
|
|
519
519
|
wrapReviewSkillMarkdown
|
|
520
|
-
} from "./chunk-
|
|
520
|
+
} from "./chunk-GAGTEI6B.js";
|
|
521
521
|
import {
|
|
522
522
|
STDERR_EVENT_MAX_CHARS,
|
|
523
523
|
STDOUT_EVENT_MAX_CHARS,
|
|
@@ -583,10 +583,10 @@ import {
|
|
|
583
583
|
parseAbleTimeOAuthCallbackUrl,
|
|
584
584
|
resolveAbleTimeOAuthHost,
|
|
585
585
|
startAbleTimeOAuth
|
|
586
|
-
} from "./chunk-
|
|
586
|
+
} from "./chunk-CEQ4Z32M.js";
|
|
587
587
|
import {
|
|
588
588
|
looksLikeAbleTimeUlid
|
|
589
|
-
} from "./chunk-
|
|
589
|
+
} from "./chunk-AJMERXZP.js";
|
|
590
590
|
import {
|
|
591
591
|
ABLETIME_MCP_PATH,
|
|
592
592
|
ABLETIME_MCP_PM_PATH,
|
|
@@ -607,7 +607,7 @@ import {
|
|
|
607
607
|
normalizeAbleTimeCredential,
|
|
608
608
|
normalizeAbleTimeHost,
|
|
609
609
|
rewriteAbleTimeError
|
|
610
|
-
} from "./chunk-
|
|
610
|
+
} from "./chunk-FDYMVJFU.js";
|
|
611
611
|
import {
|
|
612
612
|
CLOUD_COORDINATOR_BUSY_REPLY,
|
|
613
613
|
CLOUD_COORDINATOR_CANCELED_REPLY,
|
|
@@ -660,7 +660,7 @@ import {
|
|
|
660
660
|
stageBuffersAsAttachments,
|
|
661
661
|
syncWorkspacesFromThreads,
|
|
662
662
|
takenTeamSlugsForOrchestration
|
|
663
|
-
} from "./chunk-
|
|
663
|
+
} from "./chunk-XNGW4OYD.js";
|
|
664
664
|
import {
|
|
665
665
|
GITHUB_PR_BODY_MAX_CHARS,
|
|
666
666
|
GITHUB_PR_BODY_SAFE_CHARS,
|
|
@@ -750,7 +750,7 @@ import {
|
|
|
750
750
|
suggestSlug,
|
|
751
751
|
switchWorktreeBranch,
|
|
752
752
|
warmGithubAgentAuth
|
|
753
|
-
} from "./chunk-
|
|
753
|
+
} from "./chunk-NTY5WGRD.js";
|
|
754
754
|
import {
|
|
755
755
|
FAMOUS_SOCCER_TEAMS,
|
|
756
756
|
SCHEDULE_RUN_HISTORY_LIMIT,
|
|
@@ -807,7 +807,7 @@ import {
|
|
|
807
807
|
worktreeNameFromPath,
|
|
808
808
|
worktreeSlugForTicket,
|
|
809
809
|
writeThread
|
|
810
|
-
} from "./chunk-
|
|
810
|
+
} from "./chunk-ATS7SYHG.js";
|
|
811
811
|
import "./chunk-BMRJNRQK.js";
|
|
812
812
|
import {
|
|
813
813
|
BRIGHTSY_OAUTH_CLIENT_ID,
|
|
@@ -1070,6 +1070,7 @@ import {
|
|
|
1070
1070
|
saveAbleTimeConnection,
|
|
1071
1071
|
saveAppSettings,
|
|
1072
1072
|
saveLinearOAuth,
|
|
1073
|
+
savePosthogOAuth,
|
|
1073
1074
|
saveSecretVault,
|
|
1074
1075
|
secureFileUnlocksWith,
|
|
1075
1076
|
selectManagedAccount,
|
|
@@ -1099,7 +1100,7 @@ import {
|
|
|
1099
1100
|
withTurnScopedCost,
|
|
1100
1101
|
writeSecureJson,
|
|
1101
1102
|
writeViewerContext
|
|
1102
|
-
} from "./chunk-
|
|
1103
|
+
} from "./chunk-6WMNIX2U.js";
|
|
1103
1104
|
import {
|
|
1104
1105
|
stripNestedElectronEnv
|
|
1105
1106
|
} from "./chunk-4TR3HZFT.js";
|
|
@@ -9955,7 +9956,7 @@ async function startHeadlessHost(opts) {
|
|
|
9955
9956
|
};
|
|
9956
9957
|
const refreshRunning = async () => {
|
|
9957
9958
|
try {
|
|
9958
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
9959
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
|
|
9959
9960
|
agentsRunning = getOrchestrator2().getRuntime().running;
|
|
9960
9961
|
} catch {
|
|
9961
9962
|
agentsRunning = 0;
|
|
@@ -10164,6 +10165,277 @@ async function loginEntireGit() {
|
|
|
10164
10165
|
};
|
|
10165
10166
|
}
|
|
10166
10167
|
|
|
10168
|
+
// src/integrations/posthog-oauth.ts
|
|
10169
|
+
import { createHash as createHash5, randomBytes as randomBytes11 } from "crypto";
|
|
10170
|
+
import { createServer as createServer2 } from "http";
|
|
10171
|
+
var BAKED_POSTHOG_OAUTH_CLIENT_ID = "https://www.sideboard.build/oauth/posthog-client.json";
|
|
10172
|
+
var POSTHOG_OAUTH_REGISTERED_REDIRECT = "http://127.0.0.1/callback";
|
|
10173
|
+
var POSTHOG_AUTHORIZE = "https://oauth.posthog.com/oauth/authorize/";
|
|
10174
|
+
var POSTHOG_TOKEN = "https://oauth.posthog.com/oauth/token/";
|
|
10175
|
+
var POSTHOG_API_HOSTS = ["https://us.posthog.com", "https://eu.posthog.com"];
|
|
10176
|
+
var POSTHOG_OAUTH_SCOPES = [
|
|
10177
|
+
"project:read",
|
|
10178
|
+
"organization:read",
|
|
10179
|
+
"query:read",
|
|
10180
|
+
"insight:read",
|
|
10181
|
+
"feature_flag:read",
|
|
10182
|
+
"experiment:read",
|
|
10183
|
+
"error_tracking:read",
|
|
10184
|
+
"dashboard:read",
|
|
10185
|
+
"event_definition:read",
|
|
10186
|
+
"property_definition:read",
|
|
10187
|
+
"user:read",
|
|
10188
|
+
"person:read"
|
|
10189
|
+
];
|
|
10190
|
+
var POSTHOG_OAUTH_OPTIONAL_SCOPES = [
|
|
10191
|
+
"query:write",
|
|
10192
|
+
"insight:write",
|
|
10193
|
+
"feature_flag:write",
|
|
10194
|
+
"experiment:write",
|
|
10195
|
+
"error_tracking:write",
|
|
10196
|
+
"dashboard:write",
|
|
10197
|
+
"person:write",
|
|
10198
|
+
"cohort:read",
|
|
10199
|
+
"cohort:write",
|
|
10200
|
+
"survey:read",
|
|
10201
|
+
"survey:write",
|
|
10202
|
+
"annotation:read",
|
|
10203
|
+
"annotation:write",
|
|
10204
|
+
"session_recording:read",
|
|
10205
|
+
"logs:read"
|
|
10206
|
+
];
|
|
10207
|
+
var REFRESH_SKEW_MS = 6e4;
|
|
10208
|
+
var PosthogOAuthCancelledError = class extends Error {
|
|
10209
|
+
constructor(message = "PostHog sign-in cancelled") {
|
|
10210
|
+
super(message);
|
|
10211
|
+
this.name = "PosthogOAuthCancelledError";
|
|
10212
|
+
}
|
|
10213
|
+
};
|
|
10214
|
+
function isPosthogOAuthCancelled(err) {
|
|
10215
|
+
return err instanceof PosthogOAuthCancelledError;
|
|
10216
|
+
}
|
|
10217
|
+
function posthogOAuthClientId() {
|
|
10218
|
+
return process.env.SIDEBOARD_POSTHOG_OAUTH_CLIENT_ID?.trim() || BAKED_POSTHOG_OAUTH_CLIENT_ID;
|
|
10219
|
+
}
|
|
10220
|
+
function posthogOAuthScopeParam() {
|
|
10221
|
+
return [...POSTHOG_OAUTH_SCOPES, ...POSTHOG_OAUTH_OPTIONAL_SCOPES].join(" ");
|
|
10222
|
+
}
|
|
10223
|
+
function createPosthogPkce() {
|
|
10224
|
+
const verifier = randomBytes11(32).toString("base64url");
|
|
10225
|
+
const challenge = createHash5("sha256").update(verifier).digest("base64url");
|
|
10226
|
+
return { verifier, challenge };
|
|
10227
|
+
}
|
|
10228
|
+
function posthogOAuthAuthorizeUrl(clientId, state, codeChallenge, redirectUri) {
|
|
10229
|
+
const params = new URLSearchParams({
|
|
10230
|
+
client_id: clientId,
|
|
10231
|
+
redirect_uri: redirectUri,
|
|
10232
|
+
response_type: "code",
|
|
10233
|
+
scope: posthogOAuthScopeParam(),
|
|
10234
|
+
state,
|
|
10235
|
+
code_challenge: codeChallenge,
|
|
10236
|
+
code_challenge_method: "S256"
|
|
10237
|
+
});
|
|
10238
|
+
return `${POSTHOG_AUTHORIZE}?${params.toString()}`;
|
|
10239
|
+
}
|
|
10240
|
+
function htmlPage(title, body) {
|
|
10241
|
+
return `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title>
|
|
10242
|
+
<style>body{font-family:ui-sans-serif,system-ui,sans-serif;padding:48px 24px;max-width:36rem;margin:0 auto;color:#1a1a1a}
|
|
10243
|
+
h1{font-size:1.25rem}p{line-height:1.5;color:#444}</style></head><body>${body}</body></html>`;
|
|
10244
|
+
}
|
|
10245
|
+
async function exchangePosthogToken(body) {
|
|
10246
|
+
const res = await httpFetch(POSTHOG_TOKEN, {
|
|
10247
|
+
method: "POST",
|
|
10248
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
|
|
10249
|
+
body
|
|
10250
|
+
});
|
|
10251
|
+
const data = await res.json().catch(() => ({}));
|
|
10252
|
+
if (!res.ok || data.error || !data.access_token?.trim()) {
|
|
10253
|
+
const detail = data.error_description || data.error || `HTTP ${res.status}`;
|
|
10254
|
+
throw new Error(`PostHog sign-in failed: ${detail}`);
|
|
10255
|
+
}
|
|
10256
|
+
return data;
|
|
10257
|
+
}
|
|
10258
|
+
function viewerNameFromMe(body) {
|
|
10259
|
+
const record = body && typeof body === "object" ? body : {};
|
|
10260
|
+
const email = typeof record.email === "string" ? record.email.trim() : "";
|
|
10261
|
+
if (email) return email.slice(0, 120);
|
|
10262
|
+
const first = typeof record.first_name === "string" ? record.first_name.trim() : "";
|
|
10263
|
+
const last = typeof record.last_name === "string" ? record.last_name.trim() : "";
|
|
10264
|
+
const name = [first, last].filter(Boolean).join(" ");
|
|
10265
|
+
return (name || "PostHog user").slice(0, 120);
|
|
10266
|
+
}
|
|
10267
|
+
async function discoverPosthogHost(token) {
|
|
10268
|
+
let last = "PostHog rejected the sign-in";
|
|
10269
|
+
for (const host of POSTHOG_API_HOSTS) {
|
|
10270
|
+
const res = await httpFetch(`${host}/api/users/@me/`, {
|
|
10271
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" }
|
|
10272
|
+
});
|
|
10273
|
+
if (res.status === 401 || res.status === 403) {
|
|
10274
|
+
last = `${host} rejected the token`;
|
|
10275
|
+
continue;
|
|
10276
|
+
}
|
|
10277
|
+
if (!res.ok) {
|
|
10278
|
+
last = `${host} returned HTTP ${res.status}`;
|
|
10279
|
+
continue;
|
|
10280
|
+
}
|
|
10281
|
+
const body = await res.json().catch(() => ({}));
|
|
10282
|
+
return { host, viewerName: viewerNameFromMe(body) };
|
|
10283
|
+
}
|
|
10284
|
+
throw new Error(last);
|
|
10285
|
+
}
|
|
10286
|
+
var refreshInFlight = null;
|
|
10287
|
+
async function refreshPosthogAccessToken(refresh, host, viewerName, legacy) {
|
|
10288
|
+
try {
|
|
10289
|
+
const data = await exchangePosthogToken(
|
|
10290
|
+
new URLSearchParams({
|
|
10291
|
+
grant_type: "refresh_token",
|
|
10292
|
+
refresh_token: refresh,
|
|
10293
|
+
client_id: posthogOAuthClientId()
|
|
10294
|
+
})
|
|
10295
|
+
);
|
|
10296
|
+
const saved = savePosthogOAuth({
|
|
10297
|
+
accessToken: data.access_token.trim(),
|
|
10298
|
+
refreshToken: data.refresh_token?.trim() || refresh,
|
|
10299
|
+
expiresIn: data.expires_in,
|
|
10300
|
+
host,
|
|
10301
|
+
viewerName
|
|
10302
|
+
});
|
|
10303
|
+
return {
|
|
10304
|
+
token: saved.integrations.posthogAccessToken.trim(),
|
|
10305
|
+
host: saved.integrations.posthogHost?.trim() || host
|
|
10306
|
+
};
|
|
10307
|
+
} catch (err) {
|
|
10308
|
+
if (legacy) return { token: legacy, host };
|
|
10309
|
+
throw err;
|
|
10310
|
+
}
|
|
10311
|
+
}
|
|
10312
|
+
async function getPosthogAccessToken() {
|
|
10313
|
+
const integrations = loadAppSettings().integrations;
|
|
10314
|
+
const host = integrations.posthogHost?.trim() || "https://us.posthog.com";
|
|
10315
|
+
const access = integrations.posthogAccessToken?.trim() || "";
|
|
10316
|
+
const refresh = integrations.posthogRefreshToken?.trim() || "";
|
|
10317
|
+
const legacy = integrations.posthogPersonalApiKey?.trim() || "";
|
|
10318
|
+
const exp = integrations.posthogTokenExpiresAt;
|
|
10319
|
+
const accessFresh = Boolean(access) && (exp == null || exp - Date.now() > REFRESH_SKEW_MS);
|
|
10320
|
+
if (accessFresh) return { token: access, host };
|
|
10321
|
+
if (refresh) {
|
|
10322
|
+
if (!refreshInFlight) {
|
|
10323
|
+
refreshInFlight = refreshPosthogAccessToken(
|
|
10324
|
+
refresh,
|
|
10325
|
+
host,
|
|
10326
|
+
integrations.posthogViewerName,
|
|
10327
|
+
legacy
|
|
10328
|
+
).finally(() => {
|
|
10329
|
+
refreshInFlight = null;
|
|
10330
|
+
});
|
|
10331
|
+
}
|
|
10332
|
+
return refreshInFlight;
|
|
10333
|
+
}
|
|
10334
|
+
if (access) return { token: access, host };
|
|
10335
|
+
if (legacy) return { token: legacy, host };
|
|
10336
|
+
return null;
|
|
10337
|
+
}
|
|
10338
|
+
async function startPosthogOAuth(opts) {
|
|
10339
|
+
if (opts?.signal?.aborted) throw new PosthogOAuthCancelledError();
|
|
10340
|
+
const clientId = posthogOAuthClientId();
|
|
10341
|
+
const state = randomBytes11(16).toString("hex");
|
|
10342
|
+
const pkce = createPosthogPkce();
|
|
10343
|
+
const timeoutMs = opts?.timeoutMs ?? 5 * 6e4;
|
|
10344
|
+
const code = await new Promise((resolve, reject) => {
|
|
10345
|
+
let settled = false;
|
|
10346
|
+
const finish = (err, value) => {
|
|
10347
|
+
if (settled) return;
|
|
10348
|
+
settled = true;
|
|
10349
|
+
cleanup();
|
|
10350
|
+
if (err) reject(err);
|
|
10351
|
+
else resolve(value);
|
|
10352
|
+
};
|
|
10353
|
+
const server = createServer2((req, res) => {
|
|
10354
|
+
try {
|
|
10355
|
+
const url = new URL(req.url || "/", "http://127.0.0.1");
|
|
10356
|
+
if (url.pathname !== "/callback") {
|
|
10357
|
+
res.writeHead(404);
|
|
10358
|
+
res.end("Not found");
|
|
10359
|
+
return;
|
|
10360
|
+
}
|
|
10361
|
+
const err = url.searchParams.get("error");
|
|
10362
|
+
const gotState = url.searchParams.get("state");
|
|
10363
|
+
const gotCode = url.searchParams.get("code");
|
|
10364
|
+
if (err) {
|
|
10365
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
10366
|
+
res.end(htmlPage("PostHog", "<h1>Authorization cancelled</h1><p>You can close this tab.</p>"));
|
|
10367
|
+
finish(new PosthogOAuthCancelledError());
|
|
10368
|
+
return;
|
|
10369
|
+
}
|
|
10370
|
+
if (gotState !== state || !gotCode) {
|
|
10371
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
10372
|
+
res.end(htmlPage("PostHog", "<h1>Invalid callback</h1><p>State or code missing.</p>"));
|
|
10373
|
+
finish(new Error("PostHog sign-in callback was invalid"));
|
|
10374
|
+
return;
|
|
10375
|
+
}
|
|
10376
|
+
const addr = server.address();
|
|
10377
|
+
const port = addr && typeof addr !== "string" ? addr.port : 0;
|
|
10378
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
10379
|
+
res.end(
|
|
10380
|
+
htmlPage(
|
|
10381
|
+
"PostHog connected",
|
|
10382
|
+
"<h1>PostHog connected</h1><p>You can close this tab and return to Sideboard.</p>"
|
|
10383
|
+
)
|
|
10384
|
+
);
|
|
10385
|
+
finish(void 0, { code: gotCode, redirectUri: `http://127.0.0.1:${port}/callback` });
|
|
10386
|
+
} catch (e) {
|
|
10387
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10388
|
+
}
|
|
10389
|
+
});
|
|
10390
|
+
const timer = setTimeout(() => finish(new Error("PostHog sign-in timed out \u2014 try again")), timeoutMs);
|
|
10391
|
+
const onAbort = () => finish(new PosthogOAuthCancelledError());
|
|
10392
|
+
const cleanup = () => {
|
|
10393
|
+
clearTimeout(timer);
|
|
10394
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
10395
|
+
server.close();
|
|
10396
|
+
};
|
|
10397
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
10398
|
+
if (opts?.signal?.aborted) {
|
|
10399
|
+
onAbort();
|
|
10400
|
+
return;
|
|
10401
|
+
}
|
|
10402
|
+
server.on("error", (e) => {
|
|
10403
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10404
|
+
});
|
|
10405
|
+
server.listen(0, "127.0.0.1", () => {
|
|
10406
|
+
const addr = server.address();
|
|
10407
|
+
const port = addr && typeof addr !== "string" ? addr.port : 0;
|
|
10408
|
+
if (!port) {
|
|
10409
|
+
finish(new Error("PostHog sign-in could not bind a local port"));
|
|
10410
|
+
return;
|
|
10411
|
+
}
|
|
10412
|
+
const redirectUri = `http://127.0.0.1:${port}/callback`;
|
|
10413
|
+
const authorizeUrl = posthogOAuthAuthorizeUrl(clientId, state, pkce.challenge, redirectUri);
|
|
10414
|
+
void Promise.resolve(opts?.openUrl?.(authorizeUrl)).catch((e) => {
|
|
10415
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10416
|
+
});
|
|
10417
|
+
});
|
|
10418
|
+
});
|
|
10419
|
+
const data = await exchangePosthogToken(
|
|
10420
|
+
new URLSearchParams({
|
|
10421
|
+
grant_type: "authorization_code",
|
|
10422
|
+
code: code.code,
|
|
10423
|
+
redirect_uri: code.redirectUri,
|
|
10424
|
+
client_id: clientId,
|
|
10425
|
+
code_verifier: pkce.verifier
|
|
10426
|
+
})
|
|
10427
|
+
);
|
|
10428
|
+
const token = data.access_token.trim();
|
|
10429
|
+
const discovered = await discoverPosthogHost(token);
|
|
10430
|
+
return savePosthogOAuth({
|
|
10431
|
+
accessToken: token,
|
|
10432
|
+
refreshToken: data.refresh_token?.trim(),
|
|
10433
|
+
expiresIn: data.expires_in,
|
|
10434
|
+
host: discovered.host,
|
|
10435
|
+
viewerName: discovered.viewerName
|
|
10436
|
+
});
|
|
10437
|
+
}
|
|
10438
|
+
|
|
10167
10439
|
// src/composer/diff-comment.ts
|
|
10168
10440
|
function lineRangeLabel(lines) {
|
|
10169
10441
|
const nos = lines.map((l) => l.lineNo);
|
|
@@ -11469,9 +11741,16 @@ async function runPosthogApi(input) {
|
|
|
11469
11741
|
if (method === "GET" && input.body !== void 0) {
|
|
11470
11742
|
return mcpJson({ ok: false, error: "GET does not take a body" }, true);
|
|
11471
11743
|
}
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11744
|
+
let session;
|
|
11745
|
+
try {
|
|
11746
|
+
session = await getPosthogAccessToken();
|
|
11747
|
+
} catch (err) {
|
|
11748
|
+
return mcpJson(
|
|
11749
|
+
{ ok: false, error: err instanceof Error ? err.message : String(err) },
|
|
11750
|
+
true
|
|
11751
|
+
);
|
|
11752
|
+
}
|
|
11753
|
+
if (!session) {
|
|
11475
11754
|
return mcpJson(
|
|
11476
11755
|
{ ok: false, error: "PostHog is not connected (Settings \u2192 Connectors)." },
|
|
11477
11756
|
true
|
|
@@ -11480,7 +11759,7 @@ async function runPosthogApi(input) {
|
|
|
11480
11759
|
let url;
|
|
11481
11760
|
try {
|
|
11482
11761
|
url = posthogApiUrl(
|
|
11483
|
-
|
|
11762
|
+
session.host,
|
|
11484
11763
|
withPosthogSlash(method, input.path),
|
|
11485
11764
|
input.query
|
|
11486
11765
|
);
|
|
@@ -11491,7 +11770,7 @@ async function runPosthogApi(input) {
|
|
|
11491
11770
|
);
|
|
11492
11771
|
}
|
|
11493
11772
|
const headers = {
|
|
11494
|
-
Authorization: `Bearer ${token}`,
|
|
11773
|
+
Authorization: `Bearer ${session.token}`,
|
|
11495
11774
|
Accept: "application/json"
|
|
11496
11775
|
};
|
|
11497
11776
|
let body;
|
|
@@ -12411,7 +12690,7 @@ async function handleJobStop(params, _ctx) {
|
|
|
12411
12690
|
return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
|
|
12412
12691
|
}
|
|
12413
12692
|
async function defaultTurnWait(ref, timeoutMs) {
|
|
12414
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
12693
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
|
|
12415
12694
|
const orch = getOrchestrator2();
|
|
12416
12695
|
const thread = await orch.waitForTurn(ref, timeoutMs, {
|
|
12417
12696
|
resolveIfStillRunning: true
|
|
@@ -12764,7 +13043,7 @@ async function startMcpServer() {
|
|
|
12764
13043
|
);
|
|
12765
13044
|
}
|
|
12766
13045
|
try {
|
|
12767
|
-
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-
|
|
13046
|
+
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-SNOPJ7P5.js");
|
|
12768
13047
|
orch.setMaxConcurrent(maxConcurrentAgents2());
|
|
12769
13048
|
} catch {
|
|
12770
13049
|
}
|
|
@@ -13343,7 +13622,7 @@ async function startMcpServer() {
|
|
|
13343
13622
|
if (!worktreeProfile) {
|
|
13344
13623
|
registerConnectedIssueVendorTools(server);
|
|
13345
13624
|
const { getCaffeinateHold: getCaffeinateHold2, setCaffeinateHold: setCaffeinateHold2 } = await import("./caffeinate-hold-ZNUEZGHB.js");
|
|
13346
|
-
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-
|
|
13625
|
+
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-SNOPJ7P5.js");
|
|
13347
13626
|
const accountDefaults = resolveThreadDefaults2();
|
|
13348
13627
|
const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
|
|
13349
13628
|
server.tool(
|
|
@@ -14027,8 +14306,8 @@ async function startMcpServer() {
|
|
|
14027
14306
|
}
|
|
14028
14307
|
|
|
14029
14308
|
// src/agent-rpc/server.ts
|
|
14030
|
-
import { randomBytes as
|
|
14031
|
-
import { createServer as
|
|
14309
|
+
import { randomBytes as randomBytes12, randomUUID as randomUUID9, timingSafeEqual as timingSafeEqual4 } from "crypto";
|
|
14310
|
+
import { createServer as createServer3 } from "http";
|
|
14032
14311
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
14033
14312
|
function tokensEqual(a, b) {
|
|
14034
14313
|
const left = Buffer.from(a);
|
|
@@ -14067,7 +14346,7 @@ var AgentRpcServer = class {
|
|
|
14067
14346
|
async listen(opts = {}) {
|
|
14068
14347
|
const host = opts.host ?? "127.0.0.1";
|
|
14069
14348
|
const port = opts.port ?? 0;
|
|
14070
|
-
const authToken =
|
|
14349
|
+
const authToken = randomBytes12(24).toString("base64url");
|
|
14071
14350
|
this.meta = {
|
|
14072
14351
|
runtimeId: randomUUID9(),
|
|
14073
14352
|
pid: process.pid,
|
|
@@ -14076,7 +14355,7 @@ var AgentRpcServer = class {
|
|
|
14076
14355
|
startedAt: Date.now(),
|
|
14077
14356
|
transports: []
|
|
14078
14357
|
};
|
|
14079
|
-
const http =
|
|
14358
|
+
const http = createServer3((_req, res) => {
|
|
14080
14359
|
res.statusCode = 404;
|
|
14081
14360
|
res.end();
|
|
14082
14361
|
});
|
|
@@ -15781,7 +16060,7 @@ function resolveSlackListenMode(opts) {
|
|
|
15781
16060
|
}
|
|
15782
16061
|
|
|
15783
16062
|
// src/relay/account-login.ts
|
|
15784
|
-
import { randomBytes as
|
|
16063
|
+
import { randomBytes as randomBytes13 } from "crypto";
|
|
15785
16064
|
var RemoteAccountLoginCancelled = class extends Error {
|
|
15786
16065
|
constructor() {
|
|
15787
16066
|
super("Sign-in cancelled");
|
|
@@ -15847,7 +16126,7 @@ async function readJson4(res, url) {
|
|
|
15847
16126
|
async function startRemoteAccountLogin(opts) {
|
|
15848
16127
|
if (opts.signal?.aborted) throw new RemoteAccountLoginCancelled();
|
|
15849
16128
|
const origin = (opts.origin ?? remoteAccountHttpOrigin()).replace(/\/+$/, "");
|
|
15850
|
-
const state =
|
|
16129
|
+
const state = randomBytes13(16).toString("hex");
|
|
15851
16130
|
const timeoutMs = opts.timeoutMs ?? 5 * 6e4;
|
|
15852
16131
|
const pollIntervalMs = opts.pollIntervalMs ?? 400;
|
|
15853
16132
|
const linkToken = opts.linkToken?.trim() ?? "";
|
|
@@ -15985,7 +16264,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
15985
16264
|
await continueOnReply(threadId, prompt);
|
|
15986
16265
|
return;
|
|
15987
16266
|
}
|
|
15988
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
16267
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
|
|
15989
16268
|
await getOrchestrator2().send(threadId, prompt);
|
|
15990
16269
|
} catch {
|
|
15991
16270
|
}
|
|
@@ -16266,6 +16545,7 @@ export {
|
|
|
16266
16545
|
ATTACHMENTS_DIR,
|
|
16267
16546
|
AbleTimeOAuthCancelledError,
|
|
16268
16547
|
BAKED_ABLETIME_OAUTH_CLIENT_ID,
|
|
16548
|
+
BAKED_POSTHOG_OAUTH_CLIENT_ID,
|
|
16269
16549
|
BAKED_REMOTE_RELAY_URL,
|
|
16270
16550
|
BAKED_SLACK_CLIENT_ID,
|
|
16271
16551
|
BAKED_SLACK_RELAY_URL,
|
|
@@ -16353,10 +16633,14 @@ export {
|
|
|
16353
16633
|
PLAN_MODE_OFF_INSTRUCTION,
|
|
16354
16634
|
PLAN_QUESTION_ANSWERS_PREFIX,
|
|
16355
16635
|
PORT_RANGE_SIZE,
|
|
16636
|
+
POSTHOG_OAUTH_OPTIONAL_SCOPES,
|
|
16637
|
+
POSTHOG_OAUTH_REGISTERED_REDIRECT,
|
|
16638
|
+
POSTHOG_OAUTH_SCOPES,
|
|
16356
16639
|
PRESENT_PLAN_REQUIRES_PLAN_MODE,
|
|
16357
16640
|
PRESENT_PLAN_TOOL_DESCRIPTION,
|
|
16358
16641
|
PROFILE_NOTES_MAX,
|
|
16359
16642
|
PR_DETAILS_JSON_FIELDS,
|
|
16643
|
+
PosthogOAuthCancelledError,
|
|
16360
16644
|
READ_ALOUD_RATE_DEFAULT,
|
|
16361
16645
|
READ_ALOUD_RATE_MAX,
|
|
16362
16646
|
READ_ALOUD_RATE_MIN,
|
|
@@ -16579,6 +16863,7 @@ export {
|
|
|
16579
16863
|
createLinearIssue,
|
|
16580
16864
|
createLinearPkce,
|
|
16581
16865
|
createOrUpdatePr,
|
|
16866
|
+
createPosthogPkce,
|
|
16582
16867
|
createPrStack,
|
|
16583
16868
|
createSchedule,
|
|
16584
16869
|
createSlackOrgApp,
|
|
@@ -16608,6 +16893,7 @@ export {
|
|
|
16608
16893
|
disconnectOptionalService,
|
|
16609
16894
|
disconnectRemoteAccount,
|
|
16610
16895
|
disconnectSlackWorkspace,
|
|
16896
|
+
discoverPosthogHost,
|
|
16611
16897
|
discoverSkills,
|
|
16612
16898
|
downloadAbleTimeAttachment,
|
|
16613
16899
|
downloadGitHubIssueAttachment,
|
|
@@ -16778,6 +17064,7 @@ export {
|
|
|
16778
17064
|
getMcpUiHost,
|
|
16779
17065
|
getOrchestrator,
|
|
16780
17066
|
getOrderPlan,
|
|
17067
|
+
getPosthogAccessToken,
|
|
16781
17068
|
getPr,
|
|
16782
17069
|
getPrChecks,
|
|
16783
17070
|
getPrCiChecks,
|
|
@@ -16886,6 +17173,7 @@ export {
|
|
|
16886
17173
|
isPlanQuestionAnswersMessage,
|
|
16887
17174
|
isPollWrapperToolName,
|
|
16888
17175
|
isPosthogConnected,
|
|
17176
|
+
isPosthogOAuthCancelled,
|
|
16889
17177
|
isPrNotMergeableError,
|
|
16890
17178
|
isPresentPlanToolName,
|
|
16891
17179
|
isPrimaryCheckoutThread,
|
|
@@ -17114,6 +17402,9 @@ export {
|
|
|
17114
17402
|
pnpmFilterPackage,
|
|
17115
17403
|
pollSlackOutboundWatches,
|
|
17116
17404
|
posixShellSingleQuote,
|
|
17405
|
+
posthogOAuthAuthorizeUrl,
|
|
17406
|
+
posthogOAuthClientId,
|
|
17407
|
+
posthogOAuthScopeParam,
|
|
17117
17408
|
preferredCursorCostCents,
|
|
17118
17409
|
prepareTerminalCommand,
|
|
17119
17410
|
prependQueuedItem,
|
|
@@ -17241,6 +17532,7 @@ export {
|
|
|
17241
17532
|
saveAbleTimeConnection,
|
|
17242
17533
|
saveAppSettings,
|
|
17243
17534
|
saveLinearOAuth,
|
|
17535
|
+
savePosthogOAuth,
|
|
17244
17536
|
saveRemotePhoneToken,
|
|
17245
17537
|
saveSlackOrgCredentials,
|
|
17246
17538
|
saveWorktreeRunPorts,
|
|
@@ -17309,6 +17601,7 @@ export {
|
|
|
17309
17601
|
startLinearOAuth,
|
|
17310
17602
|
startMcpServer,
|
|
17311
17603
|
startOrchestration,
|
|
17604
|
+
startPosthogOAuth,
|
|
17312
17605
|
startRelayServer,
|
|
17313
17606
|
startRemoteAccountLogin,
|
|
17314
17607
|
startSlackOAuth,
|
|
@@ -25,12 +25,12 @@ import {
|
|
|
25
25
|
rewriteLinearError,
|
|
26
26
|
updateLinearIssue,
|
|
27
27
|
validateLinearApiKey
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-PVCECFJK.js";
|
|
29
29
|
import "./chunk-DBKHL7NC.js";
|
|
30
30
|
import "./chunk-W3ZLE4PO.js";
|
|
31
31
|
import "./chunk-JAT3JFOS.js";
|
|
32
32
|
import "./chunk-6K64FJDD.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-6WMNIX2U.js";
|
|
34
34
|
import "./chunk-4TR3HZFT.js";
|
|
35
35
|
import "./chunk-WDRMZKVB.js";
|
|
36
36
|
import "./chunk-KI45T4DI.js";
|
|
@@ -27,12 +27,12 @@ import {
|
|
|
27
27
|
rewriteLinearError,
|
|
28
28
|
updateLinearIssue,
|
|
29
29
|
validateLinearApiKey
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-E77SRVVO.js";
|
|
31
31
|
import "./chunk-OYRN356W.js";
|
|
32
32
|
import "./chunk-F6GE7V3Q.js";
|
|
33
33
|
import "./chunk-N2WW62LF.js";
|
|
34
34
|
import "./chunk-2GPQZZLY.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-WWU4SYZR.js";
|
|
36
36
|
import "./chunk-NSTQ6QKD.js";
|
|
37
37
|
import "./chunk-WWUABK6B.js";
|
|
38
38
|
import "./chunk-FJZWM2ON.js";
|