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