@lunora/testing 1.0.0-alpha.43 → 1.0.0-alpha.45

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  export { agentHarness, finalTurn, toolCallTurn } from './packem_shared/agentHarness-GTPhWdQ8.mjs';
2
- export { lunoraTest } from './packem_shared/lunoraTest-DbzbUAGQ.mjs';
2
+ export { lunoraTest } from './packem_shared/lunoraTest-BuoclXGw.mjs';
3
3
  export { containsScorer, evaluate, exactMatchScorer, keywordScorer, llmScorer, regexScorer, scoreSample } from './packem_shared/containsScorer-DGwtvUNp.mjs';
4
4
  export { extractLink, listCapturedMail, waitForMail } from '@lunora/mail/testing';
@@ -2,7 +2,7 @@ import { runShardMigrations, createShardCtxDb } from '@lunora/do';
2
2
  import { LunoraError } from '@lunora/errors';
3
3
  import { DatabaseSync } from 'node:sqlite';
4
4
 
5
- const createFakeScheduler = (getDispatch, getMutationContext, getFunctionRegistry, now) => {
5
+ const createFakeScheduler = (getDispatch, getMutationContext, getActionContext, getFunctionRegistry, now) => {
6
6
  let nowMs = now;
7
7
  let nextId = 1;
8
8
  const pending = /* @__PURE__ */ new Map();
@@ -48,8 +48,8 @@ const createFakeScheduler = (getDispatch, getMutationContext, getFunctionRegistr
48
48
  }
49
49
  if (entry.kind === "mutation" || entry.kind === "action") {
50
50
  const dispatch = getDispatch();
51
- const mutationContext = getMutationContext();
52
- await dispatch(entry.kind, entry, mutationContext, job.args);
51
+ const context = entry.kind === "action" ? getActionContext() : getMutationContext();
52
+ await dispatch(entry.kind, entry, context, job.args);
53
53
  } else {
54
54
  console.warn(
55
55
  `[fake-scheduler] functionPath "${job.functionPath}" is a ${entry.kind} — only mutations and actions can be scheduled; job ${job.id} dropped`
@@ -324,6 +324,7 @@ const lunoraTest = (schema, options) => {
324
324
  };
325
325
  let scheduledDispatchRef;
326
326
  let mutationContextRef;
327
+ let actionContextRef;
327
328
  const harnessNow = options?.now ?? Date.now();
328
329
  const { controls: schedulerControls, scheduler: fakeScheduler } = createFakeScheduler(
329
330
  () => {
@@ -344,6 +345,15 @@ const lunoraTest = (schema, options) => {
344
345
  }
345
346
  return mutationContextRef;
346
347
  },
348
+ () => {
349
+ if (actionContextRef === void 0) {
350
+ throw new LunoraError(
351
+ "INTERNAL",
352
+ "[fake-scheduler] actionContext not yet available — scheduler.advance called before harness construction completed"
353
+ );
354
+ }
355
+ return actionContextRef;
356
+ },
347
357
  () => functionRegistryMap,
348
358
  harnessNow
349
359
  );
@@ -403,6 +413,7 @@ const lunoraTest = (schema, options) => {
403
413
  vectors: stubProxy("vectors"),
404
414
  workflows: stubProxy("workflows")
405
415
  };
416
+ actionContextRef ??= actionContext;
406
417
  const runRegistered = (expected, reference, context, args, allowInternal) => {
407
418
  const kind = registeredFunctionKind(reference);
408
419
  if (kind !== expected) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/testing",
3
- "version": "1.0.0-alpha.43",
3
+ "version": "1.0.0-alpha.45",
4
4
  "description": "Testing toolkit for Lunora: an in-memory harness for queries, mutations, and actions",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,11 +46,11 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/agent": "1.0.0-alpha.2",
50
- "@lunora/do": "1.0.0-alpha.31",
49
+ "@lunora/agent": "1.0.0-alpha.4",
50
+ "@lunora/do": "1.0.0-alpha.33",
51
51
  "@lunora/errors": "1.0.0-alpha.5",
52
52
  "@lunora/mail": "1.0.0-alpha.15",
53
- "@lunora/server": "1.0.0-alpha.25"
53
+ "@lunora/server": "1.0.0-alpha.27"
54
54
  },
55
55
  "engines": {
56
56
  "node": "^22.15.0 || >=24.11.0"