@moltzap/client 2026.520.1 → 2026.523.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.
- package/dist/agent-client.d.ts +66 -0
- package/dist/agent-client.d.ts.map +1 -0
- package/dist/agent-client.js +287 -0
- package/dist/agent-client.js.map +1 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/channel-core-context.test.js +16 -8
- package/dist/channel-core-context.test.js.map +1 -1
- package/dist/channel-core-dispatch.test.js +17 -10
- package/dist/channel-core-dispatch.test.js.map +1 -1
- package/dist/channel-core-enrichment.d.ts +2 -1
- package/dist/channel-core-enrichment.d.ts.map +1 -1
- package/dist/channel-core-enrichment.js +4 -2
- package/dist/channel-core-enrichment.js.map +1 -1
- package/dist/channel-core-test-support.d.ts +5 -3
- package/dist/channel-core-test-support.d.ts.map +1 -1
- package/dist/channel-core-test-support.js +6 -4
- package/dist/channel-core-test-support.js.map +1 -1
- package/dist/channel-core.d.ts +18 -13
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +11 -10
- package/dist/channel-core.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts +15 -63
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +26 -167
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/messages.d.ts +5 -2
- package/dist/cli/commands/messages.d.ts.map +1 -1
- package/dist/cli/commands/messages.js +10 -5
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/messages.test.js +6 -1
- package/dist/cli/commands/messages.test.js.map +1 -1
- package/dist/cli/commands/send.d.ts +6 -37
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +35 -57
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/send.test.js +14 -19
- package/dist/cli/commands/send.test.js.map +1 -1
- package/dist/cli/commands/start.d.ts +58 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +456 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/start.test.d.ts +2 -0
- package/dist/cli/commands/start.test.d.ts.map +1 -0
- package/dist/cli/commands/start.test.js +624 -0
- package/dist/cli/commands/start.test.js.map +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/socket-client.d.ts +0 -17
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +1 -39
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js +33 -6
- package/dist/cli/transport.js.map +1 -1
- package/dist/cli/transport.test.js +31 -12
- package/dist/cli/transport.test.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/notification/__tests__/snapshot-semantics.types-check.js +1 -1
- package/dist/notification/stream.d.ts +3 -3
- package/dist/notification/stream.js +3 -3
- package/dist/runtime/close-info.d.ts +2 -2
- package/dist/runtime/close-info.js +1 -1
- package/dist/runtime/frame.test.js +4 -2
- package/dist/runtime/frame.test.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/local-history.d.ts +1 -1
- package/dist/runtime/local-history.d.ts.map +1 -1
- package/dist/runtime/local-history.js +1 -1
- package/dist/runtime/local-history.js.map +1 -1
- package/dist/runtime/subscribers.d.ts +3 -3
- package/dist/runtime/subscribers.js +2 -2
- package/dist/service-archive-purge.d.ts +17 -0
- package/dist/service-archive-purge.d.ts.map +1 -0
- package/dist/service-archive-purge.js +32 -0
- package/dist/service-archive-purge.js.map +1 -0
- package/dist/service.d.ts +15 -19
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +79 -100
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +50 -26
- package/dist/service.test.js.map +1 -1
- package/dist/test/index.d.ts +4 -4
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4 -4
- package/dist/test/index.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +2 -1
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +11 -6
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/conformance-adapter.d.ts +3 -3
- package/dist/test-utils/conformance-adapter.js +7 -7
- package/dist/test-utils/conformance-adapter.js.map +1 -1
- package/dist/test-utils/ids.d.ts +3 -1
- package/dist/test-utils/ids.d.ts.map +1 -1
- package/dist/test-utils/ids.js +3 -1
- package/dist/test-utils/ids.js.map +1 -1
- package/dist/test-utils/index.d.ts +1 -1
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/{ws-client-test-support.d.ts → tm-client-test-support.d.ts} +14 -13
- package/dist/tm-client-test-support.d.ts.map +1 -0
- package/dist/{ws-client-test-support.js → tm-client-test-support.js} +51 -18
- package/dist/tm-client-test-support.js.map +1 -0
- package/dist/{ws-client.d.ts → tm-client.d.ts} +14 -19
- package/dist/tm-client.d.ts.map +1 -0
- package/dist/{ws-client.js → tm-client.js} +10 -24
- package/dist/tm-client.js.map +1 -0
- package/dist/tm-client.test.d.ts +2 -0
- package/dist/tm-client.test.d.ts.map +1 -0
- package/dist/{ws-client.test.js → tm-client.test.js} +41 -29
- package/dist/tm-client.test.js.map +1 -0
- package/package.json +4 -3
- package/dist/cli/commands/conversations-v2.test.d.ts +0 -2
- package/dist/cli/commands/conversations-v2.test.d.ts.map +0 -1
- package/dist/cli/commands/conversations-v2.test.js +0 -107
- package/dist/cli/commands/conversations-v2.test.js.map +0 -1
- package/dist/ws-client-test-support.d.ts.map +0 -1
- package/dist/ws-client-test-support.js.map +0 -1
- package/dist/ws-client.d.ts.map +0 -1
- package/dist/ws-client.js.map +0 -1
- package/dist/ws-client.test.d.ts +0 -2
- package/dist/ws-client.test.d.ts.map +0 -1
- package/dist/ws-client.test.js.map +0 -1
|
@@ -1,65 +1,44 @@
|
|
|
1
|
-
import { Args, Command, Options } from "@effect/cli";
|
|
2
|
-
import { Effect, Option } from "effect";
|
|
1
|
+
import { Args, Command, HelpDoc, Options } from "@effect/cli";
|
|
2
|
+
import { Data, Effect, Option } from "effect";
|
|
3
|
+
import { Value } from "@sinclair/typebox/value";
|
|
3
4
|
import { request } from "../socket-client.js";
|
|
4
5
|
import { MessagesSend } from "@moltzap/protocol";
|
|
5
|
-
|
|
6
|
-
const
|
|
6
|
+
import { ConversationId, MessageId, TaskId } from "@moltzap/protocol/task";
|
|
7
|
+
const TASK_CONVERSATION_TARGET_PREFIX = "task:";
|
|
8
|
+
class SendTargetMalformedError extends Data.TaggedError("SendTargetMalformedError") {
|
|
9
|
+
get message() {
|
|
10
|
+
return `invalid target ${this.target}: ${this.reason}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const targetArg = Args.text({ name: "target" }).pipe(Args.withDescription("Target task+conversation as task:<taskId>:<convId>"), Args.mapTryCatch((raw) => {
|
|
14
|
+
if (!raw.startsWith(TASK_CONVERSATION_TARGET_PREFIX)) {
|
|
15
|
+
throw new SendTargetMalformedError({
|
|
16
|
+
target: raw,
|
|
17
|
+
reason: `missing '${TASK_CONVERSATION_TARGET_PREFIX}' prefix`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const rest = raw.slice(TASK_CONVERSATION_TARGET_PREFIX.length);
|
|
21
|
+
const [tid, cid] = rest.split(":");
|
|
22
|
+
if (!tid || !cid) {
|
|
23
|
+
throw new SendTargetMalformedError({
|
|
24
|
+
target: raw,
|
|
25
|
+
reason: "expected task:<taskId>:<conversationId>",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
taskId: Value.Decode(TaskId, tid),
|
|
30
|
+
conversationId: Value.Decode(ConversationId, cid),
|
|
31
|
+
};
|
|
32
|
+
}, (err) => HelpDoc.p(`invalid target: ${String(err)}`)));
|
|
7
33
|
const messageArg = Args.text({ name: "message" }).pipe(Args.withDescription("Message text"));
|
|
8
|
-
const replyToOption = Options.text("reply-to").pipe(Options.withDescription("Reply to a specific message"), Options.optional);
|
|
9
|
-
/**
|
|
10
|
-
* `moltzap send <target> <message> [--reply-to <id>]` — socket-call into
|
|
11
|
-
* the local MoltZapService to enqueue an outbound message. `conv:` prefix
|
|
12
|
-
* addresses a conversation id directly; otherwise `target` is passed as a
|
|
13
|
-
* string the service resolves (typically `agent:<name>` for direct messages
|
|
14
|
-
* or a bare contact name the service resolves against the caller's roster).
|
|
15
|
-
*
|
|
16
|
-
* Identity selection is driven by the parent `@effect/cli` options wired in
|
|
17
|
-
* `cli/index.ts`:
|
|
18
|
-
*
|
|
19
|
-
* --as <apiKey> Send as the agent owning the given API key.
|
|
20
|
-
* Bypasses the local daemon socket; dials the server
|
|
21
|
-
* directly. Useful in multi-agent workflows where
|
|
22
|
-
* the same host registers more than one agent.
|
|
23
|
-
* --profile <name> Load the named profile from ~/.moltzap/config.json
|
|
24
|
-
* and send as that agent. Short for looking up the
|
|
25
|
-
* apiKey out of the profile and passing it as --as.
|
|
26
|
-
*
|
|
27
|
-
* If neither is provided, the command uses the legacy default profile
|
|
28
|
-
* (top-level apiKey in ~/.moltzap/config.json) — the identity set by the
|
|
29
|
-
* most recent `moltzap register` that did not use `--profile` or
|
|
30
|
-
* `--no-persist`.
|
|
31
|
-
*
|
|
32
|
-
* Examples:
|
|
33
|
-
* moltzap send agent:bob "hello" # default identity
|
|
34
|
-
* moltzap --profile alice send agent:bob "hello" # send as alice
|
|
35
|
-
* moltzap --as $BOB_API_KEY send conv:$CID "ack" # send as bob
|
|
36
|
-
*
|
|
37
|
-
* NOTE: `moltzap send` today routes through the local channel daemon and
|
|
38
|
-
* does NOT yet honor `--as`/`--profile` end-to-end — rewiring legacy
|
|
39
|
-
* commands onto the v2 Transport layer is tracked as a follow-up (see the
|
|
40
|
-
* PR body "Concerns" block). The flag semantics documented above describe
|
|
41
|
-
* the v2 contract; new v2 subcommands (`apps/*`, `messages list`,
|
|
42
|
-
* `conversations {get,archive,unarchive}`) honor them today.
|
|
43
|
-
*/
|
|
34
|
+
const replyToOption = Options.text("reply-to").pipe(Options.withDescription("Reply to a specific message"), Options.mapTryCatch((raw) => Value.Decode(MessageId, raw), (err) => HelpDoc.p(`invalid --reply-to: ${String(err)}`)), Options.optional);
|
|
44
35
|
export const sendCommand = Command.make("send", { target: targetArg, message: messageArg, replyTo: replyToOption }, ({ target, message, replyTo }) => {
|
|
45
36
|
const reply = Option.isSome(replyTo)
|
|
46
37
|
? { replyToId: replyTo.value }
|
|
47
38
|
: {};
|
|
48
|
-
if (target.startsWith(CONVERSATION_TARGET_PREFIX)) {
|
|
49
|
-
return request(MessagesSend, {
|
|
50
|
-
conversationId: target.slice(CONVERSATION_TARGET_PREFIX.length),
|
|
51
|
-
parts: [{ type: "text", text: message }],
|
|
52
|
-
...reply,
|
|
53
|
-
}).pipe(Effect.tap((result) => Effect.sync(() => {
|
|
54
|
-
const r = result;
|
|
55
|
-
console.log(`Message sent (id: ${r.message.id})`);
|
|
56
|
-
})), Effect.asVoid, Effect.catchAll((err) => Effect.sync(() => {
|
|
57
|
-
console.error(`Failed: ${err.message}`);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
})));
|
|
60
|
-
}
|
|
61
39
|
return request(MessagesSend, {
|
|
62
|
-
|
|
40
|
+
taskId: target.taskId,
|
|
41
|
+
conversationId: target.conversationId,
|
|
63
42
|
parts: [{ type: "text", text: message }],
|
|
64
43
|
...reply,
|
|
65
44
|
}).pipe(Effect.tap((result) => Effect.sync(() => {
|
|
@@ -69,7 +48,6 @@ export const sendCommand = Command.make("send", { target: targetArg, message: me
|
|
|
69
48
|
console.error(`Failed: ${err.message}`);
|
|
70
49
|
process.exit(1);
|
|
71
50
|
})));
|
|
72
|
-
}).pipe(Command.withDescription("Send a message to
|
|
73
|
-
"Identity follows the global --as / --profile flags;
|
|
74
|
-
"legacy top-level profile in ~/.moltzap/config.json."));
|
|
51
|
+
}).pipe(Command.withDescription("Send a message to task:<taskId>:<conversationId>. " +
|
|
52
|
+
"Identity follows the global --as / --profile flags."));
|
|
75
53
|
//# sourceMappingURL=send.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../src/cli/commands/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../src/cli/commands/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,+BAA+B,GAAG,OAAO,CAAC;AAEhD,MAAM,wBAAyB,SAAQ,IAAI,CAAC,WAAW,CACrD,0BAA0B,CAC2B;IACrD,IAAa,OAAO;QAClB,OAAO,kBAAkB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;IACzD,CAAC;CACF;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAClD,IAAI,CAAC,eAAe,CAAC,oDAAoD,CAAC,EAC1E,IAAI,CAAC,WAAW,CACd,CAAC,GA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,CAAC;AACJ,CAAC,CACF,CAAC,IAAI,CACJ,OAAO,CAAC,eAAe,CACrB,oDAAoD;IAClD,qDAAqD,CACxD,CACF,CAAC"}
|
|
@@ -3,11 +3,12 @@ import { it as effectIt } from "@effect/vitest";
|
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, vi } from "vitest";
|
|
4
4
|
import { sendCommand } from "./send.js";
|
|
5
5
|
import { MessagesSend } from "@moltzap/protocol";
|
|
6
|
+
import { conversationId as makeConversationId, messageId as makeMessageId, taskId as makeTaskId, } from "@moltzap/protocol/testing";
|
|
6
7
|
const it = effectIt.effect;
|
|
8
|
+
const TASK_UUID = "00000000-0000-4000-8000-00000000abc2";
|
|
7
9
|
const CONV_UUID = "00000000-0000-4000-8000-00000000abc1";
|
|
8
10
|
const REPLY_MSG = "00000000-0000-4000-8000-0000000000a1";
|
|
9
11
|
const HELLO_WORLD = "Hello world";
|
|
10
|
-
const HI_ALICE = "Hi Alice";
|
|
11
12
|
const REPLY_TEXT = "Reply text";
|
|
12
13
|
const mockRequest = vi.fn(() => Effect.succeed({ message: { id: "msg-123" } }));
|
|
13
14
|
vi.mock("../socket-client.js", () => ({
|
|
@@ -26,38 +27,32 @@ describe("send command handler", () => {
|
|
|
26
27
|
afterEach(() => {
|
|
27
28
|
process.exit = originalExit;
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
+
const taskId = makeTaskId(TASK_UUID);
|
|
31
|
+
const conversationId = makeConversationId(CONV_UUID);
|
|
32
|
+
const replyToId = makeMessageId(REPLY_MSG);
|
|
33
|
+
it("sends to task+conversation target", () => Effect.gen(function* () {
|
|
30
34
|
yield* runSendCommand({
|
|
31
|
-
target:
|
|
35
|
+
target: { taskId, conversationId },
|
|
32
36
|
message: HELLO_WORLD,
|
|
33
37
|
replyTo: Option.none(),
|
|
34
38
|
});
|
|
35
39
|
expect(mockRequest).toHaveBeenCalledWith(MessagesSend, {
|
|
36
|
-
|
|
40
|
+
taskId,
|
|
41
|
+
conversationId,
|
|
37
42
|
parts: [{ type: "text", text: HELLO_WORLD }],
|
|
38
43
|
});
|
|
39
44
|
}));
|
|
40
|
-
it("sends to agent target without conv: prefix", () => Effect.gen(function* () {
|
|
41
|
-
yield* runSendCommand({
|
|
42
|
-
target: "agent:alice",
|
|
43
|
-
message: HI_ALICE,
|
|
44
|
-
replyTo: Option.none(),
|
|
45
|
-
});
|
|
46
|
-
expect(mockRequest).toHaveBeenCalledWith(MessagesSend, {
|
|
47
|
-
to: "agent:alice",
|
|
48
|
-
parts: [{ type: "text", text: HI_ALICE }],
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
45
|
it("includes replyToId when --reply-to is provided", () => Effect.gen(function* () {
|
|
52
46
|
yield* runSendCommand({
|
|
53
|
-
target:
|
|
47
|
+
target: { taskId, conversationId },
|
|
54
48
|
message: REPLY_TEXT,
|
|
55
|
-
replyTo: Option.some(
|
|
49
|
+
replyTo: Option.some(replyToId),
|
|
56
50
|
});
|
|
57
51
|
expect(mockRequest).toHaveBeenCalledWith(MessagesSend, {
|
|
58
|
-
|
|
52
|
+
taskId,
|
|
53
|
+
conversationId,
|
|
59
54
|
parts: [{ type: "text", text: REPLY_TEXT }],
|
|
60
|
-
replyToId
|
|
55
|
+
replyToId,
|
|
61
56
|
});
|
|
62
57
|
}));
|
|
63
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.test.js","sourceRoot":"","sources":["../../../src/cli/commands/send.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,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AC,CAAC,CAAC;IAEN,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE,CACxD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,KAAK,CAAC,CAAC,cAAc,CAAC;YACpB,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;YAClC,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,CAAC,CAAC;QACH,MAAM,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,YAAY,EAAE;YACrD,MAAM;YACN,cAAc;YACd,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;YAC3C,SAAS;SACV,CAAC,CAAC;IACL,CAAC,CAAC,CAAC,CAAC;AACR,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `moltzap start <name> <participant>... [--message <text>] [--app-id <uuid>]`
|
|
3
|
+
*
|
|
4
|
+
* Spec D2 (#599) — single-command CLI composition over Spec D1's atomic
|
|
5
|
+
* `TaskRequest({ appId, invitedAgentIds, initialConversation })` plus an
|
|
6
|
+
* optional `MessagesSend`. Today's two-step workflow
|
|
7
|
+
* (`conversations create` -> `send conv:<id> <text>`) collapses into
|
|
8
|
+
* one subcommand for the common case.
|
|
9
|
+
*
|
|
10
|
+
* See also:
|
|
11
|
+
* - `packages/protocol/src/task/tasks.ts -> TaskRequest` / `DEFAULT_APP_ID` /
|
|
12
|
+
* `AppId` — D1 (#598) wire surface this command composes.
|
|
13
|
+
* - `packages/client/docs/architecture/moltzap-start-cli.md` for the
|
|
14
|
+
* command flow diagram, exit-code contract, and test alignment.
|
|
15
|
+
* - `packages/client/src/cli/commands/conversations.ts -> createConversation`
|
|
16
|
+
* for the legacy two-step DM/Group create path D2 replaces. Untouched
|
|
17
|
+
* in D2; D3 (#600) deletes it.
|
|
18
|
+
* - `packages/client/src/cli/socket-client.ts -> resolveParticipant` —
|
|
19
|
+
* NOT reused by D2 because that helper goes via the daemon
|
|
20
|
+
* socket (`socket-client.ts -> request`), bypassing the CLI
|
|
21
|
+
* `Transport` service that `start.ts` uses for `TaskRequest` /
|
|
22
|
+
* `MessagesSend`. Mixing the two would make `--as`-mode name lookups
|
|
23
|
+
* hit the daemon (potentially absent) and would not be testable
|
|
24
|
+
* via `makeFakeTransport`. D2 introduces a local `resolveAgentTokens`
|
|
25
|
+
* helper that goes through `transport.ts -> rpc` instead
|
|
26
|
+
* (see per-flow doc §6 + §"Why we don't reuse `resolveParticipant`").
|
|
27
|
+
*/
|
|
28
|
+
import { Command } from "@effect/cli";
|
|
29
|
+
import { Effect, Option } from "effect";
|
|
30
|
+
import { type Transport } from "../transport.js";
|
|
31
|
+
/**
|
|
32
|
+
* Parsed CLI arguments for the `start` command. `@effect/cli`'s
|
|
33
|
+
* `Args.repeated` admits zero participants — caller-only tasks are
|
|
34
|
+
* permitted at the wire (Spec D1 per-flow doc 12) but not exercised by
|
|
35
|
+
* spec D2 ACs (which cover `length === 1` DM and `length >= 2` group
|
|
36
|
+
* shapes). Handler MUST NOT reject empty `participants`.
|
|
37
|
+
*/
|
|
38
|
+
export interface StartCommandArgs {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly participants: readonly string[];
|
|
41
|
+
readonly message: string | undefined;
|
|
42
|
+
readonly appId: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Test seam: invoke the handler directly with parsed args, bypassing
|
|
46
|
+
* `@effect/cli`'s parser. Returns the same `Effect` the `Command.make`
|
|
47
|
+
* wrapper would produce, including the `runStartCommand` exit-code
|
|
48
|
+
* dispatcher. Tests `Effect.provideService(Transport, fake)` and assert
|
|
49
|
+
* `process.exit` was called with the expected code.
|
|
50
|
+
*/
|
|
51
|
+
export declare const runStartHandler: (args: StartCommandArgs) => Effect.Effect<void, never, Transport>;
|
|
52
|
+
export declare const startCommand: Command.Command<"start", Transport, never, {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly participants: string[];
|
|
55
|
+
readonly message: Option.Option<string>;
|
|
56
|
+
readonly appId: Option.Option<string>;
|
|
57
|
+
}>;
|
|
58
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAQ,OAAO,EAAW,MAAM,aAAa,CAAC;AACrD,OAAO,EAAQ,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAetD,OAAO,EAAO,KAAK,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AA0E3E;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AA6iBD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,gBAAgB,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CACK,CAAC;AAE7C,eAAO,MAAM,YAAY;;;;;EA8BxB,CAAC"}
|