@moltzap/client 2026.811.0 → 2026.812.0

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.
Files changed (190) hide show
  1. package/dist/channel-base/index.d.ts +4 -4
  2. package/dist/channel-base/index.d.ts.map +1 -1
  3. package/dist/channel-base/index.js +6 -3
  4. package/dist/channel-base/index.js.map +1 -1
  5. package/dist/channel-core-enrichment.d.ts +24 -0
  6. package/dist/channel-core-enrichment.d.ts.map +1 -1
  7. package/dist/channel-core-enrichment.js +94 -20
  8. package/dist/channel-core-enrichment.js.map +1 -1
  9. package/dist/channel-core.d.ts +3 -1
  10. package/dist/channel-core.d.ts.map +1 -1
  11. package/dist/channel-core.js +2 -0
  12. package/dist/channel-core.js.map +1 -1
  13. package/dist/config.d.ts +2 -2
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +7 -1
  16. package/dist/config.js.map +1 -1
  17. package/dist/config.test-utils.d.ts +6 -0
  18. package/dist/config.test-utils.d.ts.map +1 -1
  19. package/dist/config.test-utils.js +5 -1
  20. package/dist/config.test-utils.js.map +1 -1
  21. package/dist/harness/client-runtime.d.ts +12 -5
  22. package/dist/harness/client-runtime.d.ts.map +1 -1
  23. package/dist/harness/client-runtime.js +16 -2
  24. package/dist/harness/client-runtime.js.map +1 -1
  25. package/dist/harness/index.d.ts +2 -2
  26. package/dist/harness/index.d.ts.map +1 -1
  27. package/dist/harness/index.js +2 -2
  28. package/dist/harness/index.js.map +1 -1
  29. package/dist/harness/runtime.d.ts +152 -0
  30. package/dist/harness/runtime.d.ts.map +1 -1
  31. package/dist/harness/runtime.js +99 -2
  32. package/dist/harness/runtime.js.map +1 -1
  33. package/dist/harness-client.d.ts +17 -13
  34. package/dist/harness-client.d.ts.map +1 -1
  35. package/dist/harness-client.js +59 -4
  36. package/dist/harness-client.js.map +1 -1
  37. package/dist/harness-context-projection.d.ts +35 -0
  38. package/dist/harness-context-projection.d.ts.map +1 -0
  39. package/dist/harness-context-projection.js +123 -0
  40. package/dist/harness-context-projection.js.map +1 -0
  41. package/dist/harness-mcp-server.d.ts +1 -2
  42. package/dist/harness-mcp-server.d.ts.map +1 -1
  43. package/dist/harness-mcp-server.js +11 -17
  44. package/dist/harness-mcp-server.js.map +1 -1
  45. package/dist/harness-mcp-wire.d.ts +47 -15
  46. package/dist/harness-mcp-wire.d.ts.map +1 -1
  47. package/dist/harness-mcp-wire.js +93 -37
  48. package/dist/harness-mcp-wire.js.map +1 -1
  49. package/dist/index.d.ts +3 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/local-paths.d.ts +0 -11
  54. package/dist/local-paths.d.ts.map +1 -1
  55. package/dist/local-paths.js +0 -12
  56. package/dist/local-paths.js.map +1 -1
  57. package/dist/moltzapd-catalog.d.ts +35 -0
  58. package/dist/moltzapd-catalog.d.ts.map +1 -0
  59. package/dist/moltzapd-catalog.js +117 -0
  60. package/dist/moltzapd-catalog.js.map +1 -0
  61. package/dist/moltzapd-child-ipc.d.ts +26 -0
  62. package/dist/moltzapd-child-ipc.d.ts.map +1 -0
  63. package/dist/moltzapd-child-ipc.js +31 -0
  64. package/dist/moltzapd-child-ipc.js.map +1 -0
  65. package/dist/moltzapd-child.d.ts +55 -0
  66. package/dist/moltzapd-child.d.ts.map +1 -0
  67. package/dist/moltzapd-child.js +225 -0
  68. package/dist/moltzapd-child.js.map +1 -0
  69. package/dist/moltzapd-main.d.ts +3 -0
  70. package/dist/moltzapd-main.d.ts.map +1 -0
  71. package/dist/moltzapd-main.js +18 -0
  72. package/dist/moltzapd-main.js.map +1 -0
  73. package/dist/moltzapd-registration.d.ts +40 -0
  74. package/dist/moltzapd-registration.d.ts.map +1 -0
  75. package/dist/moltzapd-registration.js +59 -0
  76. package/dist/moltzapd-registration.js.map +1 -0
  77. package/dist/moltzapd.d.ts +56 -9
  78. package/dist/moltzapd.d.ts.map +1 -1
  79. package/dist/moltzapd.js +108 -36
  80. package/dist/moltzapd.js.map +1 -1
  81. package/dist/notification/trace.d.ts +10 -0
  82. package/dist/notification/trace.d.ts.map +1 -0
  83. package/dist/notification/trace.js +34 -0
  84. package/dist/notification/trace.js.map +1 -0
  85. package/dist/presentation/index.d.ts +3 -0
  86. package/dist/presentation/index.d.ts.map +1 -0
  87. package/dist/presentation/index.js +3 -0
  88. package/dist/presentation/index.js.map +1 -0
  89. package/dist/presentation/state.d.ts +77 -0
  90. package/dist/presentation/state.d.ts.map +1 -0
  91. package/dist/presentation/state.js +211 -0
  92. package/dist/presentation/state.js.map +1 -0
  93. package/dist/profile.d.ts +30 -28
  94. package/dist/profile.d.ts.map +1 -1
  95. package/dist/profile.js +28 -20
  96. package/dist/profile.js.map +1 -1
  97. package/dist/service.d.ts +8 -79
  98. package/dist/service.d.ts.map +1 -1
  99. package/dist/service.js +29 -333
  100. package/dist/service.js.map +1 -1
  101. package/dist/test-utils/fake-service.d.ts +3 -5
  102. package/dist/test-utils/fake-service.d.ts.map +1 -1
  103. package/dist/test-utils/fake-service.js +12 -12
  104. package/dist/test-utils/fake-service.js.map +1 -1
  105. package/dist/test-utils/index.d.ts +2 -0
  106. package/dist/test-utils/index.d.ts.map +1 -1
  107. package/dist/test-utils/index.js +2 -0
  108. package/dist/test-utils/index.js.map +1 -1
  109. package/dist/test-utils/process/reserve-port.d.ts +20 -0
  110. package/dist/test-utils/process/reserve-port.d.ts.map +1 -0
  111. package/dist/test-utils/process/reserve-port.js +41 -0
  112. package/dist/test-utils/process/reserve-port.js.map +1 -0
  113. package/dist/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +32 -6
  115. package/dist/cli/adapters.d.ts +0 -21
  116. package/dist/cli/adapters.d.ts.map +0 -1
  117. package/dist/cli/adapters.js +0 -111
  118. package/dist/cli/adapters.js.map +0 -1
  119. package/dist/cli/commands/agents.d.ts +0 -11
  120. package/dist/cli/commands/agents.d.ts.map +0 -1
  121. package/dist/cli/commands/agents.js +0 -27
  122. package/dist/cli/commands/agents.js.map +0 -1
  123. package/dist/cli/commands/conversations.d.ts +0 -18
  124. package/dist/cli/commands/conversations.d.ts.map +0 -1
  125. package/dist/cli/commands/conversations.js +0 -33
  126. package/dist/cli/commands/conversations.js.map +0 -1
  127. package/dist/cli/commands/messages.d.ts +0 -41
  128. package/dist/cli/commands/messages.d.ts.map +0 -1
  129. package/dist/cli/commands/messages.js +0 -39
  130. package/dist/cli/commands/messages.js.map +0 -1
  131. package/dist/cli/commands/register.d.ts +0 -46
  132. package/dist/cli/commands/register.d.ts.map +0 -1
  133. package/dist/cli/commands/register.js +0 -103
  134. package/dist/cli/commands/register.js.map +0 -1
  135. package/dist/cli/commands/send.d.ts +0 -53
  136. package/dist/cli/commands/send.d.ts.map +0 -1
  137. package/dist/cli/commands/send.js +0 -57
  138. package/dist/cli/commands/send.js.map +0 -1
  139. package/dist/cli/commands/start.d.ts +0 -34
  140. package/dist/cli/commands/start.d.ts.map +0 -1
  141. package/dist/cli/commands/start.js +0 -59
  142. package/dist/cli/commands/start.js.map +0 -1
  143. package/dist/cli/commands/status.d.ts +0 -7
  144. package/dist/cli/commands/status.d.ts.map +0 -1
  145. package/dist/cli/commands/status.js +0 -16
  146. package/dist/cli/commands/status.js.map +0 -1
  147. package/dist/cli/commands/test-transport.d.ts +0 -28
  148. package/dist/cli/commands/test-transport.d.ts.map +0 -1
  149. package/dist/cli/commands/test-transport.js +0 -40
  150. package/dist/cli/commands/test-transport.js.map +0 -1
  151. package/dist/cli/index.d.ts +0 -3
  152. package/dist/cli/index.d.ts.map +0 -1
  153. package/dist/cli/index.js +0 -105
  154. package/dist/cli/index.js.map +0 -1
  155. package/dist/cli/output.d.ts +0 -14
  156. package/dist/cli/output.d.ts.map +0 -1
  157. package/dist/cli/output.js +0 -19
  158. package/dist/cli/output.js.map +0 -1
  159. package/dist/cli/socket-client.d.ts +0 -28
  160. package/dist/cli/socket-client.d.ts.map +0 -1
  161. package/dist/cli/socket-client.js +0 -63
  162. package/dist/cli/socket-client.js.map +0 -1
  163. package/dist/cli/transport.d.ts +0 -132
  164. package/dist/cli/transport.d.ts.map +0 -1
  165. package/dist/cli/transport.js +0 -127
  166. package/dist/cli/transport.js.map +0 -1
  167. package/dist/local-daemon-rpc.d.ts +0 -1170
  168. package/dist/local-daemon-rpc.d.ts.map +0 -1
  169. package/dist/local-daemon-rpc.js +0 -178
  170. package/dist/local-daemon-rpc.js.map +0 -1
  171. package/dist/local-history.d.ts +0 -75
  172. package/dist/local-history.d.ts.map +0 -1
  173. package/dist/local-history.js +0 -82
  174. package/dist/local-history.js.map +0 -1
  175. package/dist/local-socket-server.d.ts +0 -33
  176. package/dist/local-socket-server.d.ts.map +0 -1
  177. package/dist/local-socket-server.js +0 -100
  178. package/dist/local-socket-server.js.map +0 -1
  179. package/dist/refs.d.ts +0 -18
  180. package/dist/refs.d.ts.map +0 -1
  181. package/dist/refs.js +0 -18
  182. package/dist/refs.js.map +0 -1
  183. package/dist/service-helpers.d.ts +0 -55
  184. package/dist/service-helpers.d.ts.map +0 -1
  185. package/dist/service-helpers.js +0 -108
  186. package/dist/service-helpers.js.map +0 -1
  187. package/dist/service-local-daemon.d.ts +0 -32
  188. package/dist/service-local-daemon.d.ts.map +0 -1
  189. package/dist/service-local-daemon.js +0 -153
  190. package/dist/service-local-daemon.js.map +0 -1
@@ -2,7 +2,6 @@ import { Path } from "@effect/platform";
2
2
  import { Config, ConfigProvider, Effect, Option } from "effect";
3
3
  const MOLTZAP_DIR_NAME = ".moltzap";
4
4
  const CONFIG_FILE_NAME = "config.json";
5
- const SERVICE_SOCKET_FILE_NAME = "service.sock";
6
5
  const configHome = Config.option(Config.string("MOLTZAP_CONFIG_HOME"));
7
6
  const homeDir = Config.string("HOME").pipe(Config.orElse(() => Config.string("USERPROFILE")));
8
7
  const getConfigHomeSync = () => Option.getOrUndefined(Effect.runSync(configHome.pipe(Effect.withConfigProvider(ConfigProvider.fromEnv()))));
@@ -19,15 +18,4 @@ export const getMoltZapConfigDir = () => getConfigHomeSync() ?? getMoltZapHomeDi
19
18
  * @returns The get molt zap config path result.
20
19
  */
21
20
  export const getMoltZapConfigPath = () => pathSync((path) => path.join(getMoltZapConfigDir(), CONFIG_FILE_NAME));
22
- /**
23
- * Provides the get molt zap service socket path runtime value.
24
- * @returns The get molt zap service socket path result.
25
- */
26
- export const getMoltZapServiceSocketPath = () => pathSync((path) => path.join(getMoltZapConfigDir(), SERVICE_SOCKET_FILE_NAME));
27
- /**
28
- * Provides the get molt zap agent service socket path runtime value.
29
- * @param agentId Identifier of the agent targeted by the operation.
30
- * @returns The get molt zap agent service socket path result.
31
- */
32
- export const getMoltZapAgentServiceSocketPath = (agentId) => pathSync((path) => path.join(getMoltZapConfigDir(), `service-${agentId}.sock`));
33
21
  //# sourceMappingURL=local-paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-paths.js","sourceRoot":"","sources":["../src/local-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AACvC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAEhD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;AACvE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACxC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAClD,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAuB,EAAE,CACjD,MAAM,CAAC,cAAc,CACnB,MAAM,CAAC,OAAO,CACZ,UAAU,CAAC,IAAI,CAAC,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AAC,CAAC;AAE5E,MAAM,iBAAiB,GAAG,GAAW,EAAE,CACrC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAC9C,iBAAiB,EAAE,IAAI,iBAAiB,EAAE,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAW,EAAE,CAC/C,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { Effect } from "effect";
2
+ import type { MoltZapChannelCore } from "./channel-core.js";
3
+ import type { HarnessStatusInput, HarnessStatusResult } from "./harness/index.js";
4
+ import type { HarnessActiveTools, HarnessDaemonPhase } from "./harness-mcp-wire.js";
5
+ import type { MoltZapService } from "./service.js";
6
+ /** Answers the `status` tool in whichever catalog is current. */
7
+ export type StatusHandler = (payload: HarnessStatusInput) => Effect.Effect<HarnessStatusResult>;
8
+ /**
9
+ * Tracks which catalog the listener serves. The MCP SDK builds a fresh server
10
+ * per request, so flipping this is the whole state transition — the listener
11
+ * is never rebound and its URL never changes.
12
+ */
13
+ export interface DaemonPhaseState {
14
+ readonly read: () => HarnessDaemonPhase;
15
+ readonly setActive: (tools: HarnessActiveTools) => void;
16
+ }
17
+ /**
18
+ * Creates the phase holder a daemon starts with.
19
+ * @returns A phase reader plus its one-way transition to the active catalog.
20
+ */
21
+ export declare const makeDaemonPhaseState: () => DaemonPhaseState;
22
+ /**
23
+ * Answers `status` for a slot with no committed identity. There is no service
24
+ * to ask, so it answers for itself: reachable, but holding nothing.
25
+ * @returns The uncommitted slot's status.
26
+ */
27
+ export declare const slotStatusHandler: StatusHandler;
28
+ /**
29
+ * Binds the six active tools to one registered agent's service and core.
30
+ * @param service Connected service for the slot's committed identity.
31
+ * @param core Channel core owning the network connection.
32
+ * @returns The active catalog's handlers.
33
+ */
34
+ export declare const makeActiveTools: (service: MoltZapService, core: MoltZapChannelCore) => HarnessActiveTools;
35
+ //# sourceMappingURL=moltzapd-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-catalog.d.ts","sourceRoot":"","sources":["../src/moltzapd-catalog.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAIV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,kBAAkB,KACxB,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,kBAAkB,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACzD;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAO,gBAQvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aACwB,CAAC;AA2GzD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,YACjB,cAAc,QACjB,kBAAkB,KACvB,kBAQD,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The two catalogs a `moltzapd` listener can serve, and which one is current.
3
+ *
4
+ * A profile slot exists before Registry commit and has no service behind it, so
5
+ * the daemon serves a slot catalog until an identity lands and the active
6
+ * catalog afterward.
7
+ */
8
+ import { agentConversationCreate, conversationList, conversationSearch, } from "@moltzap/protocol/conversation";
9
+ import { AgentNotFoundError, agentsSearch, } from "@moltzap/protocol/identity";
10
+ import { messagesRead, messagesSend } from "@moltzap/protocol/message";
11
+ import { Effect } from "effect";
12
+ import { drainPaginatedList } from "./pagination.js";
13
+ /**
14
+ * Creates the phase holder a daemon starts with.
15
+ * @returns A phase reader plus its one-way transition to the active catalog.
16
+ */
17
+ export const makeDaemonPhaseState = () => {
18
+ let phase = { kind: "slot" };
19
+ return {
20
+ read: () => phase,
21
+ setActive: (tools) => {
22
+ phase = { kind: "active", tools };
23
+ },
24
+ };
25
+ };
26
+ /**
27
+ * Answers `status` for a slot with no committed identity. There is no service
28
+ * to ask, so it answers for itself: reachable, but holding nothing.
29
+ * @returns The uncommitted slot's status.
30
+ */
31
+ export const slotStatusHandler = () => Effect.succeed({ connected: false, conversations: 0 });
32
+ const makeStatusHandler = (service, core) => () => Effect.succeed({
33
+ ...(service.ownAgentId === undefined
34
+ ? {}
35
+ : { agentId: service.ownAgentId }),
36
+ connected: core.isConnected(),
37
+ conversations: service.getConversations().length,
38
+ });
39
+ const searchConversationsForHarness = (service, params) => Effect.gen(function* () {
40
+ const page = yield* service.callDefinition(conversationSearch, params);
41
+ const listed = yield* drainPaginatedList({
42
+ definition: conversationList,
43
+ sendRpc: (definition, listParams) => service.callDefinition(definition, listParams),
44
+ paramsForCursor: (cursor) => (cursor === undefined ? {} : { cursor }),
45
+ rowsForPage: (listPage) => listPage.items,
46
+ nextCursorForPage: (listPage) => listPage.nextCursor,
47
+ });
48
+ const participantsByConversation = new Map(listed.map((item) => [item.conversation.id, item.participants]));
49
+ return {
50
+ conversations: page.conversations.map((conversation) => ({
51
+ ...conversation,
52
+ participants: [
53
+ ...(participantsByConversation.get(conversation.id) ?? []),
54
+ ],
55
+ })),
56
+ ...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
57
+ };
58
+ }).pipe(Effect.withSpan("moltzapd.searchConversations"));
59
+ const agentNotFound = (agentName) => new AgentNotFoundError({
60
+ message: `Agent not found: ${agentName}`,
61
+ data: { agentName },
62
+ });
63
+ const resolveAgentByName = (service, name) => service.callDefinition(agentsSearch, { query: name }).pipe(Effect.flatMap(({ agents }) => {
64
+ const agent = agents.find((candidate) => candidate.name === name);
65
+ return agent === undefined
66
+ ? Effect.fail(agentNotFound(name))
67
+ : Effect.succeed(agent);
68
+ }));
69
+ const startConversationForHarness = (service, input) => Effect.gen(function* () {
70
+ if (new Set(input.otherAgentNames).size !== input.otherAgentNames.length) {
71
+ // eslint-disable-next-line agent-code-guard/effect-error-erasure -- Local MCP validation stays on the established broad Error boundary without adding a portable protocol error.
72
+ return yield* Effect.fail(new Error("Conversation participants must be unique"));
73
+ }
74
+ const participants = yield* Effect.forEach(input.otherAgentNames, (name) => resolveAgentByName(service, name), { concurrency: 2 });
75
+ const ownAgentId = service.ownAgentId;
76
+ if (ownAgentId === undefined) {
77
+ // eslint-disable-next-line agent-code-guard/effect-error-erasure -- A missing daemon identity is rejected at the local composition boundary whose existing contract is Error.
78
+ return yield* Effect.fail(new Error("Daemon has no agent identity"));
79
+ }
80
+ if (participants.some((participant) => participant.id === ownAgentId)) {
81
+ // eslint-disable-next-line agent-code-guard/effect-error-erasure -- Local MCP validation stays on the established broad Error boundary without adding a portable protocol error.
82
+ return yield* Effect.fail(new Error("The daemon agent is an implicit conversation participant"));
83
+ }
84
+ const created = yield* service.callDefinition(agentConversationCreate, {
85
+ participants: participants.map((participant) => participant.id),
86
+ });
87
+ yield* service.callDefinition(messagesSend, {
88
+ conversationId: created.conversation.id,
89
+ parts: [{ type: "text", text: input.initialContent }],
90
+ });
91
+ // Participants are endpoint-owned context on the MCP boundary. The
92
+ // canonical Conversation value sent over the network remains closed.
93
+ return {
94
+ conversation: {
95
+ ...created.conversation,
96
+ participants: [
97
+ ownAgentId,
98
+ ...participants.map((participant) => participant.id),
99
+ ],
100
+ },
101
+ };
102
+ }).pipe(Effect.withSpan("moltzapd.startConversation"));
103
+ /**
104
+ * Binds the six active tools to one registered agent's service and core.
105
+ * @param service Connected service for the slot's committed identity.
106
+ * @param core Channel core owning the network connection.
107
+ * @returns The active catalog's handlers.
108
+ */
109
+ export const makeActiveTools = (service, core) => ({
110
+ readConversation: (payload) => service.callDefinition(messagesRead, payload),
111
+ reply: core.sendReply.bind(core),
112
+ searchAgents: (payload) => service.callDefinition(agentsSearch, payload),
113
+ searchConversations: (payload) => searchConversationsForHarness(service, payload),
114
+ startConversation: (payload) => startConversationForHarness(service, payload),
115
+ status: makeStatusHandler(service, core),
116
+ });
117
+ //# sourceMappingURL=moltzapd-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-catalog.js","sourceRoot":"","sources":["../src/moltzapd-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,YAAY,GAEb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAahC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAkBrD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAqB,EAAE;IACzD,IAAI,KAAK,GAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACjD,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK;QACjB,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACnB,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG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,CAAC;CACzC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Effect } from "effect";
2
+ declare const READY_MESSAGE_TYPE = "moltzapd.ready";
3
+ interface MoltzapdReadyMessage {
4
+ readonly type: typeof READY_MESSAGE_TYPE;
5
+ }
6
+ declare const MoltzapdReadySignalError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
7
+ readonly _tag: "MoltzapdReadySignalError";
8
+ } & Readonly<A>;
9
+ /** Reports a failure to deliver readiness over the parent IPC channel. */
10
+ export declare class MoltzapdReadySignalError extends MoltzapdReadySignalError_base<{
11
+ readonly cause: unknown;
12
+ }> {
13
+ }
14
+ /**
15
+ * Whether an IPC payload is the daemon's post-acquisition readiness signal.
16
+ * @param value Untrusted payload received from the child process.
17
+ * @returns Whether the payload is the private readiness message.
18
+ */
19
+ export declare const isMoltzapdReadyMessage: (value: unknown) => value is MoltzapdReadyMessage;
20
+ /**
21
+ * Signals the supervising parent after this process acquires its daemon.
22
+ * A directly launched daemon has no IPC parent and therefore needs no signal.
23
+ */
24
+ export declare const signalMoltzapdReady: Effect.Effect<undefined, MoltzapdReadySignalError>;
25
+ export {};
26
+ //# sourceMappingURL=moltzapd-child-ipc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-child-ipc.d.ts","sourceRoot":"","sources":["../src/moltzapd-child-ipc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,QAAA,MAAM,kBAAkB,mBAAmB,CAAC;AAE5C,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,kBAAkB,CAAC;CAC1C;;;;AAID,0EAA0E;AAC1E,qBAAa,wBAAyB,SAAQ,8BAE5C;IACA,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;CAAG;AAEL;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAC1B,OAAO,KACb,KAAK,IAAI,oBAIuB,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAC7C,SAAS,EACT,wBAAwB,CAaxB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { Data, Effect } from "effect";
2
+ const READY_MESSAGE_TYPE = "moltzapd.ready";
3
+ const readyMessage = { type: READY_MESSAGE_TYPE };
4
+ /** Reports a failure to deliver readiness over the parent IPC channel. */
5
+ export class MoltzapdReadySignalError extends Data.TaggedError("MoltzapdReadySignalError") {
6
+ }
7
+ /**
8
+ * Whether an IPC payload is the daemon's post-acquisition readiness signal.
9
+ * @param value Untrusted payload received from the child process.
10
+ * @returns Whether the payload is the private readiness message.
11
+ */
12
+ export const isMoltzapdReadyMessage = (value) => typeof value === "object" &&
13
+ value !== null &&
14
+ "type" in value &&
15
+ value.type === READY_MESSAGE_TYPE;
16
+ /**
17
+ * Signals the supervising parent after this process acquires its daemon.
18
+ * A directly launched daemon has no IPC parent and therefore needs no signal.
19
+ */
20
+ export const signalMoltzapdReady = Effect.async((resume) => {
21
+ if (process.send === undefined) {
22
+ resume(Effect.succeed(undefined));
23
+ return;
24
+ }
25
+ process.send(readyMessage, (cause) => {
26
+ resume(cause === null
27
+ ? Effect.succeed(undefined)
28
+ : Effect.fail(new MoltzapdReadySignalError({ cause })));
29
+ });
30
+ });
31
+ //# sourceMappingURL=moltzapd-child-ipc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-child-ipc.js","sourceRoot":"","sources":["../src/moltzapd-child-ipc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAM5C,MAAM,YAAY,GAAyB,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;AAExE,0EAA0E;AAC1E,MAAM,OAAO,wBAAyB,SAAQ,IAAI,CAAC,WAAW,CAC5D,0BAA0B,CAG1B;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAc,EACiB,EAAE,CACjC,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,MAAM,IAAI,KAAK;IACf,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAG5B,MAAM,CAAC,KAAK,CAAsC,CAAC,MAAM,EAAE,EAAE;IAC/D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QAClC,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;QACnC,MAAM,CACJ,KAAK,KAAK,IAAI;YACZ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CACzD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Duration, Effect, type Scope } from "effect";
2
+ import { type HarnessClientService } from "./harness-client.js";
3
+ declare const MoltzapdChildError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
4
+ readonly _tag: "MoltzapdChildError";
5
+ } & Readonly<A>;
6
+ declare class MoltzapdChildError extends MoltzapdChildError_base<{
7
+ readonly message: string;
8
+ readonly cause?: unknown;
9
+ }> {
10
+ }
11
+ /** Scoped endpoint for a packaged profile daemon owned by the caller. */
12
+ export interface MoltzapdChild {
13
+ readonly mcpUrl: string;
14
+ readonly logs: () => string;
15
+ }
16
+ /** Inputs for starting a packaged profile daemon. */
17
+ export interface MoltzapdChildOptions {
18
+ readonly profileName: string;
19
+ }
20
+ /**
21
+ * Bounds and interrupts the complete child-readiness sequence.
22
+ * @param readiness IPC, endpoint connection, status, and liveness checks.
23
+ * @param logs Bounded child output included in the timeout diagnostic.
24
+ * @param within Startup budget; production uses one fixed local deadline.
25
+ * @returns The readiness result before the shared deadline.
26
+ * @internal
27
+ */
28
+ export declare const withMoltzapdStartupDeadline: <A, E, R>(readiness: Effect.Effect<A, E, R>, logs: () => string, within?: Duration.DurationInput) => Effect.Effect<A, E | MoltzapdChildError, R>;
29
+ /**
30
+ * Starts the package's real `moltzapd` binary against an existing slot.
31
+ * The slot carries the loopback port, so the child receives only its profile
32
+ * name and the returned URL is derived from the same persisted value.
33
+ *
34
+ * @param options Existing profile name for the child process.
35
+ * @returns A scoped packaged daemon after its MCP status reports connected.
36
+ */
37
+ export declare const acquireMoltzapdChild: (options: MoltzapdChildOptions) => Effect.Effect<MoltzapdChild, MoltzapdChildError, Scope.Scope>;
38
+ /**
39
+ * Acquire the adapter-facing client for one named profile slot.
40
+ *
41
+ * This is the whole production composition: the slot's own daemon child, the
42
+ * loopback endpoint derived from the slot, and a file-backed checkpoint store.
43
+ * A caller supplies only the profile name — no URL, no port, no store.
44
+ *
45
+ * The checkpoint directory is keyed by profile name rather than AgentId,
46
+ * because the store must be provided before `acquireHarnessClient` reads the
47
+ * identity from the daemon's status tool. One slot is exactly one AgentId, so
48
+ * the profile name is a stable agent scope.
49
+ *
50
+ * @param profileName Existing slot owning the daemon and its checkpoints.
51
+ * @returns The scoped adapter-facing service value.
52
+ */
53
+ export declare const harnessClientForProfile: (profileName: string) => Effect.Effect<HarnessClientService, MoltzapdChildError | Error, Scope.Scope>;
54
+ export {};
55
+ //# sourceMappingURL=moltzapd-child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzap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"@modelcontextprotocol/client";
2
+ import { spawn } from "node:child_process";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { NodeContext } from "@effect/platform-node";
6
+ import * as KeyValueStore from "@effect/platform/KeyValueStore";
7
+ import { Data, Deferred, Duration, Effect, Exit, Layer, } from "effect";
8
+ import packageJson from "../package.json" with { type: "json" };
9
+ import { acquireHarnessClient, } from "./harness-client.js";
10
+ import { decodeHarnessStatusResult, HARNESS_STATUS_TOOL, } from "./harness/index.js";
11
+ import { getMoltZapConfigDir } from "./local-paths.js";
12
+ import { isMoltzapdReadyMessage } from "./moltzapd-child-ipc.js";
13
+ import { isRegisteredProfile, parseProfileName, resolveProfileRecord, } from "./profile.js";
14
+ const LOOPBACK_HOST = "127.0.0.1";
15
+ const MCP_PATH = "/mcp";
16
+ const MODERN_PROTOCOL_VERSION = "2026-07-28";
17
+ const POLL_INTERVAL = Duration.millis(25);
18
+ const STARTUP_TIMEOUT = Duration.seconds(15);
19
+ const STARTUP_TIMEOUT_MILLIS = Duration.toMillis(STARTUP_TIMEOUT);
20
+ const SHUTDOWN_TIMEOUT = Duration.seconds(5);
21
+ const OUTPUT_TAIL_LIMIT = 64 * 1024;
22
+ const OUTPUT_TRUNCATED_NOTICE = "[earlier moltzapd output truncated]\n";
23
+ const packageRoot = fileURLToPath(new URL("../", import.meta.url));
24
+ const daemonEntry = join(packageRoot, packageJson.bin.moltzapd);
25
+ class MoltzapdChildError extends Data.TaggedError("MoltzapdChildError") {
26
+ }
27
+ const moltzapdChildError = (message, cause) => new MoltzapdChildError({ message, cause });
28
+ const toError = (cause) => {
29
+ if (cause instanceof MoltzapdChildError) {
30
+ return cause;
31
+ }
32
+ const message = cause instanceof Error ? cause.message : String(cause);
33
+ return moltzapdChildError(message, cause);
34
+ };
35
+ const makeOutputTail = () => {
36
+ let output = "";
37
+ let truncated = false;
38
+ const append = (chunk) => {
39
+ output += chunk;
40
+ if (output.length > OUTPUT_TAIL_LIMIT) {
41
+ output = output.slice(-OUTPUT_TAIL_LIMIT);
42
+ truncated = true;
43
+ }
44
+ };
45
+ const read = () => truncated ? `${OUTPUT_TRUNCATED_NOTICE}${output}` : output;
46
+ return {
47
+ append,
48
+ read,
49
+ };
50
+ };
51
+ const startDaemon = (profileName) => {
52
+ const output = makeOutputTail();
53
+ const readiness = Effect.runSync(Deferred.make());
54
+ const child = spawn(process.execPath, [daemonEntry, "--profile", profileName], {
55
+ cwd: packageRoot,
56
+ // eslint-disable-next-line agent-code-guard/no-process-env-at-runtime -- The isolated child inherits the caller-scoped test profile and server URL.
57
+ env: { ...process.env },
58
+ stdio: ["ignore", "pipe", "pipe", "ipc"],
59
+ });
60
+ const onMessage = (message) => {
61
+ if (isMoltzapdReadyMessage(message)) {
62
+ child.off("message", onMessage);
63
+ Effect.runSync(Deferred.succeed(readiness, undefined));
64
+ }
65
+ };
66
+ child.on("message", onMessage);
67
+ child.once("exit", () => {
68
+ child.off("message", onMessage);
69
+ });
70
+ child.stdout?.setEncoding("utf8");
71
+ child.stderr?.setEncoding("utf8");
72
+ child.stdout?.on("data", output.append);
73
+ child.stderr?.on("data", output.append);
74
+ return { child, logs: output.read, readiness };
75
+ };
76
+ const waitForExit = (running) => {
77
+ if (running.child.exitCode !== null || running.child.signalCode !== null) {
78
+ return Effect.succeed(undefined);
79
+ }
80
+ return Effect.async((resume) => {
81
+ const onExit = () => {
82
+ resume(Effect.succeed(undefined));
83
+ };
84
+ running.child.once("exit", onExit);
85
+ return Effect.sync(() => {
86
+ running.child.off("exit", onExit);
87
+ });
88
+ });
89
+ };
90
+ const stopDaemon = (running) => Effect.gen(function* () {
91
+ if (running.child.exitCode !== null || running.child.signalCode !== null) {
92
+ return;
93
+ }
94
+ running.child.kill("SIGTERM");
95
+ const stopped = yield* Effect.raceFirst(waitForExit(running).pipe(Effect.as(true)), Effect.sleep(SHUTDOWN_TIMEOUT).pipe(Effect.as(false)));
96
+ if (stopped) {
97
+ return;
98
+ }
99
+ running.child.kill("SIGKILL");
100
+ yield* waitForExit(running);
101
+ });
102
+ const exitDescription = (running) => {
103
+ if (running.child.signalCode !== null) {
104
+ return ` after signal ${running.child.signalCode}`;
105
+ }
106
+ if (running.child.exitCode !== null) {
107
+ return ` with code ${String(running.child.exitCode)}`;
108
+ }
109
+ return "";
110
+ };
111
+ const exitedBeforeReadiness = (running) => moltzapdChildError(`moltzapd exited${exitDescription(running)} before readiness\n${running.logs()}`);
112
+ const failWhenDaemonExits = (running) => waitForExit(running).pipe(Effect.flatMap(() => Effect.fail(exitedBeforeReadiness(running))));
113
+ const observeDaemonDuringReadiness = (running, readiness) => Effect.raceFirst(readiness, failWhenDaemonExits(running));
114
+ const ensureDaemonIsRunning = (running) => running.child.exitCode === null && running.child.signalCode === null
115
+ ? Effect.void
116
+ : Effect.fail(exitedBeforeReadiness(running));
117
+ const waitForReadySignal = (running) => Deferred.await(running.readiness);
118
+ const acquireDaemon = (profileName) => Effect.acquireRelease(Effect.sync(() => startDaemon(profileName)), (running) => stopDaemon(running));
119
+ const closeMcpClient = (client) => Effect.tryPromise({ try: () => client.close(), catch: toError }).pipe(Effect.ignore);
120
+ const connectMcpOnce = (url) => Effect.gen(function* () {
121
+ const client = new Client({ name: "moltzapd-child", version: "1.0.0" }, { versionNegotiation: { mode: { pin: MODERN_PROTOCOL_VERSION } } });
122
+ // A client that fails to connect still holds a transport, so the failure
123
+ // path closes it before surfacing the cause.
124
+ yield* Effect.tryPromise({
125
+ try: (signal) => client.connect(new StreamableHTTPClientTransport(url), {
126
+ signal,
127
+ timeout: STARTUP_TIMEOUT_MILLIS,
128
+ maxTotalTimeout: STARTUP_TIMEOUT_MILLIS,
129
+ }),
130
+ catch: toError,
131
+ }).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : closeMcpClient(client)));
132
+ return client;
133
+ });
134
+ const waitForMcpClient = (url, running) => {
135
+ const poll = Effect.suspend(() => {
136
+ if (running.child.exitCode !== null || running.child.signalCode !== null) {
137
+ return Effect.fail(exitedBeforeReadiness(running));
138
+ }
139
+ return connectMcpOnce(url).pipe(Effect.catchAll(() => Effect.sleep(POLL_INTERVAL).pipe(Effect.zipRight(poll))));
140
+ });
141
+ return poll;
142
+ };
143
+ const callStatus = (client) => Effect.tryPromise({
144
+ try: (signal) => client.callTool({ name: HARNESS_STATUS_TOOL, arguments: {} }, {
145
+ signal,
146
+ timeout: STARTUP_TIMEOUT_MILLIS,
147
+ maxTotalTimeout: STARTUP_TIMEOUT_MILLIS,
148
+ }),
149
+ catch: toError,
150
+ });
151
+ const identityMismatch = (profileName, expectedAgentId, actualIdentity) => moltzapdChildError(`moltzapd profile identity mismatch: ${profileName} expects ${expectedAgentId}, but the MCP endpoint reports ${actualIdentity}`);
152
+ const verifyConnectedStatus = (client, running, profileName, expectedAgentId) => callStatus(client).pipe(Effect.flatMap((result) => decodeHarnessStatusResult(result.structuredContent).pipe(Effect.mapError(toError))), Effect.flatMap((status) => {
153
+ if (status.agentId === undefined) {
154
+ return Effect.fail(identityMismatch(profileName, expectedAgentId, "no AgentId"));
155
+ }
156
+ if (status.agentId !== expectedAgentId) {
157
+ return Effect.fail(identityMismatch(profileName, expectedAgentId, status.agentId));
158
+ }
159
+ return status.connected
160
+ ? Effect.void
161
+ : Effect.fail(moltzapdChildError(`moltzapd signaled readiness without connecting\n${running.logs()}`));
162
+ }));
163
+ /**
164
+ * Bounds and interrupts the complete child-readiness sequence.
165
+ * @param readiness IPC, endpoint connection, status, and liveness checks.
166
+ * @param logs Bounded child output included in the timeout diagnostic.
167
+ * @param within Startup budget; production uses one fixed local deadline.
168
+ * @returns The readiness result before the shared deadline.
169
+ * @internal
170
+ */
171
+ export const withMoltzapdStartupDeadline = (readiness, logs, within = STARTUP_TIMEOUT) => readiness.pipe(Effect.timeoutFail({
172
+ duration: within,
173
+ onTimeout: () => moltzapdChildError(`moltzapd did not become ready before its startup deadline\n${logs()}`),
174
+ }));
175
+ // IPC binds readiness to this exact ChildProcess. The status check then binds
176
+ // the endpoint reached through the profile's port to its persisted AgentId.
177
+ const verifySpawnedDaemon = ({ expectedAgentId, profileName, running, url, }) => {
178
+ const verifyEndpoint = Effect.scoped(Effect.acquireRelease(waitForMcpClient(url, running), closeMcpClient).pipe(Effect.flatMap((client) => verifyConnectedStatus(client, running, profileName, expectedAgentId))));
179
+ const readiness = observeDaemonDuringReadiness(running, waitForReadySignal(running).pipe(Effect.zipRight(verifyEndpoint))).pipe(Effect.zipRight(ensureDaemonIsRunning(running)));
180
+ return withMoltzapdStartupDeadline(readiness, running.logs);
181
+ };
182
+ /**
183
+ * Starts the package's real `moltzapd` binary against an existing slot.
184
+ * The slot carries the loopback port, so the child receives only its profile
185
+ * name and the returned URL is derived from the same persisted value.
186
+ *
187
+ * @param options Existing profile name for the child process.
188
+ * @returns A scoped packaged daemon after its MCP status reports connected.
189
+ */
190
+ export const acquireMoltzapdChild = (options) => Effect.gen(function* () {
191
+ const name = yield* parseProfileName(options.profileName).pipe(Effect.mapError(toError));
192
+ const record = yield* resolveProfileRecord(name).pipe(Effect.mapError(toError));
193
+ if (!isRegisteredProfile(record)) {
194
+ return yield* Effect.fail(moltzapdChildError(`moltzapd profile ${options.profileName} is not registered`));
195
+ }
196
+ const running = yield* acquireDaemon(options.profileName);
197
+ const url = new URL(MCP_PATH, `http://${LOOPBACK_HOST}:${String(record.mcpPort)}`);
198
+ yield* verifySpawnedDaemon({
199
+ expectedAgentId: record.agentId,
200
+ profileName: options.profileName,
201
+ running,
202
+ url,
203
+ });
204
+ return { mcpUrl: url.href, logs: running.logs };
205
+ }).pipe(Effect.withSpan("acquireMoltzapdChild"));
206
+ /**
207
+ * Acquire the adapter-facing client for one named profile slot.
208
+ *
209
+ * This is the whole production composition: the slot's own daemon child, the
210
+ * loopback endpoint derived from the slot, and a file-backed checkpoint store.
211
+ * A caller supplies only the profile name — no URL, no port, no store.
212
+ *
213
+ * The checkpoint directory is keyed by profile name rather than AgentId,
214
+ * because the store must be provided before `acquireHarnessClient` reads the
215
+ * identity from the daemon's status tool. One slot is exactly one AgentId, so
216
+ * the profile name is a stable agent scope.
217
+ *
218
+ * @param profileName Existing slot owning the daemon and its checkpoints.
219
+ * @returns The scoped adapter-facing service value.
220
+ */
221
+ export const harnessClientForProfile = (profileName) => Effect.gen(function* () {
222
+ const child = yield* acquireMoltzapdChild({ profileName });
223
+ return yield* acquireHarnessClient({ url: child.mcpUrl }).pipe(Effect.provide(KeyValueStore.layerFileSystem(join(getMoltZapConfigDir(), "checkpoints", profileName)).pipe(Layer.provide(NodeContext.layer))), Effect.catchTag("SystemError", (cause) => Effect.die(cause)), Effect.catchTag("BadArgument", (cause) => Effect.die(cause)));
224
+ }).pipe(Effect.withSpan("harnessClientForProfile"));
225
+ //# sourceMappingURL=moltzapd-child.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-child.js","sourceRoot":"","sources":["../src/moltzapd-child.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,6BAA6B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,aAAa,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,GAEN,MAAM,QAAQ,CAAC;AAEhB,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EACL,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;A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+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=moltzapd-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-main.d.ts","sourceRoot":"","sources":["../src/moltzapd-main.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /** @file Process entry point for one profile-scoped MoltZap daemon. */
3
+ import { Command, Options } from "@effect/cli";
4
+ import { NodeContext, NodeRuntime } from "@effect/platform-node";
5
+ import { Effect } from "effect";
6
+ import packageJson from "../package.json" with { type: "json" };
7
+ import { signalMoltzapdReady } from "./moltzapd-child-ipc.js";
8
+ import { runMoltzapd } from "./moltzapd.js";
9
+ import { profileName } from "./profile.js";
10
+ const profileOption = Options.text("profile").pipe(Options.withSchema(profileName), Options.withDescription("Existing named profile owned by this daemon."));
11
+ const moltzapd = Command.make("moltzapd", { profile: profileOption }, ({ profile }) => runMoltzapd({ profileName: profile }, signalMoltzapdReady)).pipe(Command.withDescription("Run one named MoltZap profile behind its loopback MCP boundary."));
12
+ const main = Command.run(moltzapd, {
13
+ name: "moltzapd",
14
+ version: packageJson.version,
15
+ });
16
+ // eslint-disable-next-line agent-code-guard/prefer-effect-platform -- @effect/cli receives the Node argument vector at the process boundary.
17
+ main(process.argv).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);
18
+ //# sourceMappingURL=moltzapd-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltzapd-main.js","sourceRoot":"","sources":["../src/moltzapd-main.ts"],"names":[],"mappings":";AACA,uEAAuE;AACvE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,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