copilotkit 2.0.2 → 2.0.4
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 +909 -326
- package/package.json +1 -1
- package/src/commands/init.d.ts +39 -0
- package/src/commands/init.d.ts.map +1 -1
- package/src/commands/license.d.ts +8 -0
- package/src/commands/license.d.ts.map +1 -1
- package/src/services/auth.service.d.ts +36 -2
- package/src/services/auth.service.d.ts.map +1 -1
- package/src/services/cli-tips.d.ts +45 -0
- package/src/services/cli-tips.d.ts.map +1 -0
- package/src/ui/browser-login.d.ts +5 -1
- package/src/ui/browser-login.d.ts.map +1 -1
- package/src/ui/cli-tip.d.ts +111 -0
- package/src/ui/cli-tip.d.ts.map +1 -0
package/index.js
CHANGED
|
@@ -63,9 +63,9 @@ function setOpsFrontendUrl(url2) {
|
|
|
63
63
|
}
|
|
64
64
|
function getBuildInfo() {
|
|
65
65
|
return {
|
|
66
|
-
version: "2.0.
|
|
67
|
-
buildNumber: "
|
|
68
|
-
commitSha: "
|
|
66
|
+
version: "2.0.4",
|
|
67
|
+
buildNumber: "25565986307",
|
|
68
|
+
commitSha: "b30c431cac977de7dc0637d19bbe914b6bb1248d"
|
|
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
|
|
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
|
|
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 {
|
|
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
|
-
|
|
17077
|
-
|
|
17078
|
-
|
|
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
|
});
|
|
@@ -50356,7 +50395,7 @@ var require_backend = __commonJS({
|
|
|
50356
50395
|
});
|
|
50357
50396
|
return value;
|
|
50358
50397
|
},
|
|
50359
|
-
useEffect: function
|
|
50398
|
+
useEffect: function useEffect14(create3) {
|
|
50360
50399
|
nextHook();
|
|
50361
50400
|
hookLog.push({
|
|
50362
50401
|
displayName: null,
|
|
@@ -50402,7 +50441,7 @@ var require_backend = __commonJS({
|
|
|
50402
50441
|
dispatcherHookName: "InsertionEffect"
|
|
50403
50442
|
});
|
|
50404
50443
|
},
|
|
50405
|
-
useMemo: function
|
|
50444
|
+
useMemo: function useMemo8(nextCreate) {
|
|
50406
50445
|
var hook = nextHook();
|
|
50407
50446
|
nextCreate = null !== hook ? hook.memoizedState[0] : nextCreate();
|
|
50408
50447
|
hookLog.push({
|
|
@@ -50444,7 +50483,7 @@ var require_backend = __commonJS({
|
|
|
50444
50483
|
});
|
|
50445
50484
|
return initialValue;
|
|
50446
50485
|
},
|
|
50447
|
-
useState: function
|
|
50486
|
+
useState: function useState12(initialState) {
|
|
50448
50487
|
var hook = nextHook();
|
|
50449
50488
|
initialState = null !== hook ? hook.memoizedState : "function" === typeof initialState ? initialState() : initialState;
|
|
50450
50489
|
hookLog.push({
|
|
@@ -60079,7 +60118,7 @@ var require_backend = __commonJS({
|
|
|
60079
60118
|
var symbolOrNumber = renderer_typeof(type) === "object" && type !== null ? type.$$typeof : type;
|
|
60080
60119
|
return renderer_typeof(symbolOrNumber) === "symbol" ? symbolOrNumber.toString() : symbolOrNumber;
|
|
60081
60120
|
}
|
|
60082
|
-
var _ReactTypeOfWork = ReactTypeOfWork, CacheComponent = _ReactTypeOfWork.CacheComponent, ClassComponent = _ReactTypeOfWork.ClassComponent, IncompleteClassComponent = _ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = _ReactTypeOfWork.IncompleteFunctionComponent, FunctionComponent = _ReactTypeOfWork.FunctionComponent, IndeterminateComponent = _ReactTypeOfWork.IndeterminateComponent, ForwardRef = _ReactTypeOfWork.ForwardRef, HostRoot = _ReactTypeOfWork.HostRoot, HostHoistable = _ReactTypeOfWork.HostHoistable, HostSingleton = _ReactTypeOfWork.HostSingleton, HostComponent = _ReactTypeOfWork.HostComponent, HostPortal = _ReactTypeOfWork.HostPortal, HostText = _ReactTypeOfWork.HostText,
|
|
60121
|
+
var _ReactTypeOfWork = ReactTypeOfWork, CacheComponent = _ReactTypeOfWork.CacheComponent, ClassComponent = _ReactTypeOfWork.ClassComponent, IncompleteClassComponent = _ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = _ReactTypeOfWork.IncompleteFunctionComponent, FunctionComponent = _ReactTypeOfWork.FunctionComponent, IndeterminateComponent = _ReactTypeOfWork.IndeterminateComponent, ForwardRef = _ReactTypeOfWork.ForwardRef, HostRoot = _ReactTypeOfWork.HostRoot, HostHoistable = _ReactTypeOfWork.HostHoistable, HostSingleton = _ReactTypeOfWork.HostSingleton, HostComponent = _ReactTypeOfWork.HostComponent, HostPortal = _ReactTypeOfWork.HostPortal, HostText = _ReactTypeOfWork.HostText, Fragment2 = _ReactTypeOfWork.Fragment, LazyComponent = _ReactTypeOfWork.LazyComponent, LegacyHiddenComponent = _ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = _ReactTypeOfWork.MemoComponent, OffscreenComponent = _ReactTypeOfWork.OffscreenComponent, Profiler = _ReactTypeOfWork.Profiler, ScopeComponent = _ReactTypeOfWork.ScopeComponent, SimpleMemoComponent = _ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = _ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = _ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = _ReactTypeOfWork.TracingMarkerComponent, Throw = _ReactTypeOfWork.Throw, ViewTransitionComponent = _ReactTypeOfWork.ViewTransitionComponent, ActivityComponent = _ReactTypeOfWork.ActivityComponent;
|
|
60083
60122
|
function resolveFiberType(type) {
|
|
60084
60123
|
var typeSymbol = getTypeSymbol(type);
|
|
60085
60124
|
switch (typeSymbol) {
|
|
@@ -60135,7 +60174,7 @@ var require_backend = __commonJS({
|
|
|
60135
60174
|
case HostPortal:
|
|
60136
60175
|
case HostText:
|
|
60137
60176
|
return null;
|
|
60138
|
-
case
|
|
60177
|
+
case Fragment2:
|
|
60139
60178
|
return "Fragment";
|
|
60140
60179
|
case LazyComponent:
|
|
60141
60180
|
return "Lazy";
|
|
@@ -60290,7 +60329,7 @@ var require_backend = __commonJS({
|
|
|
60290
60329
|
function renderer_attach(hook, rendererID, renderer2, global2, shouldStartProfilingNow, profilingSettings) {
|
|
60291
60330
|
var version2 = renderer2.reconcilerVersion || renderer2.version;
|
|
60292
60331
|
var _getInternalReactCons = getInternalReactConstants(version2), getDisplayNameForFiber = _getInternalReactCons.getDisplayNameForFiber, getTypeSymbol = _getInternalReactCons.getTypeSymbol, ReactPriorityLevels = _getInternalReactCons.ReactPriorityLevels, ReactTypeOfWork = _getInternalReactCons.ReactTypeOfWork, StrictModeBits = _getInternalReactCons.StrictModeBits, SuspenseyImagesMode = _getInternalReactCons.SuspenseyImagesMode;
|
|
60293
|
-
var ActivityComponent = ReactTypeOfWork.ActivityComponent, ClassComponent = ReactTypeOfWork.ClassComponent, ContextConsumer = ReactTypeOfWork.ContextConsumer, DehydratedSuspenseComponent = ReactTypeOfWork.DehydratedSuspenseComponent, ForwardRef = ReactTypeOfWork.ForwardRef,
|
|
60332
|
+
var ActivityComponent = ReactTypeOfWork.ActivityComponent, ClassComponent = ReactTypeOfWork.ClassComponent, ContextConsumer = ReactTypeOfWork.ContextConsumer, DehydratedSuspenseComponent = ReactTypeOfWork.DehydratedSuspenseComponent, ForwardRef = ReactTypeOfWork.ForwardRef, Fragment2 = ReactTypeOfWork.Fragment, FunctionComponent = ReactTypeOfWork.FunctionComponent, HostRoot = ReactTypeOfWork.HostRoot, HostHoistable = ReactTypeOfWork.HostHoistable, HostSingleton = ReactTypeOfWork.HostSingleton, HostPortal = ReactTypeOfWork.HostPortal, HostComponent = ReactTypeOfWork.HostComponent, HostText = ReactTypeOfWork.HostText, IncompleteClassComponent = ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = ReactTypeOfWork.IncompleteFunctionComponent, IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent, LegacyHiddenComponent = ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = ReactTypeOfWork.MemoComponent, OffscreenComponent = ReactTypeOfWork.OffscreenComponent, SimpleMemoComponent = ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = ReactTypeOfWork.TracingMarkerComponent, Throw = ReactTypeOfWork.Throw, ViewTransitionComponent = ReactTypeOfWork.ViewTransitionComponent;
|
|
60294
60333
|
var ImmediatePriority = ReactPriorityLevels.ImmediatePriority, UserBlockingPriority = ReactPriorityLevels.UserBlockingPriority, NormalPriority = ReactPriorityLevels.NormalPriority, LowPriority = ReactPriorityLevels.LowPriority, IdlePriority = ReactPriorityLevels.IdlePriority, NoPriority = ReactPriorityLevels.NoPriority;
|
|
60295
60334
|
var getLaneLabelMap = renderer2.getLaneLabelMap, injectProfilingHooks = renderer2.injectProfilingHooks, overrideHookState = renderer2.overrideHookState, overrideHookStateDeletePath = renderer2.overrideHookStateDeletePath, overrideHookStateRenamePath = renderer2.overrideHookStateRenamePath, overrideProps = renderer2.overrideProps, overridePropsDeletePath = renderer2.overridePropsDeletePath, overridePropsRenamePath = renderer2.overridePropsRenamePath, scheduleRefresh = renderer2.scheduleRefresh, setErrorHandler = renderer2.setErrorHandler, setSuspenseHandler = renderer2.setSuspenseHandler, scheduleUpdate = renderer2.scheduleUpdate, scheduleRetry = renderer2.scheduleRetry, getCurrentFiber = renderer2.getCurrentFiber;
|
|
60296
60335
|
var supportsTogglingError = typeof setErrorHandler === "function" && typeof scheduleUpdate === "function";
|
|
@@ -60651,7 +60690,7 @@ var require_backend = __commonJS({
|
|
|
60651
60690
|
return true;
|
|
60652
60691
|
case HostRoot:
|
|
60653
60692
|
return false;
|
|
60654
|
-
case
|
|
60693
|
+
case Fragment2:
|
|
60655
60694
|
return key === null;
|
|
60656
60695
|
default:
|
|
60657
60696
|
var typeSymbol = getTypeSymbol(type);
|
|
@@ -60725,7 +60764,7 @@ var require_backend = __commonJS({
|
|
|
60725
60764
|
return ElementTypeHostComponent;
|
|
60726
60765
|
case HostPortal:
|
|
60727
60766
|
case HostText:
|
|
60728
|
-
case
|
|
60767
|
+
case Fragment2:
|
|
60729
60768
|
return ElementTypeOtherOrUnknown;
|
|
60730
60769
|
case MemoComponent:
|
|
60731
60770
|
case SimpleMemoComponent:
|
|
@@ -71925,6 +71964,383 @@ 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
|
+
|
|
72065
|
+
// apps/cli/src/services/cli-tips.ts
|
|
72066
|
+
function rankCliTips(tips = CLI_TIPS) {
|
|
72067
|
+
return [...tips].sort((firstTip, secondTip) => {
|
|
72068
|
+
const relevancyDifference = secondTip.relevancy - firstTip.relevancy;
|
|
72069
|
+
if (relevancyDifference !== 0) {
|
|
72070
|
+
return relevancyDifference;
|
|
72071
|
+
}
|
|
72072
|
+
const insightDifference = secondTip.insight - firstTip.insight;
|
|
72073
|
+
if (insightDifference !== 0) {
|
|
72074
|
+
return insightDifference;
|
|
72075
|
+
}
|
|
72076
|
+
return firstTip.id.localeCompare(secondTip.id);
|
|
72077
|
+
});
|
|
72078
|
+
}
|
|
72079
|
+
function selectCliTips(options = {}) {
|
|
72080
|
+
const {
|
|
72081
|
+
tips = CLI_TIPS,
|
|
72082
|
+
limit = tips.length,
|
|
72083
|
+
minimumRelevancy = Number.NEGATIVE_INFINITY,
|
|
72084
|
+
minimumInsight = Number.NEGATIVE_INFINITY
|
|
72085
|
+
} = options;
|
|
72086
|
+
const normalizedLimit = Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : tips.length;
|
|
72087
|
+
return rankCliTips(tips).filter((tip) => tip.relevancy >= minimumRelevancy && tip.insight >= minimumInsight).slice(0, normalizedLimit);
|
|
72088
|
+
}
|
|
72089
|
+
var CLI_TIPS;
|
|
72090
|
+
var init_cli_tips = __esm({
|
|
72091
|
+
"apps/cli/src/services/cli-tips.ts"() {
|
|
72092
|
+
"use strict";
|
|
72093
|
+
CLI_TIPS = Object.freeze([
|
|
72094
|
+
{
|
|
72095
|
+
id: "examples-as-full-stack-starters",
|
|
72096
|
+
text: "Treat CopilotKit examples as full-stack starters, not isolated snippets, because frontend, runtime, and agent code usually depend on each other.",
|
|
72097
|
+
relevancy: 85,
|
|
72098
|
+
insight: 68
|
|
72099
|
+
},
|
|
72100
|
+
{
|
|
72101
|
+
id: "runtime-info-before-react-state",
|
|
72102
|
+
text: "If your frontend cannot find an agent, check the runtime `/info` endpoint and try `127.0.0.1` before debugging React state.",
|
|
72103
|
+
relevancy: 92,
|
|
72104
|
+
insight: 94
|
|
72105
|
+
},
|
|
72106
|
+
{
|
|
72107
|
+
id: "runtime-for-production-boundaries",
|
|
72108
|
+
text: "Use Copilot Runtime for production auth, middleware, routing, threads, and observability; direct AG-UI connections are best kept for prototyping.",
|
|
72109
|
+
relevancy: 96,
|
|
72110
|
+
insight: 93
|
|
72111
|
+
},
|
|
72112
|
+
{
|
|
72113
|
+
id: "default-agent-before-agent-ids",
|
|
72114
|
+
text: "Register a `default` agent for simple apps, then pass matching `agentId` values once your app has multiple agents.",
|
|
72115
|
+
relevancy: 94,
|
|
72116
|
+
insight: 88
|
|
72117
|
+
},
|
|
72118
|
+
{
|
|
72119
|
+
id: "debug-ag-ui-event-stream",
|
|
72120
|
+
text: "AG-UI streams lifecycle, message, tool, state, and activity events over SSE, so debug the event stream instead of scraping chat text.",
|
|
72121
|
+
relevancy: 82,
|
|
72122
|
+
insight: 90
|
|
72123
|
+
},
|
|
72124
|
+
{
|
|
72125
|
+
id: "built-in-agent-before-factory-mode",
|
|
72126
|
+
text: "Use `BuiltInAgent` for fast in-process chat and tools, and switch to factory mode only when you need full control of the model stream.",
|
|
72127
|
+
relevancy: 78,
|
|
72128
|
+
insight: 82
|
|
72129
|
+
},
|
|
72130
|
+
{
|
|
72131
|
+
id: "mcp-servers-vs-clients",
|
|
72132
|
+
text: "Use `mcpServers` for runtime-managed MCP connections and `mcpClients` when you need custom auth, caching, or lifecycle control.",
|
|
72133
|
+
relevancy: 72,
|
|
72134
|
+
insight: 89
|
|
72135
|
+
},
|
|
72136
|
+
{
|
|
72137
|
+
id: "mcp-apps-stable-server-ids",
|
|
72138
|
+
text: "For MCP Apps, configure runtime `mcpApps.servers` and pin stable `serverId` values so restored conversations keep their UI.",
|
|
72139
|
+
relevancy: 65,
|
|
72140
|
+
insight: 92
|
|
72141
|
+
},
|
|
72142
|
+
{
|
|
72143
|
+
id: "use-threads-for-resume",
|
|
72144
|
+
text: "Use `useThreads` for persistent conversation lists and pass `threadId` to `CopilotChat` when resuming a specific thread.",
|
|
72145
|
+
relevancy: 80,
|
|
72146
|
+
insight: 88
|
|
72147
|
+
},
|
|
72148
|
+
{
|
|
72149
|
+
id: "archive-vs-delete-threads",
|
|
72150
|
+
text: "Remember that archived threads are recoverable but deleted threads are not, so add your own confirmation UX for destructive thread actions.",
|
|
72151
|
+
relevancy: 76,
|
|
72152
|
+
insight: 84
|
|
72153
|
+
},
|
|
72154
|
+
{
|
|
72155
|
+
id: "dev-console-and-production-errors",
|
|
72156
|
+
text: "Use `showDevConsole` only during local development and wire `onError` for production error handling.",
|
|
72157
|
+
relevancy: 91,
|
|
72158
|
+
insight: 91
|
|
72159
|
+
},
|
|
72160
|
+
{
|
|
72161
|
+
id: "server-debug-for-missing-events",
|
|
72162
|
+
text: "Enable server `debug: true` when events, state, or tool calls disappear, then use the Inspector or `/cpk-debug-events` for live AG-UI details.",
|
|
72163
|
+
relevancy: 82,
|
|
72164
|
+
insight: 90
|
|
72165
|
+
},
|
|
72166
|
+
{
|
|
72167
|
+
id: "react-core-v2-imports",
|
|
72168
|
+
text: "Import the provider from `@copilotkit/react-core`, v2 APIs from `@copilotkit/react-core/v2`, and load v2 styles once.",
|
|
72169
|
+
relevancy: 95,
|
|
72170
|
+
insight: 86
|
|
72171
|
+
},
|
|
72172
|
+
{
|
|
72173
|
+
id: "built-in-chat-surfaces-first",
|
|
72174
|
+
text: "Reach for `CopilotChat`, `CopilotSidebar`, or `CopilotPopup` before building a chat shell from scratch.",
|
|
72175
|
+
relevancy: 93,
|
|
72176
|
+
insight: 72
|
|
72177
|
+
},
|
|
72178
|
+
{
|
|
72179
|
+
id: "customize-before-replacing-chat",
|
|
72180
|
+
text: "Customize copy with labels, structure with slots, and visuals with scoped CSS before replacing built-in chat components wholesale.",
|
|
72181
|
+
relevancy: 88,
|
|
72182
|
+
insight: 86
|
|
72183
|
+
},
|
|
72184
|
+
{
|
|
72185
|
+
id: "slots-before-headless",
|
|
72186
|
+
text: "Use slots before going headless because v2 slots support class strings, prop overrides, and full component replacement.",
|
|
72187
|
+
relevancy: 90,
|
|
72188
|
+
insight: 84
|
|
72189
|
+
},
|
|
72190
|
+
{
|
|
72191
|
+
id: "use-agent-for-custom-chat",
|
|
72192
|
+
text: "For custom chat UIs, use `useAgent` for messages, state, and running status, then call `copilotkit.runAgent({ agent })`.",
|
|
72193
|
+
relevancy: 86,
|
|
72194
|
+
insight: 94
|
|
72195
|
+
},
|
|
72196
|
+
{
|
|
72197
|
+
id: "throttle-custom-message-lists",
|
|
72198
|
+
text: "Add `throttleMs` to `useAgent` when token-by-token streaming causes hot re-renders in custom message lists.",
|
|
72199
|
+
relevancy: 78,
|
|
72200
|
+
insight: 84
|
|
72201
|
+
},
|
|
72202
|
+
{
|
|
72203
|
+
id: "proxied-agent-for-isolated-state",
|
|
72204
|
+
text: "Use `registerProxiedAgent` when multiple chat windows share one runtime agent but need isolated frontend state.",
|
|
72205
|
+
relevancy: 55,
|
|
72206
|
+
insight: 88
|
|
72207
|
+
},
|
|
72208
|
+
{
|
|
72209
|
+
id: "chat-configuration-provider-context",
|
|
72210
|
+
text: "Use `CopilotChatConfigurationProvider` when custom chat pieces need shared labels, `agentId`, `threadId`, or modal state.",
|
|
72211
|
+
relevancy: 60,
|
|
72212
|
+
insight: 78
|
|
72213
|
+
},
|
|
72214
|
+
{
|
|
72215
|
+
id: "agent-context-for-serializable-state",
|
|
72216
|
+
text: "Use `useAgentContext` in v2 to expose serializable app state such as selected rows, filters, or preferences to the agent.",
|
|
72217
|
+
relevancy: 88,
|
|
72218
|
+
insight: 84
|
|
72219
|
+
},
|
|
72220
|
+
{
|
|
72221
|
+
id: "frontend-tools-with-dependencies",
|
|
72222
|
+
text: "Register browser-side actions with `useFrontendTool`, include dependencies for captured state, and use `runTool` for button-triggered tools.",
|
|
72223
|
+
relevancy: 86,
|
|
72224
|
+
insight: 93
|
|
72225
|
+
},
|
|
72226
|
+
{
|
|
72227
|
+
id: "capability-gated-controls",
|
|
72228
|
+
text: "Use `useCapabilities` to hide controls for features the current agent did not declare.",
|
|
72229
|
+
relevancy: 62,
|
|
72230
|
+
insight: 79
|
|
72231
|
+
},
|
|
72232
|
+
{
|
|
72233
|
+
id: "component-rendering-from-typed-params",
|
|
72234
|
+
text: "Use `useComponent` when the agent should render one of your React components from typed parameters.",
|
|
72235
|
+
relevancy: 73,
|
|
72236
|
+
insight: 80
|
|
72237
|
+
},
|
|
72238
|
+
{
|
|
72239
|
+
id: "render-tool-names-match-backend",
|
|
72240
|
+
text: "Use `useRenderTool` for backend tool-call UI, and keep renderer names identical to backend tool names.",
|
|
72241
|
+
relevancy: 84,
|
|
72242
|
+
insight: 87
|
|
72243
|
+
},
|
|
72244
|
+
{
|
|
72245
|
+
id: "wildcard-tool-renderers",
|
|
72246
|
+
text: "Add wildcard or default tool renderers during development to reveal unexpected tool calls and unhandled MCP tools.",
|
|
72247
|
+
relevancy: 76,
|
|
72248
|
+
insight: 88
|
|
72249
|
+
},
|
|
72250
|
+
{
|
|
72251
|
+
id: "tool-progress-from-status",
|
|
72252
|
+
text: "Render tool progress from `ToolCallStatus` instead of guessing from partial arguments.",
|
|
72253
|
+
relevancy: 72,
|
|
72254
|
+
insight: 84
|
|
72255
|
+
},
|
|
72256
|
+
{
|
|
72257
|
+
id: "human-in-loop-and-interrupts",
|
|
72258
|
+
text: "Use `useHumanInTheLoop` for model-initiated approvals and `useInterrupt` for graph-enforced checkpoints on supported runtimes.",
|
|
72259
|
+
relevancy: 76,
|
|
72260
|
+
insight: 91
|
|
72261
|
+
},
|
|
72262
|
+
{
|
|
72263
|
+
id: "agent-scoped-suggestions",
|
|
72264
|
+
text: "Use `useConfigureSuggestions` and `useSuggestions` for agent-scoped prompt pills instead of hard-coded static chips.",
|
|
72265
|
+
relevancy: 72,
|
|
72266
|
+
insight: 82
|
|
72267
|
+
},
|
|
72268
|
+
{
|
|
72269
|
+
id: "suggestions-by-provider-and-consumer",
|
|
72270
|
+
text: "Scope suggestions by provider and consumer agent when multiple agents share a page.",
|
|
72271
|
+
relevancy: 64,
|
|
72272
|
+
insight: 84
|
|
72273
|
+
},
|
|
72274
|
+
{
|
|
72275
|
+
id: "welcome-screen-render-prop",
|
|
72276
|
+
text: "Use the `welcomeScreen` render prop to customize the empty state while preserving default input and suggestions.",
|
|
72277
|
+
relevancy: 68,
|
|
72278
|
+
insight: 73
|
|
72279
|
+
},
|
|
72280
|
+
{
|
|
72281
|
+
id: "open-generative-ui-sandbox",
|
|
72282
|
+
text: "Use Open Generative UI for sandboxed ad hoc UI, and expose only deliberate host callbacks through `sandboxFunctions`.",
|
|
72283
|
+
relevancy: 55,
|
|
72284
|
+
insight: 89
|
|
72285
|
+
},
|
|
72286
|
+
{
|
|
72287
|
+
id: "a2ui-for-catalog-backed-ui",
|
|
72288
|
+
text: "Use A2UI when you want declarative, catalog-backed generative UI with runtime middleware and frontend theming.",
|
|
72289
|
+
relevancy: 55,
|
|
72290
|
+
insight: 84
|
|
72291
|
+
},
|
|
72292
|
+
{
|
|
72293
|
+
id: "mcp-apps-inline-ui",
|
|
72294
|
+
text: "Use MCP Apps when remote MCP-provided UI resources should render inline inside normal CopilotKit chat.",
|
|
72295
|
+
relevancy: 62,
|
|
72296
|
+
insight: 88
|
|
72297
|
+
},
|
|
72298
|
+
{
|
|
72299
|
+
id: "langgraph-for-ag-ui-bridges",
|
|
72300
|
+
text: "Use LangGraph integration when you need subgraph streaming, state/context injection, frontend tool interception, or graph interrupts bridged into AG-UI.",
|
|
72301
|
+
relevancy: 86,
|
|
72302
|
+
insight: 92
|
|
72303
|
+
},
|
|
72304
|
+
{
|
|
72305
|
+
id: "backend-aligned-starters",
|
|
72306
|
+
text: "Pick the starter closest to your backend, whether LangGraph, CrewAI, Mastra, LlamaIndex, PydanticAI, ADK, Strands, Microsoft Agent Framework, or A2A.",
|
|
72307
|
+
relevancy: 83,
|
|
72308
|
+
insight: 68
|
|
72309
|
+
},
|
|
72310
|
+
{
|
|
72311
|
+
id: "ag-ui-at-a2a-boundary",
|
|
72312
|
+
text: "For A2A systems, keep AG-UI at the app boundary and let A2A middleware coordinate agents behind it.",
|
|
72313
|
+
relevancy: 70,
|
|
72314
|
+
insight: 88
|
|
72315
|
+
},
|
|
72316
|
+
{
|
|
72317
|
+
id: "canvas-shared-state-source",
|
|
72318
|
+
text: "In canvas-style apps, make shared state the source of truth and expose narrow frontend actions for each operation the agent can perform.",
|
|
72319
|
+
relevancy: 82,
|
|
72320
|
+
insight: 90
|
|
72321
|
+
},
|
|
72322
|
+
{
|
|
72323
|
+
id: "canvas-card-type-coordination",
|
|
72324
|
+
text: "When adding a new canvas card type, update the frontend schema, renderer, agent schema, and matching actions together.",
|
|
72325
|
+
relevancy: 78,
|
|
72326
|
+
insight: 89
|
|
72327
|
+
},
|
|
72328
|
+
{
|
|
72329
|
+
id: "production-observability-hooks",
|
|
72330
|
+
text: "Use production observability hooks when you need structured chat, error, and runtime signals in Sentry, Datadog, New Relic, OpenTelemetry, or analytics tools.",
|
|
72331
|
+
relevancy: 84,
|
|
72332
|
+
insight: 87
|
|
72333
|
+
},
|
|
72334
|
+
{
|
|
72335
|
+
id: "enterprise-intelligence-platform",
|
|
72336
|
+
text: "Use the Enterprise Intelligence Platform when you need persistent threads, observability, and production operations beyond local debugging.",
|
|
72337
|
+
relevancy: 82,
|
|
72338
|
+
insight: 79
|
|
72339
|
+
}
|
|
72340
|
+
]);
|
|
72341
|
+
}
|
|
72342
|
+
});
|
|
72343
|
+
|
|
71928
72344
|
// node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.production.js
|
|
71929
72345
|
var require_react_jsx_runtime_production = __commonJS({
|
|
71930
72346
|
"node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.production.js"(exports) {
|
|
@@ -72231,28 +72647,191 @@ var require_jsx_runtime = __commonJS({
|
|
|
72231
72647
|
}
|
|
72232
72648
|
});
|
|
72233
72649
|
|
|
72650
|
+
// apps/cli/src/ui/cli-tip.tsx
|
|
72651
|
+
function normalizeCliTipSelectionIndex(selectionIndex = 0) {
|
|
72652
|
+
return Number.isFinite(selectionIndex) ? Math.max(0, Math.floor(selectionIndex)) : 0;
|
|
72653
|
+
}
|
|
72654
|
+
function normalizeCliTipLimit(limit, fallback) {
|
|
72655
|
+
return Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : fallback;
|
|
72656
|
+
}
|
|
72657
|
+
function normalizeCliTipRandomValue(randomValue) {
|
|
72658
|
+
if (!Number.isFinite(randomValue)) {
|
|
72659
|
+
return 0;
|
|
72660
|
+
}
|
|
72661
|
+
return Math.min(Math.max(randomValue, 0), 1 - Number.EPSILON);
|
|
72662
|
+
}
|
|
72663
|
+
function shuffleCliTips(tips, rng = Math.random) {
|
|
72664
|
+
const shuffledTips = [...tips];
|
|
72665
|
+
for (let index = shuffledTips.length - 1; index > 0; index -= 1) {
|
|
72666
|
+
const swapIndex = Math.floor(normalizeCliTipRandomValue(rng()) * (index + 1));
|
|
72667
|
+
const currentTip = shuffledTips[index];
|
|
72668
|
+
const swapTip = shuffledTips[swapIndex];
|
|
72669
|
+
if (currentTip !== void 0 && swapTip !== void 0) {
|
|
72670
|
+
shuffledTips[index] = swapTip;
|
|
72671
|
+
shuffledTips[swapIndex] = currentTip;
|
|
72672
|
+
}
|
|
72673
|
+
}
|
|
72674
|
+
return shuffledTips;
|
|
72675
|
+
}
|
|
72676
|
+
function selectCliTipRotationSubset(tips, options = {}) {
|
|
72677
|
+
const {
|
|
72678
|
+
rotationLimit = CLI_TIP_DEFAULT_ROTATION_LIMIT,
|
|
72679
|
+
rotationPoolLimit = CLI_TIP_DEFAULT_ROTATION_POOL_LIMIT,
|
|
72680
|
+
randomize = false,
|
|
72681
|
+
rng = Math.random
|
|
72682
|
+
} = typeof options === "number" ? { rotationLimit: options } : options;
|
|
72683
|
+
const normalizedLimit = normalizeCliTipLimit(
|
|
72684
|
+
rotationLimit,
|
|
72685
|
+
CLI_TIP_DEFAULT_ROTATION_LIMIT
|
|
72686
|
+
);
|
|
72687
|
+
const normalizedPoolLimit = normalizeCliTipLimit(
|
|
72688
|
+
rotationPoolLimit,
|
|
72689
|
+
CLI_TIP_DEFAULT_ROTATION_POOL_LIMIT
|
|
72690
|
+
);
|
|
72691
|
+
const rankedPool = selectCliTips({
|
|
72692
|
+
tips,
|
|
72693
|
+
limit: Math.max(normalizedLimit, normalizedPoolLimit)
|
|
72694
|
+
}).slice(0, normalizedPoolLimit);
|
|
72695
|
+
if (!randomize) {
|
|
72696
|
+
return rankedPool.slice(0, normalizedLimit);
|
|
72697
|
+
}
|
|
72698
|
+
return shuffleCliTips(rankedPool, rng).slice(0, normalizedLimit);
|
|
72699
|
+
}
|
|
72700
|
+
function parseCliTipText(text) {
|
|
72701
|
+
const segments = [];
|
|
72702
|
+
let cursor = 0;
|
|
72703
|
+
while (cursor < text.length) {
|
|
72704
|
+
const openingBacktick = text.indexOf("`", cursor);
|
|
72705
|
+
if (openingBacktick === -1) {
|
|
72706
|
+
segments.push({ kind: "text", text: text.slice(cursor) });
|
|
72707
|
+
break;
|
|
72708
|
+
}
|
|
72709
|
+
const closingBacktick = text.indexOf("`", openingBacktick + 1);
|
|
72710
|
+
if (closingBacktick === -1) {
|
|
72711
|
+
segments.push({ kind: "text", text: text.slice(cursor) });
|
|
72712
|
+
break;
|
|
72713
|
+
}
|
|
72714
|
+
if (openingBacktick > cursor) {
|
|
72715
|
+
segments.push({
|
|
72716
|
+
kind: "text",
|
|
72717
|
+
text: text.slice(cursor, openingBacktick)
|
|
72718
|
+
});
|
|
72719
|
+
}
|
|
72720
|
+
segments.push({
|
|
72721
|
+
kind: "code",
|
|
72722
|
+
text: text.slice(openingBacktick + 1, closingBacktick)
|
|
72723
|
+
});
|
|
72724
|
+
cursor = closingBacktick + 1;
|
|
72725
|
+
}
|
|
72726
|
+
return segments;
|
|
72727
|
+
}
|
|
72728
|
+
function CliTip({
|
|
72729
|
+
tips,
|
|
72730
|
+
selectionIndex = 0,
|
|
72731
|
+
delayMs = CLI_TIP_DEFAULT_DELAY_MS,
|
|
72732
|
+
rotationMs = CLI_TIP_DEFAULT_ROTATION_MS,
|
|
72733
|
+
rotationLimit = CLI_TIP_DEFAULT_ROTATION_LIMIT,
|
|
72734
|
+
rotationPoolLimit = CLI_TIP_DEFAULT_ROTATION_POOL_LIMIT,
|
|
72735
|
+
randomize = true,
|
|
72736
|
+
rng = Math.random
|
|
72737
|
+
}) {
|
|
72738
|
+
const [visible, setVisible] = (0, import_react30.useState)(delayMs <= 0);
|
|
72739
|
+
const selectedTips = (0, import_react30.useMemo)(
|
|
72740
|
+
() => selectCliTipRotationSubset(tips, {
|
|
72741
|
+
rotationLimit,
|
|
72742
|
+
rotationPoolLimit,
|
|
72743
|
+
randomize,
|
|
72744
|
+
rng
|
|
72745
|
+
}),
|
|
72746
|
+
[tips, rotationLimit, rotationPoolLimit, randomize, rng]
|
|
72747
|
+
);
|
|
72748
|
+
const initialSelectionIndex = (0, import_react30.useMemo)(
|
|
72749
|
+
() => selectedTips.length === 0 ? 0 : normalizeCliTipSelectionIndex(selectionIndex) % selectedTips.length,
|
|
72750
|
+
[selectedTips.length, selectionIndex]
|
|
72751
|
+
);
|
|
72752
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react30.useState)(initialSelectionIndex);
|
|
72753
|
+
const selectedTip = selectedTips[selectedIndex] ?? null;
|
|
72754
|
+
const textSegments = (0, import_react30.useMemo)(
|
|
72755
|
+
() => selectedTip === null ? [] : parseCliTipText(selectedTip.text),
|
|
72756
|
+
[selectedTip]
|
|
72757
|
+
);
|
|
72758
|
+
(0, import_react30.useEffect)(() => {
|
|
72759
|
+
if (delayMs <= 0) {
|
|
72760
|
+
setVisible(true);
|
|
72761
|
+
return;
|
|
72762
|
+
}
|
|
72763
|
+
setVisible(false);
|
|
72764
|
+
const timer = setTimeout(() => {
|
|
72765
|
+
setVisible(true);
|
|
72766
|
+
}, delayMs);
|
|
72767
|
+
return () => {
|
|
72768
|
+
clearTimeout(timer);
|
|
72769
|
+
};
|
|
72770
|
+
}, [delayMs]);
|
|
72771
|
+
(0, import_react30.useEffect)(() => {
|
|
72772
|
+
setSelectedIndex(initialSelectionIndex);
|
|
72773
|
+
}, [initialSelectionIndex, selectedTips]);
|
|
72774
|
+
(0, import_react30.useEffect)(() => {
|
|
72775
|
+
if (!visible || selectedTips.length <= 1 || rotationMs <= 0) {
|
|
72776
|
+
return;
|
|
72777
|
+
}
|
|
72778
|
+
const timer = setInterval(() => {
|
|
72779
|
+
setSelectedIndex(
|
|
72780
|
+
(currentIndex) => (currentIndex + 1) % selectedTips.length
|
|
72781
|
+
);
|
|
72782
|
+
}, rotationMs);
|
|
72783
|
+
return () => {
|
|
72784
|
+
clearInterval(timer);
|
|
72785
|
+
};
|
|
72786
|
+
}, [rotationMs, selectedTips.length, visible]);
|
|
72787
|
+
if (!visible || selectedTip === null) {
|
|
72788
|
+
return null;
|
|
72789
|
+
}
|
|
72790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: "gray", children: [
|
|
72791
|
+
"Tip:",
|
|
72792
|
+
" ",
|
|
72793
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "cyan", children: textSegments.map(
|
|
72794
|
+
(segment, index) => segment.kind === "code" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: "white", children: segment.text }, `${segment.kind}-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "cyan", children: segment.text }, `${segment.kind}-${index}`)
|
|
72795
|
+
) })
|
|
72796
|
+
] }) });
|
|
72797
|
+
}
|
|
72798
|
+
var import_react30, import_jsx_runtime, CLI_TIP_DEFAULT_DELAY_MS, CLI_TIP_DEFAULT_ROTATION_MS, CLI_TIP_DEFAULT_ROTATION_LIMIT, CLI_TIP_DEFAULT_ROTATION_POOL_LIMIT;
|
|
72799
|
+
var init_cli_tip = __esm({
|
|
72800
|
+
async "apps/cli/src/ui/cli-tip.tsx"() {
|
|
72801
|
+
"use strict";
|
|
72802
|
+
import_react30 = __toESM(require_react(), 1);
|
|
72803
|
+
await init_build2();
|
|
72804
|
+
init_cli_tips();
|
|
72805
|
+
import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
72806
|
+
CLI_TIP_DEFAULT_DELAY_MS = 2500;
|
|
72807
|
+
CLI_TIP_DEFAULT_ROTATION_MS = 12e3;
|
|
72808
|
+
CLI_TIP_DEFAULT_ROTATION_LIMIT = 5;
|
|
72809
|
+
CLI_TIP_DEFAULT_ROTATION_POOL_LIMIT = 20;
|
|
72810
|
+
}
|
|
72811
|
+
});
|
|
72812
|
+
|
|
72234
72813
|
// apps/cli/src/ui/spinner.tsx
|
|
72235
72814
|
function Spinner({ label }) {
|
|
72236
|
-
const [frame, setFrame] = (0,
|
|
72237
|
-
(0,
|
|
72815
|
+
const [frame, setFrame] = (0, import_react31.useState)(0);
|
|
72816
|
+
(0, import_react31.useEffect)(() => {
|
|
72238
72817
|
const id = setInterval(() => {
|
|
72239
72818
|
setFrame((prev) => (prev + 1) % KITE_FRAMES.length);
|
|
72240
72819
|
}, FRAME_INTERVAL_MS);
|
|
72241
72820
|
return () => clearInterval(id);
|
|
72242
72821
|
}, []);
|
|
72243
|
-
return /* @__PURE__ */ (0,
|
|
72244
|
-
/* @__PURE__ */ (0,
|
|
72822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
|
|
72823
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "magenta", children: KITE_FRAMES[frame] }),
|
|
72245
72824
|
" ",
|
|
72246
72825
|
label
|
|
72247
72826
|
] });
|
|
72248
72827
|
}
|
|
72249
|
-
var
|
|
72828
|
+
var import_react31, import_jsx_runtime2, KITE_FRAMES, FRAME_INTERVAL_MS;
|
|
72250
72829
|
var init_spinner = __esm({
|
|
72251
72830
|
async "apps/cli/src/ui/spinner.tsx"() {
|
|
72252
72831
|
"use strict";
|
|
72253
|
-
|
|
72832
|
+
import_react31 = __toESM(require_react(), 1);
|
|
72254
72833
|
await init_build2();
|
|
72255
|
-
|
|
72834
|
+
import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
72256
72835
|
KITE_FRAMES = [
|
|
72257
72836
|
"\u{1FA81} ",
|
|
72258
72837
|
"~\u{1FA81} ",
|
|
@@ -72275,10 +72854,11 @@ function BrowserLoginProvider({
|
|
|
72275
72854
|
loginRunner = login,
|
|
72276
72855
|
isInteractive
|
|
72277
72856
|
}) {
|
|
72278
|
-
const [state, setState] = (0,
|
|
72279
|
-
const pendingConfirmationRef = (0,
|
|
72857
|
+
const [state, setState] = (0, import_react32.useState)(idleState);
|
|
72858
|
+
const pendingConfirmationRef = (0, import_react32.useRef)(null);
|
|
72859
|
+
const pendingManualTokenRef = (0, import_react32.useRef)(null);
|
|
72280
72860
|
const shouldConfirm = isInteractive ?? isBrowserLoginConfirmationInteractive();
|
|
72281
|
-
const confirmBrowserLoginStart = (0,
|
|
72861
|
+
const confirmBrowserLoginStart = (0, import_react32.useCallback)(() => {
|
|
72282
72862
|
const pendingConfirmation = pendingConfirmationRef.current;
|
|
72283
72863
|
if (pendingConfirmation === null) {
|
|
72284
72864
|
return void 0;
|
|
@@ -72287,7 +72867,20 @@ function BrowserLoginProvider({
|
|
|
72287
72867
|
pendingConfirmation.resolve(void 0);
|
|
72288
72868
|
return void 0;
|
|
72289
72869
|
}, []);
|
|
72290
|
-
const
|
|
72870
|
+
const submitManualClerkToken = (0, import_react32.useCallback)((clerkToken) => {
|
|
72871
|
+
const pendingManualToken = pendingManualTokenRef.current;
|
|
72872
|
+
if (pendingManualToken === null) {
|
|
72873
|
+
return void 0;
|
|
72874
|
+
}
|
|
72875
|
+
const trimmed = clerkToken.trim();
|
|
72876
|
+
if (trimmed.length === 0) {
|
|
72877
|
+
return void 0;
|
|
72878
|
+
}
|
|
72879
|
+
pendingManualTokenRef.current = null;
|
|
72880
|
+
pendingManualToken.resolve(trimmed);
|
|
72881
|
+
return void 0;
|
|
72882
|
+
}, []);
|
|
72883
|
+
const runLogin2 = (0, import_react32.useCallback)(async (passthroughOptions) => {
|
|
72291
72884
|
if (pendingConfirmationRef.current !== null) {
|
|
72292
72885
|
throw new Error("Browser login is already waiting for confirmation.");
|
|
72293
72886
|
}
|
|
@@ -72304,15 +72897,42 @@ function BrowserLoginProvider({
|
|
|
72304
72897
|
});
|
|
72305
72898
|
}
|
|
72306
72899
|
setState({ ...idleState, phase: "waiting" });
|
|
72900
|
+
const manualClerkToken = new Promise((resolve2, reject) => {
|
|
72901
|
+
pendingManualTokenRef.current = {
|
|
72902
|
+
resolve: resolve2,
|
|
72903
|
+
reject: (reason) => {
|
|
72904
|
+
reject(reason);
|
|
72905
|
+
return void 0;
|
|
72906
|
+
}
|
|
72907
|
+
};
|
|
72908
|
+
});
|
|
72909
|
+
manualClerkToken.catch(() => void 0);
|
|
72307
72910
|
try {
|
|
72308
|
-
const result = await loginRunner(
|
|
72911
|
+
const result = await loginRunner({
|
|
72912
|
+
...passthroughOptions ?? {},
|
|
72913
|
+
manualClerkToken
|
|
72914
|
+
});
|
|
72309
72915
|
const organizationName = result.organization.organizationName ?? result.organization.clerkOrgId;
|
|
72916
|
+
pendingManualTokenRef.current = null;
|
|
72917
|
+
const identity = {
|
|
72918
|
+
email: result.user.email,
|
|
72919
|
+
organizationName
|
|
72920
|
+
};
|
|
72921
|
+
if (result.source === "manual") {
|
|
72922
|
+
setState({
|
|
72923
|
+
phase: "finalizing",
|
|
72924
|
+
identity,
|
|
72925
|
+
errorMessage: ""
|
|
72926
|
+
});
|
|
72927
|
+
await new Promise((resolve2) => {
|
|
72928
|
+
setTimeout(() => {
|
|
72929
|
+
resolve2(void 0);
|
|
72930
|
+
}, MANUAL_PASTE_FINALIZING_MS);
|
|
72931
|
+
});
|
|
72932
|
+
}
|
|
72310
72933
|
setState({
|
|
72311
72934
|
phase: "success",
|
|
72312
|
-
identity
|
|
72313
|
-
email: result.user.email,
|
|
72314
|
-
organizationName
|
|
72315
|
-
},
|
|
72935
|
+
identity,
|
|
72316
72936
|
errorMessage: ""
|
|
72317
72937
|
});
|
|
72318
72938
|
return result;
|
|
@@ -72321,6 +72941,7 @@ function BrowserLoginProvider({
|
|
|
72321
72941
|
error48,
|
|
72322
72942
|
"An unexpected error occurred."
|
|
72323
72943
|
);
|
|
72944
|
+
pendingManualTokenRef.current = null;
|
|
72324
72945
|
setState({
|
|
72325
72946
|
phase: "error",
|
|
72326
72947
|
identity: null,
|
|
@@ -72329,37 +72950,45 @@ function BrowserLoginProvider({
|
|
|
72329
72950
|
throw concreteError;
|
|
72330
72951
|
}
|
|
72331
72952
|
}, [loginRunner, shouldConfirm]);
|
|
72332
|
-
(0,
|
|
72953
|
+
(0, import_react32.useEffect)(() => {
|
|
72333
72954
|
return () => {
|
|
72334
72955
|
const pendingConfirmation = pendingConfirmationRef.current;
|
|
72335
|
-
if (pendingConfirmation
|
|
72336
|
-
|
|
72956
|
+
if (pendingConfirmation !== null) {
|
|
72957
|
+
pendingConfirmationRef.current = null;
|
|
72958
|
+
pendingConfirmation.reject(
|
|
72959
|
+
new Error("Browser login confirmation was interrupted.")
|
|
72960
|
+
);
|
|
72961
|
+
}
|
|
72962
|
+
const pendingManualToken = pendingManualTokenRef.current;
|
|
72963
|
+
if (pendingManualToken !== null) {
|
|
72964
|
+
pendingManualTokenRef.current = null;
|
|
72965
|
+
pendingManualToken.reject(
|
|
72966
|
+
new Error("Browser login manual paste was interrupted.")
|
|
72967
|
+
);
|
|
72337
72968
|
}
|
|
72338
|
-
pendingConfirmationRef.current = null;
|
|
72339
|
-
pendingConfirmation.reject(
|
|
72340
|
-
new Error("Browser login confirmation was interrupted.")
|
|
72341
|
-
);
|
|
72342
72969
|
};
|
|
72343
72970
|
}, []);
|
|
72344
|
-
const value = (0,
|
|
72971
|
+
const value = (0, import_react32.useMemo)(
|
|
72345
72972
|
() => ({
|
|
72346
72973
|
runLogin: runLogin2,
|
|
72347
72974
|
state,
|
|
72348
|
-
confirmBrowserLoginStart
|
|
72975
|
+
confirmBrowserLoginStart,
|
|
72976
|
+
submitManualClerkToken
|
|
72349
72977
|
}),
|
|
72350
|
-
[confirmBrowserLoginStart, runLogin2, state]
|
|
72978
|
+
[confirmBrowserLoginStart, runLogin2, state, submitManualClerkToken]
|
|
72351
72979
|
);
|
|
72352
|
-
return /* @__PURE__ */ (0,
|
|
72980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(BrowserLoginContext.Provider, { value, children });
|
|
72353
72981
|
}
|
|
72354
72982
|
function useBrowserLogin() {
|
|
72355
|
-
const context = (0,
|
|
72983
|
+
const context = (0, import_react32.useContext)(BrowserLoginContext);
|
|
72356
72984
|
if (context === null) {
|
|
72357
72985
|
throw new Error("useBrowserLogin must be used inside BrowserLoginProvider.");
|
|
72358
72986
|
}
|
|
72359
72987
|
return context;
|
|
72360
72988
|
}
|
|
72361
72989
|
function BrowserLoginConfirmation() {
|
|
72362
|
-
const { state, confirmBrowserLoginStart } = useBrowserLogin();
|
|
72990
|
+
const { state, confirmBrowserLoginStart, submitManualClerkToken } = useBrowserLogin();
|
|
72991
|
+
const [manualTokenInput, setManualTokenInput] = (0, import_react32.useState)("");
|
|
72363
72992
|
use_input_default((_input, key) => {
|
|
72364
72993
|
if (state.phase === "confirming" && key.return) {
|
|
72365
72994
|
confirmBrowserLoginStart();
|
|
@@ -72369,58 +72998,105 @@ function BrowserLoginConfirmation() {
|
|
|
72369
72998
|
return null;
|
|
72370
72999
|
}
|
|
72371
73000
|
if (state.phase === "confirming") {
|
|
72372
|
-
return /* @__PURE__ */ (0,
|
|
72373
|
-
/* @__PURE__ */ (0,
|
|
72374
|
-
/* @__PURE__ */ (0,
|
|
73001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73002
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { children: BROWSER_LOGIN_CONFIRMATION_MESSAGE }),
|
|
73003
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: "gray", children: BROWSER_LOGIN_CONFIRMATION_PROMPT })
|
|
72375
73004
|
] });
|
|
72376
73005
|
}
|
|
72377
73006
|
if (state.phase === "waiting") {
|
|
72378
|
-
return /* @__PURE__ */ (0,
|
|
73007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73008
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Spinner, { label: "\u{1FA81} Waiting for browser sign-in\u2026" }),
|
|
73009
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
|
|
73010
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: "gray", children: BROWSER_LOGIN_MANUAL_PASTE_LABEL }),
|
|
73011
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { children: [
|
|
73012
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
|
|
73013
|
+
">",
|
|
73014
|
+
" "
|
|
73015
|
+
] }),
|
|
73016
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
73017
|
+
build_default,
|
|
73018
|
+
{
|
|
73019
|
+
value: manualTokenInput,
|
|
73020
|
+
onChange: setManualTokenInput,
|
|
73021
|
+
onSubmit: (value) => {
|
|
73022
|
+
submitManualClerkToken(value);
|
|
73023
|
+
setManualTokenInput("");
|
|
73024
|
+
},
|
|
73025
|
+
placeholder: "paste code and press Enter"
|
|
73026
|
+
}
|
|
73027
|
+
)
|
|
73028
|
+
] })
|
|
73029
|
+
] }),
|
|
73030
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CliTip, {})
|
|
73031
|
+
] });
|
|
73032
|
+
}
|
|
73033
|
+
if (state.phase === "finalizing" && state.identity !== null) {
|
|
73034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73035
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: "green", children: "Logged in successfully!" }),
|
|
73036
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
|
|
73037
|
+
"Email: ",
|
|
73038
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, children: state.identity.email })
|
|
73039
|
+
] }),
|
|
73040
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
|
|
73041
|
+
"Organization: ",
|
|
73042
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, children: state.identity.organizationName })
|
|
73043
|
+
] }),
|
|
73044
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Spinner, { label: "Wrapping up..." }) }),
|
|
73045
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CliTip, {})
|
|
73046
|
+
] });
|
|
72379
73047
|
}
|
|
72380
73048
|
if (state.phase === "success" && state.identity !== null) {
|
|
72381
|
-
return /* @__PURE__ */ (0,
|
|
72382
|
-
/* @__PURE__ */ (0,
|
|
72383
|
-
/* @__PURE__ */ (0,
|
|
73049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73050
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: "green", children: "Logged in successfully!" }),
|
|
73051
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
|
|
72384
73052
|
"Email: ",
|
|
72385
|
-
/* @__PURE__ */ (0,
|
|
73053
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, children: state.identity.email })
|
|
72386
73054
|
] }),
|
|
72387
|
-
/* @__PURE__ */ (0,
|
|
73055
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
|
|
72388
73056
|
"Organization: ",
|
|
72389
|
-
/* @__PURE__ */ (0,
|
|
73057
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, children: state.identity.organizationName })
|
|
72390
73058
|
] })
|
|
72391
73059
|
] });
|
|
72392
73060
|
}
|
|
72393
|
-
return /* @__PURE__ */ (0,
|
|
73061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: "red", children: [
|
|
72394
73062
|
"Login failed: ",
|
|
72395
73063
|
state.errorMessage
|
|
72396
73064
|
] }) });
|
|
72397
73065
|
}
|
|
72398
|
-
var
|
|
73066
|
+
var import_react32, import_jsx_runtime3, BROWSER_LOGIN_CONFIRMATION_MESSAGE, BROWSER_LOGIN_CONFIRMATION_PROMPT, MANUAL_PASTE_FINALIZING_MS, idleState, BrowserLoginContext, BROWSER_LOGIN_MANUAL_PASTE_LABEL;
|
|
72399
73067
|
var init_browser_login = __esm({
|
|
72400
73068
|
async "apps/cli/src/ui/browser-login.tsx"() {
|
|
72401
73069
|
"use strict";
|
|
72402
|
-
|
|
73070
|
+
import_react32 = __toESM(require_react(), 1);
|
|
72403
73071
|
await init_build2();
|
|
73072
|
+
await init_build3();
|
|
72404
73073
|
init_auth_service();
|
|
72405
73074
|
init_cli_auth_diagnostics();
|
|
73075
|
+
await init_cli_tip();
|
|
72406
73076
|
await init_spinner();
|
|
72407
|
-
|
|
73077
|
+
import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
72408
73078
|
BROWSER_LOGIN_CONFIRMATION_MESSAGE = "Sign in to your \u{1FA81} CopilotKit account in your browser.";
|
|
72409
73079
|
BROWSER_LOGIN_CONFIRMATION_PROMPT = "Press Enter to continue...";
|
|
73080
|
+
MANUAL_PASTE_FINALIZING_MS = 6e3;
|
|
72410
73081
|
idleState = {
|
|
72411
73082
|
phase: "idle",
|
|
72412
73083
|
identity: null,
|
|
72413
73084
|
errorMessage: ""
|
|
72414
73085
|
};
|
|
72415
|
-
BrowserLoginContext = (0,
|
|
73086
|
+
BrowserLoginContext = (0, import_react32.createContext)(null);
|
|
73087
|
+
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
73088
|
}
|
|
72417
73089
|
});
|
|
72418
73090
|
|
|
72419
73091
|
// apps/cli/src/commands/license.tsx
|
|
72420
73092
|
var license_exports = {};
|
|
72421
73093
|
__export(license_exports, {
|
|
72422
|
-
runLicense: () => runLicense
|
|
73094
|
+
runLicense: () => runLicense,
|
|
73095
|
+
shouldRenderLicenseCreateBrowserLoginConfirmation: () => shouldRenderLicenseCreateBrowserLoginConfirmation
|
|
72423
73096
|
});
|
|
73097
|
+
function shouldRenderLicenseCreateBrowserLoginConfirmation(phase) {
|
|
73098
|
+
return phase === "confirming" || phase === "waiting" || phase === "finalizing";
|
|
73099
|
+
}
|
|
72424
73100
|
async function ensureCliToken(loginRunner = login, onTerminalSessionInvalidation) {
|
|
72425
73101
|
const storedToken = authStore.getToken();
|
|
72426
73102
|
let session;
|
|
@@ -72518,10 +73194,10 @@ function formatLicenseList(scope, licenses) {
|
|
|
72518
73194
|
function LicenseCreateApp({ onIssued }) {
|
|
72519
73195
|
const { exit } = use_app_default();
|
|
72520
73196
|
const browserLogin = useBrowserLogin();
|
|
72521
|
-
const [phase, setPhase] = (0,
|
|
72522
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
72523
|
-
const [authMessage, setAuthMessage] = (0,
|
|
72524
|
-
(0,
|
|
73197
|
+
const [phase, setPhase] = (0, import_react33.useState)("auth");
|
|
73198
|
+
const [errorMessage, setErrorMessage] = (0, import_react33.useState)("");
|
|
73199
|
+
const [authMessage, setAuthMessage] = (0, import_react33.useState)("");
|
|
73200
|
+
(0, import_react33.useEffect)(() => {
|
|
72525
73201
|
let cancelled = false;
|
|
72526
73202
|
async function run() {
|
|
72527
73203
|
setPhase("auth");
|
|
@@ -72569,32 +73245,32 @@ function LicenseCreateApp({ onIssued }) {
|
|
|
72569
73245
|
cancelled = true;
|
|
72570
73246
|
};
|
|
72571
73247
|
}, [browserLogin.runLogin, onIssued, exit]);
|
|
72572
|
-
if (browserLogin.state.phase
|
|
72573
|
-
return /* @__PURE__ */ (0,
|
|
73248
|
+
if (shouldRenderLicenseCreateBrowserLoginConfirmation(browserLogin.state.phase)) {
|
|
73249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BrowserLoginConfirmation, {});
|
|
72574
73250
|
}
|
|
72575
73251
|
if (phase === "auth") {
|
|
72576
|
-
return /* @__PURE__ */ (0,
|
|
72577
|
-
authMessage ? /* @__PURE__ */ (0,
|
|
72578
|
-
/* @__PURE__ */ (0,
|
|
73252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73253
|
+
authMessage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: "yellow", children: authMessage }) : null,
|
|
73254
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, { label: "Verifying authentication\u2026" })
|
|
72579
73255
|
] });
|
|
72580
73256
|
}
|
|
72581
73257
|
if (phase === "issue") {
|
|
72582
|
-
return /* @__PURE__ */ (0,
|
|
72583
|
-
authMessage ? /* @__PURE__ */ (0,
|
|
72584
|
-
/* @__PURE__ */ (0,
|
|
73258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
73259
|
+
authMessage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: "yellow", children: authMessage }) : null,
|
|
73260
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, { label: "Issuing license key\u2026" })
|
|
72585
73261
|
] });
|
|
72586
73262
|
}
|
|
72587
73263
|
if (phase === "success") {
|
|
72588
|
-
return /* @__PURE__ */ (0,
|
|
72589
|
-
/* @__PURE__ */ (0,
|
|
72590
|
-
/* @__PURE__ */ (0,
|
|
73264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", gap: 1, children: [
|
|
73265
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: "green", children: "License key issued." }),
|
|
73266
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
|
|
72591
73267
|
"Add the line printed below to your ",
|
|
72592
|
-
/* @__PURE__ */ (0,
|
|
73268
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: true, children: ".env" }),
|
|
72593
73269
|
" file:"
|
|
72594
73270
|
] })
|
|
72595
73271
|
] });
|
|
72596
73272
|
}
|
|
72597
|
-
return /* @__PURE__ */ (0,
|
|
73273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: "red", children: [
|
|
72598
73274
|
"License failed: ",
|
|
72599
73275
|
errorMessage
|
|
72600
73276
|
] }) });
|
|
@@ -72624,7 +73300,7 @@ async function runLicense(command) {
|
|
|
72624
73300
|
}
|
|
72625
73301
|
let issuedKey = null;
|
|
72626
73302
|
const { waitUntilExit } = render_default(
|
|
72627
|
-
/* @__PURE__ */ (0,
|
|
73303
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BrowserLoginProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LicenseCreateApp, { onIssued: (k) => {
|
|
72628
73304
|
issuedKey = k;
|
|
72629
73305
|
} }) })
|
|
72630
73306
|
);
|
|
@@ -72634,11 +73310,11 @@ async function runLicense(command) {
|
|
|
72634
73310
|
`);
|
|
72635
73311
|
}
|
|
72636
73312
|
}
|
|
72637
|
-
var
|
|
73313
|
+
var import_react33, import_jsx_runtime4;
|
|
72638
73314
|
var init_license = __esm({
|
|
72639
73315
|
async "apps/cli/src/commands/license.tsx"() {
|
|
72640
73316
|
"use strict";
|
|
72641
|
-
|
|
73317
|
+
import_react33 = __toESM(require_react(), 1);
|
|
72642
73318
|
await init_build2();
|
|
72643
73319
|
await init_build2();
|
|
72644
73320
|
init_auth_service();
|
|
@@ -72647,7 +73323,7 @@ var init_license = __esm({
|
|
|
72647
73323
|
await init_browser_login();
|
|
72648
73324
|
await init_spinner();
|
|
72649
73325
|
init_config();
|
|
72650
|
-
|
|
73326
|
+
import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
72651
73327
|
}
|
|
72652
73328
|
});
|
|
72653
73329
|
|
|
@@ -73410,17 +74086,17 @@ var init_project_scaffold = __esm({
|
|
|
73410
74086
|
|
|
73411
74087
|
// apps/cli/src/ui/banner.tsx
|
|
73412
74088
|
function Banner() {
|
|
73413
|
-
return /* @__PURE__ */ (0,
|
|
73414
|
-
/* @__PURE__ */ (0,
|
|
73415
|
-
/* @__PURE__ */ (0,
|
|
74089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginBottom: 1, children: [
|
|
74090
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: "magenta", children: KITE }),
|
|
74091
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: "magenta", children: "~ Welcome to CopilotKit! ~" })
|
|
73416
74092
|
] });
|
|
73417
74093
|
}
|
|
73418
|
-
var
|
|
74094
|
+
var import_jsx_runtime5, KITE;
|
|
73419
74095
|
var init_banner = __esm({
|
|
73420
74096
|
async "apps/cli/src/ui/banner.tsx"() {
|
|
73421
74097
|
"use strict";
|
|
73422
74098
|
await init_build2();
|
|
73423
|
-
|
|
74099
|
+
import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
73424
74100
|
KITE = `\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
|
|
73425
74101
|
\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u281F\u2819\u28FF\u285B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
|
|
73426
74102
|
\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u280B\u2800\u2800\u2808\u28BF\u2844\u2800\u2800\u2800\u2808\u2809\u2819\u28FB\u28FF\u28FF\u28FF
|
|
@@ -73740,13 +74416,13 @@ var init_figures = __esm({
|
|
|
73740
74416
|
|
|
73741
74417
|
// 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
74418
|
function Indicator({ isSelected = false }) {
|
|
73743
|
-
return
|
|
74419
|
+
return import_react34.default.createElement(Box_default, { marginRight: 1 }, isSelected ? import_react34.default.createElement(Text, { color: "blue" }, figures_default.pointer) : import_react34.default.createElement(Text, null, " "));
|
|
73744
74420
|
}
|
|
73745
|
-
var
|
|
74421
|
+
var import_react34, Indicator_default;
|
|
73746
74422
|
var init_Indicator = __esm({
|
|
73747
74423
|
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
74424
|
"use strict";
|
|
73749
|
-
|
|
74425
|
+
import_react34 = __toESM(require_react(), 1);
|
|
73750
74426
|
await init_build2();
|
|
73751
74427
|
init_figures();
|
|
73752
74428
|
Indicator_default = Indicator;
|
|
@@ -73755,13 +74431,13 @@ var init_Indicator = __esm({
|
|
|
73755
74431
|
|
|
73756
74432
|
// 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
74433
|
function Item({ isSelected = false, label }) {
|
|
73758
|
-
return
|
|
74434
|
+
return React13.createElement(Text, { color: isSelected ? "blue" : void 0 }, label);
|
|
73759
74435
|
}
|
|
73760
|
-
var
|
|
74436
|
+
var React13, Item_default;
|
|
73761
74437
|
var init_Item = __esm({
|
|
73762
74438
|
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
74439
|
"use strict";
|
|
73764
|
-
|
|
74440
|
+
React13 = __toESM(require_react(), 1);
|
|
73765
74441
|
await init_build2();
|
|
73766
74442
|
Item_default = Item;
|
|
73767
74443
|
}
|
|
@@ -73800,17 +74476,17 @@ function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicator
|
|
|
73800
74476
|
const hasLimit = typeof customLimit === "number" && items.length > customLimit;
|
|
73801
74477
|
const limit = hasLimit ? Math.min(customLimit, items.length) : items.length;
|
|
73802
74478
|
const lastIndex = limit - 1;
|
|
73803
|
-
const [rotateIndex, setRotateIndex] = (0,
|
|
73804
|
-
const [selectedIndex, setSelectedIndex] = (0,
|
|
73805
|
-
const previousItems = (0,
|
|
73806
|
-
(0,
|
|
74479
|
+
const [rotateIndex, setRotateIndex] = (0, import_react35.useState)(initialIndex > lastIndex ? lastIndex - initialIndex : 0);
|
|
74480
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react35.useState)(initialIndex ? initialIndex > lastIndex ? lastIndex : initialIndex : 0);
|
|
74481
|
+
const previousItems = (0, import_react35.useRef)(items);
|
|
74482
|
+
(0, import_react35.useEffect)(() => {
|
|
73807
74483
|
if (!isDeepStrictEqual2(previousItems.current.map((item) => item.value), items.map((item) => item.value))) {
|
|
73808
74484
|
setRotateIndex(0);
|
|
73809
74485
|
setSelectedIndex(0);
|
|
73810
74486
|
}
|
|
73811
74487
|
previousItems.current = items;
|
|
73812
74488
|
}, [items]);
|
|
73813
|
-
use_input_default((0,
|
|
74489
|
+
use_input_default((0, import_react35.useCallback)((input, key) => {
|
|
73814
74490
|
if (input === "k" || key.upArrow) {
|
|
73815
74491
|
const lastIndex2 = (hasLimit ? limit : items.length) - 1;
|
|
73816
74492
|
const atFirstIndex = selectedIndex === 0;
|
|
@@ -73862,24 +74538,24 @@ function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicator
|
|
|
73862
74538
|
onHighlight
|
|
73863
74539
|
]), { isActive: isFocused });
|
|
73864
74540
|
const slicedItems = hasLimit ? toRotated(items, rotateIndex).slice(0, limit) : items;
|
|
73865
|
-
return
|
|
74541
|
+
return import_react35.default.createElement(Box_default, { flexDirection: "column" }, slicedItems.map((item, index) => {
|
|
73866
74542
|
const isSelected = index === selectedIndex;
|
|
73867
74543
|
return (
|
|
73868
74544
|
// @ts-expect-error - `key` can't be optional but `item.value` is generic T
|
|
73869
|
-
|
|
74545
|
+
import_react35.default.createElement(
|
|
73870
74546
|
Box_default,
|
|
73871
74547
|
{ key: item.key ?? item.value },
|
|
73872
|
-
|
|
73873
|
-
|
|
74548
|
+
import_react35.default.createElement(indicatorComponent, { isSelected }),
|
|
74549
|
+
import_react35.default.createElement(itemComponent, { ...item, isSelected })
|
|
73874
74550
|
)
|
|
73875
74551
|
);
|
|
73876
74552
|
}));
|
|
73877
74553
|
}
|
|
73878
|
-
var
|
|
74554
|
+
var import_react35, SelectInput_default;
|
|
73879
74555
|
var init_SelectInput = __esm({
|
|
73880
74556
|
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
74557
|
"use strict";
|
|
73882
|
-
|
|
74558
|
+
import_react35 = __toESM(require_react(), 1);
|
|
73883
74559
|
init_to_rotated();
|
|
73884
74560
|
await init_build2();
|
|
73885
74561
|
await init_Indicator();
|
|
@@ -73889,7 +74565,7 @@ var init_SelectInput = __esm({
|
|
|
73889
74565
|
});
|
|
73890
74566
|
|
|
73891
74567
|
// 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
|
|
74568
|
+
var init_build4 = __esm({
|
|
73893
74569
|
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
74570
|
"use strict";
|
|
73895
74571
|
await init_Indicator();
|
|
@@ -73898,104 +74574,6 @@ var init_build3 = __esm({
|
|
|
73898
74574
|
}
|
|
73899
74575
|
});
|
|
73900
74576
|
|
|
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
74577
|
// apps/cli/src/ui/init-flow.tsx
|
|
74000
74578
|
function validateName(name) {
|
|
74001
74579
|
if (name.length === 0)
|
|
@@ -74012,8 +74590,8 @@ function InitFlow({
|
|
|
74012
74590
|
initialFramework,
|
|
74013
74591
|
onComplete
|
|
74014
74592
|
}) {
|
|
74015
|
-
const [name, setName] = (0,
|
|
74016
|
-
const [nameError, setNameError] = (0,
|
|
74593
|
+
const [name, setName] = (0, import_react36.useState)(initialName ?? "");
|
|
74594
|
+
const [nameError, setNameError] = (0, import_react36.useState)(null);
|
|
74017
74595
|
function firstStep() {
|
|
74018
74596
|
if (initialName === null)
|
|
74019
74597
|
return "name";
|
|
@@ -74025,8 +74603,8 @@ function InitFlow({
|
|
|
74025
74603
|
return "framework";
|
|
74026
74604
|
return "intelligence";
|
|
74027
74605
|
}
|
|
74028
|
-
const [step, setStep] = (0,
|
|
74029
|
-
(0,
|
|
74606
|
+
const [step, setStep] = (0, import_react36.useState)(firstStep);
|
|
74607
|
+
(0, import_react36.useEffect)(() => {
|
|
74030
74608
|
if (step === "done") {
|
|
74031
74609
|
if (initialFramework !== null) {
|
|
74032
74610
|
onComplete({
|
|
@@ -74101,16 +74679,16 @@ function InitFlow({
|
|
|
74101
74679
|
framework: chosen
|
|
74102
74680
|
});
|
|
74103
74681
|
}
|
|
74104
|
-
return /* @__PURE__ */ (0,
|
|
74105
|
-
step === "name" && /* @__PURE__ */ (0,
|
|
74106
|
-
/* @__PURE__ */ (0,
|
|
74107
|
-
/* @__PURE__ */ (0,
|
|
74108
|
-
/* @__PURE__ */ (0,
|
|
74109
|
-
/* @__PURE__ */ (0,
|
|
74682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74683
|
+
step === "name" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74684
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, children: "Project name" }),
|
|
74685
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: "gray", children: "Lowercase letters, numbers, hyphens \u2014 max 30 chars" }),
|
|
74686
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { children: [
|
|
74687
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
|
|
74110
74688
|
">",
|
|
74111
74689
|
" "
|
|
74112
74690
|
] }),
|
|
74113
|
-
/* @__PURE__ */ (0,
|
|
74691
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
74114
74692
|
build_default,
|
|
74115
74693
|
{
|
|
74116
74694
|
value: name,
|
|
@@ -74120,29 +74698,29 @@ function InitFlow({
|
|
|
74120
74698
|
}
|
|
74121
74699
|
)
|
|
74122
74700
|
] }),
|
|
74123
|
-
nameError !== null && /* @__PURE__ */ (0,
|
|
74701
|
+
nameError !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: "red", children: nameError })
|
|
74124
74702
|
] }),
|
|
74125
|
-
step === "intelligence" && /* @__PURE__ */ (0,
|
|
74126
|
-
/* @__PURE__ */ (0,
|
|
74127
|
-
/* @__PURE__ */ (0,
|
|
74128
|
-
/* @__PURE__ */ (0,
|
|
74703
|
+
step === "intelligence" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74704
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, children: "Do you want to use CopilotKit Intelligence?" }),
|
|
74705
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: "gray", children: "Intelligence adds durable threads, state persistence, and insights." }),
|
|
74706
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectInput_default, { items: INTELLIGENCE_CHOICES, onSelect: handleIntelligenceSelect })
|
|
74129
74707
|
] }),
|
|
74130
|
-
step === "framework" && /* @__PURE__ */ (0,
|
|
74131
|
-
/* @__PURE__ */ (0,
|
|
74132
|
-
/* @__PURE__ */ (0,
|
|
74708
|
+
step === "framework" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74709
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, children: "Select agent framework" }),
|
|
74710
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectInput_default, { items: FRAMEWORK_CHOICES, onSelect: handleFrameworkSelect })
|
|
74133
74711
|
] })
|
|
74134
74712
|
] });
|
|
74135
74713
|
}
|
|
74136
|
-
var
|
|
74714
|
+
var import_react36, import_jsx_runtime6, PROJECT_NAME_RE, INTELLIGENCE_CHOICES;
|
|
74137
74715
|
var init_init_flow = __esm({
|
|
74138
74716
|
async "apps/cli/src/ui/init-flow.tsx"() {
|
|
74139
74717
|
"use strict";
|
|
74140
|
-
|
|
74718
|
+
import_react36 = __toESM(require_react(), 1);
|
|
74141
74719
|
await init_build2();
|
|
74142
|
-
await init_build3();
|
|
74143
74720
|
await init_build4();
|
|
74721
|
+
await init_build3();
|
|
74144
74722
|
init_types();
|
|
74145
|
-
|
|
74723
|
+
import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
74146
74724
|
PROJECT_NAME_RE = /^[a-z0-9-]{1,30}$/;
|
|
74147
74725
|
INTELLIGENCE_CHOICES = [
|
|
74148
74726
|
{ label: "Yes \u2014 enable Intelligence (threads, persistence, insights)", value: "yes" },
|
|
@@ -74154,14 +74732,20 @@ var init_init_flow = __esm({
|
|
|
74154
74732
|
// apps/cli/src/commands/init.tsx
|
|
74155
74733
|
var init_exports = {};
|
|
74156
74734
|
__export(init_exports, {
|
|
74735
|
+
InitApp: () => InitApp,
|
|
74157
74736
|
buildInitNextSteps: () => buildInitNextSteps,
|
|
74158
74737
|
commandExists: () => commandExists,
|
|
74738
|
+
resolvePrefilledOptions: () => resolvePrefilledOptions,
|
|
74159
74739
|
runInit: () => runInit,
|
|
74160
|
-
scaffoldInitProject: () => scaffoldInitProject
|
|
74740
|
+
scaffoldInitProject: () => scaffoldInitProject,
|
|
74741
|
+
shouldRenderInitBrowserLoginConfirmation: () => shouldRenderInitBrowserLoginConfirmation
|
|
74161
74742
|
});
|
|
74162
74743
|
import { accessSync, constants as constants2 } from "node:fs";
|
|
74163
74744
|
import * as path10 from "node:path";
|
|
74164
74745
|
import { execSync as execSync2 } from "node:child_process";
|
|
74746
|
+
function shouldRenderInitBrowserLoginConfirmation(phase) {
|
|
74747
|
+
return phase === "confirming" || phase === "waiting" || phase === "finalizing";
|
|
74748
|
+
}
|
|
74165
74749
|
function writeLicenseKey(projectDir, licenseKey) {
|
|
74166
74750
|
writeEnvLicenseKey(projectDir, licenseKey);
|
|
74167
74751
|
}
|
|
@@ -74199,42 +74783,33 @@ function buildInitNextSteps(templateDefinition, projectName, result) {
|
|
|
74199
74783
|
const envTarget = result.envCreatedFromExample || result.licenseWritten ? "the scaffolded .env file" : ".env";
|
|
74200
74784
|
return `Set ${envKey.key} in ${envTarget}. ${envKey.note}`;
|
|
74201
74785
|
});
|
|
74202
|
-
const commandPrefix = `cd ${projectName}`;
|
|
74203
|
-
const steps = [`Directory: ${result.projectDir}`];
|
|
74204
74786
|
const setupMissing = missingPrerequisites.filter(
|
|
74205
74787
|
(prerequisite) => prerequisite.phase === "setup"
|
|
74206
74788
|
);
|
|
74207
|
-
|
|
74208
|
-
|
|
74209
|
-
|
|
74210
|
-
|
|
74211
|
-
|
|
74212
|
-
|
|
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}`);
|
|
74789
|
+
const runtimeMissing = missingPrerequisites.filter(
|
|
74790
|
+
(prerequisite) => prerequisite.phase === "runtime"
|
|
74791
|
+
);
|
|
74792
|
+
const steps = [`Directory: ${result.projectDir}`];
|
|
74793
|
+
for (const prerequisite of missingPrerequisites) {
|
|
74794
|
+
steps.push(`Missing ${prerequisite.label}: ${prerequisite.installHint}`);
|
|
74224
74795
|
}
|
|
74225
74796
|
for (const envNote of envNotes) {
|
|
74226
74797
|
steps.push(envNote);
|
|
74227
74798
|
}
|
|
74228
|
-
|
|
74229
|
-
|
|
74230
|
-
|
|
74231
|
-
if (runtimeMissing.length
|
|
74232
|
-
|
|
74233
|
-
}
|
|
74234
|
-
|
|
74235
|
-
|
|
74236
|
-
|
|
74799
|
+
let header = "Run these commands:";
|
|
74800
|
+
if (setupMissing.length > 0) {
|
|
74801
|
+
header = "After installing setup prerequisites, run:";
|
|
74802
|
+
} else if (runtimeMissing.length > 0) {
|
|
74803
|
+
header = "After runtime prerequisites are ready, run:";
|
|
74804
|
+
}
|
|
74805
|
+
steps.push(header);
|
|
74806
|
+
steps.push(` cd ${projectName}`);
|
|
74807
|
+
steps.push(` ${templateDefinition.installCommand}`);
|
|
74808
|
+
for (const postInstallCommand of templateDefinition.postInstallCommands ?? []) {
|
|
74809
|
+
const formatted = postInstallCommand.startsWith("cd ") ? `(${postInstallCommand})` : postInstallCommand;
|
|
74810
|
+
steps.push(` ${formatted}`);
|
|
74237
74811
|
}
|
|
74812
|
+
steps.push(` ${templateDefinition.runCommand}`);
|
|
74238
74813
|
return steps;
|
|
74239
74814
|
}
|
|
74240
74815
|
async function ensureCliToken2(dependencies, onTerminalSessionInvalidation) {
|
|
@@ -74343,25 +74918,25 @@ function ScaffoldProgress({ options }) {
|
|
|
74343
74918
|
const { exit } = use_app_default();
|
|
74344
74919
|
const browserLogin = useBrowserLogin();
|
|
74345
74920
|
const templateDefinition = resolveInitTemplate(options);
|
|
74346
|
-
const [phase, setPhase] = (0,
|
|
74921
|
+
const [phase, setPhase] = (0, import_react37.useState)(
|
|
74347
74922
|
templateDefinition.requiresLicense ? "auth" : "scaffold"
|
|
74348
74923
|
);
|
|
74349
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
74350
|
-
const [authMessage, setAuthMessage] = (0,
|
|
74351
|
-
const [nextSteps, setNextSteps] = (0,
|
|
74352
|
-
const scaffoldDependencies = (0,
|
|
74924
|
+
const [errorMessage, setErrorMessage] = (0, import_react37.useState)("");
|
|
74925
|
+
const [authMessage, setAuthMessage] = (0, import_react37.useState)("");
|
|
74926
|
+
const [nextSteps, setNextSteps] = (0, import_react37.useState)([]);
|
|
74927
|
+
const scaffoldDependencies = (0, import_react37.useMemo)(
|
|
74353
74928
|
() => ({
|
|
74354
74929
|
...defaultInitScaffoldDependencies,
|
|
74355
74930
|
login: browserLogin.runLogin
|
|
74356
74931
|
}),
|
|
74357
74932
|
[browserLogin.runLogin]
|
|
74358
74933
|
);
|
|
74359
|
-
(0,
|
|
74934
|
+
(0, import_react37.useEffect)(() => {
|
|
74360
74935
|
if (phase === "success" || phase === "error") {
|
|
74361
74936
|
exit();
|
|
74362
74937
|
}
|
|
74363
74938
|
}, [phase, exit]);
|
|
74364
|
-
(0,
|
|
74939
|
+
(0, import_react37.useEffect)(() => {
|
|
74365
74940
|
let cancelled = false;
|
|
74366
74941
|
async function run() {
|
|
74367
74942
|
const result = await scaffoldInitProject(
|
|
@@ -74397,43 +74972,46 @@ function ScaffoldProgress({ options }) {
|
|
|
74397
74972
|
cancelled = true;
|
|
74398
74973
|
};
|
|
74399
74974
|
}, [options, scaffoldDependencies]);
|
|
74400
|
-
if (browserLogin.state.phase
|
|
74401
|
-
return /* @__PURE__ */ (0,
|
|
74975
|
+
if (shouldRenderInitBrowserLoginConfirmation(browserLogin.state.phase)) {
|
|
74976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BrowserLoginConfirmation, {});
|
|
74402
74977
|
}
|
|
74403
74978
|
if (phase === "auth") {
|
|
74404
|
-
return /* @__PURE__ */ (0,
|
|
74405
|
-
authMessage ? /* @__PURE__ */ (0,
|
|
74406
|
-
/* @__PURE__ */ (0,
|
|
74979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74980
|
+
authMessage ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "yellow", children: authMessage }) : null,
|
|
74981
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { label: "\u{1FA81} Verifying authentication\u2026" })
|
|
74407
74982
|
] });
|
|
74408
74983
|
}
|
|
74409
74984
|
if (phase === "license") {
|
|
74410
|
-
return /* @__PURE__ */ (0,
|
|
74411
|
-
authMessage ? /* @__PURE__ */ (0,
|
|
74412
|
-
/* @__PURE__ */ (0,
|
|
74985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74986
|
+
authMessage ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "yellow", children: authMessage }) : null,
|
|
74987
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { label: "\u{1FA81} Issuing license key\u2026" })
|
|
74413
74988
|
] });
|
|
74414
74989
|
}
|
|
74415
74990
|
if (phase === "scaffold") {
|
|
74416
|
-
return /* @__PURE__ */ (0,
|
|
74991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { label: "\u{1FA81} Downloading template\u2026" }) });
|
|
74417
74992
|
}
|
|
74418
74993
|
if (phase === "git") {
|
|
74419
|
-
return /* @__PURE__ */ (0,
|
|
74994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { label: "Initializing git repository\u2026" }) });
|
|
74420
74995
|
}
|
|
74421
74996
|
if (phase === "success") {
|
|
74422
|
-
return /* @__PURE__ */ (0,
|
|
74423
|
-
/* @__PURE__ */ (0,
|
|
74997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
74998
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "green", children: [
|
|
74424
74999
|
templateDefinition.successEmoji,
|
|
74425
75000
|
' Project "',
|
|
74426
75001
|
options.name,
|
|
74427
75002
|
'" created successfully!'
|
|
74428
75003
|
] }),
|
|
74429
|
-
nextSteps.map((step) => /* @__PURE__ */ (0,
|
|
75004
|
+
nextSteps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "gray", children: step }, `step-${index}`))
|
|
74430
75005
|
] });
|
|
74431
75006
|
}
|
|
74432
|
-
return /* @__PURE__ */ (0,
|
|
75007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "red", children: [
|
|
74433
75008
|
"Init failed: ",
|
|
74434
75009
|
errorMessage
|
|
74435
75010
|
] }) });
|
|
74436
75011
|
}
|
|
75012
|
+
function renderDefaultScaffoldProgress(options) {
|
|
75013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScaffoldProgress, { options });
|
|
75014
|
+
}
|
|
74437
75015
|
function resolvePrefilledOptions(name, intelligence, framework) {
|
|
74438
75016
|
if (name === null)
|
|
74439
75017
|
return null;
|
|
@@ -74452,29 +75030,33 @@ function resolvePrefilledOptions(name, intelligence, framework) {
|
|
|
74452
75030
|
function InitApp({
|
|
74453
75031
|
initialName,
|
|
74454
75032
|
initialIntelligence,
|
|
74455
|
-
initialFramework
|
|
75033
|
+
initialFramework,
|
|
75034
|
+
renderScaffoldProgress = renderDefaultScaffoldProgress
|
|
74456
75035
|
}) {
|
|
74457
75036
|
const prefilled = resolvePrefilledOptions(
|
|
74458
75037
|
initialName,
|
|
74459
75038
|
initialIntelligence,
|
|
74460
75039
|
initialFramework
|
|
74461
75040
|
);
|
|
74462
|
-
const [options, setOptions] = (0,
|
|
74463
|
-
return /* @__PURE__ */ (0,
|
|
74464
|
-
/* @__PURE__ */ (0,
|
|
74465
|
-
options !== null ? /* @__PURE__ */ (0,
|
|
74466
|
-
|
|
74467
|
-
|
|
74468
|
-
|
|
74469
|
-
|
|
74470
|
-
|
|
74471
|
-
|
|
74472
|
-
|
|
74473
|
-
|
|
75041
|
+
const [options, setOptions] = (0, import_react37.useState)(prefilled);
|
|
75042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
75043
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Banner, {}),
|
|
75044
|
+
options !== null ? renderScaffoldProgress(options) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
75045
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
75046
|
+
InitFlow,
|
|
75047
|
+
{
|
|
75048
|
+
initialName,
|
|
75049
|
+
initialIntelligence,
|
|
75050
|
+
initialFramework,
|
|
75051
|
+
onComplete: (resolved) => {
|
|
75052
|
+
if (resolved !== null) {
|
|
75053
|
+
setOptions(resolved);
|
|
75054
|
+
}
|
|
74474
75055
|
}
|
|
74475
75056
|
}
|
|
74476
|
-
|
|
74477
|
-
|
|
75057
|
+
),
|
|
75058
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CliTip, {})
|
|
75059
|
+
] })
|
|
74478
75060
|
] });
|
|
74479
75061
|
}
|
|
74480
75062
|
async function runInit(flags) {
|
|
@@ -74487,7 +75069,7 @@ async function runInit(flags) {
|
|
|
74487
75069
|
}
|
|
74488
75070
|
const initialFramework = frameworkFlag;
|
|
74489
75071
|
const { waitUntilExit } = render_default(
|
|
74490
|
-
/* @__PURE__ */ (0,
|
|
75072
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BrowserLoginProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
74491
75073
|
InitApp,
|
|
74492
75074
|
{
|
|
74493
75075
|
initialName,
|
|
@@ -74498,11 +75080,11 @@ async function runInit(flags) {
|
|
|
74498
75080
|
);
|
|
74499
75081
|
await waitUntilExit();
|
|
74500
75082
|
}
|
|
74501
|
-
var
|
|
75083
|
+
var import_react37, import_jsx_runtime7, defaultInitScaffoldDependencies;
|
|
74502
75084
|
var init_init = __esm({
|
|
74503
75085
|
async "apps/cli/src/commands/init.tsx"() {
|
|
74504
75086
|
"use strict";
|
|
74505
|
-
|
|
75087
|
+
import_react37 = __toESM(require_react(), 1);
|
|
74506
75088
|
await init_build2();
|
|
74507
75089
|
await init_build2();
|
|
74508
75090
|
init_types();
|
|
@@ -74512,10 +75094,11 @@ var init_init = __esm({
|
|
|
74512
75094
|
init_config_service();
|
|
74513
75095
|
await init_banner();
|
|
74514
75096
|
await init_browser_login();
|
|
75097
|
+
await init_cli_tip();
|
|
74515
75098
|
await init_init_flow();
|
|
74516
75099
|
await init_spinner();
|
|
74517
75100
|
init_config();
|
|
74518
|
-
|
|
75101
|
+
import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
74519
75102
|
defaultInitScaffoldDependencies = {
|
|
74520
75103
|
verifyAndRefresh,
|
|
74521
75104
|
login,
|
|
@@ -74556,7 +75139,7 @@ var init_version = __esm({
|
|
|
74556
75139
|
// apps/cli/src/ui/login-flow.tsx
|
|
74557
75140
|
function LoginFlow({ onComplete }) {
|
|
74558
75141
|
const { runLogin: runLogin2 } = useBrowserLogin();
|
|
74559
|
-
(0,
|
|
75142
|
+
(0, import_react38.useEffect)(() => {
|
|
74560
75143
|
runLogin2().then(() => {
|
|
74561
75144
|
onComplete({ success: true });
|
|
74562
75145
|
}).catch((error48) => {
|
|
@@ -74568,15 +75151,15 @@ function LoginFlow({ onComplete }) {
|
|
|
74568
75151
|
onComplete({ error: fallbackError, success: false });
|
|
74569
75152
|
});
|
|
74570
75153
|
}, [onComplete, runLogin2]);
|
|
74571
|
-
return /* @__PURE__ */ (0,
|
|
75154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrowserLoginConfirmation, {});
|
|
74572
75155
|
}
|
|
74573
|
-
var
|
|
75156
|
+
var import_react38, import_jsx_runtime8;
|
|
74574
75157
|
var init_login_flow = __esm({
|
|
74575
75158
|
async "apps/cli/src/ui/login-flow.tsx"() {
|
|
74576
75159
|
"use strict";
|
|
74577
|
-
|
|
75160
|
+
import_react38 = __toESM(require_react(), 1);
|
|
74578
75161
|
await init_browser_login();
|
|
74579
|
-
|
|
75162
|
+
import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
74580
75163
|
}
|
|
74581
75164
|
});
|
|
74582
75165
|
|
|
@@ -74588,7 +75171,7 @@ __export(login_exports, {
|
|
|
74588
75171
|
async function runLogin() {
|
|
74589
75172
|
return await new Promise((resolve2, reject) => {
|
|
74590
75173
|
const { unmount } = render_default(
|
|
74591
|
-
/* @__PURE__ */ (0,
|
|
75174
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BrowserLoginProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
74592
75175
|
LoginFlow,
|
|
74593
75176
|
{
|
|
74594
75177
|
onComplete: (result) => {
|
|
@@ -74606,14 +75189,14 @@ async function runLogin() {
|
|
|
74606
75189
|
);
|
|
74607
75190
|
});
|
|
74608
75191
|
}
|
|
74609
|
-
var
|
|
75192
|
+
var import_jsx_runtime9;
|
|
74610
75193
|
var init_login = __esm({
|
|
74611
75194
|
async "apps/cli/src/commands/login.tsx"() {
|
|
74612
75195
|
"use strict";
|
|
74613
75196
|
await init_build2();
|
|
74614
75197
|
await init_login_flow();
|
|
74615
75198
|
await init_browser_login();
|
|
74616
|
-
|
|
75199
|
+
import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
74617
75200
|
}
|
|
74618
75201
|
});
|
|
74619
75202
|
|
|
@@ -89184,16 +89767,16 @@ function KiteGame({
|
|
|
89184
89767
|
const { stdout } = use_stdout_default();
|
|
89185
89768
|
const terminalWidth = useTerminalWidth(stdout);
|
|
89186
89769
|
const playableWidth = getPlayableWidth(terminalWidth);
|
|
89187
|
-
const rngRef = (0,
|
|
89188
|
-
const [highScore, setHighScore] = (0,
|
|
89189
|
-
const [state, setState] = (0,
|
|
89770
|
+
const rngRef = (0, import_react39.useRef)(rng);
|
|
89771
|
+
const [highScore, setHighScore] = (0, import_react39.useState)(() => readKiteGameHighScore());
|
|
89772
|
+
const [state, setState] = (0, import_react39.useState)(
|
|
89190
89773
|
() => createKiteGame({ width: playableWidth, rng: rngRef.current })
|
|
89191
89774
|
);
|
|
89192
|
-
const rows = (0,
|
|
89193
|
-
(0,
|
|
89775
|
+
const rows = (0, import_react39.useMemo)(() => renderKiteGameRows(state), [state]);
|
|
89776
|
+
(0, import_react39.useEffect)(() => {
|
|
89194
89777
|
rngRef.current = rng;
|
|
89195
89778
|
}, [rng]);
|
|
89196
|
-
(0,
|
|
89779
|
+
(0, import_react39.useEffect)(() => {
|
|
89197
89780
|
setState((currentState) => {
|
|
89198
89781
|
if (currentState.width === playableWidth) {
|
|
89199
89782
|
return currentState;
|
|
@@ -89205,13 +89788,13 @@ function KiteGame({
|
|
|
89205
89788
|
});
|
|
89206
89789
|
});
|
|
89207
89790
|
}, [playableWidth]);
|
|
89208
|
-
(0,
|
|
89791
|
+
(0, import_react39.useEffect)(() => {
|
|
89209
89792
|
if (!state.crashed) {
|
|
89210
89793
|
return;
|
|
89211
89794
|
}
|
|
89212
89795
|
setHighScore(saveKiteGameHighScore(state.score));
|
|
89213
89796
|
}, [state.crashed, state.score]);
|
|
89214
|
-
(0,
|
|
89797
|
+
(0, import_react39.useEffect)(() => {
|
|
89215
89798
|
if (!state.started || state.crashed) {
|
|
89216
89799
|
return void 0;
|
|
89217
89800
|
}
|
|
@@ -89254,23 +89837,23 @@ function KiteGame({
|
|
|
89254
89837
|
setState((currentState) => flapKite(currentState));
|
|
89255
89838
|
}
|
|
89256
89839
|
});
|
|
89257
|
-
return /* @__PURE__ */ (0,
|
|
89258
|
-
/* @__PURE__ */ (0,
|
|
89840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
89841
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { children: [
|
|
89259
89842
|
"CopilotKit Kite Score ",
|
|
89260
89843
|
state.score,
|
|
89261
89844
|
" High",
|
|
89262
89845
|
" ",
|
|
89263
89846
|
Math.max(highScore, state.score)
|
|
89264
89847
|
] }),
|
|
89265
|
-
/* @__PURE__ */ (0,
|
|
89266
|
-
/* @__PURE__ */ (0,
|
|
89848
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { flexDirection: "column", borderStyle: "single", children: rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { children: row }, `${index}-${row}`)) }),
|
|
89849
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { children: state.crashed ? "Crashed. Enter/r to reset. Space to restart. q/Esc to quit." : state.started ? "Space/up to send wind. q/Esc to quit." : "Ready. Space/up to start. q/Esc to quit." })
|
|
89267
89850
|
] });
|
|
89268
89851
|
}
|
|
89269
89852
|
function useTerminalWidth(stdout) {
|
|
89270
|
-
const [terminalWidth, setTerminalWidth] = (0,
|
|
89853
|
+
const [terminalWidth, setTerminalWidth] = (0, import_react39.useState)(
|
|
89271
89854
|
() => getStdoutColumns(stdout)
|
|
89272
89855
|
);
|
|
89273
|
-
(0,
|
|
89856
|
+
(0, import_react39.useEffect)(() => {
|
|
89274
89857
|
const updateTerminalWidth = () => {
|
|
89275
89858
|
setTerminalWidth(getStdoutColumns(stdout));
|
|
89276
89859
|
};
|
|
@@ -89287,15 +89870,15 @@ function getStdoutColumns(stdout) {
|
|
|
89287
89870
|
function getPlayableWidth(terminalWidth) {
|
|
89288
89871
|
return Math.max(MIN_PLAYABLE_WIDTH, terminalWidth - BORDER_COLUMNS);
|
|
89289
89872
|
}
|
|
89290
|
-
var
|
|
89873
|
+
var import_react39, import_jsx_runtime10, DEFAULT_TICK_MS, MIN_PLAYABLE_WIDTH, BORDER_COLUMNS;
|
|
89291
89874
|
var init_kite_game = __esm({
|
|
89292
89875
|
async "apps/cli/src/ui/kite-game.tsx"() {
|
|
89293
89876
|
"use strict";
|
|
89294
89877
|
await init_build2();
|
|
89295
|
-
|
|
89878
|
+
import_react39 = __toESM(require_react(), 1);
|
|
89296
89879
|
init_kite_game_engine();
|
|
89297
89880
|
init_kite_game_score();
|
|
89298
|
-
|
|
89881
|
+
import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
89299
89882
|
DEFAULT_TICK_MS = 75;
|
|
89300
89883
|
MIN_PLAYABLE_WIDTH = 32;
|
|
89301
89884
|
BORDER_COLUMNS = 2;
|
|
@@ -89309,19 +89892,19 @@ __export(kite_exports, {
|
|
|
89309
89892
|
});
|
|
89310
89893
|
async function runKite() {
|
|
89311
89894
|
return await new Promise((resolve2, reject) => {
|
|
89312
|
-
const { waitUntilExit } = render_default(/* @__PURE__ */ (0,
|
|
89895
|
+
const { waitUntilExit } = render_default(/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(KiteGame, { onExit: resolve2 }));
|
|
89313
89896
|
waitUntilExit().then(() => {
|
|
89314
89897
|
resolve2();
|
|
89315
89898
|
}).catch(reject);
|
|
89316
89899
|
});
|
|
89317
89900
|
}
|
|
89318
|
-
var
|
|
89901
|
+
var import_jsx_runtime11;
|
|
89319
89902
|
var init_kite = __esm({
|
|
89320
89903
|
async "apps/cli/src/commands/kite.tsx"() {
|
|
89321
89904
|
"use strict";
|
|
89322
89905
|
await init_build2();
|
|
89323
89906
|
await init_kite_game();
|
|
89324
|
-
|
|
89907
|
+
import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
89325
89908
|
}
|
|
89326
89909
|
});
|
|
89327
89910
|
|