@glasstrace/sdk 1.9.1 → 1.10.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 (68) hide show
  1. package/dist/async-context/index.cjs +44 -0
  2. package/dist/async-context/index.cjs.map +1 -1
  3. package/dist/async-context/index.js +2 -2
  4. package/dist/{chunk-JHUNLPSS.js → chunk-6RKS3DNA.js} +45 -1
  5. package/dist/{chunk-JHUNLPSS.js.map → chunk-6RKS3DNA.js.map} +1 -1
  6. package/dist/{chunk-HD6JIFKN.js → chunk-BSVWJSVX.js} +2 -2
  7. package/dist/{chunk-QOHKZOKB.js → chunk-D54FMQHF.js} +2 -2
  8. package/dist/chunk-I2DVVSKW.js +419 -0
  9. package/dist/chunk-I2DVVSKW.js.map +1 -0
  10. package/dist/{chunk-H6WJ63X2.js → chunk-M5GO2SSO.js} +2 -2
  11. package/dist/{chunk-QEXRCXSY.js → chunk-OXM2BZMF.js} +2 -2
  12. package/dist/{chunk-M6EWJCAT.js → chunk-QVTONMVZ.js} +2 -2
  13. package/dist/{chunk-DKV53A2C.js → chunk-RL43PU2X.js} +2 -2
  14. package/dist/{chunk-KI7YJ7XD.js → chunk-TJ46YOGJ.js} +42 -22
  15. package/dist/chunk-TJ46YOGJ.js.map +1 -0
  16. package/dist/{chunk-GWIEUBFR.js → chunk-UMGZJYC4.js} +3 -3
  17. package/dist/{chunk-2F2MGFLO.js → chunk-WQF7ZQOM.js} +39 -405
  18. package/dist/chunk-WQF7ZQOM.js.map +1 -0
  19. package/dist/{chunk-QXITSNYM.js → chunk-XG6WR2KS.js} +3 -3
  20. package/dist/cli/init.cjs +51 -25
  21. package/dist/cli/init.cjs.map +1 -1
  22. package/dist/cli/init.js +8 -8
  23. package/dist/cli/init.js.map +1 -1
  24. package/dist/cli/mcp-add.cjs +42 -22
  25. package/dist/cli/mcp-add.cjs.map +1 -1
  26. package/dist/cli/mcp-add.js +4 -4
  27. package/dist/cli/mcp-add.js.map +1 -1
  28. package/dist/cli/uninit.js +3 -3
  29. package/dist/cli/upgrade-instructions.cjs +39 -21
  30. package/dist/cli/upgrade-instructions.cjs.map +1 -1
  31. package/dist/cli/upgrade-instructions.js +4 -4
  32. package/dist/cli/upgrade-instructions.js.map +1 -1
  33. package/dist/cli/validate.cjs.map +1 -1
  34. package/dist/cli/validate.js +2 -2
  35. package/dist/edge-entry.cjs +44 -0
  36. package/dist/edge-entry.cjs.map +1 -1
  37. package/dist/edge-entry.js +4 -4
  38. package/dist/index.cjs +58 -5
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.js +10 -8
  41. package/dist/index.js.map +1 -1
  42. package/dist/middleware/index.cjs +44 -0
  43. package/dist/middleware/index.cjs.map +1 -1
  44. package/dist/middleware/index.js +2 -2
  45. package/dist/node-entry.cjs +58 -5
  46. package/dist/node-entry.cjs.map +1 -1
  47. package/dist/node-entry.js +12 -10
  48. package/dist/node-subpath.cjs.map +1 -1
  49. package/dist/node-subpath.js +3 -3
  50. package/dist/{source-map-uploader-MMJ2WCL4.js → source-map-uploader-CLYCE2TZ.js} +3 -3
  51. package/dist/trpc/index.cjs +15164 -503
  52. package/dist/trpc/index.cjs.map +1 -1
  53. package/dist/trpc/index.d.cts +62 -1
  54. package/dist/trpc/index.d.ts +62 -1
  55. package/dist/trpc/index.js +200 -1
  56. package/dist/trpc/index.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-2F2MGFLO.js.map +0 -1
  59. package/dist/chunk-KI7YJ7XD.js.map +0 -1
  60. /package/dist/{chunk-HD6JIFKN.js.map → chunk-BSVWJSVX.js.map} +0 -0
  61. /package/dist/{chunk-QOHKZOKB.js.map → chunk-D54FMQHF.js.map} +0 -0
  62. /package/dist/{chunk-H6WJ63X2.js.map → chunk-M5GO2SSO.js.map} +0 -0
  63. /package/dist/{chunk-QEXRCXSY.js.map → chunk-OXM2BZMF.js.map} +0 -0
  64. /package/dist/{chunk-M6EWJCAT.js.map → chunk-QVTONMVZ.js.map} +0 -0
  65. /package/dist/{chunk-DKV53A2C.js.map → chunk-RL43PU2X.js.map} +0 -0
  66. /package/dist/{chunk-GWIEUBFR.js.map → chunk-UMGZJYC4.js.map} +0 -0
  67. /package/dist/{chunk-QXITSNYM.js.map → chunk-XG6WR2KS.js.map} +0 -0
  68. /package/dist/{source-map-uploader-MMJ2WCL4.js.map → source-map-uploader-CLYCE2TZ.js.map} +0 -0
@@ -14413,6 +14413,43 @@ async function detectAgents(projectRoot) {
14413
14413
  return detected;
14414
14414
  }
14415
14415
 
14416
+ // src/agent-detection/agent-instruction-text.ts
14417
+ function buildAgentInstructionBody() {
14418
+ return [
14419
+ "",
14420
+ "## Glasstrace MCP \u2014 Runtime Debugging Evidence",
14421
+ "",
14422
+ "Glasstrace is connected via MCP (`glasstrace`). It captures runtime traces from this app and exposes them through tools that disambiguate bugs source alone cannot resolve.",
14423
+ "",
14424
+ "### Call Glasstrace FIRST when:",
14425
+ "- A value passed at runtime is suspect: wrong role, locale, timezone, template, tenant id, or any enum/config that branches downstream.",
14426
+ "- The bug is in a side-effect operation: email sent, calendar event created, webhook dispatched, queued job, `after()` callback.",
14427
+ "- The user reports a symptom but you do not yet know which code path actually executed.",
14428
+ "- You need to confirm a route or procedure ran in the relevant time window before doing a source dive.",
14429
+ "",
14430
+ "### SKIP Glasstrace when:",
14431
+ "- The bug is statically obvious from source (N+1 query, missing await, redundant query, type error, missing null check).",
14432
+ "- The change is a refactor whose correctness does not depend on runtime behavior.",
14433
+ "- You already have a precise traceId from another source.",
14434
+ "",
14435
+ "### Workflow",
14436
+ "1. Start with `find_trace_candidates`. Pass whatever route or procedure name is natural \u2014 the server normalizes vocabulary and, on miss, returns close matches and a sample of routes actually present in the window.",
14437
+ "2. Take the highest-confidence candidate's `suggestedFollowups` and pass them straight to `get_trace` or `get_root_cause`.",
14438
+ "3. For side-effect bugs, read `sideEffectSummary` in the `get_trace` / `get_root_cause` response. The allowlisted fields (`templateKey`, `providerOperation`, `role`, `locale`, `timezone`, `status`, `phase`) are the ones that disambiguate payload bugs.",
14439
+ "4. If a tool returns empty, READ the response's `closeMatches`, `recentRoutesSample`, and `recoveryActions` before pivoting to source. Empty results carry `notAbsenceProof: true` \u2014 they are never proof the bug did not occur.",
14440
+ "",
14441
+ "### Tools",
14442
+ "- `find_trace_candidates` \u2014 discovery, vocabulary-tolerant filter",
14443
+ "- `get_trace` \u2014 exact trace by `traceId`",
14444
+ "- `get_root_cause` \u2014 root-cause analysis for a `traceId`",
14445
+ "- `get_session_timeline` \u2014 events for a session",
14446
+ "- `get_latest_error` / `get_error_list` \u2014 recent server errors",
14447
+ "",
14448
+ "Side-effect evidence is allowlisted and compact by design. Fields you don't see may have been omitted by policy, not absent at runtime.",
14449
+ ""
14450
+ ].join("\n");
14451
+ }
14452
+
14416
14453
  // src/agent-detection/configs.ts
14417
14454
  function generateMcpConfig(agent, endpoint, bearer) {
14418
14455
  if (!endpoint || endpoint.trim() === "") {
@@ -14467,6 +14504,7 @@ function generateMcpConfig(agent, endpoint, bearer) {
14467
14504
  {
14468
14505
  mcpServers: {
14469
14506
  glasstrace: {
14507
+ type: "http",
14470
14508
  url: endpoint,
14471
14509
  headers: {
14472
14510
  Authorization: `Bearer ${bearer}`
@@ -14482,7 +14520,8 @@ function generateMcpConfig(agent, endpoint, bearer) {
14482
14520
  {
14483
14521
  mcpServers: {
14484
14522
  glasstrace: {
14485
- serverUrl: endpoint,
14523
+ type: "http",
14524
+ url: endpoint,
14486
14525
  headers: {
14487
14526
  Authorization: `Bearer ${bearer}`
14488
14527
  }
@@ -14539,26 +14578,7 @@ function generateInfoSection(agent, endpoint, sdkVersion) {
14539
14578
  "sdkVersion must match [A-Za-z0-9.+\\-]+ (semver-shaped, no whitespace, no angle brackets)"
14540
14579
  );
14541
14580
  }
14542
- const content = [
14543
- "",
14544
- "## Glasstrace MCP Integration",
14545
- "",
14546
- `Glasstrace is configured as an MCP server at: ${endpoint}`,
14547
- "",
14548
- "Glasstrace MCP is available when runtime evidence would materially reduce uncertainty. Use it when there is a failing request, stack trace, unclear runtime behavior, race/data-flow symptom, side effect, or performance issue that source inspection alone does not explain. For a current error, `get_latest_error` or `get_error_list` is usually the cheapest orientation call. For a known route/procedure with no exact error, use `find_trace_candidates` and follow returned exact `get_trace` or `get_root_cause` arguments only if the candidates look relevant. Do not call trace tools for trivial source-local fixes. Treat **no candidates** or **no_traces_found** as a scoped retrieval result, not proof the bug is absent.",
14549
- "",
14550
- "Available tools:",
14551
- "- `get_latest_error` - Get the most recent error trace from the current session",
14552
- "- `find_trace_candidates` - First-contact route/procedure/URL candidate selection when you have a route fragment, tRPC procedure, method, status, or rough recent activity window but not the exact trace ID. Returns candidate traces plus suggested `get_trace` / `get_root_cause` follow-up call arguments. Candidate discovery, not root-cause proof.",
14553
- "- `get_error_list` - List recent errors with filtering and pagination",
14554
- "- `get_trace` - Get a specific trace by ID or URL pattern",
14555
- "- `get_root_cause` - Get the root cause analysis for a specific error trace (requires a `traceId` from `get_latest_error`, `get_error_list`, or `get_trace`)",
14556
- "- `get_test_suggestions` - Get test suggestions for a specific error trace (requires a `traceId` from `get_latest_error`, `get_error_list`, or `get_trace`)",
14557
- "- `get_session_timeline` - Get the timeline of all traces in the current session",
14558
- "",
14559
- "To refresh this managed section after a `@glasstrace/sdk` upgrade, run: `npx glasstrace upgrade-instructions`. To reconfigure MCP credentials, run: `npx glasstrace mcp add`.",
14560
- ""
14561
- ].join("\n");
14581
+ const content = buildAgentInstructionBody();
14562
14582
  switch (agent.name) {
14563
14583
  case "claude": {
14564
14584
  const m = htmlMarkers(sdkVersion);
@@ -14929,7 +14949,7 @@ async function mcpAdd(options) {
14929
14949
  const bearer = resolved.effective.key;
14930
14950
  for (const agent of targetAgents) {
14931
14951
  const name = formatAgentName(agent.name);
14932
- const sdkVersion = true ? "1.9.1" : "0.0.0-dev";
14952
+ const sdkVersion = true ? "1.10.1" : "0.0.0-dev";
14933
14953
  if (agent.name !== "generic") {
14934
14954
  const cliSuccess = await registerViaCli(agent, bearer);
14935
14955
  if (cliSuccess) {