@otto-code/cli 0.8.10 → 0.8.13

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 (103) hide show
  1. package/dist/cli.js +1 -5
  2. package/dist/commands/daemon/index.js +1 -0
  3. package/dist/commands/daemon/local-daemon.js +3 -0
  4. package/dist/commands/daemon/pair.d.ts +27 -1
  5. package/dist/commands/daemon/pair.js +133 -46
  6. package/dist/commands/daemon/start.js +1 -0
  7. package/dist/commands/daemon/status.d.ts +11 -0
  8. package/dist/commands/daemon/status.js +47 -22
  9. package/dist/commands/hub/authority.d.ts +17 -0
  10. package/dist/commands/hub/authority.js +18 -0
  11. package/dist/commands/hub/connect.d.ts +21 -0
  12. package/dist/commands/hub/connect.js +34 -0
  13. package/dist/commands/hub/credentials.d.ts +21 -0
  14. package/dist/commands/hub/credentials.js +143 -0
  15. package/dist/commands/hub/daemon-client.d.ts +27 -0
  16. package/dist/commands/hub/daemon-client.js +14 -0
  17. package/dist/commands/hub/deploy-bundle.d.ts +16 -0
  18. package/dist/commands/hub/deploy-bundle.js +248 -0
  19. package/dist/commands/hub/deploy.d.ts +40 -0
  20. package/dist/commands/hub/deploy.js +90 -0
  21. package/dist/commands/hub/disconnect.d.ts +16 -0
  22. package/dist/commands/hub/disconnect.js +24 -0
  23. package/dist/commands/hub/error.d.ts +6 -0
  24. package/dist/commands/hub/error.js +9 -0
  25. package/dist/commands/hub/help.d.ts +3 -0
  26. package/dist/commands/hub/help.js +5 -0
  27. package/dist/commands/hub/hub-client/index.d.ts +19 -0
  28. package/dist/commands/hub/hub-client/index.js +99 -0
  29. package/dist/commands/hub/hub-client/internal/contracts.d.ts +86 -0
  30. package/dist/commands/hub/hub-client/internal/contracts.js +62 -0
  31. package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
  32. package/dist/commands/hub/hub-client/internal/problem.js +85 -0
  33. package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
  34. package/dist/commands/hub/hub-client/internal/transport.js +30 -0
  35. package/dist/commands/hub/index.d.ts +15 -25
  36. package/dist/commands/hub/index.js +67 -73
  37. package/dist/commands/hub/init-plan.d.ts +50 -0
  38. package/dist/commands/hub/init-plan.js +136 -0
  39. package/dist/commands/hub/init.d.ts +20 -0
  40. package/dist/commands/hub/init.js +415 -0
  41. package/dist/commands/hub/{device-authorization.d.ts → login-flow.d.ts} +12 -15
  42. package/dist/commands/hub/login-flow.js +78 -0
  43. package/dist/commands/hub/login.d.ts +21 -0
  44. package/dist/commands/hub/login.js +34 -0
  45. package/dist/commands/hub/logout.d.ts +32 -0
  46. package/dist/commands/hub/logout.js +71 -0
  47. package/dist/commands/hub/origin.d.ts +2 -0
  48. package/dist/commands/hub/origin.js +27 -0
  49. package/dist/commands/hub/projects.d.ts +24 -0
  50. package/dist/commands/hub/projects.js +49 -0
  51. package/dist/commands/hub/reporter.d.ts +10 -0
  52. package/dist/commands/hub/reporter.js +11 -0
  53. package/dist/commands/hub/status-output.d.ts +13 -0
  54. package/dist/commands/hub/status-output.js +30 -0
  55. package/dist/commands/onboard.js +20 -40
  56. package/dist/commands/provider/diagnostic.d.ts +12 -0
  57. package/dist/commands/provider/diagnostic.js +31 -0
  58. package/dist/commands/provider/index.js +5 -0
  59. package/dist/commands/schedule/types.d.ts +1 -4
  60. package/dist/commands/workspace/index.js +10 -0
  61. package/dist/commands/workspace/rename.d.ts +22 -0
  62. package/dist/commands/workspace/rename.js +61 -0
  63. package/dist/output/types.d.ts +1 -1
  64. package/dist/run.js +8 -1
  65. package/dist/utils/client.js +4 -1
  66. package/package.json +5 -5
  67. package/dist/commands/chat/create.d.ts +0 -9
  68. package/dist/commands/chat/create.js +0 -23
  69. package/dist/commands/chat/delete.d.ts +0 -6
  70. package/dist/commands/chat/delete.js +0 -20
  71. package/dist/commands/chat/index.d.ts +0 -3
  72. package/dist/commands/chat/index.js +0 -47
  73. package/dist/commands/chat/inspect.d.ts +0 -6
  74. package/dist/commands/chat/inspect.js +0 -20
  75. package/dist/commands/chat/ls.d.ts +0 -6
  76. package/dist/commands/chat/ls.js +0 -20
  77. package/dist/commands/chat/post.d.ts +0 -9
  78. package/dist/commands/chat/post.js +0 -28
  79. package/dist/commands/chat/read.d.ts +0 -11
  80. package/dist/commands/chat/read.js +0 -40
  81. package/dist/commands/chat/schema.d.ts +0 -36
  82. package/dist/commands/chat/schema.js +0 -81
  83. package/dist/commands/chat/shared.d.ts +0 -19
  84. package/dist/commands/chat/shared.js +0 -118
  85. package/dist/commands/chat/wait.d.ts +0 -9
  86. package/dist/commands/chat/wait.js +0 -45
  87. package/dist/commands/hub/cloud-device-authorization.d.ts +0 -45
  88. package/dist/commands/hub/cloud-device-authorization.js +0 -92
  89. package/dist/commands/hub/device-authorization.js +0 -87
  90. package/dist/commands/loop/index.d.ts +0 -3
  91. package/dist/commands/loop/index.js +0 -18
  92. package/dist/commands/loop/inspect.d.ts +0 -13
  93. package/dist/commands/loop/inspect.js +0 -100
  94. package/dist/commands/loop/logs.d.ts +0 -8
  95. package/dist/commands/loop/logs.js +0 -69
  96. package/dist/commands/loop/ls.d.ts +0 -18
  97. package/dist/commands/loop/ls.js +0 -62
  98. package/dist/commands/loop/run.d.ts +0 -30
  99. package/dist/commands/loop/run.js +0 -162
  100. package/dist/commands/loop/stop.d.ts +0 -15
  101. package/dist/commands/loop/stop.js +0 -56
  102. package/dist/commands/loop/types.d.ts +0 -138
  103. package/dist/commands/loop/types.js +0 -2
@@ -141,7 +141,10 @@ function stripIpcPrefix(trimmed) {
141
141
  return trimmed;
142
142
  }
143
143
  export function resolveDaemonTarget(host) {
144
- const trimmed = host.trim();
144
+ const trimmed = normalizeDaemonHost(host);
145
+ if (!trimmed) {
146
+ throw new Error(`Invalid daemon target: ${host}`);
147
+ }
145
148
  if (trimmed.startsWith("unix://") ||
146
149
  trimmed.startsWith("pipe://") ||
147
150
  trimmed.startsWith("\\\\.\\pipe\\")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otto-code/cli",
3
- "version": "0.8.10",
3
+ "version": "0.8.13",
4
4
  "description": "Otto CLI - control your AI coding agents from the command line",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "bin": {
@@ -29,10 +29,10 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@clack/prompts": "^1.0.0",
32
- "@otto-code/brain": "0.8.10",
33
- "@otto-code/client": "0.8.10",
34
- "@otto-code/protocol": "0.8.10",
35
- "@otto-code/server": "0.8.10",
32
+ "@otto-code/brain": "0.8.13",
33
+ "@otto-code/client": "0.8.13",
34
+ "@otto-code/protocol": "0.8.13",
35
+ "@otto-code/server": "0.8.13",
36
36
  "chalk": "^5.3.0",
37
37
  "commander": "^12.0.0",
38
38
  "mime-types": "^2.1.35",
@@ -1,9 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { SingleResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatRoomRow } from "./schema.js";
5
- export interface ChatCreateOptions extends ChatCommandOptions {
6
- purpose?: string;
7
- }
8
- export declare function runCreateCommand(name: string, options: ChatCreateOptions, _command: Command): Promise<SingleResult<ChatRoomRow>>;
9
- //# sourceMappingURL=create.d.ts.map
@@ -1,23 +0,0 @@
1
- import { connectChatClient, toChatCommandError } from "./shared.js";
2
- import { chatRoomSchema, toChatRoomRow } from "./schema.js";
3
- export async function runCreateCommand(name, options, _command) {
4
- const { client } = await connectChatClient(options.host);
5
- try {
6
- const payload = await client.createChatRoom({
7
- name,
8
- purpose: options.purpose,
9
- });
10
- return {
11
- type: "single",
12
- data: toChatRoomRow(payload.room),
13
- schema: chatRoomSchema,
14
- };
15
- }
16
- catch (err) {
17
- throw toChatCommandError("CHAT_CREATE_FAILED", "create chat room", err);
18
- }
19
- finally {
20
- await client.close().catch(() => { });
21
- }
22
- }
23
- //# sourceMappingURL=create.js.map
@@ -1,6 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { SingleResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatRoomRow } from "./schema.js";
5
- export declare function runDeleteCommand(room: string, options: ChatCommandOptions, _command: Command): Promise<SingleResult<ChatRoomRow>>;
6
- //# sourceMappingURL=delete.d.ts.map
@@ -1,20 +0,0 @@
1
- import { connectChatClient, toChatCommandError } from "./shared.js";
2
- import { chatRoomSchema, toChatRoomRow } from "./schema.js";
3
- export async function runDeleteCommand(room, options, _command) {
4
- const { client } = await connectChatClient(options.host);
5
- try {
6
- const payload = await client.deleteChatRoom({ room });
7
- return {
8
- type: "single",
9
- data: toChatRoomRow(payload.room),
10
- schema: chatRoomSchema,
11
- };
12
- }
13
- catch (err) {
14
- throw toChatCommandError("CHAT_DELETE_FAILED", "delete chat room", err);
15
- }
16
- finally {
17
- await client.close().catch(() => { });
18
- }
19
- }
20
- //# sourceMappingURL=delete.js.map
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function createChatCommand(): Command;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,47 +0,0 @@
1
- import { Command } from "commander";
2
- import { withOutput } from "../../output/index.js";
3
- import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
4
- import { runCreateCommand } from "./create.js";
5
- import { runLsCommand } from "./ls.js";
6
- import { runInspectCommand } from "./inspect.js";
7
- import { runDeleteCommand } from "./delete.js";
8
- import { runPostCommand } from "./post.js";
9
- import { runReadCommand } from "./read.js";
10
- import { runWaitCommand } from "./wait.js";
11
- export function createChatCommand() {
12
- const chat = new Command("chat").description("Manage chat rooms for agent coordination");
13
- addJsonAndDaemonHostOptions(chat
14
- .command("create")
15
- .description("Create a chat room")
16
- .argument("<name>", "Room name (must be unique)")
17
- .option("--purpose <text>", "Room purpose/description")).action(withOutput(runCreateCommand));
18
- addJsonAndDaemonHostOptions(chat.command("ls").description("List chat rooms")).action(withOutput(runLsCommand));
19
- addJsonAndDaemonHostOptions(chat
20
- .command("inspect")
21
- .description("Inspect a chat room")
22
- .argument("<name-or-id>", "Room name or ID")).action(withOutput(runInspectCommand));
23
- addJsonAndDaemonHostOptions(chat
24
- .command("delete")
25
- .description("Delete a chat room")
26
- .argument("<name-or-id>", "Room name or ID")).action(withOutput(runDeleteCommand));
27
- addJsonAndDaemonHostOptions(chat
28
- .command("post")
29
- .description("Post a chat message")
30
- .argument("<name-or-id>", "Room name or ID")
31
- .argument("<message>", "Message body")
32
- .option("--reply-to <msg-id>", "Reply to a specific message ID")).action(withOutput(runPostCommand));
33
- addJsonAndDaemonHostOptions(chat
34
- .command("read")
35
- .description("Read chat messages")
36
- .argument("<name-or-id>", "Room name or ID")
37
- .option("--limit <n>", "Maximum number of messages to return")
38
- .option("--since <duration-or-timestamp>", "Filter by relative duration or ISO timestamp")
39
- .option("--agent <agent-id>", "Filter by author agent ID")).action(withOutput(runReadCommand));
40
- addJsonAndDaemonHostOptions(chat
41
- .command("wait")
42
- .description("Wait for new chat messages")
43
- .argument("<name-or-id>", "Room name or ID")
44
- .option("--timeout <duration>", "Maximum wait time")).action(withOutput(runWaitCommand));
45
- return chat;
46
- }
47
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { SingleResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatRoomRow } from "./schema.js";
5
- export declare function runInspectCommand(room: string, options: ChatCommandOptions, _command: Command): Promise<SingleResult<ChatRoomRow>>;
6
- //# sourceMappingURL=inspect.d.ts.map
@@ -1,20 +0,0 @@
1
- import { connectChatClient, toChatCommandError } from "./shared.js";
2
- import { chatRoomSchema, toChatRoomRow } from "./schema.js";
3
- export async function runInspectCommand(room, options, _command) {
4
- const { client } = await connectChatClient(options.host);
5
- try {
6
- const payload = await client.inspectChatRoom({ room });
7
- return {
8
- type: "single",
9
- data: toChatRoomRow(payload.room),
10
- schema: chatRoomSchema,
11
- };
12
- }
13
- catch (err) {
14
- throw toChatCommandError("CHAT_INSPECT_FAILED", "inspect chat room", err);
15
- }
16
- finally {
17
- await client.close().catch(() => { });
18
- }
19
- }
20
- //# sourceMappingURL=inspect.js.map
@@ -1,6 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { ListResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatRoomRow } from "./schema.js";
5
- export declare function runLsCommand(options: ChatCommandOptions, _command: Command): Promise<ListResult<ChatRoomRow>>;
6
- //# sourceMappingURL=ls.d.ts.map
@@ -1,20 +0,0 @@
1
- import { connectChatClient, toChatCommandError } from "./shared.js";
2
- import { chatRoomSchema, toChatRoomRow } from "./schema.js";
3
- export async function runLsCommand(options, _command) {
4
- const { client } = await connectChatClient(options.host);
5
- try {
6
- const payload = await client.listChatRooms();
7
- return {
8
- type: "list",
9
- data: payload.rooms.map(toChatRoomRow),
10
- schema: chatRoomSchema,
11
- };
12
- }
13
- catch (err) {
14
- throw toChatCommandError("CHAT_LIST_FAILED", "list chat rooms", err);
15
- }
16
- finally {
17
- await client.close().catch(() => { });
18
- }
19
- }
20
- //# sourceMappingURL=ls.js.map
@@ -1,9 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { SingleResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatMessageRow } from "./schema.js";
5
- export interface ChatPostOptions extends ChatCommandOptions {
6
- replyTo?: string;
7
- }
8
- export declare function runPostCommand(room: string, body: string, options: ChatPostOptions, _command: Command): Promise<SingleResult<ChatMessageRow>>;
9
- //# sourceMappingURL=post.d.ts.map
@@ -1,28 +0,0 @@
1
- import { attachAgentNamesToMessages, connectChatClient, resolveChatAuthorAgentId, toChatCommandError, } from "./shared.js";
2
- import { chatMessageSchema, toChatMessageRow } from "./schema.js";
3
- export async function runPostCommand(room, body, options, _command) {
4
- const { client } = await connectChatClient(options.host);
5
- try {
6
- const payload = await client.postChatMessage({
7
- room,
8
- body,
9
- authorAgentId: resolveChatAuthorAgentId(),
10
- replyToMessageId: options.replyTo,
11
- });
12
- const [message] = await attachAgentNamesToMessages(client, [
13
- toChatMessageRow(payload.message),
14
- ]);
15
- return {
16
- type: "single",
17
- data: message,
18
- schema: chatMessageSchema,
19
- };
20
- }
21
- catch (err) {
22
- throw toChatCommandError("CHAT_POST_FAILED", "post chat message", err);
23
- }
24
- finally {
25
- await client.close().catch(() => { });
26
- }
27
- }
28
- //# sourceMappingURL=post.js.map
@@ -1,11 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { ListResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatMessageRow } from "./schema.js";
5
- export interface ChatReadOptions extends ChatCommandOptions {
6
- limit?: string;
7
- since?: string;
8
- agent?: string;
9
- }
10
- export declare function runReadCommand(room: string, options: ChatReadOptions, _command: Command): Promise<ListResult<ChatMessageRow>>;
11
- //# sourceMappingURL=read.d.ts.map
@@ -1,40 +0,0 @@
1
- import { attachAgentNamesToMessages, connectChatClient, parseSinceValue, toChatCommandError, } from "./shared.js";
2
- import { chatMessageSchema, toChatMessageRow } from "./schema.js";
3
- function parseLimit(value) {
4
- if (!value) {
5
- return undefined;
6
- }
7
- const parsed = Number.parseInt(value, 10);
8
- if (!Number.isInteger(parsed) || parsed < 0) {
9
- throw {
10
- code: "INVALID_LIMIT",
11
- message: "Invalid --limit value",
12
- details: "Use a non-negative integer.",
13
- };
14
- }
15
- return parsed;
16
- }
17
- export async function runReadCommand(room, options, _command) {
18
- const { client } = await connectChatClient(options.host);
19
- try {
20
- const payload = await client.readChatMessages({
21
- room,
22
- limit: parseLimit(options.limit),
23
- since: parseSinceValue(options.since),
24
- authorAgentId: options.agent,
25
- });
26
- const messages = await attachAgentNamesToMessages(client, payload.messages.map(toChatMessageRow));
27
- return {
28
- type: "list",
29
- data: messages,
30
- schema: chatMessageSchema,
31
- };
32
- }
33
- catch (err) {
34
- throw toChatCommandError("CHAT_READ_FAILED", "read chat messages", err);
35
- }
36
- finally {
37
- await client.close().catch(() => { });
38
- }
39
- }
40
- //# sourceMappingURL=read.js.map
@@ -1,36 +0,0 @@
1
- import type { OutputSchema } from "../../output/index.js";
2
- export interface ChatRoomRow {
3
- name: string;
4
- id: string;
5
- purpose: string;
6
- messages: number;
7
- lastMessageAt: string;
8
- }
9
- export interface ChatMessageRow {
10
- id: string;
11
- author: string;
12
- authorName: string | null;
13
- createdAt: string;
14
- replyTo: string;
15
- mentionAgentIds: string[];
16
- mentionLabels: string[];
17
- body: string;
18
- }
19
- export declare const chatRoomSchema: OutputSchema<ChatRoomRow>;
20
- export declare const chatMessageSchema: OutputSchema<ChatMessageRow>;
21
- export declare function toChatRoomRow(room: {
22
- id: string;
23
- name: string;
24
- purpose: string | null;
25
- messageCount: number;
26
- lastMessageAt: string | null;
27
- }): ChatRoomRow;
28
- export declare function toChatMessageRow(message: {
29
- id: string;
30
- authorAgentId: string;
31
- createdAt: string;
32
- replyToMessageId: string | null;
33
- mentionAgentIds: string[];
34
- body: string;
35
- }): ChatMessageRow;
36
- //# sourceMappingURL=schema.d.ts.map
@@ -1,81 +0,0 @@
1
- export const chatRoomSchema = {
2
- idField: "id",
3
- columns: [
4
- { header: "NAME", field: "name", width: 22 },
5
- { header: "ID", field: "id", width: 36 },
6
- { header: "PURPOSE", field: "purpose", width: 30 },
7
- { header: "MESSAGES", field: "messages", width: 10, align: "right" },
8
- { header: "LAST MESSAGE", field: "lastMessageAt", width: 24 },
9
- ],
10
- };
11
- export const chatMessageSchema = {
12
- idField: "id",
13
- columns: [
14
- { header: "ID", field: "id", width: 36 },
15
- { header: "AUTHOR", field: "author", width: 16 },
16
- { header: "AUTHOR NAME", field: (row) => row.authorName ?? "-", width: 20 },
17
- { header: "CREATED", field: "createdAt", width: 24 },
18
- { header: "REPLY TO", field: "replyTo", width: 36 },
19
- { header: "MENTIONS", field: (row) => row.mentionLabels.join(", ") || "-", width: 24 },
20
- { header: "MESSAGE", field: "body", width: 60 },
21
- ],
22
- renderHuman: renderChatTranscript,
23
- };
24
- function renderChatTranscript(result, _options) {
25
- const data = result.type === "list" ? result.data : [result.data];
26
- if (data.length === 0) {
27
- return "";
28
- }
29
- return data.map(renderChatMessageBlock).join("\n\n");
30
- }
31
- function renderChatMessageBlock(message) {
32
- const authorLabel = message.authorName
33
- ? `${message.authorName} (${message.author})`
34
- : message.author;
35
- const lines = [
36
- `┌─ ${authorLabel} ── ${formatTimestamp(message.createdAt)} ── [msg ${message.id}]`,
37
- ];
38
- if (message.replyTo !== "-") {
39
- lines.push(`│ reply-to: msg ${message.replyTo}`);
40
- }
41
- if (message.mentionLabels.length > 0) {
42
- lines.push(`│ mentions: ${message.mentionLabels.join(", ")}`);
43
- }
44
- lines.push("│");
45
- const bodyLines = message.body.split(/\r?\n/);
46
- for (const line of bodyLines) {
47
- lines.push(`│ ${line}`);
48
- }
49
- lines.push("│");
50
- lines.push("└─");
51
- return lines.join("\n");
52
- }
53
- function formatTimestamp(input) {
54
- const date = new Date(input);
55
- if (Number.isNaN(date.getTime())) {
56
- return input;
57
- }
58
- return date.toISOString().replace("T", " ").replace(".000Z", "Z");
59
- }
60
- export function toChatRoomRow(room) {
61
- return {
62
- id: room.id,
63
- name: room.name,
64
- purpose: room.purpose ?? "-",
65
- messages: room.messageCount,
66
- lastMessageAt: room.lastMessageAt ?? "-",
67
- };
68
- }
69
- export function toChatMessageRow(message) {
70
- return {
71
- id: message.id,
72
- author: message.authorAgentId,
73
- authorName: null,
74
- createdAt: message.createdAt,
75
- replyTo: message.replyToMessageId ?? "-",
76
- mentionAgentIds: message.mentionAgentIds,
77
- mentionLabels: message.mentionAgentIds,
78
- body: message.body,
79
- };
80
- }
81
- //# sourceMappingURL=schema.js.map
@@ -1,19 +0,0 @@
1
- import { connectToDaemon } from "../../utils/client.js";
2
- import type { CommandError, CommandOptions } from "../../output/index.js";
3
- import type { ChatMessageRow } from "./schema.js";
4
- export interface ChatCommandOptions extends CommandOptions {
5
- host?: string;
6
- }
7
- export declare function connectChatClient(host?: string): Promise<{
8
- client: import("@otto-code/client/internal/daemon-client").DaemonClient;
9
- daemonHost: string;
10
- }>;
11
- export declare function attachAgentNamesToMessages(client: Awaited<ReturnType<typeof connectToDaemon>>, messages: ChatMessageRow[], options?: {
12
- timeout?: number;
13
- bestEffort?: boolean;
14
- }): Promise<ChatMessageRow[]>;
15
- export declare function toChatCommandError(code: string, action: string, err: unknown): CommandError;
16
- export declare function parseSinceValue(input?: string): string | undefined;
17
- export declare function parseTimeoutMs(input?: string): number | undefined;
18
- export declare function resolveChatAuthorAgentId(): string;
19
- //# sourceMappingURL=shared.d.ts.map
@@ -1,118 +0,0 @@
1
- import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
2
- import { parseDuration } from "../../utils/duration.js";
3
- export async function connectChatClient(host) {
4
- const daemonHost = getDaemonHost({ host });
5
- try {
6
- const client = await connectToDaemon({ host });
7
- return { client, daemonHost };
8
- }
9
- catch (err) {
10
- const message = err instanceof Error ? err.message : String(err);
11
- const error = {
12
- code: "DAEMON_NOT_RUNNING",
13
- message: `Cannot connect to daemon at ${daemonHost}: ${message}`,
14
- details: "Start the daemon with: otto daemon start",
15
- };
16
- throw error;
17
- }
18
- }
19
- export async function attachAgentNamesToMessages(client, messages, options = {}) {
20
- const agentIds = new Set();
21
- for (const message of messages) {
22
- agentIds.add(message.author);
23
- for (const mentionId of message.mentionAgentIds) {
24
- agentIds.add(mentionId);
25
- }
26
- }
27
- if (agentIds.size === 0) {
28
- return messages;
29
- }
30
- let payload;
31
- try {
32
- payload = await client.fetchAgents({
33
- filter: { includeArchived: true },
34
- ...(typeof options.timeout === "number" ? { timeout: options.timeout } : {}),
35
- });
36
- }
37
- catch (error) {
38
- if (options.bestEffort) {
39
- return messages;
40
- }
41
- throw error;
42
- }
43
- const agentNames = new Map();
44
- for (const entry of payload.entries) {
45
- const title = entry.agent.title?.trim();
46
- if (title) {
47
- agentNames.set(entry.agent.id, title);
48
- }
49
- }
50
- return messages.map((message) => ({
51
- ...message,
52
- authorName: agentNames.get(message.author) ?? null,
53
- mentionLabels: message.mentionAgentIds.map((agentId) => {
54
- const name = agentNames.get(agentId);
55
- return name ? `${name} (${agentId})` : agentId;
56
- }),
57
- }));
58
- }
59
- export function toChatCommandError(code, action, err) {
60
- if (err && typeof err === "object" && "code" in err && "message" in err) {
61
- return err;
62
- }
63
- const message = err instanceof Error ? err.message : String(err);
64
- const rpcCode = typeof err === "object" && err !== null && "code" in err && typeof err.code === "string"
65
- ? err.code
66
- : undefined;
67
- return {
68
- code: rpcCode ?? code,
69
- message: `Failed to ${action}: ${message}`,
70
- };
71
- }
72
- export function parseSinceValue(input) {
73
- if (!input) {
74
- return undefined;
75
- }
76
- try {
77
- const durationMs = parseDuration(input);
78
- return new Date(Date.now() - durationMs).toISOString();
79
- }
80
- catch {
81
- const timestamp = new Date(input);
82
- if (Number.isNaN(timestamp.getTime())) {
83
- const error = {
84
- code: "INVALID_SINCE",
85
- message: "Invalid --since value",
86
- details: "Use a duration like 10m or an ISO timestamp.",
87
- };
88
- throw error;
89
- }
90
- return timestamp.toISOString();
91
- }
92
- }
93
- export function parseTimeoutMs(input) {
94
- if (!input) {
95
- return undefined;
96
- }
97
- try {
98
- const timeoutMs = parseDuration(input);
99
- if (timeoutMs <= 0) {
100
- throw new Error("Timeout must be positive");
101
- }
102
- return timeoutMs;
103
- }
104
- catch (err) {
105
- const message = err instanceof Error ? err.message : String(err);
106
- const error = {
107
- code: "INVALID_TIMEOUT",
108
- message: "Invalid timeout value",
109
- details: message,
110
- };
111
- throw error;
112
- }
113
- }
114
- export function resolveChatAuthorAgentId() {
115
- const agentId = process.env.OTTO_AGENT_ID?.trim();
116
- return agentId && agentId.length > 0 ? agentId : "manual";
117
- }
118
- //# sourceMappingURL=shared.js.map
@@ -1,9 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { ListResult } from "../../output/index.js";
3
- import { type ChatCommandOptions } from "./shared.js";
4
- import { type ChatMessageRow } from "./schema.js";
5
- export interface ChatWaitOptions extends ChatCommandOptions {
6
- timeout?: string;
7
- }
8
- export declare function runWaitCommand(room: string, options: ChatWaitOptions, _command: Command): Promise<ListResult<ChatMessageRow>>;
9
- //# sourceMappingURL=wait.d.ts.map
@@ -1,45 +0,0 @@
1
- import { attachAgentNamesToMessages, connectChatClient, parseTimeoutMs, toChatCommandError, } from "./shared.js";
2
- import { chatMessageSchema, toChatMessageRow } from "./schema.js";
3
- const CHAT_WAIT_PREFLIGHT_TIMEOUT_MS = 2000;
4
- export async function runWaitCommand(room, options, _command) {
5
- const timeoutMs = parseTimeoutMs(options.timeout);
6
- const { client } = await connectChatClient(options.host);
7
- const deadline = typeof timeoutMs === "number" ? Date.now() + timeoutMs : null;
8
- const hasExplicitTimeout = deadline !== null;
9
- const remainingTimeoutMs = () => deadline === null ? undefined : Math.max(1, deadline - Date.now());
10
- try {
11
- const latest = await client.readChatMessages({
12
- room,
13
- limit: 1,
14
- ...(hasExplicitTimeout
15
- ? {
16
- timeout: Math.min(remainingTimeoutMs() ?? 1, CHAT_WAIT_PREFLIGHT_TIMEOUT_MS),
17
- }
18
- : {}),
19
- });
20
- const afterMessageId = latest.messages[0]?.id;
21
- const payload = await client.waitForChatMessages({
22
- room,
23
- afterMessageId,
24
- timeoutMs: remainingTimeoutMs() ?? timeoutMs,
25
- });
26
- const messages = await attachAgentNamesToMessages(client, payload.messages.map(toChatMessageRow), hasExplicitTimeout
27
- ? {
28
- timeout: remainingTimeoutMs(),
29
- bestEffort: true,
30
- }
31
- : {});
32
- return {
33
- type: "list",
34
- data: messages,
35
- schema: chatMessageSchema,
36
- };
37
- }
38
- catch (err) {
39
- throw toChatCommandError("CHAT_WAIT_FAILED", "wait for chat messages", err);
40
- }
41
- finally {
42
- await client.close().catch(() => { });
43
- }
44
- }
45
- //# sourceMappingURL=wait.js.map
@@ -1,45 +0,0 @@
1
- import { z } from "zod";
2
- declare const authorizationSchema: z.ZodObject<{
3
- deviceCode: z.ZodString;
4
- userCode: z.ZodString;
5
- verificationUri: z.ZodURL;
6
- verificationUriComplete: z.ZodURL;
7
- expiresAt: z.ZodString;
8
- interval: z.ZodNumber;
9
- }, z.core.$strip>;
10
- declare const pollSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
- status: z.ZodLiteral<"pending">;
12
- interval: z.ZodNumber;
13
- }, z.core.$strip>, z.ZodObject<{
14
- status: z.ZodLiteral<"slow_down">;
15
- interval: z.ZodNumber;
16
- }, z.core.$strip>, z.ZodObject<{
17
- status: z.ZodLiteral<"approved">;
18
- interval: z.ZodNumber;
19
- enrollmentToken: z.ZodString;
20
- }, z.core.$strip>, z.ZodObject<{
21
- status: z.ZodLiteral<"denied">;
22
- interval: z.ZodNumber;
23
- }, z.core.$strip>, z.ZodObject<{
24
- status: z.ZodLiteral<"expired">;
25
- interval: z.ZodNumber;
26
- }, z.core.$strip>, z.ZodObject<{
27
- status: z.ZodLiteral<"enrolled">;
28
- interval: z.ZodNumber;
29
- }, z.core.$strip>, z.ZodObject<{
30
- status: z.ZodLiteral<"retry_later">;
31
- }, z.core.$strip>], "status">;
32
- export type DeviceAuthorization = z.infer<typeof authorizationSchema>;
33
- export type DeviceAuthorizationPoll = z.infer<typeof pollSchema>;
34
- export interface CloudDeviceAuthorization {
35
- start(hubUrl: string, displayName: string): Promise<DeviceAuthorization>;
36
- poll(hubUrl: string, deviceCode: string, timeoutMilliseconds: number): Promise<DeviceAuthorizationPoll>;
37
- }
38
- export declare class CloudDeviceAuthorizationClient implements CloudDeviceAuthorization {
39
- private readonly startTimeoutMilliseconds;
40
- constructor(startTimeoutMilliseconds?: number);
41
- start(hubUrl: string, displayName: string): Promise<DeviceAuthorization>;
42
- poll(hubUrl: string, deviceCode: string, timeoutMilliseconds: number): Promise<DeviceAuthorizationPoll>;
43
- }
44
- export {};
45
- //# sourceMappingURL=cloud-device-authorization.d.ts.map