copilotkit 2.0.2 → 2.0.3

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/index.js CHANGED
@@ -63,9 +63,9 @@ function setOpsFrontendUrl(url2) {
63
63
  }
64
64
  function getBuildInfo() {
65
65
  return {
66
- version: "2.0.2",
67
- buildNumber: "25375859015",
68
- commitSha: "e3187072e0586422d8de0d64ce08406f77df265e"
66
+ version: "2.0.3",
67
+ buildNumber: "25387853955",
68
+ commitSha: "6a568f521454b79698cc96223bf7bc7a6bb0c819"
69
69
  };
70
70
  }
71
71
  var opsApiUrlOverride, opsFrontendUrlOverride;
@@ -16841,6 +16841,7 @@ __export(auth_service_exports, {
16841
16841
  isTerminalSessionInvalidationError: () => isTerminalSessionInvalidationError,
16842
16842
  login: () => login,
16843
16843
  logout: () => logout,
16844
+ raceForClerkToken: () => raceForClerkToken,
16844
16845
  startCallbackServer: () => startCallbackServer,
16845
16846
  verifyAndRefresh: () => verifyAndRefresh
16846
16847
  });
@@ -16977,7 +16978,26 @@ function startCallbackServer(expectedState) {
16977
16978
  });
16978
16979
  });
16979
16980
  }
16980
- async function login() {
16981
+ async function raceForClerkToken(resultPromise, manualClerkToken) {
16982
+ const callbackBranch = resultPromise.then((result) => ({
16983
+ clerkToken: result.clerkToken,
16984
+ source: "callback"
16985
+ }));
16986
+ if (!manualClerkToken) {
16987
+ return await callbackBranch;
16988
+ }
16989
+ const manualBranch = manualClerkToken.then((clerkToken) => ({
16990
+ clerkToken,
16991
+ source: "manual"
16992
+ }));
16993
+ const swallow = (promise2) => {
16994
+ promise2.catch(() => void 0);
16995
+ };
16996
+ swallow(callbackBranch);
16997
+ swallow(manualBranch);
16998
+ return await Promise.race([callbackBranch, manualBranch]);
16999
+ }
17000
+ async function login(options = {}) {
16981
17001
  const state = crypto2.randomBytes(16).toString("hex");
16982
17002
  const diagnostics = createCliAuthDiagnostics(state);
16983
17003
  diagnostics.logPhase("login.start", {
@@ -16986,6 +17006,7 @@ async function login() {
16986
17006
  state: summarizeState(state)
16987
17007
  });
16988
17008
  const { port, resultPromise, server } = await startCallbackServer(state);
17009
+ let tokenSource = null;
16989
17010
  try {
16990
17011
  const callbackUrl = `http://127.0.0.1:${port}/callback`;
16991
17012
  const loginParams = new URLSearchParams({
@@ -17017,9 +17038,14 @@ async function login() {
17017
17038
  );
17018
17039
  }
17019
17040
  diagnostics.logPhase("login.waiting-for-callback");
17020
- const { clerkToken } = await resultPromise;
17041
+ const { clerkToken, source } = await raceForClerkToken(
17042
+ resultPromise,
17043
+ options.manualClerkToken
17044
+ );
17045
+ tokenSource = source;
17021
17046
  diagnostics.logPhase("login.callback-complete", {
17022
- clerkTokenReceived: true
17047
+ clerkTokenReceived: true,
17048
+ tokenSource: source
17023
17049
  });
17024
17050
  const apiClient = createApiClient(getOpsApiUrl());
17025
17051
  let authPayload;
@@ -17067,15 +17093,27 @@ async function login() {
17067
17093
  email: authPayload.user.email,
17068
17094
  organizationId: authPayload.organization.clerkOrgId
17069
17095
  });
17070
- return { user: authPayload.user, organization: authPayload.organization };
17096
+ return {
17097
+ user: authPayload.user,
17098
+ organization: authPayload.organization,
17099
+ source
17100
+ };
17071
17101
  } catch (error48) {
17072
17102
  diagnostics.logError("login.failed", error48);
17073
17103
  throw error48;
17074
17104
  } finally {
17075
17105
  diagnostics.logPhase("login.cleanup-start");
17076
- server.close();
17077
- server.closeAllConnections();
17078
- diagnostics.logPhase("login.cleanup-complete");
17106
+ if (tokenSource === "manual") {
17107
+ setTimeout(() => {
17108
+ server.close();
17109
+ server.closeAllConnections();
17110
+ diagnostics.logPhase("login.cleanup-complete", { deferred: true });
17111
+ }, MANUAL_PASTE_SERVER_LINGER_MS);
17112
+ } else {
17113
+ server.close();
17114
+ server.closeAllConnections();
17115
+ diagnostics.logPhase("login.cleanup-complete", { deferred: false });
17116
+ }
17079
17117
  }
17080
17118
  }
17081
17119
  function isTerminalSessionInvalidationError(error48) {
@@ -17125,7 +17163,7 @@ async function logout() {
17125
17163
  }
17126
17164
  authStore.clear();
17127
17165
  }
17128
- var TERMINAL_SESSION_INVALID_MESSAGE;
17166
+ var MANUAL_PASTE_SERVER_LINGER_MS, TERMINAL_SESSION_INVALID_MESSAGE;
17129
17167
  var init_auth_service = __esm({
17130
17168
  "apps/cli/src/services/auth.service.ts"() {
17131
17169
  "use strict";
@@ -17133,6 +17171,7 @@ var init_auth_service = __esm({
17133
17171
  init_api_client();
17134
17172
  init_cli_auth_diagnostics();
17135
17173
  init_config();
17174
+ MANUAL_PASTE_SERVER_LINGER_MS = 6e3;
17136
17175
  TERMINAL_SESSION_INVALID_MESSAGE = "Existing CLI sessions are invalid after the Clerk cutover. Please log in again.";
17137
17176
  }
17138
17177
  });
@@ -71925,6 +71964,104 @@ var init_build2 = __esm({
71925
71964
  }
71926
71965
  });
71927
71966
 
71967
+ // node_modules/.pnpm/ink-text-input@6.0.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-text-input/build/index.js
71968
+ function TextInput({ value: originalValue, placeholder = "", focus = true, mask, highlightPastedText = false, showCursor = true, onChange, onSubmit }) {
71969
+ const [state, setState] = (0, import_react29.useState)({
71970
+ cursorOffset: (originalValue || "").length,
71971
+ cursorWidth: 0
71972
+ });
71973
+ const { cursorOffset, cursorWidth } = state;
71974
+ (0, import_react29.useEffect)(() => {
71975
+ setState((previousState) => {
71976
+ if (!focus || !showCursor) {
71977
+ return previousState;
71978
+ }
71979
+ const newValue = originalValue || "";
71980
+ if (previousState.cursorOffset > newValue.length - 1) {
71981
+ return {
71982
+ cursorOffset: newValue.length,
71983
+ cursorWidth: 0
71984
+ };
71985
+ }
71986
+ return previousState;
71987
+ });
71988
+ }, [originalValue, focus, showCursor]);
71989
+ const cursorActualWidth = highlightPastedText ? cursorWidth : 0;
71990
+ const value = mask ? mask.repeat(originalValue.length) : originalValue;
71991
+ let renderedValue = value;
71992
+ let renderedPlaceholder = placeholder ? source_default.grey(placeholder) : void 0;
71993
+ if (showCursor && focus) {
71994
+ renderedPlaceholder = placeholder.length > 0 ? source_default.inverse(placeholder[0]) + source_default.grey(placeholder.slice(1)) : source_default.inverse(" ");
71995
+ renderedValue = value.length > 0 ? "" : source_default.inverse(" ");
71996
+ let i = 0;
71997
+ for (const char of value) {
71998
+ renderedValue += i >= cursorOffset - cursorActualWidth && i <= cursorOffset ? source_default.inverse(char) : char;
71999
+ i++;
72000
+ }
72001
+ if (value.length > 0 && cursorOffset === value.length) {
72002
+ renderedValue += source_default.inverse(" ");
72003
+ }
72004
+ }
72005
+ use_input_default((input, key) => {
72006
+ if (key.upArrow || key.downArrow || key.ctrl && input === "c" || key.tab || key.shift && key.tab) {
72007
+ return;
72008
+ }
72009
+ if (key.return) {
72010
+ if (onSubmit) {
72011
+ onSubmit(originalValue);
72012
+ }
72013
+ return;
72014
+ }
72015
+ let nextCursorOffset = cursorOffset;
72016
+ let nextValue = originalValue;
72017
+ let nextCursorWidth = 0;
72018
+ if (key.leftArrow) {
72019
+ if (showCursor) {
72020
+ nextCursorOffset--;
72021
+ }
72022
+ } else if (key.rightArrow) {
72023
+ if (showCursor) {
72024
+ nextCursorOffset++;
72025
+ }
72026
+ } else if (key.backspace || key.delete) {
72027
+ if (cursorOffset > 0) {
72028
+ nextValue = originalValue.slice(0, cursorOffset - 1) + originalValue.slice(cursorOffset, originalValue.length);
72029
+ nextCursorOffset--;
72030
+ }
72031
+ } else {
72032
+ nextValue = originalValue.slice(0, cursorOffset) + input + originalValue.slice(cursorOffset, originalValue.length);
72033
+ nextCursorOffset += input.length;
72034
+ if (input.length > 1) {
72035
+ nextCursorWidth = input.length;
72036
+ }
72037
+ }
72038
+ if (cursorOffset < 0) {
72039
+ nextCursorOffset = 0;
72040
+ }
72041
+ if (cursorOffset > originalValue.length) {
72042
+ nextCursorOffset = originalValue.length;
72043
+ }
72044
+ setState({
72045
+ cursorOffset: nextCursorOffset,
72046
+ cursorWidth: nextCursorWidth
72047
+ });
72048
+ if (nextValue !== originalValue) {
72049
+ onChange(nextValue);
72050
+ }
72051
+ }, { isActive: focus });
72052
+ return import_react29.default.createElement(Text, null, placeholder ? value.length > 0 ? renderedValue : renderedPlaceholder : renderedValue);
72053
+ }
72054
+ var import_react29, build_default;
72055
+ var init_build3 = __esm({
72056
+ async "node_modules/.pnpm/ink-text-input@6.0.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-text-input/build/index.js"() {
72057
+ "use strict";
72058
+ import_react29 = __toESM(require_react(), 1);
72059
+ await init_build2();
72060
+ init_source2();
72061
+ build_default = TextInput;
72062
+ }
72063
+ });
72064
+
71928
72065
  // node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.production.js
71929
72066
  var require_react_jsx_runtime_production = __commonJS({
71930
72067
  "node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.production.js"(exports) {
@@ -72233,8 +72370,8 @@ var require_jsx_runtime = __commonJS({
72233
72370
 
72234
72371
  // apps/cli/src/ui/spinner.tsx
72235
72372
  function Spinner({ label }) {
72236
- const [frame, setFrame] = (0, import_react29.useState)(0);
72237
- (0, import_react29.useEffect)(() => {
72373
+ const [frame, setFrame] = (0, import_react30.useState)(0);
72374
+ (0, import_react30.useEffect)(() => {
72238
72375
  const id = setInterval(() => {
72239
72376
  setFrame((prev) => (prev + 1) % KITE_FRAMES.length);
72240
72377
  }, FRAME_INTERVAL_MS);
@@ -72246,11 +72383,11 @@ function Spinner({ label }) {
72246
72383
  label
72247
72384
  ] });
72248
72385
  }
72249
- var import_react29, import_jsx_runtime, KITE_FRAMES, FRAME_INTERVAL_MS;
72386
+ var import_react30, import_jsx_runtime, KITE_FRAMES, FRAME_INTERVAL_MS;
72250
72387
  var init_spinner = __esm({
72251
72388
  async "apps/cli/src/ui/spinner.tsx"() {
72252
72389
  "use strict";
72253
- import_react29 = __toESM(require_react(), 1);
72390
+ import_react30 = __toESM(require_react(), 1);
72254
72391
  await init_build2();
72255
72392
  import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
72256
72393
  KITE_FRAMES = [
@@ -72275,10 +72412,11 @@ function BrowserLoginProvider({
72275
72412
  loginRunner = login,
72276
72413
  isInteractive
72277
72414
  }) {
72278
- const [state, setState] = (0, import_react30.useState)(idleState);
72279
- const pendingConfirmationRef = (0, import_react30.useRef)(null);
72415
+ const [state, setState] = (0, import_react31.useState)(idleState);
72416
+ const pendingConfirmationRef = (0, import_react31.useRef)(null);
72417
+ const pendingManualTokenRef = (0, import_react31.useRef)(null);
72280
72418
  const shouldConfirm = isInteractive ?? isBrowserLoginConfirmationInteractive();
72281
- const confirmBrowserLoginStart = (0, import_react30.useCallback)(() => {
72419
+ const confirmBrowserLoginStart = (0, import_react31.useCallback)(() => {
72282
72420
  const pendingConfirmation = pendingConfirmationRef.current;
72283
72421
  if (pendingConfirmation === null) {
72284
72422
  return void 0;
@@ -72287,7 +72425,20 @@ function BrowserLoginProvider({
72287
72425
  pendingConfirmation.resolve(void 0);
72288
72426
  return void 0;
72289
72427
  }, []);
72290
- const runLogin2 = (0, import_react30.useCallback)(async () => {
72428
+ const submitManualClerkToken = (0, import_react31.useCallback)((clerkToken) => {
72429
+ const pendingManualToken = pendingManualTokenRef.current;
72430
+ if (pendingManualToken === null) {
72431
+ return void 0;
72432
+ }
72433
+ const trimmed = clerkToken.trim();
72434
+ if (trimmed.length === 0) {
72435
+ return void 0;
72436
+ }
72437
+ pendingManualTokenRef.current = null;
72438
+ pendingManualToken.resolve(trimmed);
72439
+ return void 0;
72440
+ }, []);
72441
+ const runLogin2 = (0, import_react31.useCallback)(async (passthroughOptions) => {
72291
72442
  if (pendingConfirmationRef.current !== null) {
72292
72443
  throw new Error("Browser login is already waiting for confirmation.");
72293
72444
  }
@@ -72304,15 +72455,42 @@ function BrowserLoginProvider({
72304
72455
  });
72305
72456
  }
72306
72457
  setState({ ...idleState, phase: "waiting" });
72458
+ const manualClerkToken = new Promise((resolve2, reject) => {
72459
+ pendingManualTokenRef.current = {
72460
+ resolve: resolve2,
72461
+ reject: (reason) => {
72462
+ reject(reason);
72463
+ return void 0;
72464
+ }
72465
+ };
72466
+ });
72467
+ manualClerkToken.catch(() => void 0);
72307
72468
  try {
72308
- const result = await loginRunner();
72469
+ const result = await loginRunner({
72470
+ ...passthroughOptions ?? {},
72471
+ manualClerkToken
72472
+ });
72309
72473
  const organizationName = result.organization.organizationName ?? result.organization.clerkOrgId;
72474
+ pendingManualTokenRef.current = null;
72475
+ const identity = {
72476
+ email: result.user.email,
72477
+ organizationName
72478
+ };
72479
+ if (result.source === "manual") {
72480
+ setState({
72481
+ phase: "finalizing",
72482
+ identity,
72483
+ errorMessage: ""
72484
+ });
72485
+ await new Promise((resolve2) => {
72486
+ setTimeout(() => {
72487
+ resolve2(void 0);
72488
+ }, MANUAL_PASTE_FINALIZING_MS);
72489
+ });
72490
+ }
72310
72491
  setState({
72311
72492
  phase: "success",
72312
- identity: {
72313
- email: result.user.email,
72314
- organizationName
72315
- },
72493
+ identity,
72316
72494
  errorMessage: ""
72317
72495
  });
72318
72496
  return result;
@@ -72321,6 +72499,7 @@ function BrowserLoginProvider({
72321
72499
  error48,
72322
72500
  "An unexpected error occurred."
72323
72501
  );
72502
+ pendingManualTokenRef.current = null;
72324
72503
  setState({
72325
72504
  phase: "error",
72326
72505
  identity: null,
@@ -72329,37 +72508,45 @@ function BrowserLoginProvider({
72329
72508
  throw concreteError;
72330
72509
  }
72331
72510
  }, [loginRunner, shouldConfirm]);
72332
- (0, import_react30.useEffect)(() => {
72511
+ (0, import_react31.useEffect)(() => {
72333
72512
  return () => {
72334
72513
  const pendingConfirmation = pendingConfirmationRef.current;
72335
- if (pendingConfirmation === null) {
72336
- return;
72514
+ if (pendingConfirmation !== null) {
72515
+ pendingConfirmationRef.current = null;
72516
+ pendingConfirmation.reject(
72517
+ new Error("Browser login confirmation was interrupted.")
72518
+ );
72519
+ }
72520
+ const pendingManualToken = pendingManualTokenRef.current;
72521
+ if (pendingManualToken !== null) {
72522
+ pendingManualTokenRef.current = null;
72523
+ pendingManualToken.reject(
72524
+ new Error("Browser login manual paste was interrupted.")
72525
+ );
72337
72526
  }
72338
- pendingConfirmationRef.current = null;
72339
- pendingConfirmation.reject(
72340
- new Error("Browser login confirmation was interrupted.")
72341
- );
72342
72527
  };
72343
72528
  }, []);
72344
- const value = (0, import_react30.useMemo)(
72529
+ const value = (0, import_react31.useMemo)(
72345
72530
  () => ({
72346
72531
  runLogin: runLogin2,
72347
72532
  state,
72348
- confirmBrowserLoginStart
72533
+ confirmBrowserLoginStart,
72534
+ submitManualClerkToken
72349
72535
  }),
72350
- [confirmBrowserLoginStart, runLogin2, state]
72536
+ [confirmBrowserLoginStart, runLogin2, state, submitManualClerkToken]
72351
72537
  );
72352
72538
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BrowserLoginContext.Provider, { value, children });
72353
72539
  }
72354
72540
  function useBrowserLogin() {
72355
- const context = (0, import_react30.useContext)(BrowserLoginContext);
72541
+ const context = (0, import_react31.useContext)(BrowserLoginContext);
72356
72542
  if (context === null) {
72357
72543
  throw new Error("useBrowserLogin must be used inside BrowserLoginProvider.");
72358
72544
  }
72359
72545
  return context;
72360
72546
  }
72361
72547
  function BrowserLoginConfirmation() {
72362
- const { state, confirmBrowserLoginStart } = useBrowserLogin();
72548
+ const { state, confirmBrowserLoginStart, submitManualClerkToken } = useBrowserLogin();
72549
+ const [manualTokenInput, setManualTokenInput] = (0, import_react31.useState)("");
72363
72550
  use_input_default((_input, key) => {
72364
72551
  if (state.phase === "confirming" && key.return) {
72365
72552
  confirmBrowserLoginStart();
@@ -72375,7 +72562,44 @@ function BrowserLoginConfirmation() {
72375
72562
  ] });
72376
72563
  }
72377
72564
  if (state.phase === "waiting") {
72378
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, { label: "\u{1FA81} Waiting for browser sign-in\u2026" }) });
72565
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
72566
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, { label: "\u{1FA81} Waiting for browser sign-in\u2026" }),
72567
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
72568
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "gray", children: BROWSER_LOGIN_MANUAL_PASTE_LABEL }),
72569
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { children: [
72570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
72571
+ ">",
72572
+ " "
72573
+ ] }),
72574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
72575
+ build_default,
72576
+ {
72577
+ value: manualTokenInput,
72578
+ onChange: setManualTokenInput,
72579
+ onSubmit: (value) => {
72580
+ submitManualClerkToken(value);
72581
+ setManualTokenInput("");
72582
+ },
72583
+ placeholder: "paste code and press Enter"
72584
+ }
72585
+ )
72586
+ ] })
72587
+ ] })
72588
+ ] });
72589
+ }
72590
+ if (state.phase === "finalizing" && state.identity !== null) {
72591
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
72592
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "green", children: "Logged in successfully!" }),
72593
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
72594
+ "Email: ",
72595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, children: state.identity.email })
72596
+ ] }),
72597
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
72598
+ "Organization: ",
72599
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, children: state.identity.organizationName })
72600
+ ] }),
72601
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, { label: "Wrapping up..." }) })
72602
+ ] });
72379
72603
  }
72380
72604
  if (state.phase === "success" && state.identity !== null) {
72381
72605
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
@@ -72395,24 +72619,27 @@ function BrowserLoginConfirmation() {
72395
72619
  state.errorMessage
72396
72620
  ] }) });
72397
72621
  }
72398
- var import_react30, import_jsx_runtime2, BROWSER_LOGIN_CONFIRMATION_MESSAGE, BROWSER_LOGIN_CONFIRMATION_PROMPT, idleState, BrowserLoginContext;
72622
+ var import_react31, import_jsx_runtime2, BROWSER_LOGIN_CONFIRMATION_MESSAGE, BROWSER_LOGIN_CONFIRMATION_PROMPT, MANUAL_PASTE_FINALIZING_MS, idleState, BrowserLoginContext, BROWSER_LOGIN_MANUAL_PASTE_LABEL;
72399
72623
  var init_browser_login = __esm({
72400
72624
  async "apps/cli/src/ui/browser-login.tsx"() {
72401
72625
  "use strict";
72402
- import_react30 = __toESM(require_react(), 1);
72626
+ import_react31 = __toESM(require_react(), 1);
72403
72627
  await init_build2();
72628
+ await init_build3();
72404
72629
  init_auth_service();
72405
72630
  init_cli_auth_diagnostics();
72406
72631
  await init_spinner();
72407
72632
  import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
72408
72633
  BROWSER_LOGIN_CONFIRMATION_MESSAGE = "Sign in to your \u{1FA81} CopilotKit account in your browser.";
72409
72634
  BROWSER_LOGIN_CONFIRMATION_PROMPT = "Press Enter to continue...";
72635
+ MANUAL_PASTE_FINALIZING_MS = 6e3;
72410
72636
  idleState = {
72411
72637
  phase: "idle",
72412
72638
  identity: null,
72413
72639
  errorMessage: ""
72414
72640
  };
72415
- BrowserLoginContext = (0, import_react30.createContext)(null);
72641
+ BrowserLoginContext = (0, import_react31.createContext)(null);
72642
+ BROWSER_LOGIN_MANUAL_PASTE_LABEL = "If your browser finished sign-in but the CLI didn't notice, paste the code shown in the browser:";
72416
72643
  }
72417
72644
  });
72418
72645
 
@@ -72518,10 +72745,10 @@ function formatLicenseList(scope, licenses) {
72518
72745
  function LicenseCreateApp({ onIssued }) {
72519
72746
  const { exit } = use_app_default();
72520
72747
  const browserLogin = useBrowserLogin();
72521
- const [phase, setPhase] = (0, import_react31.useState)("auth");
72522
- const [errorMessage, setErrorMessage] = (0, import_react31.useState)("");
72523
- const [authMessage, setAuthMessage] = (0, import_react31.useState)("");
72524
- (0, import_react31.useEffect)(() => {
72748
+ const [phase, setPhase] = (0, import_react32.useState)("auth");
72749
+ const [errorMessage, setErrorMessage] = (0, import_react32.useState)("");
72750
+ const [authMessage, setAuthMessage] = (0, import_react32.useState)("");
72751
+ (0, import_react32.useEffect)(() => {
72525
72752
  let cancelled = false;
72526
72753
  async function run() {
72527
72754
  setPhase("auth");
@@ -72634,11 +72861,11 @@ async function runLicense(command) {
72634
72861
  `);
72635
72862
  }
72636
72863
  }
72637
- var import_react31, import_jsx_runtime3;
72864
+ var import_react32, import_jsx_runtime3;
72638
72865
  var init_license = __esm({
72639
72866
  async "apps/cli/src/commands/license.tsx"() {
72640
72867
  "use strict";
72641
- import_react31 = __toESM(require_react(), 1);
72868
+ import_react32 = __toESM(require_react(), 1);
72642
72869
  await init_build2();
72643
72870
  await init_build2();
72644
72871
  init_auth_service();
@@ -73740,13 +73967,13 @@ var init_figures = __esm({
73740
73967
 
73741
73968
  // node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/Indicator.js
73742
73969
  function Indicator({ isSelected = false }) {
73743
- return import_react32.default.createElement(Box_default, { marginRight: 1 }, isSelected ? import_react32.default.createElement(Text, { color: "blue" }, figures_default.pointer) : import_react32.default.createElement(Text, null, " "));
73970
+ return import_react33.default.createElement(Box_default, { marginRight: 1 }, isSelected ? import_react33.default.createElement(Text, { color: "blue" }, figures_default.pointer) : import_react33.default.createElement(Text, null, " "));
73744
73971
  }
73745
- var import_react32, Indicator_default;
73972
+ var import_react33, Indicator_default;
73746
73973
  var init_Indicator = __esm({
73747
73974
  async "node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/Indicator.js"() {
73748
73975
  "use strict";
73749
- import_react32 = __toESM(require_react(), 1);
73976
+ import_react33 = __toESM(require_react(), 1);
73750
73977
  await init_build2();
73751
73978
  init_figures();
73752
73979
  Indicator_default = Indicator;
@@ -73755,13 +73982,13 @@ var init_Indicator = __esm({
73755
73982
 
73756
73983
  // node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/Item.js
73757
73984
  function Item({ isSelected = false, label }) {
73758
- return React12.createElement(Text, { color: isSelected ? "blue" : void 0 }, label);
73985
+ return React13.createElement(Text, { color: isSelected ? "blue" : void 0 }, label);
73759
73986
  }
73760
- var React12, Item_default;
73987
+ var React13, Item_default;
73761
73988
  var init_Item = __esm({
73762
73989
  async "node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/Item.js"() {
73763
73990
  "use strict";
73764
- React12 = __toESM(require_react(), 1);
73991
+ React13 = __toESM(require_react(), 1);
73765
73992
  await init_build2();
73766
73993
  Item_default = Item;
73767
73994
  }
@@ -73800,17 +74027,17 @@ function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicator
73800
74027
  const hasLimit = typeof customLimit === "number" && items.length > customLimit;
73801
74028
  const limit = hasLimit ? Math.min(customLimit, items.length) : items.length;
73802
74029
  const lastIndex = limit - 1;
73803
- const [rotateIndex, setRotateIndex] = (0, import_react33.useState)(initialIndex > lastIndex ? lastIndex - initialIndex : 0);
73804
- const [selectedIndex, setSelectedIndex] = (0, import_react33.useState)(initialIndex ? initialIndex > lastIndex ? lastIndex : initialIndex : 0);
73805
- const previousItems = (0, import_react33.useRef)(items);
73806
- (0, import_react33.useEffect)(() => {
74030
+ const [rotateIndex, setRotateIndex] = (0, import_react34.useState)(initialIndex > lastIndex ? lastIndex - initialIndex : 0);
74031
+ const [selectedIndex, setSelectedIndex] = (0, import_react34.useState)(initialIndex ? initialIndex > lastIndex ? lastIndex : initialIndex : 0);
74032
+ const previousItems = (0, import_react34.useRef)(items);
74033
+ (0, import_react34.useEffect)(() => {
73807
74034
  if (!isDeepStrictEqual2(previousItems.current.map((item) => item.value), items.map((item) => item.value))) {
73808
74035
  setRotateIndex(0);
73809
74036
  setSelectedIndex(0);
73810
74037
  }
73811
74038
  previousItems.current = items;
73812
74039
  }, [items]);
73813
- use_input_default((0, import_react33.useCallback)((input, key) => {
74040
+ use_input_default((0, import_react34.useCallback)((input, key) => {
73814
74041
  if (input === "k" || key.upArrow) {
73815
74042
  const lastIndex2 = (hasLimit ? limit : items.length) - 1;
73816
74043
  const atFirstIndex = selectedIndex === 0;
@@ -73862,24 +74089,24 @@ function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicator
73862
74089
  onHighlight
73863
74090
  ]), { isActive: isFocused });
73864
74091
  const slicedItems = hasLimit ? toRotated(items, rotateIndex).slice(0, limit) : items;
73865
- return import_react33.default.createElement(Box_default, { flexDirection: "column" }, slicedItems.map((item, index) => {
74092
+ return import_react34.default.createElement(Box_default, { flexDirection: "column" }, slicedItems.map((item, index) => {
73866
74093
  const isSelected = index === selectedIndex;
73867
74094
  return (
73868
74095
  // @ts-expect-error - `key` can't be optional but `item.value` is generic T
73869
- import_react33.default.createElement(
74096
+ import_react34.default.createElement(
73870
74097
  Box_default,
73871
74098
  { key: item.key ?? item.value },
73872
- import_react33.default.createElement(indicatorComponent, { isSelected }),
73873
- import_react33.default.createElement(itemComponent, { ...item, isSelected })
74099
+ import_react34.default.createElement(indicatorComponent, { isSelected }),
74100
+ import_react34.default.createElement(itemComponent, { ...item, isSelected })
73874
74101
  )
73875
74102
  );
73876
74103
  }));
73877
74104
  }
73878
- var import_react33, SelectInput_default;
74105
+ var import_react34, SelectInput_default;
73879
74106
  var init_SelectInput = __esm({
73880
74107
  async "node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/SelectInput.js"() {
73881
74108
  "use strict";
73882
- import_react33 = __toESM(require_react(), 1);
74109
+ import_react34 = __toESM(require_react(), 1);
73883
74110
  init_to_rotated();
73884
74111
  await init_build2();
73885
74112
  await init_Indicator();
@@ -73889,7 +74116,7 @@ var init_SelectInput = __esm({
73889
74116
  });
73890
74117
 
73891
74118
  // node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/index.js
73892
- var init_build3 = __esm({
74119
+ var init_build4 = __esm({
73893
74120
  async "node_modules/.pnpm/ink-select-input@6.2.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-select-input/build/index.js"() {
73894
74121
  "use strict";
73895
74122
  await init_Indicator();
@@ -73898,104 +74125,6 @@ var init_build3 = __esm({
73898
74125
  }
73899
74126
  });
73900
74127
 
73901
- // node_modules/.pnpm/ink-text-input@6.0.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-text-input/build/index.js
73902
- function TextInput({ value: originalValue, placeholder = "", focus = true, mask, highlightPastedText = false, showCursor = true, onChange, onSubmit }) {
73903
- const [state, setState] = (0, import_react34.useState)({
73904
- cursorOffset: (originalValue || "").length,
73905
- cursorWidth: 0
73906
- });
73907
- const { cursorOffset, cursorWidth } = state;
73908
- (0, import_react34.useEffect)(() => {
73909
- setState((previousState) => {
73910
- if (!focus || !showCursor) {
73911
- return previousState;
73912
- }
73913
- const newValue = originalValue || "";
73914
- if (previousState.cursorOffset > newValue.length - 1) {
73915
- return {
73916
- cursorOffset: newValue.length,
73917
- cursorWidth: 0
73918
- };
73919
- }
73920
- return previousState;
73921
- });
73922
- }, [originalValue, focus, showCursor]);
73923
- const cursorActualWidth = highlightPastedText ? cursorWidth : 0;
73924
- const value = mask ? mask.repeat(originalValue.length) : originalValue;
73925
- let renderedValue = value;
73926
- let renderedPlaceholder = placeholder ? source_default.grey(placeholder) : void 0;
73927
- if (showCursor && focus) {
73928
- renderedPlaceholder = placeholder.length > 0 ? source_default.inverse(placeholder[0]) + source_default.grey(placeholder.slice(1)) : source_default.inverse(" ");
73929
- renderedValue = value.length > 0 ? "" : source_default.inverse(" ");
73930
- let i = 0;
73931
- for (const char of value) {
73932
- renderedValue += i >= cursorOffset - cursorActualWidth && i <= cursorOffset ? source_default.inverse(char) : char;
73933
- i++;
73934
- }
73935
- if (value.length > 0 && cursorOffset === value.length) {
73936
- renderedValue += source_default.inverse(" ");
73937
- }
73938
- }
73939
- use_input_default((input, key) => {
73940
- if (key.upArrow || key.downArrow || key.ctrl && input === "c" || key.tab || key.shift && key.tab) {
73941
- return;
73942
- }
73943
- if (key.return) {
73944
- if (onSubmit) {
73945
- onSubmit(originalValue);
73946
- }
73947
- return;
73948
- }
73949
- let nextCursorOffset = cursorOffset;
73950
- let nextValue = originalValue;
73951
- let nextCursorWidth = 0;
73952
- if (key.leftArrow) {
73953
- if (showCursor) {
73954
- nextCursorOffset--;
73955
- }
73956
- } else if (key.rightArrow) {
73957
- if (showCursor) {
73958
- nextCursorOffset++;
73959
- }
73960
- } else if (key.backspace || key.delete) {
73961
- if (cursorOffset > 0) {
73962
- nextValue = originalValue.slice(0, cursorOffset - 1) + originalValue.slice(cursorOffset, originalValue.length);
73963
- nextCursorOffset--;
73964
- }
73965
- } else {
73966
- nextValue = originalValue.slice(0, cursorOffset) + input + originalValue.slice(cursorOffset, originalValue.length);
73967
- nextCursorOffset += input.length;
73968
- if (input.length > 1) {
73969
- nextCursorWidth = input.length;
73970
- }
73971
- }
73972
- if (cursorOffset < 0) {
73973
- nextCursorOffset = 0;
73974
- }
73975
- if (cursorOffset > originalValue.length) {
73976
- nextCursorOffset = originalValue.length;
73977
- }
73978
- setState({
73979
- cursorOffset: nextCursorOffset,
73980
- cursorWidth: nextCursorWidth
73981
- });
73982
- if (nextValue !== originalValue) {
73983
- onChange(nextValue);
73984
- }
73985
- }, { isActive: focus });
73986
- return import_react34.default.createElement(Text, null, placeholder ? value.length > 0 ? renderedValue : renderedPlaceholder : renderedValue);
73987
- }
73988
- var import_react34, build_default;
73989
- var init_build4 = __esm({
73990
- async "node_modules/.pnpm/ink-text-input@6.0.0_ink@6.8.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-text-input/build/index.js"() {
73991
- "use strict";
73992
- import_react34 = __toESM(require_react(), 1);
73993
- await init_build2();
73994
- init_source2();
73995
- build_default = TextInput;
73996
- }
73997
- });
73998
-
73999
74128
  // apps/cli/src/ui/init-flow.tsx
74000
74129
  function validateName(name) {
74001
74130
  if (name.length === 0)
@@ -74139,8 +74268,8 @@ var init_init_flow = __esm({
74139
74268
  "use strict";
74140
74269
  import_react35 = __toESM(require_react(), 1);
74141
74270
  await init_build2();
74142
- await init_build3();
74143
74271
  await init_build4();
74272
+ await init_build3();
74144
74273
  init_types();
74145
74274
  import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
74146
74275
  PROJECT_NAME_RE = /^[a-z0-9-]{1,30}$/;
@@ -74199,42 +74328,33 @@ function buildInitNextSteps(templateDefinition, projectName, result) {
74199
74328
  const envTarget = result.envCreatedFromExample || result.licenseWritten ? "the scaffolded .env file" : ".env";
74200
74329
  return `Set ${envKey.key} in ${envTarget}. ${envKey.note}`;
74201
74330
  });
74202
- const commandPrefix = `cd ${projectName}`;
74203
- const steps = [`Directory: ${result.projectDir}`];
74204
74331
  const setupMissing = missingPrerequisites.filter(
74205
74332
  (prerequisite) => prerequisite.phase === "setup"
74206
74333
  );
74207
- if (missingPrerequisites.length > 0) {
74208
- for (const prerequisite of missingPrerequisites) {
74209
- steps.push(`Missing ${prerequisite.label}: ${prerequisite.installHint}`);
74210
- }
74211
- }
74212
- if (setupMissing.length > 0) {
74213
- steps.push(
74214
- `After installing setup prerequisites, run: ${commandPrefix} && ${templateDefinition.installCommand}`
74215
- );
74216
- } else {
74217
- steps.push(
74218
- `Install: ${commandPrefix} && ${templateDefinition.installCommand}`
74219
- );
74220
- }
74221
- for (const postInstallCommand of templateDefinition.postInstallCommands ?? []) {
74222
- const label = setupMissing.length > 0 ? "Then run" : "Setup";
74223
- steps.push(`${label}: ${commandPrefix} && ${postInstallCommand}`);
74334
+ const runtimeMissing = missingPrerequisites.filter(
74335
+ (prerequisite) => prerequisite.phase === "runtime"
74336
+ );
74337
+ const steps = [`Directory: ${result.projectDir}`];
74338
+ for (const prerequisite of missingPrerequisites) {
74339
+ steps.push(`Missing ${prerequisite.label}: ${prerequisite.installHint}`);
74224
74340
  }
74225
74341
  for (const envNote of envNotes) {
74226
74342
  steps.push(envNote);
74227
74343
  }
74228
- const runtimeMissing = missingPrerequisites.filter(
74229
- (prerequisite) => prerequisite.phase === "runtime"
74230
- );
74231
- if (runtimeMissing.length === 0) {
74232
- steps.push(`Run: ${commandPrefix} && ${templateDefinition.runCommand}`);
74233
- } else {
74234
- steps.push(
74235
- `After runtime prerequisites are ready, run: ${commandPrefix} && ${templateDefinition.runCommand}`
74236
- );
74344
+ let header = "Run these commands:";
74345
+ if (setupMissing.length > 0) {
74346
+ header = "After installing setup prerequisites, run:";
74347
+ } else if (runtimeMissing.length > 0) {
74348
+ header = "After runtime prerequisites are ready, run:";
74349
+ }
74350
+ steps.push(header);
74351
+ steps.push(` cd ${projectName}`);
74352
+ steps.push(` ${templateDefinition.installCommand}`);
74353
+ for (const postInstallCommand of templateDefinition.postInstallCommands ?? []) {
74354
+ const formatted = postInstallCommand.startsWith("cd ") ? `(${postInstallCommand})` : postInstallCommand;
74355
+ steps.push(` ${formatted}`);
74237
74356
  }
74357
+ steps.push(` ${templateDefinition.runCommand}`);
74238
74358
  return steps;
74239
74359
  }
74240
74360
  async function ensureCliToken2(dependencies, onTerminalSessionInvalidation) {
@@ -74426,7 +74546,7 @@ function ScaffoldProgress({ options }) {
74426
74546
  options.name,
74427
74547
  '" created successfully!'
74428
74548
  ] }),
74429
- nextSteps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: "gray", children: step }, step))
74549
+ nextSteps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: "gray", children: step }, `step-${index}`))
74430
74550
  ] });
74431
74551
  }
74432
74552
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: "red", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotkit",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "copilotkit": "./index.js"
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/init.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,WAAW,EACX,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAEL,KAAK,EAEL,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAIf,cAAc,EACf,MAAM,iCAAiC,CAAC;AAWzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAk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AO,cAAc,CAAC;IACtC,iEAAiE;IACjE,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,kEAAkE;IAClE,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,0EAA0E;IAC1E,iBAAiB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;CACpD;AAiBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,sBAAsB,EAC1C,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,kBAAkB,GACzB,MAAM,EAAE,CAqDV;AA0FD;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,YAAY,GAAE,wBAA0D,EACxE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,EAC5E,6BAA6B,CAAC,EAAE,MAAM,IAAI,GACzC,OAAO,CAAC,kBAAkB,CAAC,CA0D7B;AAyND;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB7D"}
@@ -30,6 +30,37 @@ export declare function startCallbackServer(expectedState: string): Promise<{
30
30
  resultPromise: Promise<CallbackResult>;
31
31
  server: http.Server;
32
32
  }>;
33
+ /**
34
+ * Origin of the Clerk token resolved during a CLI login attempt.
35
+ */
36
+ export type ClerkTokenSource = "callback" | "manual";
37
+ /**
38
+ * Races the loopback callback against an optional manual paste promise so
39
+ * either path can complete the login flow.
40
+ *
41
+ * Both inputs are guarded with rejection handlers because the loser may stay
42
+ * pending or reject after the winner is consumed; a hanging or rejected loser
43
+ * must not produce an unhandled rejection or block cleanup.
44
+ *
45
+ * @param resultPromise - Loopback callback result for the CLI auth state.
46
+ * @param manualClerkToken - Optional manual paste promise.
47
+ * @returns The resolved Clerk token and the path that produced it.
48
+ */
49
+ export declare function raceForClerkToken(resultPromise: Promise<CallbackResult>, manualClerkToken: Promise<string> | undefined): Promise<{
50
+ clerkToken: string;
51
+ source: ClerkTokenSource;
52
+ }>;
53
+ /**
54
+ * Optional inputs that adjust how {@link login} resolves the Clerk token.
55
+ */
56
+ export interface LoginOptions {
57
+ /**
58
+ * Promise that resolves with a manually pasted Clerk token. Races against
59
+ * the loopback callback so the CLI can recover when the browser redirect
60
+ * never reaches the local callback server.
61
+ */
62
+ manualClerkToken?: Promise<string>;
63
+ }
33
64
  /**
34
65
  * Launches the browser-based login flow, waits for the callback, exchanges
35
66
  * the Clerk token for a CLI session token, persists the credentials, and
@@ -39,13 +70,15 @@ export declare function startCallbackServer(expectedState: string): Promise<{
39
70
  * 1. Generate a random CSRF state token.
40
71
  * 2. Start a local callback server.
41
72
  * 3. Open the browser to the ops-frontend CLI auth page.
42
- * 4. Wait for the callback with the Clerk token.
73
+ * 4. Wait for the callback with the Clerk token, or accept a manually pasted
74
+ * token from {@link LoginOptions.manualClerkToken} when supplied.
43
75
  * 5. Exchange the Clerk token for a CLI session via ops-api.
44
76
  * 6. Persist credentials to the auth store.
45
77
  *
78
+ * @param options - Optional login overrides such as a manual paste token.
46
79
  * @returns The authenticated user and organization from the ops-api response.
47
80
  */
48
- export declare function login(): Promise<{
81
+ export declare function login(options?: LoginOptions): Promise<{
49
82
  user: {
50
83
  id: string;
51
84
  email: string;
@@ -55,6 +88,7 @@ export declare function login(): Promise<{
55
88
  clerkOrgId: string;
56
89
  organizationName?: string;
57
90
  };
91
+ source: ClerkTokenSource;
58
92
  }>;
59
93
  export interface VerifyAndRefreshOptions {
60
94
  /** When true, preserve the specific auth/session error instead of returning null. */
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/services/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AASlE,OAAO,KAAK,EAAE,qB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EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC,CAiID;AAED,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,oFACsC,CAAC;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,cAAc,CAOzB;AAED;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO9E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CA2BvC;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAa5C"}
@@ -7,7 +7,7 @@ export declare const BROWSER_LOGIN_CONFIRMATION_PROMPT = "Press Enter to continu
7
7
  /** Browser login function shape shared by command flows. */
8
8
  export type BrowserLoginRunner = typeof defaultLogin;
9
9
  /** Rendered state for the shared browser-login interaction. */
10
- export type BrowserLoginPhase = "idle" | "confirming" | "waiting" | "success" | "error";
10
+ export type BrowserLoginPhase = "idle" | "confirming" | "waiting" | "finalizing" | "success" | "error";
11
11
  /** User and organization data displayed after a successful login. */
12
12
  export interface BrowserLoginIdentity {
13
13
  /** Authenticated user email. */
@@ -32,6 +32,8 @@ export interface BrowserLoginContextValue {
32
32
  state: BrowserLoginState;
33
33
  /** Confirms that the browser login may begin. */
34
34
  confirmBrowserLoginStart: () => unknown;
35
+ /** Submits a manually pasted Clerk token to complete login when the loopback callback never fires. */
36
+ submitManualClerkToken: (clerkToken: string) => unknown;
35
37
  }
36
38
  /** Props for {@link BrowserLoginProvider}. */
37
39
  export interface BrowserLoginProviderProps {
@@ -62,6 +64,8 @@ export declare function BrowserLoginProvider({ children, loginRunner, isInteract
62
64
  * @throws When rendered outside {@link BrowserLoginProvider}.
63
65
  */
64
66
  export declare function useBrowserLogin(): BrowserLoginContextValue;
67
+ /** Hint shown beneath the spinner so users know about the manual paste fallback. */
68
+ export declare const BROWSER_LOGIN_MANUAL_PASTE_LABEL = "If your browser finished sign-in but the CLI didn't notice, paste the code shown in the browser:";
65
69
  /**
66
70
  * Renders the shared browser-login confirmation and result states.
67
71
  *
@@ -1 +1 @@
1
- {"version":3,"file":"browser-login.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/ui/browser-login.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAIpE,yEAAyE;AACzE,eAAO,MAAM,kCAAkC,qEACW,CAAC;AAE3D,oDAAoD;AACpD,eAAO,MAAM,iCAAiC,+BAChB,CAAC;AAE/B,4DAA4D;AAC5D,MAAM,MAAM,kBAAkB,GAAG,OAAO,YAAY,CAAC;AAErD,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,KAAK,EAAE,iBAAiB,CAAC;IACzB,uDAAuD;IACvD,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACtC,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,6DAA6D;AAC7D,MAAM,WAAW,wBAAwB;IACvC,mFAAmF;IACnF,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,sCAAsC;IACtC,KAAK,EAAE,iBAAiB,CAAC;IACzB,iDAAiD;IACjD,wBAAwB,EAAE,MAAM,OAAO,CAAC;CACzC;AAED,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,QAAQ,EAAE,SAAS,CAAC;IACpB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAmBD;;;;GAIG;AACH,wBAAgB,qCAAqC,IAAI,OAAO,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,WAA0B,EAC1B,aAAa,GACd,EAAE,yBAAyB,GAAG,YAAY,CA4F1C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,wBAAwB,CAO1D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,YAAY,GAAG,IAAI,CAiD9D"}
1
+ {"version":3,"file":"browser-login.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/ui/browser-login.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAIpE,yEAAyE;AACzE,eAAO,MAAM,kCAAkC,qEACW,CAAC;AAE3D,oDAAoD;AACpD,eAAO,MAAM,iCAAiC,+BAChB,CAAC;AAE/B,4DAA4D;AAC5D,MAAM,MAAM,kBAAkB,GAAG,OAAO,YAAY,CAAC;AAErD,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,SAAS,GACT,OAAO,CAAC;AAUZ,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,gBAA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