@glasstrace/sdk 1.10.0 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/init.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  detectAgents,
27
27
  generateInfoSection,
28
28
  generateMcpConfig
29
- } from "../chunk-KI7YJ7XD.js";
29
+ } from "../chunk-CIKPFJOM.js";
30
30
  import {
31
31
  MCP_ENDPOINT,
32
32
  getOrCreateAnonKey,
@@ -901,7 +901,7 @@ Then add this as the first statement in your register() function:
901
901
  }
902
902
  anyConfigWritten = true;
903
903
  anyConfigRewrittenWithBearer = true;
904
- const sdkVersionForInject = true ? "1.10.0" : "0.0.0-dev";
904
+ const sdkVersionForInject = true ? "1.10.2" : "0.0.0-dev";
905
905
  const infoContent = generateInfoSection(
906
906
  agent,
907
907
  MCP_ENDPOINT,
@@ -1007,7 +1007,7 @@ async function verifyAnonKeyRegistration(projectRoot) {
1007
1007
  }
1008
1008
  const baseConfig = resolveConfig({ apiKey: devKey });
1009
1009
  const config = { ...baseConfig, apiKey: devKey };
1010
- const sdkVersion = true ? "1.10.0" : "0.0.0-dev";
1010
+ const sdkVersion = true ? "1.10.2" : "0.0.0-dev";
1011
1011
  const result = await verifyInitReachable(config, anonKey, sdkVersion);
1012
1012
  if (result.ok) {
1013
1013
  return { outcome: "verified" };
@@ -14413,6 +14413,49 @@ 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 empty-result envelope before pivoting to source \u2014 each field disambiguates a different reason for the empty result:",
14440
+ " - `closeMatches` / `recentRoutesSample` \u2014 your filter vocabulary doesn't match server-side names; the server returns the closest known names + a sample of routes actually present.",
14441
+ ' - `windowActivity` \u2014 load-bearing four-way distinguisher. `totalTracesInWindow === 0` AND `totalTracesInTenantEver > 0` means "your time window missed the activity"; `totalTracesInTenantEver === 0` means "this tenant has never produced traces" (SDK not registered, or never hit); `captureConfigBlocksRequest === true` means "the SDK\'s capture config dropped this route"; otherwise the empty result is a vocabulary miss \u2014 see `closeMatches`.',
14442
+ " - `humanReadable` \u2014 prose guidance written for the agent.",
14443
+ " - `recoveryActions` \u2014 concrete next-call shapes.",
14444
+ " - `diagnosticValue` / `recommendedNextStep` \u2014 whether to keep searching or stop.",
14445
+ " Empty results carry `notAbsenceProof: true` \u2014 they are never proof the bug did not occur.",
14446
+ "",
14447
+ "### Tools",
14448
+ "- `find_trace_candidates` \u2014 discovery, vocabulary-tolerant filter",
14449
+ "- `get_trace` \u2014 exact trace by `traceId`",
14450
+ "- `get_root_cause` \u2014 root-cause analysis for a `traceId`",
14451
+ "- `get_session_timeline` \u2014 events for a session",
14452
+ "- `get_latest_error` / `get_error_list` \u2014 recent server errors",
14453
+ "",
14454
+ "Side-effect evidence is allowlisted and compact by design. Fields you don't see may have been omitted by policy, not absent at runtime.",
14455
+ ""
14456
+ ].join("\n");
14457
+ }
14458
+
14416
14459
  // src/agent-detection/configs.ts
14417
14460
  function generateMcpConfig(agent, endpoint, bearer) {
14418
14461
  if (!endpoint || endpoint.trim() === "") {
@@ -14467,6 +14510,7 @@ function generateMcpConfig(agent, endpoint, bearer) {
14467
14510
  {
14468
14511
  mcpServers: {
14469
14512
  glasstrace: {
14513
+ type: "http",
14470
14514
  url: endpoint,
14471
14515
  headers: {
14472
14516
  Authorization: `Bearer ${bearer}`
@@ -14482,7 +14526,8 @@ function generateMcpConfig(agent, endpoint, bearer) {
14482
14526
  {
14483
14527
  mcpServers: {
14484
14528
  glasstrace: {
14485
- serverUrl: endpoint,
14529
+ type: "http",
14530
+ url: endpoint,
14486
14531
  headers: {
14487
14532
  Authorization: `Bearer ${bearer}`
14488
14533
  }
@@ -14539,26 +14584,7 @@ function generateInfoSection(agent, endpoint, sdkVersion) {
14539
14584
  "sdkVersion must match [A-Za-z0-9.+\\-]+ (semver-shaped, no whitespace, no angle brackets)"
14540
14585
  );
14541
14586
  }
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");
14587
+ const content = buildAgentInstructionBody();
14562
14588
  switch (agent.name) {
14563
14589
  case "claude": {
14564
14590
  const m = htmlMarkers(sdkVersion);
@@ -14929,7 +14955,7 @@ async function mcpAdd(options) {
14929
14955
  const bearer = resolved.effective.key;
14930
14956
  for (const agent of targetAgents) {
14931
14957
  const name = formatAgentName(agent.name);
14932
- const sdkVersion = true ? "1.10.0" : "0.0.0-dev";
14958
+ const sdkVersion = true ? "1.10.2" : "0.0.0-dev";
14933
14959
  if (agent.name !== "generic") {
14934
14960
  const cliSuccess = await registerViaCli(agent, bearer);
14935
14961
  if (cliSuccess) {