@effect-agent/testing 0.1.0-beta.19 → 0.1.0-beta.21

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.d.mts CHANGED
@@ -993,6 +993,42 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
993
993
  readonly createdAt: string;
994
994
  readonly deploymentId: string;
995
995
  readonly payload: {
996
+ readonly _tag: "AbortRequested";
997
+ readonly submissionId: string;
998
+ readonly author: string;
999
+ readonly reason: string;
1000
+ } | {
1001
+ readonly _tag: "ToolCallResolved";
1002
+ readonly runId: string;
1003
+ readonly toolCallId: string;
1004
+ readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
1005
+ readonly author: string;
1006
+ readonly reason: string;
1007
+ } | {
1008
+ readonly _tag: "ToolCallPrepared";
1009
+ readonly runId: string;
1010
+ readonly turnId: string;
1011
+ readonly turn: number;
1012
+ readonly toolCallId: string;
1013
+ readonly toolName: string;
1014
+ readonly parameters: Schema.Json;
1015
+ readonly parametersDigest: string;
1016
+ } | {
1017
+ readonly _tag: "ToolCallUnknown";
1018
+ readonly runId: string;
1019
+ readonly turn: number;
1020
+ readonly toolCallId: string;
1021
+ readonly toolName: string;
1022
+ readonly reason: string;
1023
+ } | {
1024
+ readonly _tag: "ToolApprovalDecided";
1025
+ readonly runId: string;
1026
+ readonly turn: number;
1027
+ readonly toolCallId: string;
1028
+ readonly decision: "approved" | "denied";
1029
+ readonly resolver: string;
1030
+ readonly reason: string;
1031
+ } | {
996
1032
  readonly _tag: "ConversationCreated";
997
1033
  readonly agentId: string;
998
1034
  readonly definitions: {
@@ -1020,15 +1056,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1020
1056
  readonly inputTokens?: number | undefined;
1021
1057
  readonly outputTokens?: number | undefined;
1022
1058
  readonly costMicrousd?: number | undefined;
1023
- } | {
1024
- readonly _tag: "ToolCallPrepared";
1025
- readonly runId: string;
1026
- readonly turnId: string;
1027
- readonly turn: number;
1028
- readonly toolCallId: string;
1029
- readonly toolName: string;
1030
- readonly parameters: Schema.Json;
1031
- readonly parametersDigest: string;
1032
1059
  } | {
1033
1060
  readonly _tag: "ToolCallSettled";
1034
1061
  readonly runId: string;
@@ -1036,20 +1063,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1036
1063
  readonly toolName: string;
1037
1064
  readonly result: Schema.Json;
1038
1065
  readonly isFailure: boolean;
1039
- } | {
1040
- readonly _tag: "ToolCallUnknown";
1041
- readonly runId: string;
1042
- readonly turn: number;
1043
- readonly toolCallId: string;
1044
- readonly toolName: string;
1045
- readonly reason: string;
1046
- } | {
1047
- readonly _tag: "ToolCallResolved";
1048
- readonly runId: string;
1049
- readonly toolCallId: string;
1050
- readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
1051
- readonly author: string;
1052
- readonly reason: string;
1053
1066
  } | {
1054
1067
  readonly _tag: "ToolStepSettled";
1055
1068
  readonly runId: string;
@@ -1065,14 +1078,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1065
1078
  readonly toolCallId: string;
1066
1079
  readonly toolName: string;
1067
1080
  readonly parametersDigest: string;
1068
- } | {
1069
- readonly _tag: "ToolApprovalDecided";
1070
- readonly runId: string;
1071
- readonly turn: number;
1072
- readonly toolCallId: string;
1073
- readonly decision: "approved" | "denied";
1074
- readonly resolver: string;
1075
- readonly reason: string;
1076
1081
  } | {
1077
1082
  readonly _tag: "ModelResponseInterrupted";
1078
1083
  readonly runId: string;
@@ -1094,11 +1099,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1094
1099
  readonly _tag: "RunCompleted";
1095
1100
  readonly runId: string;
1096
1101
  readonly output: Schema.Json;
1097
- } | {
1098
- readonly _tag: "AbortRequested";
1099
- readonly submissionId: string;
1100
- readonly author: string;
1101
- readonly reason: string;
1102
1102
  } | {
1103
1103
  readonly _tag: "SubmissionSettled";
1104
1104
  readonly submissionId: string;
@@ -1182,6 +1182,42 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1182
1182
  readonly createdAt: string;
1183
1183
  readonly deploymentId: string;
1184
1184
  readonly payload: {
1185
+ readonly _tag: "AbortRequested";
1186
+ readonly submissionId: string;
1187
+ readonly author: string;
1188
+ readonly reason: string;
1189
+ } | {
1190
+ readonly _tag: "ToolCallResolved";
1191
+ readonly runId: string;
1192
+ readonly toolCallId: string;
1193
+ readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
1194
+ readonly author: string;
1195
+ readonly reason: string;
1196
+ } | {
1197
+ readonly _tag: "ToolCallPrepared";
1198
+ readonly runId: string;
1199
+ readonly turnId: string;
1200
+ readonly turn: number;
1201
+ readonly toolCallId: string;
1202
+ readonly toolName: string;
1203
+ readonly parameters: Schema.Json;
1204
+ readonly parametersDigest: string;
1205
+ } | {
1206
+ readonly _tag: "ToolCallUnknown";
1207
+ readonly runId: string;
1208
+ readonly turn: number;
1209
+ readonly toolCallId: string;
1210
+ readonly toolName: string;
1211
+ readonly reason: string;
1212
+ } | {
1213
+ readonly _tag: "ToolApprovalDecided";
1214
+ readonly runId: string;
1215
+ readonly turn: number;
1216
+ readonly toolCallId: string;
1217
+ readonly decision: "approved" | "denied";
1218
+ readonly resolver: string;
1219
+ readonly reason: string;
1220
+ } | {
1185
1221
  readonly _tag: "ConversationCreated";
1186
1222
  readonly agentId: string;
1187
1223
  readonly definitions: {
@@ -1209,15 +1245,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1209
1245
  readonly inputTokens?: number | undefined;
1210
1246
  readonly outputTokens?: number | undefined;
1211
1247
  readonly costMicrousd?: number | undefined;
1212
- } | {
1213
- readonly _tag: "ToolCallPrepared";
1214
- readonly runId: string;
1215
- readonly turnId: string;
1216
- readonly turn: number;
1217
- readonly toolCallId: string;
1218
- readonly toolName: string;
1219
- readonly parameters: Schema.Json;
1220
- readonly parametersDigest: string;
1221
1248
  } | {
1222
1249
  readonly _tag: "ToolCallSettled";
1223
1250
  readonly runId: string;
@@ -1225,20 +1252,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1225
1252
  readonly toolName: string;
1226
1253
  readonly result: Schema.Json;
1227
1254
  readonly isFailure: boolean;
1228
- } | {
1229
- readonly _tag: "ToolCallUnknown";
1230
- readonly runId: string;
1231
- readonly turn: number;
1232
- readonly toolCallId: string;
1233
- readonly toolName: string;
1234
- readonly reason: string;
1235
- } | {
1236
- readonly _tag: "ToolCallResolved";
1237
- readonly runId: string;
1238
- readonly toolCallId: string;
1239
- readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
1240
- readonly author: string;
1241
- readonly reason: string;
1242
1255
  } | {
1243
1256
  readonly _tag: "ToolStepSettled";
1244
1257
  readonly runId: string;
@@ -1254,14 +1267,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1254
1267
  readonly toolCallId: string;
1255
1268
  readonly toolName: string;
1256
1269
  readonly parametersDigest: string;
1257
- } | {
1258
- readonly _tag: "ToolApprovalDecided";
1259
- readonly runId: string;
1260
- readonly turn: number;
1261
- readonly toolCallId: string;
1262
- readonly decision: "approved" | "denied";
1263
- readonly resolver: string;
1264
- readonly reason: string;
1265
1270
  } | {
1266
1271
  readonly _tag: "ModelResponseInterrupted";
1267
1272
  readonly runId: string;
@@ -1283,11 +1288,6 @@ declare const phase3TravelPlannerEncodedFixture: readonly {
1283
1288
  readonly _tag: "RunCompleted";
1284
1289
  readonly runId: string;
1285
1290
  readonly output: Schema.Json;
1286
- } | {
1287
- readonly _tag: "AbortRequested";
1288
- readonly submissionId: string;
1289
- readonly author: string;
1290
- readonly reason: string;
1291
1291
  } | {
1292
1292
  readonly _tag: "SubmissionSettled";
1293
1293
  readonly submissionId: string;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { McpConnectionRequest, McpConnector, McpServerIdentity, McpToolkitMismat
2
2
  import { Agent, AgentId, AgentPolicy, ConversationId, IdGenerator, RunId, SubmissionId, ToolCallId, TurnId } from "@effect-agent/core";
3
3
  import { DurableStep, DurableStepError, ToolExecutionClass } from "@effect-agent/engine";
4
4
  import { AbortCommand, AgentBindingResolver, ApprovalDecisionCommand, BatchId, CanonicalBatch, CanonicalRecordEnvelope, CertificationReport, CertificationSweepResult, CertificationTierThreeReport, CertifiedAdapterIdentity, ConversationCheckpoint, ConversationExportRequest, ConversationProjection, ConversationStore, DEFAULT_OWNERSHIP_LEASE_DURATION, DefinitionDigests, DeploymentId, Digest, DurableAgentRuntime, DurableRuntimeConfig, DurableRuntimeFailpoint, DurableRuntimeFailpointError, DurableRuntimeFailpointLocation, DurableRuntimeFailpointTestControl, DurableWorkerBinding, IdempotencyKey, LoadCheckpointRequest, ObligationThresholds, PersistedJson, Principal, ProducerId, ReconciliationCompleted, ReconciliationSafeToRetry, ReconciliationUncertain, RecordEnvelope, RecordId, ResolutionAbortSubmission, ResolutionCompletedWithResult, ResolutionNeverHappened, ResolutionSafeToRetry, SubmissionLedger, SubmissionLookupById, ToolReconciler, ToolReconcilerError, UnknownResolutionCommand, WakeScheduler, certifyPorts, childConversationIdFor, verifyConversationInvariants } from "@effect-agent/session";
5
- import { Cause, Clock, Context, DateTime, Deferred, Duration, Effect, Exit, Fiber, Layer, Option, Queue, Ref, Schema, Stream } from "effect";
5
+ import { Cause, Clock, Context, DateTime, Deferred, Duration, Effect, Exit, Fiber, JsonSchema, Layer, Option, Queue, Ref, Schema, Stream } from "effect";
6
6
  import { FastCheck, TestClock } from "effect/testing";
7
7
  import { AiError, LanguageModel, Model, Response, Tool, Toolkit } from "effect/unstable/ai";
8
8
  import { CodeExecutionHost, CodeExecutionLimits, CodeExecutionNamespace, CodeExecutionProtocolError, CodeExecutionRequest, CodeExecutionResourceUse, CodeExecutionResult, CodeExecutionTimeoutError, CodeExecutor, CodeExecutorUnsupportedError, CodeHostCall, CodeHostCallFailure, CodeHostCallLimitError, CodeHostCallResult, CodeHostCallSuccess, CodeOutputLimitError, CodeProgramFailedError, CodeSourceError, NetworkAllowlist, NetworkDisabled, SandboxImplementation } from "@effect-agent/sandbox";
@@ -2387,10 +2387,25 @@ const docsMcpIdentity = McpServerIdentity.make({
2387
2387
  version: "1.0.0"
2388
2388
  })
2389
2389
  });
2390
+ /**
2391
+ * `Tool.getJsonSchema` produces a `$ref`/`$defs`-shaped schema for
2392
+ * `FetchDocument`'s named, refined parameters type, but `McpSchema.Tool`'s
2393
+ * `inputSchema` requires a flat `{ type: "object", ... }` root — the shape a
2394
+ * real MCP server advertises on the wire. This inlines the single top-level
2395
+ * `$ref` so the derivation described above still holds byte-for-byte.
2396
+ */
2397
+ const flattenTopLevelRef = (schema) => {
2398
+ const ref = schema["$ref"];
2399
+ const defs = schema["$defs"];
2400
+ if (typeof ref !== "string" || defs === void 0) return schema;
2401
+ return JsonSchema.resolve$ref(ref, defs) ?? schema;
2402
+ };
2403
+ const fetchDocumentOutputSchema = flattenTopLevelRef(Tool.getJsonSchemaFromSchema(FetchDocument.successSchema));
2390
2404
  const discoveredFetchDocument = McpSchema.Tool.make({
2391
2405
  name: FetchDocument.name,
2392
2406
  description: "Fetch one bounded research document by its identifier.",
2393
- inputSchema: Tool.getJsonSchema(FetchDocument)
2407
+ inputSchema: flattenTopLevelRef(Tool.getJsonSchema(FetchDocument)),
2408
+ ...fetchDocumentOutputSchema.type === "object" ? { outputSchema: fetchDocumentOutputSchema } : {}
2394
2409
  });
2395
2410
  const scriptedConnector = (tools) => Layer.succeed(McpConnector)({ connect: () => Effect.acquireRelease(Effect.succeed({
2396
2411
  identity: docsMcpIdentity,