@conto_finance/create-conto-agent 0.5.1 → 0.6.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 +11 -0
- package/README.md +12 -0
- package/dist/{chunk-TJJY5NFH.js → chunk-2M2WVAJI.js} +22 -0
- package/dist/{chunk-YWVIBVYN.js → chunk-QJIXCSI2.js} +1 -1
- package/dist/cli.js +68 -3
- package/dist/index.js +1 -1
- package/dist/lib/rule-values.d.ts +14 -1
- package/dist/lib/rule-values.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- `conto spending export` downloads the organization's spend as CSV, up to 20,000 rows, to stdout or
|
|
6
|
+
to a new private file with `--output`. It never overwrites a file. `--format json --limit 500`
|
|
7
|
+
returns one page and `nextCursor`, and `--cursor` with the same `--from` and `--to` gets the next.
|
|
8
|
+
It uses the configured organization API key, which needs `transactions:read`.
|
|
9
|
+
- `conto policies create` and `conto policies add-rule` save a budget cap as an amount and a period, such as
|
|
10
|
+
`{"amount":500,"period":"MONTHLY"}`. Earlier versions saved a bare number, which the server
|
|
11
|
+
cannot read as a budget, so the rule denied every payment its policy covered. The date range
|
|
12
|
+
example now starts today instead of showing a range that has already ended.
|
|
13
|
+
|
|
3
14
|
## 0.5.1
|
|
4
15
|
|
|
5
16
|
- `conto pay` no longer invites a second payment after a failed call. Every run sends an idempotency
|
package/README.md
CHANGED
|
@@ -116,6 +116,18 @@ new setup. Resources the old setup created stay in the organization.
|
|
|
116
116
|
| 3 | Partial setup, run the resume command |
|
|
117
117
|
| 4 | Reconciliation or owner action needed first, see the output |
|
|
118
118
|
|
|
119
|
+
## Accounting export
|
|
120
|
+
|
|
121
|
+
`conto spending export` downloads organization-wide accounting CSV using your configured
|
|
122
|
+
organization API key (`transactions:read`). Set the range with `--from` and `--to` ISO timestamps.
|
|
123
|
+
`--from` is included and `--to` is not. Use `--output spend.csv` to save a new private file without
|
|
124
|
+
overwriting an existing file. Without `--output`, the export goes to stdout.
|
|
125
|
+
|
|
126
|
+
`conto spending export --format json --limit 500` returns one page and `nextCursor`.
|
|
127
|
+
Pass `--cursor` with the same date bounds for the next page. CSV is limited to 20,000 rows and a
|
|
128
|
+
JSON page to 1,000. Categories are applied at export time. The nullable `receiptPath` links to an
|
|
129
|
+
authenticated Conto transaction receipt, not a merchant invoice.
|
|
130
|
+
|
|
119
131
|
## Documentation
|
|
120
132
|
|
|
121
133
|
- [CLI quickstart](https://conto.finance/docs/cli/quickstart)
|
|
@@ -30,6 +30,25 @@ function buildVelocityCountValue(input, period) {
|
|
|
30
30
|
}
|
|
31
31
|
return { ok: true, value: JSON.stringify({ maxCount: count, period: normalizedPeriod }) };
|
|
32
32
|
}
|
|
33
|
+
var BUDGET_PERIODS = ["DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY"];
|
|
34
|
+
function buildBudgetCapValue(input, period) {
|
|
35
|
+
const trimmed = input.trim();
|
|
36
|
+
const amount = Number(trimmed);
|
|
37
|
+
if (trimmed === "" || !Number.isFinite(amount) || amount <= 0) {
|
|
38
|
+
return { ok: false, error: "Budget amount must be a number greater than 0." };
|
|
39
|
+
}
|
|
40
|
+
const normalizedPeriod = period.toUpperCase();
|
|
41
|
+
if (!BUDGET_PERIODS.includes(normalizedPeriod)) {
|
|
42
|
+
return { ok: false, error: `Period must be one of ${BUDGET_PERIODS.join(", ")}.` };
|
|
43
|
+
}
|
|
44
|
+
return { ok: true, value: JSON.stringify({ amount, period: normalizedPeriod }) };
|
|
45
|
+
}
|
|
46
|
+
function dateRangePlaceholder(now = /* @__PURE__ */ new Date()) {
|
|
47
|
+
const start = now.toISOString().slice(0, 10);
|
|
48
|
+
const end = new Date(now);
|
|
49
|
+
end.setUTCFullYear(end.getUTCFullYear() + 1);
|
|
50
|
+
return JSON.stringify({ start, end: end.toISOString().slice(0, 10) });
|
|
51
|
+
}
|
|
33
52
|
var EVM_ADDRESS = /^0x[a-fA-F0-9]{40}$/;
|
|
34
53
|
var SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
35
54
|
var MAX_PAYMENT_AMOUNT = 1e9;
|
|
@@ -72,5 +91,8 @@ export {
|
|
|
72
91
|
parseTrustScoreInput,
|
|
73
92
|
VELOCITY_PERIODS,
|
|
74
93
|
buildVelocityCountValue,
|
|
94
|
+
BUDGET_PERIODS,
|
|
95
|
+
buildBudgetCapValue,
|
|
96
|
+
dateRangePlaceholder,
|
|
75
97
|
validatePaymentRequest
|
|
76
98
|
};
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
// package.json
|
|
22
22
|
var package_default = {
|
|
23
23
|
name: "@conto_finance/create-conto-agent",
|
|
24
|
-
version: "0.
|
|
24
|
+
version: "0.6.0",
|
|
25
25
|
description: "Set up an AI agent with Conto spending controls",
|
|
26
26
|
bin: {
|
|
27
27
|
"create-conto-agent": "bin/create-conto-agent.js",
|
package/dist/cli.js
CHANGED
|
@@ -27,13 +27,16 @@ import {
|
|
|
27
27
|
retryAfterSeconds,
|
|
28
28
|
runInit,
|
|
29
29
|
writeProjectStateFile
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-QJIXCSI2.js";
|
|
31
31
|
import {
|
|
32
|
+
BUDGET_PERIODS,
|
|
32
33
|
VELOCITY_PERIODS,
|
|
34
|
+
buildBudgetCapValue,
|
|
33
35
|
buildVelocityCountValue,
|
|
36
|
+
dateRangePlaceholder,
|
|
34
37
|
parseTrustScoreInput,
|
|
35
38
|
validatePaymentRequest
|
|
36
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-2M2WVAJI.js";
|
|
37
40
|
import {
|
|
38
41
|
SANDBOX_SETUP_ENV_FILE,
|
|
39
42
|
isSensitiveConfigKey,
|
|
@@ -102,6 +105,38 @@ async function run(work, owner = false) {
|
|
|
102
105
|
}
|
|
103
106
|
var id = encodeURIComponent;
|
|
104
107
|
function registerSpendingCommands(program2) {
|
|
108
|
+
program2.command("spending").description("Organization accounting exports").command("export").description(
|
|
109
|
+
"Export cross-rail spend with categories and GL accounts (organization key required)"
|
|
110
|
+
).option("--from <timestamp>", "Inclusive ISO timestamp").option("--to <timestamp>", "Exclusive ISO timestamp").option("--format <format>", "csv or json (JSON returns one page)").option("--limit <count>", "JSON page size, at most 1000").option("--cursor <cursor>", "JSON nextCursor from the previous page").option("--output <file>", "Save to a new file; refuse to overwrite").action(async (o) => {
|
|
111
|
+
try {
|
|
112
|
+
const config = loadConfig();
|
|
113
|
+
if (!config.orgApiKey)
|
|
114
|
+
throw new Error("An organization key is required for accounting exports.");
|
|
115
|
+
const format = o.format ?? (isJsonMode() ? "json" : "csv");
|
|
116
|
+
if (!["csv", "json"].includes(format)) throw new Error("Format must be csv or json.");
|
|
117
|
+
if (format === "csv" && (o.cursor || o.limit))
|
|
118
|
+
throw new Error("Cursor and limit require JSON format.");
|
|
119
|
+
const query = new URLSearchParams({ format });
|
|
120
|
+
for (const key of ["from", "to", "limit", "cursor"])
|
|
121
|
+
if (o[key] !== void 0) query.set(key, o[key]);
|
|
122
|
+
const api = createApiClient(config);
|
|
123
|
+
const data = format === "csv" ? await api.spendingDownload(`export?${query}`, true) : JSON.stringify(
|
|
124
|
+
await api.spending("GET", `export?${query}`, void 0, true),
|
|
125
|
+
null,
|
|
126
|
+
2
|
|
127
|
+
) + "\n";
|
|
128
|
+
if (o.output) {
|
|
129
|
+
await writeFile(o.output, data, { flag: "wx", mode: 384 });
|
|
130
|
+
if (isJsonMode()) printJson({ savedTo: o.output });
|
|
131
|
+
else printKeyValue("Saved", o.output);
|
|
132
|
+
} else process.stdout.write(data);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const message = error instanceof Error ? error.message : "Export failed";
|
|
135
|
+
if (isJsonMode()) printJson({ error: message });
|
|
136
|
+
else printError(message);
|
|
137
|
+
process.exitCode = 1;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
105
140
|
const budgets = program2.command("budgets").description("Shared budget availability and owner controls");
|
|
106
141
|
budgets.command("list").option("--owner", "Use organization credentials").action((o) => run((api) => api.spending("GET", "budgets", void 0, o.owner), o.owner));
|
|
107
142
|
budgets.command("create <file>").description("Owner: create a budget from a JSON definition").action(
|
|
@@ -2300,6 +2335,36 @@ async function promptForRule(policyType) {
|
|
|
2300
2335
|
action: action2
|
|
2301
2336
|
};
|
|
2302
2337
|
}
|
|
2338
|
+
if (ruleStr === "BUDGET_CAP") {
|
|
2339
|
+
const period = await p.select({
|
|
2340
|
+
message: "Budget period",
|
|
2341
|
+
options: BUDGET_PERIODS.map((value2) => ({ value: value2, label: value2.toLowerCase() })),
|
|
2342
|
+
initialValue: "MONTHLY"
|
|
2343
|
+
});
|
|
2344
|
+
if (p.isCancel(period)) return null;
|
|
2345
|
+
const amount = await p.text({
|
|
2346
|
+
message: "Budget amount in dollars",
|
|
2347
|
+
placeholder: "500",
|
|
2348
|
+
validate: (v) => {
|
|
2349
|
+
const result = buildBudgetCapValue(v ?? "", period);
|
|
2350
|
+
return result.ok ? void 0 : result.error;
|
|
2351
|
+
}
|
|
2352
|
+
});
|
|
2353
|
+
if (p.isCancel(amount)) return null;
|
|
2354
|
+
const built = buildBudgetCapValue(amount, period);
|
|
2355
|
+
if (!built.ok) return null;
|
|
2356
|
+
const action2 = await p.select({
|
|
2357
|
+
message: "Action when rule triggers",
|
|
2358
|
+
options: ACTIONS
|
|
2359
|
+
});
|
|
2360
|
+
if (p.isCancel(action2)) return null;
|
|
2361
|
+
return {
|
|
2362
|
+
ruleType: ruleStr,
|
|
2363
|
+
operator,
|
|
2364
|
+
value: built.value,
|
|
2365
|
+
action: action2
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2303
2368
|
let placeholder = "500";
|
|
2304
2369
|
let valueHint = "Enter a number for limits, or JSON for lists";
|
|
2305
2370
|
if (ruleStr.includes("LIMIT") || ruleStr.includes("AMOUNT") || ruleStr.includes("CAP") || ruleStr === "REQUIRE_APPROVAL_ABOVE") {
|
|
@@ -2315,7 +2380,7 @@ async function promptForRule(policyType) {
|
|
|
2315
2380
|
placeholder = '["US","GB","DE"]';
|
|
2316
2381
|
valueHint = "JSON array of country codes";
|
|
2317
2382
|
} else if (ruleStr === "DATE_RANGE") {
|
|
2318
|
-
placeholder =
|
|
2383
|
+
placeholder = dateRangePlaceholder();
|
|
2319
2384
|
valueHint = "JSON with start and end dates (ISO format)";
|
|
2320
2385
|
}
|
|
2321
2386
|
const value = await p.text({
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,19 @@ type VelocityPeriod = (typeof VELOCITY_PERIODS)[number];
|
|
|
23
23
|
* {"maxCount": n, "period": "HOUR" | "DAY" | "WEEK" | "MONTH"}.
|
|
24
24
|
*/
|
|
25
25
|
declare function buildVelocityCountValue(input: string, period: string): ValidationResult;
|
|
26
|
+
declare const BUDGET_PERIODS: readonly ["DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY"];
|
|
27
|
+
/**
|
|
28
|
+
* BUDGET_CAP rules are read by the server as {"amount": n, "period": ...}. A
|
|
29
|
+
* bare number has no amount the server can read, so it denies every payment
|
|
30
|
+
* the policy covers.
|
|
31
|
+
*/
|
|
32
|
+
declare function buildBudgetCapValue(input: string, period: string): ValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* An example DATE_RANGE value that is current when the prompt shows it: from
|
|
35
|
+
* today for one year. A fixed example goes out of date and saves a range that
|
|
36
|
+
* has already ended.
|
|
37
|
+
*/
|
|
38
|
+
declare function dateRangePlaceholder(now?: Date): string;
|
|
26
39
|
interface PaymentRequestBody {
|
|
27
40
|
amount: number;
|
|
28
41
|
recipientAddress: string;
|
|
@@ -49,5 +62,5 @@ declare function validatePaymentRequest(input: {
|
|
|
49
62
|
walletId?: string;
|
|
50
63
|
}): PaymentValidation;
|
|
51
64
|
|
|
52
|
-
export { VELOCITY_PERIODS, buildVelocityCountValue, parseTrustScoreInput, validatePaymentRequest };
|
|
65
|
+
export { BUDGET_PERIODS, VELOCITY_PERIODS, buildBudgetCapValue, buildVelocityCountValue, dateRangePlaceholder, parseTrustScoreInput, validatePaymentRequest };
|
|
53
66
|
export type { PaymentRequestBody, PaymentValidation, ValidationResult, VelocityPeriod };
|
package/dist/lib/rule-values.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BUDGET_PERIODS,
|
|
2
3
|
VELOCITY_PERIODS,
|
|
4
|
+
buildBudgetCapValue,
|
|
3
5
|
buildVelocityCountValue,
|
|
6
|
+
dateRangePlaceholder,
|
|
4
7
|
parseTrustScoreInput,
|
|
5
8
|
validatePaymentRequest
|
|
6
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-2M2WVAJI.js";
|
|
7
10
|
export {
|
|
11
|
+
BUDGET_PERIODS,
|
|
8
12
|
VELOCITY_PERIODS,
|
|
13
|
+
buildBudgetCapValue,
|
|
9
14
|
buildVelocityCountValue,
|
|
15
|
+
dateRangePlaceholder,
|
|
10
16
|
parseTrustScoreInput,
|
|
11
17
|
validatePaymentRequest
|
|
12
18
|
};
|