@rikalabs/akter 0.1.0-alpha.0 → 0.1.0-alpha.3
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/CHANGELOG.md +46 -3
- package/README.md +2 -2
- package/dist/actor/definition.d.ts +13 -9
- package/dist/actor/descriptor.d.ts +2 -2
- package/dist/actor/descriptor.js +4 -4
- package/dist/client/calls.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/errors/actor.d.ts +12 -42
- package/dist/errors/actor.js +13 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/members/payload.d.ts +1 -1
- package/dist/protocol/inspection.d.ts +221 -1
- package/dist/protocol/inspection.js +151 -2
- package/dist/protocol/wire.d.ts +6 -49
- package/dist/protocol/wire.js +1 -10
- package/dist/runtime/actors.d.ts +3 -0
- package/dist/runtime/adoption/backfill.js +1 -1
- package/dist/runtime/adoption/enforce.js +2 -2
- package/dist/runtime/adoption/observe.js +1 -1
- package/dist/runtime/adoption/plan.d.ts +1 -1
- package/dist/runtime/adoption/startup.js +1 -1
- package/dist/runtime/adoption/status.d.ts +1 -1
- package/dist/runtime/app.d.ts +65 -0
- package/dist/runtime/app.js +38 -0
- package/dist/runtime/connections/holder.d.ts +11 -1
- package/dist/runtime/connections/holder.js +8 -4
- package/dist/runtime/connections/streams.d.ts +4 -4
- package/dist/runtime/content/store.js +15 -11
- package/dist/runtime/database/bounded.d.ts +4 -18
- package/dist/runtime/database/bounded.js +36 -22
- package/dist/runtime/database/coordination.d.ts +12 -3
- package/dist/runtime/database/coordination.js +29 -36
- package/dist/runtime/database/migrations.d.ts +61 -29
- package/dist/runtime/database/migrations.js +375 -139
- package/dist/runtime/database/replica.d.ts +4 -1
- package/dist/runtime/database/replica.js +4 -1
- package/dist/runtime/database/schema.d.ts +13 -0
- package/dist/runtime/database/schema.js +13 -0
- package/dist/runtime/database/shards.d.ts +31 -13
- package/dist/runtime/database/shards.js +38 -26
- package/dist/runtime/entity/register.d.ts +8 -1
- package/dist/runtime/entity/register.js +58 -7
- package/dist/runtime/fleet/checks.js +4 -4
- package/dist/runtime/fleet/maintainer.d.ts +1 -1
- package/dist/runtime/fleet/maintainer.js +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/inspector/layer.d.ts +20 -0
- package/dist/runtime/inspector/layer.js +224 -5
- package/dist/runtime/inspector/queries.d.ts +54 -8
- package/dist/runtime/inspector/queries.js +84 -15
- package/dist/runtime/layer.d.ts +48 -39
- package/dist/runtime/layer.js +124 -56
- package/dist/runtime/operators/audit.d.ts +3 -0
- package/dist/runtime/operators/audit.js +6 -2
- package/dist/runtime/operators/repair.js +30 -10
- package/dist/runtime/operators/seed.js +4 -2
- package/dist/runtime/payloads/versions.d.ts +4 -4
- package/dist/runtime/payloads/versions.js +24 -15
- package/dist/runtime/queries.js +4 -2
- package/dist/runtime/registration.d.ts +5 -2
- package/dist/runtime/registration.js +3 -3
- package/dist/runtime/runner.d.ts +12 -0
- package/dist/runtime/runner.js +12 -0
- package/dist/runtime/storage/codec.d.ts +19 -7
- package/dist/runtime/storage/codec.js +23 -7
- package/dist/runtime/storage/placements.d.ts +6 -1
- package/dist/runtime/storage/placements.js +98 -6
- package/dist/runtime/storage/retention.d.ts +6 -0
- package/dist/runtime/storage/retention.js +25 -13
- package/dist/runtime/subscriptions/relay.js +47 -44
- package/dist/runtime/subscriptions/storage.d.ts +3 -2
- package/dist/runtime/subscriptions/storage.js +9 -6
- package/dist/runtime/telemetry/live.d.ts +255 -0
- package/dist/runtime/telemetry/live.js +540 -0
- package/dist/runtime/telemetry/metrics.d.ts +2 -0
- package/dist/runtime/telemetry/metrics.js +4 -1
- package/dist/runtime/telemetry/sampler.js +33 -13
- package/dist/runtime/telemetry/spans.d.ts +1 -1
- package/dist/runtime/telemetry/spans.js +1 -1
- package/dist/runtime/topology/locks.d.ts +6 -3
- package/dist/runtime/topology/locks.js +27 -4
- package/dist/runtime/turn/execute.d.ts +2 -0
- package/dist/runtime/turn/execute.js +5 -2
- package/dist/runtime/turn/pipeline.d.ts +5 -12
- package/dist/runtime/turn/pipeline.js +11 -11
- package/dist/runtime/turn/relay.d.ts +13 -3
- package/dist/runtime/turn/relay.js +27 -14
- package/dist/runtime/turn/rows.js +4 -4
- package/dist/runtime/workflows/compatibility.d.ts +1 -1
- package/dist/runtime/workflows/compatibility.js +85 -31
- package/dist/runtime/workflows/engine.js +20 -17
- package/dist/serve/layer.js +3 -2
- package/dist/tables/owned.d.ts +1 -1
- package/dist/tables/owned.js +1 -1
- package/dist/testing/actor-test.d.ts +2 -24
- package/dist/testing/actor-test.js +1 -27
- package/dist/testing/index.d.ts +0 -12
- package/dist/testing/index.js +0 -6
- package/package.json +1 -1
- package/dist/runtime/database/neki/migrations.d.ts +0 -31
- package/dist/runtime/database/neki/migrations.js +0 -276
- package/dist/runtime/database/neki/session.d.ts +0 -23
- package/dist/runtime/database/neki/session.js +0 -31
- package/dist/testing/cluster.d.ts +0 -93
- package/dist/testing/cluster.js +0 -296
- package/dist/testing/conformance/access.d.ts +0 -5
- package/dist/testing/conformance/access.js +0 -531
- package/dist/testing/conformance/admission.d.ts +0 -11
- package/dist/testing/conformance/admission.js +0 -182
- package/dist/testing/conformance/adoption.d.ts +0 -2
- package/dist/testing/conformance/adoption.js +0 -1019
- package/dist/testing/conformance/assertions.d.ts +0 -202
- package/dist/testing/conformance/assertions.js +0 -849
- package/dist/testing/conformance/batches.d.ts +0 -41
- package/dist/testing/conformance/batches.js +0 -388
- package/dist/testing/conformance/blobs.d.ts +0 -14
- package/dist/testing/conformance/blobs.js +0 -405
- package/dist/testing/conformance/capacity.d.ts +0 -8
- package/dist/testing/conformance/capacity.js +0 -433
- package/dist/testing/conformance/client.d.ts +0 -5
- package/dist/testing/conformance/client.js +0 -719
- package/dist/testing/conformance/cold-serve.d.ts +0 -16
- package/dist/testing/conformance/cold-serve.js +0 -254
- package/dist/testing/conformance/connections/actors.d.ts +0 -1143
- package/dist/testing/conformance/connections/actors.js +0 -180
- package/dist/testing/conformance/connections/harness.d.ts +0 -1754
- package/dist/testing/conformance/connections/harness.js +0 -142
- package/dist/testing/conformance/connections/holders.d.ts +0 -4
- package/dist/testing/conformance/connections/holders.js +0 -165
- package/dist/testing/conformance/connections/lifecycle.d.ts +0 -4
- package/dist/testing/conformance/connections/lifecycle.js +0 -113
- package/dist/testing/conformance/connections/limits.d.ts +0 -4
- package/dist/testing/conformance/connections/limits.js +0 -127
- package/dist/testing/conformance/connections/reauthorization.d.ts +0 -4
- package/dist/testing/conformance/connections/reauthorization.js +0 -170
- package/dist/testing/conformance/connections/resync.d.ts +0 -4
- package/dist/testing/conformance/connections/resync.js +0 -360
- package/dist/testing/conformance/connections/takeover.d.ts +0 -4
- package/dist/testing/conformance/connections/takeover.js +0 -287
- package/dist/testing/conformance/connections.d.ts +0 -4
- package/dist/testing/conformance/connections.js +0 -15
- package/dist/testing/conformance/content-blobs.d.ts +0 -16
- package/dist/testing/conformance/content-blobs.js +0 -534
- package/dist/testing/conformance/counter.d.ts +0 -16
- package/dist/testing/conformance/counter.js +0 -813
- package/dist/testing/conformance/cron.d.ts +0 -5
- package/dist/testing/conformance/cron.js +0 -665
- package/dist/testing/conformance/drain.d.ts +0 -26
- package/dist/testing/conformance/drain.js +0 -540
- package/dist/testing/conformance/effect-control.d.ts +0 -38
- package/dist/testing/conformance/effect-control.js +0 -1059
- package/dist/testing/conformance/effects.d.ts +0 -23
- package/dist/testing/conformance/effects.js +0 -432
- package/dist/testing/conformance/events.d.ts +0 -28
- package/dist/testing/conformance/events.js +0 -335
- package/dist/testing/conformance/export.d.ts +0 -2
- package/dist/testing/conformance/export.js +0 -368
- package/dist/testing/conformance/fleet.d.ts +0 -444
- package/dist/testing/conformance/fleet.js +0 -1009
- package/dist/testing/conformance/groups.d.ts +0 -7
- package/dist/testing/conformance/groups.js +0 -353
- package/dist/testing/conformance/heap.d.ts +0 -3
- package/dist/testing/conformance/heap.js +0 -149
- package/dist/testing/conformance/http.d.ts +0 -2809
- package/dist/testing/conformance/http.js +0 -1234
- package/dist/testing/conformance/inspection-views.d.ts +0 -8
- package/dist/testing/conformance/inspection-views.js +0 -272
- package/dist/testing/conformance/inspector.d.ts +0 -7
- package/dist/testing/conformance/inspector.js +0 -650
- package/dist/testing/conformance/mint.d.ts +0 -58
- package/dist/testing/conformance/mint.js +0 -692
- package/dist/testing/conformance/multi-runner.d.ts +0 -8
- package/dist/testing/conformance/multi-runner.js +0 -403
- package/dist/testing/conformance/neki/plan.d.ts +0 -19
- package/dist/testing/conformance/neki/plan.js +0 -30
- package/dist/testing/conformance/observability.d.ts +0 -3
- package/dist/testing/conformance/observability.js +0 -343
- package/dist/testing/conformance/offline.d.ts +0 -4
- package/dist/testing/conformance/offline.js +0 -474
- package/dist/testing/conformance/operator-harness.d.ts +0 -57
- package/dist/testing/conformance/operator-harness.js +0 -78
- package/dist/testing/conformance/operator.d.ts +0 -3
- package/dist/testing/conformance/operator.js +0 -379
- package/dist/testing/conformance/outbox-cross-shard.d.ts +0 -14
- package/dist/testing/conformance/outbox-cross-shard.js +0 -160
- package/dist/testing/conformance/outbox.d.ts +0 -36
- package/dist/testing/conformance/outbox.js +0 -437
- package/dist/testing/conformance/payload-migrations.d.ts +0 -3
- package/dist/testing/conformance/payload-migrations.js +0 -612
- package/dist/testing/conformance/pipeline.d.ts +0 -3
- package/dist/testing/conformance/pipeline.js +0 -1040
- package/dist/testing/conformance/placement.d.ts +0 -22
- package/dist/testing/conformance/placement.js +0 -539
- package/dist/testing/conformance/platform.d.ts +0 -40
- package/dist/testing/conformance/platform.js +0 -101
- package/dist/testing/conformance/progress.d.ts +0 -39
- package/dist/testing/conformance/progress.js +0 -666
- package/dist/testing/conformance/properties.d.ts +0 -6
- package/dist/testing/conformance/properties.js +0 -295
- package/dist/testing/conformance/protocols.d.ts +0 -4
- package/dist/testing/conformance/protocols.js +0 -618
- package/dist/testing/conformance/provider/advertise.d.ts +0 -21
- package/dist/testing/conformance/provider/advertise.js +0 -44
- package/dist/testing/conformance/read-your-writes.d.ts +0 -20
- package/dist/testing/conformance/read-your-writes.js +0 -192
- package/dist/testing/conformance/reducers.d.ts +0 -8
- package/dist/testing/conformance/reducers.js +0 -258
- package/dist/testing/conformance/relay.d.ts +0 -42
- package/dist/testing/conformance/relay.js +0 -1115
- package/dist/testing/conformance/restore.d.ts +0 -43
- package/dist/testing/conformance/restore.js +0 -341
- package/dist/testing/conformance/retention.d.ts +0 -14
- package/dist/testing/conformance/retention.js +0 -463
- package/dist/testing/conformance/rls.d.ts +0 -24
- package/dist/testing/conformance/rls.js +0 -576
- package/dist/testing/conformance/simulation.d.ts +0 -31
- package/dist/testing/conformance/simulation.js +0 -167
- package/dist/testing/conformance/single-shard.d.ts +0 -2
- package/dist/testing/conformance/single-shard.js +0 -125
- package/dist/testing/conformance/singleton.d.ts +0 -3
- package/dist/testing/conformance/singleton.js +0 -293
- package/dist/testing/conformance/statements.d.ts +0 -60
- package/dist/testing/conformance/statements.js +0 -108
- package/dist/testing/conformance/streams.d.ts +0 -7
- package/dist/testing/conformance/streams.js +0 -280
- package/dist/testing/conformance/subscriptions/access.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/access.js +0 -98
- package/dist/testing/conformance/subscriptions/actors.d.ts +0 -4910
- package/dist/testing/conformance/subscriptions/actors.js +0 -372
- package/dist/testing/conformance/subscriptions/cluster.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/cluster.js +0 -89
- package/dist/testing/conformance/subscriptions/delivery.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/delivery.js +0 -253
- package/dist/testing/conformance/subscriptions/deploys.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/deploys.js +0 -162
- package/dist/testing/conformance/subscriptions/epochs.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/epochs.js +0 -169
- package/dist/testing/conformance/subscriptions/failures.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/failures.js +0 -108
- package/dist/testing/conformance/subscriptions/feeds.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/feeds.js +0 -218
- package/dist/testing/conformance/subscriptions/harness.d.ts +0 -124
- package/dist/testing/conformance/subscriptions/harness.js +0 -143
- package/dist/testing/conformance/subscriptions/operator.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/operator.js +0 -128
- package/dist/testing/conformance/subscriptions/retention.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/retention.js +0 -288
- package/dist/testing/conformance/subscriptions/routing.d.ts +0 -4
- package/dist/testing/conformance/subscriptions/routing.js +0 -179
- package/dist/testing/conformance/subscriptions.d.ts +0 -4
- package/dist/testing/conformance/subscriptions.js +0 -19
- package/dist/testing/conformance/tables.d.ts +0 -125
- package/dist/testing/conformance/tables.js +0 -664
- package/dist/testing/conformance/transports/actors.d.ts +0 -1907
- package/dist/testing/conformance/transports/actors.js +0 -163
- package/dist/testing/conformance/transports/client.d.ts +0 -3
- package/dist/testing/conformance/transports/client.js +0 -237
- package/dist/testing/conformance/transports/feeds.d.ts +0 -3
- package/dist/testing/conformance/transports/feeds.js +0 -232
- package/dist/testing/conformance/transports/harness.d.ts +0 -93
- package/dist/testing/conformance/transports/harness.js +0 -84
- package/dist/testing/conformance/transports/streams.d.ts +0 -3
- package/dist/testing/conformance/transports/streams.js +0 -96
- package/dist/testing/conformance/transports/websocket.d.ts +0 -3
- package/dist/testing/conformance/transports/websocket.js +0 -384
- package/dist/testing/conformance/transports/wire.d.ts +0 -141
- package/dist/testing/conformance/transports/wire.js +0 -204
- package/dist/testing/conformance/transports.d.ts +0 -3
- package/dist/testing/conformance/transports.js +0 -11
- package/dist/testing/conformance/watch.d.ts +0 -59
- package/dist/testing/conformance/watch.js +0 -879
- package/dist/testing/conformance/workflow-engine.d.ts +0 -97
- package/dist/testing/conformance/workflow-engine.js +0 -253
- package/dist/testing/conformance/workflow-versions.d.ts +0 -3
- package/dist/testing/conformance/workflow-versions.js +0 -545
- package/dist/testing/conformance/workflows/access.d.ts +0 -4
- package/dist/testing/conformance/workflows/access.js +0 -147
- package/dist/testing/conformance/workflows/actors.d.ts +0 -2317
- package/dist/testing/conformance/workflows/actors.js +0 -305
- package/dist/testing/conformance/workflows/basics.d.ts +0 -4
- package/dist/testing/conformance/workflows/basics.js +0 -144
- package/dist/testing/conformance/workflows/engine.d.ts +0 -4
- package/dist/testing/conformance/workflows/engine.js +0 -80
- package/dist/testing/conformance/workflows/guards.d.ts +0 -4
- package/dist/testing/conformance/workflows/guards.js +0 -172
- package/dist/testing/conformance/workflows/harness.d.ts +0 -14
- package/dist/testing/conformance/workflows/harness.js +0 -44
- package/dist/testing/conformance/workflows/recovery.d.ts +0 -4
- package/dist/testing/conformance/workflows/recovery.js +0 -181
- package/dist/testing/conformance/workflows/starts.d.ts +0 -4
- package/dist/testing/conformance/workflows/starts.js +0 -57
- package/dist/testing/conformance/workflows/suspension.d.ts +0 -4
- package/dist/testing/conformance/workflows/suspension.js +0 -106
- package/dist/testing/conformance/workflows/waits.d.ts +0 -4
- package/dist/testing/conformance/workflows/waits.js +0 -284
- package/dist/testing/conformance/workflows.d.ts +0 -4
- package/dist/testing/conformance/workflows.js +0 -19
- package/dist/testing/conformance.d.ts +0 -330
- package/dist/testing/conformance.js +0 -364
- package/dist/testing/foundation.d.ts +0 -41
- package/dist/testing/foundation.js +0 -517
- package/dist/testing/simulate-cluster.d.ts +0 -112
- package/dist/testing/simulate-cluster.js +0 -257
- package/dist/testing/simulate.d.ts +0 -90
- package/dist/testing/simulate.js +0 -127
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
import { Cause, Effect, Exit, Layer, Schema } from "effect";
|
|
2
|
-
import { Base64 } from "effect/encoding";
|
|
3
|
-
import { HttpRouter } from "effect/http";
|
|
4
|
-
import { Unauthorized } from "../../index.js";
|
|
5
|
-
import { InvalidInput } from "../../errors/actor.js";
|
|
6
|
-
import { CommandConflict, CommandExpired } from "../../errors/actor.js";
|
|
7
|
-
import { InternalActors } from "../../runtime/actors.js";
|
|
8
|
-
import { MCP_VERSION } from "../../serve/mcp/endpoint.js";
|
|
9
|
-
import { envelope, HttpLobby, HttpRoom, isDefectBody, reasonOf, receipts, runs, serveHttp, tenantOf, tokens, httpSuite, } from "./http.js";
|
|
10
|
-
import { serve } from "../../serve/layer.js";
|
|
11
|
-
const options = { openapi: { path: "/openapi.json" }, mcp: { path: "/mcp" } };
|
|
12
|
-
const META = {
|
|
13
|
-
"io.modelcontextprotocol/protocolVersion": MCP_VERSION,
|
|
14
|
-
"io.modelcontextprotocol/clientCapabilities": {},
|
|
15
|
-
};
|
|
16
|
-
const decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Json));
|
|
17
|
-
const Content = Schema.Struct({
|
|
18
|
-
"application/json": Schema.optionalKey(Schema.Struct({ schema: Schema.Json })),
|
|
19
|
-
});
|
|
20
|
-
const Spec = Schema.Struct({
|
|
21
|
-
paths: Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Struct({
|
|
22
|
-
operationId: Schema.String,
|
|
23
|
-
"x-durable-transport": Schema.optionalKey(Schema.String),
|
|
24
|
-
parameters: Schema.optionalKey(Schema.Array(Schema.Struct({ name: Schema.String, in: Schema.String }))),
|
|
25
|
-
requestBody: Schema.optionalKey(Schema.Struct({ content: Content })),
|
|
26
|
-
responses: Schema.Struct({
|
|
27
|
-
"200": Schema.optionalKey(Schema.Struct({ content: Schema.optionalKey(Content) })),
|
|
28
|
-
}),
|
|
29
|
-
}))),
|
|
30
|
-
components: Schema.Struct({ schemas: Schema.Record(Schema.String, Schema.Json) }),
|
|
31
|
-
});
|
|
32
|
-
const ToolList = Schema.Struct({
|
|
33
|
-
result: Schema.Struct({
|
|
34
|
-
resultType: Schema.String,
|
|
35
|
-
ttlMs: Schema.Int,
|
|
36
|
-
cacheScope: Schema.String,
|
|
37
|
-
tools: Schema.Array(Schema.Struct({
|
|
38
|
-
name: Schema.String,
|
|
39
|
-
description: Schema.String,
|
|
40
|
-
inputSchema: Schema.Struct({
|
|
41
|
-
type: Schema.String,
|
|
42
|
-
properties: Schema.Record(Schema.String, Schema.Json),
|
|
43
|
-
required: Schema.Array(Schema.String),
|
|
44
|
-
additionalProperties: Schema.Boolean,
|
|
45
|
-
$defs: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),
|
|
46
|
-
}),
|
|
47
|
-
outputSchema: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),
|
|
48
|
-
annotations: Schema.Struct({
|
|
49
|
-
readOnlyHint: Schema.Boolean,
|
|
50
|
-
idempotentHint: Schema.Boolean,
|
|
51
|
-
}),
|
|
52
|
-
})),
|
|
53
|
-
}),
|
|
54
|
-
});
|
|
55
|
-
const ToolReply = Schema.Struct({
|
|
56
|
-
result: Schema.Struct({
|
|
57
|
-
resultType: Schema.Literal("complete"),
|
|
58
|
-
content: Schema.Array(Schema.Struct({ type: Schema.Literal("text"), text: Schema.String })),
|
|
59
|
-
isError: Schema.optionalKey(Schema.Boolean),
|
|
60
|
-
structuredContent: Schema.optionalKey(Schema.Json),
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
63
|
-
const RpcError = Schema.Struct({
|
|
64
|
-
error: Schema.Struct({
|
|
65
|
-
code: Schema.Int,
|
|
66
|
-
message: Schema.String,
|
|
67
|
-
data: Schema.optionalKey(Schema.Json),
|
|
68
|
-
}),
|
|
69
|
-
});
|
|
70
|
-
const rpc = (server, call) => server.send("/mcp", {
|
|
71
|
-
token: call.token,
|
|
72
|
-
body: {
|
|
73
|
-
jsonrpc: "2.0",
|
|
74
|
-
id: 1,
|
|
75
|
-
method: call.method,
|
|
76
|
-
params: Object.assign({}, call.params, { _meta: META }),
|
|
77
|
-
},
|
|
78
|
-
headers: { "mcp-protocol-version": MCP_VERSION, "mcp-method": call.method, ...call.headers },
|
|
79
|
-
});
|
|
80
|
-
/** One `tools/call`, with its text content decoded as the JSON it carries. */
|
|
81
|
-
const callTool = Effect.fnUntraced(function* (server, token, name, args) {
|
|
82
|
-
const reply = yield* rpc(server, {
|
|
83
|
-
token,
|
|
84
|
-
method: "tools/call",
|
|
85
|
-
params: { name, arguments: args },
|
|
86
|
-
headers: { "mcp-name": name },
|
|
87
|
-
});
|
|
88
|
-
const { result } = yield* Schema.decodeUnknownEffect(ToolReply)(reply.body).pipe(Effect.orDie);
|
|
89
|
-
const text = result.content[0]?.text;
|
|
90
|
-
return {
|
|
91
|
-
status: reply.status,
|
|
92
|
-
isError: result.isError === true,
|
|
93
|
-
empty: result.content.length === 0,
|
|
94
|
-
text,
|
|
95
|
-
body: text === undefined ? undefined : yield* decodeJson(text).pipe(Effect.orDie),
|
|
96
|
-
structured: result.structuredContent,
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
const rpcError = Effect.fnUntraced(function* (reply) {
|
|
100
|
-
const { error } = yield* Schema.decodeUnknownEffect(RpcError)(reply.body).pipe(Effect.orDie);
|
|
101
|
-
return error;
|
|
102
|
-
});
|
|
103
|
-
const mint = Effect.fnUntraced(function* (server, token) {
|
|
104
|
-
const minted = yield* callTool(server, token, "durable.commandIds", {});
|
|
105
|
-
return yield* Schema.decodeUnknownEffect(Schema.Struct({ commandId: Schema.String }))(minted.body).pipe(Effect.map(({ commandId }) => commandId), Effect.orDie);
|
|
106
|
-
});
|
|
107
|
-
const mcpConformanceOptions = options;
|
|
108
|
-
export const protocolsConformance = [
|
|
109
|
-
{
|
|
110
|
-
name: "lists every public command, reducer, and query as a tool with its OpenAPI operation's parameters and schemas, and no internal member",
|
|
111
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
112
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
113
|
-
const token = `${yield* tenantOf}:alice`;
|
|
114
|
-
const spec = yield* server.send("/openapi.json", { method: "GET" }).pipe(Effect.flatMap((reply) => Schema.decodeUnknownEffect(Spec)(reply.body)), Effect.orDie);
|
|
115
|
-
const listed = yield* rpc(server, { token, method: "tools/list" }).pipe(Effect.flatMap((reply) => Schema.decodeUnknownEffect(ToolList)(reply.body)), Effect.orDie);
|
|
116
|
-
expect(listed.result).toMatchObject({ resultType: "complete", ttlMs: 0 });
|
|
117
|
-
expect(listed.result.cacheScope).toBe("public");
|
|
118
|
-
const operations = Object.entries(spec.paths).flatMap(([path, methods]) => methods["post"] !== undefined &&
|
|
119
|
-
methods["post"]["x-durable-transport"] === undefined &&
|
|
120
|
-
(path.startsWith("/actors/") || methods["post"].operationId === "durable.commandIds")
|
|
121
|
-
? [{ path, operation: methods["post"] }]
|
|
122
|
-
: []);
|
|
123
|
-
expect(listed.result.tools.map((tool) => tool.name)).toEqual(operations.map(({ operation }) => operation.operationId));
|
|
124
|
-
expect(listed.result.tools.map((tool) => tool.name)).not.toContain("HttpRoom.Secret");
|
|
125
|
-
for (const { path, operation } of operations) {
|
|
126
|
-
const tool = listed.result.tools.find((candidate) => candidate.name === operation.operationId);
|
|
127
|
-
const parameters = operation.parameters ?? [];
|
|
128
|
-
const body = operation.requestBody?.content["application/json"]?.schema;
|
|
129
|
-
const success = operation.responses["200"]?.content?.["application/json"]?.schema;
|
|
130
|
-
expect(Object.keys(tool.inputSchema.properties).sort()).toEqual([
|
|
131
|
-
...(path.includes("{id}") ? ["id"] : []),
|
|
132
|
-
...(parameters.some((parameter) => parameter.name === "idempotency-key")
|
|
133
|
-
? ["commandId"]
|
|
134
|
-
: []),
|
|
135
|
-
...(body === undefined ? [] : ["input"]),
|
|
136
|
-
].sort());
|
|
137
|
-
expect(tool.inputSchema.type).toBe("object");
|
|
138
|
-
expect(tool.inputSchema.additionalProperties).toBe(false);
|
|
139
|
-
expect(tool.inputSchema.required).toEqual([
|
|
140
|
-
...(path.includes("{id}") ? ["id"] : []),
|
|
141
|
-
...(parameters.some((parameter) => parameter.name === "idempotency-key")
|
|
142
|
-
? ["commandId"]
|
|
143
|
-
: []),
|
|
144
|
-
...(body === undefined ? [] : ["input"]),
|
|
145
|
-
]);
|
|
146
|
-
if (body !== undefined && tool.inputSchema.$defs === undefined)
|
|
147
|
-
expect(tool.inputSchema.properties["input"]).toEqual(body);
|
|
148
|
-
if (success !== undefined &&
|
|
149
|
-
tool.outputSchema !== undefined &&
|
|
150
|
-
tool.outputSchema["$defs"] === undefined)
|
|
151
|
-
expect(tool.outputSchema).toEqual(success);
|
|
152
|
-
expect(tool.outputSchema === undefined).toBe(success === undefined);
|
|
153
|
-
expect(tool.annotations.readOnlyHint).toBe(path.endsWith("/Count") ||
|
|
154
|
-
path.endsWith("/Peek") ||
|
|
155
|
-
path.endsWith("/Snapshot") ||
|
|
156
|
-
path.endsWith("/Level"));
|
|
157
|
-
}
|
|
158
|
-
const named = listed.result.tools.find((tool) => tool.name === "HttpRoom.Post");
|
|
159
|
-
expect(named.inputSchema.required).toEqual(["id", "commandId", "input"]);
|
|
160
|
-
expect(named.annotations).toEqual({ readOnlyHint: false, idempotentHint: true });
|
|
161
|
-
const lobby = listed.result.tools.find((tool) => tool.name === "HttpLobby.Join");
|
|
162
|
-
expect(lobby.inputSchema.required).toEqual(["commandId"]);
|
|
163
|
-
const mintTool = listed.result.tools.find((tool) => tool.name === "durable.commandIds");
|
|
164
|
-
expect(mintTool.inputSchema.properties).toEqual({});
|
|
165
|
-
expect(mintTool.annotations).toEqual({ readOnlyHint: false, idempotentHint: false });
|
|
166
|
-
})),
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: "answers server/discover with the supported revision and the tools capability",
|
|
170
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
171
|
-
const server = yield* serveHttp({ mcp: { path: "/mcp", name: "rooms", version: "7" } });
|
|
172
|
-
const token = `${yield* tenantOf}:alice`;
|
|
173
|
-
const reply = yield* rpc(server, { token, method: "server/discover" });
|
|
174
|
-
expect(reply.status).toBe(200);
|
|
175
|
-
expect(reply.body).toMatchObject({
|
|
176
|
-
jsonrpc: "2.0",
|
|
177
|
-
id: 1,
|
|
178
|
-
result: {
|
|
179
|
-
resultType: "complete",
|
|
180
|
-
supportedVersions: [MCP_VERSION],
|
|
181
|
-
capabilities: { tools: {} },
|
|
182
|
-
cacheScope: "public",
|
|
183
|
-
_meta: { "io.modelcontextprotocol/serverInfo": { name: "rooms", version: "7" } },
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
})),
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: "runs a command once per command id across MCP and HTTP, and refuses a reused id with other input on either",
|
|
190
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
191
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
192
|
-
const tenant = yield* tenantOf;
|
|
193
|
-
const token = `${tenant}:alice`;
|
|
194
|
-
const commandId = yield* mint(server, token);
|
|
195
|
-
const before = runs.count;
|
|
196
|
-
const first = yield* callTool(server, token, "HttpRoom.Post", {
|
|
197
|
-
id: "shared",
|
|
198
|
-
commandId,
|
|
199
|
-
input: { text: "a" },
|
|
200
|
-
});
|
|
201
|
-
expect(first).toMatchObject({ isError: false, body: 1, structured: 1 });
|
|
202
|
-
expect(runs.count).toBe(before + 1);
|
|
203
|
-
const overHttp = yield* server.send("/actors/HttpRoom/shared/Post", {
|
|
204
|
-
token,
|
|
205
|
-
key: commandId,
|
|
206
|
-
body: { text: "a" },
|
|
207
|
-
});
|
|
208
|
-
expect(overHttp).toMatchObject({ status: 200, body: 1 });
|
|
209
|
-
const again = yield* callTool(server, token, "HttpRoom.Post", {
|
|
210
|
-
id: "shared",
|
|
211
|
-
commandId,
|
|
212
|
-
input: { text: "a" },
|
|
213
|
-
});
|
|
214
|
-
expect(again).toMatchObject({ isError: false, body: 1 });
|
|
215
|
-
expect(runs.count).toBe(before + 1);
|
|
216
|
-
expect(yield* receipts(tenant, "HttpRoom", "shared")).toBe(1);
|
|
217
|
-
const conflict = yield* callTool(server, token, "HttpRoom.Post", {
|
|
218
|
-
id: "shared",
|
|
219
|
-
commandId,
|
|
220
|
-
input: { text: "b" },
|
|
221
|
-
});
|
|
222
|
-
const conflictOverHttp = yield* server.send("/actors/HttpRoom/shared/Post", {
|
|
223
|
-
token,
|
|
224
|
-
key: commandId,
|
|
225
|
-
body: { text: "b" },
|
|
226
|
-
});
|
|
227
|
-
expect(conflict.isError).toBe(true);
|
|
228
|
-
expect(conflict.body).toEqual(yield* envelope(CommandConflict.make({ commandId })));
|
|
229
|
-
expect(conflict.body).toEqual(conflictOverHttp.body);
|
|
230
|
-
expect(runs.count).toBe(before + 1);
|
|
231
|
-
})),
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: "answers declared and framework failures with the same bodies as HTTP, and never mints a replacement for an expired id",
|
|
235
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
236
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
237
|
-
const actors = yield* InternalActors;
|
|
238
|
-
const tenant = yield* tenantOf;
|
|
239
|
-
const token = `${tenant}:alice`;
|
|
240
|
-
for (const [text, status] of [
|
|
241
|
-
["full", 422],
|
|
242
|
-
["closed", 423],
|
|
243
|
-
]) {
|
|
244
|
-
const overHttp = yield* server.send(`/actors/HttpRoom/${text}-http/Post`, {
|
|
245
|
-
token,
|
|
246
|
-
key: yield* server.mint(),
|
|
247
|
-
body: { text },
|
|
248
|
-
});
|
|
249
|
-
const overMcp = yield* callTool(server, token, "HttpRoom.Post", {
|
|
250
|
-
id: `${text}-mcp`,
|
|
251
|
-
commandId: yield* mint(server, token),
|
|
252
|
-
input: { text },
|
|
253
|
-
});
|
|
254
|
-
expect(overHttp.status).toBe(status);
|
|
255
|
-
expect(overMcp.isError).toBe(true);
|
|
256
|
-
expect(overMcp.body).toEqual(overHttp.body);
|
|
257
|
-
}
|
|
258
|
-
const before = runs.count;
|
|
259
|
-
const expired = yield* server.mint(-actors.retryWindowMs - 1);
|
|
260
|
-
const cases = [
|
|
261
|
-
{ id: "failures", commandId: expired, input: { text: "a" } },
|
|
262
|
-
{ id: "failures", commandId: "v1.not-an-id", input: { text: "a" } },
|
|
263
|
-
{ id: "failures", commandId: yield* server.mint(60 * 60_000), input: { text: "a" } },
|
|
264
|
-
{ id: "failures", commandId: yield* server.mint(), input: { text: 5 } },
|
|
265
|
-
{ id: "failures", commandId: yield* server.mint(), input: {} },
|
|
266
|
-
];
|
|
267
|
-
for (const arguments_ of cases) {
|
|
268
|
-
const overHttp = yield* server.send(`/actors/HttpRoom/${arguments_.id}/Post`, {
|
|
269
|
-
token,
|
|
270
|
-
key: arguments_.commandId,
|
|
271
|
-
body: arguments_.input,
|
|
272
|
-
});
|
|
273
|
-
const overMcp = yield* callTool(server, token, "HttpRoom.Post", arguments_);
|
|
274
|
-
expect(overHttp.status >= 400).toBe(true);
|
|
275
|
-
expect(overMcp.isError).toBe(true);
|
|
276
|
-
expect(overMcp.body).toEqual(overHttp.body);
|
|
277
|
-
}
|
|
278
|
-
const expiredOverMcp = yield* callTool(server, token, "HttpRoom.Post", cases[0]);
|
|
279
|
-
expect(expiredOverMcp.body).toEqual(yield* envelope(CommandExpired.make({ commandId: expired })));
|
|
280
|
-
const withoutId = yield* callTool(server, token, "HttpRoom.Post", {
|
|
281
|
-
id: "failures",
|
|
282
|
-
input: { text: "a" },
|
|
283
|
-
});
|
|
284
|
-
const withoutKey = yield* server.send("/actors/HttpRoom/failures/Post", {
|
|
285
|
-
token,
|
|
286
|
-
body: { text: "a" },
|
|
287
|
-
});
|
|
288
|
-
expect(withoutId.body).toEqual(withoutKey.body);
|
|
289
|
-
expect(yield* reasonOf(withoutId.body)).toEqual({
|
|
290
|
-
tag: "InvalidInput",
|
|
291
|
-
code: "missing_command_id",
|
|
292
|
-
});
|
|
293
|
-
expect(runs.count).toBe(before);
|
|
294
|
-
expect(yield* receipts(tenant, "HttpRoom", "failures")).toBe(0);
|
|
295
|
-
})),
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
name: "answers a defect with the opaque Defect body, and a caller's own principal is the only one a tool call runs as",
|
|
299
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
300
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
301
|
-
const tenant = yield* tenantOf;
|
|
302
|
-
const crash = yield* callTool(server, `${tenant}:alice`, "HttpRoom.Crash", {
|
|
303
|
-
id: "defect",
|
|
304
|
-
commandId: yield* mint(server, `${tenant}:alice`),
|
|
305
|
-
});
|
|
306
|
-
expect(crash.isError).toBe(true);
|
|
307
|
-
expect(isDefectBody(crash.body)).toBe(true);
|
|
308
|
-
expect(Object.keys(crash.body).sort()).toEqual(["_tag", "traceId"]);
|
|
309
|
-
expect(crash.text?.includes("secret")).toBe(false);
|
|
310
|
-
expect(yield* receipts(tenant, "HttpRoom", "defect")).toBe(0);
|
|
311
|
-
for (const subject of ["alice", "bob"]) {
|
|
312
|
-
const token = `${tenant}:${subject}`;
|
|
313
|
-
const whoami = yield* callTool(server, token, "HttpRoom.Whoami", {
|
|
314
|
-
id: "principals",
|
|
315
|
-
commandId: yield* mint(server, token),
|
|
316
|
-
});
|
|
317
|
-
expect(whoami.body).toBe(`${tenant}/${subject}`);
|
|
318
|
-
}
|
|
319
|
-
const smuggled = yield* callTool(server, `${tenant}:alice`, "HttpRoom.Whoami", {
|
|
320
|
-
id: "principals",
|
|
321
|
-
commandId: yield* mint(server, `${tenant}:alice`),
|
|
322
|
-
tenant: "other",
|
|
323
|
-
});
|
|
324
|
-
expect(smuggled.isError).toBe(true);
|
|
325
|
-
expect(smuggled.body).toEqual(yield* envelope(InvalidInput.make({
|
|
326
|
-
code: "decode",
|
|
327
|
-
issues: [{ path: "tenant", message: "Unexpected key" }],
|
|
328
|
-
})));
|
|
329
|
-
})),
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
name: "fails missing, invalid, and expired credentials with the HTTP body before any JSON-RPC, and applies authorize to tool calls",
|
|
333
|
-
run: ({ expect, environment, access }) => environment.run(Effect.gen(function* () {
|
|
334
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
335
|
-
const tenant = yield* tenantOf;
|
|
336
|
-
const token = `${tenant}:alice`;
|
|
337
|
-
const before = runs.count;
|
|
338
|
-
for (const [credential, code] of [
|
|
339
|
-
[undefined, "missing_credentials"],
|
|
340
|
-
["no-colon", "invalid_credentials"],
|
|
341
|
-
["expired", "expired"],
|
|
342
|
-
]) {
|
|
343
|
-
const reply = yield* rpc(server, { token: credential, method: "server/discover" });
|
|
344
|
-
expect(reply.status).toBe(401);
|
|
345
|
-
expect(reply.headers.get("www-authenticate")).toBe("Bearer");
|
|
346
|
-
expect(reply.body).toEqual(yield* envelope(Unauthorized.make({ code })));
|
|
347
|
-
}
|
|
348
|
-
expect(runs.count).toBe(before);
|
|
349
|
-
const commandId = yield* mint(server, token);
|
|
350
|
-
access.denied.add("Post");
|
|
351
|
-
access.denied.add("Count");
|
|
352
|
-
const denied = yield* Effect.gen(function* () {
|
|
353
|
-
const command = yield* callTool(server, token, "HttpRoom.Post", {
|
|
354
|
-
id: "denied",
|
|
355
|
-
commandId,
|
|
356
|
-
input: { text: "a" },
|
|
357
|
-
});
|
|
358
|
-
const overHttp = yield* server.send("/actors/HttpRoom/denied/Post", {
|
|
359
|
-
token,
|
|
360
|
-
key: commandId,
|
|
361
|
-
body: { text: "a" },
|
|
362
|
-
});
|
|
363
|
-
const query = yield* callTool(server, token, "HttpRoom.Count", { id: "denied" });
|
|
364
|
-
return { command, overHttp, query };
|
|
365
|
-
}).pipe(Effect.ensuring(Effect.sync(() => {
|
|
366
|
-
access.denied.clear();
|
|
367
|
-
})));
|
|
368
|
-
const accessDenied = yield* envelope(Unauthorized.make({ code: "access_denied" }));
|
|
369
|
-
expect(denied.command).toMatchObject({ isError: true, body: accessDenied });
|
|
370
|
-
expect(denied.overHttp.body).toEqual(accessDenied);
|
|
371
|
-
expect(denied.query).toMatchObject({ isError: true, body: accessDenied });
|
|
372
|
-
expect(runs.count).toBe(before);
|
|
373
|
-
expect(yield* receipts(tenant, "HttpRoom", "denied")).toBe(0);
|
|
374
|
-
})),
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
name: "refuses a request whose protocol headers are missing or disagree with its body, an unsupported revision, or an unknown method, tool, or internal member, before any turn",
|
|
378
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
379
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
380
|
-
const tenant = yield* tenantOf;
|
|
381
|
-
const token = `${tenant}:alice`;
|
|
382
|
-
const before = runs.count;
|
|
383
|
-
const call = (name, extra = {}) => ({
|
|
384
|
-
jsonrpc: "2.0",
|
|
385
|
-
id: 1,
|
|
386
|
-
method: "tools/call",
|
|
387
|
-
params: Object.assign({ name, arguments: { id: "headers" }, _meta: META }, extra),
|
|
388
|
-
});
|
|
389
|
-
const headers = {
|
|
390
|
-
"mcp-protocol-version": MCP_VERSION,
|
|
391
|
-
"mcp-method": "tools/call",
|
|
392
|
-
"mcp-name": "HttpRoom.Count",
|
|
393
|
-
};
|
|
394
|
-
const refusals = [
|
|
395
|
-
[{ "mcp-method": headers["mcp-method"], "mcp-name": headers["mcp-name"] }, -32020],
|
|
396
|
-
[{ ...headers, "mcp-protocol-version": "2025-11-25" }, -32020],
|
|
397
|
-
[{ ...headers, "mcp-method": "tools/list" }, -32020],
|
|
398
|
-
[{ ...headers, "mcp-name": "HttpRoom.Peek" }, -32020],
|
|
399
|
-
[{ "mcp-protocol-version": MCP_VERSION, "mcp-method": "tools/call" }, -32020],
|
|
400
|
-
];
|
|
401
|
-
for (const [sent, code] of refusals) {
|
|
402
|
-
const reply = yield* server.send("/mcp", {
|
|
403
|
-
token,
|
|
404
|
-
body: call("HttpRoom.Count"),
|
|
405
|
-
headers: sent,
|
|
406
|
-
});
|
|
407
|
-
expect(reply.status).toBe(400);
|
|
408
|
-
expect((yield* rpcError(reply)).code).toBe(code);
|
|
409
|
-
}
|
|
410
|
-
const unsupported = yield* server.send("/mcp", {
|
|
411
|
-
token,
|
|
412
|
-
body: call("HttpRoom.Count", {
|
|
413
|
-
_meta: { ...META, "io.modelcontextprotocol/protocolVersion": "2099-01-01" },
|
|
414
|
-
}),
|
|
415
|
-
headers: { ...headers, "mcp-protocol-version": "2099-01-01" },
|
|
416
|
-
});
|
|
417
|
-
expect(unsupported.status).toBe(400);
|
|
418
|
-
expect(yield* rpcError(unsupported)).toMatchObject({
|
|
419
|
-
code: -32022,
|
|
420
|
-
data: { supported: [MCP_VERSION], requested: "2099-01-01" },
|
|
421
|
-
});
|
|
422
|
-
const incomplete = [
|
|
423
|
-
{ name: "HttpRoom.Count" },
|
|
424
|
-
{
|
|
425
|
-
name: "HttpRoom.Count",
|
|
426
|
-
_meta: { "io.modelcontextprotocol/protocolVersion": MCP_VERSION },
|
|
427
|
-
},
|
|
428
|
-
];
|
|
429
|
-
for (const params of incomplete) {
|
|
430
|
-
const reply = yield* server.send("/mcp", {
|
|
431
|
-
token,
|
|
432
|
-
body: { jsonrpc: "2.0", id: 1, method: "tools/call", params },
|
|
433
|
-
headers,
|
|
434
|
-
});
|
|
435
|
-
expect(reply.status).toBe(400);
|
|
436
|
-
expect((yield* rpcError(reply)).code).toBe(-32602);
|
|
437
|
-
}
|
|
438
|
-
const unknownMethod = yield* rpc(server, { token, method: "resources/list" });
|
|
439
|
-
expect(unknownMethod.status).toBe(404);
|
|
440
|
-
expect((yield* rpcError(unknownMethod)).code).toBe(-32601);
|
|
441
|
-
const paged = yield* rpc(server, { token, method: "tools/list", params: { cursor: "x" } });
|
|
442
|
-
expect(paged.status).toBe(400);
|
|
443
|
-
expect((yield* rpcError(paged)).code).toBe(-32602);
|
|
444
|
-
for (const name of ["HttpRoom.Secret", "HttpRoom.Nope"]) {
|
|
445
|
-
const reply = yield* server.send("/mcp", {
|
|
446
|
-
token,
|
|
447
|
-
body: call(name),
|
|
448
|
-
headers: { ...headers, "mcp-name": name },
|
|
449
|
-
});
|
|
450
|
-
expect(reply.status).toBe(400);
|
|
451
|
-
expect(yield* rpcError(reply)).toEqual({
|
|
452
|
-
code: -32602,
|
|
453
|
-
message: `Unknown tool: ${name}`,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
const encoded = yield* server.send("/mcp", {
|
|
457
|
-
token,
|
|
458
|
-
body: call("HttpRoom.Count"),
|
|
459
|
-
headers: {
|
|
460
|
-
...headers,
|
|
461
|
-
"mcp-name": `=?base64?${Base64.encode("HttpRoom.Count")}?=`,
|
|
462
|
-
},
|
|
463
|
-
});
|
|
464
|
-
expect(encoded.status).toBe(200);
|
|
465
|
-
expect(runs.count).toBe(before);
|
|
466
|
-
expect(yield* receipts(tenant, "HttpRoom", "headers")).toBe(0);
|
|
467
|
-
})),
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
name: "accepts a notification with 202, refuses GET and DELETE with 405, and answers a body that is not one JSON-RPC request with a JSON-RPC error",
|
|
471
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
472
|
-
const server = yield* serveHttp({
|
|
473
|
-
...mcpConformanceOptions,
|
|
474
|
-
limits: { requestBytes: 4096 },
|
|
475
|
-
});
|
|
476
|
-
const token = `${yield* tenantOf}:alice`;
|
|
477
|
-
const notification = yield* server.send("/mcp", {
|
|
478
|
-
token,
|
|
479
|
-
body: { jsonrpc: "2.0", method: "notifications/initialized" },
|
|
480
|
-
});
|
|
481
|
-
expect(notification.status).toBe(202);
|
|
482
|
-
expect(notification.text).toBe("");
|
|
483
|
-
for (const method of ["GET", "DELETE"]) {
|
|
484
|
-
const reply = yield* server.send("/mcp", { method, token });
|
|
485
|
-
expect(reply.status).toBe(405);
|
|
486
|
-
expect(reply.headers.get("allow")).toBe("POST");
|
|
487
|
-
}
|
|
488
|
-
const malformed = [
|
|
489
|
-
[{ raw: "{not json" }, -32700],
|
|
490
|
-
[{ raw: "" }, -32700],
|
|
491
|
-
[{ bytes: new Uint8Array([0xff, 0xfe, 0x7b]) }, -32700],
|
|
492
|
-
[{ raw: "[]" }, -32600],
|
|
493
|
-
[{ raw: '{"jsonrpc":"1.0","id":1,"method":"tools/list"}' }, -32600],
|
|
494
|
-
[{ raw: '{"jsonrpc":"2.0","id":1}' }, -32600],
|
|
495
|
-
];
|
|
496
|
-
for (const [body, code] of malformed) {
|
|
497
|
-
const reply = yield* server.send("/mcp", { token, ...body });
|
|
498
|
-
expect(reply.status).toBe(400);
|
|
499
|
-
expect((yield* rpcError(reply)).code).toBe(code);
|
|
500
|
-
}
|
|
501
|
-
const other = yield* server.send("/mcp", {
|
|
502
|
-
token,
|
|
503
|
-
raw: "{}",
|
|
504
|
-
headers: { "content-type": "text/plain" },
|
|
505
|
-
});
|
|
506
|
-
expect(other.status).toBe(415);
|
|
507
|
-
expect(yield* reasonOf(other.body)).toEqual({
|
|
508
|
-
tag: "InvalidInput",
|
|
509
|
-
code: "unsupported_media_type",
|
|
510
|
-
});
|
|
511
|
-
const large = yield* server.send("/mcp", {
|
|
512
|
-
token,
|
|
513
|
-
raw: `{"pad":"${"x".repeat(5000)}"}`,
|
|
514
|
-
});
|
|
515
|
-
expect(large.status).toBe(413);
|
|
516
|
-
const foreign = yield* server.send("/mcp", {
|
|
517
|
-
token,
|
|
518
|
-
body: { jsonrpc: "2.0", id: 1, method: "server/discover" },
|
|
519
|
-
headers: { origin: "https://evil.example" },
|
|
520
|
-
});
|
|
521
|
-
expect(foreign.status).toBe(403);
|
|
522
|
-
expect(yield* reasonOf(foreign.body)).toEqual({
|
|
523
|
-
tag: "InvalidInput",
|
|
524
|
-
code: "origin_not_allowed",
|
|
525
|
-
});
|
|
526
|
-
})),
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
name: "answers queries, void commands, singletons, and minted actors like their routes, and refuses arguments a tool does not take",
|
|
530
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
531
|
-
const server = yield* serveHttp(mcpConformanceOptions);
|
|
532
|
-
const tenant = yield* tenantOf;
|
|
533
|
-
const token = `${tenant}:alice`;
|
|
534
|
-
const peek = yield* callTool(server, token, "HttpRoom.Peek", { id: "reads" });
|
|
535
|
-
const peekOverHttp = yield* server.send("/actors/HttpRoom/reads/Peek", { token });
|
|
536
|
-
expect(peekOverHttp.body).toBe(null);
|
|
537
|
-
expect(peek).toMatchObject({ isError: false, body: null, structured: null });
|
|
538
|
-
const snapshot = yield* callTool(server, token, "HttpTally.Snapshot", { id: "reads" });
|
|
539
|
-
const snapshotOverHttp = yield* server.send("/actors/HttpTally/reads/Snapshot", { token });
|
|
540
|
-
expect(snapshot.structured).toEqual(snapshotOverHttp.body);
|
|
541
|
-
expect(snapshot.body).toEqual(snapshotOverHttp.body);
|
|
542
|
-
const join = yield* callTool(server, token, "HttpLobby.Join", {
|
|
543
|
-
commandId: yield* mint(server, token),
|
|
544
|
-
});
|
|
545
|
-
expect(join).toMatchObject({ isError: false, body: 1, structured: 1 });
|
|
546
|
-
const leave = yield* callTool(server, token, "HttpLobby.Leave", {
|
|
547
|
-
commandId: yield* mint(server, token),
|
|
548
|
-
});
|
|
549
|
-
expect(leave).toMatchObject({ isError: false, empty: true, structured: undefined });
|
|
550
|
-
const leaveOverHttp = yield* server.send("/actors/HttpLobby/Leave", {
|
|
551
|
-
token,
|
|
552
|
-
key: yield* server.mint(),
|
|
553
|
-
});
|
|
554
|
-
expect(leaveOverHttp.status).toBe(204);
|
|
555
|
-
const unexpected = [
|
|
556
|
-
["HttpLobby.Join", { id: "x", commandId: yield* mint(server, token) }, "id"],
|
|
557
|
-
["HttpRoom.Count", { id: "reads", commandId: yield* mint(server, token) }, "commandId"],
|
|
558
|
-
[
|
|
559
|
-
"HttpRoom.Crash",
|
|
560
|
-
{ id: "reads", commandId: yield* mint(server, token), input: {} },
|
|
561
|
-
"input",
|
|
562
|
-
],
|
|
563
|
-
["durable.commandIds", { id: "x" }, "id"],
|
|
564
|
-
];
|
|
565
|
-
for (const [name, args, path] of unexpected) {
|
|
566
|
-
const reply = yield* callTool(server, token, name, args);
|
|
567
|
-
expect(reply.isError).toBe(true);
|
|
568
|
-
expect(reply.body).toEqual(yield* envelope(InvalidInput.make({
|
|
569
|
-
code: "decode",
|
|
570
|
-
issues: [{ path, message: "Unexpected key" }],
|
|
571
|
-
})));
|
|
572
|
-
}
|
|
573
|
-
const missing = [
|
|
574
|
-
["HttpRoom.Count", {}, "id"],
|
|
575
|
-
["HttpRoom.Post", { id: "reads", commandId: yield* mint(server, token) }, "input"],
|
|
576
|
-
];
|
|
577
|
-
for (const [name, args, path] of missing) {
|
|
578
|
-
const reply = yield* callTool(server, token, name, args);
|
|
579
|
-
expect(reply.body).toEqual(yield* envelope(InvalidInput.make({ code: "decode", issues: [{ path, message: "Missing key" }] })));
|
|
580
|
-
}
|
|
581
|
-
const dots = yield* callTool(server, token, "HttpRoom.Count", { id: ".." });
|
|
582
|
-
expect(yield* reasonOf(dots.body)).toEqual({ tag: "InvalidInput", code: "unservable_id" });
|
|
583
|
-
const ticket = yield* callTool(server, token, "HttpTicket.Join", {
|
|
584
|
-
id: "not-a-uuid",
|
|
585
|
-
commandId: yield* mint(server, token),
|
|
586
|
-
});
|
|
587
|
-
const ticketOverHttp = yield* server.send("/actors/HttpTicket/not-a-uuid/Join", {
|
|
588
|
-
token,
|
|
589
|
-
key: yield* server.mint(),
|
|
590
|
-
});
|
|
591
|
-
expect(ticket.isError).toBe(true);
|
|
592
|
-
expect(ticket.body).toEqual(ticketOverHttp.body);
|
|
593
|
-
})),
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
name: "fails Actor.serve at startup when mcp.path collides with a protocol route or the OpenAPI path",
|
|
597
|
-
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
598
|
-
const internal = Layer.succeed(InternalActors, yield* InternalActors);
|
|
599
|
-
for (const path of ["/protocol", "/command-ids", "/ready", "/actors/Room"]) {
|
|
600
|
-
const exit = yield* HttpRouter.toHttpEffect(serve({ actors: [HttpRoom], auth: tokens, mcp: { path } }).pipe(Layer.provide(internal))).pipe(Effect.exit);
|
|
601
|
-
expect(Exit.isFailure(exit) && Cause.pretty(exit.cause)).toContain(`mcp.path ${path} collides with a protocol route`);
|
|
602
|
-
}
|
|
603
|
-
const same = yield* HttpRouter.toHttpEffect(serve({
|
|
604
|
-
actors: [HttpRoom],
|
|
605
|
-
auth: tokens,
|
|
606
|
-
openapi: { path: "/docs" },
|
|
607
|
-
mcp: { path: "/docs" },
|
|
608
|
-
}).pipe(Layer.provide(internal))).pipe(Effect.exit);
|
|
609
|
-
expect(Exit.isFailure(same) && Cause.pretty(same.cause)).toContain("mcp.path and openapi.path are both /docs");
|
|
610
|
-
const lobby = yield* HttpRouter.toHttpEffect(serve({ actors: [HttpLobby], auth: tokens, mcp: { path: "/mcp" } }).pipe(Layer.provide(internal))).pipe(Effect.exit);
|
|
611
|
-
expect(Exit.isSuccess(lobby)).toBe(true);
|
|
612
|
-
})),
|
|
613
|
-
},
|
|
614
|
-
];
|
|
615
|
-
/** Protocol cases call the served HTTP actors. */
|
|
616
|
-
export const protocolsSuite = {
|
|
617
|
-
uses: [httpSuite],
|
|
618
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Duration, Effect, Schema } from "effect";
|
|
2
|
-
declare const BadAdvertised_base: Schema.Class<BadAdvertised, Schema.TaggedStruct<"BadAdvertised", {
|
|
3
|
-
readonly reason: Schema.String;
|
|
4
|
-
}>, import("effect/Cause").YieldableError>;
|
|
5
|
-
/** An advertised-address list that cannot be read. */
|
|
6
|
-
export declare class BadAdvertised extends BadAdvertised_base {
|
|
7
|
-
}
|
|
8
|
-
/** A runner's advertised address, as `host:port`. */
|
|
9
|
-
export interface AdvertisedAddress {
|
|
10
|
-
readonly host: string;
|
|
11
|
-
readonly port: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Parses a comma-separated list of `host:port`, where `host` may be a name,
|
|
15
|
-
* an IPv4 address, or a bracketed IPv6 address. A malformed entry fails
|
|
16
|
-
* instead of being dropped, so a typo cannot pass as "every address reached".
|
|
17
|
-
*/
|
|
18
|
-
export declare const parseAdvertised: (list: string) => Effect.Effect<ReadonlyArray<AdvertisedAddress>, BadAdvertised>;
|
|
19
|
-
/** The `host:port` of every address this process cannot connect to. */
|
|
20
|
-
export declare const unreachable: (addresses: readonly AdvertisedAddress[], timeout: Duration.Input) => Effect.Effect<string[], never, never>;
|
|
21
|
-
export {};
|