@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
@@ -2,12 +2,12 @@ import {
2
2
  atomicWriteFile,
3
3
  refreshGenericMcpConfigAtRuntime,
4
4
  resolveEffectiveMcpCredential
5
- } from "./chunk-DKV53A2C.js";
5
+ } from "./chunk-RL43PU2X.js";
6
6
  import {
7
7
  DEFAULT_CAPTURE_CONFIG,
8
8
  SdkCachedConfigSchema,
9
9
  SdkInitResponseSchema
10
- } from "./chunk-JHUNLPSS.js";
10
+ } from "./chunk-6RKS3DNA.js";
11
11
  import {
12
12
  __require
13
13
  } from "./chunk-NSBPE2FW.js";
@@ -692,4 +692,4 @@ export {
692
692
  didLastInitSucceed,
693
693
  verifyInitReachable
694
694
  };
695
- //# sourceMappingURL=chunk-QXITSNYM.js.map
695
+ //# sourceMappingURL=chunk-XG6WR2KS.js.map
package/dist/cli/init.cjs CHANGED
@@ -15302,6 +15302,48 @@ var init_detect = __esm({
15302
15302
  }
15303
15303
  });
15304
15304
 
15305
+ // src/agent-detection/agent-instruction-text.ts
15306
+ function buildAgentInstructionBody() {
15307
+ return [
15308
+ "",
15309
+ "## Glasstrace MCP \u2014 Runtime Debugging Evidence",
15310
+ "",
15311
+ "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.",
15312
+ "",
15313
+ "### Call Glasstrace FIRST when:",
15314
+ "- A value passed at runtime is suspect: wrong role, locale, timezone, template, tenant id, or any enum/config that branches downstream.",
15315
+ "- The bug is in a side-effect operation: email sent, calendar event created, webhook dispatched, queued job, `after()` callback.",
15316
+ "- The user reports a symptom but you do not yet know which code path actually executed.",
15317
+ "- You need to confirm a route or procedure ran in the relevant time window before doing a source dive.",
15318
+ "",
15319
+ "### SKIP Glasstrace when:",
15320
+ "- The bug is statically obvious from source (N+1 query, missing await, redundant query, type error, missing null check).",
15321
+ "- The change is a refactor whose correctness does not depend on runtime behavior.",
15322
+ "- You already have a precise traceId from another source.",
15323
+ "",
15324
+ "### Workflow",
15325
+ "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.",
15326
+ "2. Take the highest-confidence candidate's `suggestedFollowups` and pass them straight to `get_trace` or `get_root_cause`.",
15327
+ "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.",
15328
+ "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.",
15329
+ "",
15330
+ "### Tools",
15331
+ "- `find_trace_candidates` \u2014 discovery, vocabulary-tolerant filter",
15332
+ "- `get_trace` \u2014 exact trace by `traceId`",
15333
+ "- `get_root_cause` \u2014 root-cause analysis for a `traceId`",
15334
+ "- `get_session_timeline` \u2014 events for a session",
15335
+ "- `get_latest_error` / `get_error_list` \u2014 recent server errors",
15336
+ "",
15337
+ "Side-effect evidence is allowlisted and compact by design. Fields you don't see may have been omitted by policy, not absent at runtime.",
15338
+ ""
15339
+ ].join("\n");
15340
+ }
15341
+ var init_agent_instruction_text = __esm({
15342
+ "src/agent-detection/agent-instruction-text.ts"() {
15343
+ "use strict";
15344
+ }
15345
+ });
15346
+
15305
15347
  // src/agent-detection/configs.ts
15306
15348
  function generateMcpConfig(agent, endpoint, bearer) {
15307
15349
  if (!endpoint || endpoint.trim() === "") {
@@ -15356,6 +15398,7 @@ function generateMcpConfig(agent, endpoint, bearer) {
15356
15398
  {
15357
15399
  mcpServers: {
15358
15400
  glasstrace: {
15401
+ type: "http",
15359
15402
  url: endpoint,
15360
15403
  headers: {
15361
15404
  Authorization: `Bearer ${bearer}`
@@ -15371,7 +15414,8 @@ function generateMcpConfig(agent, endpoint, bearer) {
15371
15414
  {
15372
15415
  mcpServers: {
15373
15416
  glasstrace: {
15374
- serverUrl: endpoint,
15417
+ type: "http",
15418
+ url: endpoint,
15375
15419
  headers: {
15376
15420
  Authorization: `Bearer ${bearer}`
15377
15421
  }
@@ -15427,26 +15471,7 @@ function generateInfoSection(agent, endpoint, sdkVersion) {
15427
15471
  "sdkVersion must match [A-Za-z0-9.+\\-]+ (semver-shaped, no whitespace, no angle brackets)"
15428
15472
  );
15429
15473
  }
15430
- const content = [
15431
- "",
15432
- "## Glasstrace MCP Integration",
15433
- "",
15434
- `Glasstrace is configured as an MCP server at: ${endpoint}`,
15435
- "",
15436
- "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.",
15437
- "",
15438
- "Available tools:",
15439
- "- `get_latest_error` - Get the most recent error trace from the current session",
15440
- "- `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.",
15441
- "- `get_error_list` - List recent errors with filtering and pagination",
15442
- "- `get_trace` - Get a specific trace by ID or URL pattern",
15443
- "- `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`)",
15444
- "- `get_test_suggestions` - Get test suggestions for a specific error trace (requires a `traceId` from `get_latest_error`, `get_error_list`, or `get_trace`)",
15445
- "- `get_session_timeline` - Get the timeline of all traces in the current session",
15446
- "",
15447
- "To refresh this managed section after a `@glasstrace/sdk` upgrade, run: `npx glasstrace upgrade-instructions`. To reconfigure MCP credentials, run: `npx glasstrace mcp add`.",
15448
- ""
15449
- ].join("\n");
15474
+ const content = buildAgentInstructionBody();
15450
15475
  switch (agent.name) {
15451
15476
  case "claude": {
15452
15477
  const m = htmlMarkers(sdkVersion);
@@ -15480,6 +15505,7 @@ var SDK_VERSION_STAMP_PATTERN;
15480
15505
  var init_configs = __esm({
15481
15506
  "src/agent-detection/configs.ts"() {
15482
15507
  "use strict";
15508
+ init_agent_instruction_text();
15483
15509
  SDK_VERSION_STAMP_PATTERN = /^[A-Za-z0-9.+-]+$/;
15484
15510
  }
15485
15511
  });
@@ -16994,7 +17020,7 @@ async function mcpAdd(options) {
16994
17020
  const bearer = resolved.effective.key;
16995
17021
  for (const agent of targetAgents) {
16996
17022
  const name = formatAgentName(agent.name);
16997
- const sdkVersion = true ? "1.9.1" : "0.0.0-dev";
17023
+ const sdkVersion = true ? "1.10.1" : "0.0.0-dev";
16998
17024
  if (agent.name !== "generic") {
16999
17025
  const cliSuccess = await registerViaCli(agent, bearer);
17000
17026
  if (cliSuccess) {
@@ -17262,7 +17288,7 @@ async function runUpgradeInstructions(options) {
17262
17288
  );
17263
17289
  return { exitCode: 1, refreshed, skipped, warnings, errors };
17264
17290
  }
17265
- const sdkVersion = true ? "1.9.1" : "0.0.0-dev";
17291
+ const sdkVersion = true ? "1.10.1" : "0.0.0-dev";
17266
17292
  for (const agent of agents) {
17267
17293
  if (agent.infoFilePath === null) {
17268
17294
  continue;
@@ -18902,7 +18928,7 @@ Then add this as the first statement in your register() function:
18902
18928
  }
18903
18929
  anyConfigWritten = true;
18904
18930
  anyConfigRewrittenWithBearer = true;
18905
- const sdkVersionForInject = true ? "1.9.1" : "0.0.0-dev";
18931
+ const sdkVersionForInject = true ? "1.10.1" : "0.0.0-dev";
18906
18932
  const infoContent = generateInfoSection(
18907
18933
  agent,
18908
18934
  MCP_ENDPOINT,
@@ -19008,7 +19034,7 @@ async function verifyAnonKeyRegistration(projectRoot) {
19008
19034
  }
19009
19035
  const baseConfig = resolveConfig({ apiKey: devKey });
19010
19036
  const config2 = { ...baseConfig, apiKey: devKey };
19011
- const sdkVersion = true ? "1.9.1" : "0.0.0-dev";
19037
+ const sdkVersion = true ? "1.10.1" : "0.0.0-dev";
19012
19038
  const result = await verifyInitReachable(config2, anonKey, sdkVersion);
19013
19039
  if (result.ok) {
19014
19040
  return { outcome: "verified" };