Open History to see the last commit
1import * as NodeCrypto from "node:crypto";
2import * as NodeServices from "@effect/platform-node/NodeServices";
3
4import type {
5 EnvironmentId,
6 ExecutionEnvironmentDescriptor,
7 OrchestrationEvent,
8 OrchestrationProjectShell,
9 OrchestrationShellSnapshot,
10 OrchestrationThreadShell,
11 ProjectId,
12 ThreadId,
13 TurnId,
14} from "@t3tools/contracts";
15import type {
16 RelayAgentActivityPublishProofPayload,
17 RelayAgentActivityState,
18} from "@t3tools/contracts/relay";
19import { CommandId, ProviderInstanceId } from "@t3tools/contracts";
20import { RelayClientTracer } from "@t3tools/shared/relayTracing";
21import { RELAY_ACTIVITY_PUBLISH_TYP, verifyRelayJwt } from "@t3tools/shared/relayJwt";
22import { describe, expect, it } from "@effect/vitest";
23import * as Deferred from "effect/Deferred";
24import * as Effect from "effect/Effect";
25import * as Layer from "effect/Layer";
26import * as Option from "effect/Option";
27import * as Queue from "effect/Queue";
28import * as Stream from "effect/Stream";
29import * as Tracer from "effect/Tracer";
30
31import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
32import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
33import {
34 OrchestrationEngineService,
35 type OrchestrationEngineShape,
36} from "../orchestration/Services/OrchestrationEngine.ts";
37import {
38 ProjectionSnapshotQuery,
39 type ProjectionSnapshotQueryShape,
40} from "../orchestration/Services/ProjectionSnapshotQuery.ts";
41import {
42 isAgentActivityPublishingEnabledValue,
43 RELAY_ENVIRONMENT_CREDENTIAL_SECRET,
44 RELAY_ISSUER_SECRET,
45 RELAY_URL_SECRET,
46 PUBLISH_AGENT_ACTIVITY_SECRET,
47} from "../cloud/config.ts";
48import * as AgentAwarenessRelay from "./AgentAwarenessRelay.ts";
49
50const state: RelayAgentActivityState = {
51 environmentId: "env" as RelayAgentActivityState["environmentId"],
52 threadId: "thread" as RelayAgentActivityState["threadId"],
53 projectTitle: "Project",
54 threadTitle: "Thread",
55 modelTitle: "gpt-5.4",
56 phase: "running",
57 headline: "Running",
58 updatedAt: "2026-05-25T00:00:00.000Z",
59 deepLink: "/threads/env/thread",
60};
61
62const encodeSecret = (value: string): Uint8Array => new TextEncoder().encode(value);
63
64function makeMemorySecretStore() {
65 const values = new Map<string, Uint8Array>();
66 const store = {
67 get: ((name) =>
68 Effect.sync(() => {
69 const value = values.get(name);
70 return value === undefined ? Option.none() : Option.some(Uint8Array.from(value));
71 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["get"],
72 set: ((name, value) =>
73 Effect.sync(() => {
74 values.set(name, Uint8Array.from(value));
75 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["set"],
76 create: ((name, value) =>
77 Effect.sync(() => {
78 values.set(name, Uint8Array.from(value));
79 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["create"],
80 getOrCreateRandom: ((name, bytes) =>
81 Effect.sync(() => {
82 const existing = values.get(name);
83 if (existing) {
84 return existing;
85 }
86 const generated = new Uint8Array(bytes);
87 values.set(name, generated);
88 return generated;
89 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["getOrCreateRandom"],
90 remove: ((name) =>
91 Effect.sync(() => {
92 values.delete(name);
93 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["remove"],
94 } satisfies ServerSecretStore.ServerSecretStore["Service"];
95 return {
96 store,
97 setString: (name: string, value: string) => store.set(name, encodeSecret(value)),
98 };
99}
100
101describe.sequential("signRelayAgentActivityPublishProof", () => {
102 it("distinguishes pending link credentials from disabled publication", () => {
103 expect(
104 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
105 relayConfigured: false,
106 publishEnabled: false,
107 }),
108 ).toBe("waiting-for-link");
109 expect(
110 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
111 relayConfigured: true,
112 publishEnabled: false,
113 }),
114 ).toBe("disabled");
115 expect(
116 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
117 relayConfigured: true,
118 publishEnabled: true,
119 }),
120 ).toBe("enabled");
121 });
122
123 it("derives the thread id from the aggregate id for thread events without payload thread ids", () => {
124 const threadId = "thread-aggregate-1" as ThreadId;
125 const now = "2026-05-25T00:00:00.000Z";
126 const event = {
127 type: "thread.activity-appended",
128 sequence: 1,
129 eventId: "evt-aggregate-1",
130 commandId: CommandId.make("cmd-1"),
131 aggregateKind: "thread",
132 aggregateId: threadId,
133 actor: { kind: "server" },
134 payload: {},
135 occurredAt: now,
136 } as unknown as OrchestrationEvent;
137
138 expect(AgentAwarenessRelay.eventThreadId(event)).toBe(threadId);
139 });
140
141 it("does not publish start intents, streaming content, or non-awareness activity events", () => {
142 const now = "2026-05-25T00:00:00.000Z";
143 const base = {
144 sequence: 1,
145 eventId: "evt-1",
146 commandId: CommandId.make("cmd-1"),
147 aggregateKind: "thread",
148 aggregateId: "thread-1" as ThreadId,
149 occurredAt: now,
150 };
151
152 expect(
153 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
154 ...base,
155 type: "thread.message-sent",
156 payload: {
157 threadId: "thread-1" as ThreadId,
158 streaming: true,
159 },
160 } as unknown as OrchestrationEvent),
161 ).toBe(false);
162 expect(
163 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
164 ...base,
165 type: "thread.activity-appended",
166 payload: {
167 threadId: "thread-1" as ThreadId,
168 activity: {
169 kind: "task.progress",
170 },
171 },
172 } as unknown as OrchestrationEvent),
173 ).toBe(false);
174 expect(
175 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
176 ...base,
177 type: "thread.activity-appended",
178 payload: {
179 threadId: "thread-1" as ThreadId,
180 activity: {
181 kind: "approval.requested",
182 },
183 },
184 } as unknown as OrchestrationEvent),
185 ).toBe(true);
186 expect(
187 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
188 ...base,
189 type: "thread.message-sent",
190 payload: {
191 threadId: "thread-1" as ThreadId,
192 streaming: false,
193 },
194 } as unknown as OrchestrationEvent),
195 ).toBe(false);
196 expect(
197 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
198 ...base,
199 type: "thread.turn-start-requested",
200 payload: {
201 threadId: "thread-1" as ThreadId,
202 },
203 } as unknown as OrchestrationEvent),
204 ).toBe(false);
205 });
206
207 it("deduplicates awareness state updates whose only change is their event timestamp", () => {
208 expect(AgentAwarenessRelay.agentAwarenessPublishIdentity(state)).toBe(
209 AgentAwarenessRelay.agentAwarenessPublishIdentity({
210 ...state,
211 updatedAt: "2026-05-25T00:10:00.000Z",
212 }),
213 );
214 expect(AgentAwarenessRelay.agentAwarenessPublishIdentity(state)).not.toBe(
215 AgentAwarenessRelay.agentAwarenessPublishIdentity({
216 ...state,
217 phase: "completed",
218 headline: "Agent finished",
219 }),
220 );
221 });
222
223 it("requires an explicit opt-in before publishing agent activity", () => {
224 expect(isAgentActivityPublishingEnabledValue(null)).toBe(false);
225 expect(isAgentActivityPublishingEnabledValue("false")).toBe(false);
226 expect(isAgentActivityPublishingEnabledValue("TRUE")).toBe(false);
227 expect(isAgentActivityPublishingEnabledValue("true")).toBe(true);
228 });
229
230 it("redacts failed activity details and caps other relay detail", () => {
231 expect(
232 AgentAwarenessRelay.sanitizeRelayAgentActivityState({
233 ...state,
234 phase: "failed",
235 detail: "Provider process exited with secret token.",
236 }),
237 ).toMatchObject({
238 phase: "failed",
239 detail: "The agent run failed.",
240 });
241 expect(
242 AgentAwarenessRelay.sanitizeRelayAgentActivityState({
243 ...state,
244 detail: "x".repeat(200),
245 })?.detail,
246 ).toHaveLength(160);
247 });
248
249 it("resolves a null publish state when a thread or project snapshot disappeared", () => {
250 const environmentId = "env-1" as EnvironmentId;
251 const threadId = "thread-1" as ThreadId;
252 const thread = {
253 id: threadId,
254 projectId: "project-1" as ProjectId,
255 title: "Deleted thread",
256 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
257 session: null,
258 latestTurn: null,
259 updatedAt: "2026-05-25T00:00:00.000Z",
260 hasPendingApprovals: false,
261 hasPendingUserInput: false,
262 } as OrchestrationThreadShell;
263
264 expect(
265 AgentAwarenessRelay.resolveAgentAwarenessRelayPublishSnapshot({
266 environmentId,
267 threadId,
268 thread: Option.none(),
269 project: Option.none(),
270 }),
271 ).toEqual({
272 projectId: null,
273 state: null,
274 reason: "thread-not-found",
275 });
276
277 expect(
278 AgentAwarenessRelay.resolveAgentAwarenessRelayPublishSnapshot({
279 environmentId,
280 threadId,
281 thread: Option.some(thread),
282 project: Option.none(),
283 }),
284 ).toEqual({
285 projectId: "project-1",
286 state: null,
287 reason: "project-not-found",
288 });
289 });
290
291 it("selects only active shell snapshot threads for startup catch-up", () => {
292 const now = "2026-05-25T00:00:00.000Z";
293 const environmentId = "env-1" as EnvironmentId;
294 const projectId = "project-1" as ProjectId;
295 const activeThreadId = "thread-active" as ThreadId;
296 const idleThreadId = "thread-idle" as ThreadId;
297
298 const baseThread = {
299 projectId,
300 title: "Run remote agent",
301 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
302 runtimeMode: "full-access",
303 interactionMode: "default",
304 branch: null,
305 worktreePath: null,
306 latestTurn: null,
307 createdAt: now,
308 updatedAt: now,
309 archivedAt: null,
310 settledOverride: null,
311 settledAt: null,
312 session: null,
313 latestUserMessageAt: null,
314 hasPendingApprovals: false,
315 hasPendingUserInput: false,
316 hasActionableProposedPlan: false,
317 } satisfies Omit<OrchestrationThreadShell, "id">;
318
319 expect(
320 AgentAwarenessRelay.resolveAgentAwarenessRelayActiveThreadIds({
321 environmentId,
322 projects: [
323 {
324 id: projectId,
325 title: "T3 Code",
326 },
327 ],
328 threads: [
329 {
330 ...baseThread,
331 id: activeThreadId,
332 latestTurn: {
333 turnId: "turn-1" as TurnId,
334 state: "running",
335 requestedAt: now,
336 startedAt: now,
337 completedAt: null,
338 assistantMessageId: null,
339 },
340 },
341 {
342 ...baseThread,
343 id: idleThreadId,
344 },
345 {
346 ...baseThread,
347 id: "thread-missing-project" as ThreadId,
348 projectId: "missing-project" as ProjectId,
349 latestTurn: {
350 turnId: "turn-2" as TurnId,
351 state: "running",
352 requestedAt: now,
353 startedAt: now,
354 completedAt: null,
355 assistantMessageId: null,
356 },
357 },
358 ],
359 }),
360 ).toEqual([activeThreadId]);
361 });
362
363 it.effect("signs the activity publish JWT and rejects tampering", () =>
364 Effect.gen(function* () {
365 const keyPair = NodeCrypto.generateKeyPairSync("ed25519", {
366 privateKeyEncoding: { format: "pem", type: "pkcs8" },
367 publicKeyEncoding: { format: "pem", type: "spki" },
368 });
369 const payload = {
370 iss: "t3-env:env",
371 aud: "https://relay.example.test",
372 sub: "env",
373 jti: "nonce-1",
374 iat: 100,
375 exp: 200,
376 environmentId: state.environmentId,
377 threadId: state.threadId,
378 state,
379 } satisfies RelayAgentActivityPublishProofPayload;
380 const proof = yield* AgentAwarenessRelay.signRelayAgentActivityPublishProof({
381 privateKey: keyPair.privateKey,
382 payload,
383 });
384 const verify = (token: string) =>
385 verifyRelayJwt({
386 publicKey: keyPair.publicKey,
387 token,
388 typ: RELAY_ACTIVITY_PUBLISH_TYP,
389 issuer: "t3-env:env",
390 audience: "https://relay.example.test",
391 nowEpochSeconds: 150,
392 });
393
394 expect(yield* verify(proof)).toMatchObject({ jti: "nonce-1", state });
395
396 const [header, body, signature = ""] = proof.split(".");
397 const corruptedSignature = `${signature.startsWith("a") ? "b" : "a"}${signature.slice(1)}`;
398 const rejection = yield* Effect.flip(verify(`${header}.${body}.${corruptedSignature}`));
399 expect(rejection).toBeDefined();
400 }),
401 );
402
403 it.effect("keeps the orchestration listener armed until relay config is installed", () =>
404 Effect.scoped(
405 Effect.gen(function* () {
406 const events = yield* Queue.unbounded<OrchestrationEvent>();
407 const threadShellRequested = yield* Deferred.make<void>();
408 const secrets = makeMemorySecretStore();
409 const now = "2026-05-25T00:00:00.000Z";
410 const projectId = "project-1" as ProjectId;
411 const threadId = "thread-1" as ThreadId;
412 const environmentId = "env-1" as EnvironmentId;
413
414 const project = {
415 id: projectId,
416 title: "T3 Code",
417 workspaceRoot: "/workspace",
418 repositoryIdentity: null,
419 defaultModelSelection: null,
420 scripts: [],
421 createdAt: now,
422 updatedAt: now,
423 } satisfies OrchestrationProjectShell;
424
425 const thread = {
426 id: threadId,
427 projectId,
428 title: "Run remote agent",
429 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
430 runtimeMode: "full-access",
431 interactionMode: "default",
432 branch: null,
433 worktreePath: null,
434 latestTurn: {
435 turnId: "turn-1" as TurnId,
436 state: "running",
437 requestedAt: now,
438 startedAt: now,
439 completedAt: null,
440 assistantMessageId: null,
441 },
442 createdAt: now,
443 updatedAt: now,
444 archivedAt: null,
445 settledOverride: null,
446 settledAt: null,
447 session: {
448 threadId,
449 status: "running",
450 providerName: "Codex",
451 runtimeMode: "full-access",
452 activeTurnId: "turn-1" as TurnId,
453 lastError: null,
454 updatedAt: now,
455 },
456 latestUserMessageAt: now,
457 hasPendingApprovals: false,
458 hasPendingUserInput: false,
459 hasActionableProposedPlan: false,
460 } satisfies OrchestrationThreadShell;
461
462 const orchestrationEngine = {
463 readEvents: () => Stream.empty,
464 readThreadEvents: () => Stream.empty,
465 getThreadReplayStats: () => Effect.die("unused thread replay stats"),
466 dispatch: () => Effect.succeed({ sequence: 1 }),
467 streamDomainEvents: Stream.fromQueue(events),
468 subscribeDomainEvents: Effect.succeed(Stream.fromQueue(events)),
469 latestSequence: Effect.succeed(0),
470 } satisfies OrchestrationEngineShape;
471
472 const snapshotQuery = {
473 getShellSnapshot: () =>
474 Effect.succeed({
475 snapshotSequence: 1,
476 projects: [project],
477 threads: [thread],
478 updatedAt: now,
479 } satisfies OrchestrationShellSnapshot),
480 getThreadShellById: () =>
481 Deferred.succeed(threadShellRequested, undefined).pipe(
482 Effect.ignore,
483 Effect.as(Option.some(thread)),
484 ),
485 getProjectShellById: () => Effect.succeed(Option.some(project)),
486 } as unknown as ProjectionSnapshotQueryShape;
487
488 const descriptor = {
489 environmentId,
490 label: "Test Desktop",
491 platform: {
492 os: "darwin",
493 arch: "arm64",
494 },
495 serverVersion: "0.0.0-test",
496 capabilities: {
497 repositoryIdentity: true,
498 },
499 } satisfies ExecutionEnvironmentDescriptor;
500
501 const layer = Layer.mergeAll(
502 Layer.succeed(ServerSecretStore.ServerSecretStore, secrets.store),
503 Layer.succeed(ServerEnvironment.ServerEnvironment, {
504 getEnvironmentId: Effect.succeed(environmentId),
505 getDescriptor: Effect.succeed(descriptor),
506 }),
507 Layer.succeed(OrchestrationEngineService, orchestrationEngine),
508 Layer.succeed(ProjectionSnapshotQuery, snapshotQuery),
509 );
510
511 yield* Effect.gen(function* () {
512 const relay = yield* AgentAwarenessRelay.AgentAwarenessRelay;
513 yield* relay.start();
514 yield* secrets.setString(RELAY_URL_SECRET, "http://127.0.0.1:1");
515 yield* secrets.setString(RELAY_ENVIRONMENT_CREDENTIAL_SECRET, "relay-credential");
516 yield* secrets.setString(PUBLISH_AGENT_ACTIVITY_SECRET, "true");
517 yield* Queue.offer(events, {
518 type: "thread.activity-appended",
519 sequence: 1,
520 eventId: "evt-1",
521 commandId: CommandId.make("cmd-1"),
522 aggregateKind: "thread",
523 aggregateId: threadId,
524 actor: { kind: "server" },
525 payload: {
526 threadId,
527 activity: {
528 kind: "approval.requested",
529 },
530 },
531 occurredAt: now,
532 } as unknown as OrchestrationEvent);
533
534 yield* Deferred.await(threadShellRequested).pipe(Effect.timeout("2 seconds"));
535 }).pipe(
536 Effect.provide(
537 AgentAwarenessRelay.layer.pipe(
538 Layer.provide(layer),
539 Layer.provideMerge(NodeServices.layer),
540 ),
541 ),
542 );
543 }),
544 ),
545 );
546
547 it.effect("publishes agent activity to the relay transport URL, not the relay issuer", () =>
548 Effect.scoped(
549 Effect.gen(function* () {
550 const originalFetch = globalThis.fetch;
551 const events = yield* Queue.unbounded<OrchestrationEvent>();
552 let resolveFetchSeen: (url: URL) => void = () => {};
553 const fetchSeen = new Promise<URL>((resolve) => {
554 resolveFetchSeen = resolve;
555 });
556 const userSpans: Array<string> = [];
557 const productSpans: Array<string> = [];
558 const collectingTracer = (spans: Array<string>) =>
559 Tracer.make({
560 span: (options) => {
561 const span = new Tracer.NativeSpan(options);
562 const end = span.end.bind(span);
563 span.end = (endTime, exit) => {
564 end(endTime, exit);
565 spans.push(span.name);
566 };
567 return span;
568 },
569 });
570 const secrets = makeMemorySecretStore();
571 const now = "2026-05-25T00:00:00.000Z";
572 const projectId = "project-1" as ProjectId;
573 const threadId = "thread-1" as ThreadId;
574 const environmentId = "env-1" as EnvironmentId;
575
576 const project = {
577 id: projectId,
578 title: "T3 Code",
579 workspaceRoot: "/workspace",
580 repositoryIdentity: null,
581 defaultModelSelection: null,
582 scripts: [],
583 createdAt: now,
584 updatedAt: now,
585 } satisfies OrchestrationProjectShell;
586
587 const thread = {
588 id: threadId,
589 projectId,
590 title: "Run remote agent",
591 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
592 runtimeMode: "full-access",
593 interactionMode: "default",
594 branch: null,
595 worktreePath: null,
596 latestTurn: {
597 turnId: "turn-1" as TurnId,
598 state: "running",
599 requestedAt: now,
600 startedAt: now,
601 completedAt: null,
602 assistantMessageId: null,
603 },
604 createdAt: now,
605 updatedAt: now,
606 archivedAt: null,
607 settledOverride: null,
608 settledAt: null,
609 session: {
610 threadId,
611 status: "running",
612 providerName: "Codex",
613 runtimeMode: "full-access",
614 activeTurnId: "turn-1" as TurnId,
615 lastError: null,
616 updatedAt: now,
617 },
618 latestUserMessageAt: now,
619 hasPendingApprovals: false,
620 hasPendingUserInput: false,
621 hasActionableProposedPlan: false,
622 } satisfies OrchestrationThreadShell;
623
624 const descriptor = {
625 environmentId,
626 label: "Test Desktop",
627 platform: {
628 os: "darwin",
629 arch: "arm64",
630 },
631 serverVersion: "0.0.0-test",
632 capabilities: {
633 repositoryIdentity: true,
634 },
635 } satisfies ExecutionEnvironmentDescriptor;
636
637 globalThis.fetch = ((input: Parameters<typeof fetch>[0]) => {
638 const url = new URL(
639 typeof input === "string" || input instanceof URL
640 ? input
641 : (input as unknown as { readonly url: string }).url,
642 );
643 resolveFetchSeen(url);
644 return Promise.resolve(Response.json({ ok: true, deliveries: [] }));
645 }) as unknown as typeof fetch;
646 yield* Effect.addFinalizer(() =>
647 Effect.sync(() => {
648 globalThis.fetch = originalFetch;
649 }),
650 );
651
652 const layer = Layer.mergeAll(
653 Layer.succeed(ServerSecretStore.ServerSecretStore, secrets.store),
654 Layer.succeed(ServerEnvironment.ServerEnvironment, {
655 getEnvironmentId: Effect.succeed(environmentId),
656 getDescriptor: Effect.succeed(descriptor),
657 }),
658 Layer.succeed(OrchestrationEngineService, {
659 readEvents: () => Stream.empty,
660 readThreadEvents: () => Stream.empty,
661 getThreadReplayStats: () => Effect.die("unused thread replay stats"),
662 dispatch: () => Effect.succeed({ sequence: 1 }),
663 streamDomainEvents: Stream.fromQueue(events),
664 subscribeDomainEvents: Effect.succeed(Stream.fromQueue(events)),
665 latestSequence: Effect.succeed(0),
666 } satisfies OrchestrationEngineShape),
667 Layer.succeed(ProjectionSnapshotQuery, {
668 getShellSnapshot: () =>
669 Effect.succeed({
670 snapshotSequence: 1,
671 projects: [project],
672 threads: [thread],
673 updatedAt: now,
674 } satisfies OrchestrationShellSnapshot),
675 getThreadShellById: () => Effect.succeed(Option.some(thread)),
676 getProjectShellById: () => Effect.succeed(Option.some(project)),
677 } as unknown as ProjectionSnapshotQueryShape),
678 );
679
680 yield* Effect.gen(function* () {
681 const relay = yield* AgentAwarenessRelay.AgentAwarenessRelay;
682 yield* secrets.setString(RELAY_URL_SECRET, "https://transport.example.test");
683 yield* secrets.setString(RELAY_ISSUER_SECRET, "https://issuer.example.test");
684 yield* secrets.setString(RELAY_ENVIRONMENT_CREDENTIAL_SECRET, "relay-credential");
685 yield* secrets.setString(PUBLISH_AGENT_ACTIVITY_SECRET, "true");
686 yield* relay.start();
687 yield* Queue.offer(events, {
688 type: "thread.activity-appended",
689 sequence: 1,
690 eventId: "evt-1",
691 commandId: CommandId.make("cmd-1"),
692 aggregateKind: "thread",
693 aggregateId: threadId,
694 actor: { kind: "server" },
695 payload: {
696 threadId,
697 activity: {
698 kind: "approval.requested",
699 },
700 },
701 occurredAt: now,
702 } as unknown as OrchestrationEvent);
703
704 const url = yield* Effect.promise(() => fetchSeen).pipe(Effect.timeout("2 seconds"));
705 expect(url.origin).toBe("https://transport.example.test");
706 expect(productSpans).toContain("makePublishProof");
707 expect(userSpans).not.toContain("makePublishProof");
708 }).pipe(
709 Effect.provide(
710 AgentAwarenessRelay.layer.pipe(
711 Layer.provide(layer),
712 Layer.provideMerge(NodeServices.layer),
713 ),
714 ),
715 Effect.provideService(RelayClientTracer, Option.some(collectingTracer(productSpans))),
716 Effect.withTracer(collectingTracer(userSpans)),
717 );
718 }),
719 ),
720 );
721});