@boxes-dev/dvb-runtime 1.0.1066 → 1.0.1068
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/bin/dvb.mjs +479 -360
- package/dist/bin/dvbd.mjs +6 -6
- package/dist/product-docs/references/files-git-and-review.md +4 -1
- package/dist/product-docs/references/mobile.md +12 -5
- package/dist/product-docs/references/project-setup.md +28 -2
- package/dist/product-docs/references/security-and-data.md +8 -0
- package/dist/product-docs/references/slack.md +2 -1
- package/dist/product-docs/references/team-template.md +2 -0
- package/dist/product-docs/references/threads-and-agents.md +9 -4
- package/dist/product-docs/references/troubleshooting.md +35 -0
- package/package.json +2 -2
package/dist/bin/dvb.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f9b05d56-bcfd-5306-9e59-f832431ece07")}catch(e){}}();
|
|
4
4
|
import { createRequire as __dvbCreateRequire } from "node:module";
|
|
5
5
|
import { dirname as __dvbDirname } from "node:path";
|
|
6
6
|
import { fileURLToPath as __dvbFileURLToPath } from "node:url";
|
|
@@ -5897,7 +5897,11 @@ var init_profiles = __esm({
|
|
|
5897
5897
|
agentVersion: MANAGED_CODEX_MCP_OAUTH_VERSION,
|
|
5898
5898
|
profileVersion: "codex-0.144.0",
|
|
5899
5899
|
callbackHostname: "127.0.0.1",
|
|
5900
|
-
|
|
5900
|
+
// Native Codex's Auto registration mode (codex-rs/rmcp-client
|
|
5901
|
+
// oauth_client_registration.rs) offers OpenAI's per-callback client metadata
|
|
5902
|
+
// document to servers that accept public clients. The SDK uses it only when
|
|
5903
|
+
// the server also advertises client metadata documents.
|
|
5904
|
+
resolveClientMetadataUrl: (serverUrl, authorizationServerMetadata) => authorizationServerMetadata?.token_endpoint_auth_methods_supported?.includes("none") ? `https://chatgpt.com/oauth/codex/${buildCodexCallbackId(serverUrl)}/client.json` : null,
|
|
5901
5905
|
buildCallbackPath: (serverUrl) => `/callback/${buildCodexCallbackId(serverUrl)}`,
|
|
5902
5906
|
buildClientMetadata: (_serverName, redirectUri) => buildPublicClientMetadata("Codex", redirectUri)
|
|
5903
5907
|
};
|
|
@@ -5907,7 +5911,7 @@ var init_profiles = __esm({
|
|
|
5907
5911
|
profileVersion: "claude-2.1.220",
|
|
5908
5912
|
// Anthropic permits both hosts; some servers allow varying ports only for IP loopback.
|
|
5909
5913
|
callbackHostname: "127.0.0.1",
|
|
5910
|
-
|
|
5914
|
+
resolveClientMetadataUrl: () => CLAUDE_CODE_CLIENT_METADATA_URL,
|
|
5911
5915
|
buildCallbackPath: () => "/callback",
|
|
5912
5916
|
buildClientMetadata: (serverName, redirectUri) => buildPublicClientMetadata(`Claude Code (${serverName})`, redirectUri)
|
|
5913
5917
|
};
|
|
@@ -26274,17 +26278,16 @@ var init_companion = __esm({
|
|
|
26274
26278
|
redirectUrl;
|
|
26275
26279
|
clientMetadataUrl;
|
|
26276
26280
|
clientMetadata;
|
|
26281
|
+
resolveClientMetadataUrl;
|
|
26277
26282
|
expectedState;
|
|
26278
26283
|
openAuthorizationUrl;
|
|
26279
26284
|
codeVerifierValue;
|
|
26280
26285
|
clientInformationValue;
|
|
26281
26286
|
tokensValue;
|
|
26282
26287
|
discoveryStateValue;
|
|
26283
|
-
constructor({
|
|
26288
|
+
constructor({ resolveClientMetadataUrl, clientMetadata, expectedState, openAuthorizationUrl, redirectUrl }) {
|
|
26284
26289
|
this.redirectUrl = redirectUrl;
|
|
26285
|
-
|
|
26286
|
-
this.clientMetadataUrl = clientMetadataUrl;
|
|
26287
|
-
}
|
|
26290
|
+
this.resolveClientMetadataUrl = resolveClientMetadataUrl;
|
|
26288
26291
|
this.clientMetadata = clientMetadata;
|
|
26289
26292
|
this.expectedState = expectedState;
|
|
26290
26293
|
this.openAuthorizationUrl = openAuthorizationUrl;
|
|
@@ -26343,6 +26346,12 @@ var init_companion = __esm({
|
|
|
26343
26346
|
}
|
|
26344
26347
|
saveDiscoveryState(state) {
|
|
26345
26348
|
this.discoveryStateValue = state;
|
|
26349
|
+
const clientMetadataUrl = this.resolveClientMetadataUrl(state.authorizationServerMetadata);
|
|
26350
|
+
if (clientMetadataUrl === null) {
|
|
26351
|
+
delete this.clientMetadataUrl;
|
|
26352
|
+
} else {
|
|
26353
|
+
this.clientMetadataUrl = clientMetadataUrl;
|
|
26354
|
+
}
|
|
26346
26355
|
}
|
|
26347
26356
|
discoveryState() {
|
|
26348
26357
|
return this.discoveryStateValue;
|
|
@@ -26437,7 +26446,7 @@ var init_companion = __esm({
|
|
|
26437
26446
|
errorCode: null
|
|
26438
26447
|
});
|
|
26439
26448
|
provider = new TransientMcpOAuthProvider({
|
|
26440
|
-
|
|
26449
|
+
resolveClientMetadataUrl: (authorizationServerMetadata) => profile.resolveClientMetadataUrl(serverUrl, authorizationServerMetadata),
|
|
26441
26450
|
clientMetadata: profile.buildClientMetadata(serverName, callbackListener.redirectUri),
|
|
26442
26451
|
expectedState: state,
|
|
26443
26452
|
openAuthorizationUrl: async (authorizationUrl) => {
|
|
@@ -27010,7 +27019,7 @@ var init_chatGptBrowserSignIn = __esm({
|
|
|
27010
27019
|
});
|
|
27011
27020
|
|
|
27012
27021
|
// ../../../../shared/devboxCore/dist/claudeOAuthParams.js
|
|
27013
|
-
var CLAUDE_OAUTH_SOURCE_VERSION, CLAUDE_OAUTH_AUTHORIZE_URL, CLAUDE_OAUTH_CLIENT_ID, CLAUDE_OAUTH_MANUAL_REDIRECT_URL, CLAUDE_OAUTH_AUTOMATIC_REDIRECT_URL,
|
|
27022
|
+
var CLAUDE_OAUTH_SOURCE_VERSION, CLAUDE_OAUTH_AUTHORIZE_URL, CLAUDE_OAUTH_CLIENT_ID, CLAUDE_OAUTH_MANUAL_REDIRECT_URL, CLAUDE_OAUTH_AUTOMATIC_REDIRECT_URL, CLAUDE_SETUP_TOKEN_EXPIRES_IN_SECONDS, CLAUDE_LOGIN_SCOPES, CLAUDE_OAUTH_HTTP_USER_AGENT, buildClaudeAuthDiscovery;
|
|
27014
27023
|
var init_claudeOAuthParams = __esm({
|
|
27015
27024
|
"../../../../shared/devboxCore/dist/claudeOAuthParams.js"() {
|
|
27016
27025
|
"use strict";
|
|
@@ -27019,8 +27028,16 @@ var init_claudeOAuthParams = __esm({
|
|
|
27019
27028
|
CLAUDE_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
27020
27029
|
CLAUDE_OAUTH_MANUAL_REDIRECT_URL = "https://platform.claude.com/oauth/code/callback";
|
|
27021
27030
|
CLAUDE_OAUTH_AUTOMATIC_REDIRECT_URL = "http://localhost/callback";
|
|
27022
|
-
CLAUDE_SETUP_TOKEN_SCOPE = "user:inference";
|
|
27023
27031
|
CLAUDE_SETUP_TOKEN_EXPIRES_IN_SECONDS = 365 * 24 * 60 * 60;
|
|
27032
|
+
CLAUDE_LOGIN_SCOPES = [
|
|
27033
|
+
"org:create_api_key",
|
|
27034
|
+
"user:profile",
|
|
27035
|
+
"user:inference",
|
|
27036
|
+
"user:sessions:claude_code",
|
|
27037
|
+
"user:mcp_servers",
|
|
27038
|
+
"user:file_upload",
|
|
27039
|
+
"user:plugins"
|
|
27040
|
+
];
|
|
27024
27041
|
CLAUDE_OAUTH_HTTP_USER_AGENT = "axios/1.15.2";
|
|
27025
27042
|
buildClaudeAuthDiscovery = () => {
|
|
27026
27043
|
const authorizeUrl = new URL(CLAUDE_OAUTH_AUTHORIZE_URL);
|
|
@@ -69709,9 +69726,9 @@ var init_sentry = __esm({
|
|
|
69709
69726
|
uncaughtExceptionMonitorInstalled = false;
|
|
69710
69727
|
currentDevboxSentryUser = null;
|
|
69711
69728
|
readBuildMetadata = () => {
|
|
69712
|
-
const rawPackageVersion = "1.0.
|
|
69713
|
-
const rawGitSha = "
|
|
69714
|
-
const rawSentryRelease = "boxes-dev-dvb@1.0.
|
|
69729
|
+
const rawPackageVersion = "1.0.1068";
|
|
69730
|
+
const rawGitSha = "2568b3433ede13bc0c6b1399d95ffa38a55bacac";
|
|
69731
|
+
const rawSentryRelease = "boxes-dev-dvb@1.0.1068+2568b3433ede13bc0c6b1399d95ffa38a55bacac";
|
|
69715
69732
|
const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
|
|
69716
69733
|
const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
|
|
69717
69734
|
const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
|
|
@@ -75095,7 +75112,7 @@ var init_packageVersion = __esm({
|
|
|
75095
75112
|
return path18.join(process.cwd(), "dvb");
|
|
75096
75113
|
};
|
|
75097
75114
|
readEmbeddedPackageVersion = () => {
|
|
75098
|
-
const raw = "1.0.
|
|
75115
|
+
const raw = "1.0.1068";
|
|
75099
75116
|
return trimVersion(raw);
|
|
75100
75117
|
};
|
|
75101
75118
|
readNearestPackageMetadata = (basePath) => {
|
|
@@ -75408,6 +75425,35 @@ var init_devboxCore = __esm({
|
|
|
75408
75425
|
}
|
|
75409
75426
|
});
|
|
75410
75427
|
|
|
75428
|
+
// src/devbox/authErrors.ts
|
|
75429
|
+
var LOGIN_REQUIRED_MESSAGES, ControlPlaneLoginRequiredError, ControlPlaneAuthUnavailableError;
|
|
75430
|
+
var init_authErrors = __esm({
|
|
75431
|
+
"src/devbox/authErrors.ts"() {
|
|
75432
|
+
"use strict";
|
|
75433
|
+
LOGIN_REQUIRED_MESSAGES = {
|
|
75434
|
+
signed_out: "Not logged in to boxes.dev. Run `dvb setup` in an interactive terminal first.",
|
|
75435
|
+
session_invalid: "Your saved boxes.dev login is no longer valid. Run `dvb setup` in an interactive terminal to log in again."
|
|
75436
|
+
};
|
|
75437
|
+
ControlPlaneLoginRequiredError = class extends Error {
|
|
75438
|
+
reason;
|
|
75439
|
+
constructor(reason, options) {
|
|
75440
|
+
super(options?.message ?? LOGIN_REQUIRED_MESSAGES[reason], options);
|
|
75441
|
+
this.name = "ControlPlaneLoginRequiredError";
|
|
75442
|
+
this.reason = reason;
|
|
75443
|
+
}
|
|
75444
|
+
};
|
|
75445
|
+
ControlPlaneAuthUnavailableError = class extends Error {
|
|
75446
|
+
constructor(options) {
|
|
75447
|
+
super(
|
|
75448
|
+
"Couldn't check your boxes.dev login. Check your network connection, or try again in a few minutes.",
|
|
75449
|
+
options
|
|
75450
|
+
);
|
|
75451
|
+
this.name = "ControlPlaneAuthUnavailableError";
|
|
75452
|
+
}
|
|
75453
|
+
};
|
|
75454
|
+
}
|
|
75455
|
+
});
|
|
75456
|
+
|
|
75411
75457
|
// src/devbox/daemonWorkingDirectory.ts
|
|
75412
75458
|
import fs13 from "node:fs";
|
|
75413
75459
|
import path19 from "node:path";
|
|
@@ -90108,7 +90154,7 @@ var init_index_node2 = __esm({
|
|
|
90108
90154
|
// src/devbox/controlPlane.ts
|
|
90109
90155
|
import http7 from "node:http";
|
|
90110
90156
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
90111
|
-
var MANAGED_DAEMON_NOT_READY_CODE, CONVEX_INFLIGHT_ACTION_DISCONNECTED_MESSAGE, CONTROL_PLANE_ACTION_RETRY_MAX_ATTEMPTS, CONTROL_PLANE_ACTION_RETRY_BASE_DELAY_MS, MANAGED_DAEMON_RECOVERY_WAKING_TIMEOUT_MS, CONTROL_PLANE_CHECKPOINT_RECOVERY_MAX_ATTEMPTS, CONTROL_PLANE_CHECKPOINT_RECOVERY_POLL_MS, ManagedDaemonNotReadyError, isManagedDaemonNotReadyError, isManagedDaemonSleepingError, sleep2, isRetryableTransientConvexActionError, buildTransientConvexActionRetryMessage, announceTransientConvexActionRetry, retryTransientConvexAction, normalizeStringRecord, E2B_DEVBOX_ALIAS_EXISTS_CODE, isRecord3, maybeMapE2bProvisionControlPlaneError, mapE2bProvisionControlPlaneError, LOGIN_CODE_REJECTIONS, resolveControlPlaneUrl, resolveConvexUrl, escapeHtml2, CALLBACK_LOGO_MARK, CALLBACK_FULL_LOGO, renderCallbackPage, CONTROL_PLANE_REQUEST_UNAVAILABLE_CODE, ControlPlaneRequestUnavailableError, isControlPlaneRequestUnavailableError, requestJson, ControlPlaneRequestError, isControlPlaneAuthRejectionError, isControlPlaneSessionRefreshRejectionError, startCallbackServer, getControlPlaneUrl, getConvexUrl, createDefaultBrowserSignInDeps, signInWithBrowser, claudeTokenGet, claudeTokenSet, claudeTokenClear, agentAuthCredentialsList, fetchAgentCredentialRows, codexAuthCacheGet, codexAuthCacheSet, codexAuthCacheClear, claudeTokenReportRuntimeAuthFailureForViewer, claudeTokenReportRuntimeValidatedForViewer, e2bTokenResolvedGet, userSettingsGet, userSettingsSet, projectInstanceTypeOptionsGet, e2bDevboxRemove, e2bDevboxGet, e2bDevboxStatusesList, e2bDevboxDestroy, e2bDevboxProvision, e2bDevboxPause, e2bDevboxEnsureActive, e2bDevboxKeepAlive, e2bDevboxReset, e2bDevboxIssueBootstrapConnectInfo, e2bDevboxBootstrapDaemon, managedDevboxIssueDaemonConnectInfo, managedDaemonRecoverForInstance, managedDaemonControlGrantIssueForViewer, managedDevboxCreateCheckpoint, managedDevboxListRemoteStates, clientThreadsListForPrimaryInstance, threadTitleGenerationStatesListForPrimaryInstance, spriteDaemonSessionsList, clientThreadsUpsertRemoteInitCodexThread, clientThreadsDiscardRemoteInitCodexThread, projectInitJobsGetActiveForProject, agentInitProgressReportCliStep, instancesList, helloViewerGet, billingSummaryGet, convexBrowserModulePromise, loadConvexBrowserModule, buildConvexClientOptions, configureAuthenticatedConvexClient, createAuthenticatedConvexClient, withConvexClient, resolveInstanceIdForAlias, resolveManagedDaemonControlTargetWithClient, issueManagedDaemonControlGrantWithClient, resolveSpriteInstanceId, fetchClaudeTokenStatus, fetchResolvedE2bCredentials, fetchViewerIdentity, BILLING_ACTIVATION_STATES, readBillingActivationBoolean, parseBillingActivationDecision, parseBillingActivationSummary, fetchTeamBillingActivationForViewer, fetchActiveDesktopInitJobForProject, AGENT_INIT_STEP_REPORT_TIMEOUT_MS, reportAgentInitStep, fetchViewerCodingAgentPreference, fetchProjectInstanceTypeOptionsForViewer, storeViewerCodingAgentPreference, storeClaudeCodeOauthToken, clearClaudeCodeOauthToken, reportClaudeRuntimeAuthFailureForViewer, reportClaudeRuntimeValidatedForViewer, fetchCodexAuthCacheStatus, storeCodexAuthCache, clearCodexAuthCache, normalizeE2bDevboxRecord, fetchE2bDevboxLifecycle, listE2bDevboxStatuses, destroyE2bDevbox, provisionE2bDevbox, pauseE2bDevbox, ensureE2bDevboxActive, keepAliveE2bDevbox, resetE2bDevbox, bootstrapE2bDaemon, throwManagedDaemonNotReady, normalizeOptionalString2, normalizeAliasForLookup, validateManagedDaemonRecoveryResponse, normalizeManagedCheckpointResponse, buildRecoveredManagedCheckpointResponse, readManagedCheckpointRecoveryState, recoverManagedCheckpointAfterDisconnect, buildManagedDaemonConnectInfoResponseSummary, buildManagedDaemonConnectInfoUnexpectedMessage, buildManagedDaemonConnectInfoSleepingMessage, buildManagedDaemonConnectInfoWakingMessage, readWakingRetryAfterMs, logManagedDaemonConnectInfoResponse, fetchManagedDaemonConnectInfoWithAction, requestManagedDaemonConnectInfo, fetchManagedDaemonConnectInfo, recoverManagedDaemonForInit, recoverManagedDaemonControlTargetWithClient, fetchE2bBootstrapConnectInfo, createManagedCheckpoint, listManagedRemoteStates, listViewerInstances, listSpriteDaemonSessions, upsertRemoteInitCodexThread, discardRemoteInitCodexThread, signOutControlPlane, refreshControlPlaneSession, readLoginCodeRejection, exchangeLoginCode, createCliInitResponsesRelayTokenForViewer;
|
|
90157
|
+
var MANAGED_DAEMON_NOT_READY_CODE, CONVEX_INFLIGHT_ACTION_DISCONNECTED_MESSAGE, CONTROL_PLANE_ACTION_RETRY_MAX_ATTEMPTS, CONTROL_PLANE_ACTION_RETRY_BASE_DELAY_MS, MANAGED_DAEMON_RECOVERY_WAKING_TIMEOUT_MS, CONTROL_PLANE_CHECKPOINT_RECOVERY_MAX_ATTEMPTS, CONTROL_PLANE_CHECKPOINT_RECOVERY_POLL_MS, ManagedDaemonNotReadyError, isManagedDaemonNotReadyError, isManagedDaemonSleepingError, sleep2, isRetryableTransientConvexActionError, buildTransientConvexActionRetryMessage, announceTransientConvexActionRetry, retryTransientConvexAction, normalizeStringRecord, E2B_DEVBOX_ALIAS_EXISTS_CODE, isRecord3, maybeMapE2bProvisionControlPlaneError, mapE2bProvisionControlPlaneError, LOGIN_CODE_REJECTIONS, resolveControlPlaneUrl, resolveConvexUrl, escapeHtml2, CALLBACK_LOGO_MARK, CALLBACK_FULL_LOGO, renderCallbackPage, CONTROL_PLANE_REQUEST_UNAVAILABLE_CODE, ControlPlaneRequestUnavailableError, isControlPlaneRequestUnavailableError, requestJson, ControlPlaneRequestError, isControlPlaneAuthRejectionError, isControlPlaneSessionRefreshRejectionError, startCallbackServer, getControlPlaneUrl, getConvexUrl, createDefaultBrowserSignInDeps, signInWithBrowser, claudeTokenGet, claudeTokenSet, claudeLoginSave, claudeTokenClear, agentAuthCredentialsList, fetchAgentCredentialRows, codexAuthCacheGet, codexAuthCacheSet, codexAuthCacheClear, claudeTokenReportRuntimeAuthFailureForViewer, claudeTokenReportRuntimeValidatedForViewer, e2bTokenResolvedGet, userSettingsGet, userSettingsSet, projectInstanceTypeOptionsGet, e2bDevboxRemove, e2bDevboxGet, e2bDevboxStatusesList, e2bDevboxDestroy, e2bDevboxProvision, e2bDevboxPause, e2bDevboxEnsureActive, e2bDevboxKeepAlive, e2bDevboxReset, e2bDevboxIssueBootstrapConnectInfo, e2bDevboxBootstrapDaemon, managedDevboxIssueDaemonConnectInfo, managedDaemonRecoverForInstance, managedDaemonControlGrantIssueForViewer, managedDevboxCreateCheckpoint, managedDevboxListRemoteStates, clientThreadsListForPrimaryInstance, threadTitleGenerationStatesListForPrimaryInstance, spriteDaemonSessionsList, clientThreadsUpsertRemoteInitCodexThread, clientThreadsDiscardRemoteInitCodexThread, projectInitJobsGetActiveForProject, agentInitProgressReportCliStep, instancesList, helloViewerGet, billingSummaryGet, convexBrowserModulePromise, loadConvexBrowserModule, buildConvexClientOptions, configureAuthenticatedConvexClient, createAuthenticatedConvexClient, withConvexClient, resolveInstanceIdForAlias, resolveManagedDaemonControlTargetWithClient, issueManagedDaemonControlGrantWithClient, resolveSpriteInstanceId, fetchClaudeTokenStatus, fetchResolvedE2bCredentials, VIEWER_LOOKUP_TIMEOUT_MS, fetchViewerIdentity, BILLING_ACTIVATION_STATES, readBillingActivationBoolean, parseBillingActivationDecision, parseBillingActivationSummary, fetchTeamBillingActivationForViewer, fetchActiveDesktopInitJobForProject, AGENT_INIT_STEP_REPORT_TIMEOUT_MS, reportAgentInitStep, fetchViewerCodingAgentPreference, fetchProjectInstanceTypeOptionsForViewer, storeViewerCodingAgentPreference, storeClaudeCodeOauthToken, storeClaudeLogin, clearClaudeCodeOauthToken, reportClaudeRuntimeAuthFailureForViewer, reportClaudeRuntimeValidatedForViewer, fetchCodexAuthCacheStatus, storeCodexAuthCache, clearCodexAuthCache, normalizeE2bDevboxRecord, fetchE2bDevboxLifecycle, listE2bDevboxStatuses, destroyE2bDevbox, provisionE2bDevbox, pauseE2bDevbox, ensureE2bDevboxActive, keepAliveE2bDevbox, resetE2bDevbox, bootstrapE2bDaemon, throwManagedDaemonNotReady, normalizeOptionalString2, normalizeAliasForLookup, validateManagedDaemonRecoveryResponse, normalizeManagedCheckpointResponse, buildRecoveredManagedCheckpointResponse, readManagedCheckpointRecoveryState, recoverManagedCheckpointAfterDisconnect, buildManagedDaemonConnectInfoResponseSummary, buildManagedDaemonConnectInfoUnexpectedMessage, buildManagedDaemonConnectInfoSleepingMessage, buildManagedDaemonConnectInfoWakingMessage, readWakingRetryAfterMs, logManagedDaemonConnectInfoResponse, fetchManagedDaemonConnectInfoWithAction, requestManagedDaemonConnectInfo, fetchManagedDaemonConnectInfo, recoverManagedDaemonForInit, recoverManagedDaemonControlTargetWithClient, fetchE2bBootstrapConnectInfo, createManagedCheckpoint, listManagedRemoteStates, listViewerInstances, listSpriteDaemonSessions, upsertRemoteInitCodexThread, discardRemoteInitCodexThread, signOutControlPlane, REFRESH_SESSION_TIMEOUT_MS, refreshControlPlaneSession, readLoginCodeRejection, exchangeLoginCode, createCliInitResponsesRelayTokenForViewer;
|
|
90112
90158
|
var init_controlPlane = __esm({
|
|
90113
90159
|
"src/devbox/controlPlane.ts"() {
|
|
90114
90160
|
"use strict";
|
|
@@ -90116,6 +90162,7 @@ var init_controlPlane = __esm({
|
|
|
90116
90162
|
init_devboxCore();
|
|
90117
90163
|
init_server();
|
|
90118
90164
|
init_wrapper2();
|
|
90165
|
+
init_authErrors();
|
|
90119
90166
|
init_browser();
|
|
90120
90167
|
init_logger3();
|
|
90121
90168
|
init_copyableUrl();
|
|
@@ -90434,7 +90481,7 @@ var init_controlPlane = __esm({
|
|
|
90434
90481
|
}
|
|
90435
90482
|
};
|
|
90436
90483
|
isControlPlaneRequestUnavailableError = (error55) => error55 instanceof ControlPlaneRequestUnavailableError || !!error55 && typeof error55 === "object" && error55.code === CONTROL_PLANE_REQUEST_UNAVAILABLE_CODE;
|
|
90437
|
-
requestJson = async (baseUrl, method, path104, body, token) => {
|
|
90484
|
+
requestJson = async (baseUrl, method, path104, body, token, signal) => {
|
|
90438
90485
|
const requestId2 = randomUUID5();
|
|
90439
90486
|
const url3 = new URL(path104, baseUrl);
|
|
90440
90487
|
const headers = {
|
|
@@ -90456,10 +90503,10 @@ var init_controlPlane = __esm({
|
|
|
90456
90503
|
if (body) {
|
|
90457
90504
|
init3.body = JSON.stringify(body);
|
|
90458
90505
|
}
|
|
90459
|
-
|
|
90460
|
-
|
|
90461
|
-
|
|
90462
|
-
|
|
90506
|
+
if (signal) {
|
|
90507
|
+
init3.signal = signal;
|
|
90508
|
+
}
|
|
90509
|
+
const unavailable = (error55) => {
|
|
90463
90510
|
logger2.warn("control_plane_request_failed", {
|
|
90464
90511
|
requestId: requestId2,
|
|
90465
90512
|
method,
|
|
@@ -90467,12 +90514,18 @@ var init_controlPlane = __esm({
|
|
|
90467
90514
|
status: "unavailable",
|
|
90468
90515
|
error: error55 instanceof Error ? error55.message : String(error55)
|
|
90469
90516
|
});
|
|
90470
|
-
|
|
90517
|
+
return new ControlPlaneRequestUnavailableError({
|
|
90471
90518
|
requestId: requestId2,
|
|
90472
90519
|
method,
|
|
90473
90520
|
path: url3.pathname,
|
|
90474
90521
|
cause: error55
|
|
90475
90522
|
});
|
|
90523
|
+
};
|
|
90524
|
+
let response;
|
|
90525
|
+
try {
|
|
90526
|
+
response = await fetch(url3, init3);
|
|
90527
|
+
} catch (error55) {
|
|
90528
|
+
throw unavailable(error55);
|
|
90476
90529
|
}
|
|
90477
90530
|
logger2.info("control_plane_response", {
|
|
90478
90531
|
requestId: requestId2,
|
|
@@ -90480,18 +90533,22 @@ var init_controlPlane = __esm({
|
|
|
90480
90533
|
path: url3.pathname,
|
|
90481
90534
|
status: response.status
|
|
90482
90535
|
});
|
|
90536
|
+
let text;
|
|
90537
|
+
try {
|
|
90538
|
+
text = await response.text();
|
|
90539
|
+
} catch (error55) {
|
|
90540
|
+
throw unavailable(error55);
|
|
90541
|
+
}
|
|
90483
90542
|
if (!response.ok) {
|
|
90484
|
-
const
|
|
90485
|
-
const upgradeRequired = parseUpgradeRequiredResponseBody(message, {
|
|
90543
|
+
const upgradeRequired = parseUpgradeRequiredResponseBody(text, {
|
|
90486
90544
|
source: "control_plane",
|
|
90487
90545
|
statusCode: response.status
|
|
90488
90546
|
});
|
|
90489
90547
|
if (upgradeRequired) {
|
|
90490
90548
|
throw upgradeRequired;
|
|
90491
90549
|
}
|
|
90492
|
-
throw new ControlPlaneRequestError(response.status,
|
|
90550
|
+
throw new ControlPlaneRequestError(response.status, text);
|
|
90493
90551
|
}
|
|
90494
|
-
const text = await response.text();
|
|
90495
90552
|
if (!text) return {};
|
|
90496
90553
|
return JSON.parse(text);
|
|
90497
90554
|
};
|
|
@@ -90691,6 +90748,7 @@ var init_controlPlane = __esm({
|
|
|
90691
90748
|
};
|
|
90692
90749
|
claudeTokenGet = makeFunctionReference("claudeTokens:getForViewer");
|
|
90693
90750
|
claudeTokenSet = makeFunctionReference("claudeTokens:setForViewer");
|
|
90751
|
+
claudeLoginSave = makeFunctionReference("claudeLoginSignIn:saveForViewer");
|
|
90694
90752
|
claudeTokenClear = makeFunctionReference("claudeTokens:clearForViewer");
|
|
90695
90753
|
agentAuthCredentialsList = makeFunctionReference("agentAuthCredentials:listForViewer");
|
|
90696
90754
|
fetchAgentCredentialRows = async (token) => await withConvexClient(token, async (client) => {
|
|
@@ -90831,6 +90889,7 @@ var init_controlPlane = __esm({
|
|
|
90831
90889
|
const response = await client.query(claudeTokenGet, {});
|
|
90832
90890
|
return {
|
|
90833
90891
|
authMode: response?.authMode === "api_key" || response?.authMode === "oauth" ? response.authMode : null,
|
|
90892
|
+
oauthKind: response?.oauthKind === "login" || response?.oauthKind === "setup_token" ? response.oauthKind : null,
|
|
90834
90893
|
hasToken: response?.hasToken === true,
|
|
90835
90894
|
expiresAt: typeof response?.expiresAt === "number" ? response.expiresAt : null,
|
|
90836
90895
|
updatedAt: typeof response?.updatedAt === "number" ? response.updatedAt : null,
|
|
@@ -90848,9 +90907,29 @@ var init_controlPlane = __esm({
|
|
|
90848
90907
|
return { apiKey, source };
|
|
90849
90908
|
});
|
|
90850
90909
|
};
|
|
90910
|
+
VIEWER_LOOKUP_TIMEOUT_MS = 15e3;
|
|
90851
90911
|
fetchViewerIdentity = async (token) => {
|
|
90852
90912
|
return await withConvexClient(token, async (client) => {
|
|
90853
|
-
|
|
90913
|
+
let timeout;
|
|
90914
|
+
const timedOut = new Promise((_resolve, reject) => {
|
|
90915
|
+
timeout = setTimeout(() => {
|
|
90916
|
+
logger2.warn("control_plane_viewer_lookup_timed_out", {
|
|
90917
|
+
timeoutMs: VIEWER_LOOKUP_TIMEOUT_MS
|
|
90918
|
+
});
|
|
90919
|
+
reject(
|
|
90920
|
+
new ControlPlaneAuthUnavailableError({
|
|
90921
|
+
cause: new Error(
|
|
90922
|
+
`hello:getViewer did not answer within ${VIEWER_LOOKUP_TIMEOUT_MS} ms.`
|
|
90923
|
+
)
|
|
90924
|
+
})
|
|
90925
|
+
);
|
|
90926
|
+
}, VIEWER_LOOKUP_TIMEOUT_MS);
|
|
90927
|
+
});
|
|
90928
|
+
try {
|
|
90929
|
+
return await Promise.race([client.query(helloViewerGet, {}), timedOut]);
|
|
90930
|
+
} finally {
|
|
90931
|
+
clearTimeout(timeout);
|
|
90932
|
+
}
|
|
90854
90933
|
});
|
|
90855
90934
|
};
|
|
90856
90935
|
BILLING_ACTIVATION_STATES = /* @__PURE__ */ new Set([
|
|
@@ -91020,6 +91099,17 @@ var init_controlPlane = __esm({
|
|
|
91020
91099
|
};
|
|
91021
91100
|
});
|
|
91022
91101
|
};
|
|
91102
|
+
storeClaudeLogin = async (token, tokenResponse, exchangeIdentity) => await withConvexClient(token, async (client) => {
|
|
91103
|
+
const response = await client.action(claudeLoginSave, {
|
|
91104
|
+
tokenResponse,
|
|
91105
|
+
exchangeIdentity,
|
|
91106
|
+
intent: "add"
|
|
91107
|
+
});
|
|
91108
|
+
return {
|
|
91109
|
+
expiresAt: response.expiresAt ?? 0,
|
|
91110
|
+
updatedAt: response.updatedAt
|
|
91111
|
+
};
|
|
91112
|
+
});
|
|
91023
91113
|
clearClaudeCodeOauthToken = async (token) => {
|
|
91024
91114
|
await withConvexClient(token, async (client) => {
|
|
91025
91115
|
await client.mutation(claudeTokenClear, {});
|
|
@@ -91866,6 +91956,7 @@ var init_controlPlane = __esm({
|
|
|
91866
91956
|
}
|
|
91867
91957
|
await requestJson(baseUrl, "POST", "/auth/signout", void 0, token);
|
|
91868
91958
|
};
|
|
91959
|
+
REFRESH_SESSION_TIMEOUT_MS = 15e3;
|
|
91869
91960
|
refreshControlPlaneSession = async (refreshToken) => {
|
|
91870
91961
|
const baseUrl = resolveControlPlaneUrl();
|
|
91871
91962
|
if (!baseUrl) {
|
|
@@ -91877,7 +91968,9 @@ var init_controlPlane = __esm({
|
|
|
91877
91968
|
baseUrl,
|
|
91878
91969
|
"POST",
|
|
91879
91970
|
"/auth/refresh",
|
|
91880
|
-
{ refresh_token: refreshToken }
|
|
91971
|
+
{ refresh_token: refreshToken },
|
|
91972
|
+
void 0,
|
|
91973
|
+
AbortSignal.timeout(REFRESH_SESSION_TIMEOUT_MS)
|
|
91881
91974
|
);
|
|
91882
91975
|
if (!response.token) {
|
|
91883
91976
|
throw new Error("Could not refresh boxes.dev login.");
|
|
@@ -95629,11 +95722,12 @@ var init_src = __esm({
|
|
|
95629
95722
|
});
|
|
95630
95723
|
|
|
95631
95724
|
// src/devbox/auth.ts
|
|
95632
|
-
var CONTROL_PLANE_INTERACTIVE_SIGNIN_STAGE, CONTROL_PLANE_AUTH_REFRESH_ERROR_CODE, ControlPlaneAuthRefreshError, isControlPlaneAuthRefreshError, TOKEN_REFRESH_BUFFER_MS2, CONTROL_PLANE_AUTH_REFRESH_RETRY_DELAYS_MS, defaultControlPlaneAuthApi, waitForControlPlaneAuthRefreshRetry, createRetryingControlPlaneTokenProvider, decodeJwtPayload4, parseTokenExpiresAt2, isTokenExpired, shouldRefreshToken2, clearControlPlaneAccessToken2, clearControlPlaneSession, updateControlPlaneSession, refreshControlPlaneToken, refreshLongLivedControlPlaneToken, createLongLivedControlPlaneTokenProvider,
|
|
95725
|
+
var CONTROL_PLANE_INTERACTIVE_SIGNIN_STAGE, CONTROL_PLANE_AUTH_REFRESH_ERROR_CODE, ControlPlaneAuthRefreshError, isControlPlaneAuthRefreshError, TOKEN_REFRESH_BUFFER_MS2, CONTROL_PLANE_AUTH_REFRESH_RETRY_DELAYS_MS, defaultControlPlaneAuthApi, waitForControlPlaneAuthRefreshRetry, createRetryingControlPlaneTokenProvider, decodeJwtPayload4, parseTokenExpiresAt2, isTokenExpired, shouldRefreshToken2, clearControlPlaneAccessToken2, clearControlPlaneSession, updateControlPlaneSession, refreshControlPlaneToken, refreshLongLivedControlPlaneToken, createLongLivedControlPlaneTokenProvider, lookupControlPlaneViewer, refreshStoredControlPlaneToken, resolveStoredControlPlaneSession, resolveStoredControlPlaneToken, ensureControlPlaneSession, ensureControlPlaneToken, readUnexpiredControlPlaneToken, ensureExistingControlPlaneToken;
|
|
95633
95726
|
var init_auth = __esm({
|
|
95634
95727
|
"src/devbox/auth.ts"() {
|
|
95635
95728
|
"use strict";
|
|
95636
95729
|
init_devboxCore();
|
|
95730
|
+
init_authErrors();
|
|
95637
95731
|
init_logger3();
|
|
95638
95732
|
init_controlPlane();
|
|
95639
95733
|
CONTROL_PLANE_INTERACTIVE_SIGNIN_STAGE = "Opening browser to sign in";
|
|
@@ -95811,30 +95905,37 @@ var init_auth = __esm({
|
|
|
95811
95905
|
wait: waitForControlPlaneAuthRefreshRetry,
|
|
95812
95906
|
retryDelaysMs: CONTROL_PLANE_AUTH_REFRESH_RETRY_DELAYS_MS
|
|
95813
95907
|
});
|
|
95814
|
-
|
|
95908
|
+
lookupControlPlaneViewer = async (token, authApi, stage) => {
|
|
95815
95909
|
stage?.("Checking boxes.dev login");
|
|
95816
|
-
|
|
95817
|
-
|
|
95818
|
-
if (viewer) {
|
|
95819
|
-
syncDevboxSentryUserFromViewerIdentity(viewer);
|
|
95820
|
-
return { status: "valid" };
|
|
95821
|
-
}
|
|
95910
|
+
const viewer = await authApi.fetchViewerIdentity(token);
|
|
95911
|
+
if (!viewer) {
|
|
95822
95912
|
logger2.warn("control_plane_viewer_missing");
|
|
95913
|
+
return null;
|
|
95914
|
+
}
|
|
95915
|
+
syncDevboxSentryUserFromViewerIdentity(viewer);
|
|
95916
|
+
return viewer;
|
|
95917
|
+
};
|
|
95918
|
+
refreshStoredControlPlaneToken = async (store, authApi, stage) => {
|
|
95919
|
+
try {
|
|
95920
|
+
return await refreshControlPlaneToken(store, authApi, stage);
|
|
95823
95921
|
} catch (error55) {
|
|
95824
|
-
if (
|
|
95825
|
-
logger2.warn("
|
|
95922
|
+
if (isControlPlaneSessionRefreshRejectionError(error55)) {
|
|
95923
|
+
logger2.warn("control_plane_refresh_rejected", { error: String(error55) });
|
|
95924
|
+
await clearControlPlaneSession(store);
|
|
95925
|
+
throw new ControlPlaneLoginRequiredError("session_invalid", {
|
|
95926
|
+
cause: error55
|
|
95927
|
+
});
|
|
95928
|
+
}
|
|
95929
|
+
if (isControlPlaneRequestUnavailableError(error55) || error55 instanceof ControlPlaneRequestError && (error55.statusCode === 429 || error55.statusCode >= 500)) {
|
|
95930
|
+
logger2.warn("control_plane_refresh_unavailable", {
|
|
95826
95931
|
error: String(error55)
|
|
95827
95932
|
});
|
|
95828
|
-
|
|
95933
|
+
throw new ControlPlaneAuthUnavailableError({ cause: error55 });
|
|
95829
95934
|
}
|
|
95830
|
-
|
|
95831
|
-
error: String(error55)
|
|
95832
|
-
});
|
|
95935
|
+
throw error55;
|
|
95833
95936
|
}
|
|
95834
|
-
await clearControlPlaneAccessToken2(store);
|
|
95835
|
-
return { status: "rejected" };
|
|
95836
95937
|
};
|
|
95837
|
-
|
|
95938
|
+
resolveStoredControlPlaneSession = async (store, stage, authApi = defaultControlPlaneAuthApi) => {
|
|
95838
95939
|
const controlPlaneUrl = getControlPlaneUrl();
|
|
95839
95940
|
const convexUrl = getConvexUrl();
|
|
95840
95941
|
if (!controlPlaneUrl) {
|
|
@@ -95847,89 +95948,79 @@ var init_auth = __esm({
|
|
|
95847
95948
|
"This dvb build is missing its backend URL. Reinstall dvb, then retry."
|
|
95848
95949
|
);
|
|
95849
95950
|
}
|
|
95850
|
-
let
|
|
95851
|
-
|
|
95852
|
-
const
|
|
95853
|
-
|
|
95854
|
-
const refreshed2 = await refreshControlPlaneToken(store, authApi, stage);
|
|
95855
|
-
if (refreshed2) {
|
|
95856
|
-
const validation = await validateControlPlaneToken(
|
|
95857
|
-
store,
|
|
95858
|
-
refreshed2,
|
|
95859
|
-
authApi,
|
|
95860
|
-
stage
|
|
95861
|
-
);
|
|
95862
|
-
if (validation.status === "valid") {
|
|
95863
|
-
return refreshed2;
|
|
95864
|
-
}
|
|
95865
|
-
if (validation.status === "unavailable") {
|
|
95866
|
-
throw validation.error;
|
|
95867
|
-
}
|
|
95868
|
-
}
|
|
95869
|
-
} catch (error55) {
|
|
95870
|
-
logger2.warn("control_plane_refresh_failed", { error: String(error55) });
|
|
95871
|
-
}
|
|
95872
|
-
return null;
|
|
95873
|
-
};
|
|
95874
|
-
if (existing && isTokenExpired(existing)) {
|
|
95951
|
+
let token = await store.getControlPlaneToken();
|
|
95952
|
+
const expiresAt = await store.getControlPlaneTokenExpiresAt();
|
|
95953
|
+
const hadStoredLogin = token !== null || await store.getControlPlaneRefreshToken() !== null;
|
|
95954
|
+
if (token && isTokenExpired(token)) {
|
|
95875
95955
|
await clearControlPlaneAccessToken2(store);
|
|
95876
|
-
|
|
95877
|
-
expiresAt = null;
|
|
95956
|
+
token = null;
|
|
95878
95957
|
}
|
|
95879
|
-
if (
|
|
95880
|
-
const
|
|
95881
|
-
|
|
95882
|
-
|
|
95883
|
-
authApi,
|
|
95884
|
-
stage
|
|
95885
|
-
);
|
|
95886
|
-
if (validation.status === "valid") {
|
|
95887
|
-
return existing;
|
|
95888
|
-
}
|
|
95889
|
-
if (validation.status === "unavailable") {
|
|
95890
|
-
throw validation.error;
|
|
95958
|
+
if (token && !shouldRefreshToken2(expiresAt)) {
|
|
95959
|
+
const viewer = await lookupControlPlaneViewer(token, authApi, stage);
|
|
95960
|
+
if (viewer) {
|
|
95961
|
+
return { token, viewer };
|
|
95891
95962
|
}
|
|
95892
|
-
|
|
95963
|
+
await clearControlPlaneAccessToken2(store);
|
|
95964
|
+
token = null;
|
|
95893
95965
|
}
|
|
95894
|
-
|
|
95895
|
-
|
|
95896
|
-
|
|
95897
|
-
|
|
95898
|
-
|
|
95899
|
-
|
|
95900
|
-
store,
|
|
95901
|
-
existing,
|
|
95902
|
-
authApi,
|
|
95903
|
-
stage
|
|
95904
|
-
);
|
|
95905
|
-
if (validation.status === "valid") {
|
|
95906
|
-
return existing;
|
|
95966
|
+
let refreshed;
|
|
95967
|
+
try {
|
|
95968
|
+
refreshed = await refreshStoredControlPlaneToken(store, authApi, stage);
|
|
95969
|
+
} catch (error55) {
|
|
95970
|
+
if (!token || !(error55 instanceof ControlPlaneAuthUnavailableError)) {
|
|
95971
|
+
throw error55;
|
|
95907
95972
|
}
|
|
95908
|
-
|
|
95909
|
-
|
|
95973
|
+
const viewer = await lookupControlPlaneViewer(token, authApi, stage);
|
|
95974
|
+
if (viewer) {
|
|
95975
|
+
return { token, viewer };
|
|
95910
95976
|
}
|
|
95911
|
-
|
|
95977
|
+
throw error55;
|
|
95912
95978
|
}
|
|
95913
|
-
const
|
|
95914
|
-
if (
|
|
95915
|
-
|
|
95979
|
+
const candidate = refreshed ?? token;
|
|
95980
|
+
if (candidate) {
|
|
95981
|
+
const viewer = await lookupControlPlaneViewer(candidate, authApi, stage);
|
|
95982
|
+
if (viewer) {
|
|
95983
|
+
return { token: candidate, viewer };
|
|
95984
|
+
}
|
|
95916
95985
|
}
|
|
95917
95986
|
await clearControlPlaneSession(store);
|
|
95918
|
-
|
|
95987
|
+
throw new ControlPlaneLoginRequiredError(
|
|
95988
|
+
hadStoredLogin ? "session_invalid" : "signed_out"
|
|
95989
|
+
);
|
|
95919
95990
|
};
|
|
95920
|
-
|
|
95921
|
-
|
|
95922
|
-
|
|
95923
|
-
|
|
95991
|
+
resolveStoredControlPlaneToken = async (store, stage, authApi = defaultControlPlaneAuthApi) => {
|
|
95992
|
+
try {
|
|
95993
|
+
return (await resolveStoredControlPlaneSession(store, stage, authApi)).token;
|
|
95994
|
+
} catch (error55) {
|
|
95995
|
+
if (error55 instanceof ControlPlaneLoginRequiredError) {
|
|
95996
|
+
return null;
|
|
95997
|
+
}
|
|
95998
|
+
throw error55;
|
|
95924
95999
|
}
|
|
95925
|
-
|
|
95926
|
-
|
|
96000
|
+
};
|
|
96001
|
+
ensureControlPlaneSession = async (store, stage, authApi = defaultControlPlaneAuthApi) => {
|
|
96002
|
+
try {
|
|
96003
|
+
return await resolveStoredControlPlaneSession(store, stage, authApi);
|
|
96004
|
+
} catch (error55) {
|
|
96005
|
+
if (!(error55 instanceof ControlPlaneLoginRequiredError) || !process.stdin.isTTY) {
|
|
96006
|
+
throw error55;
|
|
96007
|
+
}
|
|
95927
96008
|
}
|
|
95928
96009
|
stage?.(CONTROL_PLANE_INTERACTIVE_SIGNIN_STAGE);
|
|
95929
96010
|
const tokens = await authApi.signInWithBrowser();
|
|
95930
96011
|
await updateControlPlaneSession(store, tokens.token, tokens.refreshToken);
|
|
95931
96012
|
logger2.info("control_plane_signed_in");
|
|
95932
|
-
return
|
|
96013
|
+
return await resolveStoredControlPlaneSession(store, stage, authApi);
|
|
96014
|
+
};
|
|
96015
|
+
ensureControlPlaneToken = async (store, stage, authApi = defaultControlPlaneAuthApi) => {
|
|
96016
|
+
try {
|
|
96017
|
+
return (await ensureControlPlaneSession(store, stage, authApi)).token;
|
|
96018
|
+
} catch (error55) {
|
|
96019
|
+
if (error55 instanceof ControlPlaneLoginRequiredError) {
|
|
96020
|
+
return null;
|
|
96021
|
+
}
|
|
96022
|
+
throw error55;
|
|
96023
|
+
}
|
|
95933
96024
|
};
|
|
95934
96025
|
readUnexpiredControlPlaneToken = async (store) => {
|
|
95935
96026
|
const token = await store.getControlPlaneToken();
|
|
@@ -97022,45 +97113,46 @@ var init_version2 = __esm({
|
|
|
97022
97113
|
// src/devbox/accountScope.ts
|
|
97023
97114
|
import fs16 from "node:fs/promises";
|
|
97024
97115
|
import path22 from "node:path";
|
|
97025
|
-
var
|
|
97116
|
+
var buildCliAccountScope, resolveCliAccountScope, readCliActiveConvexTarget, findNearestActiveConvexTargetRoot, readCliActiveConvexTargetFromCwd, resolveCliAccountScopeFromLocalAuth, tryResolveCliAccountScopeFromLocalAuth;
|
|
97026
97117
|
var init_accountScope2 = __esm({
|
|
97027
97118
|
"src/devbox/accountScope.ts"() {
|
|
97028
97119
|
"use strict";
|
|
97029
97120
|
init_devboxCore();
|
|
97030
97121
|
init_auth();
|
|
97122
|
+
init_authErrors();
|
|
97031
97123
|
init_controlPlane();
|
|
97032
|
-
|
|
97033
|
-
const userId = viewer?.userId.trim() ?? "";
|
|
97034
|
-
if (!userId) {
|
|
97035
|
-
throw new Error(
|
|
97036
|
-
"Could not resolve the signed-in boxes.dev account. Log in again with `dvb setup`, then retry."
|
|
97037
|
-
);
|
|
97038
|
-
}
|
|
97039
|
-
return userId;
|
|
97040
|
-
};
|
|
97041
|
-
resolveCliAccountScope = async ({
|
|
97124
|
+
buildCliAccountScope = async ({
|
|
97042
97125
|
activeConvexTarget = null,
|
|
97043
|
-
|
|
97044
|
-
|
|
97045
|
-
homeDir: homeDir2
|
|
97126
|
+
homeDir: homeDir2,
|
|
97127
|
+
viewer
|
|
97046
97128
|
}) => {
|
|
97047
|
-
const viewer = await fetchViewerIdentityFn(controlPlaneToken);
|
|
97048
|
-
const userId = normalizeViewerUserId2(viewer);
|
|
97049
97129
|
const accountScope = createDevboxAccountScope({
|
|
97050
|
-
viewerUserId: userId,
|
|
97051
|
-
email: viewer
|
|
97130
|
+
viewerUserId: viewer.userId,
|
|
97131
|
+
email: viewer.email ?? null,
|
|
97052
97132
|
activeConvexTarget
|
|
97053
97133
|
});
|
|
97054
97134
|
await writeDevboxAccountMetadata({ accountScope, homeDir: homeDir2 });
|
|
97055
97135
|
return {
|
|
97056
97136
|
accountScope,
|
|
97057
97137
|
viewer: {
|
|
97058
|
-
userId,
|
|
97059
|
-
email: viewer
|
|
97060
|
-
isAdmin: viewer
|
|
97138
|
+
userId: viewer.userId,
|
|
97139
|
+
email: viewer.email ?? null,
|
|
97140
|
+
isAdmin: viewer.isAdmin === true
|
|
97061
97141
|
}
|
|
97062
97142
|
};
|
|
97063
97143
|
};
|
|
97144
|
+
resolveCliAccountScope = async ({
|
|
97145
|
+
activeConvexTarget = null,
|
|
97146
|
+
controlPlaneToken,
|
|
97147
|
+
fetchViewerIdentityFn = fetchViewerIdentity,
|
|
97148
|
+
homeDir: homeDir2
|
|
97149
|
+
}) => {
|
|
97150
|
+
const viewer = await fetchViewerIdentityFn(controlPlaneToken);
|
|
97151
|
+
if (!viewer) {
|
|
97152
|
+
throw new ControlPlaneLoginRequiredError("session_invalid");
|
|
97153
|
+
}
|
|
97154
|
+
return await buildCliAccountScope({ activeConvexTarget, homeDir: homeDir2, viewer });
|
|
97155
|
+
};
|
|
97064
97156
|
readCliActiveConvexTarget = async ({
|
|
97065
97157
|
repoRoot
|
|
97066
97158
|
}) => await readDevboxAccountActiveConvexTarget({ repoRoot }) ?? await readDevboxAccountActiveConvexTargetFromEnv();
|
|
@@ -97097,16 +97189,11 @@ var init_accountScope2 = __esm({
|
|
|
97097
97189
|
config5?.tokenStore,
|
|
97098
97190
|
homeDir2 ? { homeDir: homeDir2 } : void 0
|
|
97099
97191
|
);
|
|
97100
|
-
const
|
|
97101
|
-
|
|
97102
|
-
throw new Error(
|
|
97103
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
97104
|
-
);
|
|
97105
|
-
}
|
|
97106
|
-
return await resolveCliAccountScope({
|
|
97192
|
+
const { viewer } = await ensureControlPlaneSession(store, onAuthStage);
|
|
97193
|
+
return await buildCliAccountScope({
|
|
97107
97194
|
activeConvexTarget: resolvedActiveConvexTarget,
|
|
97108
|
-
|
|
97109
|
-
|
|
97195
|
+
homeDir: homeDir2,
|
|
97196
|
+
viewer
|
|
97110
97197
|
});
|
|
97111
97198
|
};
|
|
97112
97199
|
tryResolveCliAccountScopeFromLocalAuth = async (options = {}) => {
|
|
@@ -137049,6 +137136,7 @@ var init_e2bCommandContext = __esm({
|
|
|
137049
137136
|
"use strict";
|
|
137050
137137
|
init_devboxCore();
|
|
137051
137138
|
init_auth();
|
|
137139
|
+
init_authErrors();
|
|
137052
137140
|
resolveE2bCommandContext = async (options = {}) => {
|
|
137053
137141
|
const config5 = await loadConfig(
|
|
137054
137142
|
process.env.HOME ? { homeDir: process.env.HOME } : void 0
|
|
@@ -137060,9 +137148,9 @@ var init_e2bCommandContext = __esm({
|
|
|
137060
137148
|
const controlPlaneToken = await ensureControlPlaneToken(store, options.stage);
|
|
137061
137149
|
const trimmedControlPlaneToken = controlPlaneToken?.trim() ?? "";
|
|
137062
137150
|
if (!trimmedControlPlaneToken) {
|
|
137063
|
-
throw new
|
|
137064
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev before managing this machine."
|
|
137065
|
-
);
|
|
137151
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
137152
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev before managing this machine."
|
|
137153
|
+
});
|
|
137066
137154
|
}
|
|
137067
137155
|
return {
|
|
137068
137156
|
controlPlaneToken: trimmedControlPlaneToken
|
|
@@ -140279,6 +140367,7 @@ var init_destroy = __esm({
|
|
|
140279
140367
|
init_devboxCore();
|
|
140280
140368
|
init_daemonClient();
|
|
140281
140369
|
init_auth();
|
|
140370
|
+
init_authErrors();
|
|
140282
140371
|
init_controlPlane();
|
|
140283
140372
|
init_logger3();
|
|
140284
140373
|
init_statusLine();
|
|
@@ -140420,9 +140509,9 @@ var init_destroy = __esm({
|
|
|
140420
140509
|
(message) => status.stage(message)
|
|
140421
140510
|
);
|
|
140422
140511
|
if (!controlPlaneToken) {
|
|
140423
|
-
throw new
|
|
140424
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev before destroying this machine."
|
|
140425
|
-
);
|
|
140512
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
140513
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev before destroying this machine."
|
|
140514
|
+
});
|
|
140426
140515
|
}
|
|
140427
140516
|
const managedDestroyResult = await destroyE2bDevbox2({
|
|
140428
140517
|
alias,
|
|
@@ -142554,96 +142643,6 @@ var init_threadInventory = __esm({
|
|
|
142554
142643
|
}
|
|
142555
142644
|
});
|
|
142556
142645
|
|
|
142557
|
-
// src/devbox/resourceApi/errors.ts
|
|
142558
|
-
var CLI_AGENT_TOOL_FAILURE_CODES, readConvexApplicationError, CliAgentToolError, normalizeCliAgentToolError;
|
|
142559
|
-
var init_errors5 = __esm({
|
|
142560
|
-
"src/devbox/resourceApi/errors.ts"() {
|
|
142561
|
-
"use strict";
|
|
142562
|
-
init_values();
|
|
142563
|
-
CLI_AGENT_TOOL_FAILURE_CODES = /* @__PURE__ */ new Set([
|
|
142564
|
-
"not_authenticated",
|
|
142565
|
-
"project_not_found",
|
|
142566
|
-
"ambiguous_project",
|
|
142567
|
-
"devbox_not_found",
|
|
142568
|
-
"devbox_has_threads",
|
|
142569
|
-
"thread_not_found",
|
|
142570
|
-
"contract_version_unsupported",
|
|
142571
|
-
"invalid_request",
|
|
142572
|
-
"operation_in_progress",
|
|
142573
|
-
"idempotency_key_reused",
|
|
142574
|
-
"daemon_unavailable",
|
|
142575
|
-
"unsupported_capability",
|
|
142576
|
-
"operation_canceled",
|
|
142577
|
-
"billing_blocked",
|
|
142578
|
-
"capacity_blocked",
|
|
142579
|
-
"thread_busy",
|
|
142580
|
-
"thread_controlled_elsewhere",
|
|
142581
|
-
"turn_not_active",
|
|
142582
|
-
"turn_changed",
|
|
142583
|
-
"not_found",
|
|
142584
|
-
"name_conflict",
|
|
142585
|
-
"project_url_limit_reached",
|
|
142586
|
-
"configuration_conflict",
|
|
142587
|
-
"invalid_configuration",
|
|
142588
|
-
"template_maintenance_unavailable",
|
|
142589
|
-
"watch_removal_confirmation_required",
|
|
142590
|
-
"github_connection_required",
|
|
142591
|
-
"github_repository_access_required",
|
|
142592
|
-
"service_update_required",
|
|
142593
|
-
"invalid_delivery_policy",
|
|
142594
|
-
"port_not_eligible",
|
|
142595
|
-
"infrastructure_unavailable",
|
|
142596
|
-
"command_failed",
|
|
142597
|
-
"internal_error"
|
|
142598
|
-
]);
|
|
142599
|
-
readConvexApplicationError = (error55) => {
|
|
142600
|
-
if (!(error55 instanceof ConvexError)) return null;
|
|
142601
|
-
const data = error55.data;
|
|
142602
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) return null;
|
|
142603
|
-
const record3 = data;
|
|
142604
|
-
if (typeof record3.code !== "string" || !CLI_AGENT_TOOL_FAILURE_CODES.has(
|
|
142605
|
-
record3.code
|
|
142606
|
-
) || typeof record3.message !== "string") {
|
|
142607
|
-
return null;
|
|
142608
|
-
}
|
|
142609
|
-
return {
|
|
142610
|
-
code: record3.code,
|
|
142611
|
-
message: record3.message,
|
|
142612
|
-
retryable: typeof record3.retryable === "boolean" ? record3.retryable : false
|
|
142613
|
-
};
|
|
142614
|
-
};
|
|
142615
|
-
CliAgentToolError = class extends Error {
|
|
142616
|
-
code;
|
|
142617
|
-
retryable;
|
|
142618
|
-
constructor({
|
|
142619
|
-
code: code2,
|
|
142620
|
-
message,
|
|
142621
|
-
retryable = false,
|
|
142622
|
-
cause
|
|
142623
|
-
}) {
|
|
142624
|
-
super(message, { cause });
|
|
142625
|
-
this.name = "CliAgentToolError";
|
|
142626
|
-
this.code = code2;
|
|
142627
|
-
this.retryable = retryable;
|
|
142628
|
-
}
|
|
142629
|
-
};
|
|
142630
|
-
normalizeCliAgentToolError = (error55) => {
|
|
142631
|
-
if (error55 instanceof CliAgentToolError) {
|
|
142632
|
-
return error55;
|
|
142633
|
-
}
|
|
142634
|
-
const applicationError = readConvexApplicationError(error55);
|
|
142635
|
-
if (applicationError) {
|
|
142636
|
-
return new CliAgentToolError({ ...applicationError, cause: error55 });
|
|
142637
|
-
}
|
|
142638
|
-
return new CliAgentToolError({
|
|
142639
|
-
code: "internal_error",
|
|
142640
|
-
message: error55 instanceof Error ? error55.message : String(error55),
|
|
142641
|
-
cause: error55
|
|
142642
|
-
});
|
|
142643
|
-
};
|
|
142644
|
-
}
|
|
142645
|
-
});
|
|
142646
|
-
|
|
142647
142646
|
// src/devbox/resourceApi/context.ts
|
|
142648
142647
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
142649
142648
|
var createCliControlPlaneTokenContext, createCliAgentToolRequestId, createCliAgentResourceContext;
|
|
@@ -142654,37 +142653,19 @@ var init_context2 = __esm({
|
|
|
142654
142653
|
init_auth();
|
|
142655
142654
|
init_controlPlane();
|
|
142656
142655
|
init_accountScope2();
|
|
142657
|
-
init_errors5();
|
|
142658
142656
|
createCliControlPlaneTokenContext = async ({
|
|
142659
142657
|
allowInteractiveLogin,
|
|
142660
|
-
missingLoginMessage,
|
|
142661
142658
|
tokenProviderMode
|
|
142662
142659
|
}) => {
|
|
142663
142660
|
const config5 = await loadConfig();
|
|
142664
142661
|
const store = await createSecretStore(config5?.tokenStore);
|
|
142665
|
-
|
|
142666
|
-
|
|
142667
|
-
const token = allowInteractiveLogin ? await ensureControlPlaneToken(store) : await ensureExistingControlPlaneToken(store);
|
|
142668
|
-
if (!token) {
|
|
142669
|
-
throw new Error(missingLoginMessage);
|
|
142670
|
-
}
|
|
142671
|
-
initialToken = token;
|
|
142672
|
-
} catch (error55) {
|
|
142673
|
-
if (allowInteractiveLogin) {
|
|
142674
|
-
throw error55;
|
|
142675
|
-
}
|
|
142676
|
-
throw new CliAgentToolError({
|
|
142677
|
-
code: "not_authenticated",
|
|
142678
|
-
message: missingLoginMessage,
|
|
142679
|
-
cause: error55
|
|
142680
|
-
});
|
|
142681
|
-
}
|
|
142682
|
-
let seededToken = initialToken;
|
|
142662
|
+
const session = allowInteractiveLogin ? await ensureControlPlaneSession(store) : await resolveStoredControlPlaneSession(store);
|
|
142663
|
+
let seededToken = session.token;
|
|
142683
142664
|
const longLivedTokenProvider = tokenProviderMode === "long_lived" ? createLongLivedControlPlaneTokenProvider(store) : null;
|
|
142684
142665
|
const activeConvexTarget = await readCliActiveConvexTargetFromCwd();
|
|
142685
|
-
const { accountScope, viewer } = await
|
|
142666
|
+
const { accountScope, viewer } = await buildCliAccountScope({
|
|
142686
142667
|
activeConvexTarget,
|
|
142687
|
-
|
|
142668
|
+
viewer: session.viewer
|
|
142688
142669
|
});
|
|
142689
142670
|
return {
|
|
142690
142671
|
accountScope,
|
|
@@ -142707,7 +142688,6 @@ var init_context2 = __esm({
|
|
|
142707
142688
|
createCliAgentResourceContext = async () => {
|
|
142708
142689
|
const tokenContext = await createCliControlPlaneTokenContext({
|
|
142709
142690
|
allowInteractiveLogin: false,
|
|
142710
|
-
missingLoginMessage: "Not logged in to boxes.dev. Run `dvb setup` in an interactive terminal first.",
|
|
142711
142691
|
tokenProviderMode: "bounded"
|
|
142712
142692
|
});
|
|
142713
142693
|
const client = await createAuthenticatedConvexClient(tokenContext.getToken);
|
|
@@ -142878,10 +142858,9 @@ var init_commandContext = __esm({
|
|
|
142878
142858
|
});
|
|
142879
142859
|
return Ct(answer) ? null : String(answer);
|
|
142880
142860
|
};
|
|
142881
|
-
createAgentViewCommandTokenContext = async (
|
|
142861
|
+
createAgentViewCommandTokenContext = async () => {
|
|
142882
142862
|
const context34 = await createCliControlPlaneTokenContext({
|
|
142883
142863
|
allowInteractiveLogin: true,
|
|
142884
|
-
missingLoginMessage: `Not logged in to boxes.dev. Rerun \`dvb ${command}\` in an interactive terminal to log in.`,
|
|
142885
142864
|
tokenProviderMode: "long_lived"
|
|
142886
142865
|
});
|
|
142887
142866
|
return {
|
|
@@ -142930,6 +142909,112 @@ var init_commandContext = __esm({
|
|
|
142930
142909
|
}
|
|
142931
142910
|
});
|
|
142932
142911
|
|
|
142912
|
+
// src/devbox/resourceApi/errors.ts
|
|
142913
|
+
var CLI_AGENT_TOOL_FAILURE_CODES, readConvexApplicationError, CliAgentToolError, normalizeCliAgentToolError;
|
|
142914
|
+
var init_errors5 = __esm({
|
|
142915
|
+
"src/devbox/resourceApi/errors.ts"() {
|
|
142916
|
+
"use strict";
|
|
142917
|
+
init_values();
|
|
142918
|
+
init_authErrors();
|
|
142919
|
+
CLI_AGENT_TOOL_FAILURE_CODES = /* @__PURE__ */ new Set([
|
|
142920
|
+
"not_authenticated",
|
|
142921
|
+
"project_not_found",
|
|
142922
|
+
"ambiguous_project",
|
|
142923
|
+
"devbox_not_found",
|
|
142924
|
+
"devbox_has_threads",
|
|
142925
|
+
"thread_not_found",
|
|
142926
|
+
"contract_version_unsupported",
|
|
142927
|
+
"invalid_request",
|
|
142928
|
+
"operation_in_progress",
|
|
142929
|
+
"idempotency_key_reused",
|
|
142930
|
+
"daemon_unavailable",
|
|
142931
|
+
"unsupported_capability",
|
|
142932
|
+
"operation_canceled",
|
|
142933
|
+
"billing_blocked",
|
|
142934
|
+
"capacity_blocked",
|
|
142935
|
+
"thread_busy",
|
|
142936
|
+
"thread_controlled_elsewhere",
|
|
142937
|
+
"turn_not_active",
|
|
142938
|
+
"turn_changed",
|
|
142939
|
+
"not_found",
|
|
142940
|
+
"name_conflict",
|
|
142941
|
+
"project_url_limit_reached",
|
|
142942
|
+
"configuration_conflict",
|
|
142943
|
+
"invalid_configuration",
|
|
142944
|
+
"template_maintenance_unavailable",
|
|
142945
|
+
"watch_removal_confirmation_required",
|
|
142946
|
+
"github_connection_required",
|
|
142947
|
+
"github_repository_access_required",
|
|
142948
|
+
"service_update_required",
|
|
142949
|
+
"invalid_delivery_policy",
|
|
142950
|
+
"port_not_eligible",
|
|
142951
|
+
"infrastructure_unavailable",
|
|
142952
|
+
"command_failed",
|
|
142953
|
+
"internal_error"
|
|
142954
|
+
]);
|
|
142955
|
+
readConvexApplicationError = (error55) => {
|
|
142956
|
+
if (!(error55 instanceof ConvexError)) return null;
|
|
142957
|
+
const data = error55.data;
|
|
142958
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return null;
|
|
142959
|
+
const record3 = data;
|
|
142960
|
+
if (typeof record3.code !== "string" || !CLI_AGENT_TOOL_FAILURE_CODES.has(
|
|
142961
|
+
record3.code
|
|
142962
|
+
) || typeof record3.message !== "string") {
|
|
142963
|
+
return null;
|
|
142964
|
+
}
|
|
142965
|
+
return {
|
|
142966
|
+
code: record3.code,
|
|
142967
|
+
message: record3.message,
|
|
142968
|
+
retryable: typeof record3.retryable === "boolean" ? record3.retryable : false
|
|
142969
|
+
};
|
|
142970
|
+
};
|
|
142971
|
+
CliAgentToolError = class extends Error {
|
|
142972
|
+
code;
|
|
142973
|
+
retryable;
|
|
142974
|
+
constructor({
|
|
142975
|
+
code: code2,
|
|
142976
|
+
message,
|
|
142977
|
+
retryable = false,
|
|
142978
|
+
cause
|
|
142979
|
+
}) {
|
|
142980
|
+
super(message, { cause });
|
|
142981
|
+
this.name = "CliAgentToolError";
|
|
142982
|
+
this.code = code2;
|
|
142983
|
+
this.retryable = retryable;
|
|
142984
|
+
}
|
|
142985
|
+
};
|
|
142986
|
+
normalizeCliAgentToolError = (error55) => {
|
|
142987
|
+
if (error55 instanceof CliAgentToolError) {
|
|
142988
|
+
return error55;
|
|
142989
|
+
}
|
|
142990
|
+
if (error55 instanceof ControlPlaneLoginRequiredError) {
|
|
142991
|
+
return new CliAgentToolError({
|
|
142992
|
+
code: "not_authenticated",
|
|
142993
|
+
message: error55.message,
|
|
142994
|
+
cause: error55
|
|
142995
|
+
});
|
|
142996
|
+
}
|
|
142997
|
+
if (error55 instanceof ControlPlaneAuthUnavailableError) {
|
|
142998
|
+
return new CliAgentToolError({
|
|
142999
|
+
code: "infrastructure_unavailable",
|
|
143000
|
+
message: error55.message,
|
|
143001
|
+
retryable: true,
|
|
143002
|
+
cause: error55
|
|
143003
|
+
});
|
|
143004
|
+
}
|
|
143005
|
+
const applicationError = readConvexApplicationError(error55);
|
|
143006
|
+
if (applicationError) {
|
|
143007
|
+
return new CliAgentToolError({ ...applicationError, cause: error55 });
|
|
143008
|
+
}
|
|
143009
|
+
return new CliAgentToolError({
|
|
143010
|
+
code: "internal_error",
|
|
143011
|
+
message: error55 instanceof Error ? error55.message : String(error55),
|
|
143012
|
+
cause: error55
|
|
143013
|
+
});
|
|
143014
|
+
};
|
|
143015
|
+
}
|
|
143016
|
+
});
|
|
143017
|
+
|
|
142933
143018
|
// src/devbox/resourceApi/identifiers.ts
|
|
142934
143019
|
var resolveCliAgentToolProject, resolveCliAgentToolDevbox;
|
|
142935
143020
|
var init_identifiers = __esm({
|
|
@@ -168180,7 +168265,7 @@ var init_agentDirectThread = __esm({
|
|
|
168180
168265
|
`\`dvb ${backend}\` requires an interactive terminal. Rerun it directly in your terminal.`
|
|
168181
168266
|
);
|
|
168182
168267
|
}
|
|
168183
|
-
const { accountScope, getToken } = await dependencies.createTokenContext(
|
|
168268
|
+
const { accountScope, getToken } = await dependencies.createTokenContext();
|
|
168184
168269
|
const client = await dependencies.createClient(getToken);
|
|
168185
168270
|
try {
|
|
168186
168271
|
const selection = await dependencies.selectProject({
|
|
@@ -168641,7 +168726,7 @@ var init_agentDirectResume = __esm({
|
|
|
168641
168726
|
`\`dvb ${backend} --resume\` requires an interactive terminal. Rerun it directly in your terminal.`
|
|
168642
168727
|
);
|
|
168643
168728
|
}
|
|
168644
|
-
const { accountScope, getToken } = await dependencies.createTokenContext(
|
|
168729
|
+
const { accountScope, getToken } = await dependencies.createTokenContext();
|
|
168645
168730
|
const client = await dependencies.createClient(getToken);
|
|
168646
168731
|
try {
|
|
168647
168732
|
const selection = await dependencies.selectProject({
|
|
@@ -230401,7 +230486,7 @@ var init_runAgentWorkspaceDetail = __esm({
|
|
|
230401
230486
|
error: error55 instanceof Error ? error55.message : String(error55)
|
|
230402
230487
|
});
|
|
230403
230488
|
});
|
|
230404
|
-
const { accountScope, getToken, isAdmin } = await createAgentViewCommandTokenContext(
|
|
230489
|
+
const { accountScope, getToken, isAdmin } = await createAgentViewCommandTokenContext();
|
|
230405
230490
|
const memoryDiagnostics = await startAgentViewMemoryDiagnostics({
|
|
230406
230491
|
localDiagnosticsEnabled: isAdmin,
|
|
230407
230492
|
role: "workspace_detail",
|
|
@@ -231290,7 +231375,7 @@ var init_agents = __esm({
|
|
|
231290
231375
|
init_threads();
|
|
231291
231376
|
init_resourceOutput();
|
|
231292
231377
|
init_threads2();
|
|
231293
|
-
createAgentViewTokenProvider = async () => await createAgentViewCommandTokenContext(
|
|
231378
|
+
createAgentViewTokenProvider = async () => await createAgentViewCommandTokenContext();
|
|
231294
231379
|
defaultDependencies7 = {
|
|
231295
231380
|
stdinIsTTY: () => process.stdin.isTTY === true,
|
|
231296
231381
|
stdoutIsTTY: () => process.stdout.isTTY === true,
|
|
@@ -249797,6 +249882,7 @@ var init_service = __esm({
|
|
|
249797
249882
|
init_initPrep();
|
|
249798
249883
|
init_accountScope2();
|
|
249799
249884
|
init_auth();
|
|
249885
|
+
init_authErrors();
|
|
249800
249886
|
init_databaseDumpTools2();
|
|
249801
249887
|
init_siteUrl();
|
|
249802
249888
|
init_controlPlane2();
|
|
@@ -249825,7 +249911,9 @@ var init_service = __esm({
|
|
|
249825
249911
|
const store = await openAgentInitSecretStore(homeDir2);
|
|
249826
249912
|
const controlPlaneToken = await ensureControlPlaneToken(store);
|
|
249827
249913
|
if (!controlPlaneToken) {
|
|
249828
|
-
throw new
|
|
249914
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
249915
|
+
message: buildAgentInitLoginRequiredMessage()
|
|
249916
|
+
});
|
|
249829
249917
|
}
|
|
249830
249918
|
const activeConvexTarget = await readCliActiveConvexTargetFromCwd({ cwd: cwd2 });
|
|
249831
249919
|
const { accountScope, viewer } = await resolveCliAccountScope({
|
|
@@ -249959,6 +250047,7 @@ var init_failureReport = __esm({
|
|
|
249959
250047
|
"use strict";
|
|
249960
250048
|
init_devboxCore();
|
|
249961
250049
|
init_auth();
|
|
250050
|
+
init_authErrors();
|
|
249962
250051
|
init_billingActivationGate();
|
|
249963
250052
|
init_errors4();
|
|
249964
250053
|
init_progressReport();
|
|
@@ -249992,7 +250081,7 @@ var init_failureReport = __esm({
|
|
|
249992
250081
|
report = reportAgentInitStepBestEffort
|
|
249993
250082
|
}) => {
|
|
249994
250083
|
const progress = readProgressCommand(args);
|
|
249995
|
-
if (progress === null || isCommandUsageError(error55) || error55 instanceof UpgradeRequiredError || isBillingActivationRequiredError(error55)) {
|
|
250084
|
+
if (progress === null || isCommandUsageError(error55) || error55 instanceof UpgradeRequiredError || isBillingActivationRequiredError(error55) || error55 instanceof ControlPlaneLoginRequiredError || error55 instanceof ControlPlaneAuthUnavailableError) {
|
|
249996
250085
|
return;
|
|
249997
250086
|
}
|
|
249998
250087
|
printError(
|
|
@@ -250379,7 +250468,7 @@ var init_claudeSetupOauth = __esm({
|
|
|
250379
250468
|
automaticUrl.searchParams.set("client_id", discovery.clientId);
|
|
250380
250469
|
automaticUrl.searchParams.set("response_type", "code");
|
|
250381
250470
|
automaticUrl.searchParams.set("redirect_uri", automaticRedirectUrl);
|
|
250382
|
-
automaticUrl.searchParams.set("scope",
|
|
250471
|
+
automaticUrl.searchParams.set("scope", CLAUDE_LOGIN_SCOPES.join(" "));
|
|
250383
250472
|
automaticUrl.searchParams.set("code_challenge", codeChallenge);
|
|
250384
250473
|
automaticUrl.searchParams.set("code_challenge_method", "S256");
|
|
250385
250474
|
automaticUrl.searchParams.set("state", state);
|
|
@@ -250388,7 +250477,7 @@ var init_claudeSetupOauth = __esm({
|
|
|
250388
250477
|
manualUrl.searchParams.set("client_id", discovery.clientId);
|
|
250389
250478
|
manualUrl.searchParams.set("response_type", "code");
|
|
250390
250479
|
manualUrl.searchParams.set("redirect_uri", discovery.manualRedirectUrl);
|
|
250391
|
-
manualUrl.searchParams.set("scope",
|
|
250480
|
+
manualUrl.searchParams.set("scope", CLAUDE_LOGIN_SCOPES.join(" "));
|
|
250392
250481
|
manualUrl.searchParams.set("code_challenge", codeChallenge);
|
|
250393
250482
|
manualUrl.searchParams.set("code_challenge_method", "S256");
|
|
250394
250483
|
manualUrl.searchParams.set("state", state);
|
|
@@ -250672,8 +250761,9 @@ var init_claudeSetupOauth = __esm({
|
|
|
250672
250761
|
redirect_uri: redirectUrl,
|
|
250673
250762
|
client_id: discovery.clientId,
|
|
250674
250763
|
code_verifier: codeVerifier,
|
|
250675
|
-
state
|
|
250676
|
-
|
|
250764
|
+
state
|
|
250765
|
+
// A claude.ai login takes Anthropic's default lifetime; a custom one is
|
|
250766
|
+
// refused for its scopes.
|
|
250677
250767
|
});
|
|
250678
250768
|
const response = await sendClaudeSetupJsonRequest({
|
|
250679
250769
|
url: tokenUrl,
|
|
@@ -250711,6 +250801,16 @@ var init_claudeSetupOauth = __esm({
|
|
|
250711
250801
|
"expires_in"
|
|
250712
250802
|
);
|
|
250713
250803
|
const scope = requireNullableString2(parsed.scope);
|
|
250804
|
+
const tokenResponse = {
|
|
250805
|
+
access_token: accessToken,
|
|
250806
|
+
refresh_token: requireNonEmptyString(parsed.refresh_token, "refresh_token"),
|
|
250807
|
+
expires_in: expiresInSeconds,
|
|
250808
|
+
refresh_token_expires_in: requirePositiveInteger(
|
|
250809
|
+
parsed.refresh_token_expires_in,
|
|
250810
|
+
"refresh_token_expires_in"
|
|
250811
|
+
),
|
|
250812
|
+
scope: requireNonEmptyString(parsed.scope, "scope")
|
|
250813
|
+
};
|
|
250714
250814
|
const account = isRecord7(parsed.account) ? parsed.account : null;
|
|
250715
250815
|
const organization = isRecord7(parsed.organization) ? parsed.organization : null;
|
|
250716
250816
|
return {
|
|
@@ -250719,7 +250819,8 @@ var init_claudeSetupOauth = __esm({
|
|
|
250719
250819
|
emailAddress: account ? requireNullableString2(account.email_address) : null,
|
|
250720
250820
|
expiresInSeconds,
|
|
250721
250821
|
organizationUuid: organization ? requireNullableString2(organization.uuid) : null,
|
|
250722
|
-
scope
|
|
250822
|
+
scope,
|
|
250823
|
+
tokenResponse
|
|
250723
250824
|
};
|
|
250724
250825
|
};
|
|
250725
250826
|
prepareClaudeSetupAuthorizeUrls = ({
|
|
@@ -250873,7 +250974,8 @@ var init_claudeSetupOauth = __esm({
|
|
|
250873
250974
|
accountEmail: null,
|
|
250874
250975
|
accountUuid: null,
|
|
250875
250976
|
organizationUuid: null,
|
|
250876
|
-
source: "existing_token"
|
|
250977
|
+
source: "existing_token",
|
|
250978
|
+
tokenResponse: null
|
|
250877
250979
|
};
|
|
250878
250980
|
}
|
|
250879
250981
|
const tokenExchange = await exchangeClaudeSetupOauthCodeFn({
|
|
@@ -250888,7 +250990,8 @@ var init_claudeSetupOauth = __esm({
|
|
|
250888
250990
|
accountEmail: tokenExchange.emailAddress,
|
|
250889
250991
|
accountUuid: tokenExchange.accountUuid,
|
|
250890
250992
|
organizationUuid: tokenExchange.organizationUuid,
|
|
250891
|
-
source: "oauth"
|
|
250993
|
+
source: "oauth",
|
|
250994
|
+
tokenResponse: tokenExchange.tokenResponse
|
|
250892
250995
|
};
|
|
250893
250996
|
} finally {
|
|
250894
250997
|
await callbackServer.close().catch(() => void 0);
|
|
@@ -250925,7 +251028,8 @@ var init_claudeSetupOauth = __esm({
|
|
|
250925
251028
|
accountEmail: null,
|
|
250926
251029
|
accountUuid: null,
|
|
250927
251030
|
organizationUuid: null,
|
|
250928
|
-
source: "existing_token"
|
|
251031
|
+
source: "existing_token",
|
|
251032
|
+
tokenResponse: null
|
|
250929
251033
|
};
|
|
250930
251034
|
}
|
|
250931
251035
|
const tokenExchange = await exchangeClaudeSetupOauthCodeFn({
|
|
@@ -250940,25 +251044,29 @@ var init_claudeSetupOauth = __esm({
|
|
|
250940
251044
|
accountEmail: tokenExchange.emailAddress,
|
|
250941
251045
|
accountUuid: tokenExchange.accountUuid,
|
|
250942
251046
|
organizationUuid: tokenExchange.organizationUuid,
|
|
250943
|
-
source: "oauth"
|
|
251047
|
+
source: "oauth",
|
|
251048
|
+
tokenResponse: tokenExchange.tokenResponse
|
|
250944
251049
|
};
|
|
250945
251050
|
};
|
|
250946
251051
|
}
|
|
250947
251052
|
});
|
|
250948
251053
|
|
|
250949
251054
|
// src/devbox/commands/setupClaude.ts
|
|
250950
|
-
var CLAUDE_TOKEN_RENEWAL_WINDOW_MS, trim11, formatDate, resolveClaudeSetupState, formatClaudeSetupState, preflightClaudeSetupToken, resolveClaudeSetupPromptContent, needsClaudeSetupAttention, promptForClaudeSetupAuthMethod, collectClaudeCodeOauthTokenInteractively, ensureManagedClaudeAuth;
|
|
251055
|
+
var CLAUDE_TOKEN_RENEWAL_WINDOW_MS, CLAUDE_LOGIN_RENEWAL_WINDOW_MS, trim11, formatDate, resolveClaudeSetupState, formatClaudeSetupState, preflightClaudeSetupToken, resolveClaudeSetupPromptContent, needsClaudeSetupAttention, promptForClaudeSetupAuthMethod, collectClaudeCodeOauthTokenInteractively, ensureManagedClaudeAuth;
|
|
250951
251056
|
var init_setupClaude = __esm({
|
|
250952
251057
|
"src/devbox/commands/setupClaude.ts"() {
|
|
250953
251058
|
"use strict";
|
|
250954
251059
|
init_dist5();
|
|
250955
251060
|
init_devboxCore();
|
|
250956
251061
|
init_claudeSetupOauth();
|
|
251062
|
+
init_controlPlane();
|
|
250957
251063
|
CLAUDE_TOKEN_RENEWAL_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
251064
|
+
CLAUDE_LOGIN_RENEWAL_WINDOW_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
250958
251065
|
trim11 = (value) => value.trim().replace(/\r/g, "");
|
|
250959
251066
|
formatDate = (value) => typeof value === "number" ? new Date(value).toISOString().slice(0, 10) : "unknown";
|
|
250960
251067
|
resolveClaudeSetupState = ({
|
|
250961
251068
|
authMode = null,
|
|
251069
|
+
oauthKind = null,
|
|
250962
251070
|
hasToken,
|
|
250963
251071
|
expiresAt,
|
|
250964
251072
|
lastRuntimeAuthFailureAt,
|
|
@@ -250980,7 +251088,7 @@ var init_setupClaude = __esm({
|
|
|
250980
251088
|
if (expiresAt <= nowMs) {
|
|
250981
251089
|
return "expired";
|
|
250982
251090
|
}
|
|
250983
|
-
if (expiresAt <= nowMs + CLAUDE_TOKEN_RENEWAL_WINDOW_MS) {
|
|
251091
|
+
if (expiresAt <= nowMs + (oauthKind === "login" ? CLAUDE_LOGIN_RENEWAL_WINDOW_MS : CLAUDE_TOKEN_RENEWAL_WINDOW_MS)) {
|
|
250984
251092
|
return "renewal_recommended";
|
|
250985
251093
|
}
|
|
250986
251094
|
return "healthy";
|
|
@@ -251143,6 +251251,7 @@ var init_setupClaude = __esm({
|
|
|
251143
251251
|
};
|
|
251144
251252
|
ensureManagedClaudeAuth = async ({
|
|
251145
251253
|
controlPlaneToken,
|
|
251254
|
+
refreshControlPlaneToken: refreshControlPlaneToken2,
|
|
251146
251255
|
providedClaudeCodeOauthToken = null,
|
|
251147
251256
|
skipClaudeAuth = false,
|
|
251148
251257
|
forceReplace = false,
|
|
@@ -251150,6 +251259,7 @@ var init_setupClaude = __esm({
|
|
|
251150
251259
|
canPromptInteractively,
|
|
251151
251260
|
fetchClaudeTokenStatusFn,
|
|
251152
251261
|
storeClaudeCodeOauthTokenFn,
|
|
251262
|
+
storeClaudeLoginFn = storeClaudeLogin,
|
|
251153
251263
|
collectClaudeCodeOauthTokenInteractivelyFn = collectClaudeCodeOauthTokenInteractively,
|
|
251154
251264
|
onStatusStage,
|
|
251155
251265
|
onInteractivePromptStart,
|
|
@@ -251161,6 +251271,7 @@ var init_setupClaude = __esm({
|
|
|
251161
251271
|
);
|
|
251162
251272
|
let claudeTokenStatus = {
|
|
251163
251273
|
authMode: null,
|
|
251274
|
+
oauthKind: null,
|
|
251164
251275
|
hasToken: false,
|
|
251165
251276
|
expiresAt: null,
|
|
251166
251277
|
updatedAt: null,
|
|
@@ -251181,15 +251292,19 @@ var init_setupClaude = __esm({
|
|
|
251181
251292
|
}
|
|
251182
251293
|
return { claudeTokenStatus, claudeAuthState, didUpdateClaudeAuth };
|
|
251183
251294
|
}
|
|
251295
|
+
let currentControlPlaneToken = controlPlaneToken;
|
|
251184
251296
|
const refreshClaudeStatus = async () => {
|
|
251185
251297
|
onStatusStage?.("Checking Claude auth");
|
|
251186
251298
|
try {
|
|
251187
|
-
claudeTokenStatus = await fetchClaudeTokenStatusFn(
|
|
251299
|
+
claudeTokenStatus = await fetchClaudeTokenStatusFn(
|
|
251300
|
+
currentControlPlaneToken
|
|
251301
|
+
);
|
|
251188
251302
|
} catch (error55) {
|
|
251189
251303
|
onFetchStatusError?.(error55);
|
|
251190
251304
|
}
|
|
251191
251305
|
claudeAuthState = resolveClaudeSetupState({
|
|
251192
251306
|
authMode: claudeTokenStatus.authMode,
|
|
251307
|
+
oauthKind: claudeTokenStatus.oauthKind,
|
|
251193
251308
|
hasToken: claudeTokenStatus.hasToken,
|
|
251194
251309
|
expiresAt: claudeTokenStatus.expiresAt,
|
|
251195
251310
|
lastRuntimeAuthFailureAt: claudeTokenStatus.lastRuntimeAuthFailureAt,
|
|
@@ -251200,11 +251315,23 @@ var init_setupClaude = __esm({
|
|
|
251200
251315
|
accessToken,
|
|
251201
251316
|
accountEmail,
|
|
251202
251317
|
accountUuid,
|
|
251203
|
-
organizationUuid
|
|
251318
|
+
organizationUuid,
|
|
251319
|
+
tokenResponse
|
|
251204
251320
|
}) => {
|
|
251205
251321
|
onStatusStage?.("Updating Claude auth");
|
|
251322
|
+
currentControlPlaneToken = await refreshControlPlaneToken2();
|
|
251323
|
+
if (tokenResponse) {
|
|
251324
|
+
await storeClaudeLoginFn(currentControlPlaneToken, tokenResponse, {
|
|
251325
|
+
accountEmail,
|
|
251326
|
+
accountUuid,
|
|
251327
|
+
organizationUuid
|
|
251328
|
+
});
|
|
251329
|
+
didUpdateClaudeAuth = true;
|
|
251330
|
+
await refreshClaudeStatus();
|
|
251331
|
+
return;
|
|
251332
|
+
}
|
|
251206
251333
|
const stored = await storeClaudeCodeOauthTokenFn(
|
|
251207
|
-
|
|
251334
|
+
currentControlPlaneToken,
|
|
251208
251335
|
accessToken,
|
|
251209
251336
|
{
|
|
251210
251337
|
accountEmail,
|
|
@@ -251228,7 +251355,8 @@ var init_setupClaude = __esm({
|
|
|
251228
251355
|
accountEmail: null,
|
|
251229
251356
|
accountUuid: null,
|
|
251230
251357
|
organizationUuid: null,
|
|
251231
|
-
source: "existing_token"
|
|
251358
|
+
source: "existing_token",
|
|
251359
|
+
tokenResponse: null
|
|
251232
251360
|
});
|
|
251233
251361
|
return { claudeTokenStatus, claudeAuthState, didUpdateClaudeAuth };
|
|
251234
251362
|
}
|
|
@@ -251263,6 +251391,7 @@ var init_accounts = __esm({
|
|
|
251263
251391
|
init_progressReport();
|
|
251264
251392
|
init_remoteSession();
|
|
251265
251393
|
init_auth();
|
|
251394
|
+
init_authErrors();
|
|
251266
251395
|
init_browser();
|
|
251267
251396
|
init_errors4();
|
|
251268
251397
|
init_codingAgents2();
|
|
@@ -251353,7 +251482,7 @@ var init_accounts = __esm({
|
|
|
251353
251482
|
redirectUrl: signIn.redirectUrl,
|
|
251354
251483
|
state
|
|
251355
251484
|
});
|
|
251356
|
-
await
|
|
251485
|
+
await storeClaudeLogin(controlPlaneToken, exchange.tokenResponse, {
|
|
251357
251486
|
accountEmail: exchange.emailAddress,
|
|
251358
251487
|
accountUuid: exchange.accountUuid,
|
|
251359
251488
|
organizationUuid: exchange.organizationUuid
|
|
@@ -251380,7 +251509,9 @@ var init_accounts = __esm({
|
|
|
251380
251509
|
const store = await openAgentInitSecretStore();
|
|
251381
251510
|
const controlPlaneToken = await resolveStoredControlPlaneToken(store);
|
|
251382
251511
|
if (!controlPlaneToken) {
|
|
251383
|
-
throw new
|
|
251512
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
251513
|
+
message: buildAgentInitLoginRequiredMessage()
|
|
251514
|
+
});
|
|
251384
251515
|
}
|
|
251385
251516
|
const { accountScope, viewer } = await resolveCliAccountScope({
|
|
251386
251517
|
activeConvexTarget: await readCliActiveConvexTargetFromCwd(),
|
|
@@ -280878,6 +281009,7 @@ var init_setupAgents = __esm({
|
|
|
280878
281009
|
init_dist5();
|
|
280879
281010
|
init_devboxCore();
|
|
280880
281011
|
init_auth();
|
|
281012
|
+
init_authErrors();
|
|
280881
281013
|
init_accountScope2();
|
|
280882
281014
|
init_controlPlane();
|
|
280883
281015
|
init_managedCodexAuth();
|
|
@@ -280888,6 +281020,7 @@ var init_setupAgents = __esm({
|
|
|
280888
281020
|
codingAgentSelectionsEqual = (left, right) => left.codex === right.codex && left.claudeCode === right.claudeCode;
|
|
280889
281021
|
DEFAULT_CLAUDE_TOKEN_STATUS = {
|
|
280890
281022
|
authMode: null,
|
|
281023
|
+
oauthKind: null,
|
|
280891
281024
|
hasToken: false,
|
|
280892
281025
|
expiresAt: null,
|
|
280893
281026
|
updatedAt: null,
|
|
@@ -280980,6 +281113,7 @@ var init_setupAgents = __esm({
|
|
|
280980
281113
|
storeClaudeCodeOauthTokenFn = storeClaudeCodeOauthToken,
|
|
280981
281114
|
clearClaudeCodeOauthTokenFn = clearClaudeCodeOauthToken,
|
|
280982
281115
|
ensureControlPlaneTokenFn = ensureControlPlaneToken,
|
|
281116
|
+
ensureExistingControlPlaneTokenFn = ensureExistingControlPlaneToken,
|
|
280983
281117
|
validateManagedCodexAuthFn = validateManagedCodexAuth,
|
|
280984
281118
|
loginManagedCodexFn = loginManagedCodex,
|
|
280985
281119
|
clearManagedCodexAuthFn = clearManagedCodexAuth
|
|
@@ -281002,9 +281136,9 @@ var init_setupAgents = __esm({
|
|
|
281002
281136
|
onStatusStage?.("Checking boxes.dev login");
|
|
281003
281137
|
const ensured = await ensureControlPlaneTokenFn(store, onStatusStage);
|
|
281004
281138
|
if (!ensured) {
|
|
281005
|
-
throw new
|
|
281006
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
281007
|
-
);
|
|
281139
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
281140
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
281141
|
+
});
|
|
281008
281142
|
}
|
|
281009
281143
|
controlPlaneToken = ensured;
|
|
281010
281144
|
return ensured;
|
|
@@ -281061,6 +281195,13 @@ var init_setupAgents = __esm({
|
|
|
281061
281195
|
}
|
|
281062
281196
|
const outcome = await ensureManagedClaudeAuthFn({
|
|
281063
281197
|
controlPlaneToken: skipClaudeAuth ? controlPlaneToken : await ensureControlPlaneTokenForAgents(),
|
|
281198
|
+
refreshControlPlaneToken: async () => {
|
|
281199
|
+
controlPlaneToken = await ensureExistingControlPlaneTokenFn(
|
|
281200
|
+
store,
|
|
281201
|
+
onStatusStage
|
|
281202
|
+
);
|
|
281203
|
+
return controlPlaneToken;
|
|
281204
|
+
},
|
|
281064
281205
|
providedClaudeCodeOauthToken,
|
|
281065
281206
|
skipClaudeAuth,
|
|
281066
281207
|
forceReplace: shouldForceReplaceClaudeAuth,
|
|
@@ -281167,6 +281308,7 @@ var init_setup = __esm({
|
|
|
281167
281308
|
init_dist5();
|
|
281168
281309
|
init_devboxCore();
|
|
281169
281310
|
init_auth();
|
|
281311
|
+
init_authErrors();
|
|
281170
281312
|
init_args();
|
|
281171
281313
|
init_errors4();
|
|
281172
281314
|
init_controlPlane();
|
|
@@ -281730,9 +281872,9 @@ var init_setup = __esm({
|
|
|
281730
281872
|
};
|
|
281731
281873
|
let controlPlaneToken = await ensureControlPlaneToken(store, authStage);
|
|
281732
281874
|
if (!controlPlaneToken) {
|
|
281733
|
-
throw new
|
|
281734
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
281735
|
-
);
|
|
281875
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
281876
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
281877
|
+
});
|
|
281736
281878
|
}
|
|
281737
281879
|
await ensureCliBillingActivated({
|
|
281738
281880
|
controlPlaneToken,
|
|
@@ -288484,6 +288626,7 @@ var init_agentsSection = __esm({
|
|
|
288484
288626
|
status,
|
|
288485
288627
|
pathSetup,
|
|
288486
288628
|
controlPlaneToken,
|
|
288629
|
+
refreshControlPlaneToken: refreshControlPlaneToken2,
|
|
288487
288630
|
usesCodex,
|
|
288488
288631
|
shouldProbeRemoteCodexAuth,
|
|
288489
288632
|
shouldBootstrapManagedLocalCodexAuthFromRemote,
|
|
@@ -288536,6 +288679,7 @@ var init_agentsSection = __esm({
|
|
|
288536
288679
|
let nextPendingManagedClaudeTokenUpdate = pendingManagedClaudeTokenUpdate;
|
|
288537
288680
|
claudeAuthOutcome = await ensureManagedClaudeAuthFn({
|
|
288538
288681
|
controlPlaneToken,
|
|
288682
|
+
refreshControlPlaneToken: refreshControlPlaneToken2,
|
|
288539
288683
|
skipClaudeAuth: !usesClaudeCode,
|
|
288540
288684
|
requireSetupConfirmation: false,
|
|
288541
288685
|
canPromptInteractively,
|
|
@@ -288812,6 +288956,7 @@ var init_init = __esm({
|
|
|
288812
288956
|
init_devboxCore();
|
|
288813
288957
|
init_daemonClient();
|
|
288814
288958
|
init_auth();
|
|
288959
|
+
init_authErrors();
|
|
288815
288960
|
init_accountScope2();
|
|
288816
288961
|
init_billingActivationGate();
|
|
288817
288962
|
init_controlPlane();
|
|
@@ -289154,14 +289299,15 @@ var init_init = __esm({
|
|
|
289154
289299
|
(message) => status.stage(message)
|
|
289155
289300
|
);
|
|
289156
289301
|
if (!controlPlaneToken) {
|
|
289157
|
-
throw new
|
|
289158
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
289159
|
-
);
|
|
289302
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
289303
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev, then retry."
|
|
289304
|
+
});
|
|
289160
289305
|
}
|
|
289161
289306
|
return {
|
|
289162
289307
|
config: config5,
|
|
289163
289308
|
relayBaseUrl,
|
|
289164
|
-
controlPlaneToken
|
|
289309
|
+
controlPlaneToken,
|
|
289310
|
+
store
|
|
289165
289311
|
};
|
|
289166
289312
|
}
|
|
289167
289313
|
});
|
|
@@ -289551,6 +289697,7 @@ var init_init = __esm({
|
|
|
289551
289697
|
}
|
|
289552
289698
|
const config5 = runtime.config;
|
|
289553
289699
|
const controlPlaneToken = runtime.controlPlaneToken;
|
|
289700
|
+
const refreshControlPlaneToken2 = async () => await ensureExistingControlPlaneToken(runtime.store);
|
|
289554
289701
|
const managedDaemonTarget = resolveManagedDaemonTarget();
|
|
289555
289702
|
await runInitStep({
|
|
289556
289703
|
enabled: progressEnabled,
|
|
@@ -289558,6 +289705,7 @@ var init_init = __esm({
|
|
|
289558
289705
|
fn: async ({ status, ok }) => {
|
|
289559
289706
|
claudeAuthOutcome = await ensureManagedClaudeAuth({
|
|
289560
289707
|
controlPlaneToken,
|
|
289708
|
+
refreshControlPlaneToken: refreshControlPlaneToken2,
|
|
289561
289709
|
skipClaudeAuth: !usesClaudeCode,
|
|
289562
289710
|
requireSetupConfirmation: false,
|
|
289563
289711
|
canPromptInteractively,
|
|
@@ -289920,6 +290068,7 @@ var init_init = __esm({
|
|
|
289920
290068
|
status,
|
|
289921
290069
|
pathSetup,
|
|
289922
290070
|
controlPlaneToken,
|
|
290071
|
+
refreshControlPlaneToken: refreshControlPlaneToken2,
|
|
289923
290072
|
usesCodex,
|
|
289924
290073
|
shouldProbeRemoteCodexAuth,
|
|
289925
290074
|
shouldBootstrapManagedLocalCodexAuthFromRemote: codexExecutionPreparation.shouldBootstrapLocalAuthFromRemote,
|
|
@@ -290775,7 +290924,6 @@ var init_mcp = __esm({
|
|
|
290775
290924
|
createDefaultSession = async () => {
|
|
290776
290925
|
const tokenContext = await createCliControlPlaneTokenContext({
|
|
290777
290926
|
allowInteractiveLogin: process.stdin.isTTY === true,
|
|
290778
|
-
missingLoginMessage: "Not logged in to boxes.dev. Run `dvb setup` in an interactive terminal first.",
|
|
290779
290927
|
tokenProviderMode: "bounded"
|
|
290780
290928
|
});
|
|
290781
290929
|
const client = await createAuthenticatedConvexClient(
|
|
@@ -292220,6 +292368,7 @@ var init_reset = __esm({
|
|
|
292220
292368
|
"use strict";
|
|
292221
292369
|
init_devboxCore();
|
|
292222
292370
|
init_auth();
|
|
292371
|
+
init_authErrors();
|
|
292223
292372
|
init_controlPlane();
|
|
292224
292373
|
init_args();
|
|
292225
292374
|
init_errors4();
|
|
@@ -292311,9 +292460,9 @@ var init_reset = __esm({
|
|
|
292311
292460
|
(message) => status.stage(message)
|
|
292312
292461
|
);
|
|
292313
292462
|
if (!controlPlaneToken) {
|
|
292314
|
-
throw new
|
|
292315
|
-
"Not logged in. Run `dvb setup` to log in to boxes.dev before resetting this machine."
|
|
292316
|
-
);
|
|
292463
|
+
throw new ControlPlaneLoginRequiredError("signed_out", {
|
|
292464
|
+
message: "Not logged in. Run `dvb setup` to log in to boxes.dev before resetting this machine."
|
|
292465
|
+
});
|
|
292317
292466
|
}
|
|
292318
292467
|
status.stage("Resolving machine");
|
|
292319
292468
|
const instances2 = await dependencies.listViewerInstances(controlPlaneToken);
|
|
@@ -294745,14 +294894,15 @@ var init_upgrade = __esm({
|
|
|
294745
294894
|
});
|
|
294746
294895
|
|
|
294747
294896
|
// src/devbox/commands/whoami.ts
|
|
294748
|
-
var parseWhoamiArgs,
|
|
294897
|
+
var parseWhoamiArgs, runWhoami;
|
|
294749
294898
|
var init_whoami = __esm({
|
|
294750
294899
|
"src/devbox/commands/whoami.ts"() {
|
|
294751
294900
|
"use strict";
|
|
294752
294901
|
init_devboxCore();
|
|
294753
294902
|
init_args();
|
|
294754
294903
|
init_errors4();
|
|
294755
|
-
|
|
294904
|
+
init_auth();
|
|
294905
|
+
init_authErrors();
|
|
294756
294906
|
parseWhoamiArgs = (args) => {
|
|
294757
294907
|
const { flags, positionals } = parseCommandArgs({
|
|
294758
294908
|
args,
|
|
@@ -294765,32 +294915,6 @@ var init_whoami = __esm({
|
|
|
294765
294915
|
}
|
|
294766
294916
|
return { json: readBooleanFlag(flags, "json") };
|
|
294767
294917
|
};
|
|
294768
|
-
TOKEN_REFRESH_BUFFER_MS3 = 5 * 60 * 1e3;
|
|
294769
|
-
decodeJwtPayload6 = (token) => {
|
|
294770
|
-
const parts = token.split(".");
|
|
294771
|
-
if (parts.length < 2) return null;
|
|
294772
|
-
const payload = parts[1];
|
|
294773
|
-
if (!payload) return null;
|
|
294774
|
-
const normalized = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
294775
|
-
const pad = normalized.length % 4;
|
|
294776
|
-
const padded = pad === 0 ? normalized : `${normalized}${"=".repeat(4 - pad)}`;
|
|
294777
|
-
try {
|
|
294778
|
-
const decoded = Buffer.from(padded, "base64").toString("utf8");
|
|
294779
|
-
return JSON.parse(decoded);
|
|
294780
|
-
} catch {
|
|
294781
|
-
return null;
|
|
294782
|
-
}
|
|
294783
|
-
};
|
|
294784
|
-
parseTokenExpiresAt3 = (token) => {
|
|
294785
|
-
const payload = decodeJwtPayload6(token);
|
|
294786
|
-
const exp = payload?.exp;
|
|
294787
|
-
if (typeof exp !== "number") return null;
|
|
294788
|
-
return Math.floor(exp * 1e3);
|
|
294789
|
-
};
|
|
294790
|
-
shouldRefreshToken3 = (expiresAt) => {
|
|
294791
|
-
if (!expiresAt) return false;
|
|
294792
|
-
return Date.now() + TOKEN_REFRESH_BUFFER_MS3 >= expiresAt;
|
|
294793
|
-
};
|
|
294794
294918
|
runWhoami = async (args) => {
|
|
294795
294919
|
const parsed = parseWhoamiArgs(args);
|
|
294796
294920
|
const homeDir2 = process.env.HOME?.trim();
|
|
@@ -294799,44 +294923,33 @@ var init_whoami = __esm({
|
|
|
294799
294923
|
config5?.tokenStore,
|
|
294800
294924
|
homeDir2 ? { homeDir: homeDir2 } : void 0
|
|
294801
294925
|
);
|
|
294802
|
-
let
|
|
294803
|
-
|
|
294804
|
-
|
|
294805
|
-
|
|
294806
|
-
if (
|
|
294807
|
-
const refreshed = await refreshControlPlaneSession(refreshToken);
|
|
294808
|
-
token = refreshed.token;
|
|
294809
|
-
const nextExpiresAt = parseTokenExpiresAt3(refreshed.token);
|
|
294810
|
-
await store.setControlPlaneSession({
|
|
294811
|
-
token: refreshed.token,
|
|
294812
|
-
...refreshed.refreshToken ? { refreshToken: refreshed.refreshToken } : {},
|
|
294813
|
-
expiresAt: nextExpiresAt
|
|
294814
|
-
});
|
|
294815
|
-
return true;
|
|
294816
|
-
};
|
|
294817
|
-
if (!token) {
|
|
294818
|
-
await refreshIfPossible().catch(() => false);
|
|
294819
|
-
} else if (shouldRefreshToken3(expiresAt)) {
|
|
294820
|
-
await refreshIfPossible().catch(() => false);
|
|
294821
|
-
}
|
|
294822
|
-
if (!token) {
|
|
294823
|
-
if (parsed.json) {
|
|
294824
|
-
console.log(JSON.stringify({ ok: true, authenticated: false }, null, 2));
|
|
294825
|
-
return;
|
|
294826
|
-
}
|
|
294827
|
-
console.log("Not signed in.");
|
|
294828
|
-
return;
|
|
294829
|
-
}
|
|
294830
|
-
const viewer = await fetchViewerIdentity(token);
|
|
294831
|
-
if (!viewer) {
|
|
294832
|
-
if (parsed.json) {
|
|
294926
|
+
let viewer;
|
|
294927
|
+
try {
|
|
294928
|
+
({ viewer } = await resolveStoredControlPlaneSession(store));
|
|
294929
|
+
} catch (error55) {
|
|
294930
|
+
if (parsed.json && error55 instanceof ControlPlaneAuthUnavailableError) {
|
|
294833
294931
|
console.log(
|
|
294834
294932
|
JSON.stringify(
|
|
294835
|
-
{
|
|
294933
|
+
{
|
|
294934
|
+
ok: false,
|
|
294935
|
+
error: {
|
|
294936
|
+
code: "infrastructure_unavailable",
|
|
294937
|
+
message: error55.message,
|
|
294938
|
+
retryable: true
|
|
294939
|
+
}
|
|
294940
|
+
},
|
|
294836
294941
|
null,
|
|
294837
294942
|
2
|
|
294838
294943
|
)
|
|
294839
294944
|
);
|
|
294945
|
+
process.exitCode = 1;
|
|
294946
|
+
return;
|
|
294947
|
+
}
|
|
294948
|
+
if (!(error55 instanceof ControlPlaneLoginRequiredError)) {
|
|
294949
|
+
throw error55;
|
|
294950
|
+
}
|
|
294951
|
+
if (parsed.json) {
|
|
294952
|
+
console.log(JSON.stringify({ ok: true, authenticated: false }, null, 2));
|
|
294840
294953
|
return;
|
|
294841
294954
|
}
|
|
294842
294955
|
console.log("Not signed in.");
|
|
@@ -296948,6 +297061,7 @@ var init_cli = __esm({
|
|
|
296948
297061
|
|
|
296949
297062
|
// src/bin/dvb.ts
|
|
296950
297063
|
init_devboxCore();
|
|
297064
|
+
init_authErrors();
|
|
296951
297065
|
init_daemonWorkingDirectory();
|
|
296952
297066
|
init_billingActivationGate();
|
|
296953
297067
|
import fsp from "node:fs/promises";
|
|
@@ -297067,6 +297181,11 @@ run().catch(async (error55) => {
|
|
|
297067
297181
|
await flushDevboxSentry();
|
|
297068
297182
|
process.exit(1);
|
|
297069
297183
|
}
|
|
297184
|
+
if (error55 instanceof ControlPlaneLoginRequiredError || error55 instanceof ControlPlaneAuthUnavailableError) {
|
|
297185
|
+
console.error(error55.message);
|
|
297186
|
+
await flushDevboxSentry();
|
|
297187
|
+
process.exit(1);
|
|
297188
|
+
}
|
|
297070
297189
|
const command = args[0] ?? "none";
|
|
297071
297190
|
captureDevboxException(error55, {
|
|
297072
297191
|
tags: {
|
|
@@ -297280,4 +297399,4 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
297280
297399
|
*)
|
|
297281
297400
|
*/
|
|
297282
297401
|
|
|
297283
|
-
//# debugId=
|
|
297402
|
+
//# debugId=f9b05d56-bcfd-5306-9e59-f832431ece07
|