@conto_finance/create-conto-agent 0.10.1 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ - `conto inbox list` lists pending requests visible to the current credential.
6
+ `conto inbox show <id>` displays one request and its review URL. Add `--open` to
7
+ open the review page in your browser. Both commands are read-only and support
8
+ `--json` and `--owner`.
9
+
3
10
  ## 0.10.1
4
11
 
5
12
  - `--connect` includes the custom server URL in resume commands. Resuming on a different server
@@ -22,7 +22,7 @@ import {
22
22
  // package.json
23
23
  var package_default = {
24
24
  name: "@conto_finance/create-conto-agent",
25
- version: "0.10.1",
25
+ version: "0.11.0",
26
26
  description: "Set up an AI agent with Conto spending controls",
27
27
  bin: {
28
28
  "create-conto-agent": "bin/create-conto-agent.js",
@@ -1054,6 +1054,14 @@ function createApiClient(options) {
1054
1054
  // src/lib/owner-client.ts
1055
1055
  var enc = encodeURIComponent;
1056
1056
  var OwnerApiClient = class extends ApiClient {
1057
+ pendingInbox(auth, query) {
1058
+ const path4 = auth === "org" ? "/api/inbox" : "/api/sdk/inbox";
1059
+ return this.request(
1060
+ "GET",
1061
+ `${path4}?${query}`,
1062
+ { auth }
1063
+ );
1064
+ }
1057
1065
  // ── Teams ──
1058
1066
  listTeams() {
1059
1067
  return this.request("GET", "/api/teams", { auth: "org" });
@@ -17,6 +17,7 @@ var CLI_COMMANDS = /* @__PURE__ */ new Set([
17
17
  "policies",
18
18
  "limits",
19
19
  "alerts",
20
+ "inbox",
20
21
  "config",
21
22
  "login",
22
23
  "logout",
package/dist/cli.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  runConnect,
30
30
  runInit,
31
31
  writeProjectStateFile
32
- } from "./chunk-K5KWPN2D.js";
32
+ } from "./chunk-6SFX4NZF.js";
33
33
  import {
34
34
  BUDGET_PERIODS,
35
35
  VELOCITY_PERIODS,
@@ -67,9 +67,8 @@ import {
67
67
  truncateAddress
68
68
  } from "./chunk-DT5NOLBD.js";
69
69
 
70
- // src/commands/spending.ts
71
- import { readFile, writeFile } from "fs/promises";
72
- import { basename, extname } from "path";
70
+ // src/lib/owner-command.ts
71
+ import chalk from "chalk";
73
72
 
74
73
  // src/lib/org-key.ts
75
74
  var OrgKeyError = class extends Error {
@@ -164,7 +163,112 @@ async function confirmSameOrganization(baseUrl, apiKey, saved) {
164
163
  );
165
164
  }
166
165
 
166
+ // src/lib/owner-command.ts
167
+ var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
168
+ async function runOwnerCommand(needs, fn) {
169
+ const config = loadConfig();
170
+ if (needs === "org" && !hasOrgApiKey(config)) {
171
+ fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
172
+ return;
173
+ }
174
+ if (needs === "sdk" && !config.apiKey) {
175
+ fail(
176
+ 'Not configured. Run "npx @conto_finance/create-conto-agent" or "conto login" first.',
177
+ "SDK_KEY_REQUIRED"
178
+ );
179
+ return;
180
+ }
181
+ const api = createOwnerClient({
182
+ baseUrl: config.baseUrl,
183
+ apiKey: config.apiKey,
184
+ orgApiKey: orgApiKeySource(config)
185
+ });
186
+ try {
187
+ if (needs === "org") await resolveOrgApiKey(config);
188
+ await fn({ api, config });
189
+ } catch (err) {
190
+ const error = err;
191
+ if (error.status === 401) {
192
+ fail(`${error.message}. ${LOGIN_HINT}`, error.code ?? "AUTH_FAILED");
193
+ return;
194
+ }
195
+ fail(error.message || "Request failed", error.code, error.recovery);
196
+ }
197
+ }
198
+ function fail(message, code, recovery) {
199
+ process.exitCode = 1;
200
+ if (isJsonMode()) {
201
+ printJson({
202
+ ok: false,
203
+ error: message,
204
+ ...code ? { code } : {},
205
+ ...recovery ? { recovery } : {}
206
+ });
207
+ return;
208
+ }
209
+ printError(message);
210
+ if (recovery) console.log(chalk.dim(` ${recovery}`));
211
+ }
212
+ function parseUsd(value, flag) {
213
+ if (value === void 0) return void 0;
214
+ const amount = Number(value);
215
+ if (!Number.isFinite(amount) || amount < 0) {
216
+ throw new Error(`${flag} takes an amount in USD, for example 250`);
217
+ }
218
+ return amount;
219
+ }
220
+
221
+ // src/commands/inbox.ts
222
+ async function readInbox(id2, options) {
223
+ const auth = options.owner || !loadConfig().apiKey ? "org" : "sdk";
224
+ await runOwnerCommand(auth, async ({ api, config }) => {
225
+ const query = new URLSearchParams();
226
+ if (id2 !== void 0) query.set("id", id2);
227
+ if (options.after !== void 0) query.set("after", options.after);
228
+ if (options.limit !== void 0) query.set("limit", options.limit);
229
+ const page = await api.pendingInbox(auth, query);
230
+ const items = page.items.map(({ reviewPath, ...item }) => {
231
+ const base = parseSecureBaseUrl(config.baseUrl);
232
+ if (!reviewPath.startsWith("/") || reviewPath.startsWith("//") || reviewPath.includes("\\")) {
233
+ throw new Error("Invalid inbox review path");
234
+ }
235
+ const reviewUrl = apiUrl(base.href, reviewPath);
236
+ if (reviewUrl.origin !== base.origin) throw new Error("Invalid inbox review origin");
237
+ return { ...item, reviewUrl: reviewUrl.href };
238
+ });
239
+ if (id2 !== void 0 && (items.length !== 1 || items[0].id !== id2))
240
+ throw new Error("Pending inbox item not found");
241
+ if (isJsonMode())
242
+ printJson(id2 === void 0 ? { items, nextCursor: page.nextCursor } : items[0]);
243
+ else {
244
+ if (!items.length) console.log("No pending requests.");
245
+ for (const item of items) {
246
+ console.log(`
247
+ ${item.id} ${item.title}`);
248
+ printKeyValue("Type", item.kind);
249
+ printKeyValue("Details", item.details.join(" \xB7 "));
250
+ printKeyValue("Requested", item.createdAt);
251
+ if (item.expiresAt) printKeyValue("Expires", item.expiresAt);
252
+ if (item.approvalProgress) printKeyValue("Approvals", item.approvalProgress);
253
+ printKeyValue("Review", item.reviewUrl);
254
+ }
255
+ if (page.nextCursor) printKeyValue("Next page (--after)", page.nextCursor);
256
+ }
257
+ if (options.open && id2 !== void 0) {
258
+ const { default: open } = await import("open");
259
+ await open(items[0].reviewUrl);
260
+ }
261
+ });
262
+ }
263
+ function registerInboxCommands(program2) {
264
+ const inbox = program2.command("inbox").description("Inspect pending requests and their review links");
265
+ inbox.command("list").description("List pending requests visible to this credential").option("--owner", "Use organization credentials").option("--limit <count>", "Page size (1\u2013100, default 50)").option("--after <cursor>", "Continue after the previous page").action((options) => readInbox(void 0, options));
266
+ inbox.command("show <id>").description("Inspect one pending request").option("--owner", "Use organization credentials").option("--open", "Open the review page in your browser").action(readInbox);
267
+ }
268
+
167
269
  // src/commands/spending.ts
270
+ import { readFile, writeFile } from "fs/promises";
271
+ import { basename, extname } from "path";
168
272
  async function run(work, owner = false) {
169
273
  try {
170
274
  const config = loadConfig();
@@ -403,62 +507,6 @@ function registerSpendingCommands(program2) {
403
507
  );
404
508
  }
405
509
 
406
- // src/lib/owner-command.ts
407
- import chalk from "chalk";
408
- var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
409
- async function runOwnerCommand(needs, fn) {
410
- const config = loadConfig();
411
- if (needs === "org" && !hasOrgApiKey(config)) {
412
- fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
413
- return;
414
- }
415
- if (needs === "sdk" && !config.apiKey) {
416
- fail(
417
- 'Not configured. Run "npx @conto_finance/create-conto-agent" or "conto login" first.',
418
- "SDK_KEY_REQUIRED"
419
- );
420
- return;
421
- }
422
- const api = createOwnerClient({
423
- baseUrl: config.baseUrl,
424
- apiKey: config.apiKey,
425
- orgApiKey: orgApiKeySource(config)
426
- });
427
- try {
428
- if (needs === "org") await resolveOrgApiKey(config);
429
- await fn({ api, config });
430
- } catch (err) {
431
- const error = err;
432
- if (error.status === 401) {
433
- fail(`${error.message}. ${LOGIN_HINT}`, error.code ?? "AUTH_FAILED");
434
- return;
435
- }
436
- fail(error.message || "Request failed", error.code, error.recovery);
437
- }
438
- }
439
- function fail(message, code, recovery) {
440
- process.exitCode = 1;
441
- if (isJsonMode()) {
442
- printJson({
443
- ok: false,
444
- error: message,
445
- ...code ? { code } : {},
446
- ...recovery ? { recovery } : {}
447
- });
448
- return;
449
- }
450
- printError(message);
451
- if (recovery) console.log(chalk.dim(` ${recovery}`));
452
- }
453
- function parseUsd(value, flag) {
454
- if (value === void 0) return void 0;
455
- const amount = Number(value);
456
- if (!Number.isFinite(amount) || amount < 0) {
457
- throw new Error(`${flag} takes an amount in USD, for example 250`);
458
- }
459
- return amount;
460
- }
461
-
462
510
  // src/commands/teams.ts
463
511
  function change(api, direct, action, input, options) {
464
512
  return directOrReview(api, direct, async () => ({ action, input }), options);
@@ -4949,5 +4997,6 @@ program.command("docs [topic]").description("Open Conto documentation (cli, poli
4949
4997
  printInfo2(`Opening ${url}`);
4950
4998
  open(url);
4951
4999
  });
5000
+ registerInboxCommands(program);
4952
5001
  registerSpendingCommands(program);
4953
5002
  program.parse();
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runConnect,
3
3
  runInit
4
- } from "./chunk-K5KWPN2D.js";
4
+ } from "./chunk-6SFX4NZF.js";
5
5
  import {
6
6
  delegatesToCli
7
- } from "./chunk-D6JPJHU4.js";
7
+ } from "./chunk-JWTKJEM4.js";
8
8
  import "./chunk-F72EK2TO.js";
9
9
  import {
10
10
  isJsonMode,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CLI_COMMANDS,
3
3
  delegatesToCli
4
- } from "../chunk-D6JPJHU4.js";
4
+ } from "../chunk-JWTKJEM4.js";
5
5
  export {
6
6
  CLI_COMMANDS,
7
7
  delegatesToCli
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Set up an AI agent with Conto spending controls",
5
5
  "bin": {
6
6
  "create-conto-agent": "bin/create-conto-agent.js",