actorctl 0.3.0-rc.14 → 0.3.0-rc.15

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/actorctl.js CHANGED
@@ -27159,7 +27159,7 @@ var actorctl = make30("actorctl").pipe(withDescription4("Deploy actors, run thre
27159
27159
  make30("secrets").pipe(withSubcommands([secretsPut, secretsDelete]))
27160
27160
  ]));
27161
27161
  // package.json
27162
- var version2 = "0.3.0-rc.14";
27162
+ var version2 = "0.3.0-rc.15";
27163
27163
 
27164
27164
  // src/main.ts
27165
27165
  run5(actorctl, { version: version2 }).pipe(provide4(mergeAll2(layer10, layer12)), runMain2);
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
18
 
19
19
  // ../../src/platform/cloudflare/user-worker.ts
20
- import { ConfigProvider, Layer as Layer9 } from "effect";
20
+ import { ConfigProvider, Layer as Layer8 } from "effect";
21
21
 
22
22
  // ../../src/platform/cloudflare/analytics.ts
23
23
  import { Effect as Effect2, Layer } from "effect";
@@ -62,7 +62,7 @@ var boundAiGateway = (accountId, binding) => Layer2.succeed(AiGateway, AiGateway
62
62
  }));
63
63
 
64
64
  // ../../src/platform/cloudflare/runtime.ts
65
- import { Effect as Effect18 } from "effect";
65
+ import { Effect as Effect17 } from "effect";
66
66
 
67
67
  // ../../node_modules/.bun/@effect+sql-sqlite-do@4.1.2+edf248c88a527e3e/node_modules/@effect/sql-sqlite-do/dist/SqliteClient.js
68
68
  var SqliteClient_exports = {};
@@ -262,11 +262,11 @@ var run = /* @__PURE__ */ Migrator.make({});
262
262
  var layer3 = (options) => Layer4.effectDiscard(run(options));
263
263
 
264
264
  // ../../src/platform/cloudflare/runtime.ts
265
- import { HttpRouter as HttpRouter2 } from "effect/http";
265
+ import { HttpRouter } from "effect/http";
266
266
  import { hostRoutes } from "tardie/platform/http";
267
267
 
268
268
  // ../../src/platform/exporting-host.ts
269
- import { Context as Context6, Effect as Effect11, Fiber, Layer as Layer7, ManagedRuntime, Queue, Semaphore as Semaphore3, Schema as Schema3 } from "effect";
269
+ import { Context as Context5, Effect as Effect10, Fiber, Layer as Layer6, ManagedRuntime, Queue, Semaphore as Semaphore3, Schema as Schema2 } from "effect";
270
270
  import { SqlClient as SqlClient3 } from "effect/sql";
271
271
  import { createThreadHost, InitialState, InvalidMessage as InvalidMessage2, MessageConflict as MessageConflict2 } from "tardie/core";
272
272
 
@@ -355,99 +355,29 @@ var sqlEventExporter = (options) => Layer5.unwrap(Effect8.gen(function* () {
355
355
  return eventExporter({ ...options, source });
356
356
  }));
357
357
 
358
- // ../../src/platform/actor-mcp.ts
359
- import { Context as Context5, Effect as Effect9, Layer as Layer6, Schema } from "effect";
360
- import { McpProtocol, McpSchema, McpServer, Tool } from "effect/ai";
361
- import { HttpRouter } from "effect/http";
362
- var ACTOR_MCP_PROTOCOLS = [McpProtocol.v2025_11_25, McpProtocol.v2025_06_18];
363
- var identity2 = { thread: Schema.NonEmptyString, id: Schema.NonEmptyString };
364
- var receipt = Schema.Struct({ id: Schema.String, position: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))) });
365
- function actorMcp(host, instance, options = {}) {
366
- const path = `/v1/actors/${encodeURIComponent(instance)}/mcp`;
367
- let app;
368
- const open = () => app ??= Effect9.runPromise(host.methodContracts({ instance })).then((contracts) => {
369
- const register = Layer6.effectDiscard(Effect9.gen(function* () {
370
- const server = yield* McpServer.McpServer;
371
- const add2 = (name, description, input, output, run2) => server.addTool({
372
- tool: new McpSchema.Tool({ name, description, inputSchema: Tool.getJsonSchemaFromSchema(input), outputSchema: Tool.getJsonSchemaFromSchema(output) }),
373
- annotations: Context5.empty(),
374
- handle: (payload) => Schema.decodeUnknownEffect(Schema.toType(input), { onExcessProperty: "error" })(payload).pipe(
375
- Effect9.mapError((error) => new McpSchema.InvalidParams({ message: error.message })),
376
- Effect9.flatMap((value) => run2(value).pipe(
377
- Effect9.map((result) => new McpSchema.CallToolResult({ content: [{ type: "text", text: JSON.stringify(result) }], structuredContent: result })),
378
- Effect9.catch((error) => Effect9.succeed(new McpSchema.CallToolResult({ isError: true, content: [{ type: "text", text: error.message }] })))
379
- ))
380
- )
381
- });
382
- const thread = (name) => host.getThread({ instance, thread: name }).pipe(Effect9.flatMap((value) => value ? Effect9.succeed(value) : Effect9.fail(new Error("Unknown thread"))));
383
- for (const [name, method] of Object.entries(contracts)) {
384
- yield* add2(
385
- `invoke_${name}`,
386
- `Accept ${name}. Returns a durable call receipt; use call_get for the final result. Reuse id and input on retries.`,
387
- Schema.Struct({ ...identity2, input: method.inputSchema }),
388
- receipt,
389
- (input) => thread(input.thread).pipe(Effect9.flatMap((current) => current.invoke(name, input.input, { id: input.id })))
390
- );
391
- }
392
- yield* add2(
393
- "call_get",
394
- "Read a call's current status and final result.",
395
- Schema.Struct(identity2),
396
- Schema.Struct({ id: Schema.String, method: Schema.String, status: Schema.String, output: Schema.optionalKey(Schema.Json), error: Schema.optionalKey(Schema.String), reason: Schema.optionalKey(Schema.String) }),
397
- (input) => thread(input.thread).pipe(Effect9.flatMap((current) => Effect9.gen(function* () {
398
- const records = yield* current.records();
399
- const invocation = records.find((record) => record.message?.id === input.id)?.message?.invocation;
400
- return invocation ? { id: input.id, method: invocation.method, ...yield* current.methodState(invocation.method, input.id) } : void 0;
401
- })), Effect9.flatMap((value) => value ? Effect9.succeed(value) : Effect9.fail(new Error("Unknown call"))))
402
- );
403
- yield* add2(
404
- "call_cancel",
405
- "Request cancellation of an accepted call. Returns acceptance, not cancellation completion.",
406
- Schema.Struct({ ...identity2, reason: Schema.String }),
407
- receipt,
408
- (input) => thread(input.thread).pipe(Effect9.flatMap((current) => Effect9.gen(function* () {
409
- const records = yield* current.records();
410
- const invocation = records.find((record) => record.message?.id === input.id)?.message?.invocation;
411
- return invocation ? { id: input.id, method: invocation.method, ...yield* current.methodState(invocation.method, input.id) } : void 0;
412
- }).pipe(Effect9.flatMap((call) => call ? current.cancel(call.method, input.id, input.reason) : Effect9.fail(new Error("Unknown call"))))))
413
- );
414
- })).pipe(Layer6.provide(McpServer.layerHttp({ name: host.actor, version: "1.0.0", path, protocols: ACTOR_MCP_PROTOCOLS, ...options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {} })));
415
- return HttpRouter.toWebHandler(register, { disableLogger: true });
416
- }).catch((error) => {
417
- app = void 0;
418
- throw error;
419
- });
420
- return {
421
- request: async (request) => new URL(request.url).pathname === path ? (await open()).handler(request) : void 0,
422
- close: async () => {
423
- if (app) await (await app).dispose();
424
- }
425
- };
426
- }
427
-
428
358
  // src/worker/webhooks.ts
429
- import { Effect as Effect10, Schema as Schema2 } from "effect";
359
+ import { Effect as Effect9, Schema } from "effect";
430
360
  import { InvalidMessage, MessageConflict } from "tardie/core";
431
361
  var REPLY_TO_HEADER = "x-tardigrade-reply-to";
432
362
  var WEBHOOK_TRANSPORT = "tardigrade.webhook";
433
363
  var REPLY_ACCEPTED = "accepted";
434
- var CallMetadata = Schema2.Record(Schema2.String, Schema2.String.check(Schema2.isMaxLength(512))).check(
435
- Schema2.makeFilter((value) => Object.keys(value).length <= 16 && Object.keys(value).every((key) => key.length <= 64) || "Metadata accepts at most 16 pairs with keys up to 64 characters.")
364
+ var CallMetadata = Schema.Record(Schema.String, Schema.String.check(Schema.isMaxLength(512))).check(
365
+ Schema.makeFilter((value) => Object.keys(value).length <= 16 && Object.keys(value).every((key) => key.length <= 64) || "Metadata accepts at most 16 pairs with keys up to 64 characters.")
436
366
  );
437
- var ReplyAddress = Schema2.Struct({
438
- webhook: Schema2.NonEmptyString,
439
- account: Schema2.NonEmptyString,
440
- actor: Schema2.NonEmptyString,
441
- thread: Schema2.NonEmptyString,
442
- method: Schema2.NonEmptyString,
443
- id: Schema2.NonEmptyString,
367
+ var ReplyAddress = Schema.Struct({
368
+ webhook: Schema.NonEmptyString,
369
+ account: Schema.NonEmptyString,
370
+ actor: Schema.NonEmptyString,
371
+ thread: Schema.NonEmptyString,
372
+ method: Schema.NonEmptyString,
373
+ id: Schema.NonEmptyString,
444
374
  metadata: CallMetadata,
445
- url: Schema2.String
375
+ url: Schema.String
446
376
  });
447
377
  var webhookTransport = (binding) => ({
448
- deliver: (address, body, metadata) => Effect10.tryPromise({
378
+ deliver: (address, body, metadata) => Effect9.tryPromise({
449
379
  try: async () => {
450
- const reply = Schema2.decodeUnknownSync(ReplyAddress, { onExcessProperty: "error" })(address);
380
+ const reply = Schema.decodeUnknownSync(ReplyAddress, { onExcessProperty: "error" })(address);
451
381
  if (!binding) throw new Error("WEBHOOKS binding is required");
452
382
  if (metadata.inReplyTo !== reply.id) throw new Error("Webhook reply identifies a different invocation");
453
383
  await binding.enqueueReply(reply, body, metadata.inReplyTo);
@@ -465,14 +395,14 @@ async function receiveWebhookRequest(request, options) {
465
395
  const id = request.headers.get("idempotency-key");
466
396
  let address;
467
397
  try {
468
- address = Schema2.decodeUnknownSync(ReplyAddress, { onExcessProperty: "error" })(JSON.parse(request.headers.get(REPLY_TO_HEADER)));
398
+ address = Schema.decodeUnknownSync(ReplyAddress, { onExcessProperty: "error" })(JSON.parse(request.headers.get(REPLY_TO_HEADER)));
469
399
  if (!id?.trim() || address.id !== id || address.account !== instance || address.actor !== options.actor || address.thread !== thread || address.method !== method) throw new Error("Reply identity mismatch");
470
400
  } catch {
471
401
  return Response.json({ code: "invalid_message", message: "Invalid webhook reply address" }, { status: 400 });
472
402
  }
473
403
  const input = await request.json();
474
- const receipt2 = await options.receive({ target: { actor: options.actor, instance, thread }, body: { method, input }, message: { id, from: { transport: WEBHOOK_TRANSPORT, address } } });
475
- return Response.json(receipt2, { status: 202, headers: { [REPLY_TO_HEADER]: REPLY_ACCEPTED } });
404
+ const receipt = await options.receive({ target: { actor: options.actor, instance, thread }, body: { method, input }, message: { id, from: { transport: WEBHOOK_TRANSPORT, address } } });
405
+ return Response.json(receipt, { status: 202, headers: { [REPLY_TO_HEADER]: REPLY_ACCEPTED } });
476
406
  }
477
407
  const generic = /^\/v1\/actors\/([^/]+)\/threads\/([^/]+)\/calls\/([^/]+)(\/cancel)?$/.exec(path);
478
408
  if (generic && (request.method === "GET" && !generic[4] || request.method === "POST" && generic[4])) {
@@ -482,7 +412,7 @@ async function receiveWebhookRequest(request, options) {
482
412
  if (request.method === "GET") return Response.json({ id, method: call.method, ...call.state });
483
413
  let reason;
484
414
  try {
485
- reason = Schema2.decodeUnknownSync(Schema2.Struct({ reason: Schema2.String }), { onExcessProperty: "error" })(await request.json()).reason;
415
+ reason = Schema.decodeUnknownSync(Schema.Struct({ reason: Schema.String }), { onExcessProperty: "error" })(await request.json()).reason;
486
416
  } catch {
487
417
  return Response.json({ code: "invalid_message", message: "A cancellation reason is required" }, { status: 400 });
488
418
  }
@@ -496,7 +426,7 @@ async function receiveWebhookRequest(request, options) {
496
426
  if (call?.method !== method || !from || !("transport" in from) || from.transport !== WEBHOOK_TRANSPORT) return void 0;
497
427
  let reason;
498
428
  try {
499
- reason = Schema2.decodeUnknownSync(Schema2.Struct({ reason: Schema2.String }), { onExcessProperty: "error" })(await request.json()).reason;
429
+ reason = Schema.decodeUnknownSync(Schema.Struct({ reason: Schema.String }), { onExcessProperty: "error" })(await request.json()).reason;
500
430
  } catch {
501
431
  return Response.json({ code: "invalid_message", message: "A cancellation reason is required" }, { status: 400 });
502
432
  }
@@ -513,7 +443,7 @@ async function receiveWebhookRequest(request, options) {
513
443
  }
514
444
 
515
445
  // ../../src/platform/exporting-host.ts
516
- import { Tool as Tool2 } from "effect/ai";
446
+ import { Tool } from "effect/ai";
517
447
  var DEFAULT_EXPORT_FLUSH_TIMEOUT_MS = 3e4;
518
448
  var isThreadEventJournal = (value, actor, account) => {
519
449
  try {
@@ -530,16 +460,16 @@ async function createSqlExportingHost(options) {
530
460
  const runtime = ManagedRuntime.make(options.sql);
531
461
  const connections = /* @__PURE__ */ new Set();
532
462
  try {
533
- const state = await runtime.runPromise(Effect11.gen(function* () {
463
+ const state = await runtime.runPromise(Effect10.gen(function* () {
534
464
  const sql = yield* SqlClient3.SqlClient;
535
465
  yield* sql`CREATE TABLE IF NOT EXISTS event_export_identity (id INTEGER PRIMARY KEY CHECK (id = 1), account TEXT NOT NULL, actor TEXT NOT NULL, generation TEXT NOT NULL)`;
536
466
  yield* sql`INSERT INTO event_export_identity VALUES (1, ${options.accountId}, ${options.actor.actorName}, ${crypto.randomUUID()}) ON CONFLICT (id) DO NOTHING`;
537
467
  const rows = yield* sql`SELECT account, actor, generation FROM event_export_identity WHERE id = 1`;
538
- const identity3 = rows[0];
539
- if (identity3.account !== options.accountId || identity3.actor !== options.actor.actorName) return yield* Effect11.fail(new Error("Journal database belongs to a different account or actor."));
468
+ const identity2 = rows[0];
469
+ if (identity2.account !== options.accountId || identity2.actor !== options.actor.actorName) return yield* Effect10.fail(new Error("Journal database belongs to a different account or actor."));
540
470
  const signals = yield* Queue.make({ capacity: 1, strategy: "sliding" });
541
471
  const lock = yield* Semaphore3.make(1);
542
- return { sql, identity: identity3, signals, lock };
472
+ return { sql, identity: identity2, signals, lock };
543
473
  }));
544
474
  let closed = false;
545
475
  const signal = () => {
@@ -549,10 +479,10 @@ async function createSqlExportingHost(options) {
549
479
  const key = JSON.stringify(parts);
550
480
  const opened = options.journalFactory({
551
481
  actor: key,
552
- layer: Layer7.succeed(SqlClient3.SqlClient, state.sql),
482
+ layer: Layer6.succeed(SqlClient3.SqlClient, state.sql),
553
483
  ...options.transaction ? { transaction: options.transaction } : {},
554
- flush: Effect11.gen(function* () {
555
- if (options.sync) yield* Effect11.tryPromise({ try: () => options.sync(), catch: (error) => error instanceof Error ? error : new Error(String(error)) });
484
+ flush: Effect10.gen(function* () {
485
+ if (options.sync) yield* Effect10.tryPromise({ try: () => options.sync(), catch: (error) => error instanceof Error ? error : new Error(String(error)) });
556
486
  if (exportEvents) signal();
557
487
  })
558
488
  });
@@ -571,59 +501,57 @@ async function createSqlExportingHost(options) {
571
501
  checkAccount(coordinate.instance);
572
502
  return journal([coordinate.actor, coordinate.instance, "thread", coordinate.thread, "events"], true);
573
503
  },
574
- close: Effect11.gen(function* () {
504
+ close: Effect10.gen(function* () {
575
505
  for (const close of connections) yield* close;
576
506
  connections.clear();
577
507
  })
578
508
  };
579
509
  const allocations = Semaphore3.makeUnsafe(1);
580
- const host = createThreadHost({ ...options, services: (coordinate, current) => options.services(coordinate, current).pipe(Layer7.provideMerge(Layer7.succeed(SqlClient3.SqlClient, state.sql))), storage, actorContext: options.actorContext ?? ((context) => context) });
581
- const bootstrap = options.journalFactory({ actor: "bootstrap", layer: Layer7.succeed(SqlClient3.SqlClient, state.sql), ...options.transaction ? { transaction: options.transaction } : {} });
510
+ const host = createThreadHost({ ...options, services: (coordinate, current) => options.services(coordinate, current).pipe(Layer6.provideMerge(Layer6.succeed(SqlClient3.SqlClient, state.sql))), storage, actorContext: options.actorContext ?? ((context) => context) });
511
+ const bootstrap = options.journalFactory({ actor: "bootstrap", layer: Layer6.succeed(SqlClient3.SqlClient, state.sql), ...options.transaction ? { transaction: options.transaction } : {} });
582
512
  bootstrap.read();
583
- await Effect11.runPromise(bootstrap.close);
584
- const flush = state.lock.withPermits(1)(Effect11.scoped(Effect11.gen(function* () {
513
+ await Effect10.runPromise(bootstrap.close);
514
+ const flush = state.lock.withPermits(1)(Effect10.scoped(Effect10.gen(function* () {
585
515
  const rows = yield* state.sql`SELECT DISTINCT actor FROM experimental_events ORDER BY actor`;
586
516
  const journals = rows.filter((row) => isThreadEventJournal(row.actor, options.actor.actorName, options.accountId));
587
517
  const results = [];
588
518
  if (journals.length === 0) return results;
589
- const analytics = Context6.get(yield* Layer7.build(options.analytics), Analytics);
519
+ const analytics = Context5.get(yield* Layer6.build(options.analytics), Analytics);
590
520
  for (const row of journals) {
591
- const result = yield* Effect11.gen(function* () {
521
+ const result = yield* Effect10.gen(function* () {
592
522
  return yield* (yield* EventExporter).flush();
593
- }).pipe(Effect11.provide(sqlEventExporter({
523
+ }).pipe(Effect10.provide(sqlEventExporter({
594
524
  accountId: options.accountId,
595
525
  actor: options.actor.actorName,
596
526
  sourceId: JSON.stringify([state.identity.generation, row.actor]),
597
527
  destinationId: options.destinationId,
598
528
  journal: row.actor,
599
529
  ...options.batchSize === void 0 ? {} : { batchSize: options.batchSize }
600
- }).pipe(Layer7.provide(Layer7.succeed(Analytics, analytics)))));
530
+ }).pipe(Layer6.provide(Layer6.succeed(Analytics, analytics)))));
601
531
  results.push(result);
602
532
  }
603
533
  return results;
604
- })).pipe(Effect11.timeout(flushTimeoutMs)));
605
- const worker = runtime.runFork(Effect11.forever(Effect11.gen(function* () {
534
+ })).pipe(Effect10.timeout(flushTimeoutMs)));
535
+ const worker = runtime.runFork(Effect10.forever(Effect10.gen(function* () {
606
536
  yield* Queue.take(state.signals);
607
537
  yield* flush.pipe(
608
- Effect11.tap((results) => Effect11.sync(() => {
538
+ Effect10.tap((results) => Effect10.sync(() => {
609
539
  if (results.some((result) => result.hasMore)) signal();
610
540
  })),
611
- Effect11.catch((error) => Effect11.logWarning("Actor analytics export failed; the cursor is retained for the next flush.", { operation: error instanceof ExportError ? error.operation : "connection", flushTimeoutMs }))
541
+ Effect10.catch((error) => Effect10.logWarning("Actor analytics export failed; the cursor is retained for the next flush.", { operation: error instanceof ExportError ? error.operation : "connection", flushTimeoutMs }))
612
542
  );
613
543
  })));
614
544
  signal();
615
- const mcp = actorMcp(host, options.accountId, options.mcp);
616
545
  let closing;
617
546
  return {
618
547
  ...host,
619
- mcpRequest: mcp.request,
620
548
  allocationRequest: async (request) => {
621
549
  const parts = new URL(request.url).pathname.split("/");
622
550
  if (request.method !== "POST" || parts.length !== 5 || parts[1] !== "v1" || parts[2] !== "actors" || parts[4] !== "threads") return void 0;
623
551
  const input = await request.json().catch(() => void 0);
624
- const schema = Schema3.Struct({ name: Schema3.optionalKey(Schema3.NonEmptyString), parent: Schema3.optionalKey(Schema3.NonEmptyString), initialState: Schema3.optionalKey(InitialState) });
625
- const work = allocations.withPermit(Effect11.gen(function* () {
626
- const body = yield* Schema3.decodeUnknownEffect(schema)(input).pipe(Effect11.mapError(InvalidMessage2.from));
552
+ const schema = Schema2.Struct({ name: Schema2.optionalKey(Schema2.NonEmptyString), parent: Schema2.optionalKey(Schema2.NonEmptyString), initialState: Schema2.optionalKey(InitialState) });
553
+ const work = allocations.withPermit(Effect10.gen(function* () {
554
+ const body = yield* Schema2.decodeUnknownEffect(schema)(input).pipe(Effect10.mapError(InvalidMessage2.from));
627
555
  const instance = decodeURIComponent(parts[3]);
628
556
  if (body.name && (yield* host.getThread({ instance, thread: body.name }))) return Response.json({ code: "thread_exists", message: "Thread already exists." }, { status: 409 });
629
557
  const name = body.name === void 0 ? {} : { name: body.name };
@@ -631,22 +559,22 @@ async function createSqlExportingHost(options) {
631
559
  const thread = yield* body.parent === void 0 ? host.allocateRootThread({ instance, ...name, ...seed }) : host.allocateChildThread({ parent: { actor: host.actor, instance, thread: body.parent }, ...name, ...seed });
632
560
  return Response.json(thread.coordinate);
633
561
  }));
634
- return Effect11.runPromise(work.pipe(Effect11.catch((error) => Effect11.succeed(Response.json({ error: error.message }, { status: error instanceof InvalidMessage2 ? 400 : 500 })))));
562
+ return Effect10.runPromise(work.pipe(Effect10.catch((error) => Effect10.succeed(Response.json({ error: error.message }, { status: error instanceof InvalidMessage2 ? 400 : 500 })))));
635
563
  },
636
564
  methodRequest: async (request) => {
637
565
  const parts = new URL(request.url).pathname.split("/");
638
566
  if (parts[1] !== "v1" || parts[2] !== "actors" || decodeURIComponent(parts[3] ?? "") !== options.accountId) return void 0;
639
567
  if (request.method === "GET" && parts.length === 5 && parts[4] === "methods") {
640
- const contracts = await Effect11.runPromise(host.methodContracts({ instance: options.accountId }));
568
+ const contracts = await Effect10.runPromise(host.methodContracts({ instance: options.accountId }));
641
569
  return Response.json({ items: Object.entries(contracts).map(([name, method]) => ({
642
570
  name,
643
- inputSchema: Tool2.getJsonSchemaFromSchema(method.inputSchema),
644
- outputSchema: Tool2.getJsonSchemaFromSchema(method.outputSchema),
571
+ inputSchema: Tool.getJsonSchemaFromSchema(method.inputSchema),
572
+ outputSchema: Tool.getJsonSchemaFromSchema(method.outputSchema),
645
573
  cancellable: method.onCancel !== void 0
646
574
  })) });
647
575
  }
648
576
  if (parts[4] === "threads" && parts[6] === "calls" && (request.method === "GET" && parts.length === 8 || request.method === "POST" && parts.length === 9 && parts[8] === "cancel")) {
649
- const work2 = Effect11.gen(function* () {
577
+ const work2 = Effect10.gen(function* () {
650
578
  const thread = yield* host.getThread({ instance: options.accountId, thread: decodeURIComponent(parts[5]) });
651
579
  if (!thread) return new Response(null, { status: 404 });
652
580
  const id2 = decodeURIComponent(parts[7]);
@@ -655,26 +583,26 @@ async function createSqlExportingHost(options) {
655
583
  const call = invocation ? { id: id2, method: invocation.method, ...yield* thread.methodState(invocation.method, id2) } : void 0;
656
584
  if (!call) return new Response(null, { status: 404 });
657
585
  if (request.method === "GET") return Response.json(call);
658
- const input2 = yield* Effect11.tryPromise(() => request.json()).pipe(Effect11.mapError(InvalidMessage2.from));
659
- const body = yield* Schema3.decodeUnknownEffect(Schema3.Struct({ reason: Schema3.String }), { onExcessProperty: "error" })(input2).pipe(Effect11.mapError(InvalidMessage2.from));
586
+ const input2 = yield* Effect10.tryPromise(() => request.json()).pipe(Effect10.mapError(InvalidMessage2.from));
587
+ const body = yield* Schema2.decodeUnknownEffect(Schema2.Struct({ reason: Schema2.String }), { onExcessProperty: "error" })(input2).pipe(Effect10.mapError(InvalidMessage2.from));
660
588
  const original = records.find((record) => record.message?.id === id2)?.message;
661
- const receipt2 = original?.from && "transport" in original.from && original.from.transport === WEBHOOK_TRANSPORT ? yield* host.receive({ target: thread.coordinate, body: { method: call.method, cancel: { id: id2, reason: body.reason } }, message: { id: JSON.stringify(["cancel", call.method, id2]), from: original.from } }) : yield* thread.cancel(call.method, id2, body.reason);
662
- return Response.json(receipt2, { status: 202 });
589
+ const receipt = original?.from && "transport" in original.from && original.from.transport === WEBHOOK_TRANSPORT ? yield* host.receive({ target: thread.coordinate, body: { method: call.method, cancel: { id: id2, reason: body.reason } }, message: { id: JSON.stringify(["cancel", call.method, id2]), from: original.from } }) : yield* thread.cancel(call.method, id2, body.reason);
590
+ return Response.json(receipt, { status: 202 });
663
591
  });
664
- return Effect11.runPromise(work2.pipe(Effect11.catch((error) => Effect11.succeed(Response.json({ error: error.message }, { status: error instanceof InvalidMessage2 ? 400 : error instanceof MessageConflict2 ? 409 : 500 })))));
592
+ return Effect10.runPromise(work2.pipe(Effect10.catch((error) => Effect10.succeed(Response.json({ error: error.message }, { status: error instanceof InvalidMessage2 ? 400 : error instanceof MessageConflict2 ? 409 : 500 })))));
665
593
  }
666
594
  if (request.method === "POST" && parts.length === 8 && parts[4] === "threads" && parts[6] === "methods" && request.headers.has("x-tardigrade-reply-to")) {
667
- const thread = await Effect11.runPromise(host.getThread({ instance: options.accountId, thread: decodeURIComponent(parts[5]) }));
595
+ const thread = await Effect10.runPromise(host.getThread({ instance: options.accountId, thread: decodeURIComponent(parts[5]) }));
668
596
  if (!thread || !Object.hasOwn(thread.methods, decodeURIComponent(parts[7]))) return new Response(null, { status: 404 });
669
597
  }
670
598
  const webhook = await receiveWebhookRequest(request.clone(), {
671
599
  actor: host.actor,
672
- receive: (packet) => Effect11.runPromise(host.receive(packet)),
600
+ receive: (packet) => Effect10.runPromise(host.receive(packet)),
673
601
  lookup: async (instance, thread, id2) => {
674
- const handle = await Effect11.runPromise(host.getThread({ instance, thread }));
602
+ const handle = await Effect10.runPromise(host.getThread({ instance, thread }));
675
603
  if (!handle) return void 0;
676
- const message = (await Effect11.runPromise(handle.records())).find((record) => record.message?.id === id2 && record.message.invocation)?.message;
677
- return message?.invocation ? { method: message.invocation.method, from: message.from, state: await Effect11.runPromise(handle.methodState(message.invocation.method, id2)) } : void 0;
604
+ const message = (await Effect10.runPromise(handle.records())).find((record) => record.message?.id === id2 && record.message.invocation)?.message;
605
+ return message?.invocation ? { method: message.invocation.method, from: message.from, state: await Effect10.runPromise(handle.methodState(message.invocation.method, id2)) } : void 0;
678
606
  }
679
607
  }).catch((error) => Response.json({ error: error.message }, { status: error instanceof MessageConflict2 ? 409 : error instanceof InvalidMessage2 || error instanceof SyntaxError ? 400 : 500 }));
680
608
  if (webhook) return webhook;
@@ -682,15 +610,15 @@ async function createSqlExportingHost(options) {
682
610
  const id = request.headers.get("idempotency-key");
683
611
  if (!id?.trim()) return Response.json({ error: "Idempotency-Key is required" }, { status: 400 });
684
612
  const input = await request.json().catch(() => void 0);
685
- const work = Effect11.gen(function* () {
613
+ const work = Effect10.gen(function* () {
686
614
  const thread = yield* host.getThread({ instance: decodeURIComponent(parts[3]), thread: decodeURIComponent(parts[5]) });
687
615
  const method = decodeURIComponent(parts[7]);
688
616
  if (!thread || !Object.hasOwn(thread.methods, method)) return new Response(null, { status: 404 });
689
- const body = yield* Schema3.decodeUnknownEffect(Schema3.Json)(input).pipe(Effect11.mapError(InvalidMessage2.from));
690
- const receipt2 = yield* thread.invoke(method, body, { id });
691
- return Response.json(receipt2, { status: 202 });
617
+ const body = yield* Schema2.decodeUnknownEffect(Schema2.Json)(input).pipe(Effect10.mapError(InvalidMessage2.from));
618
+ const receipt = yield* thread.invoke(method, body, { id });
619
+ return Response.json(receipt, { status: 202 });
692
620
  });
693
- return Effect11.runPromise(work.pipe(Effect11.catch((error) => Effect11.succeed(Response.json({ error: error.message }, { status: error instanceof MessageConflict2 ? 409 : error instanceof InvalidMessage2 ? 400 : 500 })))));
621
+ return Effect10.runPromise(work.pipe(Effect10.catch((error) => Effect10.succeed(Response.json({ error: error.message }, { status: error instanceof MessageConflict2 ? 409 : error instanceof InvalidMessage2 ? 400 : 500 })))));
694
622
  },
695
623
  flushEvents: () => {
696
624
  if (closed) return Promise.reject(new Error("Actor host is closed."));
@@ -699,19 +627,15 @@ async function createSqlExportingHost(options) {
699
627
  close: () => closing ??= (async () => {
700
628
  closed = true;
701
629
  try {
702
- try {
703
- await mcp.close();
704
- } finally {
705
- await Effect11.runPromise(host.close);
706
- }
630
+ await Effect10.runPromise(host.close);
707
631
  } finally {
708
- await Effect11.runPromise(Fiber.interrupt(worker));
632
+ await Effect10.runPromise(Fiber.interrupt(worker));
709
633
  await runtime.dispose();
710
634
  }
711
635
  })()
712
636
  };
713
637
  } catch (error) {
714
- for (const close of connections) await Effect11.runPromise(close);
638
+ for (const close of connections) await Effect10.runPromise(close);
715
639
  await runtime.dispose();
716
640
  throw error;
717
641
  }
@@ -755,91 +679,91 @@ var eventsPage = (rows, query) => ({
755
679
  });
756
680
 
757
681
  // ../../src/platform/cloudflare/router.ts
758
- import { Effect as Effect17, Layer as Layer8 } from "effect";
682
+ import { Effect as Effect16, Layer as Layer7 } from "effect";
759
683
 
760
684
  // ../../src/services/actor-router.ts
761
- import { Context as Context7, Data as Data4 } from "effect";
685
+ import { Context as Context6, Data as Data4 } from "effect";
762
686
  var ActorRouterError = class extends Data4.TaggedError("ActorRouterError") {
763
687
  };
764
- var ActorRouter = class extends Context7.Service()("tardigrade-cloud/ActorRouter") {
688
+ var ActorRouter = class extends Context6.Service()("tardigrade-cloud/ActorRouter") {
765
689
  };
766
690
 
767
691
  // ../../src/services/actor-runtime.ts
768
- import { Context as Context8, Data as Data5 } from "effect";
692
+ import { Context as Context7, Data as Data5 } from "effect";
769
693
  var ActorRuntimeError = class extends Data5.TaggedError("ActorRuntimeError") {
770
694
  };
771
- var ActorRuntime = class extends Context8.Service()("tardigrade-cloud/ActorRuntime") {
695
+ var ActorRuntime = class extends Context7.Service()("tardigrade-cloud/ActorRuntime") {
772
696
  };
773
697
 
774
698
  // ../../src/services/metadata-store.ts
775
- import { Context as Context10, Data as Data7, Schema as Schema5 } from "effect";
699
+ import { Context as Context9, Data as Data7, Schema as Schema4 } from "effect";
776
700
 
777
701
  // ../../src/services/webhooks.ts
778
- import { Context as Context9, Data as Data6, Schema as Schema4 } from "effect";
779
- var WebhookEventType = Schema4.Literals(["call.completed", "call.failed", "call.cancelled", "webhook.test"]);
780
- var WebhookEndpoint = Schema4.Struct({
781
- id: Schema4.String,
782
- url: Schema4.String,
783
- events: Schema4.Array(WebhookEventType),
784
- description: Schema4.String,
785
- status: Schema4.Literals(["active", "disabled"]),
786
- createdAt: Schema4.String
702
+ import { Context as Context8, Data as Data6, Schema as Schema3 } from "effect";
703
+ var WebhookEventType = Schema3.Literals(["call.completed", "call.failed", "call.cancelled", "webhook.test"]);
704
+ var WebhookEndpoint = Schema3.Struct({
705
+ id: Schema3.String,
706
+ url: Schema3.String,
707
+ events: Schema3.Array(WebhookEventType),
708
+ description: Schema3.String,
709
+ status: Schema3.Literals(["active", "disabled"]),
710
+ createdAt: Schema3.String
787
711
  });
788
- var WebhookCreate = Schema4.Struct({ url: Schema4.String, events: Schema4.optionalKey(Schema4.Array(WebhookEventType)), description: Schema4.optionalKey(Schema4.String) });
789
- var WebhookPatch = Schema4.Struct({
790
- url: Schema4.optionalKey(Schema4.String),
791
- events: Schema4.optionalKey(Schema4.Array(WebhookEventType)),
792
- description: Schema4.optionalKey(Schema4.String),
793
- status: Schema4.optionalKey(Schema4.Literals(["active", "disabled"]))
712
+ var WebhookCreate = Schema3.Struct({ url: Schema3.String, events: Schema3.optionalKey(Schema3.Array(WebhookEventType)), description: Schema3.optionalKey(Schema3.String) });
713
+ var WebhookPatch = Schema3.Struct({
714
+ url: Schema3.optionalKey(Schema3.String),
715
+ events: Schema3.optionalKey(Schema3.Array(WebhookEventType)),
716
+ description: Schema3.optionalKey(Schema3.String),
717
+ status: Schema3.optionalKey(Schema3.Literals(["active", "disabled"]))
794
718
  });
795
719
  var WebhookError = class extends Data6.TaggedError("WebhookError") {
796
720
  };
797
- var WebhookStore = class extends Context9.Service()("tardigrade-cloud/WebhookStore") {
721
+ var WebhookStore = class extends Context8.Service()("tardigrade-cloud/WebhookStore") {
798
722
  };
799
- var WebhookAttempt = Schema4.Struct({ startedAt: Schema4.Number, finishedAt: Schema4.NullOr(Schema4.Number), statusCode: Schema4.NullOr(Schema4.Number), error: Schema4.NullOr(Schema4.String) });
800
- var WebhookDelivery = Schema4.Struct({
801
- id: Schema4.String,
723
+ var WebhookAttempt = Schema3.Struct({ startedAt: Schema3.Number, finishedAt: Schema3.NullOr(Schema3.Number), statusCode: Schema3.NullOr(Schema3.Number), error: Schema3.NullOr(Schema3.String) });
724
+ var WebhookDelivery = Schema3.Struct({
725
+ id: Schema3.String,
802
726
  type: WebhookEventType,
803
- status: Schema4.Literals(["pending", "delivered", "failed", "skipped"]),
804
- createdAt: Schema4.Number,
805
- attempts: Schema4.Array(WebhookAttempt)
727
+ status: Schema3.Literals(["pending", "delivered", "failed", "skipped"]),
728
+ createdAt: Schema3.Number,
729
+ attempts: Schema3.Array(WebhookAttempt)
806
730
  });
807
- var WebhookDeliveryService = class extends Context9.Service()("tardigrade-cloud/WebhookDeliveryService") {
731
+ var WebhookDeliveryService = class extends Context8.Service()("tardigrade-cloud/WebhookDeliveryService") {
808
732
  };
809
733
 
810
734
  // ../../src/services/metadata-store.ts
811
- var Actor = Schema5.Struct({
812
- name: Schema5.NonEmptyString,
813
- description: Schema5.String,
814
- metadata: Schema5.optionalKey(CallMetadata)
735
+ var Actor = Schema4.Struct({
736
+ name: Schema4.NonEmptyString,
737
+ description: Schema4.String,
738
+ metadata: Schema4.optionalKey(CallMetadata)
815
739
  }).annotate({ identifier: "Actor" });
816
- var Version = Schema5.Struct({
817
- id: Schema5.NonEmptyString,
818
- actor: Schema5.NonEmptyString,
819
- digest: Schema5.NonEmptyString
740
+ var Version = Schema4.Struct({
741
+ id: Schema4.NonEmptyString,
742
+ actor: Schema4.NonEmptyString,
743
+ digest: Schema4.NonEmptyString
820
744
  }).annotate({ identifier: "Version" });
821
- var Deployment = Schema5.Struct({
822
- id: Schema5.NonEmptyString,
823
- version: Schema5.NonEmptyString
745
+ var Deployment = Schema4.Struct({
746
+ id: Schema4.NonEmptyString,
747
+ version: Schema4.NonEmptyString
824
748
  }).annotate({ identifier: "Deployment" });
825
- var VersionRecord = Schema5.Struct({
749
+ var VersionRecord = Schema4.Struct({
826
750
  ...Version.fields,
827
- artifactDigest: Schema5.String.check(Schema5.isPattern(/^sha256:[a-f0-9]{64}$/))
751
+ artifactDigest: Schema4.String.check(Schema4.isPattern(/^sha256:[a-f0-9]{64}$/))
828
752
  }).annotate({ identifier: "VersionRecord" });
829
753
  var MetadataStoreError = class extends Data7.TaggedError("MetadataStoreError") {
830
754
  };
831
- var MetadataStore = class extends Context10.Service()("tardigrade-cloud/MetadataStore") {
755
+ var MetadataStore = class extends Context9.Service()("tardigrade-cloud/MetadataStore") {
832
756
  };
833
757
 
834
758
  // ../../src/platform/router.ts
835
- import { Effect as Effect16, Option as Option2 } from "effect";
759
+ import { Effect as Effect15, Option as Option2 } from "effect";
836
760
 
837
761
  // ../../src/platform/cloudflare/router.ts
838
762
  var actorObjectName = (address) => JSON.stringify([address.accountId, address.actorName]);
839
763
 
840
764
  // ../../src/platform/cloudflare/runtime.ts
841
765
  var createCloudflareExportingHost = (options) => import("tardie/platform/journal").then(({ sqlJournal }) => createSqlExportingHost({ ...options, journalFactory: sqlJournal, sql: SqliteClient_exports.layer({ storage: options.storage }), transaction: (work) => options.storage.transactionSync(work), sync: () => options.storage.sync() }));
842
- var cloudflareHandler = (host) => HttpRouter2.toWebHandler(hostRoutes(host), { disableLogger: true });
766
+ var cloudflareHandler = (host) => HttpRouter.toWebHandler(hostRoutes(host), { disableLogger: true });
843
767
  var DEFAULT_EVENT_PAGE_SIZE = 100;
844
768
  var READY_PATH = "/__tardigrade/ready";
845
769
  var cloudflareActorObject = (options) => class {
@@ -895,7 +819,7 @@ var cloudflareActorObject = (options) => class {
895
819
  if (!Number.isSafeInteger(pageSize) || pageSize < 1) throw new Error("Event page size must be a positive integer.");
896
820
  if (request.method === "GET" && parts.length === 7 && parts[6] === "events") {
897
821
  const thread = decodeURIComponent(parts[5]);
898
- if (!await Effect18.runPromise(this.active.host.getThread({ instance: accountId, thread }))) return new Response(null, { status: 404 });
822
+ if (!await Effect17.runPromise(this.active.host.getThread({ instance: accountId, thread }))) return new Response(null, { status: 404 });
899
823
  const query = parseEventsQuery(url.searchParams, pageSize);
900
824
  if (!query) return new Response(null, { status: 400 });
901
825
  const statement = eventsStatement(JSON.stringify([actorName, accountId, "thread", thread, "events"]), query);
@@ -904,15 +828,15 @@ var cloudflareActorObject = (options) => class {
904
828
  if (request.method === "GET" && parts.length === 5 && parts[4] === "threads") {
905
829
  const cursor = Number(url.searchParams.get("cursor") ?? 0);
906
830
  if (!Number.isSafeInteger(cursor) || cursor < 0) return new Response(null, { status: 400 });
907
- const store = await Effect18.runPromise(this.active.host.supervisorStore(accountId));
831
+ const store = await Effect17.runPromise(this.active.host.supervisorStore(accountId));
908
832
  const threads = store.threads.get().filter((thread) => thread.status === "registered");
909
833
  return Response.json({ items: threads.slice(cursor, cursor + pageSize).map((thread) => ({ id: thread.coordinate.thread, ...thread.parent ? { parent: thread.parent } : {} })), ...cursor + pageSize < threads.length ? { cursor: String(cursor + pageSize) } : {} });
910
834
  }
911
835
  if (request.method === "POST" && parts.length === 5 && parts[4] === "threads") {
912
836
  const input = await request.clone().json().catch(() => null);
913
- if (typeof input?.name === "string" && await Effect18.runPromise(this.active.host.getThread({ instance: accountId, thread: input.name }))) return Response.json({ code: "thread_exists", message: "Thread already exists." }, { status: 409 });
837
+ if (typeof input?.name === "string" && await Effect17.runPromise(this.active.host.getThread({ instance: accountId, thread: input.name }))) return Response.json({ code: "thread_exists", message: "Thread already exists." }, { status: 409 });
914
838
  }
915
- return await this.active.host.allocationRequest(request.clone()) ?? await this.active.host.methodRequest(request.clone()) ?? await this.active.host.mcpRequest(request.clone()) ?? this.active.app.handler(request);
839
+ return await this.active.host.allocationRequest(request.clone()) ?? await this.active.host.methodRequest(request.clone()) ?? this.active.app.handler(request);
916
840
  }
917
841
  };
918
842
 
@@ -932,11 +856,11 @@ var createActorWorker = (actor, DurableObject, services, actorContext) => {
932
856
  transports: { [WEBHOOK_TRANSPORT]: webhookTransport(env.WEBHOOKS) },
933
857
  ...actorContext ? { actorContext } : {},
934
858
  services: (coordinate, runtime) => {
935
- const platform = Layer9.mergeAll(
859
+ const platform = Layer8.mergeAll(
936
860
  ConfigProvider.layer(ConfigProvider.fromUnknown(secrets(env.SECRETS))),
937
861
  boundAiGateway(deployment.accountId, env.INFERENCE)
938
862
  );
939
- return services ? services(runtime, coordinate).pipe(Layer9.provideMerge(platform)) : platform;
863
+ return services ? services(runtime, coordinate).pipe(Layer8.provideMerge(platform)) : platform;
940
864
  },
941
865
  analytics: cloudflareAnalytics(deployment.accountId, env.ANALYTICS),
942
866
  destinationId: "aurora",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "actorctl",
3
- "version": "0.3.0-rc.14",
3
+ "version": "0.3.0-rc.15",
4
4
  "description": "Deploy actors, run threads, and read events on Tardigrade Cloud.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -26,6 +26,6 @@
26
26
  "tardie": "*"
27
27
  },
28
28
  "tardigrade": {
29
- "sourceTree": "5f4ded0dbdcd5ce67173fb01a7ff98c527b18a7e"
29
+ "sourceTree": "44da75311ba234a08beb4452bee1c55507dcd92c"
30
30
  }
31
31
  }