@conto_finance/create-conto-agent 0.10.0 → 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 +16 -0
- package/README.md +7 -0
- package/dist/{chunk-ALQ6UCGI.js → chunk-6SFX4NZF.js} +34 -16
- package/dist/{chunk-D6JPJHU4.js → chunk-JWTKJEM4.js} +1 -0
- package/dist/cli.js +109 -60
- package/dist/index.js +2 -2
- package/dist/lib/cli-commands.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
10
|
+
## 0.10.1
|
|
11
|
+
|
|
12
|
+
- `--connect` includes the custom server URL in resume commands. Resuming on a different server
|
|
13
|
+
preserves the original approval request.
|
|
14
|
+
- Resuming an expired request clears it and exits 1 with `EXPIRED`. Run `--connect` again for a
|
|
15
|
+
fresh approval link.
|
|
16
|
+
- Pending JSON reports `sandboxPolicyCopyRequested` when sandbox policies were requested for
|
|
17
|
+
copying. `sandboxPoliciesCopied` stays false while approval is pending.
|
|
18
|
+
|
|
3
19
|
## 0.10.0
|
|
4
20
|
|
|
5
21
|
- `create-conto-agent --connect` sets an agent up in a person's real Conto account without a
|
package/README.md
CHANGED
|
@@ -81,6 +81,13 @@ the sandbox's policies. Exit codes: 0 approved or the link is out, 1 failed or e
|
|
|
81
81
|
or refused, 4 still waiting. See
|
|
82
82
|
[connect to a person's account](https://conto.finance/docs/cli/commands#connect-to-a-persons-account).
|
|
83
83
|
|
|
84
|
+
If you use a custom server, the printed resume command includes its `--base-url`. A server mismatch
|
|
85
|
+
keeps the pending request available. Use `--restart` to replace it explicitly. Resuming an expired
|
|
86
|
+
request clears it and exits 1. Run `--connect` again to request a fresh approval.
|
|
87
|
+
|
|
88
|
+
In pending JSON, `sandboxPolicyCopyRequested` tells you whether the request includes sandbox
|
|
89
|
+
policies to copy on approval. `sandboxPoliciesCopied` stays false while approval is pending.
|
|
90
|
+
|
|
84
91
|
## Hand a sandbox to its owner
|
|
85
92
|
|
|
86
93
|
```bash
|
|
@@ -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.
|
|
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" });
|
|
@@ -3895,8 +3903,16 @@ function printRequest(request, reused) {
|
|
|
3895
3903
|
printInfo("Approving also copies this project's sandbox policies to the new agent.");
|
|
3896
3904
|
}
|
|
3897
3905
|
}
|
|
3898
|
-
function
|
|
3899
|
-
|
|
3906
|
+
function connectCommand(baseUrl) {
|
|
3907
|
+
const command = `${FULL_CLI2} --connect`;
|
|
3908
|
+
if (baseUrl === DEFAULT_BASE_URL2) return command;
|
|
3909
|
+
return `${command} --base-url '${baseUrl.replaceAll("'", "'\\''")}'`;
|
|
3910
|
+
}
|
|
3911
|
+
function expiredRequest(cwd, request) {
|
|
3912
|
+
removeSavedRequest(cwd);
|
|
3913
|
+
throw new ConnectStop(CONNECT_EXIT_CODES.failed, "EXPIRED", "The setup request expired.", {
|
|
3914
|
+
nextStep: `Start a new one: ${connectCommand(request.baseUrl)}${request.emailed ? " --email <their email>" : ""}`
|
|
3915
|
+
});
|
|
3900
3916
|
}
|
|
3901
3917
|
async function runConnect(options = {}) {
|
|
3902
3918
|
try {
|
|
@@ -3947,12 +3963,16 @@ async function connect(options) {
|
|
|
3947
3963
|
let reused = false;
|
|
3948
3964
|
const saved = loadSavedRequest(cwd);
|
|
3949
3965
|
if (saved && !options.restart) {
|
|
3950
|
-
if (saved.baseUrl
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3966
|
+
if (saved.baseUrl !== baseUrl) {
|
|
3967
|
+
throw new ConnectStop(
|
|
3968
|
+
CONNECT_EXIT_CODES.refused,
|
|
3969
|
+
"SERVER_MISMATCH",
|
|
3970
|
+
"This project has a setup request for another server. Repeat the original --base-url to resume it, or use --restart to start over on this server."
|
|
3971
|
+
);
|
|
3955
3972
|
}
|
|
3973
|
+
if (isExpired(saved)) expiredRequest(cwd, saved);
|
|
3974
|
+
request = saved;
|
|
3975
|
+
reused = true;
|
|
3956
3976
|
} else if (saved) {
|
|
3957
3977
|
removeSavedRequest(cwd);
|
|
3958
3978
|
}
|
|
@@ -3995,16 +4015,17 @@ async function connect(options) {
|
|
|
3995
4015
|
expiresAt: request.expiresAt,
|
|
3996
4016
|
emailed: request.emailed,
|
|
3997
4017
|
...request.emailFailed ? { emailFailed: true } : {},
|
|
3998
|
-
sandboxPoliciesCopied:
|
|
4018
|
+
sandboxPoliciesCopied: false,
|
|
4019
|
+
sandboxPolicyCopyRequested: request.sandboxRules,
|
|
3999
4020
|
savedIn: SETUP_REQUEST_FILE,
|
|
4000
4021
|
...reused ? { reused: true } : {},
|
|
4001
4022
|
tellThePerson: request.emailed ? `Conto emailed you a link. Check that it shows the code ${request.userCode}, then approve.` : `Open ${request.link}, check that it shows the code ${request.userCode}, then approve.`,
|
|
4002
|
-
nextSteps:
|
|
4023
|
+
nextSteps: [`${connectCommand(baseUrl)} --wait --json`]
|
|
4003
4024
|
});
|
|
4004
4025
|
} else {
|
|
4005
4026
|
printRequest(request, reused);
|
|
4006
4027
|
console.log("");
|
|
4007
|
-
console.log(` Then run: ${chalk3.cyan(`${
|
|
4028
|
+
console.log(` Then run: ${chalk3.cyan(`${connectCommand(baseUrl)} --wait`)}`);
|
|
4008
4029
|
console.log("");
|
|
4009
4030
|
}
|
|
4010
4031
|
return;
|
|
@@ -4035,10 +4056,7 @@ async function connect(options) {
|
|
|
4035
4056
|
);
|
|
4036
4057
|
}
|
|
4037
4058
|
if (result.status === "expired") {
|
|
4038
|
-
|
|
4039
|
-
throw new ConnectStop(CONNECT_EXIT_CODES.failed, "EXPIRED", "The setup request expired.", {
|
|
4040
|
-
nextStep: `Start a new one: ${FULL_CLI2} --connect${request.emailed ? " --email <their email>" : ""}`
|
|
4041
|
-
});
|
|
4059
|
+
expiredRequest(cwd, request);
|
|
4042
4060
|
}
|
|
4043
4061
|
if (result.status === "delivered") {
|
|
4044
4062
|
removeSavedRequest(cwd);
|
|
@@ -4063,7 +4081,7 @@ async function connect(options) {
|
|
|
4063
4081
|
link: request.link,
|
|
4064
4082
|
userCode: request.userCode,
|
|
4065
4083
|
expiresAt: request.expiresAt,
|
|
4066
|
-
nextStep: `Run it again to keep waiting: ${
|
|
4084
|
+
nextStep: `Run it again to keep waiting: ${connectCommand(baseUrl)} --wait`
|
|
4067
4085
|
}
|
|
4068
4086
|
);
|
|
4069
4087
|
}
|
package/dist/cli.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
runConnect,
|
|
30
30
|
runInit,
|
|
31
31
|
writeProjectStateFile
|
|
32
|
-
} from "./chunk-
|
|
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/
|
|
71
|
-
import
|
|
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
package/dist/lib/cli-commands.js
CHANGED