copilotkit 4.16.0 → 4.17.0

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 (81) hide show
  1. package/README.md +69 -4
  2. package/cli-build-info.json +7 -7
  3. package/index.js +3993 -2742
  4. package/onboarding/index.json +1 -1
  5. package/onboarding/prompts/authenticate/start.md +17 -15
  6. package/onboarding/prompts/conversion/plan.md +3 -3
  7. package/onboarding/prompts/credentials/finalize-plan.md +20 -20
  8. package/onboarding/prompts/credentials/plan.md +21 -21
  9. package/onboarding/prompts/credentials/settle-credentials.md +46 -10
  10. package/onboarding/prompts/credentials/write-plan.md +35 -20
  11. package/onboarding/prompts/fallback/best-effort.md +23 -15
  12. package/onboarding/prompts/feature/a2ui/implement.md +40 -12
  13. package/onboarding/prompts/feature/a2ui/proof.md +29 -9
  14. package/onboarding/prompts/feature/a2ui/start.md +8 -10
  15. package/onboarding/prompts/feature/blocked-by-plan.md +4 -4
  16. package/onboarding/prompts/feature/channels/implement.md +41 -13
  17. package/onboarding/prompts/feature/channels/proof.md +30 -11
  18. package/onboarding/prompts/feature/channels/start.md +11 -9
  19. package/onboarding/prompts/feature/chat-suggestions/implement.md +40 -12
  20. package/onboarding/prompts/feature/chat-suggestions/proof.md +29 -9
  21. package/onboarding/prompts/feature/chat-suggestions/start.md +8 -10
  22. package/onboarding/prompts/feature/complete.md +2 -2
  23. package/onboarding/prompts/feature/learning/implement.md +58 -26
  24. package/onboarding/prompts/feature/learning/proof.md +30 -10
  25. package/onboarding/prompts/feature/learning/start.md +15 -12
  26. package/onboarding/prompts/feature/open-generative-ui/implement.md +41 -13
  27. package/onboarding/prompts/feature/open-generative-ui/proof.md +29 -9
  28. package/onboarding/prompts/feature/open-generative-ui/start.md +8 -10
  29. package/onboarding/prompts/feature/realtime-sync/implement.md +41 -13
  30. package/onboarding/prompts/feature/realtime-sync/proof.md +31 -10
  31. package/onboarding/prompts/feature/realtime-sync/start.md +8 -9
  32. package/onboarding/prompts/feature/rich-threads/implement.md +42 -14
  33. package/onboarding/prompts/feature/rich-threads/proof.md +31 -10
  34. package/onboarding/prompts/feature/rich-threads/start.md +8 -9
  35. package/onboarding/prompts/feature/stop.md +3 -3
  36. package/onboarding/prompts/feature/voice/implement.md +40 -12
  37. package/onboarding/prompts/feature/voice/proof.md +29 -9
  38. package/onboarding/prompts/feature/voice/start.md +8 -9
  39. package/onboarding/prompts/framework/ag2.md +2 -2
  40. package/onboarding/prompts/framework/agno.md +4 -4
  41. package/onboarding/prompts/framework/built-in.md +2 -2
  42. package/onboarding/prompts/framework/claude-sdk-python.md +8 -7
  43. package/onboarding/prompts/framework/claude-sdk-typescript.md +2 -2
  44. package/onboarding/prompts/framework/crewai-flows.md +15 -7
  45. package/onboarding/prompts/framework/deep-agents.md +4 -3
  46. package/onboarding/prompts/framework/google-adk.md +7 -7
  47. package/onboarding/prompts/framework/langgraph-fastapi.md +2 -2
  48. package/onboarding/prompts/framework/langgraph-python.md +2 -2
  49. package/onboarding/prompts/framework/langgraph-typescript.md +2 -2
  50. package/onboarding/prompts/framework/llamaindex.md +4 -4
  51. package/onboarding/prompts/framework/mastra.md +2 -2
  52. package/onboarding/prompts/framework/ms-agent-dotnet.md +2 -2
  53. package/onboarding/prompts/framework/ms-agent-harness-dotnet.md +2 -2
  54. package/onboarding/prompts/framework/ms-agent-python.md +6 -6
  55. package/onboarding/prompts/framework/pydantic-ai.md +2 -2
  56. package/onboarding/prompts/framework/strands-python.md +4 -4
  57. package/onboarding/prompts/framework/strands-typescript.md +4 -4
  58. package/onboarding/prompts/frontend/angular.md +3 -3
  59. package/onboarding/prompts/frontend/nextjs.md +16 -3
  60. package/onboarding/prompts/frontend/plan.md +7 -7
  61. package/onboarding/prompts/frontend/react-native.md +2 -2
  62. package/onboarding/prompts/frontend/react-spa.md +2 -2
  63. package/onboarding/prompts/frontend/vue.md +2 -2
  64. package/onboarding/prompts/implementation/build-and-validate.md +67 -28
  65. package/onboarding/prompts/proof/complete.md +21 -14
  66. package/onboarding/prompts/proof/oss-baseline.md +16 -12
  67. package/onboarding/prompts/proof/round-trip.md +33 -22
  68. package/onboarding/prompts/research/gather.md +8 -7
  69. package/onboarding/prompts/research/merge.md +3 -3
  70. package/onboarding/prompts/research/preflight.md +4 -4
  71. package/onboarding/prompts/research/route.md +6 -6
  72. package/onboarding/prompts/starter/clone.md +14 -11
  73. package/onboarding/prompts/stopped/run-failed.md +9 -9
  74. package/onboarding/prompts/subagent/create-plan.md +15 -10
  75. package/onboarding/prompts/subagent/implement-and-validate.md +25 -11
  76. package/onboarding/prompts/subagent/inspect-repository.md +14 -6
  77. package/onboarding/prompts/subagent/prove-oss-baseline.md +5 -4
  78. package/onboarding/prompts/subagent/prove-round-trip.md +38 -14
  79. package/onboarding/prompts/unsupported/no-validated-path.md +2 -2
  80. package/package.json +1 -5
  81. package/release/release-tool.js +171 -40
@@ -14811,7 +14811,7 @@ var FLAG_DEFINITIONS = defineFlags({
14811
14811
 
14812
14812
  // apps/cli/src/config.ts
14813
14813
  function getTemplateRef() {
14814
- return true ? "a933af0b132e61d2d04be7ce0a8f55743af21ccc" : "main";
14814
+ return true ? "0c8647a7f4ecf565e58405642539c9d9744f62c5" : "main";
14815
14815
  }
14816
14816
 
14817
14817
  // apps/cli/src/services/agentcore-config.ts
@@ -14980,6 +14980,13 @@ async function writeShowcaseConfig(projectDir, showcase) {
14980
14980
  // apps/cli/src/services/telemetry/event-properties.ts
14981
14981
  var TELEMETRY_ERROR_CODES = {
14982
14982
  TEMPLATE_FETCH_FAILED: "TEMPLATE_FETCH_FAILED",
14983
+ /**
14984
+ * Copying the fetched starter into the project folder failed. Separate from
14985
+ * {@link TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED}: a Windows antivirus
14986
+ * lock (`EBUSY`) used to be filed as a failed download (PE-358). Buckets as
14987
+ * `filesystem`, or `sandbox_denied` when a sandbox refused the write.
14988
+ */
14989
+ TEMPLATE_COPY_FAILED: "TEMPLATE_COPY_FAILED",
14983
14990
  GIT_FAILED: "GIT_FAILED",
14984
14991
  PREREQUISITE_MISSING: "PREREQUISITE_MISSING",
14985
14992
  INVALID_FRAMEWORK: "INVALID_FRAMEWORK",
@@ -15026,6 +15033,11 @@ function tagError(err, code) {
15026
15033
  err.code = code;
15027
15034
  return err;
15028
15035
  }
15036
+ function annotateFailure(err, cause) {
15037
+ const annotated = err;
15038
+ annotated.failureCause = { ...cause, ...annotated.failureCause };
15039
+ return err;
15040
+ }
15029
15041
 
15030
15042
  // apps/cli/src/types.ts
15031
15043
  var AGENT_FRAMEWORKS = Object.keys(
@@ -15383,7 +15395,7 @@ var FRAMEWORK_TEMPLATES = {
15383
15395
  import * as fs4 from "node:fs";
15384
15396
  import * as path4 from "node:path";
15385
15397
  import * as os from "node:os";
15386
- import { execFileSync } from "node:child_process";
15398
+ import { execFileSync, spawn } from "node:child_process";
15387
15399
 
15388
15400
  // apps/cli/src/services/project-config.ts
15389
15401
  import * as fs3 from "node:fs";
@@ -15434,6 +15446,11 @@ function canonicalizeDir(dir) {
15434
15446
  }
15435
15447
 
15436
15448
  // apps/cli/src/services/project-scaffold.ts
15449
+ var DEFAULT_GIT_STALL_TIMEOUT_MS = 6e4;
15450
+ var NON_INTERACTIVE_GIT_ENV = {
15451
+ GIT_TERMINAL_PROMPT: "0",
15452
+ GCM_INTERACTIVE: "never"
15453
+ };
15437
15454
  var PROJECT_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
15438
15455
  "agent",
15439
15456
  "api",
@@ -15451,12 +15468,17 @@ var PROJECT_MANIFEST_NAMES = /* @__PURE__ */ new Set([
15451
15468
  "Gemfile",
15452
15469
  "build.gradle",
15453
15470
  "composer.json",
15471
+ "global.json",
15454
15472
  "go.mod",
15455
15473
  "package.json",
15456
15474
  "pom.xml",
15457
15475
  "pyproject.toml",
15458
15476
  "requirements.txt"
15459
15477
  ]);
15478
+ var PROJECT_MANIFEST_EXTENSIONS = [".csproj", ".sln"];
15479
+ function isProjectManifest(entry) {
15480
+ return PROJECT_MANIFEST_NAMES.has(entry) || PROJECT_MANIFEST_EXTENSIONS.some((extension) => entry.endsWith(extension));
15481
+ }
15460
15482
  var ENV_TEMPLATE_SUFFIXES = [".example", ".sample", ".template"];
15461
15483
  function isCredentialEnvFile(entry) {
15462
15484
  if (!entry.startsWith(".env"))
@@ -15468,7 +15490,7 @@ function isCredentialEnvFile(entry) {
15468
15490
  function entryHoldsProject(entry) {
15469
15491
  if (isCredentialEnvFile(entry))
15470
15492
  return true;
15471
- return PROJECT_DIRECTORY_NAMES.has(entry) || PROJECT_MANIFEST_NAMES.has(entry);
15493
+ return PROJECT_DIRECTORY_NAMES.has(entry) || isProjectManifest(entry);
15472
15494
  }
15473
15495
  var SYSTEM_FOLDERS = [
15474
15496
  "/Applications",
@@ -15565,7 +15587,7 @@ function walkProjectsBelow(dir, top, limits) {
15565
15587
  if (exhausted)
15566
15588
  return;
15567
15589
  const names = childEntries.map((e) => e.name);
15568
- if (names.some((n) => n === ".git" || PROJECT_MANIFEST_NAMES.has(n))) {
15590
+ if (names.some((n) => n === ".git" || isProjectManifest(n))) {
15569
15591
  found.push(child);
15570
15592
  } else if (depth < PROJECTS_BELOW_DEPTH) {
15571
15593
  visit(child, childEntries, depth + 1);
@@ -15622,6 +15644,7 @@ function occupiedMessage(projectDir, contents) {
15622
15644
  }
15623
15645
  async function scaffoldProject(options) {
15624
15646
  const { projectDir, template } = options;
15647
+ const stallTimeoutMs = options.gitStallTimeoutMs ?? DEFAULT_GIT_STALL_TIMEOUT_MS;
15625
15648
  assertProjectDirAvailable(projectDir);
15626
15649
  const localTemplateDir = process.env["COPILOTKIT_TEMPLATE_DIR"];
15627
15650
  if (localTemplateDir !== void 0 && localTemplateDir !== "") {
@@ -15633,8 +15656,16 @@ async function scaffoldProject(options) {
15633
15656
  TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED
15634
15657
  );
15635
15658
  }
15636
- fs4.mkdirSync(projectDir, { recursive: true });
15637
- await copyDirectory(localTemplateDir, projectDir, true);
15659
+ try {
15660
+ fs4.mkdirSync(projectDir, { recursive: true });
15661
+ await copyDirectory(localTemplateDir, projectDir, true);
15662
+ } catch (cause) {
15663
+ throw wrapStepError(
15664
+ cause,
15665
+ TELEMETRY_ERROR_CODES.TEMPLATE_COPY_FAILED,
15666
+ "copy"
15667
+ );
15668
+ }
15638
15669
  return;
15639
15670
  }
15640
15671
  const source = typeof template === "string" ? parseGitHubUrl(template) : {
@@ -15644,7 +15675,7 @@ async function scaffoldProject(options) {
15644
15675
  subdirectoryPath: template.path,
15645
15676
  mode: template.mode
15646
15677
  };
15647
- await cloneTemplate(source, projectDir);
15678
+ await cloneTemplate(source, projectDir, stallTimeoutMs);
15648
15679
  }
15649
15680
  function pathEntryExists(entryPath) {
15650
15681
  try {
@@ -15657,61 +15688,85 @@ function pathEntryExists(entryPath) {
15657
15688
  throw error48;
15658
15689
  }
15659
15690
  }
15660
- async function cloneTemplate(source, destinationPath) {
15691
+ async function cloneTemplate(source, destinationPath, stallTimeoutMs) {
15661
15692
  const { owner, repo, revision, subdirectoryPath, mode } = source;
15662
15693
  const tempDir = fs4.mkdtempSync(path4.join(os.tmpdir(), "copilotkit-clone-"));
15663
15694
  const isWholeRepo = mode === "whole-repository";
15664
15695
  const destinationExisted = pathEntryExists(destinationPath);
15665
15696
  try {
15666
- runGit(
15697
+ await runGit(
15667
15698
  ["init"],
15668
- { cwd: tempDir, stdio: "pipe" },
15669
- TELEMETRY_ERROR_CODES.GIT_FAILED
15699
+ { cwd: tempDir, stallTimeoutMs },
15700
+ TELEMETRY_ERROR_CODES.GIT_FAILED,
15701
+ "git_init"
15670
15702
  );
15671
- runGit(
15703
+ await runGit(
15672
15704
  ["remote", "add", "origin", `https://github.com/${owner}/${repo}.git`],
15673
- { cwd: tempDir, stdio: "pipe" },
15674
- TELEMETRY_ERROR_CODES.GIT_FAILED
15705
+ { cwd: tempDir, stallTimeoutMs },
15706
+ TELEMETRY_ERROR_CODES.GIT_FAILED,
15707
+ "remote_add"
15675
15708
  );
15676
15709
  if (!isWholeRepo) {
15677
- runGit(
15710
+ await runGit(
15678
15711
  ["config", "core.sparseCheckout", "true"],
15679
- { cwd: tempDir, stdio: "pipe" },
15680
- TELEMETRY_ERROR_CODES.GIT_FAILED
15681
- );
15682
- fs4.writeFileSync(
15683
- path4.join(tempDir, ".git/info/sparse-checkout"),
15684
- subdirectoryPath
15712
+ { cwd: tempDir, stallTimeoutMs },
15713
+ TELEMETRY_ERROR_CODES.GIT_FAILED,
15714
+ "sparse_config"
15685
15715
  );
15716
+ try {
15717
+ fs4.writeFileSync(
15718
+ path4.join(tempDir, ".git/info/sparse-checkout"),
15719
+ subdirectoryPath
15720
+ );
15721
+ } catch (cause) {
15722
+ throw wrapStepError(
15723
+ cause,
15724
+ TELEMETRY_ERROR_CODES.GIT_FAILED,
15725
+ "sparse_config"
15726
+ );
15727
+ }
15686
15728
  }
15687
- runGit(
15688
- ["fetch", "--depth=1", "origin", revision],
15689
- { cwd: tempDir, stdio: "pipe" },
15690
- TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED
15729
+ await runGit(
15730
+ ["fetch", "--progress", "--depth=1", "origin", revision],
15731
+ { cwd: tempDir, stallTimeoutMs },
15732
+ TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED,
15733
+ "fetch"
15691
15734
  );
15692
- runGit(
15693
- ["checkout", "--detach", "FETCH_HEAD"],
15694
- { cwd: tempDir, stdio: "pipe" },
15695
- TELEMETRY_ERROR_CODES.GIT_FAILED
15735
+ await runGit(
15736
+ ["checkout", "--progress", "--detach", "FETCH_HEAD"],
15737
+ { cwd: tempDir, stallTimeoutMs },
15738
+ TELEMETRY_ERROR_CODES.GIT_FAILED,
15739
+ "checkout"
15696
15740
  );
15697
15741
  const sourcePath = isWholeRepo ? tempDir : path4.join(tempDir, subdirectoryPath);
15698
15742
  if (!isWholeRepo && !fs4.existsSync(sourcePath)) {
15699
- throw tagError(
15700
- new Error(
15701
- `Template directory '${subdirectoryPath}' not found in the repository.`
15743
+ throw annotateFailure(
15744
+ tagError(
15745
+ new Error(
15746
+ `Template directory '${subdirectoryPath}' not found in the repository.`
15747
+ ),
15748
+ TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED
15702
15749
  ),
15703
- TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED
15750
+ { failedStep: "subdirectory_missing" }
15751
+ );
15752
+ }
15753
+ try {
15754
+ fs4.mkdirSync(destinationPath, { recursive: true });
15755
+ await copyDirectory(sourcePath, destinationPath, isWholeRepo);
15756
+ } catch (cause) {
15757
+ throw wrapStepError(
15758
+ cause,
15759
+ TELEMETRY_ERROR_CODES.TEMPLATE_COPY_FAILED,
15760
+ "copy"
15704
15761
  );
15705
15762
  }
15706
- fs4.mkdirSync(destinationPath, { recursive: true });
15707
- await copyDirectory(sourcePath, destinationPath, isWholeRepo);
15708
15763
  } catch (cause) {
15709
15764
  if (!destinationExisted) {
15710
15765
  fs4.rmSync(destinationPath, { recursive: true, force: true });
15711
15766
  }
15712
15767
  const error48 = cause instanceof Error ? cause : new Error("Starter template checkout failed");
15713
15768
  const code = error48.code;
15714
- if (code === TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED || code === TELEMETRY_ERROR_CODES.GIT_FAILED) {
15769
+ if (code === TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED || code === TELEMETRY_ERROR_CODES.TEMPLATE_COPY_FAILED || code === TELEMETRY_ERROR_CODES.GIT_FAILED) {
15715
15770
  throw error48;
15716
15771
  }
15717
15772
  throw tagError(error48, TELEMETRY_ERROR_CODES.TEMPLATE_FETCH_FAILED);
@@ -15740,12 +15795,88 @@ async function copyDirectory(source, destination, excludeGit = false) {
15740
15795
  }
15741
15796
  }
15742
15797
  }
15743
- function runGit(args, opts, code) {
15798
+ function wrapStepError(cause, code, failedStep) {
15799
+ const message = cause instanceof Error ? cause.message : `Starter step failed: ${failedStep}`;
15800
+ const status = cause?.status;
15801
+ return annotateFailure(tagError(new Error(message, { cause }), code), {
15802
+ failedStep,
15803
+ ...typeof status === "number" ? { gitExitCode: status } : {}
15804
+ });
15805
+ }
15806
+ var GIT_STDERR_TAIL_LINES = 20;
15807
+ var GIT_PROGRESS_LINE = /^(remote: )?(Counting|Compressing|Receiving|Resolving|Enumerating|Updating files|Total)\b/;
15808
+ function gitStderrTail(stderr) {
15809
+ return stderr.split(/\r|\n/).map((line) => line.trimEnd()).filter((line) => line !== "" && !GIT_PROGRESS_LINE.test(line)).slice(-GIT_STDERR_TAIL_LINES).join("\n");
15810
+ }
15811
+ var GIT_STDERR_MAX_CHARS = 64 * 1024;
15812
+ function stallError(command, failedStep, options) {
15813
+ const seconds = Math.round(options.stallTimeoutMs / 1e3);
15814
+ const advice = failedStep === "fetch" ? " Check your network connection to github.com. If you are behind a proxy, set HTTPS_PROXY to its address and run the command again." : "";
15815
+ return Object.assign(
15816
+ new Error(
15817
+ `\`${command}\` stopped: git printed nothing for ${seconds} seconds.${advice}`
15818
+ ),
15819
+ { code: "ETIMEDOUT" }
15820
+ );
15821
+ }
15822
+ async function runGit(args, options, code, failedStep) {
15823
+ const command = `git ${args.join(" ")}`;
15744
15824
  try {
15745
- execFileSync("git", args, opts);
15825
+ await new Promise((resolve5, reject) => {
15826
+ const child = spawn("git", args, {
15827
+ cwd: options.cwd,
15828
+ env: { ...process.env, ...NON_INTERACTIVE_GIT_ENV },
15829
+ stdio: ["ignore", "ignore", "pipe"],
15830
+ windowsHide: true
15831
+ });
15832
+ let stderr = "";
15833
+ let settled = false;
15834
+ let watchdog;
15835
+ const settle = (finish) => {
15836
+ if (settled)
15837
+ return;
15838
+ settled = true;
15839
+ clearTimeout(watchdog);
15840
+ finish();
15841
+ };
15842
+ const armWatchdog = () => {
15843
+ clearTimeout(watchdog);
15844
+ watchdog = setTimeout(() => {
15845
+ child.kill();
15846
+ child.stderr.destroy();
15847
+ child.unref();
15848
+ settle(() => reject(stallError(command, failedStep, options)));
15849
+ }, options.stallTimeoutMs);
15850
+ };
15851
+ armWatchdog();
15852
+ child.stderr.setEncoding("utf8");
15853
+ child.stderr.on("data", (chunk) => {
15854
+ stderr = (stderr + chunk).slice(-GIT_STDERR_MAX_CHARS);
15855
+ armWatchdog();
15856
+ });
15857
+ child.on("error", (error48) => settle(() => reject(error48)));
15858
+ child.on(
15859
+ "close",
15860
+ (status) => settle(() => {
15861
+ if (status === 0) {
15862
+ resolve5();
15863
+ return;
15864
+ }
15865
+ const tail = gitStderrTail(stderr);
15866
+ reject(
15867
+ Object.assign(
15868
+ new Error(
15869
+ `Command failed: ${command}${tail ? `
15870
+ ${tail}` : ""}`
15871
+ ),
15872
+ { status }
15873
+ )
15874
+ );
15875
+ })
15876
+ );
15877
+ });
15746
15878
  } catch (cause) {
15747
- const wrapped = cause instanceof Error ? cause : new Error(`git command failed: git ${args.join(" ")}`);
15748
- throw tagError(wrapped, code);
15879
+ throw wrapStepError(cause, code, failedStep);
15749
15880
  }
15750
15881
  }
15751
15882
  function parseGitHubUrl(githubUrl) {