@sideboard-ai/core 0.1.346 → 0.1.348
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-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-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-5IMXA563.js → chunk-OH3BAUMC.js} +46 -33
- 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-JZKNRDKF.js → chunk-WMD77UCY.js} +47 -34
- 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 +1115 -651
- package/dist/index.d.cts +61 -6
- package/dist/index.d.ts +61 -6
- package/dist/index.js +326 -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 +524 -235
- 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-4SXTORD2.js} +10 -10
- package/dist/{orchestrator-POMFVZLB.js → orchestrator-KNOMW5CZ.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-WMD77UCY.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";
|
|
@@ -5965,6 +5966,7 @@ function pushNotes(input) {
|
|
|
5965
5966
|
}
|
|
5966
5967
|
const event = input.event;
|
|
5967
5968
|
if (!event || event.type !== "turn_finished" && event.type !== "error") return notes;
|
|
5969
|
+
if (event.type === "turn_finished" && event.routineStop) return notes;
|
|
5968
5970
|
if (fresh.has(event.threadId)) return notes;
|
|
5969
5971
|
const finished = event.type === "turn_finished" && (event.exitCode === 0 || event.exitCode == null);
|
|
5970
5972
|
notes.push({ chatId: event.threadId, kind: finished ? "finished" : "failed" });
|
|
@@ -9955,7 +9957,7 @@ async function startHeadlessHost(opts) {
|
|
|
9955
9957
|
};
|
|
9956
9958
|
const refreshRunning = async () => {
|
|
9957
9959
|
try {
|
|
9958
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
9960
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
9959
9961
|
agentsRunning = getOrchestrator2().getRuntime().running;
|
|
9960
9962
|
} catch {
|
|
9961
9963
|
agentsRunning = 0;
|
|
@@ -10164,6 +10166,277 @@ async function loginEntireGit() {
|
|
|
10164
10166
|
};
|
|
10165
10167
|
}
|
|
10166
10168
|
|
|
10169
|
+
// src/integrations/posthog-oauth.ts
|
|
10170
|
+
import { createHash as createHash5, randomBytes as randomBytes11 } from "crypto";
|
|
10171
|
+
import { createServer as createServer2 } from "http";
|
|
10172
|
+
var BAKED_POSTHOG_OAUTH_CLIENT_ID = "https://www.sideboard.build/oauth/posthog-client.json";
|
|
10173
|
+
var POSTHOG_OAUTH_REGISTERED_REDIRECT = "http://127.0.0.1/callback";
|
|
10174
|
+
var POSTHOG_AUTHORIZE = "https://oauth.posthog.com/oauth/authorize/";
|
|
10175
|
+
var POSTHOG_TOKEN = "https://oauth.posthog.com/oauth/token/";
|
|
10176
|
+
var POSTHOG_API_HOSTS = ["https://us.posthog.com", "https://eu.posthog.com"];
|
|
10177
|
+
var POSTHOG_OAUTH_SCOPES = [
|
|
10178
|
+
"project:read",
|
|
10179
|
+
"organization:read",
|
|
10180
|
+
"query:read",
|
|
10181
|
+
"insight:read",
|
|
10182
|
+
"feature_flag:read",
|
|
10183
|
+
"experiment:read",
|
|
10184
|
+
"error_tracking:read",
|
|
10185
|
+
"dashboard:read",
|
|
10186
|
+
"event_definition:read",
|
|
10187
|
+
"property_definition:read",
|
|
10188
|
+
"user:read",
|
|
10189
|
+
"person:read"
|
|
10190
|
+
];
|
|
10191
|
+
var POSTHOG_OAUTH_OPTIONAL_SCOPES = [
|
|
10192
|
+
"query:write",
|
|
10193
|
+
"insight:write",
|
|
10194
|
+
"feature_flag:write",
|
|
10195
|
+
"experiment:write",
|
|
10196
|
+
"error_tracking:write",
|
|
10197
|
+
"dashboard:write",
|
|
10198
|
+
"person:write",
|
|
10199
|
+
"cohort:read",
|
|
10200
|
+
"cohort:write",
|
|
10201
|
+
"survey:read",
|
|
10202
|
+
"survey:write",
|
|
10203
|
+
"annotation:read",
|
|
10204
|
+
"annotation:write",
|
|
10205
|
+
"session_recording:read",
|
|
10206
|
+
"logs:read"
|
|
10207
|
+
];
|
|
10208
|
+
var REFRESH_SKEW_MS = 6e4;
|
|
10209
|
+
var PosthogOAuthCancelledError = class extends Error {
|
|
10210
|
+
constructor(message = "PostHog sign-in cancelled") {
|
|
10211
|
+
super(message);
|
|
10212
|
+
this.name = "PosthogOAuthCancelledError";
|
|
10213
|
+
}
|
|
10214
|
+
};
|
|
10215
|
+
function isPosthogOAuthCancelled(err) {
|
|
10216
|
+
return err instanceof PosthogOAuthCancelledError;
|
|
10217
|
+
}
|
|
10218
|
+
function posthogOAuthClientId() {
|
|
10219
|
+
return process.env.SIDEBOARD_POSTHOG_OAUTH_CLIENT_ID?.trim() || BAKED_POSTHOG_OAUTH_CLIENT_ID;
|
|
10220
|
+
}
|
|
10221
|
+
function posthogOAuthScopeParam() {
|
|
10222
|
+
return [...POSTHOG_OAUTH_SCOPES, ...POSTHOG_OAUTH_OPTIONAL_SCOPES].join(" ");
|
|
10223
|
+
}
|
|
10224
|
+
function createPosthogPkce() {
|
|
10225
|
+
const verifier = randomBytes11(32).toString("base64url");
|
|
10226
|
+
const challenge = createHash5("sha256").update(verifier).digest("base64url");
|
|
10227
|
+
return { verifier, challenge };
|
|
10228
|
+
}
|
|
10229
|
+
function posthogOAuthAuthorizeUrl(clientId, state, codeChallenge, redirectUri) {
|
|
10230
|
+
const params = new URLSearchParams({
|
|
10231
|
+
client_id: clientId,
|
|
10232
|
+
redirect_uri: redirectUri,
|
|
10233
|
+
response_type: "code",
|
|
10234
|
+
scope: posthogOAuthScopeParam(),
|
|
10235
|
+
state,
|
|
10236
|
+
code_challenge: codeChallenge,
|
|
10237
|
+
code_challenge_method: "S256"
|
|
10238
|
+
});
|
|
10239
|
+
return `${POSTHOG_AUTHORIZE}?${params.toString()}`;
|
|
10240
|
+
}
|
|
10241
|
+
function htmlPage(title, body) {
|
|
10242
|
+
return `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title>
|
|
10243
|
+
<style>body{font-family:ui-sans-serif,system-ui,sans-serif;padding:48px 24px;max-width:36rem;margin:0 auto;color:#1a1a1a}
|
|
10244
|
+
h1{font-size:1.25rem}p{line-height:1.5;color:#444}</style></head><body>${body}</body></html>`;
|
|
10245
|
+
}
|
|
10246
|
+
async function exchangePosthogToken(body) {
|
|
10247
|
+
const res = await httpFetch(POSTHOG_TOKEN, {
|
|
10248
|
+
method: "POST",
|
|
10249
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
|
|
10250
|
+
body
|
|
10251
|
+
});
|
|
10252
|
+
const data = await res.json().catch(() => ({}));
|
|
10253
|
+
if (!res.ok || data.error || !data.access_token?.trim()) {
|
|
10254
|
+
const detail = data.error_description || data.error || `HTTP ${res.status}`;
|
|
10255
|
+
throw new Error(`PostHog sign-in failed: ${detail}`);
|
|
10256
|
+
}
|
|
10257
|
+
return data;
|
|
10258
|
+
}
|
|
10259
|
+
function viewerNameFromMe(body) {
|
|
10260
|
+
const record = body && typeof body === "object" ? body : {};
|
|
10261
|
+
const email = typeof record.email === "string" ? record.email.trim() : "";
|
|
10262
|
+
if (email) return email.slice(0, 120);
|
|
10263
|
+
const first = typeof record.first_name === "string" ? record.first_name.trim() : "";
|
|
10264
|
+
const last = typeof record.last_name === "string" ? record.last_name.trim() : "";
|
|
10265
|
+
const name = [first, last].filter(Boolean).join(" ");
|
|
10266
|
+
return (name || "PostHog user").slice(0, 120);
|
|
10267
|
+
}
|
|
10268
|
+
async function discoverPosthogHost(token) {
|
|
10269
|
+
let last = "PostHog rejected the sign-in";
|
|
10270
|
+
for (const host of POSTHOG_API_HOSTS) {
|
|
10271
|
+
const res = await httpFetch(`${host}/api/users/@me/`, {
|
|
10272
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" }
|
|
10273
|
+
});
|
|
10274
|
+
if (res.status === 401 || res.status === 403) {
|
|
10275
|
+
last = `${host} rejected the token`;
|
|
10276
|
+
continue;
|
|
10277
|
+
}
|
|
10278
|
+
if (!res.ok) {
|
|
10279
|
+
last = `${host} returned HTTP ${res.status}`;
|
|
10280
|
+
continue;
|
|
10281
|
+
}
|
|
10282
|
+
const body = await res.json().catch(() => ({}));
|
|
10283
|
+
return { host, viewerName: viewerNameFromMe(body) };
|
|
10284
|
+
}
|
|
10285
|
+
throw new Error(last);
|
|
10286
|
+
}
|
|
10287
|
+
var refreshInFlight = null;
|
|
10288
|
+
async function refreshPosthogAccessToken(refresh, host, viewerName, legacy) {
|
|
10289
|
+
try {
|
|
10290
|
+
const data = await exchangePosthogToken(
|
|
10291
|
+
new URLSearchParams({
|
|
10292
|
+
grant_type: "refresh_token",
|
|
10293
|
+
refresh_token: refresh,
|
|
10294
|
+
client_id: posthogOAuthClientId()
|
|
10295
|
+
})
|
|
10296
|
+
);
|
|
10297
|
+
const saved = savePosthogOAuth({
|
|
10298
|
+
accessToken: data.access_token.trim(),
|
|
10299
|
+
refreshToken: data.refresh_token?.trim() || refresh,
|
|
10300
|
+
expiresIn: data.expires_in,
|
|
10301
|
+
host,
|
|
10302
|
+
viewerName
|
|
10303
|
+
});
|
|
10304
|
+
return {
|
|
10305
|
+
token: saved.integrations.posthogAccessToken.trim(),
|
|
10306
|
+
host: saved.integrations.posthogHost?.trim() || host
|
|
10307
|
+
};
|
|
10308
|
+
} catch (err) {
|
|
10309
|
+
if (legacy) return { token: legacy, host };
|
|
10310
|
+
throw err;
|
|
10311
|
+
}
|
|
10312
|
+
}
|
|
10313
|
+
async function getPosthogAccessToken() {
|
|
10314
|
+
const integrations = loadAppSettings().integrations;
|
|
10315
|
+
const host = integrations.posthogHost?.trim() || "https://us.posthog.com";
|
|
10316
|
+
const access = integrations.posthogAccessToken?.trim() || "";
|
|
10317
|
+
const refresh = integrations.posthogRefreshToken?.trim() || "";
|
|
10318
|
+
const legacy = integrations.posthogPersonalApiKey?.trim() || "";
|
|
10319
|
+
const exp = integrations.posthogTokenExpiresAt;
|
|
10320
|
+
const accessFresh = Boolean(access) && (exp == null || exp - Date.now() > REFRESH_SKEW_MS);
|
|
10321
|
+
if (accessFresh) return { token: access, host };
|
|
10322
|
+
if (refresh) {
|
|
10323
|
+
if (!refreshInFlight) {
|
|
10324
|
+
refreshInFlight = refreshPosthogAccessToken(
|
|
10325
|
+
refresh,
|
|
10326
|
+
host,
|
|
10327
|
+
integrations.posthogViewerName,
|
|
10328
|
+
legacy
|
|
10329
|
+
).finally(() => {
|
|
10330
|
+
refreshInFlight = null;
|
|
10331
|
+
});
|
|
10332
|
+
}
|
|
10333
|
+
return refreshInFlight;
|
|
10334
|
+
}
|
|
10335
|
+
if (access) return { token: access, host };
|
|
10336
|
+
if (legacy) return { token: legacy, host };
|
|
10337
|
+
return null;
|
|
10338
|
+
}
|
|
10339
|
+
async function startPosthogOAuth(opts) {
|
|
10340
|
+
if (opts?.signal?.aborted) throw new PosthogOAuthCancelledError();
|
|
10341
|
+
const clientId = posthogOAuthClientId();
|
|
10342
|
+
const state = randomBytes11(16).toString("hex");
|
|
10343
|
+
const pkce = createPosthogPkce();
|
|
10344
|
+
const timeoutMs = opts?.timeoutMs ?? 5 * 6e4;
|
|
10345
|
+
const code = await new Promise((resolve, reject) => {
|
|
10346
|
+
let settled = false;
|
|
10347
|
+
const finish = (err, value) => {
|
|
10348
|
+
if (settled) return;
|
|
10349
|
+
settled = true;
|
|
10350
|
+
cleanup();
|
|
10351
|
+
if (err) reject(err);
|
|
10352
|
+
else resolve(value);
|
|
10353
|
+
};
|
|
10354
|
+
const server = createServer2((req, res) => {
|
|
10355
|
+
try {
|
|
10356
|
+
const url = new URL(req.url || "/", "http://127.0.0.1");
|
|
10357
|
+
if (url.pathname !== "/callback") {
|
|
10358
|
+
res.writeHead(404);
|
|
10359
|
+
res.end("Not found");
|
|
10360
|
+
return;
|
|
10361
|
+
}
|
|
10362
|
+
const err = url.searchParams.get("error");
|
|
10363
|
+
const gotState = url.searchParams.get("state");
|
|
10364
|
+
const gotCode = url.searchParams.get("code");
|
|
10365
|
+
if (err) {
|
|
10366
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
10367
|
+
res.end(htmlPage("PostHog", "<h1>Authorization cancelled</h1><p>You can close this tab.</p>"));
|
|
10368
|
+
finish(new PosthogOAuthCancelledError());
|
|
10369
|
+
return;
|
|
10370
|
+
}
|
|
10371
|
+
if (gotState !== state || !gotCode) {
|
|
10372
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
10373
|
+
res.end(htmlPage("PostHog", "<h1>Invalid callback</h1><p>State or code missing.</p>"));
|
|
10374
|
+
finish(new Error("PostHog sign-in callback was invalid"));
|
|
10375
|
+
return;
|
|
10376
|
+
}
|
|
10377
|
+
const addr = server.address();
|
|
10378
|
+
const port = addr && typeof addr !== "string" ? addr.port : 0;
|
|
10379
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
10380
|
+
res.end(
|
|
10381
|
+
htmlPage(
|
|
10382
|
+
"PostHog connected",
|
|
10383
|
+
"<h1>PostHog connected</h1><p>You can close this tab and return to Sideboard.</p>"
|
|
10384
|
+
)
|
|
10385
|
+
);
|
|
10386
|
+
finish(void 0, { code: gotCode, redirectUri: `http://127.0.0.1:${port}/callback` });
|
|
10387
|
+
} catch (e) {
|
|
10388
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10389
|
+
}
|
|
10390
|
+
});
|
|
10391
|
+
const timer = setTimeout(() => finish(new Error("PostHog sign-in timed out \u2014 try again")), timeoutMs);
|
|
10392
|
+
const onAbort = () => finish(new PosthogOAuthCancelledError());
|
|
10393
|
+
const cleanup = () => {
|
|
10394
|
+
clearTimeout(timer);
|
|
10395
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
10396
|
+
server.close();
|
|
10397
|
+
};
|
|
10398
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
10399
|
+
if (opts?.signal?.aborted) {
|
|
10400
|
+
onAbort();
|
|
10401
|
+
return;
|
|
10402
|
+
}
|
|
10403
|
+
server.on("error", (e) => {
|
|
10404
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10405
|
+
});
|
|
10406
|
+
server.listen(0, "127.0.0.1", () => {
|
|
10407
|
+
const addr = server.address();
|
|
10408
|
+
const port = addr && typeof addr !== "string" ? addr.port : 0;
|
|
10409
|
+
if (!port) {
|
|
10410
|
+
finish(new Error("PostHog sign-in could not bind a local port"));
|
|
10411
|
+
return;
|
|
10412
|
+
}
|
|
10413
|
+
const redirectUri = `http://127.0.0.1:${port}/callback`;
|
|
10414
|
+
const authorizeUrl = posthogOAuthAuthorizeUrl(clientId, state, pkce.challenge, redirectUri);
|
|
10415
|
+
void Promise.resolve(opts?.openUrl?.(authorizeUrl)).catch((e) => {
|
|
10416
|
+
finish(e instanceof Error ? e : new Error(String(e)));
|
|
10417
|
+
});
|
|
10418
|
+
});
|
|
10419
|
+
});
|
|
10420
|
+
const data = await exchangePosthogToken(
|
|
10421
|
+
new URLSearchParams({
|
|
10422
|
+
grant_type: "authorization_code",
|
|
10423
|
+
code: code.code,
|
|
10424
|
+
redirect_uri: code.redirectUri,
|
|
10425
|
+
client_id: clientId,
|
|
10426
|
+
code_verifier: pkce.verifier
|
|
10427
|
+
})
|
|
10428
|
+
);
|
|
10429
|
+
const token = data.access_token.trim();
|
|
10430
|
+
const discovered = await discoverPosthogHost(token);
|
|
10431
|
+
return savePosthogOAuth({
|
|
10432
|
+
accessToken: token,
|
|
10433
|
+
refreshToken: data.refresh_token?.trim(),
|
|
10434
|
+
expiresIn: data.expires_in,
|
|
10435
|
+
host: discovered.host,
|
|
10436
|
+
viewerName: discovered.viewerName
|
|
10437
|
+
});
|
|
10438
|
+
}
|
|
10439
|
+
|
|
10167
10440
|
// src/composer/diff-comment.ts
|
|
10168
10441
|
function lineRangeLabel(lines) {
|
|
10169
10442
|
const nos = lines.map((l) => l.lineNo);
|
|
@@ -11469,9 +11742,16 @@ async function runPosthogApi(input) {
|
|
|
11469
11742
|
if (method === "GET" && input.body !== void 0) {
|
|
11470
11743
|
return mcpJson({ ok: false, error: "GET does not take a body" }, true);
|
|
11471
11744
|
}
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11745
|
+
let session;
|
|
11746
|
+
try {
|
|
11747
|
+
session = await getPosthogAccessToken();
|
|
11748
|
+
} catch (err) {
|
|
11749
|
+
return mcpJson(
|
|
11750
|
+
{ ok: false, error: err instanceof Error ? err.message : String(err) },
|
|
11751
|
+
true
|
|
11752
|
+
);
|
|
11753
|
+
}
|
|
11754
|
+
if (!session) {
|
|
11475
11755
|
return mcpJson(
|
|
11476
11756
|
{ ok: false, error: "PostHog is not connected (Settings \u2192 Connectors)." },
|
|
11477
11757
|
true
|
|
@@ -11480,7 +11760,7 @@ async function runPosthogApi(input) {
|
|
|
11480
11760
|
let url;
|
|
11481
11761
|
try {
|
|
11482
11762
|
url = posthogApiUrl(
|
|
11483
|
-
|
|
11763
|
+
session.host,
|
|
11484
11764
|
withPosthogSlash(method, input.path),
|
|
11485
11765
|
input.query
|
|
11486
11766
|
);
|
|
@@ -11491,7 +11771,7 @@ async function runPosthogApi(input) {
|
|
|
11491
11771
|
);
|
|
11492
11772
|
}
|
|
11493
11773
|
const headers = {
|
|
11494
|
-
Authorization: `Bearer ${token}`,
|
|
11774
|
+
Authorization: `Bearer ${session.token}`,
|
|
11495
11775
|
Accept: "application/json"
|
|
11496
11776
|
};
|
|
11497
11777
|
let body;
|
|
@@ -12411,7 +12691,7 @@ async function handleJobStop(params, _ctx) {
|
|
|
12411
12691
|
return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
|
|
12412
12692
|
}
|
|
12413
12693
|
async function defaultTurnWait(ref, timeoutMs) {
|
|
12414
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
12694
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
12415
12695
|
const orch = getOrchestrator2();
|
|
12416
12696
|
const thread = await orch.waitForTurn(ref, timeoutMs, {
|
|
12417
12697
|
resolveIfStillRunning: true
|
|
@@ -12764,7 +13044,7 @@ async function startMcpServer() {
|
|
|
12764
13044
|
);
|
|
12765
13045
|
}
|
|
12766
13046
|
try {
|
|
12767
|
-
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-
|
|
13047
|
+
const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-SNOPJ7P5.js");
|
|
12768
13048
|
orch.setMaxConcurrent(maxConcurrentAgents2());
|
|
12769
13049
|
} catch {
|
|
12770
13050
|
}
|
|
@@ -13343,7 +13623,7 @@ async function startMcpServer() {
|
|
|
13343
13623
|
if (!worktreeProfile) {
|
|
13344
13624
|
registerConnectedIssueVendorTools(server);
|
|
13345
13625
|
const { getCaffeinateHold: getCaffeinateHold2, setCaffeinateHold: setCaffeinateHold2 } = await import("./caffeinate-hold-ZNUEZGHB.js");
|
|
13346
|
-
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-
|
|
13626
|
+
const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-SNOPJ7P5.js");
|
|
13347
13627
|
const accountDefaults = resolveThreadDefaults2();
|
|
13348
13628
|
const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
|
|
13349
13629
|
server.tool(
|
|
@@ -14027,8 +14307,8 @@ async function startMcpServer() {
|
|
|
14027
14307
|
}
|
|
14028
14308
|
|
|
14029
14309
|
// src/agent-rpc/server.ts
|
|
14030
|
-
import { randomBytes as
|
|
14031
|
-
import { createServer as
|
|
14310
|
+
import { randomBytes as randomBytes12, randomUUID as randomUUID9, timingSafeEqual as timingSafeEqual4 } from "crypto";
|
|
14311
|
+
import { createServer as createServer3 } from "http";
|
|
14032
14312
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
14033
14313
|
function tokensEqual(a, b) {
|
|
14034
14314
|
const left = Buffer.from(a);
|
|
@@ -14067,7 +14347,7 @@ var AgentRpcServer = class {
|
|
|
14067
14347
|
async listen(opts = {}) {
|
|
14068
14348
|
const host = opts.host ?? "127.0.0.1";
|
|
14069
14349
|
const port = opts.port ?? 0;
|
|
14070
|
-
const authToken =
|
|
14350
|
+
const authToken = randomBytes12(24).toString("base64url");
|
|
14071
14351
|
this.meta = {
|
|
14072
14352
|
runtimeId: randomUUID9(),
|
|
14073
14353
|
pid: process.pid,
|
|
@@ -14076,7 +14356,7 @@ var AgentRpcServer = class {
|
|
|
14076
14356
|
startedAt: Date.now(),
|
|
14077
14357
|
transports: []
|
|
14078
14358
|
};
|
|
14079
|
-
const http =
|
|
14359
|
+
const http = createServer3((_req, res) => {
|
|
14080
14360
|
res.statusCode = 404;
|
|
14081
14361
|
res.end();
|
|
14082
14362
|
});
|
|
@@ -15781,7 +16061,7 @@ function resolveSlackListenMode(opts) {
|
|
|
15781
16061
|
}
|
|
15782
16062
|
|
|
15783
16063
|
// src/relay/account-login.ts
|
|
15784
|
-
import { randomBytes as
|
|
16064
|
+
import { randomBytes as randomBytes13 } from "crypto";
|
|
15785
16065
|
var RemoteAccountLoginCancelled = class extends Error {
|
|
15786
16066
|
constructor() {
|
|
15787
16067
|
super("Sign-in cancelled");
|
|
@@ -15847,7 +16127,7 @@ async function readJson4(res, url) {
|
|
|
15847
16127
|
async function startRemoteAccountLogin(opts) {
|
|
15848
16128
|
if (opts.signal?.aborted) throw new RemoteAccountLoginCancelled();
|
|
15849
16129
|
const origin = (opts.origin ?? remoteAccountHttpOrigin()).replace(/\/+$/, "");
|
|
15850
|
-
const state =
|
|
16130
|
+
const state = randomBytes13(16).toString("hex");
|
|
15851
16131
|
const timeoutMs = opts.timeoutMs ?? 5 * 6e4;
|
|
15852
16132
|
const pollIntervalMs = opts.pollIntervalMs ?? 400;
|
|
15853
16133
|
const linkToken = opts.linkToken?.trim() ?? "";
|
|
@@ -15985,7 +16265,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
15985
16265
|
await continueOnReply(threadId, prompt);
|
|
15986
16266
|
return;
|
|
15987
16267
|
}
|
|
15988
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
16268
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
15989
16269
|
await getOrchestrator2().send(threadId, prompt);
|
|
15990
16270
|
} catch {
|
|
15991
16271
|
}
|
|
@@ -16266,6 +16546,7 @@ export {
|
|
|
16266
16546
|
ATTACHMENTS_DIR,
|
|
16267
16547
|
AbleTimeOAuthCancelledError,
|
|
16268
16548
|
BAKED_ABLETIME_OAUTH_CLIENT_ID,
|
|
16549
|
+
BAKED_POSTHOG_OAUTH_CLIENT_ID,
|
|
16269
16550
|
BAKED_REMOTE_RELAY_URL,
|
|
16270
16551
|
BAKED_SLACK_CLIENT_ID,
|
|
16271
16552
|
BAKED_SLACK_RELAY_URL,
|
|
@@ -16353,10 +16634,14 @@ export {
|
|
|
16353
16634
|
PLAN_MODE_OFF_INSTRUCTION,
|
|
16354
16635
|
PLAN_QUESTION_ANSWERS_PREFIX,
|
|
16355
16636
|
PORT_RANGE_SIZE,
|
|
16637
|
+
POSTHOG_OAUTH_OPTIONAL_SCOPES,
|
|
16638
|
+
POSTHOG_OAUTH_REGISTERED_REDIRECT,
|
|
16639
|
+
POSTHOG_OAUTH_SCOPES,
|
|
16356
16640
|
PRESENT_PLAN_REQUIRES_PLAN_MODE,
|
|
16357
16641
|
PRESENT_PLAN_TOOL_DESCRIPTION,
|
|
16358
16642
|
PROFILE_NOTES_MAX,
|
|
16359
16643
|
PR_DETAILS_JSON_FIELDS,
|
|
16644
|
+
PosthogOAuthCancelledError,
|
|
16360
16645
|
READ_ALOUD_RATE_DEFAULT,
|
|
16361
16646
|
READ_ALOUD_RATE_MAX,
|
|
16362
16647
|
READ_ALOUD_RATE_MIN,
|
|
@@ -16579,6 +16864,7 @@ export {
|
|
|
16579
16864
|
createLinearIssue,
|
|
16580
16865
|
createLinearPkce,
|
|
16581
16866
|
createOrUpdatePr,
|
|
16867
|
+
createPosthogPkce,
|
|
16582
16868
|
createPrStack,
|
|
16583
16869
|
createSchedule,
|
|
16584
16870
|
createSlackOrgApp,
|
|
@@ -16608,6 +16894,7 @@ export {
|
|
|
16608
16894
|
disconnectOptionalService,
|
|
16609
16895
|
disconnectRemoteAccount,
|
|
16610
16896
|
disconnectSlackWorkspace,
|
|
16897
|
+
discoverPosthogHost,
|
|
16611
16898
|
discoverSkills,
|
|
16612
16899
|
downloadAbleTimeAttachment,
|
|
16613
16900
|
downloadGitHubIssueAttachment,
|
|
@@ -16778,6 +17065,7 @@ export {
|
|
|
16778
17065
|
getMcpUiHost,
|
|
16779
17066
|
getOrchestrator,
|
|
16780
17067
|
getOrderPlan,
|
|
17068
|
+
getPosthogAccessToken,
|
|
16781
17069
|
getPr,
|
|
16782
17070
|
getPrChecks,
|
|
16783
17071
|
getPrCiChecks,
|
|
@@ -16886,6 +17174,7 @@ export {
|
|
|
16886
17174
|
isPlanQuestionAnswersMessage,
|
|
16887
17175
|
isPollWrapperToolName,
|
|
16888
17176
|
isPosthogConnected,
|
|
17177
|
+
isPosthogOAuthCancelled,
|
|
16889
17178
|
isPrNotMergeableError,
|
|
16890
17179
|
isPresentPlanToolName,
|
|
16891
17180
|
isPrimaryCheckoutThread,
|
|
@@ -17114,6 +17403,9 @@ export {
|
|
|
17114
17403
|
pnpmFilterPackage,
|
|
17115
17404
|
pollSlackOutboundWatches,
|
|
17116
17405
|
posixShellSingleQuote,
|
|
17406
|
+
posthogOAuthAuthorizeUrl,
|
|
17407
|
+
posthogOAuthClientId,
|
|
17408
|
+
posthogOAuthScopeParam,
|
|
17117
17409
|
preferredCursorCostCents,
|
|
17118
17410
|
prepareTerminalCommand,
|
|
17119
17411
|
prependQueuedItem,
|
|
@@ -17241,6 +17533,7 @@ export {
|
|
|
17241
17533
|
saveAbleTimeConnection,
|
|
17242
17534
|
saveAppSettings,
|
|
17243
17535
|
saveLinearOAuth,
|
|
17536
|
+
savePosthogOAuth,
|
|
17244
17537
|
saveRemotePhoneToken,
|
|
17245
17538
|
saveSlackOrgCredentials,
|
|
17246
17539
|
saveWorktreeRunPorts,
|
|
@@ -17309,6 +17602,7 @@ export {
|
|
|
17309
17602
|
startLinearOAuth,
|
|
17310
17603
|
startMcpServer,
|
|
17311
17604
|
startOrchestration,
|
|
17605
|
+
startPosthogOAuth,
|
|
17312
17606
|
startRelayServer,
|
|
17313
17607
|
startRemoteAccountLogin,
|
|
17314
17608
|
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";
|