@agentconnect.md/daemon 1.0.0-rc.234 → 1.0.0-rc.236

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.
@@ -197,6 +197,23 @@ object({
197
197
  });
198
198
  /** The all-zero UUID used when a frame is malformed past the point of reading `id`. */
199
199
  const NIL_UUID = "00000000-0000-0000-0000-000000000000";
200
+ /**
201
+ * Builds the envelope schema for one frame `type` — the `type` literal plus the
202
+ * typed payload — so a wire's discriminated union infers `payload` precisely.
203
+ * Shared by the daemon↔CP union (`frame.ts`) and the relay wire unions
204
+ * (`frames/relay-cp.ts` / `frames/relay-daemon.ts`), which are deliberately
205
+ * SEPARATE unions over the same envelope shape (shared-bot-relay.md §8).
206
+ */
207
+ function frameSchema(type, payload) {
208
+ return object({
209
+ v: literal(1),
210
+ id: string().uuid(),
211
+ ts: string().datetime(),
212
+ type: literal(type),
213
+ corr: string().uuid().optional(),
214
+ payload
215
+ });
216
+ }
200
217
  //#endregion
201
218
  //#region ../protocol/dist/frames/auth.js
202
219
  /**
@@ -235,7 +252,8 @@ const AuthOk = object({
235
252
  const Platform = _enum([
236
253
  "slack",
237
254
  "telegram",
238
- "webchat"
255
+ "webchat",
256
+ "discord"
239
257
  ]);
240
258
  const SessionKey = object({
241
259
  platform: Platform,
@@ -308,7 +326,11 @@ const DrainDone = object({ released: array(SessionKey) });
308
326
  * platform output).
309
327
  */
310
328
  const CronTarget = object({
311
- platform: _enum(["slack", "telegram"]).default("slack"),
329
+ platform: _enum([
330
+ "slack",
331
+ "telegram",
332
+ "discord"
333
+ ]).default("slack"),
312
334
  channel: string(),
313
335
  integrationId: string().uuid().optional()
314
336
  });
@@ -548,22 +570,43 @@ const IntegrationTelegramConfig = object({
548
570
  bindRules: array(IntegrationBindRule).default([])
549
571
  });
550
572
  /**
573
+ * The Discord config the daemon needs to open the Gateway + route (discord.js).
574
+ * Discord authenticates the Gateway with a SINGLE bot token — no Slack-style
575
+ * app-level token and no signing secret. `applicationId` is public metadata (the
576
+ * client id for the OAuth2 bot-invite URL); it is not secret material.
577
+ */
578
+ const IntegrationDiscordConfig = object({
579
+ botToken: string(),
580
+ applicationId: string().optional(),
581
+ allowedUserIds: array(string()).default([]),
582
+ bindRules: array(IntegrationBindRule).default([])
583
+ });
584
+ /**
551
585
  * One platform integration, owned by exactly one agent. Also the element type of
552
586
  * `RegisterOk.integrations[]` (the per-daemon reconcile set). Discriminated on
553
- * `platform`: the daemon opens a Slack Socket Mode connection or a Telegram
554
- * long-poll from whichever variant is delivered.
587
+ * `platform`: the daemon opens a Slack Socket Mode connection, a Telegram
588
+ * long-poll, or a Discord Gateway from whichever variant is delivered.
555
589
  */
556
- const IntegrationSpec = discriminatedUnion("platform", [object({
557
- integrationId: string().uuid(),
558
- agentId: string().uuid(),
559
- platform: literal("slack"),
560
- slack: IntegrationSlackConfig
561
- }), object({
562
- integrationId: string().uuid(),
563
- agentId: string().uuid(),
564
- platform: literal("telegram"),
565
- telegram: IntegrationTelegramConfig
566
- })]);
590
+ const IntegrationSpec = discriminatedUnion("platform", [
591
+ object({
592
+ integrationId: string().uuid(),
593
+ agentId: string().uuid(),
594
+ platform: literal("slack"),
595
+ slack: IntegrationSlackConfig
596
+ }),
597
+ object({
598
+ integrationId: string().uuid(),
599
+ agentId: string().uuid(),
600
+ platform: literal("telegram"),
601
+ telegram: IntegrationTelegramConfig
602
+ }),
603
+ object({
604
+ integrationId: string().uuid(),
605
+ agentId: string().uuid(),
606
+ platform: literal("discord"),
607
+ discord: IntegrationDiscordConfig
608
+ })
609
+ ]);
567
610
  /** C→D EVT — install/update an integration on the owning agent's daemon. */
568
611
  const IntegrationUpsert = IntegrationSpec;
569
612
  /** C→D EVT — remove an integration from the daemon. */
@@ -1246,6 +1289,23 @@ const WebchatStatus = object({
1246
1289
  fastModeAvailable: boolean().optional(),
1247
1290
  sessionId: string().optional()
1248
1291
  });
1292
+ const WebchatOutput = object({
1293
+ conversationId: string().uuid(),
1294
+ turnId: string().uuid(),
1295
+ index: number().int(),
1296
+ event: WebchatEvent.optional(),
1297
+ status: WebchatStatus.optional()
1298
+ }).refine((o) => o.event !== void 0 || o.status !== void 0, { message: "WebchatOutput must carry event and/or status" });
1299
+ const WebchatDone = object({
1300
+ conversationId: string().uuid(),
1301
+ turnId: string().uuid(),
1302
+ stopReason: string().optional(),
1303
+ usage: object({
1304
+ used: number().int().optional(),
1305
+ cost: number().optional()
1306
+ }).optional(),
1307
+ error: string().optional()
1308
+ });
1249
1309
  //#endregion
1250
1310
  //#region ../protocol/dist/frame.js
1251
1311
  /**
@@ -1275,23 +1335,8 @@ const FRAME_SCHEMAS = {
1275
1335
  "agent/scope-denied": AgentScopeDenied,
1276
1336
  "webchat/message": WebchatMessage,
1277
1337
  "webchat/ack": WebchatAck,
1278
- "webchat/output": object({
1279
- conversationId: string().uuid(),
1280
- turnId: string().uuid(),
1281
- index: number().int(),
1282
- event: WebchatEvent.optional(),
1283
- status: WebchatStatus.optional()
1284
- }).refine((o) => o.event !== void 0 || o.status !== void 0, { message: "WebchatOutput must carry event and/or status" }),
1285
- "webchat/done": object({
1286
- conversationId: string().uuid(),
1287
- turnId: string().uuid(),
1288
- stopReason: string().optional(),
1289
- usage: object({
1290
- used: number().int().optional(),
1291
- cost: number().optional()
1292
- }).optional(),
1293
- error: string().optional()
1294
- }),
1338
+ "webchat/output": WebchatOutput,
1339
+ "webchat/done": WebchatDone,
1295
1340
  "webchat/close": object({ conversationId: string().uuid() }),
1296
1341
  "webchat/set-model": object({
1297
1342
  conversationId: string().uuid(),
@@ -1571,6 +1616,114 @@ function encode(frame) {
1571
1616
  return JSON.stringify(frame);
1572
1617
  }
1573
1618
  //#endregion
1619
+ //#region ../protocol/dist/frames/relay-daemon.js
1620
+ /**
1621
+ * relay↔daemon frames (`rd/*`) — shared-bot-relay.md §7.2.
1622
+ *
1623
+ * The daemon dials OUT to every relay in its roster (one WS per (daemon, relay)
1624
+ * pair, multiplexing every source). This wire CARRIES MESSAGE CONTENT — it is
1625
+ * the ingress data plane — so nothing on it is ever logged with its payload.
1626
+ *
1627
+ * Direction per frame:
1628
+ * - `rd/hello` (+ `rd/hello/ok`) D→R REQ / R→D REP — authenticate the dial-in
1629
+ * - `rd/msg` R→D REQ — one inbound item, already routed
1630
+ * - `rd/ack` D→R REP — receipt (+ webchat turn verdict)
1631
+ * - `rd/chat` D→R EVT — webchat output stream back to the
1632
+ * browser (webchat is the one BIDIRECTIONAL
1633
+ * source: its far end hangs off the relay)
1634
+ *
1635
+ * Milestone A carries the webchat slice only; `im` (shared bot) and `hook`
1636
+ * (webhook) members join the `rd/msg` union with milestone B.
1637
+ */
1638
+ /** Subprotocol negotiated on the relay↔daemon socket. */
1639
+ const RELAY_DAEMON_SUBPROTOCOL = "agentconnect.rd.v1";
1640
+ /** The canonical path the relay mounts its daemon-facing `rd/*` server at, and
1641
+ * the daemon appends to a roster `daemonUrl` origin when dialing (mirrors the
1642
+ * daemon↔CP `/daemon/ws` convention). A roster url already ending in it is used
1643
+ * verbatim. */
1644
+ const RELAY_DAEMON_WS_PATH = "/rd/ws";
1645
+ const RdHello = object({
1646
+ apiKey: string().min(1),
1647
+ daemonId: string().uuid()
1648
+ });
1649
+ const RdHelloOk = object({ relayId: string().uuid() });
1650
+ const RelayWebchatOp = discriminatedUnion("op", [
1651
+ object({
1652
+ op: literal("turn"),
1653
+ text: string(),
1654
+ user: string().optional()
1655
+ }),
1656
+ object({
1657
+ op: literal("set_model"),
1658
+ model: string()
1659
+ }),
1660
+ object({
1661
+ op: literal("set_effort"),
1662
+ effort: string()
1663
+ }),
1664
+ object({
1665
+ op: literal("set_permission_mode"),
1666
+ permissionMode: string()
1667
+ }),
1668
+ object({
1669
+ op: literal("set_fast"),
1670
+ fastMode: boolean()
1671
+ }),
1672
+ object({ op: literal("cancel") }),
1673
+ object({ op: literal("close") })
1674
+ ]);
1675
+ const RdMsg = discriminatedUnion("source", [object({
1676
+ source: literal("webchat"),
1677
+ agentId: string().uuid(),
1678
+ sessionKey: string().min(1),
1679
+ msgId: string().min(1),
1680
+ chatId: string().uuid(),
1681
+ payload: RelayWebchatOp
1682
+ })]);
1683
+ const RdAck = object({
1684
+ msgId: string(),
1685
+ accepted: boolean(),
1686
+ turnId: string().uuid().optional(),
1687
+ reason: string().optional()
1688
+ });
1689
+ const RdChatEvent = discriminatedUnion("kind", [object({
1690
+ kind: literal("output"),
1691
+ output: WebchatOutput
1692
+ }), object({
1693
+ kind: literal("done"),
1694
+ done: WebchatDone
1695
+ })]);
1696
+ /** `type` string → payload schema for the relay↔daemon wire. */
1697
+ const RELAY_DAEMON_SCHEMAS = {
1698
+ "rd/hello": RdHello,
1699
+ "rd/hello/ok": RdHelloOk,
1700
+ "rd/msg": RdMsg,
1701
+ "rd/ack": RdAck,
1702
+ "rd/chat": object({
1703
+ chatId: string().uuid(),
1704
+ seq: number().int(),
1705
+ event: RdChatEvent
1706
+ }),
1707
+ error: ErrorFrame
1708
+ };
1709
+ Object.keys(RELAY_DAEMON_SCHEMAS);
1710
+ discriminatedUnion("type", [
1711
+ frameSchema("rd/hello", RELAY_DAEMON_SCHEMAS["rd/hello"]),
1712
+ frameSchema("rd/hello/ok", RELAY_DAEMON_SCHEMAS["rd/hello/ok"]),
1713
+ frameSchema("rd/msg", RELAY_DAEMON_SCHEMAS["rd/msg"]),
1714
+ frameSchema("rd/ack", RELAY_DAEMON_SCHEMAS["rd/ack"]),
1715
+ frameSchema("rd/chat", RELAY_DAEMON_SCHEMAS["rd/chat"]),
1716
+ frameSchema("error", RELAY_DAEMON_SCHEMAS["error"])
1717
+ ]);
1718
+ /** Decode one relay↔daemon wire frame (envelope + typed payload). */
1719
+ function decodeRelayDaemonFrame(text) {
1720
+ return decodeEnvelopeWith(RELAY_DAEMON_SCHEMAS, text);
1721
+ }
1722
+ /** Build a relay↔daemon frame with a compile-time-typed payload. */
1723
+ function buildRelayDaemonFrame(type, payload, opts = {}) {
1724
+ return buildEnvelopeRaw(type, payload, opts);
1725
+ }
1726
+ //#endregion
1574
1727
  //#region ../protocol/dist/git-url.js
1575
1728
  /**
1576
1729
  * Git repo address helpers, shared by the CP (normalize on write) and the
@@ -10694,6 +10847,6 @@ var AcpHost = class {
10694
10847
  }
10695
10848
  };
10696
10849
  //#endregion
10697
- export { cachedRuntimeNames as _, initGitInjection as a, simpleGit as c, buildEnvelope as d, decodeEnvelope as f, RESERVED_MCP_SERVER_NAME as g, MEMORY_INDEX as h, prepareWorkspace as i, isFrame as l, MAX_FRAME_BYTES as m, installedRuntimes as n, probeGitVersion as o, encode as p, prefetchWorkspace as r, sessionGitEnv as s, AcpHost as t, normalizeGitUrl as u, cachedRuntimeVersions as v, resolveRuntimes as y };
10850
+ export { resolveRuntimes as C, cachedRuntimeVersions as S, encode as _, initGitInjection as a, RESERVED_MCP_SERVER_NAME as b, simpleGit as c, RELAY_DAEMON_SUBPROTOCOL as d, RELAY_DAEMON_WS_PATH as f, decodeEnvelope as g, buildEnvelope as h, prepareWorkspace as i, isFrame as l, decodeRelayDaemonFrame as m, installedRuntimes as n, probeGitVersion as o, buildRelayDaemonFrame as p, prefetchWorkspace as r, sessionGitEnv as s, AcpHost as t, normalizeGitUrl as u, MAX_FRAME_BYTES as v, cachedRuntimeNames as x, MEMORY_INDEX as y };
10698
10851
 
10699
- //# sourceMappingURL=acp-host-CF3j4yST.js.map
10852
+ //# sourceMappingURL=acp-host-D_V0pKJA.js.map