photon-msg 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +275 -2
- package/dist/args.d.ts +63 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +68 -0
- package/dist/args.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +163 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +68 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/attachments.d.ts +25 -0
- package/dist/commands/attachments.d.ts.map +1 -0
- package/dist/commands/attachments.js +78 -0
- package/dist/commands/attachments.js.map +1 -0
- package/dist/commands/doctor.d.ts +9 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +54 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/line.d.ts +51 -0
- package/dist/commands/line.d.ts.map +1 -0
- package/dist/commands/line.js +117 -0
- package/dist/commands/line.js.map +1 -0
- package/dist/commands/messages.d.ts +82 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +163 -0
- package/dist/commands/messages.js.map +1 -0
- package/dist/commands/misc.d.ts +33 -0
- package/dist/commands/misc.d.ts.map +1 -0
- package/dist/commands/misc.js +61 -0
- package/dist/commands/misc.js.map +1 -0
- package/dist/commands/send.d.ts +107 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +104 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/spaces.d.ts +56 -0
- package/dist/commands/spaces.d.ts.map +1 -0
- package/dist/commands/spaces.js +118 -0
- package/dist/commands/spaces.js.map +1 -0
- package/dist/commands/users.d.ts +34 -0
- package/dist/commands/users.d.ts.map +1 -0
- package/dist/commands/users.js +82 -0
- package/dist/commands/users.js.map +1 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +77 -0
- package/dist/config.js.map +1 -0
- package/dist/content.d.ts +33 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +287 -0
- package/dist/content.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +95 -0
- package/dist/errors.js.map +1 -0
- package/dist/help.d.ts +8 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +177 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +35 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +121 -0
- package/dist/output.js.map +1 -0
- package/dist/target.d.ts +34 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +75 -0
- package/dist/target.js.map +1 -0
- package/dist/types.d.ts +200 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/upload.d.ts +33 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +119 -0
- package/dist/upload.js.map +1 -0
- package/package.json +49 -4
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `messages` — list, fetch, and follow messages.
|
|
3
|
+
*/
|
|
4
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
5
|
+
import { handleOf, nextPageToken, pageItems } from "../client.js";
|
|
6
|
+
import { formatTime, summarizeContent } from "../output.js";
|
|
7
|
+
import { usageError } from "../errors.js";
|
|
8
|
+
/** Builds the SDK query object from list flags. */
|
|
9
|
+
const listQuery = (flags) => {
|
|
10
|
+
const query = {};
|
|
11
|
+
const map = [
|
|
12
|
+
["platform", "platform"],
|
|
13
|
+
["direction", "direction"],
|
|
14
|
+
["order", "order"],
|
|
15
|
+
["order-by", "orderBy"],
|
|
16
|
+
["space", "spaceId"],
|
|
17
|
+
["resource", "resourceId"],
|
|
18
|
+
["perspective-user", "perspectiveUserId"],
|
|
19
|
+
["created-since", "createdSince"],
|
|
20
|
+
["created-before", "createdBefore"],
|
|
21
|
+
["updated-since", "updatedSince"],
|
|
22
|
+
["updated-before", "updatedBefore"],
|
|
23
|
+
["exclude-content-types", "excludeContentTypes"],
|
|
24
|
+
["page-token", "pageToken"],
|
|
25
|
+
];
|
|
26
|
+
for (const [flag, key] of map) {
|
|
27
|
+
const value = flags[flag];
|
|
28
|
+
if (typeof value === "string")
|
|
29
|
+
query[key] = value;
|
|
30
|
+
}
|
|
31
|
+
if (flags["page-size"] !== undefined)
|
|
32
|
+
query.pageSize = Number(flags["page-size"]);
|
|
33
|
+
return query;
|
|
34
|
+
};
|
|
35
|
+
const columns = [
|
|
36
|
+
{ header: "ID", value: (message) => message.id },
|
|
37
|
+
{ header: "TIME", value: (message) => formatTime(message.createdAt) },
|
|
38
|
+
{ header: "PLATFORM", value: (message) => message.platform },
|
|
39
|
+
{ header: "DIRECTION", value: (message) => message.direction },
|
|
40
|
+
{ header: "STATUS", value: (message) => message.status },
|
|
41
|
+
{ header: "FROM", value: (message) => handleOf(message.sentBy) },
|
|
42
|
+
{ header: "TO", value: (message) => handleOf(message.receivedBy) },
|
|
43
|
+
{ header: "CONTENT", value: (message) => summarizeContent(message.content) },
|
|
44
|
+
];
|
|
45
|
+
export const list = {
|
|
46
|
+
options: {
|
|
47
|
+
platform: { type: "string" },
|
|
48
|
+
direction: { type: "string" },
|
|
49
|
+
order: { type: "string" },
|
|
50
|
+
"order-by": { type: "string" },
|
|
51
|
+
space: { type: "string" },
|
|
52
|
+
resource: { type: "string" },
|
|
53
|
+
"perspective-user": { type: "string" },
|
|
54
|
+
"created-since": { type: "string" },
|
|
55
|
+
"created-before": { type: "string" },
|
|
56
|
+
"updated-since": { type: "string" },
|
|
57
|
+
"updated-before": { type: "string" },
|
|
58
|
+
"exclude-content-types": { type: "string" },
|
|
59
|
+
"page-size": { type: "string" },
|
|
60
|
+
"page-token": { type: "string" },
|
|
61
|
+
limit: { type: "string" },
|
|
62
|
+
},
|
|
63
|
+
async run({ client, projectId, flags, out }) {
|
|
64
|
+
const limit = flags.limit ? Number(flags.limit) : undefined;
|
|
65
|
+
if (limit !== undefined && (Number.isNaN(limit) || limit <= 0)) {
|
|
66
|
+
throw usageError("--limit must be a positive number.");
|
|
67
|
+
}
|
|
68
|
+
const collected = [];
|
|
69
|
+
let pageToken = flags["page-token"];
|
|
70
|
+
let pages = 0;
|
|
71
|
+
do {
|
|
72
|
+
const page = await client.projects.listMessages({
|
|
73
|
+
path: { id: projectId },
|
|
74
|
+
query: {
|
|
75
|
+
...listQuery(flags),
|
|
76
|
+
...(pageToken ? { pageToken } : {}),
|
|
77
|
+
...(limit && !flags["page-size"] ? { pageSize: Math.min(limit, 200) } : {}),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
collected.push(...pageItems(page));
|
|
81
|
+
pageToken = nextPageToken(page);
|
|
82
|
+
pages += 1;
|
|
83
|
+
if (limit && collected.length >= limit)
|
|
84
|
+
break;
|
|
85
|
+
if (pages >= 50)
|
|
86
|
+
break;
|
|
87
|
+
} while (pageToken);
|
|
88
|
+
const rows = limit ? collected.slice(0, limit) : collected;
|
|
89
|
+
out.data({ items: rows, count: rows.length, pages, nextPageToken: pageToken ?? null });
|
|
90
|
+
out.table(rows, columns);
|
|
91
|
+
if (!flags.quiet)
|
|
92
|
+
out.info(`${rows.length} message(s)`);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export const get = {
|
|
96
|
+
options: {},
|
|
97
|
+
async run({ client, projectId, positionals, out }) {
|
|
98
|
+
const messageId = positionals[0];
|
|
99
|
+
if (!messageId)
|
|
100
|
+
throw usageError("Usage: photon-msg messages get <messageId>");
|
|
101
|
+
const message = (await client.projects.getMessage({
|
|
102
|
+
path: { id: projectId, messageId },
|
|
103
|
+
}));
|
|
104
|
+
out.data(message);
|
|
105
|
+
out.heading(`message ${message.id}`);
|
|
106
|
+
out.keyValue([
|
|
107
|
+
["platform", message.platform],
|
|
108
|
+
["direction", message.direction],
|
|
109
|
+
["status", message.status],
|
|
110
|
+
["created", formatTime(message.createdAt)],
|
|
111
|
+
["space", message.space?.id],
|
|
112
|
+
["from", `${handleOf(message.sentBy) || "—"} (${message.sentBy?.kind ?? "?"})`],
|
|
113
|
+
["to", `${handleOf(message.receivedBy) || "—"} (${message.receivedBy?.kind ?? "outbound"})`],
|
|
114
|
+
["content", summarizeContent(message.content)],
|
|
115
|
+
]);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
export const watch = {
|
|
119
|
+
options: {
|
|
120
|
+
platform: { type: "string" },
|
|
121
|
+
space: { type: "string" },
|
|
122
|
+
direction: { type: "string" },
|
|
123
|
+
interval: { type: "string" },
|
|
124
|
+
for: { type: "string" },
|
|
125
|
+
since: { type: "string" },
|
|
126
|
+
},
|
|
127
|
+
async run({ client, projectId, flags, out }) {
|
|
128
|
+
const intervalMs = Math.max(1, Number(flags.interval ?? 2)) * 1000;
|
|
129
|
+
const durationMs = flags.for ? Number(flags.for) * 1000 : 0;
|
|
130
|
+
const createdSince = flags.since ? new Date(flags.since).toISOString() : new Date().toISOString();
|
|
131
|
+
const deadline = durationMs ? Date.now() + durationMs : Number.POSITIVE_INFINITY;
|
|
132
|
+
const seen = new Set();
|
|
133
|
+
if (!flags.quiet)
|
|
134
|
+
out.info(`watching from ${createdSince}, every ${intervalMs / 1000}s (ctrl-c to stop)`);
|
|
135
|
+
while (Date.now() < deadline) {
|
|
136
|
+
let pageToken;
|
|
137
|
+
do {
|
|
138
|
+
const page = await client.projects.listMessages({
|
|
139
|
+
path: { id: projectId },
|
|
140
|
+
query: {
|
|
141
|
+
createdSince,
|
|
142
|
+
direction: flags.direction ?? "received",
|
|
143
|
+
order: "asc",
|
|
144
|
+
pageSize: 100,
|
|
145
|
+
...(flags.platform ? { platform: flags.platform } : {}),
|
|
146
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
147
|
+
...(pageToken ? { pageToken } : {}),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
for (const message of pageItems(page)) {
|
|
151
|
+
if (seen.has(message.id))
|
|
152
|
+
continue;
|
|
153
|
+
seen.add(message.id);
|
|
154
|
+
// JSON lines so the output can be piped straight into another process.
|
|
155
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
156
|
+
}
|
|
157
|
+
pageToken = nextPageToken(page);
|
|
158
|
+
} while (pageToken);
|
|
159
|
+
await sleep(intervalMs);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAoB,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,mDAAmD;AACnD,MAAM,SAAS,GAAG,CAAC,KAAY,EAAmC,EAAE;IAClE,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,MAAM,GAAG,GAAiC;QACxC,CAAC,UAAU,EAAE,UAAU,CAAC;QACxB,CAAC,WAAW,EAAE,WAAW,CAAC;QAC1B,CAAC,OAAO,EAAE,OAAO,CAAC;QAClB,CAAC,UAAU,EAAE,SAAS,CAAC;QACvB,CAAC,OAAO,EAAE,SAAS,CAAC;QACpB,CAAC,UAAU,EAAE,YAAY,CAA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AAC,CAAC;gBAEH,KAAK,MAAM,OAAO,IAAI,SAAS,CAAgB,IAAI,CAAC,EAAE,CAAC;oBACrD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;wBAAE,SAAS;oBACnC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBACrB,uEAAuE;oBACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvD,CAAC;gBACD,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC,QAAQ,SAAS,EAAE;YAEpB,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `typing` and `read` — small conversation-state commands.
|
|
3
|
+
*
|
|
4
|
+
* Typing goes through its own endpoint (`setSpaceTyping`); the same signal can
|
|
5
|
+
* also travel as `space.typing.update` content via `send --typing`.
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandContext } from "../types.js";
|
|
8
|
+
export declare const typing: {
|
|
9
|
+
options: {
|
|
10
|
+
readonly space: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly as: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly on: {
|
|
17
|
+
readonly type: "boolean";
|
|
18
|
+
};
|
|
19
|
+
readonly off: {
|
|
20
|
+
readonly type: "boolean";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
run({ client, projectId, flags, out, dryRun, config }: CommandContext): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export declare const read: {
|
|
26
|
+
options: {
|
|
27
|
+
readonly "idempotency-key": {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
run({ client, projectId, flags, positionals, out, dryRun }: CommandContext): Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/commands/misc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;2DAQ4C,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA2B5F,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;gEAKmD,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBjG,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `typing` and `read` — small conversation-state commands.
|
|
3
|
+
*
|
|
4
|
+
* Typing goes through its own endpoint (`setSpaceTyping`); the same signal can
|
|
5
|
+
* also travel as `space.typing.update` content via `send --typing`.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { usageError } from "../errors.js";
|
|
9
|
+
import { resolveTarget } from "../target.js";
|
|
10
|
+
export const typing = {
|
|
11
|
+
options: {
|
|
12
|
+
space: { type: "string" },
|
|
13
|
+
as: { type: "string" },
|
|
14
|
+
on: { type: "boolean" },
|
|
15
|
+
off: { type: "boolean" },
|
|
16
|
+
},
|
|
17
|
+
async run({ client, projectId, flags, out, dryRun, config }) {
|
|
18
|
+
if (!flags.space) {
|
|
19
|
+
throw usageError("Pass --space <spaceId> (using --to here would create a conversation, which typing should not do).");
|
|
20
|
+
}
|
|
21
|
+
if (flags.on === flags.off)
|
|
22
|
+
throw usageError("Pass exactly one of --on or --off.");
|
|
23
|
+
const typingState = flags.on === true;
|
|
24
|
+
if (dryRun) {
|
|
25
|
+
const sender = flags.as ?? config.agentHandle ?? "(agent)";
|
|
26
|
+
out.data({ dryRun: true, spaceId: flags.space, senderId: `${sender} (resolved at send time)`, typing: typingState });
|
|
27
|
+
out.line(`would set typing=${typingState} in ${flags.space}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const target = await resolveTarget({ client, projectId, flags, defaultHandle: config.agentHandle });
|
|
31
|
+
await client.projects.setSpaceTyping({
|
|
32
|
+
path: { id: projectId, spaceId: flags.space },
|
|
33
|
+
body: { senderId: target.senderId, typing: typingState },
|
|
34
|
+
});
|
|
35
|
+
out.data({ spaceId: flags.space, senderId: target.senderId, typing: typingState });
|
|
36
|
+
out.success(`typing ${typingState ? "on" : "off"} in ${flags.space}`);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const read = {
|
|
40
|
+
options: {
|
|
41
|
+
"idempotency-key": { type: "string" },
|
|
42
|
+
},
|
|
43
|
+
async run({ client, projectId, flags, positionals, out, dryRun }) {
|
|
44
|
+
const messageId = positionals[0];
|
|
45
|
+
if (!messageId)
|
|
46
|
+
throw usageError("Usage: photon-msg read <messageId>");
|
|
47
|
+
const idempotencyKey = flags["idempotency-key"] ?? randomUUID();
|
|
48
|
+
if (dryRun) {
|
|
49
|
+
out.data({ dryRun: true, messageId, idempotencyKey });
|
|
50
|
+
out.line(`would mark ${messageId} read`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await client.projects.markMessageRead({
|
|
54
|
+
path: { id: projectId, messageId },
|
|
55
|
+
headers: { "idempotency-key": idempotencyKey },
|
|
56
|
+
});
|
|
57
|
+
out.data({ messageId, read: true, idempotencyKey });
|
|
58
|
+
out.success(`marked ${messageId} read`);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/commands/misc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,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AAC;YACpC,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;YAClC,OAAO,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;SAC/C,CAAC,CAAC;QAEH,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACpD,GAAG,CAAC,OAAO,CAAC,UAAU,SAAS,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `send` — the core command.
|
|
3
|
+
*
|
|
4
|
+
* One command covers every outbound content type because the API takes a
|
|
5
|
+
* polymorphic content object rather than an endpoint per action.
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandContext } from "../types.js";
|
|
8
|
+
export declare const options: {
|
|
9
|
+
readonly to: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
};
|
|
12
|
+
readonly space: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
};
|
|
15
|
+
readonly as: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
};
|
|
18
|
+
readonly platform: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
};
|
|
21
|
+
readonly text: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly multiple: true;
|
|
24
|
+
};
|
|
25
|
+
readonly "text-file": {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
readonly format: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
};
|
|
31
|
+
readonly image: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly multiple: true;
|
|
34
|
+
};
|
|
35
|
+
readonly file: {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly multiple: true;
|
|
38
|
+
};
|
|
39
|
+
readonly caption: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
};
|
|
42
|
+
readonly voice: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
};
|
|
45
|
+
readonly reaction: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
};
|
|
48
|
+
readonly "reaction-action": {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
};
|
|
51
|
+
readonly poll: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
};
|
|
54
|
+
readonly "poll-option": {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
readonly multiple: true;
|
|
57
|
+
};
|
|
58
|
+
readonly "poll-mode": {
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
};
|
|
61
|
+
readonly edit: {
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
};
|
|
64
|
+
readonly delete: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
readonly reason: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly read: {
|
|
71
|
+
readonly type: "boolean";
|
|
72
|
+
};
|
|
73
|
+
readonly typing: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
};
|
|
76
|
+
readonly "participants-add": {
|
|
77
|
+
readonly type: "string";
|
|
78
|
+
readonly multiple: true;
|
|
79
|
+
};
|
|
80
|
+
readonly "participants-remove": {
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly multiple: true;
|
|
83
|
+
};
|
|
84
|
+
readonly group: {
|
|
85
|
+
readonly type: "boolean";
|
|
86
|
+
};
|
|
87
|
+
readonly "reply-to": {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
};
|
|
90
|
+
readonly "idempotency-key": {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
};
|
|
93
|
+
readonly subject: {
|
|
94
|
+
readonly type: "string";
|
|
95
|
+
};
|
|
96
|
+
readonly cc: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly multiple: true;
|
|
99
|
+
};
|
|
100
|
+
readonly bcc: {
|
|
101
|
+
readonly type: "string";
|
|
102
|
+
readonly multiple: true;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/** Sends (or, with --dry-run, describes) one message. */
|
|
106
|
+
export declare function run({ flags, projectId, client, out, dryRun, upload, config }: CommandContext): Promise<void>;
|
|
107
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAErE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCuB,CAAC;AAI5C,yDAAyD;AACzD,wBAAsB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuElH"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `send` — the core command.
|
|
3
|
+
*
|
|
4
|
+
* One command covers every outbound content type because the API takes a
|
|
5
|
+
* polymorphic content object rather than an endpoint per action.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { buildMessage, describeContent } from "../content.js";
|
|
9
|
+
import { resolveTarget } from "../target.js";
|
|
10
|
+
import { usageError } from "../errors.js";
|
|
11
|
+
export const options = {
|
|
12
|
+
to: { type: "string" },
|
|
13
|
+
space: { type: "string" },
|
|
14
|
+
as: { type: "string" },
|
|
15
|
+
platform: { type: "string" },
|
|
16
|
+
text: { type: "string", multiple: true },
|
|
17
|
+
"text-file": { type: "string" },
|
|
18
|
+
format: { type: "string" },
|
|
19
|
+
image: { type: "string", multiple: true },
|
|
20
|
+
file: { type: "string", multiple: true },
|
|
21
|
+
caption: { type: "string" },
|
|
22
|
+
voice: { type: "string" },
|
|
23
|
+
reaction: { type: "string" },
|
|
24
|
+
"reaction-action": { type: "string" },
|
|
25
|
+
poll: { type: "string" },
|
|
26
|
+
"poll-option": { type: "string", multiple: true },
|
|
27
|
+
"poll-mode": { type: "string" },
|
|
28
|
+
edit: { type: "string" },
|
|
29
|
+
delete: { type: "string" },
|
|
30
|
+
reason: { type: "string" },
|
|
31
|
+
read: { type: "boolean" },
|
|
32
|
+
typing: { type: "string" },
|
|
33
|
+
"participants-add": { type: "string", multiple: true },
|
|
34
|
+
"participants-remove": { type: "string", multiple: true },
|
|
35
|
+
group: { type: "boolean" },
|
|
36
|
+
"reply-to": { type: "string" },
|
|
37
|
+
"idempotency-key": { type: "string" },
|
|
38
|
+
subject: { type: "string" },
|
|
39
|
+
cc: { type: "string", multiple: true },
|
|
40
|
+
bcc: { type: "string", multiple: true },
|
|
41
|
+
};
|
|
42
|
+
const UPLOAD_FLAGS = ["image", "file", "voice"];
|
|
43
|
+
/** Sends (or, with --dry-run, describes) one message. */
|
|
44
|
+
export async function run({ flags, projectId, client, out, dryRun, upload, config }) {
|
|
45
|
+
if (dryRun && UPLOAD_FLAGS.some((flag) => flags[flag] !== undefined)) {
|
|
46
|
+
throw usageError("--dry-run cannot include attachments, because uploading them is a network write.");
|
|
47
|
+
}
|
|
48
|
+
const message = await buildMessage({
|
|
49
|
+
flags,
|
|
50
|
+
upload,
|
|
51
|
+
getUsers: async (ids) => Promise.all(ids.map(async (userId) => {
|
|
52
|
+
const user = await client.projects.getUser({ path: { id: projectId, userId } });
|
|
53
|
+
return user;
|
|
54
|
+
})),
|
|
55
|
+
});
|
|
56
|
+
const idempotencyKey = flags["idempotency-key"] ?? randomUUID();
|
|
57
|
+
if (dryRun) {
|
|
58
|
+
const spaceId = flags.space ?? "(resolved from --to)";
|
|
59
|
+
const senderId = flags.as ?? config.agentHandle;
|
|
60
|
+
const request = {
|
|
61
|
+
spaceId,
|
|
62
|
+
senderId: senderId ? `${senderId} (resolved at send time)` : "(agent)",
|
|
63
|
+
...(message.parentMessageId ? { parentMessageId: message.parentMessageId } : {}),
|
|
64
|
+
content: message.content,
|
|
65
|
+
...(message.email ? { email: message.email } : {}),
|
|
66
|
+
};
|
|
67
|
+
out.data({ dryRun: true, idempotencyKey, request });
|
|
68
|
+
out.line(`would send ${describeContent(message.content)}`);
|
|
69
|
+
out.keyValue([
|
|
70
|
+
["space", request.spaceId],
|
|
71
|
+
["sender", request.senderId],
|
|
72
|
+
["idempotency key", idempotencyKey],
|
|
73
|
+
]);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const target = await resolveTarget({ client, projectId, flags, defaultHandle: config.agentHandle });
|
|
77
|
+
const request = {
|
|
78
|
+
spaceId: target.spaceId,
|
|
79
|
+
senderId: target.senderId,
|
|
80
|
+
...(message.parentMessageId ? { parentMessageId: message.parentMessageId } : {}),
|
|
81
|
+
content: message.content,
|
|
82
|
+
...(message.email ? { email: message.email } : {}),
|
|
83
|
+
};
|
|
84
|
+
const sent = await client.projects.sendMessage({
|
|
85
|
+
path: { id: projectId },
|
|
86
|
+
headers: { "idempotency-key": idempotencyKey },
|
|
87
|
+
body: request,
|
|
88
|
+
});
|
|
89
|
+
const sentRecord = sent;
|
|
90
|
+
out.data({
|
|
91
|
+
messageId: sentRecord.id,
|
|
92
|
+
status: sentRecord.status,
|
|
93
|
+
spaceId: request.spaceId,
|
|
94
|
+
senderId: request.senderId,
|
|
95
|
+
idempotencyKey,
|
|
96
|
+
content: request.content,
|
|
97
|
+
});
|
|
98
|
+
if (!flags.quiet) {
|
|
99
|
+
out.success(`sent ${sentRecord.id} (${sentRecord.status ?? "accepted"})`);
|
|
100
|
+
out.info(`space ${request.spaceId} · idempotency ${idempotencyKey}`);
|
|
101
|
+
out.info("acceptance is asynchronous; delivery is reported later on the message resource");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0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I,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,GAAG,CAAC,OAAO,CAAC,QAAQ,UAAU,CAAC,EAAE,KAAK,UAAU,CAAC,MAAM,IAAI,UAAU,GAAG,CAAC,CAAC;QAC1E,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,OAAO,kBAAkB,cAAc,EAAE,CAAC,CAAC;QACrE,GAAG,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `spaces` — conversations. `create` is idempotent: it reuses an exact match.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandContext } from "../types.js";
|
|
5
|
+
export declare const list: {
|
|
6
|
+
options: {
|
|
7
|
+
readonly platform: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly participant: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly "participant-handle": {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly order: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
};
|
|
19
|
+
readonly "order-by": {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
readonly "created-since": {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
};
|
|
25
|
+
readonly "created-before": {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
readonly "page-size": {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
};
|
|
31
|
+
readonly "page-token": {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
run({ client, projectId, flags, out }: CommandContext): Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
export declare const get: {
|
|
38
|
+
options: {};
|
|
39
|
+
run({ client, projectId, positionals, out }: CommandContext): Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export declare const create: {
|
|
42
|
+
options: {
|
|
43
|
+
readonly platform: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
};
|
|
46
|
+
readonly participant: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly multiple: true;
|
|
49
|
+
};
|
|
50
|
+
readonly "idempotency-key": {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
run({ client, projectId, flags, out, dryRun }: CommandContext): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=spaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../src/commands/spaces.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAa8B,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA2B5E,CAAC;AAEF,eAAO,MAAM,GAAG;;iDAGqC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBlF,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;mDAOoC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CpF,CAAC"}
|