taist 0.2.2 → 0.2.4

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 (2) hide show
  1. package/lib/transform.js +15 -2
  2. package/package.json +1 -1
package/lib/transform.js CHANGED
@@ -150,6 +150,15 @@ const __taist_debug = process.env.TAIST_DEBUG === 'true';
150
150
  if (process.env.TAIST_COLLECTOR_SOCKET && !__taist_reporter.isConnected()) {
151
151
  __taist_reporter.connectEager();
152
152
  }
153
+ // Helper to find correlationId from GraphQL context argument (Apollo: parent, args, context, info)
154
+ const __taist_findCorrelationIdInArgs = (args) => {
155
+ for (const arg of args) {
156
+ if (arg && typeof arg === 'object' && arg.taistCorrelationId) {
157
+ return arg.taistCorrelationId;
158
+ }
159
+ }
160
+ return null;
161
+ };
153
162
  const __taist_wrap = (fn, name) => {
154
163
  if (typeof fn !== 'function') return fn;
155
164
  if (__taist_debug) console.log('[taist] wrapping:', name);
@@ -158,8 +167,10 @@ const __taist_wrap = (fn, name) => {
158
167
  const parentCtx = __taist_getContext();
159
168
  const id = __taist_generateId();
160
169
  const depth = parentCtx.depth;
161
- // Get correlationId from parent context or fallback global
162
- const correlationId = parentCtx.correlationId || __taist_getCorrelationId();
170
+ // Get correlationId: 1) parent context, 2) GraphQL context arg, 3) fallback global
171
+ const argsCorrelationId = __taist_findCorrelationIdInArgs(args);
172
+ const correlationId = parentCtx.correlationId || argsCorrelationId || __taist_getCorrelationId();
173
+ if (__taist_debug && argsCorrelationId) console.log('[taist] Found correlationId in args:', argsCorrelationId);
163
174
  const newCtx = {
164
175
  depth: depth + 1,
165
176
  traceId: parentCtx.traceId || id,
@@ -171,6 +182,7 @@ const __taist_wrap = (fn, name) => {
171
182
  const start = performance.now();
172
183
 
173
184
  const reportSuccess = (result) => {
185
+ if (__taist_debug) console.log('[taist] REPORT:', name, 'depth:', depth, 'correlationId:', correlationId);
174
186
  __taist_reporter.report({
175
187
  id, name, type: 'exit', args, result,
176
188
  duration: performance.now() - start,
@@ -184,6 +196,7 @@ const __taist_wrap = (fn, name) => {
184
196
  };
185
197
 
186
198
  const reportError = (err) => {
199
+ if (__taist_debug) console.log('[taist] REPORT ERROR:', name, 'depth:', depth, 'correlationId:', correlationId, 'error:', err.message);
187
200
  __taist_reporter.report({
188
201
  id, name, type: 'error', args,
189
202
  error: { name: err.name, message: err.message },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taist",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Token-Optimized Testing Framework for AI-Assisted Development",
5
5
  "main": "index.js",
6
6
  "type": "module",