copilotkit 4.8.4 → 4.9.1

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 (45) hide show
  1. package/README.md +46 -5
  2. package/cli-build-info.json +7 -7
  3. package/index.js +647 -124
  4. package/onboarding/index.json +140 -1
  5. package/onboarding/prompts/authenticate/start.md +47 -10
  6. package/onboarding/prompts/credentials/finalize-plan.md +64 -14
  7. package/onboarding/prompts/credentials/plan.md +54 -16
  8. package/onboarding/prompts/fallback/best-effort.md +36 -0
  9. package/onboarding/prompts/framework/ag2.md +48 -0
  10. package/onboarding/prompts/framework/agno.md +48 -0
  11. package/onboarding/prompts/framework/built-in.md +43 -0
  12. package/onboarding/prompts/framework/claude-sdk-python.md +49 -0
  13. package/onboarding/prompts/framework/claude-sdk-typescript.md +53 -0
  14. package/onboarding/prompts/framework/crewai-flows.md +56 -0
  15. package/onboarding/prompts/framework/deep-agents.md +45 -0
  16. package/onboarding/prompts/framework/google-adk.md +8 -3
  17. package/onboarding/prompts/framework/langgraph-fastapi.md +42 -0
  18. package/onboarding/prompts/framework/langgraph-python.md +8 -3
  19. package/onboarding/prompts/framework/langgraph-typescript.md +8 -3
  20. package/onboarding/prompts/framework/llamaindex.md +51 -0
  21. package/onboarding/prompts/framework/mastra.md +8 -3
  22. package/onboarding/prompts/framework/ms-agent-dotnet.md +8 -3
  23. package/onboarding/prompts/framework/ms-agent-harness-dotnet.md +62 -0
  24. package/onboarding/prompts/framework/ms-agent-python.md +8 -3
  25. package/onboarding/prompts/framework/pydantic-ai.md +48 -0
  26. package/onboarding/prompts/framework/strands-python.md +42 -0
  27. package/onboarding/prompts/framework/strands-typescript.md +42 -0
  28. package/onboarding/prompts/frontend/angular.md +9 -3
  29. package/onboarding/prompts/frontend/nextjs.md +8 -3
  30. package/onboarding/prompts/frontend/plan.md +22 -10
  31. package/onboarding/prompts/frontend/react-native.md +9 -3
  32. package/onboarding/prompts/frontend/react-spa.md +20 -5
  33. package/onboarding/prompts/frontend/vue.md +9 -3
  34. package/onboarding/prompts/implementation/build-and-validate.md +12 -2
  35. package/onboarding/prompts/proof/complete.md +51 -16
  36. package/onboarding/prompts/proof/oss-baseline.md +59 -0
  37. package/onboarding/prompts/proof/round-trip.md +51 -24
  38. package/onboarding/prompts/subagent/create-plan.md +14 -2
  39. package/onboarding/prompts/subagent/implement-and-validate.md +10 -0
  40. package/onboarding/prompts/subagent/inspect-repository.md +6 -1
  41. package/onboarding/prompts/subagent/prove-oss-baseline.md +35 -0
  42. package/onboarding/prompts/subagent/prove-round-trip.md +46 -21
  43. package/onboarding/prompts/unsupported/no-validated-path.md +23 -9
  44. package/package.json +1 -1
  45. package/release/release-tool.js +1 -1
package/index.js CHANGED
@@ -96,14 +96,14 @@ function getTelemetryEndpointUrl() {
96
96
  }
97
97
  function getBuildInfo() {
98
98
  return {
99
- version: true ? "4.8.4" : "dev",
100
- buildNumber: true ? "32806721876" : "dev",
101
- commitSha: true ? "6483664ecea767ad39fe52106d85b94731740150" : "dev",
99
+ version: true ? "4.9.1" : "dev",
100
+ buildNumber: true ? "32915219082" : "dev",
101
+ commitSha: true ? "0528d9de0d7915386d789deb676d44c4668842b1" : "dev",
102
102
  copilotKitCommit: getTemplateRef()
103
103
  };
104
104
  }
105
105
  function getTemplateRef() {
106
- return true ? "47c5510b4909f6728288ecf28d7b14cd14922d33" : "main";
106
+ return true ? "2ad03320fe1f0834b138113fffe791781e5b226e" : "main";
107
107
  }
108
108
  function getC15tBackendUrl() {
109
109
  return true ? "https://calm-hazelnut-joy-copilotkit.inth.app" : "";
@@ -93909,11 +93909,15 @@ function BrowserLoginConfirmation({
93909
93909
  } = {}) {
93910
93910
  const { state, confirmBrowserLoginStart, submitManualClerkToken } = useBrowserLogin();
93911
93911
  const [manualTokenInput, setManualTokenInput] = (0, import_react35.useState)("");
93912
- use_input_default((_input, key) => {
93913
- if (state.phase === "confirming" && key.return) {
93914
- confirmBrowserLoginStart();
93915
- }
93916
- });
93912
+ const canPrompt = isBrowserLoginConfirmationInteractive();
93913
+ use_input_default(
93914
+ (_input, key) => {
93915
+ if (state.phase === "confirming" && key.return) {
93916
+ confirmBrowserLoginStart();
93917
+ }
93918
+ },
93919
+ { isActive: canPrompt }
93920
+ );
93917
93921
  if (state.phase === "idle") {
93918
93922
  return null;
93919
93923
  }
@@ -93931,7 +93935,7 @@ function BrowserLoginConfirmation({
93931
93935
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { dimColor: true, children: BROWSER_LOGIN_MANUAL_URL_LABEL }),
93932
93936
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { children: state.loginUrl })
93933
93937
  ] }) : null,
93934
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
93938
+ canPrompt ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
93935
93939
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { dimColor: true, children: BROWSER_LOGIN_MANUAL_PASTE_LABEL }),
93936
93940
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { children: [
93937
93941
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
@@ -93951,7 +93955,7 @@ function BrowserLoginConfirmation({
93951
93955
  }
93952
93956
  )
93953
93957
  ] })
93954
- ] }),
93958
+ ] }) : null,
93955
93959
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CliTip, {})
93956
93960
  ] });
93957
93961
  }
@@ -94890,8 +94894,12 @@ var project_list_exports = {};
94890
94894
  __export(project_list_exports, {
94891
94895
  runProjectList: () => runProjectList
94892
94896
  });
94893
- function renderTable(projects, selectedId, organizationId) {
94897
+ function renderTable(projects, selectedId, organizationId, search) {
94894
94898
  if (projects.length === 0) {
94899
+ if (search !== void 0) {
94900
+ return `No hosted Intelligence projects match "${search}" in ${organizationId}.
94901
+ `;
94902
+ }
94895
94903
  return `No hosted Intelligence projects exist in ${organizationId} yet.
94896
94904
  Run \`copilotkit project select --create <name>\` to create one.
94897
94905
  `;
@@ -94933,8 +94941,16 @@ async function driveProjectList(options) {
94933
94941
  return { kind: "api-error", error: error98 };
94934
94942
  }
94935
94943
  const selectedId = findProjectConfig(process.cwd())?.projectId;
94944
+ const trimmedSearch = options.search?.trim();
94945
+ const search = trimmedSearch === "" ? void 0 : trimmedSearch;
94946
+ const matchedProjects = search === void 0 || search.length === 0 ? projects : projects.filter((project) => {
94947
+ const query = search.toLocaleLowerCase();
94948
+ return [project.id, project.slug, project.name].some(
94949
+ (value) => value.toLocaleLowerCase().includes(query)
94950
+ );
94951
+ });
94936
94952
  if (options.json) {
94937
- const rows = projects.map((project) => ({
94953
+ const rows = matchedProjects.map((project) => ({
94938
94954
  id: project.id,
94939
94955
  slug: project.slug,
94940
94956
  name: project.name,
@@ -94947,6 +94963,7 @@ async function driveProjectList(options) {
94947
94963
  {
94948
94964
  organizationId: auth2.clerkOrgId,
94949
94965
  selectedProjectId: selectedId ?? null,
94966
+ search: search ?? null,
94950
94967
  projects: rows
94951
94968
  },
94952
94969
  null,
@@ -94956,7 +94973,9 @@ async function driveProjectList(options) {
94956
94973
  );
94957
94974
  return { kind: "success" };
94958
94975
  }
94959
- process.stdout.write(renderTable(projects, selectedId, auth2.clerkOrgId));
94976
+ process.stdout.write(
94977
+ renderTable(matchedProjects, selectedId, auth2.clerkOrgId, search)
94978
+ );
94960
94979
  return { kind: "success" };
94961
94980
  }
94962
94981
  async function runProjectList(options) {
@@ -95672,15 +95691,15 @@ function createFlagPrompts(request) {
95672
95691
  };
95673
95692
  return { prompts, refusal };
95674
95693
  }
95675
- function formatFlagRefusal(refusal) {
95694
+ function formatFlagRefusal(refusal, command2 = "project select") {
95676
95695
  if (refusal.kind === "name-rejected") {
95677
- 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}\`.`;
95696
+ 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}\`.`;
95678
95697
  return `${refusal.message} ${remedy}
95679
95698
  `;
95680
95699
  }
95681
95700
  if (refusal.available.length === 0) {
95682
95701
  return `No hosted Intelligence projects exist in this organization, so --project ${refusal.requested} cannot be selected.
95683
- Create one with \`copilotkit project select --create <name>\`.
95702
+ Create one with \`copilotkit ${command2} --create <name>\`.
95684
95703
  `;
95685
95704
  }
95686
95705
  return `No hosted project matches --project ${refusal.requested} in this organization.
@@ -95691,13 +95710,16 @@ Run \`copilotkit project list --json\` to see ids alongside slugs.
95691
95710
  function buildProjectSelectJson(selection, apiKeyProvisioned, configPath) {
95692
95711
  return {
95693
95712
  type: "completed",
95713
+ selected_project_slug: selection.projectSlug,
95694
95714
  project: {
95695
95715
  id: selection.projectId,
95696
95716
  slug: selection.projectSlug,
95697
95717
  organizationId: selection.organizationId
95698
95718
  },
95699
95719
  config_path: configPath,
95700
- api_key_provisioned: apiKeyProvisioned
95720
+ project_file_written: true,
95721
+ api_key_provisioned: apiKeyProvisioned,
95722
+ environment_file_written: apiKeyProvisioned
95701
95723
  };
95702
95724
  }
95703
95725
  var init_project_select_flags = __esm({
@@ -373441,7 +373463,7 @@ function intelligenceConsumedCheck(credential, runtime) {
373441
373463
  }
373442
373464
  if (runtime.info.licenseStatus === void 0) {
373443
373465
  return {
373444
- detail: `The key authenticates, but the runtime reports no license, which means it was built without an Intelligence client and is running in SSE mode. The key is never read: threads are not durable and nothing reaches the platform. Pass \`intelligence: new CopilotKitIntelligence({ apiKey })\` where the runtime is constructed \u2014 https://docs.copilotkit.ai/premium/connect-your-runtime`,
373466
+ detail: `The key authenticates, but the runtime reports no license, which means it was built without an Intelligence client and is running in OSS/SSE mode. The key is never read and nothing reaches the platform. The default in-memory OSS runner is ephemeral. SQLite, custom, or framework persistence can be durable. Pass \`intelligence: new CopilotKitIntelligence({ apiKey })\` where the runtime is constructed \u2014 https://docs.copilotkit.ai/premium/connect-your-runtime`,
373445
373467
  id: "intelligence_consumed",
373446
373468
  status: "fail",
373447
373469
  title
@@ -373454,6 +373476,31 @@ function intelligenceConsumedCheck(credential, runtime) {
373454
373476
  title
373455
373477
  };
373456
373478
  }
373479
+ function ossRuntimeModeCheck(runtime) {
373480
+ const title = "The runtime uses the expected OSS mode";
373481
+ if (runtime.kind !== "ok") {
373482
+ return {
373483
+ detail: "Not attempted: the runtime did not return valid /info data. Fix the runtime check above first.",
373484
+ id: "runtime_mode",
373485
+ status: "undetermined",
373486
+ title
373487
+ };
373488
+ }
373489
+ if (runtime.info.licenseStatus !== void 0) {
373490
+ return {
373491
+ detail: `The runtime reports license ${runtime.info.licenseStatus}, so it uses Intelligence rather than OSS mode.`,
373492
+ id: "runtime_mode",
373493
+ status: "fail",
373494
+ title
373495
+ };
373496
+ }
373497
+ return {
373498
+ detail: "The runtime returned valid /info data without licenseStatus, as expected for OSS mode.",
373499
+ id: "runtime_mode",
373500
+ status: "pass",
373501
+ title
373502
+ };
373503
+ }
373457
373504
  function intelligenceThreadRoutesCheck(runtime) {
373458
373505
  const title = "The runtime serves the Intelligence thread routes";
373459
373506
  if (runtime.kind !== "ok") {
@@ -373515,8 +373562,12 @@ function collectFacts(input) {
373515
373562
  runtimeVersion: info?.version
373516
373563
  };
373517
373564
  }
373518
- function runVerifyChecks(input) {
373519
- const checks = [
373565
+ function runVerifyChecks(input, expectedRuntime = "intelligence") {
373566
+ const checks = expectedRuntime === "oss" ? [
373567
+ runtimeReachableCheck(input.runtime),
373568
+ runtimeAgentsCheck(input.runtime),
373569
+ ossRuntimeModeCheck(input.runtime)
373570
+ ] : [
373520
373571
  projectSelectedCheck(input.projectConfig),
373521
373572
  apiKeyPresentCheck(
373522
373573
  input.apiKeyVariableName,
@@ -373861,18 +373912,24 @@ async function runVerify(options, overrides = {}) {
373861
373912
  probeRuntimeInfo(runtimeUrl, deps.fetchImpl)
373862
373913
  ]);
373863
373914
  const apiKeySource = apiKey === void 0 || deps.env[apiKey.variableName] !== void 0 ? void 0 : projectEnv.origins[apiKey.variableName];
373864
- const result = runVerifyChecks({
373865
- apiKeySource,
373866
- apiKeyVariableName: apiKey?.variableName,
373867
- credential,
373868
- envSearch: {
373869
- ceiling: projectEnv.ceiling,
373870
- searchedFrom: projectEnv.searchedFrom
373915
+ const expectedRuntime = options.expectRuntime ?? "intelligence";
373916
+ const result = runVerifyChecks(
373917
+ {
373918
+ apiKeySource,
373919
+ apiKeyVariableName: apiKey?.variableName,
373920
+ credential,
373921
+ envSearch: {
373922
+ ceiling: projectEnv.ceiling,
373923
+ searchedFrom: projectEnv.searchedFrom
373924
+ },
373925
+ projectConfig,
373926
+ runtime
373871
373927
  },
373872
- projectConfig,
373873
- runtime
373874
- });
373875
- const roundTrip = options.roundTrip === true ? await runLiveRoundTrip(options, deps, runtimeUrl, runtime) : void 0;
373928
+ expectedRuntime
373929
+ );
373930
+ const roundTrip = expectedRuntime === "oss" && (options.roundTrip !== true || options.agent === void 0) ? notAttempted(
373931
+ "Not attempted: --expect-runtime oss requires --round-trip --agent <id> so the named agent must answer before this command can pass."
373932
+ ) : options.roundTrip === true ? await runLiveRoundTrip(options, deps, runtimeUrl, runtime) : void 0;
373876
373933
  const context3 = { runtimeUrl, runtimeUrlSource };
373877
373934
  deps.stdout(
373878
373935
  options.json ? renderVerifyJson(result, context3, roundTrip) : renderVerifyReport(result, context3, roundTrip)
@@ -377268,6 +377325,146 @@ var init_env_file = __esm({
377268
377325
  }
377269
377326
  });
377270
377327
 
377328
+ // apps/cli/src/commands/init-project-flag.ts
377329
+ var init_project_flag_exports = {};
377330
+ __export(init_project_flag_exports, {
377331
+ hostedProjectFlagUnsupportedError: () => hostedProjectFlagUnsupportedError,
377332
+ resolveInitProjectFlag: () => resolveInitProjectFlag,
377333
+ selectHostedProjectFromFlag: () => selectHostedProjectFromFlag
377334
+ });
377335
+ function resolveInitProjectFlag(input) {
377336
+ const project = input.project?.trim();
377337
+ const create3 = input.create?.trim();
377338
+ if (input.project !== void 0 && input.create !== void 0) {
377339
+ return {
377340
+ status: "invalid",
377341
+ 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."
377342
+ };
377343
+ }
377344
+ if (input.project !== void 0) {
377345
+ if (project === void 0 || project === "") {
377346
+ return {
377347
+ status: "invalid",
377348
+ message: "`--project` needs a project slug or id.\nRun `copilotkit project list --json` to see them."
377349
+ };
377350
+ }
377351
+ return resolveAgainstFramework(
377352
+ { kind: "project", value: project },
377353
+ input.framework
377354
+ );
377355
+ }
377356
+ if (input.create !== void 0) {
377357
+ if (create3 === void 0 || create3 === "") {
377358
+ return {
377359
+ status: "invalid",
377360
+ message: "`--create` needs a project name."
377361
+ };
377362
+ }
377363
+ return resolveAgainstFramework(
377364
+ { kind: "create", name: create3 },
377365
+ input.framework
377366
+ );
377367
+ }
377368
+ return { status: "ok", request: null };
377369
+ }
377370
+ function resolveAgainstFramework(request, framework) {
377371
+ const unsupported = hostedProjectFlagUnsupportedError(
377372
+ request,
377373
+ framework ?? null
377374
+ );
377375
+ return unsupported === void 0 ? { status: "ok", request } : { status: "invalid", message: unsupported };
377376
+ }
377377
+ function hostedProjectFlagUnsupportedError(hostedProject, framework) {
377378
+ if (hostedProject === null || framework === null)
377379
+ return void 0;
377380
+ const resolved = resolveFrameworkAlias(framework);
377381
+ if (!isAgentFramework(resolved) || THREADS_FRAMEWORKS.has(resolved)) {
377382
+ return void 0;
377383
+ }
377384
+ const flag = hostedProject.kind === "project" ? `--project ${hostedProject.value}` : `--create ${hostedProject.name}`;
377385
+ return `The ${resolved} starter ships no Intelligence threads, so there is no hosted project to bind and \`${flag}\` cannot be used with it.
377386
+ Run \`copilotkit framework list\` to see which frameworks bind a project, or scaffold without the flag.`;
377387
+ }
377388
+ async function selectHostedProjectFromFlag(apiClient, request, telemetry) {
377389
+ const { prompts, refusal } = createFlagPrompts(request);
377390
+ const result = await selectOrCreateHostedProject({
377391
+ apiClient,
377392
+ prompts,
377393
+ ...telemetry ? { telemetry } : {}
377394
+ });
377395
+ if ("canceled" in result) {
377396
+ const recorded = refusal.value;
377397
+ throw tagError(
377398
+ new Error(
377399
+ recorded === null ? "Project selection canceled." : formatFlagRefusal(recorded, "init").trimEnd()
377400
+ ),
377401
+ TELEMETRY_ERROR_CODES.PROJECT_NOT_FOUND
377402
+ );
377403
+ }
377404
+ return result;
377405
+ }
377406
+ var init_init_project_flag = __esm({
377407
+ "apps/cli/src/commands/init-project-flag.ts"() {
377408
+ "use strict";
377409
+ init_hosted_project2();
377410
+ init_types();
377411
+ init_event_properties();
377412
+ init_project_select_flags();
377413
+ }
377414
+ });
377415
+
377416
+ // apps/cli/src/commands/init-non-interactive.ts
377417
+ var init_non_interactive_exports = {};
377418
+ __export(init_non_interactive_exports, {
377419
+ NON_INTERACTIVE_LOGIN_MESSAGE: () => NON_INTERACTIVE_LOGIN_MESSAGE,
377420
+ formatNonInteractiveInitRefusal: () => formatNonInteractiveInitRefusal,
377421
+ missingNonInteractiveInitFlags: () => missingNonInteractiveInitFlags,
377422
+ resolveInitInstallFlag: () => resolveInitInstallFlag
377423
+ });
377424
+ function missingNonInteractiveInitFlags(answers) {
377425
+ const missing = [];
377426
+ if (answers.name === void 0 || answers.name.trim() === "") {
377427
+ missing.push("--name");
377428
+ }
377429
+ const framework = answers.framework === void 0 ? void 0 : resolveFrameworkAlias(answers.framework);
377430
+ if (framework === void 0 || framework.trim() === "") {
377431
+ missing.push("--framework");
377432
+ } else if (isAgentFramework(framework) && THREADS_FRAMEWORKS.has(framework) && !answers.hostedProjectNamed) {
377433
+ missing.push("--project");
377434
+ }
377435
+ if (!answers.installAnswered) {
377436
+ missing.push("--yes");
377437
+ }
377438
+ return missing;
377439
+ }
377440
+ function formatNonInteractiveInitRefusal(missing) {
377441
+ return `\`copilotkit init\` prompts for anything you do not name, and this shell has no terminal to prompt in.
377442
+ Name the rest up front: ${missing.join(", ")}
377443
+ ` + (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" : "");
377444
+ }
377445
+ function resolveInitInstallFlag(input) {
377446
+ const wantsInstall = input.yes === true || input.install === true;
377447
+ if (wantsInstall && input.noInstall === true) {
377448
+ return {
377449
+ status: "invalid",
377450
+ message: "Pass either `--install` (or `--yes`) or `--no-install`, not both: they answer the same question in opposite ways."
377451
+ };
377452
+ }
377453
+ if (wantsInstall)
377454
+ return { status: "ok", install: true };
377455
+ if (input.noInstall === true)
377456
+ return { status: "ok", install: false };
377457
+ return { status: "ok", install: null };
377458
+ }
377459
+ var NON_INTERACTIVE_LOGIN_MESSAGE;
377460
+ var init_init_non_interactive = __esm({
377461
+ "apps/cli/src/commands/init-non-interactive.ts"() {
377462
+ "use strict";
377463
+ init_types();
377464
+ 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.";
377465
+ }
377466
+ });
377467
+
377271
377468
  // apps/cli/src/ui/init-flow.tsx
377272
377469
  import * as path26 from "node:path";
377273
377470
  function FrameworkIndicator({ isSelected = false }) {
@@ -379057,6 +379254,12 @@ import {
379057
379254
  rmSync as rmSync4
379058
379255
  } from "node:fs";
379059
379256
  import * as path33 from "node:path";
379257
+ function markDisplayedAtTerminal(error98) {
379258
+ if (process.stdout.isTTY === true) {
379259
+ error98.displayed = true;
379260
+ }
379261
+ return error98;
379262
+ }
379060
379263
  function shouldRenderInitBrowserLoginConfirmation(phase) {
379061
379264
  return phase === "confirming" || phase === "waiting" || phase === "finalizing";
379062
379265
  }
@@ -379084,6 +379287,16 @@ function commandExists(command2, environment = process.env, platform4 = process.
379084
379287
  function vendorKeyPromptInteractive() {
379085
379288
  return process.stdin.isTTY === true && process.stdout.isTTY === true;
379086
379289
  }
379290
+ function createHostedProjectApiClient(auth2) {
379291
+ return createApiClient(getOpsApiUrl(), auth2.cliToken, {
379292
+ onProductCredential: (productCredential) => {
379293
+ authStore.save({ ...auth2, productCredential });
379294
+ },
379295
+ productBaseUrl: getAppApiUrl(),
379296
+ productCredential: auth2.productCredential,
379297
+ productOrganizationId: auth2.clerkOrgId
379298
+ });
379299
+ }
379087
379300
  function buildInitNextSteps(templateDefinition, projectName, result, unsatisfiedKeys, installAlreadyRan = false, mockProvider = void 0) {
379088
379301
  const missingPrerequisites = templateDefinition.prerequisites.filter(
379089
379302
  (prerequisite) => result.missingPrerequisites.includes(prerequisite.command)
@@ -379269,6 +379482,12 @@ async function ensureCliToken2(dependencies, onTerminalSessionInvalidation, onBr
379269
379482
  }
379270
379483
  };
379271
379484
  const openBrowser = async () => {
379485
+ if (!(dependencies.isBrowserLoginInteractive ?? isBrowserLoginConfirmationInteractive)()) {
379486
+ throw tagError(
379487
+ new Error(NON_INTERACTIVE_LOGIN_MESSAGE),
379488
+ TELEMETRY_ERROR_CODES.NON_INTERACTIVE
379489
+ );
379490
+ }
379272
379491
  emitGate(false);
379273
379492
  if (!openedBrowser) {
379274
379493
  openedBrowser = true;
@@ -379526,13 +379745,16 @@ async function scaffoldInitProject(options, dependencies = defaultInitScaffoldDe
379526
379745
  });
379527
379746
  } catch (selectionError) {
379528
379747
  const detail = selectionError instanceof Error ? selectionError.message : String(selectionError);
379529
- warnings.push(
379530
- `Project not selected (${detail}); run \`copilotkit project select\` in the project to choose one.`
379531
- );
379532
379748
  writeCliLog("error", {
379533
379749
  event: "init.project_select_failed",
379534
379750
  detail
379535
379751
  });
379752
+ if (options.hostedProject !== null && options.hostedProject !== void 0) {
379753
+ throw selectionError instanceof Error ? selectionError : new Error(detail);
379754
+ }
379755
+ warnings.push(
379756
+ `Project not selected (${detail}); run \`copilotkit project select\` in the project to choose one.`
379757
+ );
379536
379758
  }
379537
379759
  }
379538
379760
  telemetry?.onScaffoldSucceeded({
@@ -379704,6 +379926,7 @@ function ScaffoldProgress({
379704
379926
  const channelOfferDeferredRef = (0, import_react48.useRef)(null);
379705
379927
  const channelCompletionOfferedRef = (0, import_react48.useRef)(false);
379706
379928
  const installAlreadyRanRef = (0, import_react48.useRef)(false);
379929
+ const installAnsweredRef = (0, import_react48.useRef)(false);
379707
379930
  const [credentialRequest, setCredentialRequest] = (0, import_react48.useState)(null);
379708
379931
  const [attachingChannel, setAttachingChannel] = (0, import_react48.useState)(false);
379709
379932
  const channelFlagError = (0, import_react48.useMemo)(
@@ -379713,6 +379936,13 @@ function ScaffoldProgress({
379713
379936
  ),
379714
379937
  [options.channel, options.framework]
379715
379938
  );
379939
+ const hostedProjectFlagError = (0, import_react48.useMemo)(
379940
+ () => hostedProjectFlagUnsupportedError(
379941
+ options.hostedProject ?? null,
379942
+ options.framework ?? null
379943
+ ),
379944
+ [options.hostedProject, options.framework]
379945
+ );
379716
379946
  const flagChannelOffer = (0, import_react48.useMemo)(
379717
379947
  () => channelOfferFromFlag(options.channel ?? null),
379718
379948
  [options.channel]
@@ -379728,6 +379958,19 @@ function ScaffoldProgress({
379728
379958
  new Error("Not authenticated for project selection.")
379729
379959
  );
379730
379960
  }
379961
+ const named = options.hostedProject;
379962
+ if (named !== null && named !== void 0) {
379963
+ return selectHostedProjectFromFlag(
379964
+ createHostedProjectApiClient(auth2),
379965
+ named,
379966
+ {
379967
+ onPickerViewed: (projectCount) => telemetry?.onProjectPickerViewed({ projectCount }),
379968
+ onResolved: (outcome, projectCount) => telemetry?.onProjectResolved({ outcome, projectCount }),
379969
+ onCreateNameRejected: (reason) => telemetry?.onProjectCreateNameRejected({ reason }),
379970
+ onBack: () => telemetry?.onProjectPickerBack()
379971
+ }
379972
+ );
379973
+ }
379731
379974
  return new Promise((resolve9, reject) => {
379732
379975
  selectionDeferredRef.current = { resolve: resolve9, reject };
379733
379976
  });
@@ -379793,11 +380036,11 @@ function ScaffoldProgress({
379793
380036
  }, [phase, scaffoldResult]);
379794
380037
  (0, import_react48.useEffect)(() => {
379795
380038
  let cancelled = false;
379796
- if (channelFlagError !== void 0) {
379797
- const error98 = new Error(channelFlagError);
379798
- error98.displayed = true;
380039
+ const flagError = channelFlagError ?? hostedProjectFlagError;
380040
+ if (flagError !== void 0) {
380041
+ const error98 = markDisplayedAtTerminal(new Error(flagError));
379799
380042
  scaffoldErrorRef.current = error98;
379800
- setErrorMessage(channelFlagError);
380043
+ setErrorMessage(flagError);
379801
380044
  setPhase("error");
379802
380045
  return () => {
379803
380046
  cancelled = true;
@@ -379839,8 +380082,9 @@ function ScaffoldProgress({
379839
380082
  run().catch((err2) => {
379840
380083
  if (cancelled)
379841
380084
  return;
379842
- const error98 = err2 instanceof Error ? err2 : new Error("An unexpected error occurred.");
379843
- error98.displayed = true;
380085
+ const error98 = markDisplayedAtTerminal(
380086
+ err2 instanceof Error ? err2 : new Error("An unexpected error occurred.")
380087
+ );
379844
380088
  scaffoldErrorRef.current = error98;
379845
380089
  setErrorMessage(error98.message);
379846
380090
  setPhase("error");
@@ -379887,6 +380131,45 @@ function ScaffoldProgress({
379887
380131
  }
379888
380132
  setPhase("success");
379889
380133
  }
380134
+ function answerInstall(result, install) {
380135
+ if (!install) {
380136
+ finalizeSuccess(result);
380137
+ return;
380138
+ }
380139
+ setPhase("installing");
380140
+ scaffoldDependencies.installDependencies({
380141
+ cwd: result.projectDir,
380142
+ command: templateDefinition.installCommand,
380143
+ log: writeCliLog
380144
+ }).then((r2) => {
380145
+ if (r2.ok)
380146
+ return true;
380147
+ if (isMountedRef.current) {
380148
+ setInstallError(r2.stderrTail || "install failed");
380149
+ }
380150
+ return false;
380151
+ }).catch((e2) => {
380152
+ if (isMountedRef.current) {
380153
+ setInstallError(e2 instanceof Error ? e2.message : String(e2));
380154
+ }
380155
+ return false;
380156
+ }).then((installSucceeded) => {
380157
+ if (!isMountedRef.current)
380158
+ return;
380159
+ finalizeSuccess(result, installSucceeded);
380160
+ });
380161
+ }
380162
+ (0, import_react48.useEffect)(() => {
380163
+ if (phase !== "install-prompt" || scaffoldResult === null)
380164
+ return;
380165
+ const answer = options.installDependencies;
380166
+ if (answer !== true && answer !== false)
380167
+ return;
380168
+ if (installAnsweredRef.current)
380169
+ return;
380170
+ installAnsweredRef.current = true;
380171
+ answerInstall(scaffoldResult, answer);
380172
+ }, [phase, scaffoldResult, options.installDependencies]);
379890
380173
  function completeChannel(result, channel2) {
379891
380174
  const complete = scaffoldDependencies.completeChannelSetup;
379892
380175
  if (complete === void 0) {
@@ -379980,6 +380263,9 @@ function ScaffoldProgress({
379980
380263
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Downloading template\u2026" }) });
379981
380264
  }
379982
380265
  if (phase === "select-project") {
380266
+ if (options.hostedProject !== null && options.hostedProject !== void 0) {
380267
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Selecting your Intelligence project\u2026" });
380268
+ }
379983
380269
  const auth2 = authStore.get();
379984
380270
  if (auth2 === null) {
379985
380271
  return null;
@@ -379987,14 +380273,7 @@ function ScaffoldProgress({
379987
380273
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
379988
380274
  HostedProjectSelect,
379989
380275
  {
379990
- apiClient: createApiClient(getOpsApiUrl(), auth2.cliToken, {
379991
- onProductCredential: (productCredential) => {
379992
- authStore.save({ ...auth2, productCredential });
379993
- },
379994
- productBaseUrl: getAppApiUrl(),
379995
- productCredential: auth2.productCredential,
379996
- productOrganizationId: auth2.clerkOrgId
379997
- }),
380276
+ apiClient: createHostedProjectApiClient(auth2),
379998
380277
  defaultName: options.name,
379999
380278
  telemetry: {
380000
380279
  onPickerViewed: (projectCount) => telemetry?.onProjectPickerViewed({ projectCount }),
@@ -380110,38 +380389,17 @@ function ScaffoldProgress({
380110
380389
  );
380111
380390
  }
380112
380391
  if (phase === "install-prompt" && scaffoldResult) {
380392
+ if (options.installDependencies === true) {
380393
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Spinner, { label: "\u{1FA81} Installing dependencies\u2026" });
380394
+ }
380395
+ if (options.installDependencies === false) {
380396
+ return null;
380397
+ }
380113
380398
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
380114
380399
  InstallPrompt,
380115
380400
  {
380116
380401
  installCommand: templateDefinition.installCommand,
380117
- onAnswer: (install) => {
380118
- if (!install) {
380119
- finalizeSuccess(scaffoldResult);
380120
- return;
380121
- }
380122
- setPhase("installing");
380123
- scaffoldDependencies.installDependencies({
380124
- cwd: scaffoldResult.projectDir,
380125
- command: templateDefinition.installCommand,
380126
- log: writeCliLog
380127
- }).then((r2) => {
380128
- if (r2.ok)
380129
- return true;
380130
- if (isMountedRef.current) {
380131
- setInstallError(r2.stderrTail || "install failed");
380132
- }
380133
- return false;
380134
- }).catch((e2) => {
380135
- if (isMountedRef.current) {
380136
- setInstallError(e2 instanceof Error ? e2.message : String(e2));
380137
- }
380138
- return false;
380139
- }).then((installSucceeded) => {
380140
- if (!isMountedRef.current)
380141
- return;
380142
- finalizeSuccess(scaffoldResult, installSucceeded);
380143
- });
380144
- }
380402
+ onAnswer: (install) => answerInstall(scaffoldResult, install)
380145
380403
  }
380146
380404
  );
380147
380405
  }
@@ -380216,6 +380474,8 @@ function InitApp({
380216
380474
  noBanner = false,
380217
380475
  initialMock = false,
380218
380476
  initialChannel = null,
380477
+ initialHostedProject = null,
380478
+ initialInstall = null,
380219
380479
  renderScaffoldProgress = renderDefaultScaffoldProgress,
380220
380480
  onIntelligenceSelected,
380221
380481
  onFrameworkSelected,
@@ -380228,7 +380488,12 @@ function InitApp({
380228
380488
  initialFramework,
380229
380489
  mock
380230
380490
  );
380231
- const prefilled = prefilledBase === null ? null : { ...prefilledBase, channel: initialChannel };
380491
+ const prefilled = prefilledBase === null ? null : {
380492
+ ...prefilledBase,
380493
+ channel: initialChannel,
380494
+ hostedProject: initialHostedProject,
380495
+ installDependencies: initialInstall
380496
+ };
380232
380497
  const [options, setOptions] = (0, import_react48.useState)(prefilled);
380233
380498
  (0, import_react48.useEffect)(() => {
380234
380499
  if (prefilled !== null) {
@@ -380262,7 +380527,13 @@ function InitApp({
380262
380527
  onFrameworkSelected,
380263
380528
  onComplete: (resolved) => {
380264
380529
  if (resolved !== null) {
380265
- setOptions({ ...resolved, mock, channel: initialChannel });
380530
+ setOptions({
380531
+ ...resolved,
380532
+ mock,
380533
+ channel: initialChannel,
380534
+ hostedProject: initialHostedProject,
380535
+ installDependencies: initialInstall
380536
+ });
380266
380537
  }
380267
380538
  }
380268
380539
  }
@@ -380306,6 +380577,8 @@ async function runInit(flags, callbacks) {
380306
380577
  initialFramework,
380307
380578
  initialMock: flags.mock ?? false,
380308
380579
  initialChannel: flags.channel ?? null,
380580
+ initialHostedProject: flags.hostedProject ?? null,
380581
+ initialInstall: flags.installDependencies ?? null,
380309
380582
  noBanner: flags.noBanner === true,
380310
380583
  onIntelligenceSelected: callbacks?.onIntelligenceSelected,
380311
380584
  onFrameworkSelected: callbacks?.onFrameworkSelected,
@@ -380334,6 +380607,8 @@ var init_init = __esm({
380334
380607
  await init_vendor_key_prompt();
380335
380608
  init_feature_flags();
380336
380609
  await init_install_prompt();
380610
+ init_init_project_flag();
380611
+ init_init_non_interactive();
380337
380612
  init_config_service();
380338
380613
  init_event_properties();
380339
380614
  init_cli_logs();
@@ -380396,7 +380671,8 @@ var init_init = __esm({
380396
380671
  appendIntelligenceReadme,
380397
380672
  writeHostedApiKey,
380398
380673
  writeVendorKey,
380399
- isVendorKeyPromptInteractive: vendorKeyPromptInteractive
380674
+ isVendorKeyPromptInteractive: vendorKeyPromptInteractive,
380675
+ isBrowserLoginInteractive: isBrowserLoginConfirmationInteractive
380400
380676
  };
380401
380677
  }
380402
380678
  });
@@ -380912,6 +381188,56 @@ var init_onboarding_state = __esm({
380912
381188
  }
380913
381189
  });
380914
381190
 
381191
+ // apps/cli/src/services/onboarding-classification.ts
381192
+ function requireOnboardingChoice(flag, value, choices) {
381193
+ const selected = choices.find((choice) => choice === value);
381194
+ if (selected === void 0) {
381195
+ throw new Error(`${flag} must be one of: ${choices.join(", ")}.`);
381196
+ }
381197
+ return selected;
381198
+ }
381199
+ var ONBOARDING_STARTING_STATES, ONBOARDING_AGENT_FRAMEWORKS, ONBOARDING_FRONTENDS;
381200
+ var init_onboarding_classification = __esm({
381201
+ "apps/cli/src/services/onboarding-classification.ts"() {
381202
+ "use strict";
381203
+ ONBOARDING_STARTING_STATES = [
381204
+ "empty",
381205
+ "agent-only",
381206
+ "frontend-only",
381207
+ "both",
381208
+ "both-oss"
381209
+ ];
381210
+ ONBOARDING_AGENT_FRAMEWORKS = [
381211
+ "ag2",
381212
+ "agno",
381213
+ "built-in",
381214
+ "claude-sdk-python",
381215
+ "claude-sdk-typescript",
381216
+ "crewai-flows",
381217
+ "deep-agents",
381218
+ "google-adk",
381219
+ "langgraph-fastapi",
381220
+ "langgraph-python",
381221
+ "langgraph-typescript",
381222
+ "llamaindex",
381223
+ "mastra",
381224
+ "ms-agent-dotnet",
381225
+ "ms-agent-harness-dotnet",
381226
+ "ms-agent-python",
381227
+ "pydantic-ai",
381228
+ "strands-python",
381229
+ "strands-typescript"
381230
+ ];
381231
+ ONBOARDING_FRONTENDS = [
381232
+ "react-spa",
381233
+ "nextjs",
381234
+ "angular",
381235
+ "vue",
381236
+ "react-native"
381237
+ ];
381238
+ }
381239
+ });
381240
+
380915
381241
  // apps/cli/src/commands/onboard.ts
380916
381242
  var onboard_exports = {};
380917
381243
  __export(onboard_exports, {
@@ -380971,25 +381297,61 @@ async function runOnboard(argv, dependencies) {
380971
381297
  return;
380972
381298
  }
380973
381299
  if (subcommand === "complete") {
380974
- const visualCheck = parseVisualCheck(argv.slice(1));
380975
- if (visualCheck === void 0) {
380976
- throw new Error(
380977
- "Usage: copilotkit onboard complete --visual-check <performed|skipped-no-browser-tool|failed>"
380978
- );
380979
- }
381300
+ const check4 = parseSurfaceCheck(argv.slice(1));
381301
+ if (check4 === void 0)
381302
+ throw new Error(SURFACE_CHECK_USAGE);
380980
381303
  recordBestEffort(deps, {
380981
381304
  event: "cli.onboarding.completed",
380982
381305
  properties: {
380983
381306
  command: "onboard",
380984
381307
  onboarding_run_id: binding.runId,
380985
381308
  cli_version: deps.cliVersion,
380986
- visual_check: visualCheck
381309
+ ...check4.kind === "visual" ? { visual_check: check4.outcome } : { device_check: check4.outcome }
380987
381310
  }
380988
381311
  });
380989
- deps.stdout.write("CopilotKit onboarding marked complete.\n");
380990
- if (visualCheck !== "performed") {
380991
- deps.stdout.write(visualCheckWarning(visualCheck));
380992
- }
381312
+ deps.stdout.write(
381313
+ check4.outcome === "performed" ? "CopilotKit onboarding marked complete.\n" : blockedWithoutSurfaceProof(check4)
381314
+ );
381315
+ return;
381316
+ }
381317
+ if (subcommand === "classify") {
381318
+ const parsed = parseArgs2({
381319
+ args: [...argv.slice(1)],
381320
+ allowPositionals: false,
381321
+ options: {
381322
+ "starting-state": { type: "string" },
381323
+ "agent-framework": { type: "string" },
381324
+ frontend: { type: "string" }
381325
+ },
381326
+ strict: true
381327
+ });
381328
+ const startingState = requireOnboardingChoice(
381329
+ "--starting-state",
381330
+ parsed.values["starting-state"],
381331
+ ONBOARDING_STARTING_STATES
381332
+ );
381333
+ const agentFramework = requireOnboardingChoice(
381334
+ "--agent-framework",
381335
+ parsed.values["agent-framework"],
381336
+ ONBOARDING_AGENT_FRAMEWORKS
381337
+ );
381338
+ const frontend = requireOnboardingChoice(
381339
+ "--frontend",
381340
+ parsed.values.frontend,
381341
+ ONBOARDING_FRONTENDS
381342
+ );
381343
+ recordBestEffort(deps, {
381344
+ event: "cli.onboarding.classified",
381345
+ properties: {
381346
+ command: "onboard",
381347
+ onboarding_run_id: binding.runId,
381348
+ cli_version: deps.cliVersion,
381349
+ starting_state: startingState,
381350
+ agent_framework: agentFramework,
381351
+ frontend
381352
+ }
381353
+ });
381354
+ deps.stdout.write("Onboarding path included in telemetry when enabled.\n");
380993
381355
  return;
380994
381356
  }
380995
381357
  if (subcommand === "feedback") {
@@ -381004,28 +381366,66 @@ async function runOnboard(argv, dependencies) {
381004
381366
  return;
381005
381367
  }
381006
381368
  throw new Error(
381007
- "Usage: copilotkit onboard <start|read|complete|feedback|friction>"
381369
+ "Usage: copilotkit onboard <start|read|classify|complete|feedback|friction>"
381008
381370
  );
381009
381371
  }
381010
- function parseVisualCheck(rest) {
381011
- if (rest.length !== 2 || rest[0] !== "--visual-check")
381372
+ function parseSurfaceCheck(rest) {
381373
+ if (rest.length !== 2)
381012
381374
  return void 0;
381013
- const value = rest[1];
381014
- return VISUAL_CHECK_OUTCOMES.find((outcome) => outcome === value);
381375
+ const [flag, value] = rest;
381376
+ if (flag === "--visual-check") {
381377
+ const outcome = VISUAL_CHECK_OUTCOMES.find((known) => known === value);
381378
+ return outcome === void 0 ? void 0 : { kind: "visual", outcome };
381379
+ }
381380
+ if (flag === "--device-check") {
381381
+ const outcome = DEVICE_CHECK_OUTCOMES.find((known) => known === value);
381382
+ return outcome === void 0 ? void 0 : { kind: "device", outcome };
381383
+ }
381384
+ return void 0;
381015
381385
  }
381016
- function visualCheckWarning(outcome) {
381017
- const cause = outcome === "failed" ? "it did not succeed" : "no browser automation was available to the coding agent, so nothing drove the real frontend";
381386
+ function blockedWithoutSurfaceProof(check4) {
381387
+ const failed2 = check4.outcome === "failed";
381388
+ const visual = {
381389
+ headline: [
381390
+ " The live UI check was NOT performed:",
381391
+ failed2 ? " it did not succeed." : " no browser automation was available, so nothing drove the real frontend."
381392
+ ],
381393
+ uncovered: [
381394
+ "realtime delivery to a browser over the gateway",
381395
+ "browser-origin CORS and CSP, which a CLI request never exercises",
381396
+ "the frontend provider being wired to this runtime",
381397
+ "generative UI actually rendering a component"
381398
+ ],
381399
+ reach: "which reaches no browser",
381400
+ 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`"
381401
+ };
381402
+ const device = {
381403
+ headline: [
381404
+ " The on-device check was NOT performed:",
381405
+ failed2 ? " it did not succeed." : " no device or emulator was available, so nothing ran the real app."
381406
+ ],
381407
+ uncovered: [
381408
+ "the app rendering at all on a real screen",
381409
+ "a tool-rendered component painted in the view tree",
381410
+ "an unresolved redbox, which no terminal output shows",
381411
+ "realtime delivery to the app over the gateway"
381412
+ ],
381413
+ reach: "which reaches no screen",
381414
+ 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`"
381415
+ };
381416
+ const surface = check4.kind === "visual" ? visual : device;
381018
381417
  return [
381019
381418
  "",
381020
- `! The live UI check was NOT performed: ${cause}.`,
381021
- " The agent round trip itself was proven with `copilotkit verify --round-trip`.",
381022
- " Not covered by that, and still unverified here:",
381023
- " - realtime delivery to a browser over the gateway",
381024
- " - browser-origin CORS and CSP, which a CLI request never exercises",
381025
- " - the frontend provider being wired to this runtime",
381026
- " - generative UI actually rendering a component",
381027
- " To close it, configure a browser MCP server for your coding agent and",
381028
- " drive the app once by hand.",
381419
+ "! Onboarding is NOT complete.",
381420
+ ...surface.headline,
381421
+ ` The agent round trip is what \`copilotkit verify --round-trip\` proves, ${surface.reach}.`,
381422
+ " Not covered by it, and still unverified here:",
381423
+ ...surface.uncovered.map((line) => ` - ${line}`),
381424
+ "",
381425
+ " Report this run as blocked, and name the unverified lines above as the",
381426
+ " evidence it is missing. Do not report it as complete: every other check in",
381427
+ " this graph can pass while all four of those fail.",
381428
+ ` To close it, ${surface.close}.`,
381029
381429
  ""
381030
381430
  ].join("\n");
381031
381431
  }
@@ -381179,7 +381579,7 @@ function recordBestEffort(dependencies, event) {
381179
381579
  } catch {
381180
381580
  }
381181
381581
  }
381182
- var VISUAL_CHECK_OUTCOMES;
381582
+ var VISUAL_CHECK_OUTCOMES, DEVICE_CHECK_OUTCOMES, SURFACE_CHECK_USAGE;
381183
381583
  var init_onboard = __esm({
381184
381584
  async "apps/cli/src/commands/onboard.ts"() {
381185
381585
  "use strict";
@@ -381189,12 +381589,19 @@ var init_onboard = __esm({
381189
381589
  init_onboarding_friction();
381190
381590
  init_onboarding_feedback();
381191
381591
  init_onboarding_state();
381592
+ init_onboarding_classification();
381192
381593
  await init_telemetry();
381193
381594
  VISUAL_CHECK_OUTCOMES = [
381194
381595
  "performed",
381195
381596
  "skipped-no-browser-tool",
381196
381597
  "failed"
381197
381598
  ];
381599
+ DEVICE_CHECK_OUTCOMES = [
381600
+ "performed",
381601
+ "skipped-no-device",
381602
+ "failed"
381603
+ ];
381604
+ 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.";
381198
381605
  }
381199
381606
  });
381200
381607
 
@@ -384374,6 +384781,7 @@ Options:
384374
384781
  `,
384375
384782
  onboard: `Usage: copilotkit onboard start [--run <id>] [--coding-agent <slug>]
384376
384783
  copilotkit onboard read <prompt-name>
384784
+ copilotkit onboard classify --starting-state <state> --agent-framework <framework> --frontend <frontend>
384377
384785
  copilotkit onboard complete
384378
384786
  copilotkit onboard feedback
384379
384787
  copilotkit onboard friction --category <slug> --cost-seconds <seconds>
@@ -384383,6 +384791,7 @@ Guide a coding agent through the Markdown graph bundled with this exact CLI.
384383
384791
  Subcommands:
384384
384792
  start Start or replace the repository-bound onboarding run
384385
384793
  read Print one rendered prompt as the only stdout payload
384794
+ classify Send the bounded matrix path for this run
384386
384795
  complete Mark a proven onboarding run complete
384387
384796
  feedback Read one non-empty message from standard input
384388
384797
  friction Report one papercut that slowed a run down
@@ -384402,6 +384811,7 @@ refused before anything is sent, and the reason is printed. Both commands print
384402
384811
  what they sent. Every refusal exits zero and leaves onboarding unaffected.
384403
384812
  `,
384404
384813
  verify: `Usage: copilotkit verify [--json] [--runtime-url <url>] [--round-trip]
384814
+ [--expect-runtime <mode>]
384405
384815
 
384406
384816
  Check that this project's CopilotKit wiring works, and report what it found.
384407
384817
 
@@ -384418,10 +384828,15 @@ the answer back from the thread, which is the only check here that proves the
384418
384828
  agent runs rather than that it is configured. That costs a model call and
384419
384829
  records a thread, so it is opt-in.
384420
384830
 
384831
+ With --expect-runtime oss, hosted project and credential checks do not apply.
384832
+ The command exits zero only when valid /info data declares the named agent,
384833
+ licenseStatus is absent, and --round-trip --agent <id> passes.
384834
+
384421
384835
  Options:
384422
384836
  --json Emit a machine-readable payload alone on stdout
384423
384837
  --runtime-url <url> The CopilotKit runtime endpoint to probe
384424
384838
  (default: http://localhost:3000/api/copilotkit)
384839
+ --expect-runtime <mode> Require intelligence (default) or oss runtime mode
384425
384840
  --round-trip Also run the agent and read its answer back
384426
384841
  --agent <id> Which declared agent to run, when there are several
384427
384842
  --timeout <seconds> How long to wait for the answer (default: 90)
@@ -384493,9 +384908,28 @@ ${isCliFlagEnabled("cli.aimock-mock-mode") ? ` --mock Run keyle
384493
384908
  provider will ask you for. A named provider is set up as
384494
384909
  far as it can go without credentials, then reports what
384495
384910
  is left -- it never prompts for a secret.
384911
+ --project <ref> Select an existing hosted Intelligence project by slug
384912
+ or id, instead of showing the picker
384913
+ --create <name> Create a hosted Intelligence project with this name and
384914
+ select it
384915
+ -y, --yes Install dependencies without asking
384916
+ --install Install dependencies without asking (same as --yes)
384917
+ --no-install Skip the install without asking
384496
384918
  --no-banner Suppress the CopilotKit welcome banner (used when a
384497
384919
  parent tool, e.g. create-ag-ui-app, shows its own)
384498
384920
  -h, --help Show help for init
384921
+
384922
+ Pass --project or --create, never both. They resolve the same way
384923
+ \`copilotkit project select\` does: a typo fails with the real slugs rather than
384924
+ creating something you did not ask for.
384925
+
384926
+ init prompts for anything you do not name, so a shell with no terminal needs the
384927
+ answers up front: -n, -f, -y, and --project or --create. It then refuses only the
384928
+ ones still missing, and names them.
384929
+
384930
+ Signing in is the one answer no flag supplies: it opens a browser and finishes
384931
+ back at the terminal. Run \`copilotkit login\` first, or a run with no terminal is
384932
+ refused rather than opening a browser it cannot finish with.
384499
384933
  `,
384500
384934
  license: `Usage: copilotkit license [create]
384501
384935
  copilotkit license list [options]
@@ -384612,6 +385046,7 @@ one currently selected in .copilotkit/project.json.
384612
385046
 
384613
385047
  Options:
384614
385048
  --json Emit a machine-readable payload instead of a table
385049
+ --search <query> Match a project name, slug, or id
384615
385050
  -h, --help Show help for project list
384616
385051
 
384617
385052
  Runs with no TTY, so a coding agent can read the choices before selecting one.
@@ -384641,9 +385076,10 @@ organization's real projects, so a typo fails with the available slugs rather
384641
385076
  than recording a selection that points at nothing. Run
384642
385077
  \`copilotkit project list --json\` first to see them.
384643
385078
 
384644
- --json reports api_key_provisioned. Key provisioning is deliberately non-fatal,
384645
- so a run can persist the selection, warn on stderr, and still exit 0 with no key
384646
- written; that field is how a caller detects it without reading stderr.
385079
+ --json reports selected_project_slug, project_file_written,
385080
+ api_key_provisioned, and environment_file_written. Key provisioning is
385081
+ deliberately non-fatal, so the key fields can be false after exit 0. The payload
385082
+ never contains the API key.
384647
385083
 
384648
385084
  With --json the payload is the ONLY thing on stdout: warnings, errors, and the
384649
385085
  interactive picker itself all render to stderr, so piping stdout into a parser
@@ -385196,15 +385632,22 @@ async function runProjectCommand(argv) {
385196
385632
  const parsed2 = parseArgs4({
385197
385633
  args: [...argv.slice(1)],
385198
385634
  options: {
385199
- json: { type: "boolean" }
385635
+ json: { type: "boolean" },
385636
+ search: { type: "string" }
385200
385637
  },
385201
385638
  strict: true,
385202
385639
  allowPositionals: false
385203
385640
  });
385204
- await withTelemetry({ command: "project", subcommand: "list" }, async () => {
385205
- const { runProjectList: runProjectList2 } = await Promise.resolve().then(() => (init_project_list(), project_list_exports));
385206
- await runProjectList2({ json: parsed2.values["json"] === true });
385207
- });
385641
+ await withTelemetry(
385642
+ { command: "project", subcommand: "list" },
385643
+ async () => {
385644
+ const { runProjectList: runProjectList2 } = await Promise.resolve().then(() => (init_project_list(), project_list_exports));
385645
+ await runProjectList2({
385646
+ json: parsed2.values["json"] === true,
385647
+ search: parsed2.values["search"]
385648
+ });
385649
+ }
385650
+ );
385208
385651
  return;
385209
385652
  }
385210
385653
  if (subcommand !== "select") {
@@ -385558,6 +386001,7 @@ async function runVerifyCommand(argv) {
385558
386001
  args: [...argv],
385559
386002
  options: {
385560
386003
  agent: { type: "string" },
386004
+ "expect-runtime": { type: "string" },
385561
386005
  header: { multiple: true, type: "string" },
385562
386006
  json: { type: "boolean" },
385563
386007
  "round-trip": { type: "boolean" },
@@ -385581,6 +386025,14 @@ async function runVerifyCommand(argv) {
385581
386025
  if (timeoutSeconds !== void 0 && !/^\d+$/.test(timeoutSeconds)) {
385582
386026
  process.stderr.write(
385583
386027
  `Error: --timeout must be a whole number of seconds (received "${timeoutSeconds}").
386028
+ `
386029
+ );
386030
+ await exitWithFlush(1);
386031
+ }
386032
+ const expectedRuntime = parsed.values["expect-runtime"];
386033
+ if (expectedRuntime !== void 0 && expectedRuntime !== "intelligence" && expectedRuntime !== "oss") {
386034
+ process.stderr.write(
386035
+ `Error: --expect-runtime must be intelligence or oss (received "${expectedRuntime}").
385584
386036
  `
385585
386037
  );
385586
386038
  await exitWithFlush(1);
@@ -385589,9 +386041,7 @@ async function runVerifyCommand(argv) {
385589
386041
  parsed.values["header"] ?? []
385590
386042
  );
385591
386043
  if (headers === void 0) {
385592
- process.stderr.write(
385593
- 'Error: --header expects "Name: value".\n'
385594
- );
386044
+ process.stderr.write('Error: --header expects "Name: value".\n');
385595
386045
  await exitWithFlush(1);
385596
386046
  }
385597
386047
  const agent = parsed.values["agent"];
@@ -385599,6 +386049,7 @@ async function runVerifyCommand(argv) {
385599
386049
  await runVerify2({
385600
386050
  json: parsed.values["json"] === true,
385601
386051
  ...agent === void 0 ? {} : { agent },
386052
+ ...expectedRuntime === void 0 ? {} : { expectRuntime: expectedRuntime },
385602
386053
  ...headers === void 0 || Object.keys(headers).length === 0 ? {} : { headers },
385603
386054
  ...parsed.values["round-trip"] === true ? { roundTrip: true } : {},
385604
386055
  ...runtimeUrl === void 0 ? {} : { runtimeUrl },
@@ -385659,6 +386110,11 @@ var INIT_PARSE_OPTIONS = {
385659
386110
  framework: { type: "string", short: "f" },
385660
386111
  mock: { type: "boolean" },
385661
386112
  channel: { type: "string" },
386113
+ project: { type: "string" },
386114
+ create: { type: "string" },
386115
+ yes: { type: "boolean", short: "y" },
386116
+ install: { type: "boolean" },
386117
+ "no-install": { type: "boolean" },
385662
386118
  "no-banner": { type: "boolean" }
385663
386119
  };
385664
386120
  async function runInitCommand(invokedAs, argv) {
@@ -385699,17 +386155,22 @@ async function runInitCommand(invokedAs, argv) {
385699
386155
  await exitWithFlush(1);
385700
386156
  return;
385701
386157
  }
385702
- if (!process.stdin.isTTY) {
386158
+ const { resolveInitProjectFlag: resolveInitProjectFlag2 } = await Promise.resolve().then(() => (init_init_project_flag(), init_project_flag_exports));
386159
+ const projectResolution = resolveInitProjectFlag2({
386160
+ project: parsed.values["project"],
386161
+ create: parsed.values["create"],
386162
+ framework: frameworkFlag
386163
+ });
386164
+ if (projectResolution.status === "invalid") {
385703
386165
  recordTelemetryEvent({
385704
386166
  properties: {
385705
386167
  ...telemetryBase,
385706
386168
  outcome: "failed",
385707
- error_code: "non_interactive"
386169
+ error_code: "validation"
385708
386170
  }
385709
386171
  });
385710
- process.stderr.write(
385711
- "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"
385712
- );
386172
+ process.stderr.write(`Error: ${projectResolution.message}
386173
+ `);
385713
386174
  await exitWithFlush(1);
385714
386175
  return;
385715
386176
  }
@@ -385741,12 +386202,74 @@ async function runInitCommand(invokedAs, argv) {
385741
386202
  await exitWithFlush(1);
385742
386203
  return;
385743
386204
  }
386205
+ const {
386206
+ formatNonInteractiveInitRefusal: formatNonInteractiveInitRefusal2,
386207
+ missingNonInteractiveInitFlags: missingNonInteractiveInitFlags2,
386208
+ resolveInitInstallFlag: resolveInitInstallFlag2,
386209
+ NON_INTERACTIVE_LOGIN_MESSAGE: NON_INTERACTIVE_LOGIN_MESSAGE2
386210
+ } = await Promise.resolve().then(() => (init_init_non_interactive(), init_non_interactive_exports));
386211
+ const installResolution = resolveInitInstallFlag2({
386212
+ yes: parsed.values["yes"],
386213
+ install: parsed.values["install"],
386214
+ noInstall: parsed.values["no-install"]
386215
+ });
386216
+ if (installResolution.status === "invalid") {
386217
+ recordTelemetryEvent({
386218
+ properties: {
386219
+ ...telemetryBase,
386220
+ outcome: "failed",
386221
+ error_code: "validation"
386222
+ }
386223
+ });
386224
+ process.stderr.write(`Error: ${installResolution.message}
386225
+ `);
386226
+ await exitWithFlush(1);
386227
+ return;
386228
+ }
386229
+ if (!process.stdin.isTTY) {
386230
+ const missing = missingNonInteractiveInitFlags2({
386231
+ name: parsed.values["name"],
386232
+ framework: frameworkFlag,
386233
+ hostedProjectNamed: projectResolution.request !== null,
386234
+ installAnswered: installResolution.install !== null
386235
+ });
386236
+ if (missing.length > 0) {
386237
+ recordTelemetryEvent({
386238
+ properties: {
386239
+ ...telemetryBase,
386240
+ outcome: "failed",
386241
+ error_code: "non_interactive"
386242
+ }
386243
+ });
386244
+ process.stderr.write(
386245
+ `Error: ${formatNonInteractiveInitRefusal2(missing)}`
386246
+ );
386247
+ await exitWithFlush(1);
386248
+ return;
386249
+ }
386250
+ const { authStore: authStore2 } = await Promise.resolve().then(() => (init_config_service(), config_service_exports));
386251
+ if (authStore2.get() === null) {
386252
+ recordTelemetryEvent({
386253
+ properties: {
386254
+ ...telemetryBase,
386255
+ outcome: "failed",
386256
+ error_code: "non_interactive"
386257
+ }
386258
+ });
386259
+ process.stderr.write(`Error: ${NON_INTERACTIVE_LOGIN_MESSAGE2}
386260
+ `);
386261
+ await exitWithFlush(1);
386262
+ return;
386263
+ }
386264
+ }
385744
386265
  const flags = {
385745
386266
  name: parsed.values["name"],
385746
386267
  intelligence,
385747
386268
  framework,
385748
386269
  mock,
385749
386270
  channel: channelResolution.channel,
386271
+ hostedProject: projectResolution.request,
386272
+ installDependencies: installResolution.install,
385750
386273
  noBanner: parsed.values["no-banner"]
385751
386274
  };
385752
386275
  await withTelemetry(telemetryBase, async (ctx) => {