@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
@@ -1,132 +0,0 @@
1
- /**
2
- * CLI transport layer — the single boundary between the command handlers and
3
- * the local daemon socket.
4
- *
5
- * Command handlers pull `Transport` from Effect context; they do NOT open
6
- * sockets or construct clients themselves. The kind of
7
- * transport in effect is decided once at CLI boot by {@link makeTransportLayer}
8
- * and is immutable for the lifetime of the process.
9
- *
10
- * Test seam: integration tests swap {@link makeTransportLayer} for a layer
11
- * that provides a recording `Transport`; unit tests provide `Transport`
12
- * directly via `Effect.provideService`.
13
- */
14
- import { Context, Effect, Layer } from "effect";
15
- import type { RpcGroup } from "@effect/rpc";
16
- import type { LocalDaemonError, LocalDaemonRpcs } from "../local-daemon-rpc.js";
17
- import { type ProfileError, type ProfileName } from "../profile.js";
18
- import type { PayloadForTag, SuccessForTag } from "@moltzap/protocol/rpc";
19
- /** The local daemon command group's member `Rpc`s. */
20
- type DaemonRpcs = RpcGroup.Rpcs<typeof LocalDaemonRpcs>;
21
- /** The local command tags the CLI may originate. */
22
- type DaemonCommand = DaemonRpcs["_tag"];
23
- /** Errors any Transport.rpc call may surface. Exhaustive. */
24
- export type TransportError = ServiceUnreachableError | TransportTimeoutError | TransportRpcError | TransportDecodeError | LocalDaemonError;
25
- declare const ServiceUnreachableError_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 & {
26
- readonly _tag: "ServiceUnreachableError";
27
- } & Readonly<A>;
28
- /**
29
- * The daemon socket path did not exist or refused connection. Only raised
30
- * by the daemon path.
31
- */
32
- declare class ServiceUnreachableError extends ServiceUnreachableError_base<{
33
- readonly socketPath: string;
34
- readonly cause: unknown;
35
- }> {
36
- }
37
- declare const TransportTimeoutError_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 & {
38
- readonly _tag: "TransportTimeoutError";
39
- } & Readonly<A>;
40
- /** RPC exceeded the per-call deadline without a response frame. */
41
- declare class TransportTimeoutError extends TransportTimeoutError_base<{
42
- readonly method: string;
43
- readonly timeoutMs: number;
44
- }> {
45
- }
46
- declare const TransportRpcError_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 & {
47
- readonly _tag: "TransportRpcError";
48
- } & Readonly<A>;
49
- /**
50
- * Server returned a typed wire `error` for a request. `tag` is the failing
51
- * method's tagged-error discriminant (e.g. `"TaskRejected"`, `"Forbidden"`) —
52
- * the `_tag` the engine decoded the error against, not a numeric code.
53
- */
54
- export declare class TransportRpcError extends TransportRpcError_base<{
55
- readonly method: string;
56
- readonly tag: string;
57
- readonly message: string;
58
- readonly data?: unknown;
59
- }> {
60
- }
61
- declare const TransportDecodeError_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 & {
62
- readonly _tag: "TransportDecodeError";
63
- } & Readonly<A>;
64
- /** Response frame failed to parse or did not match the expected RPC result shape. */
65
- declare class TransportDecodeError extends TransportDecodeError_base<{
66
- readonly method: string;
67
- readonly cause: unknown;
68
- }> {
69
- }
70
- /**
71
- * Transport surface used by every CLI command. One typed per-command call keyed
72
- * by local daemon command.
73
- */
74
- export interface Transport {
75
- readonly command: <Tag extends DaemonCommand>(tag: Tag, payload: PayloadForTag<DaemonRpcs, Tag>) => Effect.Effect<SuccessForTag<DaemonRpcs, Tag>, TransportError>;
76
- }
77
- /** Provides the transport runtime value. */
78
- export declare const transportSchema: Context.Tag<Transport, Transport>;
79
- /**
80
- * Inputs shaping the transport for one CLI invocation. Assembled from
81
- * parsed CLI options and profile config by the CLI entrypoint.
82
- */
83
- export interface TransportOptions {
84
- /** Selected daemon socket path for this invocation. */
85
- readonly socketPath: string;
86
- }
87
- /**
88
- * Build the Layer that provides {@link Transport} for the current invocation.
89
- * @param options Options that control the operation.
90
- * @returns The created transport layer.
91
- */
92
- export declare const makeTransportLayer: (options: TransportOptions) => Layer.Layer<Transport>;
93
- /**
94
- * Convenience for command handlers: pull the Transport tag and call a daemon
95
- * command.
96
- * Every subcommand routes through this helper; command handlers do not
97
- * import `socket-client` directly.
98
- * @param tag Value supplied to the operation.
99
- * @param payload Value supplied to the operation.
100
- * @returns The command result.
101
- */
102
- export declare const command: <Tag extends DaemonCommand>(tag: Tag, payload: PayloadForTag<DaemonRpcs, Tag>) => Effect.Effect<SuccessForTag<DaemonRpcs, Tag>, TransportError, Transport>;
103
- /**
104
- * Uniform error-to-exit adapter for subcommand handlers. Catches every error
105
- * channel, prints `Failed: &lt;msg>` to stderr, and exits non-zero. Uses the
106
- * tagged-error `message` field if present, otherwise the `_tag`, otherwise
107
- * a generic fallback. Shared across every subcommand wrapper so the
108
- * exit-code contract has a single implementation.
109
- *
110
- * No forced `process.exit(0)` — that would truncate piped stdout on large
111
- * payloads.
112
- * @param effect Effect to execute.
113
- * @returns The run handler result.
114
- */
115
- export declare const runHandler: <E extends {
116
- readonly message?: string;
117
- readonly _tag?: string;
118
- }, R>(effect: Effect.Effect<void, E, R>) => Effect.Effect<void, never, R>;
119
- /**
120
- * Lazy resolver invoked by the CLI entrypoint BEFORE constructing the
121
- * transport layer. With `profileName` set, this resolves the named profile
122
- * into the profile agent's daemon socket; otherwise it uses the default
123
- * daemon socket.
124
- * @param parsed Value supplied to the operation.
125
- * @param parsed.profileName Value supplied to the operation.
126
- * @returns The resolve transport inputs result.
127
- */
128
- export declare const resolveTransportInputs: (parsed: {
129
- readonly profileName?: ProfileName;
130
- }) => Effect.Effect<TransportOptions, ProfileError>;
131
- export {};
132
- //# sourceMappingURL=transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/cli/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE1E,sDAAsD;AACtD,KAAK,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,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eAAO,MAAM,eAAe,mCAE3B,CAAC;AAIF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AA6CD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,YACpB,gBAAgB,KACxB,KAAK,CAAC,KAAK,CAAC,SAAS,CACiD,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,SAAS,aAAa,OAC1C,GAAG,WACC,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,cAAc,EAAE,SAAS,CACT,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/D,CAAC,UAEO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,KAChC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAW5B,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,WAAY;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;CACpC,KAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAaI,CAAC"}
@@ -1,127 +0,0 @@
1
- /**
2
- * CLI transport layer — the single boundary between the command handlers and
3
- * the local daemon socket.
4
- *
5
- * Command handlers pull `Transport` from Effect context; they do NOT open
6
- * sockets or construct clients themselves. The kind of
7
- * transport in effect is decided once at CLI boot by {@link makeTransportLayer}
8
- * and is immutable for the lifetime of the process.
9
- *
10
- * Test seam: integration tests swap {@link makeTransportLayer} for a layer
11
- * that provides a recording `Transport`; unit tests provide `Transport`
12
- * directly via `Effect.provideService`.
13
- */
14
- import { Context, Data, Effect, Layer } from "effect";
15
- import { MoltZapService } from "../service.js";
16
- import { getMoltZapAgentServiceSocketPath } from "../local-paths.js";
17
- import { requestDaemonCommand, SocketRequestError } from "./socket-client.js";
18
- import { resolveProfileRecord, } from "../profile.js";
19
- /**
20
- * The daemon socket path did not exist or refused connection. Only raised
21
- * by the daemon path.
22
- */
23
- class ServiceUnreachableError extends Data.TaggedError("ServiceUnreachableError") {
24
- }
25
- /** RPC exceeded the per-call deadline without a response frame. */
26
- class TransportTimeoutError extends Data.TaggedError("TransportTimeoutError") {
27
- }
28
- /**
29
- * Server returned a typed wire `error` for a request. `tag` is the failing
30
- * method's tagged-error discriminant (e.g. `"TaskRejected"`, `"Forbidden"`) —
31
- * the `_tag` the engine decoded the error against, not a numeric code.
32
- */
33
- export class TransportRpcError extends Data.TaggedError("TransportRpcError") {
34
- }
35
- /** Response frame failed to parse or did not match the expected RPC result shape. */
36
- class TransportDecodeError extends Data.TaggedError("TransportDecodeError") {
37
- }
38
- /** Provides the transport runtime value. */
39
- export const transportSchema = Context.GenericTag("moltzap/cli/Transport");
40
- const DAEMON_TIMEOUT_MS = 10_000;
41
- // Map local socket faults to CLI transport tags. Errors decoded from the daemon
42
- // RPC error channel are already typed tagged errors and pass through unchanged.
43
- const tagDaemonError = (method, err, socketPath) => {
44
- if (!(err instanceof SocketRequestError)) {
45
- return err;
46
- }
47
- const msg = err.message;
48
- if (msg.includes("not running") ||
49
- msg.includes("ENOENT") ||
50
- msg.includes("ECONNREFUSED")) {
51
- return new ServiceUnreachableError({
52
- socketPath,
53
- cause: err,
54
- });
55
- }
56
- if (msg.includes("timed out") || msg.includes("aborted")) {
57
- return new TransportTimeoutError({ method, timeoutMs: DAEMON_TIMEOUT_MS });
58
- }
59
- if (msg.startsWith("Malformed")) {
60
- return new TransportDecodeError({ method, cause: err });
61
- }
62
- return new TransportRpcError({
63
- method,
64
- tag: err._tag,
65
- message: msg,
66
- });
67
- };
68
- const makeDaemonTransport = (socketPath) => ({
69
- command: (tag, payload) => requestDaemonCommand(tag, payload, socketPath).pipe(Effect.mapError((err) => tagDaemonError(tag, err, socketPath))),
70
- });
71
- /**
72
- * Build the Layer that provides {@link Transport} for the current invocation.
73
- * @param options Options that control the operation.
74
- * @returns The created transport layer.
75
- */
76
- export const makeTransportLayer = (options) => Layer.succeed(transportSchema, makeDaemonTransport(options.socketPath));
77
- /**
78
- * Convenience for command handlers: pull the Transport tag and call a daemon
79
- * command.
80
- * Every subcommand routes through this helper; command handlers do not
81
- * import `socket-client` directly.
82
- * @param tag Value supplied to the operation.
83
- * @param payload Value supplied to the operation.
84
- * @returns The command result.
85
- */
86
- export const command = (tag, payload) => Effect.flatMap(transportSchema, (t) => t.command(tag, payload));
87
- /**
88
- * Uniform error-to-exit adapter for subcommand handlers. Catches every error
89
- * channel, prints `Failed: &lt;msg>` to stderr, and exits non-zero. Uses the
90
- * tagged-error `message` field if present, otherwise the `_tag`, otherwise
91
- * a generic fallback. Shared across every subcommand wrapper so the
92
- * exit-code contract has a single implementation.
93
- *
94
- * No forced `process.exit(0)` — that would truncate piped stdout on large
95
- * payloads.
96
- * @param effect Effect to execute.
97
- * @returns The run handler result.
98
- */
99
- export const runHandler = (effect) => effect.pipe(Effect.catchAll((err) => {
100
- const msg = err.message !== undefined && err.message !== ""
101
- ? err.message
102
- : (err._tag ?? "unknown error");
103
- return Effect.logError(`Failed: ${msg}`).pipe(Effect.zipRight(Effect.sync(() => process.exit(1))));
104
- }));
105
- /**
106
- * Lazy resolver invoked by the CLI entrypoint BEFORE constructing the
107
- * transport layer. With `profileName` set, this resolves the named profile
108
- * into the profile agent's daemon socket; otherwise it uses the default
109
- * daemon socket.
110
- * @param parsed Value supplied to the operation.
111
- * @param parsed.profileName Value supplied to the operation.
112
- * @returns The resolve transport inputs result.
113
- */
114
- export const resolveTransportInputs = (parsed) => Effect.gen(function* () {
115
- // ─── Branch A: profile ─────────────────────────────────────────────────
116
- if (parsed.profileName !== undefined) {
117
- const record = yield* resolveProfileRecord(parsed.profileName);
118
- return {
119
- socketPath: getMoltZapAgentServiceSocketPath(record.agentId),
120
- };
121
- }
122
- // ─── Branch B: daemon ──────────────────────────────────────────────────
123
- return {
124
- socketPath: MoltZapService.SOCKET_PATH,
125
- };
126
- }).pipe(Effect.withSpan("resolveTransportInputs"));
127
- //# sourceMappingURL=transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/cli/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EACL,oBAAoB,GAGrB,MAAM,eAAe,CAAC;AAmBvB;;;GAGG;AACH,MAAM,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CACpD,yBAAyB,CAIzB;CAAG;AAEL,mEAAmE;AACnE,MAAM,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAG1E;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAKzE;CAAG;AAEL,qFAAqF;AACrF,MAAM,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAGxE;CAAG;AAeL,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAC/C,uBAAuB,CACxB,CAAC;AAaF,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,gFAAgF;AAChF,gFAAgF;AAChF,MAAM,cAAc,GAAG,CAC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