@trusty-squire/mcp 1.1.13-rc.9 → 1.1.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.
- package/README.md +136 -64
- package/assets/login/vnc-input.js +9 -0
- package/assets/login/vnc.html +214 -202
- package/assets/screencaps/connect-walkthrough.png +0 -0
- package/assets/screencaps/connect-walkthrough.svg +1 -1
- package/dist/api-client.d.ts +26 -3
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +19 -31
- package/dist/api-client.js.map +1 -1
- package/dist/bin.js +2 -3
- package/dist/bin.js.map +1 -1
- package/dist/bot/browser.d.ts +85 -80
- package/dist/bot/browser.d.ts.map +1 -1
- package/dist/bot/browser.js +1314 -1570
- package/dist/bot/browser.js.map +1 -1
- package/dist/bot/compact-observation-v2.d.ts +167 -0
- package/dist/bot/compact-observation-v2.d.ts.map +1 -0
- package/dist/bot/compact-observation-v2.js +1038 -0
- package/dist/bot/compact-observation-v2.js.map +1 -0
- package/dist/bot/credential-shape.d.ts +2 -0
- package/dist/bot/credential-shape.d.ts.map +1 -1
- package/dist/bot/credential-shape.js +21 -8
- package/dist/bot/credential-shape.js.map +1 -1
- package/dist/bot/element-fingerprint.d.ts +9 -0
- package/dist/bot/element-fingerprint.d.ts.map +1 -0
- package/dist/bot/element-fingerprint.js +147 -0
- package/dist/bot/element-fingerprint.js.map +1 -0
- package/dist/bot/email-verification.d.ts +7 -1
- package/dist/bot/email-verification.d.ts.map +1 -1
- package/dist/bot/email-verification.js +48 -14
- package/dist/bot/email-verification.js.map +1 -1
- package/dist/bot/google-login.d.ts +28 -52
- package/dist/bot/google-login.d.ts.map +1 -1
- package/dist/bot/google-login.js +246 -1119
- package/dist/bot/google-login.js.map +1 -1
- package/dist/bot/install-completion.d.ts +1 -2
- package/dist/bot/install-completion.d.ts.map +1 -1
- package/dist/bot/install-completion.js +1 -2
- package/dist/bot/install-completion.js.map +1 -1
- package/dist/bot/login-state.d.ts +13 -7
- package/dist/bot/login-state.d.ts.map +1 -1
- package/dist/bot/login-state.js +50 -114
- package/dist/bot/login-state.js.map +1 -1
- package/dist/bot/oauth-providers.d.ts +1 -1
- package/dist/bot/oauth-providers.d.ts.map +1 -1
- package/dist/bot/oauth-providers.js +3 -3
- package/dist/bot/oauth-providers.js.map +1 -1
- package/dist/bot/oauth-scope.d.ts +4 -0
- package/dist/bot/oauth-scope.d.ts.map +1 -0
- package/dist/bot/oauth-scope.js +58 -0
- package/dist/bot/oauth-scope.js.map +1 -0
- package/dist/bot/operator-browser-watchdog.d.ts +18 -6
- package/dist/bot/operator-browser-watchdog.d.ts.map +1 -1
- package/dist/bot/operator-browser-watchdog.js +91 -37
- package/dist/bot/operator-browser-watchdog.js.map +1 -1
- package/dist/bot/owner-process-reaper-worker.d.ts +2 -0
- package/dist/bot/owner-process-reaper-worker.d.ts.map +1 -0
- package/dist/bot/owner-process-reaper-worker.js +17 -0
- package/dist/bot/owner-process-reaper-worker.js.map +1 -0
- package/dist/bot/owner-process-reaper.d.ts +103 -0
- package/dist/bot/owner-process-reaper.d.ts.map +1 -0
- package/dist/bot/owner-process-reaper.js +1058 -0
- package/dist/bot/owner-process-reaper.js.map +1 -0
- package/dist/bot/pay-operator.d.ts +7 -1
- package/dist/bot/pay-operator.d.ts.map +1 -1
- package/dist/bot/pay-operator.js +269 -103
- package/dist/bot/pay-operator.js.map +1 -1
- package/dist/bot/profile.d.ts +10 -1
- package/dist/bot/profile.d.ts.map +1 -1
- package/dist/bot/profile.js +137 -11
- package/dist/bot/profile.js.map +1 -1
- package/dist/bot/promote-to-skill.js +1 -1
- package/dist/bot/promote-to-skill.js.map +1 -1
- package/dist/bot/provision-session.d.ts +57 -186
- package/dist/bot/provision-session.d.ts.map +1 -1
- package/dist/bot/provision-session.js +1976 -1812
- package/dist/bot/provision-session.js.map +1 -1
- package/dist/bot/remote-login-display.d.ts +61 -0
- package/dist/bot/remote-login-display.d.ts.map +1 -0
- package/dist/bot/remote-login-display.js +765 -0
- package/dist/bot/remote-login-display.js.map +1 -0
- package/dist/bot/session/hosts.d.ts +8 -0
- package/dist/bot/session/hosts.d.ts.map +1 -0
- package/dist/bot/session/hosts.js +36 -0
- package/dist/bot/session/hosts.js.map +1 -0
- package/dist/bot/session/lifecycle.d.ts +56 -0
- package/dist/bot/session/lifecycle.d.ts.map +1 -0
- package/dist/bot/session/lifecycle.js +962 -0
- package/dist/bot/session/lifecycle.js.map +1 -0
- package/dist/bot/session/model.d.ts +175 -0
- package/dist/bot/session/model.d.ts.map +1 -0
- package/dist/bot/session/model.js +77 -0
- package/dist/bot/session/model.js.map +1 -0
- package/dist/install/cli.d.ts +29 -9
- package/dist/install/cli.d.ts.map +1 -1
- package/dist/install/cli.js +243 -322
- package/dist/install/cli.js.map +1 -1
- package/dist/install/interactive.d.ts +1 -0
- package/dist/install/interactive.d.ts.map +1 -1
- package/dist/install/interactive.js +19 -5
- package/dist/install/interactive.js.map +1 -1
- package/dist/install/ui.d.ts.map +1 -1
- package/dist/install/ui.js +3 -15
- package/dist/install/ui.js.map +1 -1
- package/dist/operator-env.js +1 -1
- package/dist/operator-env.js.map +1 -1
- package/dist/server-instance-registry.d.ts +103 -0
- package/dist/server-instance-registry.d.ts.map +1 -0
- package/dist/server-instance-registry.js +392 -0
- package/dist/server-instance-registry.js.map +1 -0
- package/dist/server.d.ts +15 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +164 -62
- package/dist/server.js.map +1 -1
- package/dist/session-guard.d.ts +28 -0
- package/dist/session-guard.d.ts.map +1 -0
- package/dist/session-guard.js +84 -0
- package/dist/session-guard.js.map +1 -0
- package/dist/session.d.ts +57 -13
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +246 -127
- package/dist/session.js.map +1 -1
- package/dist/tools/audit-log.d.ts +16 -2
- package/dist/tools/audit-log.d.ts.map +1 -1
- package/dist/tools/audit-log.js +223 -13
- package/dist/tools/audit-log.js.map +1 -1
- package/dist/tools/audit-rollup.d.ts +80 -0
- package/dist/tools/audit-rollup.d.ts.map +1 -0
- package/dist/tools/audit-rollup.js +0 -0
- package/dist/tools/audit-rollup.js.map +1 -0
- package/dist/tools/fetch-credential.d.ts +37 -0
- package/dist/tools/fetch-credential.d.ts.map +1 -0
- package/dist/tools/fetch-credential.js +153 -0
- package/dist/tools/fetch-credential.js.map +1 -0
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/operate-pay.d.ts +4 -4
- package/dist/tools/operate-pay.d.ts.map +1 -1
- package/dist/tools/operate-pay.js +151 -96
- package/dist/tools/operate-pay.js.map +1 -1
- package/dist/tools/provision-drive.d.ts +47 -39
- package/dist/tools/provision-drive.d.ts.map +1 -1
- package/dist/tools/provision-drive.js +268 -164
- package/dist/tools/provision-drive.js.map +1 -1
- package/dist/tools/use-credential.d.ts.map +1 -1
- package/dist/tools/use-credential.js +3 -2
- package/dist/tools/use-credential.js.map +1 -1
- package/package.json +4 -6
- package/dist/bot/operator-direct-identity.d.ts +0 -26
- package/dist/bot/operator-direct-identity.d.ts.map +0 -1
- package/dist/bot/operator-direct-identity.js +0 -120
- package/dist/bot/operator-direct-identity.js.map +0 -1
- package/dist/bot/operator-profile-pool.d.ts +0 -97
- package/dist/bot/operator-profile-pool.d.ts.map +0 -1
- package/dist/bot/operator-profile-pool.js +0 -855
- package/dist/bot/operator-profile-pool.js.map +0 -1
- package/dist/bot/xvfb.d.ts +0 -13
- package/dist/bot/xvfb.d.ts.map +0 -1
- package/dist/bot/xvfb.js +0 -146
- package/dist/bot/xvfb.js.map +0 -1
package/dist/tools/audit-log.js
CHANGED
|
@@ -1,26 +1,59 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { assertApi } from "./index.js";
|
|
3
3
|
import { ALWAYS_LOAD_META } from "./always-load.js";
|
|
4
|
+
import { anomalyReason, buildEgressRollups, buildGrantTotals, decodeRollupId, describeStatuses, formatBytes, grantLabels, isEgressCall, normalizeAuditType, } from "./audit-rollup.js";
|
|
4
5
|
// The who-touched-my-keys ledger. Every vault action — stored / retrieved /
|
|
5
6
|
// rotated / deleted / proxy_executed / proxy_rejected — newest first, keyset-
|
|
6
7
|
// paginated by the `before` cursor. Payloads carry NO secret values; this is
|
|
7
8
|
// strictly less than what list_credentials already exposes, so the account's
|
|
8
9
|
// own agent can read it (same account boundary as the human's web UI).
|
|
10
|
+
//
|
|
11
|
+
// Read-side shaping (see audit-rollup.ts): the default `ledger` view keeps the
|
|
12
|
+
// security-relevant lifecycle events as rows, collapses routine egress traffic
|
|
13
|
+
// into per (credential x host x burst) rollups, and pulls anomalies back out of
|
|
14
|
+
// those rollups so a 429 or a rejected call is never hidden. `view: "raw"` is
|
|
15
|
+
// the unaggregated escape hatch and returns exactly the server's page.
|
|
9
16
|
const inputSchema = z.object({
|
|
10
17
|
limit: z.number().int().min(1).max(200).optional(),
|
|
11
18
|
before: z.string().min(1).optional(),
|
|
12
19
|
type: z.string().min(1).optional(),
|
|
13
20
|
reference: z.string().min(1).optional(),
|
|
21
|
+
// "ledger" (default) groups; "raw" is the flat per-request stream.
|
|
22
|
+
view: z.enum(["ledger", "raw"]).optional(),
|
|
23
|
+
// How many raw events the ledger view reads before shaping them. The point
|
|
24
|
+
// of the rollup is to see past a page of near-identical egress calls, so the
|
|
25
|
+
// scan is deliberately deeper than `limit`.
|
|
26
|
+
scan: z.number().int().min(1).max(2000).optional(),
|
|
27
|
+
// Gap that splits one egress burst from the next, in minutes.
|
|
28
|
+
window_minutes: z.number().int().min(1).max(1440).optional(),
|
|
29
|
+
// A rollup `id` from a ledger response — returns that rollup's individual calls.
|
|
30
|
+
expand: z.string().min(1).optional(),
|
|
14
31
|
});
|
|
32
|
+
const DEFAULT_LIMIT = 50;
|
|
33
|
+
const DEFAULT_SCAN = 500;
|
|
34
|
+
const DEFAULT_WINDOW_MINUTES = 60;
|
|
35
|
+
const API_PAGE_MAX = 200;
|
|
15
36
|
const DESCRIPTION = `Read the vault audit ledger — "show me everything that touched my keys."
|
|
16
|
-
|
|
17
|
-
deleted / proxy_executed / proxy_rejected, each with a timestamp, the credential
|
|
18
|
-
reference, requester, and outcome. NO secret values are ever included.
|
|
37
|
+
Account-scoped, newest-first, NO secret values ever.
|
|
19
38
|
|
|
20
|
-
|
|
21
|
-
\`
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
By default (\`view:"ledger"\`) the response is SHAPED so it is readable:
|
|
40
|
+
- \`events\` — the security ledger: credential stored / rotated / deleted /
|
|
41
|
+
edited, grants minted / revoked, payments, plus every ANOMALY
|
|
42
|
+
(\`anomaly:true\` with an \`anomaly_reason\` — non-2xx, 429, proxy error,
|
|
43
|
+
rejected call). Routine successful egress is NOT listed here.
|
|
44
|
+
- \`egress.rollups\` — routine proxied calls collapsed per credential x target
|
|
45
|
+
host x burst: count, status breakdown, total bytes, first/last timestamp,
|
|
46
|
+
and the grants covering that window. Pass a rollup's \`id\` back as
|
|
47
|
+
\`expand\` to see its individual calls.
|
|
48
|
+
- \`grant_totals\` — per egress grant: cumulative calls, bytes, last used.
|
|
49
|
+
- \`summary\` — one human-readable line per rollup / headline.
|
|
50
|
+
|
|
51
|
+
Escape hatches and filters: \`view:"raw"\` returns the flat unaggregated page
|
|
52
|
+
(the original shape). \`type\` (an event kind), \`reference\` (a single
|
|
53
|
+
credential), \`limit\` (rows, default ${DEFAULT_LIMIT}, max 200), \`before\`
|
|
54
|
+
(keyset cursor from \`next_before\`), \`scan\` (raw events read before shaping,
|
|
55
|
+
default ${DEFAULT_SCAN}, max 2000) and \`window_minutes\` (burst gap, default
|
|
56
|
+
${DEFAULT_WINDOW_MINUTES}) all still apply.`;
|
|
24
57
|
export const auditLogTool = {
|
|
25
58
|
name: "audit_log",
|
|
26
59
|
description: DESCRIPTION,
|
|
@@ -32,18 +65,195 @@ export const auditLogTool = {
|
|
|
32
65
|
before: { type: "string" },
|
|
33
66
|
type: { type: "string" },
|
|
34
67
|
reference: { type: "string" },
|
|
68
|
+
view: { type: "string", enum: ["ledger", "raw"] },
|
|
69
|
+
scan: { type: "number" },
|
|
70
|
+
window_minutes: { type: "number" },
|
|
71
|
+
expand: { type: "string" },
|
|
35
72
|
},
|
|
36
73
|
},
|
|
37
74
|
annotations: { readOnlyHint: true },
|
|
38
75
|
meta: ALWAYS_LOAD_META,
|
|
39
76
|
async handler(args, api) {
|
|
40
77
|
assertApi(api);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
78
|
+
if (args.expand !== undefined)
|
|
79
|
+
return expandRollup(api, args, args.expand);
|
|
80
|
+
if (args.view === "raw") {
|
|
81
|
+
const page = await api.listAudit(passthroughFilters(args));
|
|
82
|
+
return { view: "raw", ...page };
|
|
83
|
+
}
|
|
84
|
+
return buildLedgerView(api, args);
|
|
47
85
|
},
|
|
48
86
|
};
|
|
87
|
+
function passthroughFilters(args) {
|
|
88
|
+
return {
|
|
89
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
90
|
+
...(args.before !== undefined ? { before: args.before } : {}),
|
|
91
|
+
...(args.type !== undefined ? { type: args.type } : {}),
|
|
92
|
+
...(args.reference !== undefined ? { reference: args.reference } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Page the server's keyset cursor until `scan` events are read or the trail
|
|
96
|
+
// ends. Returns the cursor to continue from, so a caller can keep walking back.
|
|
97
|
+
async function scanEvents(api, filters, scan,
|
|
98
|
+
// Stop paging once the trail is older than this (epoch ms). The drill-down
|
|
99
|
+
// knows its window's lower bound, so it should not walk a credential's whole
|
|
100
|
+
// history to rebuild one burst.
|
|
101
|
+
until) {
|
|
102
|
+
const events = [];
|
|
103
|
+
let cursor = filters.before ?? null;
|
|
104
|
+
for (;;) {
|
|
105
|
+
const page = await api.listAudit({
|
|
106
|
+
limit: Math.min(API_PAGE_MAX, scan - events.length),
|
|
107
|
+
...(cursor !== null ? { before: cursor } : {}),
|
|
108
|
+
...(filters.type !== undefined ? { type: filters.type } : {}),
|
|
109
|
+
...(filters.reference !== undefined ? { reference: filters.reference } : {}),
|
|
110
|
+
});
|
|
111
|
+
events.push(...page.events);
|
|
112
|
+
cursor = page.next_before;
|
|
113
|
+
if (cursor === null || page.events.length === 0 || events.length >= scan)
|
|
114
|
+
break;
|
|
115
|
+
if (until !== undefined && Date.parse(cursor) < until)
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return { events, next_before: cursor };
|
|
119
|
+
}
|
|
120
|
+
// Egress grants give the rollups their "which standing access spent this key"
|
|
121
|
+
// context. Best-effort: an account with no egress at all should not pay for the
|
|
122
|
+
// extra call, and a failure here must not sink the whole ledger read.
|
|
123
|
+
async function loadGrants(api, needed) {
|
|
124
|
+
if (!needed)
|
|
125
|
+
return [];
|
|
126
|
+
try {
|
|
127
|
+
const { grants } = await api.listEgressGrants();
|
|
128
|
+
return grants.map((g) => ({
|
|
129
|
+
grant_id: g.grant_id,
|
|
130
|
+
credential_ref: g.credential_ref,
|
|
131
|
+
created_at: g.created_at,
|
|
132
|
+
revoked_at: g.revoked_at,
|
|
133
|
+
rate_limit_per_hour: g.rate_limit_per_hour,
|
|
134
|
+
spend_cap_usd: g.spend_cap_usd,
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function buildLedgerView(api, args) {
|
|
142
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
143
|
+
const scan = Math.max(args.scan ?? DEFAULT_SCAN, limit);
|
|
144
|
+
const windowMinutes = args.window_minutes ?? DEFAULT_WINDOW_MINUTES;
|
|
145
|
+
const { events, next_before } = await scanEvents(api, {
|
|
146
|
+
...(args.before !== undefined ? { before: args.before } : {}),
|
|
147
|
+
...(args.type !== undefined ? { type: args.type } : {}),
|
|
148
|
+
...(args.reference !== undefined ? { reference: args.reference } : {}),
|
|
149
|
+
}, scan);
|
|
150
|
+
const egressCalls = events.filter(isEgressCall);
|
|
151
|
+
const grants = await loadGrants(api, egressCalls.length > 0);
|
|
152
|
+
// Ledger rows: everything that is not routine egress. An egress call that
|
|
153
|
+
// failed, was rate-limited, or errored is pulled back out of the aggregate
|
|
154
|
+
// and marked, so the actionable rows are visible without expanding anything.
|
|
155
|
+
const ledgerRows = [];
|
|
156
|
+
let anomalyCount = 0;
|
|
157
|
+
for (const event of events) {
|
|
158
|
+
const reason = anomalyReason(event);
|
|
159
|
+
if (reason !== null)
|
|
160
|
+
anomalyCount += 1;
|
|
161
|
+
if (isEgressCall(event) && reason === null)
|
|
162
|
+
continue;
|
|
163
|
+
ledgerRows.push(reason === null ? event : { ...event, anomaly: true, anomaly_reason: reason });
|
|
164
|
+
}
|
|
165
|
+
const labels = grantLabels(events);
|
|
166
|
+
const rollups = buildEgressRollups(events, {
|
|
167
|
+
windowMinutes,
|
|
168
|
+
...(grants !== null ? { grants } : {}),
|
|
169
|
+
labels,
|
|
170
|
+
});
|
|
171
|
+
const grantTotals = grants === null ? [] : buildGrantTotals(events, grants);
|
|
172
|
+
const oldest = events[events.length - 1];
|
|
173
|
+
const newest = events[0];
|
|
174
|
+
return {
|
|
175
|
+
view: "ledger",
|
|
176
|
+
window: {
|
|
177
|
+
from: oldest?.emitted_at ?? null,
|
|
178
|
+
to: newest?.emitted_at ?? null,
|
|
179
|
+
},
|
|
180
|
+
scanned: events.length,
|
|
181
|
+
// More history exists past the scan — page it with `before: next_before`.
|
|
182
|
+
truncated: next_before !== null,
|
|
183
|
+
next_before,
|
|
184
|
+
events: ledgerRows.slice(0, limit),
|
|
185
|
+
events_total: ledgerRows.length,
|
|
186
|
+
events_truncated: ledgerRows.length > limit,
|
|
187
|
+
anomaly_count: anomalyCount,
|
|
188
|
+
egress: {
|
|
189
|
+
calls: egressCalls.length,
|
|
190
|
+
rolled_up_into: rollups.length,
|
|
191
|
+
window_minutes: windowMinutes,
|
|
192
|
+
rollups,
|
|
193
|
+
...(rollups.length > 0
|
|
194
|
+
? {
|
|
195
|
+
hint: 'Pass a rollup\'s `id` as `expand` to list its individual calls, or view:"raw" for the flat stream.',
|
|
196
|
+
}
|
|
197
|
+
: {}),
|
|
198
|
+
},
|
|
199
|
+
grant_totals: grantTotals,
|
|
200
|
+
// Honest about what read-side attribution can and cannot know: the write
|
|
201
|
+
// side records no grant id on a proxied call, so these totals count egress
|
|
202
|
+
// on the grant's credential during its lifetime and include any direct
|
|
203
|
+
// use_credential traffic on that same credential.
|
|
204
|
+
attribution: grants === null
|
|
205
|
+
? "grants_unavailable"
|
|
206
|
+
: "by_credential_reference_within_grant_lifetime (may include direct use_credential calls; per-event grant attribution is a planned follow-up)",
|
|
207
|
+
summary: summarize(ledgerRows.length, anomalyCount, rollups, egressCalls.length),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function summarize(ledgerRows, anomalies, rollups, egressCalls) {
|
|
211
|
+
const lines = [
|
|
212
|
+
`${ledgerRows} ledger event(s), ${anomalies} anomaly(ies), ${egressCalls} egress call(s) in ${rollups.length} rollup(s)`,
|
|
213
|
+
];
|
|
214
|
+
for (const r of rollups.slice(0, 20)) {
|
|
215
|
+
const marker = r.anomaly_count > 0 ? ` [${r.anomaly_count} anomaly]` : "";
|
|
216
|
+
lines.push(`${r.target_host} via ${r.reference}: ${r.count} call(s) (${describeStatuses(r.status_breakdown)}), ${formatBytes(r.total_bytes)}, ${r.from} → ${r.to}${marker}`);
|
|
217
|
+
}
|
|
218
|
+
return lines;
|
|
219
|
+
}
|
|
220
|
+
// Drill-down: the individual calls behind one rollup id. Stateless — the id
|
|
221
|
+
// carries (reference, host, window), so no server-side rollup state is needed.
|
|
222
|
+
async function expandRollup(api, args, expand) {
|
|
223
|
+
const key = decodeRollupId(expand);
|
|
224
|
+
if (key === null) {
|
|
225
|
+
throw new Error("audit_log expand expects a rollup `id` from a ledger response (rollup_…). Call audit_log with no expand first.");
|
|
226
|
+
}
|
|
227
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
228
|
+
const scan = Math.max(args.scan ?? DEFAULT_SCAN, limit);
|
|
229
|
+
const from = Date.parse(key.from);
|
|
230
|
+
const to = Date.parse(key.to);
|
|
231
|
+
// `before` is exclusive on the server; nudge past the newest member so the
|
|
232
|
+
// rollup's own upper bound is included.
|
|
233
|
+
const cursor = Number.isNaN(to) ? undefined : new Date(to + 1).toISOString();
|
|
234
|
+
const { events } = await scanEvents(api, { reference: key.reference, ...(cursor !== undefined ? { before: cursor } : {}) }, scan, Number.isNaN(from) ? undefined : from);
|
|
235
|
+
const calls = events.filter((event) => {
|
|
236
|
+
if (!isEgressCall(event))
|
|
237
|
+
return false;
|
|
238
|
+
if (event.target_host !== key.target_host)
|
|
239
|
+
return false;
|
|
240
|
+
const at = Date.parse(event.emitted_at);
|
|
241
|
+
return !Number.isNaN(at) && at >= from && at <= to;
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
view: "expand",
|
|
245
|
+
rollup: { id: expand, ...key },
|
|
246
|
+
calls: calls.slice(0, limit).map((event) => {
|
|
247
|
+
const reason = anomalyReason(event);
|
|
248
|
+
return reason === null ? event : { ...event, anomaly: true, anomaly_reason: reason };
|
|
249
|
+
}),
|
|
250
|
+
calls_total: calls.length,
|
|
251
|
+
calls_truncated: calls.length > limit,
|
|
252
|
+
// Raise `limit` (max 200) or narrow `window_minutes` on the ledger call to
|
|
253
|
+
// see the rest of a very large burst.
|
|
254
|
+
scanned: events.length,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// Re-exported for the web/CLI surfaces and tests that shape the same trail.
|
|
258
|
+
export { normalizeAuditType };
|
|
49
259
|
//# sourceMappingURL=audit-log.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-log.js","sourceRoot":"","sources":["../../src/tools/audit-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CA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AAC,YAAY,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,IAAI,KAAK,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW;YAAE,OAAO,KAAK,CAAC;QACxD,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE;QAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACzC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YACpC,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;QACvF,CAAC,CAAC;QACF,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,eAAe,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK;QACrC,2EAA2E;QAC3E,sCAAsC;QACtC,OAAO,EAAE,MAAM,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface AuditEvent {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
emitted_at: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface EgressGrantSummary {
|
|
8
|
+
grant_id: string;
|
|
9
|
+
credential_ref: string;
|
|
10
|
+
created_at: string;
|
|
11
|
+
revoked_at: string | null;
|
|
12
|
+
rate_limit_per_hour?: number | null;
|
|
13
|
+
spend_cap_usd?: number | null;
|
|
14
|
+
}
|
|
15
|
+
export interface RollupKey {
|
|
16
|
+
reference: string;
|
|
17
|
+
target_host: string;
|
|
18
|
+
from: string;
|
|
19
|
+
to: string;
|
|
20
|
+
}
|
|
21
|
+
export interface EgressRollup extends RollupKey {
|
|
22
|
+
id: string;
|
|
23
|
+
count: number;
|
|
24
|
+
status_breakdown: Record<string, number>;
|
|
25
|
+
error_count: number;
|
|
26
|
+
anomaly_count: number;
|
|
27
|
+
total_bytes: number;
|
|
28
|
+
grants: Array<{
|
|
29
|
+
grant_id: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export interface GrantTotals {
|
|
34
|
+
grant_id: string;
|
|
35
|
+
credential_ref: string;
|
|
36
|
+
calls: number;
|
|
37
|
+
total_bytes: number;
|
|
38
|
+
last_used_at: string | null;
|
|
39
|
+
status_breakdown: Record<string, number>;
|
|
40
|
+
anomaly_count: number;
|
|
41
|
+
revoked_at: string | null;
|
|
42
|
+
rate_limit_per_hour?: number | null;
|
|
43
|
+
spend_cap_usd?: number | null;
|
|
44
|
+
}
|
|
45
|
+
export declare function normalizeAuditType(type: string): string;
|
|
46
|
+
/** Why this row is actionable, or null when it is routine. */
|
|
47
|
+
export declare function anomalyReason(event: AuditEvent): string | null;
|
|
48
|
+
/** proxy_executed rows are the high-volume class the rollups collapse. */
|
|
49
|
+
export declare function isEgressCall(event: AuditEvent): boolean;
|
|
50
|
+
export declare function encodeRollupId(key: RollupKey): string;
|
|
51
|
+
export declare function decodeRollupId(id: string): RollupKey | null;
|
|
52
|
+
/**
|
|
53
|
+
* Cluster egress calls by (reference x target host), splitting a cluster
|
|
54
|
+
* whenever the gap between adjacent calls exceeds `windowMinutes`. A burst
|
|
55
|
+
* stays one row; a call an hour later starts a new one, so the window a rollup
|
|
56
|
+
* reports is a real burst rather than an arbitrary clock bucket.
|
|
57
|
+
*
|
|
58
|
+
* `events` is newest-first (the ledger's own order); the returned rollups keep
|
|
59
|
+
* that order.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildEgressRollups(events: readonly AuditEvent[], options: {
|
|
62
|
+
windowMinutes: number;
|
|
63
|
+
grants?: readonly EgressGrantSummary[];
|
|
64
|
+
labels?: Map<string, string>;
|
|
65
|
+
}): EgressRollup[];
|
|
66
|
+
/**
|
|
67
|
+
* Rolling per-grant totals so a human never sums rows by hand.
|
|
68
|
+
*
|
|
69
|
+
* Attribution caveat (see the module header): `vault.proxy_executed` carries no
|
|
70
|
+
* grant id, so a grant's calls are the egress calls on its credential inside
|
|
71
|
+
* its lifetime. Direct `use_credential` traffic on the same credential is
|
|
72
|
+
* indistinguishable and lands here too — an upper bound, flagged in the
|
|
73
|
+
* response's `attribution` field.
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildGrantTotals(events: readonly AuditEvent[], grants: readonly EgressGrantSummary[]): GrantTotals[];
|
|
76
|
+
/** Grant labels recorded on the grant_minted lifecycle event, when in scan. */
|
|
77
|
+
export declare function grantLabels(events: readonly AuditEvent[]): Map<string, string>;
|
|
78
|
+
export declare function formatBytes(bytes: number): string;
|
|
79
|
+
export declare function describeStatuses(breakdown: Record<string, number>): string;
|
|
80
|
+
//# sourceMappingURL=audit-rollup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-rollup.d.ts","sourceRoot":"","sources":["../../src/tools/audit-rollup.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CA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G,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,SAAiC;IAChE,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SAC7B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,MAAM,EAAE,CAAC;SAC9C,IAAI,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Tool } from "./index.js";
|
|
3
|
+
declare const inputSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
4
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
5
|
+
service: z.ZodOptional<z.ZodString>;
|
|
6
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7
|
+
field: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
reference?: string | undefined;
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
field?: string | undefined;
|
|
12
|
+
service?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
reference?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
field?: string | undefined;
|
|
17
|
+
service?: string | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
reference?: string | undefined;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
field?: string | undefined;
|
|
22
|
+
service?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
reference?: string | undefined;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
field?: string | undefined;
|
|
27
|
+
service?: string | undefined;
|
|
28
|
+
}>, z.ZodObject<{
|
|
29
|
+
approval_id: z.ZodString;
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
|
+
approval_id: string;
|
|
32
|
+
}, {
|
|
33
|
+
approval_id: string;
|
|
34
|
+
}>]>;
|
|
35
|
+
export declare const fetchCredentialTool: Tool<z.infer<typeof inputSchema>>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=fetch-credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-credential.d.ts","sourceRoot":"","sources":["../../src/tools/fetch-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAgBlD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAA2B,CAAC;AAoF7C,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAwDjE,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiCallError } from "../api-client.js";
|
|
3
|
+
import { ALWAYS_LOAD_META } from "./always-load.js";
|
|
4
|
+
import { assertApi } from "./index.js";
|
|
5
|
+
const start = z
|
|
6
|
+
.object({
|
|
7
|
+
reference: z.string().min(1).max(400).optional(),
|
|
8
|
+
service: z.string().min(1).max(120).optional(),
|
|
9
|
+
name: z.string().min(1).max(60).optional(),
|
|
10
|
+
field: z.string().min(1).max(120).optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict()
|
|
13
|
+
.refine((value) => value.reference !== undefined || value.service !== undefined || value.name !== undefined, { message: "one of reference, service, or name is required" });
|
|
14
|
+
const resume = z.object({ approval_id: z.string().min(1).max(64) }).strict();
|
|
15
|
+
const inputSchema = z.union([start, resume]);
|
|
16
|
+
// The description is the only thing standing between a model and a needless
|
|
17
|
+
// plaintext secret in its own transcript, so it leads with the cheaper route
|
|
18
|
+
// and states the cost of this one in the first two sentences.
|
|
19
|
+
const DESCRIPTION = `Return a vaulted credential's RAW value to you, in clear, after an explicit
|
|
20
|
+
human passkey approval. Use it ONLY when unavoidable: the value lands in your
|
|
21
|
+
context and therefore in the conversation transcript and any logs of it, which
|
|
22
|
+
no later step can undo.
|
|
23
|
+
|
|
24
|
+
Prefer \`use_credential\` whenever the task is "call an API with this key" — the
|
|
25
|
+
server injects the secret into the HTTP request and returns only the upstream
|
|
26
|
+
response, so the key never reaches you at all. Prefer an egress grant
|
|
27
|
+
(\`grant_app_access\`) when a deployed app needs standing access. Reach for
|
|
28
|
+
\`fetch_credential\` only when the raw key must physically land somewhere YOU
|
|
29
|
+
control and no server-side injection path exists — writing it into a
|
|
30
|
+
GitHub Actions secret, a .env file, or a config file. If you can accomplish
|
|
31
|
+
the task without the plaintext, do that instead.
|
|
32
|
+
|
|
33
|
+
Every fetch requires an explicit human passkey approval; there is no way to
|
|
34
|
+
skip it. The first call resolves the credential and returns approval_pending
|
|
35
|
+
with an approval_url — NO value. The user opens that link and signs with their
|
|
36
|
+
passkey. Then call fetch_credential again with ONLY that approval_id to receive
|
|
37
|
+
the value. Delivery is single-use: the same approval_id will not return the
|
|
38
|
+
value twice, so store it where it needs to go on first receipt. A denied or
|
|
39
|
+
expired approval returns a refusal and no value. Pass \`field\` to name one
|
|
40
|
+
field of a multi-field credential (required when the credential has more than
|
|
41
|
+
one — call list_credentials for its field names).`;
|
|
42
|
+
function refusal(reason, approval) {
|
|
43
|
+
return {
|
|
44
|
+
status: "credential_fetch_refused",
|
|
45
|
+
reason,
|
|
46
|
+
approval_id: approval.approval_id,
|
|
47
|
+
credential: approval.credential,
|
|
48
|
+
field: approval.field,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function toolResult(approval) {
|
|
52
|
+
if (approval.status === "consumed" && approval.fields !== undefined) {
|
|
53
|
+
return {
|
|
54
|
+
status: "credential_fetched",
|
|
55
|
+
credential: approval.credential,
|
|
56
|
+
field: approval.field,
|
|
57
|
+
fields: approval.fields,
|
|
58
|
+
approval_id: approval.approval_id,
|
|
59
|
+
fetched_at: approval.fetched_at,
|
|
60
|
+
reminder: "This value is now in your context. Write it only where the user asked, " +
|
|
61
|
+
"and do not repeat it back in your reply.",
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (approval.status === "pending") {
|
|
65
|
+
return {
|
|
66
|
+
status: "approval_pending",
|
|
67
|
+
approval_id: approval.approval_id,
|
|
68
|
+
approval_url: approval.approval_url,
|
|
69
|
+
expires_at: approval.expires_at,
|
|
70
|
+
credential: approval.credential,
|
|
71
|
+
field: approval.field,
|
|
72
|
+
field_names: approval.field_names,
|
|
73
|
+
next: { tool: "fetch_credential", approval_id: approval.approval_id },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return refusal(approval.error ?? `approval_${approval.status}`, approval);
|
|
77
|
+
}
|
|
78
|
+
// A refused fetch comes back as a non-2xx carrying the same approval shape.
|
|
79
|
+
// Rendering it as a typed refusal — rather than letting the HTTP error escape —
|
|
80
|
+
// is what tells the agent to stop instead of retrying the approval loop.
|
|
81
|
+
function refusalFromError(error) {
|
|
82
|
+
if (!(error instanceof ApiCallError))
|
|
83
|
+
return null;
|
|
84
|
+
if (!error.code.startsWith("credential_fetch_"))
|
|
85
|
+
return null;
|
|
86
|
+
const body = error.body;
|
|
87
|
+
return {
|
|
88
|
+
status: "credential_fetch_refused",
|
|
89
|
+
reason: error.code,
|
|
90
|
+
...(body?.approval_id !== undefined ? { approval_id: body.approval_id } : {}),
|
|
91
|
+
...(body?.credential !== undefined ? { credential: body.credential } : {}),
|
|
92
|
+
...(body?.field !== undefined ? { field: body.field } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export const fetchCredentialTool = {
|
|
96
|
+
name: "fetch_credential",
|
|
97
|
+
description: DESCRIPTION,
|
|
98
|
+
inputSchema,
|
|
99
|
+
jsonInputSchema: {
|
|
100
|
+
type: "object",
|
|
101
|
+
oneOf: [
|
|
102
|
+
{
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: {
|
|
105
|
+
reference: { type: "string" },
|
|
106
|
+
service: { type: "string" },
|
|
107
|
+
name: { type: "string" },
|
|
108
|
+
field: { type: "string" },
|
|
109
|
+
},
|
|
110
|
+
additionalProperties: false,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "object",
|
|
114
|
+
required: ["approval_id"],
|
|
115
|
+
properties: { approval_id: { type: "string" } },
|
|
116
|
+
additionalProperties: false,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
// Not read-only: a fetch discloses a secret and burns a single-use approval.
|
|
121
|
+
annotations: { destructiveHint: true, idempotentHint: false },
|
|
122
|
+
meta: ALWAYS_LOAD_META,
|
|
123
|
+
async handler(args, api) {
|
|
124
|
+
assertApi(api);
|
|
125
|
+
try {
|
|
126
|
+
const approval = "approval_id" in args
|
|
127
|
+
? await api.getCredentialFetchApproval(args.approval_id)
|
|
128
|
+
: await api.createCredentialFetchApproval({
|
|
129
|
+
...(args.reference !== undefined ? { reference: args.reference } : {}),
|
|
130
|
+
...(args.service !== undefined ? { service: args.service } : {}),
|
|
131
|
+
...(args.name !== undefined ? { name: args.name } : {}),
|
|
132
|
+
...(args.field !== undefined ? { field: args.field } : {}),
|
|
133
|
+
});
|
|
134
|
+
return toolResult(approval);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
const refused = refusalFromError(error);
|
|
138
|
+
if (refused !== null)
|
|
139
|
+
return refused;
|
|
140
|
+
if (error instanceof ApiCallError && error.code === "ambiguous_credential_field") {
|
|
141
|
+
const names = error.body?.field_names;
|
|
142
|
+
return {
|
|
143
|
+
status: "credential_fetch_refused",
|
|
144
|
+
reason: "ambiguous_credential_field",
|
|
145
|
+
field_names: Array.isArray(names) ? names : [],
|
|
146
|
+
remedy: "Retry fetch_credential with `field` set to one of field_names.",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=fetch-credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-credential.js","sourceRoot":"","sources":["../../src/tools/fetch-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAElD,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAChD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC9C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,MAAM,EAAE;KACR,MAAM,CAC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audit-log.js";
|
|
10
10
|
import { listPaymentCardsTool, operatePayTool, operatePaymentStatusTool } from "./operate-pay.js";
|
|
11
11
|
import { deleteCredentialTool, editCredentialTool } from "./credential-mutations.js";
|
|
12
|
+
import { fetchCredentialTool } from "./fetch-credential.js";
|
|
12
13
|
export interface Tool<TArgs extends Record<string, unknown> = Record<string, unknown>> {
|
|
13
14
|
name: string;
|
|
14
15
|
description: string;
|
|
@@ -21,6 +22,7 @@ export interface Tool<TArgs extends Record<string, unknown> = Record<string, unk
|
|
|
21
22
|
}
|
|
22
23
|
export interface ToolContext {
|
|
23
24
|
notifyUser: (message: string, data?: Record<string, unknown>) => Promise<void>;
|
|
25
|
+
paymentApprovalWaitMs?: number;
|
|
24
26
|
}
|
|
25
27
|
export { ALWAYS_LOAD_META } from "./always-load.js";
|
|
26
28
|
export declare function assertApi(api: ApiClient | null): asserts api is ApiClient;
|
|
@@ -28,5 +30,5 @@ export declare function buildToolRegistry(env?: NodeJS.ProcessEnv): Tool[];
|
|
|
28
30
|
export declare const TOOLS: Tool[];
|
|
29
31
|
export declare function findTool(name: string, tools?: readonly Tool[]): Tool | null;
|
|
30
32
|
export { z };
|
|
31
|
-
export { listCredentialsTool, storeCredentialTool, editCredentialTool, deleteCredentialTool, useCredentialTool, grantAppAccessTool, listAppAccessTool, revokeAppAccessTool, auditLogTool, listExtractFailuresTool, getExtractFailureTool, listPaymentCardsTool, operatePayTool, operatePaymentStatusTool, };
|
|
33
|
+
export { listCredentialsTool, storeCredentialTool, editCredentialTool, deleteCredentialTool, useCredentialTool, fetchCredentialTool, grantAppAccessTool, listAppAccessTool, revokeAppAccessTool, auditLogTool, listExtractFailuresTool, getExtractFailureTool, listPaymentCardsTool, operatePayTool, operatePaymentStatusTool, };
|
|
32
34
|
//# sourceMappingURL=index.d.ts.map
|