copilotkit 4.9.0 → 4.9.2

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.
Files changed (46) hide show
  1. package/README.md +24 -0
  2. package/cli-build-info.json +7 -7
  3. package/index.js +559 -96
  4. package/onboarding/index.json +10 -0
  5. package/onboarding/prompts/authenticate/start.md +43 -17
  6. package/onboarding/prompts/credentials/finalize-plan.md +62 -14
  7. package/onboarding/prompts/credentials/plan.md +26 -20
  8. package/onboarding/prompts/fallback/best-effort.md +10 -3
  9. package/onboarding/prompts/framework/ag2.md +2 -2
  10. package/onboarding/prompts/framework/agno.md +2 -2
  11. package/onboarding/prompts/framework/built-in.md +2 -2
  12. package/onboarding/prompts/framework/claude-sdk-python.md +2 -2
  13. package/onboarding/prompts/framework/claude-sdk-typescript.md +2 -2
  14. package/onboarding/prompts/framework/crewai-flows.md +2 -2
  15. package/onboarding/prompts/framework/deep-agents.md +2 -2
  16. package/onboarding/prompts/framework/google-adk.md +2 -2
  17. package/onboarding/prompts/framework/langgraph-fastapi.md +2 -2
  18. package/onboarding/prompts/framework/langgraph-python.md +2 -2
  19. package/onboarding/prompts/framework/langgraph-typescript.md +2 -2
  20. package/onboarding/prompts/framework/llamaindex.md +2 -2
  21. package/onboarding/prompts/framework/mastra.md +2 -2
  22. package/onboarding/prompts/framework/ms-agent-dotnet.md +2 -2
  23. package/onboarding/prompts/framework/ms-agent-harness-dotnet.md +2 -2
  24. package/onboarding/prompts/framework/ms-agent-python.md +2 -2
  25. package/onboarding/prompts/framework/pydantic-ai.md +2 -2
  26. package/onboarding/prompts/framework/strands-python.md +2 -2
  27. package/onboarding/prompts/framework/strands-typescript.md +2 -2
  28. package/onboarding/prompts/frontend/angular.md +7 -2
  29. package/onboarding/prompts/frontend/nextjs.md +17 -2
  30. package/onboarding/prompts/frontend/plan.md +12 -6
  31. package/onboarding/prompts/frontend/react-native.md +2 -2
  32. package/onboarding/prompts/frontend/react-spa.md +2 -2
  33. package/onboarding/prompts/frontend/vue.md +2 -2
  34. package/onboarding/prompts/implementation/build-and-validate.md +19 -4
  35. package/onboarding/prompts/proof/complete.md +51 -15
  36. package/onboarding/prompts/proof/oss-baseline.md +3 -3
  37. package/onboarding/prompts/proof/round-trip.md +192 -60
  38. package/onboarding/prompts/starter/clone.md +67 -0
  39. package/onboarding/prompts/subagent/create-plan.md +22 -4
  40. package/onboarding/prompts/subagent/implement-and-validate.md +17 -2
  41. package/onboarding/prompts/subagent/inspect-repository.md +11 -1
  42. package/onboarding/prompts/subagent/prove-oss-baseline.md +1 -1
  43. package/onboarding/prompts/subagent/prove-round-trip.md +184 -58
  44. package/onboarding/prompts/unsupported/no-validated-path.md +6 -5
  45. package/package.json +1 -1
  46. package/release/release-tool.js +15 -1
package/index.js CHANGED
@@ -96,14 +96,14 @@ function getTelemetryEndpointUrl() {
96
96
  }
97
97
  function getBuildInfo() {
98
98
  return {
99
- version: true ? "4.9.0" : "dev",
100
- buildNumber: true ? "32886074334" : "dev",
101
- commitSha: true ? "fab380427c6324aaf090b195af0f51eaf4a1a407" : "dev",
99
+ version: true ? "4.9.2" : "dev",
100
+ buildNumber: true ? "33012065996" : "dev",
101
+ commitSha: true ? "bc4cd3dc36cef218051ef6236acdef7033d2a7b0" : "dev",
102
102
  copilotKitCommit: getTemplateRef()
103
103
  };
104
104
  }
105
105
  function getTemplateRef() {
106
- return true ? "bf2068734bcc42b9dc9999b183d0fd07a673f713" : "main";
106
+ return true ? "e432fd161b9114fb15080dbd9d9208e29f5e8960" : "main";
107
107
  }
108
108
  function getC15tBackendUrl() {
109
109
  return true ? "https://calm-hazelnut-joy-copilotkit.inth.app" : "";
@@ -192,6 +192,9 @@ var init_starter_source_catalog = __esm({
192
192
  STARTER_SOURCE_CATALOG = {
193
193
  "langgraph-py": langGraphPython,
194
194
  "langgraph-js": copilotKitStarter("examples/integrations/langgraph-js"),
195
+ "langgraph-fastapi": copilotKitStarter(
196
+ "examples/integrations/langgraph-fastapi"
197
+ ),
195
198
  "claude-sdk-typescript": copilotKitStarter(
196
199
  "examples/integrations/claude-sdk-typescript"
197
200
  ),
@@ -412,6 +415,7 @@ function formatInvalidFrameworkError(value) {
412
415
  function standardTemplate(framework, template, successEmoji) {
413
416
  const pythonUvTemplates = /* @__PURE__ */ new Set([
414
417
  "langgraph-py",
418
+ "langgraph-fastapi",
415
419
  "claude-sdk-python",
416
420
  "flows",
417
421
  "llamaindex",
@@ -493,6 +497,7 @@ var init_types = __esm({
493
497
  FRAMEWORK_EMOJI = {
494
498
  "langgraph-py": "\u{1F99C}",
495
499
  "langgraph-js": "\u{1F99C}",
500
+ "langgraph-fastapi": "\u{1F99C}",
496
501
  "claude-sdk-typescript": "\u{1F506}",
497
502
  "claude-sdk-python": "\u{1F506}",
498
503
  flows: "\u{1F465}",
@@ -523,6 +528,10 @@ var init_types = __esm({
523
528
  label: `${FRAMEWORK_EMOJI["langgraph-js"]} LangGraph (JavaScript)`,
524
529
  value: "langgraph-js"
525
530
  },
531
+ {
532
+ label: `${FRAMEWORK_EMOJI["langgraph-fastapi"]} LangGraph (Python, FastAPI)`,
533
+ value: "langgraph-fastapi"
534
+ },
526
535
  {
527
536
  label: `${FRAMEWORK_EMOJI["claude-sdk-typescript"]} Claude Agent SDK (TypeScript)`,
528
537
  value: "claude-sdk-typescript"
@@ -636,6 +645,11 @@ var init_types = __esm({
636
645
  TEMPLATE_REPOS["langgraph-js"],
637
646
  `\u{1FA81}\u{1F91D}${FRAMEWORK_EMOJI["langgraph-js"]}`
638
647
  ),
648
+ "langgraph-fastapi": standardTemplate(
649
+ "langgraph-fastapi",
650
+ TEMPLATE_REPOS["langgraph-fastapi"],
651
+ `\u{1FA81}\u{1F91D}${FRAMEWORK_EMOJI["langgraph-fastapi"]}`
652
+ ),
639
653
  "claude-sdk-typescript": {
640
654
  ...standardTemplate(
641
655
  "claude-sdk-typescript",
@@ -810,6 +824,7 @@ var init_types = __esm({
810
824
  THREADS_FRAMEWORKS = /* @__PURE__ */ new Set([
811
825
  "langgraph-py",
812
826
  "langgraph-js",
827
+ "langgraph-fastapi",
813
828
  "claude-sdk-typescript",
814
829
  "claude-sdk-python",
815
830
  "mastra",
@@ -833,6 +848,7 @@ var init_types = __esm({
833
848
  FRAMEWORK_LANGUAGE = {
834
849
  "langgraph-py": "python",
835
850
  "langgraph-js": "typescript",
851
+ "langgraph-fastapi": "python",
836
852
  "claude-sdk-typescript": "typescript",
837
853
  "claude-sdk-python": "python",
838
854
  flows: "python",
@@ -93356,7 +93372,7 @@ var init_cli_tips = __esm({
93356
93372
  },
93357
93373
  {
93358
93374
  id: "server-debug-for-missing-events",
93359
- 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.",
93375
+ text: "Enable server `debug: true` when events, state, or tool calls disappear, then read live AG-UI details from the Inspector in a browser, or from the runtime's `/cpk-debug-events` route on any frontend.",
93360
93376
  relevancy: 82,
93361
93377
  insight: 90
93362
93378
  },
@@ -93909,11 +93925,15 @@ function BrowserLoginConfirmation({
93909
93925
  } = {}) {
93910
93926
  const { state, confirmBrowserLoginStart, submitManualClerkToken } = useBrowserLogin();
93911
93927
  const [manualTokenInput, setManualTokenInput] = (0, import_react35.useState)("");
93912
- use_input_default((_input, key) => {
93913
- if (state.phase === "confirming" && key.return) {
93914
- confirmBrowserLoginStart();
93915
- }
93916
- });
93928
+ const canPrompt = isBrowserLoginConfirmationInteractive();
93929
+ use_input_default(
93930
+ (_input, key) => {
93931
+ if (state.phase === "confirming" && key.return) {
93932
+ confirmBrowserLoginStart();
93933
+ }
93934
+ },
93935
+ { isActive: canPrompt }
93936
+ );
93917
93937
  if (state.phase === "idle") {
93918
93938
  return null;
93919
93939
  }
@@ -93931,7 +93951,7 @@ function BrowserLoginConfirmation({
93931
93951
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { dimColor: true, children: BROWSER_LOGIN_MANUAL_URL_LABEL }),
93932
93952
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { children: state.loginUrl })
93933
93953
  ] }) : null,
93934
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
93954
+ canPrompt ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
93935
93955
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { dimColor: true, children: BROWSER_LOGIN_MANUAL_PASTE_LABEL }),
93936
93956
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { children: [
93937
93957
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
@@ -93951,7 +93971,7 @@ function BrowserLoginConfirmation({
93951
93971
  }
93952
93972
  )
93953
93973
  ] })
93954
- ] }),
93974
+ ] }) : null,
93955
93975
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CliTip, {})
93956
93976
  ] });
93957
93977
  }
@@ -95687,15 +95707,15 @@ function createFlagPrompts(request) {
95687
95707
  };
95688
95708
  return { prompts, refusal };
95689
95709
  }
95690
- function formatFlagRefusal(refusal) {
95710
+ function formatFlagRefusal(refusal, command2 = "project select") {
95691
95711
  if (refusal.kind === "name-rejected") {
95692
- const remedy = refusal.duplicateSlug === void 0 ? "Pass a different --create name." : `Pass a different --create name, or select it with \`copilotkit project select --project ${refusal.duplicateSlug}\`.`;
95712
+ const remedy = refusal.duplicateSlug === void 0 ? "Pass a different --create name." : `Pass a different --create name, or select it with \`copilotkit ${command2} --project ${refusal.duplicateSlug}\`.`;
95693
95713
  return `${refusal.message} ${remedy}
95694
95714
  `;
95695
95715
  }
95696
95716
  if (refusal.available.length === 0) {
95697
95717
  return `No hosted Intelligence projects exist in this organization, so --project ${refusal.requested} cannot be selected.
95698
- Create one with \`copilotkit project select --create <name>\`.
95718
+ Create one with \`copilotkit ${command2} --create <name>\`.
95699
95719
  `;
95700
95720
  }
95701
95721
  return `No hosted project matches --project ${refusal.requested} in this organization.
@@ -377321,6 +377341,146 @@ var init_env_file = __esm({
377321
377341
  }
377322
377342
  });
377323
377343
 
377344
+ // apps/cli/src/commands/init-project-flag.ts
377345
+ var init_project_flag_exports = {};
377346
+ __export(init_project_flag_exports, {
377347
+ hostedProjectFlagUnsupportedError: () => hostedProjectFlagUnsupportedError,
377348
+ resolveInitProjectFlag: () => resolveInitProjectFlag,
377349
+ selectHostedProjectFromFlag: () => selectHostedProjectFromFlag
377350
+ });
377351
+ function resolveInitProjectFlag(input) {
377352
+ const project = input.project?.trim();
377353
+ const create3 = input.create?.trim();
377354
+ if (input.project !== void 0 && input.create !== void 0) {
377355
+ return {
377356
+ status: "invalid",
377357
+ message: "`--project` and `--create` cannot be combined: one selects an existing hosted Intelligence project, the other makes a new one.\nRun `copilotkit project list --json` to see what already exists."
377358
+ };
377359
+ }
377360
+ if (input.project !== void 0) {
377361
+ if (project === void 0 || project === "") {
377362
+ return {
377363
+ status: "invalid",
377364
+ message: "`--project` needs a project slug or id.\nRun `copilotkit project list --json` to see them."
377365
+ };
377366
+ }
377367
+ return resolveAgainstFramework(
377368
+ { kind: "project", value: project },
377369
+ input.framework
377370
+ );
377371
+ }
377372
+ if (input.create !== void 0) {
377373
+ if (create3 === void 0 || create3 === "") {
377374
+ return {
377375
+ status: "invalid",
377376
+ message: "`--create` needs a project name."
377377
+ };
377378
+ }
377379
+ return resolveAgainstFramework(
377380
+ { kind: "create", name: create3 },
377381
+ input.framework
377382
+ );
377383
+ }
377384
+ return { status: "ok", request: null };
377385
+ }
377386
+ function resolveAgainstFramework(request, framework) {
377387
+ const unsupported = hostedProjectFlagUnsupportedError(
377388
+ request,
377389
+ framework ?? null
377390
+ );
377391
+ return unsupported === void 0 ? { status: "ok", request } : { status: "invalid", message: unsupported };
377392
+ }
377393
+ function hostedProjectFlagUnsupportedError(hostedProject, framework) {
377394
+ if (hostedProject === null || framework === null)
377395
+ return void 0;
377396
+ const resolved = resolveFrameworkAlias(framework);
377397
+ if (!isAgentFramework(resolved) || THREADS_FRAMEWORKS.has(resolved)) {
377398
+ return void 0;
377399
+ }
377400
+ const flag = hostedProject.kind === "project" ? `--project ${hostedProject.value}` : `--create ${hostedProject.name}`;
377401
+ return `The ${resolved} starter ships no Intelligence threads, so there is no hosted project to bind and \`${flag}\` cannot be used with it.
377402
+ Run \`copilotkit framework list\` to see which frameworks bind a project, or scaffold without the flag.`;
377403
+ }
377404
+ async function selectHostedProjectFromFlag(apiClient, request, telemetry) {
377405
+ const { prompts, refusal } = createFlagPrompts(request);
377406
+ const result = await selectOrCreateHostedProject({
377407
+ apiClient,
377408
+ prompts,
377409
+ ...telemetry ? { telemetry } : {}
377410
+ });
377411
+ if ("canceled" in result) {
377412
+ const recorded = refusal.value;
377413
+ throw tagError(
377414
+ new Error(
377415
+ recorded === null ? "Project selection canceled." : formatFlagRefusal(recorded, "init").trimEnd()
377416
+ ),
377417
+ TELEMETRY_ERROR_CODES.PROJECT_NOT_FOUND
377418
+ );
377419
+ }
377420
+ return result;
377421
+ }
377422
+ var init_init_project_flag = __esm({
377423
+ "apps/cli/src/commands/init-project-flag.ts"() {
377424
+ "use strict";
377425
+ init_hosted_project2();
377426
+ init_types();
377427
+ init_event_properties();
377428
+ init_project_select_flags();
377429
+ }
377430
+ });
377431
+
377432
+ // apps/cli/src/commands/init-non-interactive.ts
377433
+ var init_non_interactive_exports = {};
377434
+ __export(init_non_interactive_exports, {
377435
+ NON_INTERACTIVE_LOGIN_MESSAGE: () => NON_INTERACTIVE_LOGIN_MESSAGE,
377436
+ formatNonInteractiveInitRefusal: () => formatNonInteractiveInitRefusal,
377437
+ missingNonInteractiveInitFlags: () => missingNonInteractiveInitFlags,
377438
+ resolveInitInstallFlag: () => resolveInitInstallFlag
377439
+ });
377440
+ function missingNonInteractiveInitFlags(answers) {
377441
+ const missing = [];
377442
+ if (answers.name === void 0 || answers.name.trim() === "") {
377443
+ missing.push("--name");
377444
+ }
377445
+ const framework = answers.framework === void 0 ? void 0 : resolveFrameworkAlias(answers.framework);
377446
+ if (framework === void 0 || framework.trim() === "") {
377447
+ missing.push("--framework");
377448
+ } else if (isAgentFramework(framework) && THREADS_FRAMEWORKS.has(framework) && !answers.hostedProjectNamed) {
377449
+ missing.push("--project");
377450
+ }
377451
+ if (!answers.installAnswered) {
377452
+ missing.push("--yes");
377453
+ }
377454
+ return missing;
377455
+ }
377456
+ function formatNonInteractiveInitRefusal(missing) {
377457
+ return `\`copilotkit init\` prompts for anything you do not name, and this shell has no terminal to prompt in.
377458
+ Name the rest up front: ${missing.join(", ")}
377459
+ ` + (missing.includes("--project") ? "Run `copilotkit project list --json` to see your projects, or pass `--create <name>` to make one.\n" : "") + (missing.includes("--framework") ? "Run `copilotkit framework list` to see the frameworks and the flags each accepts.\n" : "") + (missing.includes("--yes") ? "`--yes` installs dependencies; pass `--no-install` to answer the same question without installing.\n" : "");
377460
+ }
377461
+ function resolveInitInstallFlag(input) {
377462
+ const wantsInstall = input.yes === true || input.install === true;
377463
+ if (wantsInstall && input.noInstall === true) {
377464
+ return {
377465
+ status: "invalid",
377466
+ message: "Pass either `--install` (or `--yes`) or `--no-install`, not both: they answer the same question in opposite ways."
377467
+ };
377468
+ }
377469
+ if (wantsInstall)
377470
+ return { status: "ok", install: true };
377471
+ if (input.noInstall === true)
377472
+ return { status: "ok", install: false };
377473
+ return { status: "ok", install: null };
377474
+ }
377475
+ var NON_INTERACTIVE_LOGIN_MESSAGE;
377476
+ var init_init_non_interactive = __esm({
377477
+ "apps/cli/src/commands/init-non-interactive.ts"() {
377478
+ "use strict";
377479
+ init_types();
377480
+ NON_INTERACTIVE_LOGIN_MESSAGE = "`copilotkit init` needs a CopilotKit session, and signing in opens a browser that finishes back at a terminal this shell does not have.\nRun `copilotkit login` in a terminal, then re-run this command.";
377481
+ }
377482
+ });
377483
+
377324
377484
  // apps/cli/src/ui/init-flow.tsx
377325
377485
  import * as path26 from "node:path";
377326
377486
  function FrameworkIndicator({ isSelected = false }) {
@@ -379110,6 +379270,12 @@ import {
379110
379270
  rmSync as rmSync4
379111
379271
  } from "node:fs";
379112
379272
  import * as path33 from "node:path";
379273
+ function markDisplayedAtTerminal(error98) {
379274
+ if (process.stdout.isTTY === true) {
379275
+ error98.displayed = true;
379276
+ }
379277
+ return error98;
379278
+ }
379113
379279
  function shouldRenderInitBrowserLoginConfirmation(phase) {
379114
379280
  return phase === "confirming" || phase === "waiting" || phase === "finalizing";
379115
379281
  }
@@ -379137,6 +379303,16 @@ function commandExists(command2, environment = process.env, platform4 = process.
379137
379303
  function vendorKeyPromptInteractive() {
379138
379304
  return process.stdin.isTTY === true && process.stdout.isTTY === true;
379139
379305
  }
379306
+ function createHostedProjectApiClient(auth2) {
379307
+ return createApiClient(getOpsApiUrl(), auth2.cliToken, {
379308
+ onProductCredential: (productCredential) => {
379309
+ authStore.save({ ...auth2, productCredential });
379310
+ },
379311
+ productBaseUrl: getAppApiUrl(),
379312
+ productCredential: auth2.productCredential,
379313
+ productOrganizationId: auth2.clerkOrgId
379314
+ });
379315
+ }
379140
379316
  function buildInitNextSteps(templateDefinition, projectName, result, unsatisfiedKeys, installAlreadyRan = false, mockProvider = void 0) {
379141
379317
  const missingPrerequisites = templateDefinition.prerequisites.filter(
379142
379318
  (prerequisite) => result.missingPrerequisites.includes(prerequisite.command)
@@ -379322,6 +379498,12 @@ async function ensureCliToken2(dependencies, onTerminalSessionInvalidation, onBr
379322
379498
  }
379323
379499
  };
379324
379500
  const openBrowser = async () => {
379501
+ if (!(dependencies.isBrowserLoginInteractive ?? isBrowserLoginConfirmationInteractive)()) {
379502
+ throw tagError(
379503
+ new Error(NON_INTERACTIVE_LOGIN_MESSAGE),
379504
+ TELEMETRY_ERROR_CODES.NON_INTERACTIVE
379505
+ );
379506
+ }
379325
379507
  emitGate(false);
379326
379508
  if (!openedBrowser) {
379327
379509
  openedBrowser = true;
@@ -379579,13 +379761,16 @@ async function scaffoldInitProject(options, dependencies = defaultInitScaffoldDe
379579
379761
  });
379580
379762
  } catch (selectionError) {
379581
379763
  const detail = selectionError instanceof Error ? selectionError.message : String(selectionError);
379582
- warnings.push(
379583
- `Project not selected (${detail}); run \`copilotkit project select\` in the project to choose one.`
379584
- );
379585
379764
  writeCliLog("error", {
379586
379765
  event: "init.project_select_failed",
379587
379766
  detail
379588
379767
  });
379768
+ if (options.hostedProject !== null && options.hostedProject !== void 0) {
379769
+ throw selectionError instanceof Error ? selectionError : new Error(detail);
379770
+ }
379771
+ warnings.push(
379772
+ `Project not selected (${detail}); run \`copilotkit project select\` in the project to choose one.`
379773
+ );
379589
379774
  }
379590
379775
  }
379591
379776
  telemetry?.onScaffoldSucceeded({
@@ -379757,6 +379942,7 @@ function ScaffoldProgress({
379757
379942
  const channelOfferDeferredRef = (0, import_react48.useRef)(null);
379758
379943
  const channelCompletionOfferedRef = (0, import_react48.useRef)(false);
379759
379944
  const installAlreadyRanRef = (0, import_react48.useRef)(false);
379945
+ const installAnsweredRef = (0, import_react48.useRef)(false);
379760
379946
  const [credentialRequest, setCredentialRequest] = (0, import_react48.useState)(null);
379761
379947
  const [attachingChannel, setAttachingChannel] = (0, import_react48.useState)(false);
379762
379948
  const channelFlagError = (0, import_react48.useMemo)(
@@ -379766,6 +379952,13 @@ function ScaffoldProgress({
379766
379952
  ),
379767
379953
  [options.channel, options.framework]
379768
379954
  );
379955
+ const hostedProjectFlagError = (0, import_react48.useMemo)(
379956
+ () => hostedProjectFlagUnsupportedError(
379957
+ options.hostedProject ?? null,
379958
+ options.framework ?? null
379959
+ ),
379960
+ [options.hostedProject, options.framework]
379961
+ );
379769
379962
  const flagChannelOffer = (0, import_react48.useMemo)(
379770
379963
  () => channelOfferFromFlag(options.channel ?? null),
379771
379964
  [options.channel]
@@ -379781,6 +379974,19 @@ function ScaffoldProgress({
379781
379974
  new Error("Not authenticated for project selection.")
379782
379975
  );
379783
379976
  }
379977
+ const named = options.hostedProject;
379978
+ if (named !== null && named !== void 0) {
379979
+ return selectHostedProjectFromFlag(
379980
+ createHostedProjectApiClient(auth2),
379981
+ named,
379982
+ {
379983
+ onPickerViewed: (projectCount) => telemetry?.onProjectPickerViewed({ projectCount }),
379984
+ onResolved: (outcome, projectCount) => telemetry?.onProjectResolved({ outcome, projectCount }),
379985
+ onCreateNameRejected: (reason) => telemetry?.onProjectCreateNameRejected({ reason }),
379986
+ onBack: () => telemetry?.onProjectPickerBack()
379987
+ }
379988
+ );
379989
+ }
379784
379990
  return new Promise((resolve9, reject) => {
379785
379991
  selectionDeferredRef.current = { resolve: resolve9, reject };
379786
379992
  });
@@ -379846,11 +380052,11 @@ function ScaffoldProgress({
379846
380052
  }, [phase, scaffoldResult]);
379847
380053
  (0, import_react48.useEffect)(() => {
379848
380054
  let cancelled = false;
379849
- if (channelFlagError !== void 0) {
379850
- const error98 = new Error(channelFlagError);
379851
- error98.displayed = true;
380055
+ const flagError = channelFlagError ?? hostedProjectFlagError;
380056
+ if (flagError !== void 0) {
380057
+ const error98 = markDisplayedAtTerminal(new Error(flagError));
379852
380058
  scaffoldErrorRef.current = error98;
379853
- setErrorMessage(channelFlagError);
380059
+ setErrorMessage(flagError);
379854
380060
  setPhase("error");
379855
380061
  return () => {
379856
380062
  cancelled = true;
@@ -379892,8 +380098,9 @@ function ScaffoldProgress({
379892
380098
  run().catch((err2) => {
379893
380099
  if (cancelled)
379894
380100
  return;
379895
- const error98 = err2 instanceof Error ? err2 : new Error("An unexpected error occurred.");
379896
- error98.displayed = true;
380101
+ const error98 = markDisplayedAtTerminal(
380102
+ err2 instanceof Error ? err2 : new Error("An unexpected error occurred.")
380103
+ );
379897
380104
  scaffoldErrorRef.current = error98;
379898
380105
  setErrorMessage(error98.message);
379899
380106
  setPhase("error");
@@ -379940,6 +380147,45 @@ function ScaffoldProgress({
379940
380147
  }
379941
380148
  setPhase("success");
379942
380149
  }
380150
+ function answerInstall(result, install) {
380151
+ if (!install) {
380152
+ finalizeSuccess(result);
380153
+ return;
380154
+ }
380155
+ setPhase("installing");
380156
+ scaffoldDependencies.installDependencies({
380157
+ cwd: result.projectDir,
380158
+ command: templateDefinition.installCommand,
380159
+ log: writeCliLog
380160
+ }).then((r2) => {
380161
+ if (r2.ok)
380162
+ return true;
380163
+ if (isMountedRef.current) {
380164
+ setInstallError(r2.stderrTail || "install failed");
380165
+ }
380166
+ return false;
380167
+ }).catch((e2) => {
380168
+ if (isMountedRef.current) {
380169
+ setInstallError(e2 instanceof Error ? e2.message : String(e2));
380170
+ }
380171
+ return false;
380172
+ }).then((installSucceeded) => {
380173
+ if (!isMountedRef.current)
380174
+ return;
380175
+ finalizeSuccess(result, installSucceeded);
380176
+ });
380177
+ }
380178
+ (0, import_react48.useEffect)(() => {
380179
+ if (phase !== "install-prompt" || scaffoldResult === null)
380180
+ return;
380181
+ const answer = options.installDependencies;
380182
+ if (answer !== true && answer !== false)
380183
+ return;
380184
+ if (installAnsweredRef.current)
380185
+ return;
380186
+ installAnsweredRef.current = true;
380187
+ answerInstall(scaffoldResult, answer);
380188
+ }, [phase, scaffoldResult, options.installDependencies]);
379943
380189
  function completeChannel(result, channel2) {
379944
380190
  const complete = scaffoldDependencies.completeChannelSetup;
379945
380191
  if (complete === void 0) {
@@ -380033,6 +380279,9 @@ function ScaffoldProgress({
380033
380279
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Downloading template\u2026" }) });
380034
380280
  }
380035
380281
  if (phase === "select-project") {
380282
+ if (options.hostedProject !== null && options.hostedProject !== void 0) {
380283
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Selecting your Intelligence project\u2026" });
380284
+ }
380036
380285
  const auth2 = authStore.get();
380037
380286
  if (auth2 === null) {
380038
380287
  return null;
@@ -380040,14 +380289,7 @@ function ScaffoldProgress({
380040
380289
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
380041
380290
  HostedProjectSelect,
380042
380291
  {
380043
- apiClient: createApiClient(getOpsApiUrl(), auth2.cliToken, {
380044
- onProductCredential: (productCredential) => {
380045
- authStore.save({ ...auth2, productCredential });
380046
- },
380047
- productBaseUrl: getAppApiUrl(),
380048
- productCredential: auth2.productCredential,
380049
- productOrganizationId: auth2.clerkOrgId
380050
- }),
380292
+ apiClient: createHostedProjectApiClient(auth2),
380051
380293
  defaultName: options.name,
380052
380294
  telemetry: {
380053
380295
  onPickerViewed: (projectCount) => telemetry?.onProjectPickerViewed({ projectCount }),
@@ -380163,38 +380405,17 @@ function ScaffoldProgress({
380163
380405
  );
380164
380406
  }
380165
380407
  if (phase === "install-prompt" && scaffoldResult) {
380408
+ if (options.installDependencies === true) {
380409
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Installing dependencies\u2026" });
380410
+ }
380411
+ if (options.installDependencies === false) {
380412
+ return null;
380413
+ }
380166
380414
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
380167
380415
  InstallPrompt,
380168
380416
  {
380169
380417
  installCommand: templateDefinition.installCommand,
380170
- onAnswer: (install) => {
380171
- if (!install) {
380172
- finalizeSuccess(scaffoldResult);
380173
- return;
380174
- }
380175
- setPhase("installing");
380176
- scaffoldDependencies.installDependencies({
380177
- cwd: scaffoldResult.projectDir,
380178
- command: templateDefinition.installCommand,
380179
- log: writeCliLog
380180
- }).then((r2) => {
380181
- if (r2.ok)
380182
- return true;
380183
- if (isMountedRef.current) {
380184
- setInstallError(r2.stderrTail || "install failed");
380185
- }
380186
- return false;
380187
- }).catch((e2) => {
380188
- if (isMountedRef.current) {
380189
- setInstallError(e2 instanceof Error ? e2.message : String(e2));
380190
- }
380191
- return false;
380192
- }).then((installSucceeded) => {
380193
- if (!isMountedRef.current)
380194
- return;
380195
- finalizeSuccess(scaffoldResult, installSucceeded);
380196
- });
380197
- }
380418
+ onAnswer: (install) => answerInstall(scaffoldResult, install)
380198
380419
  }
380199
380420
  );
380200
380421
  }
@@ -380269,6 +380490,8 @@ function InitApp({
380269
380490
  noBanner = false,
380270
380491
  initialMock = false,
380271
380492
  initialChannel = null,
380493
+ initialHostedProject = null,
380494
+ initialInstall = null,
380272
380495
  renderScaffoldProgress = renderDefaultScaffoldProgress,
380273
380496
  onIntelligenceSelected,
380274
380497
  onFrameworkSelected,
@@ -380281,7 +380504,12 @@ function InitApp({
380281
380504
  initialFramework,
380282
380505
  mock
380283
380506
  );
380284
- const prefilled = prefilledBase === null ? null : { ...prefilledBase, channel: initialChannel };
380507
+ const prefilled = prefilledBase === null ? null : {
380508
+ ...prefilledBase,
380509
+ channel: initialChannel,
380510
+ hostedProject: initialHostedProject,
380511
+ installDependencies: initialInstall
380512
+ };
380285
380513
  const [options, setOptions] = (0, import_react48.useState)(prefilled);
380286
380514
  (0, import_react48.useEffect)(() => {
380287
380515
  if (prefilled !== null) {
@@ -380315,7 +380543,13 @@ function InitApp({
380315
380543
  onFrameworkSelected,
380316
380544
  onComplete: (resolved) => {
380317
380545
  if (resolved !== null) {
380318
- setOptions({ ...resolved, mock, channel: initialChannel });
380546
+ setOptions({
380547
+ ...resolved,
380548
+ mock,
380549
+ channel: initialChannel,
380550
+ hostedProject: initialHostedProject,
380551
+ installDependencies: initialInstall
380552
+ });
380319
380553
  }
380320
380554
  }
380321
380555
  }
@@ -380359,6 +380593,8 @@ async function runInit(flags, callbacks) {
380359
380593
  initialFramework,
380360
380594
  initialMock: flags.mock ?? false,
380361
380595
  initialChannel: flags.channel ?? null,
380596
+ initialHostedProject: flags.hostedProject ?? null,
380597
+ initialInstall: flags.installDependencies ?? null,
380362
380598
  noBanner: flags.noBanner === true,
380363
380599
  onIntelligenceSelected: callbacks?.onIntelligenceSelected,
380364
380600
  onFrameworkSelected: callbacks?.onFrameworkSelected,
@@ -380387,6 +380623,8 @@ var init_init = __esm({
380387
380623
  await init_vendor_key_prompt();
380388
380624
  init_feature_flags();
380389
380625
  await init_install_prompt();
380626
+ init_init_project_flag();
380627
+ init_init_non_interactive();
380390
380628
  init_config_service();
380391
380629
  init_event_properties();
380392
380630
  init_cli_logs();
@@ -380449,7 +380687,8 @@ var init_init = __esm({
380449
380687
  appendIntelligenceReadme,
380450
380688
  writeHostedApiKey,
380451
380689
  writeVendorKey,
380452
- isVendorKeyPromptInteractive: vendorKeyPromptInteractive
380690
+ isVendorKeyPromptInteractive: vendorKeyPromptInteractive,
380691
+ isBrowserLoginInteractive: isBrowserLoginConfirmationInteractive
380453
380692
  };
380454
380693
  }
380455
380694
  });
@@ -380965,6 +381204,56 @@ var init_onboarding_state = __esm({
380965
381204
  }
380966
381205
  });
380967
381206
 
381207
+ // apps/cli/src/services/onboarding-classification.ts
381208
+ function requireOnboardingChoice(flag, value, choices) {
381209
+ const selected = choices.find((choice) => choice === value);
381210
+ if (selected === void 0) {
381211
+ throw new Error(`${flag} must be one of: ${choices.join(", ")}.`);
381212
+ }
381213
+ return selected;
381214
+ }
381215
+ var ONBOARDING_STARTING_STATES, ONBOARDING_AGENT_FRAMEWORKS, ONBOARDING_FRONTENDS;
381216
+ var init_onboarding_classification = __esm({
381217
+ "apps/cli/src/services/onboarding-classification.ts"() {
381218
+ "use strict";
381219
+ ONBOARDING_STARTING_STATES = [
381220
+ "empty",
381221
+ "agent-only",
381222
+ "frontend-only",
381223
+ "both",
381224
+ "both-oss"
381225
+ ];
381226
+ ONBOARDING_AGENT_FRAMEWORKS = [
381227
+ "ag2",
381228
+ "agno",
381229
+ "built-in",
381230
+ "claude-sdk-python",
381231
+ "claude-sdk-typescript",
381232
+ "crewai-flows",
381233
+ "deep-agents",
381234
+ "google-adk",
381235
+ "langgraph-fastapi",
381236
+ "langgraph-python",
381237
+ "langgraph-typescript",
381238
+ "llamaindex",
381239
+ "mastra",
381240
+ "ms-agent-dotnet",
381241
+ "ms-agent-harness-dotnet",
381242
+ "ms-agent-python",
381243
+ "pydantic-ai",
381244
+ "strands-python",
381245
+ "strands-typescript"
381246
+ ];
381247
+ ONBOARDING_FRONTENDS = [
381248
+ "react-spa",
381249
+ "nextjs",
381250
+ "angular",
381251
+ "vue",
381252
+ "react-native"
381253
+ ];
381254
+ }
381255
+ });
381256
+
380968
381257
  // apps/cli/src/commands/onboard.ts
380969
381258
  var onboard_exports = {};
380970
381259
  __export(onboard_exports, {
@@ -381024,25 +381313,61 @@ async function runOnboard(argv, dependencies) {
381024
381313
  return;
381025
381314
  }
381026
381315
  if (subcommand === "complete") {
381027
- const visualCheck = parseVisualCheck(argv.slice(1));
381028
- if (visualCheck === void 0) {
381029
- throw new Error(
381030
- "Usage: copilotkit onboard complete --visual-check <performed|skipped-no-browser-tool|failed>"
381031
- );
381032
- }
381316
+ const check4 = parseSurfaceCheck(argv.slice(1));
381317
+ if (check4 === void 0)
381318
+ throw new Error(SURFACE_CHECK_USAGE);
381033
381319
  recordBestEffort(deps, {
381034
381320
  event: "cli.onboarding.completed",
381035
381321
  properties: {
381036
381322
  command: "onboard",
381037
381323
  onboarding_run_id: binding.runId,
381038
381324
  cli_version: deps.cliVersion,
381039
- visual_check: visualCheck
381325
+ ...check4.kind === "visual" ? { visual_check: check4.outcome } : { device_check: check4.outcome }
381040
381326
  }
381041
381327
  });
381042
- deps.stdout.write("CopilotKit onboarding marked complete.\n");
381043
- if (visualCheck !== "performed") {
381044
- deps.stdout.write(visualCheckWarning(visualCheck));
381045
- }
381328
+ deps.stdout.write(
381329
+ check4.outcome === "performed" ? "CopilotKit onboarding marked complete.\n" : blockedWithoutSurfaceProof(check4)
381330
+ );
381331
+ return;
381332
+ }
381333
+ if (subcommand === "classify") {
381334
+ const parsed = parseArgs2({
381335
+ args: [...argv.slice(1)],
381336
+ allowPositionals: false,
381337
+ options: {
381338
+ "starting-state": { type: "string" },
381339
+ "agent-framework": { type: "string" },
381340
+ frontend: { type: "string" }
381341
+ },
381342
+ strict: true
381343
+ });
381344
+ const startingState = requireOnboardingChoice(
381345
+ "--starting-state",
381346
+ parsed.values["starting-state"],
381347
+ ONBOARDING_STARTING_STATES
381348
+ );
381349
+ const agentFramework = requireOnboardingChoice(
381350
+ "--agent-framework",
381351
+ parsed.values["agent-framework"],
381352
+ ONBOARDING_AGENT_FRAMEWORKS
381353
+ );
381354
+ const frontend = requireOnboardingChoice(
381355
+ "--frontend",
381356
+ parsed.values.frontend,
381357
+ ONBOARDING_FRONTENDS
381358
+ );
381359
+ recordBestEffort(deps, {
381360
+ event: "cli.onboarding.classified",
381361
+ properties: {
381362
+ command: "onboard",
381363
+ onboarding_run_id: binding.runId,
381364
+ cli_version: deps.cliVersion,
381365
+ starting_state: startingState,
381366
+ agent_framework: agentFramework,
381367
+ frontend
381368
+ }
381369
+ });
381370
+ deps.stdout.write("Onboarding path included in telemetry when enabled.\n");
381046
381371
  return;
381047
381372
  }
381048
381373
  if (subcommand === "feedback") {
@@ -381057,28 +381382,66 @@ async function runOnboard(argv, dependencies) {
381057
381382
  return;
381058
381383
  }
381059
381384
  throw new Error(
381060
- "Usage: copilotkit onboard <start|read|complete|feedback|friction>"
381385
+ "Usage: copilotkit onboard <start|read|classify|complete|feedback|friction>"
381061
381386
  );
381062
381387
  }
381063
- function parseVisualCheck(rest) {
381064
- if (rest.length !== 2 || rest[0] !== "--visual-check")
381388
+ function parseSurfaceCheck(rest) {
381389
+ if (rest.length !== 2)
381065
381390
  return void 0;
381066
- const value = rest[1];
381067
- return VISUAL_CHECK_OUTCOMES.find((outcome) => outcome === value);
381391
+ const [flag, value] = rest;
381392
+ if (flag === "--visual-check") {
381393
+ const outcome = VISUAL_CHECK_OUTCOMES.find((known) => known === value);
381394
+ return outcome === void 0 ? void 0 : { kind: "visual", outcome };
381395
+ }
381396
+ if (flag === "--device-check") {
381397
+ const outcome = DEVICE_CHECK_OUTCOMES.find((known) => known === value);
381398
+ return outcome === void 0 ? void 0 : { kind: "device", outcome };
381399
+ }
381400
+ return void 0;
381068
381401
  }
381069
- function visualCheckWarning(outcome) {
381070
- const cause = outcome === "failed" ? "it did not succeed" : "no browser automation was available to the coding agent, so nothing drove the real frontend";
381402
+ function blockedWithoutSurfaceProof(check4) {
381403
+ const failed2 = check4.outcome === "failed";
381404
+ const visual = {
381405
+ headline: [
381406
+ " The live UI check was NOT performed:",
381407
+ failed2 ? " it did not succeed." : " no browser automation was available, so nothing drove the real frontend."
381408
+ ],
381409
+ uncovered: [
381410
+ "realtime delivery to a browser over the gateway",
381411
+ "browser-origin CORS and CSP, which a CLI request never exercises",
381412
+ "the frontend provider being wired to this runtime",
381413
+ "generative UI actually rendering a component"
381414
+ ],
381415
+ reach: "which reaches no browser",
381416
+ close: "configure a browser MCP server for your coding agent and drive\n the app once by hand, then run this command again with\n `--visual-check performed`"
381417
+ };
381418
+ const device = {
381419
+ headline: [
381420
+ " The on-device check was NOT performed:",
381421
+ failed2 ? " it did not succeed." : " no device or emulator was available, so nothing ran the real app."
381422
+ ],
381423
+ uncovered: [
381424
+ "the app rendering at all on a real screen",
381425
+ "a tool-rendered component painted in the view tree",
381426
+ "an unresolved redbox, which no terminal output shows",
381427
+ "realtime delivery to the app over the gateway"
381428
+ ],
381429
+ reach: "which reaches no screen",
381430
+ close: "run the app on a device or emulator and capture the terminal state --\n `adb exec-out screencap -p` on Android -- then run this command again\n with `--device-check performed`"
381431
+ };
381432
+ const surface = check4.kind === "visual" ? visual : device;
381071
381433
  return [
381072
381434
  "",
381073
- `! The live UI check was NOT performed: ${cause}.`,
381074
- " The agent round trip itself was proven with `copilotkit verify --round-trip`.",
381075
- " Not covered by that, and still unverified here:",
381076
- " - realtime delivery to a browser over the gateway",
381077
- " - browser-origin CORS and CSP, which a CLI request never exercises",
381078
- " - the frontend provider being wired to this runtime",
381079
- " - generative UI actually rendering a component",
381080
- " To close it, configure a browser MCP server for your coding agent and",
381081
- " drive the app once by hand.",
381435
+ "! Onboarding is NOT complete.",
381436
+ ...surface.headline,
381437
+ ` The agent round trip is what \`copilotkit verify --round-trip\` proves, ${surface.reach}.`,
381438
+ " Not covered by it, and still unverified here:",
381439
+ ...surface.uncovered.map((line) => ` - ${line}`),
381440
+ "",
381441
+ " Report this run as blocked, and name the unverified lines above as the",
381442
+ " evidence it is missing. Do not report it as complete: every other check in",
381443
+ " this graph can pass while all four of those fail.",
381444
+ ` To close it, ${surface.close}.`,
381082
381445
  ""
381083
381446
  ].join("\n");
381084
381447
  }
@@ -381232,7 +381595,7 @@ function recordBestEffort(dependencies, event) {
381232
381595
  } catch {
381233
381596
  }
381234
381597
  }
381235
- var VISUAL_CHECK_OUTCOMES;
381598
+ var VISUAL_CHECK_OUTCOMES, DEVICE_CHECK_OUTCOMES, SURFACE_CHECK_USAGE;
381236
381599
  var init_onboard = __esm({
381237
381600
  async "apps/cli/src/commands/onboard.ts"() {
381238
381601
  "use strict";
@@ -381242,12 +381605,19 @@ var init_onboard = __esm({
381242
381605
  init_onboarding_friction();
381243
381606
  init_onboarding_feedback();
381244
381607
  init_onboarding_state();
381608
+ init_onboarding_classification();
381245
381609
  await init_telemetry();
381246
381610
  VISUAL_CHECK_OUTCOMES = [
381247
381611
  "performed",
381248
381612
  "skipped-no-browser-tool",
381249
381613
  "failed"
381250
381614
  ];
381615
+ DEVICE_CHECK_OUTCOMES = [
381616
+ "performed",
381617
+ "skipped-no-device",
381618
+ "failed"
381619
+ ];
381620
+ SURFACE_CHECK_USAGE = "Usage: copilotkit onboard complete --visual-check <performed|skipped-no-browser-tool|failed>\n or: copilotkit onboard complete --device-check <performed|skipped-no-device|failed>\nPass exactly one. A web journey is proven in a browser and a mobile one on a device;\nwhich flag you pass is how this run states which surface it proved.";
381251
381621
  }
381252
381622
  });
381253
381623
 
@@ -384427,6 +384797,7 @@ Options:
384427
384797
  `,
384428
384798
  onboard: `Usage: copilotkit onboard start [--run <id>] [--coding-agent <slug>]
384429
384799
  copilotkit onboard read <prompt-name>
384800
+ copilotkit onboard classify --starting-state <state> --agent-framework <framework> --frontend <frontend>
384430
384801
  copilotkit onboard complete
384431
384802
  copilotkit onboard feedback
384432
384803
  copilotkit onboard friction --category <slug> --cost-seconds <seconds>
@@ -384436,6 +384807,7 @@ Guide a coding agent through the Markdown graph bundled with this exact CLI.
384436
384807
  Subcommands:
384437
384808
  start Start or replace the repository-bound onboarding run
384438
384809
  read Print one rendered prompt as the only stdout payload
384810
+ classify Send the bounded matrix path for this run
384439
384811
  complete Mark a proven onboarding run complete
384440
384812
  feedback Read one non-empty message from standard input
384441
384813
  friction Report one papercut that slowed a run down
@@ -384552,9 +384924,28 @@ ${isCliFlagEnabled("cli.aimock-mock-mode") ? ` --mock Run keyle
384552
384924
  provider will ask you for. A named provider is set up as
384553
384925
  far as it can go without credentials, then reports what
384554
384926
  is left -- it never prompts for a secret.
384927
+ --project <ref> Select an existing hosted Intelligence project by slug
384928
+ or id, instead of showing the picker
384929
+ --create <name> Create a hosted Intelligence project with this name and
384930
+ select it
384931
+ -y, --yes Install dependencies without asking
384932
+ --install Install dependencies without asking (same as --yes)
384933
+ --no-install Skip the install without asking
384555
384934
  --no-banner Suppress the CopilotKit welcome banner (used when a
384556
384935
  parent tool, e.g. create-ag-ui-app, shows its own)
384557
384936
  -h, --help Show help for init
384937
+
384938
+ Pass --project or --create, never both. They resolve the same way
384939
+ \`copilotkit project select\` does: a typo fails with the real slugs rather than
384940
+ creating something you did not ask for.
384941
+
384942
+ init prompts for anything you do not name, so a shell with no terminal needs the
384943
+ answers up front: -n, -f, -y, and --project or --create. It then refuses only the
384944
+ ones still missing, and names them.
384945
+
384946
+ Signing in is the one answer no flag supplies: it opens a browser and finishes
384947
+ back at the terminal. Run \`copilotkit login\` first, or a run with no terminal is
384948
+ refused rather than opening a browser it cannot finish with.
384558
384949
  `,
384559
384950
  license: `Usage: copilotkit license [create]
384560
384951
  copilotkit license list [options]
@@ -385735,6 +386126,11 @@ var INIT_PARSE_OPTIONS = {
385735
386126
  framework: { type: "string", short: "f" },
385736
386127
  mock: { type: "boolean" },
385737
386128
  channel: { type: "string" },
386129
+ project: { type: "string" },
386130
+ create: { type: "string" },
386131
+ yes: { type: "boolean", short: "y" },
386132
+ install: { type: "boolean" },
386133
+ "no-install": { type: "boolean" },
385738
386134
  "no-banner": { type: "boolean" }
385739
386135
  };
385740
386136
  async function runInitCommand(invokedAs, argv) {
@@ -385775,17 +386171,22 @@ async function runInitCommand(invokedAs, argv) {
385775
386171
  await exitWithFlush(1);
385776
386172
  return;
385777
386173
  }
385778
- if (!process.stdin.isTTY) {
386174
+ const { resolveInitProjectFlag: resolveInitProjectFlag2 } = await Promise.resolve().then(() => (init_init_project_flag(), init_project_flag_exports));
386175
+ const projectResolution = resolveInitProjectFlag2({
386176
+ project: parsed.values["project"],
386177
+ create: parsed.values["create"],
386178
+ framework: frameworkFlag
386179
+ });
386180
+ if (projectResolution.status === "invalid") {
385779
386181
  recordTelemetryEvent({
385780
386182
  properties: {
385781
386183
  ...telemetryBase,
385782
386184
  outcome: "failed",
385783
- error_code: "non_interactive"
386185
+ error_code: "validation"
385784
386186
  }
385785
386187
  });
385786
- process.stderr.write(
385787
- "Error: `copilotkit init` must be run in an interactive terminal.\nIt prompts for project options, and Intelligence templates open a browser to sign in.\nRe-run it directly in a terminal (not piped, redirected, or in a non-interactive CI step).\n"
385788
- );
386188
+ process.stderr.write(`Error: ${projectResolution.message}
386189
+ `);
385789
386190
  await exitWithFlush(1);
385790
386191
  return;
385791
386192
  }
@@ -385817,12 +386218,74 @@ async function runInitCommand(invokedAs, argv) {
385817
386218
  await exitWithFlush(1);
385818
386219
  return;
385819
386220
  }
386221
+ const {
386222
+ formatNonInteractiveInitRefusal: formatNonInteractiveInitRefusal2,
386223
+ missingNonInteractiveInitFlags: missingNonInteractiveInitFlags2,
386224
+ resolveInitInstallFlag: resolveInitInstallFlag2,
386225
+ NON_INTERACTIVE_LOGIN_MESSAGE: NON_INTERACTIVE_LOGIN_MESSAGE2
386226
+ } = await Promise.resolve().then(() => (init_init_non_interactive(), init_non_interactive_exports));
386227
+ const installResolution = resolveInitInstallFlag2({
386228
+ yes: parsed.values["yes"],
386229
+ install: parsed.values["install"],
386230
+ noInstall: parsed.values["no-install"]
386231
+ });
386232
+ if (installResolution.status === "invalid") {
386233
+ recordTelemetryEvent({
386234
+ properties: {
386235
+ ...telemetryBase,
386236
+ outcome: "failed",
386237
+ error_code: "validation"
386238
+ }
386239
+ });
386240
+ process.stderr.write(`Error: ${installResolution.message}
386241
+ `);
386242
+ await exitWithFlush(1);
386243
+ return;
386244
+ }
386245
+ if (!process.stdin.isTTY) {
386246
+ const missing = missingNonInteractiveInitFlags2({
386247
+ name: parsed.values["name"],
386248
+ framework: frameworkFlag,
386249
+ hostedProjectNamed: projectResolution.request !== null,
386250
+ installAnswered: installResolution.install !== null
386251
+ });
386252
+ if (missing.length > 0) {
386253
+ recordTelemetryEvent({
386254
+ properties: {
386255
+ ...telemetryBase,
386256
+ outcome: "failed",
386257
+ error_code: "non_interactive"
386258
+ }
386259
+ });
386260
+ process.stderr.write(
386261
+ `Error: ${formatNonInteractiveInitRefusal2(missing)}`
386262
+ );
386263
+ await exitWithFlush(1);
386264
+ return;
386265
+ }
386266
+ const { authStore: authStore2 } = await Promise.resolve().then(() => (init_config_service(), config_service_exports));
386267
+ if (authStore2.get() === null) {
386268
+ recordTelemetryEvent({
386269
+ properties: {
386270
+ ...telemetryBase,
386271
+ outcome: "failed",
386272
+ error_code: "non_interactive"
386273
+ }
386274
+ });
386275
+ process.stderr.write(`Error: ${NON_INTERACTIVE_LOGIN_MESSAGE2}
386276
+ `);
386277
+ await exitWithFlush(1);
386278
+ return;
386279
+ }
386280
+ }
385820
386281
  const flags = {
385821
386282
  name: parsed.values["name"],
385822
386283
  intelligence,
385823
386284
  framework,
385824
386285
  mock,
385825
386286
  channel: channelResolution.channel,
386287
+ hostedProject: projectResolution.request,
386288
+ installDependencies: installResolution.install,
385826
386289
  noBanner: parsed.values["no-banner"]
385827
386290
  };
385828
386291
  await withTelemetry(telemetryBase, async (ctx) => {