@makine/cli 0.6.4 → 0.7.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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * `makine agents`: register an outside A2A agent, read it, rotate its credential, re-pin its card
3
+ * and retire it (ADR 0016 § D16.5).
4
+ *
5
+ * The agent's credential is read from stdin or a hidden prompt only, never from an argument or an
6
+ * environment variable, where `ps` and shell history would see it, and it is never printed back.
7
+ * Every write needs `makine login`: a workspace key is refused, because this workspace's task input
8
+ * leaves Makine for whatever host a registration names.
9
+ */
10
+ export declare const AGENTS_SUBCOMMANDS: readonly ["register", "list", "show", "credential", "repin", "retire"];
11
+ export type AgentsSubcommand = (typeof AGENTS_SUBCOMMANDS)[number];
12
+ export interface AgentsInvocation {
13
+ subcommand: AgentsSubcommand;
14
+ /** The host for `register`; the agent id for `show`, `credential`, `repin` and `retire`. */
15
+ target?: string;
16
+ /** `register` only: what screens call the agent. */
17
+ name?: string;
18
+ /** `register` only: one `<role>:<artifact_type>[:<artifact_name>]` per `--artifact`. */
19
+ artifacts?: readonly string[];
20
+ /** `register` only: read the agent's credential from standard input. */
21
+ credentialStdin?: boolean;
22
+ /** `register` only: the explicit acknowledgement the route requires. */
23
+ acknowledgeEgress?: boolean;
24
+ /** `repin` only: pin the live card without asking. */
25
+ yes: boolean;
26
+ json: boolean;
27
+ }
28
+ export interface AgentsConnection {
29
+ baseUrl: string;
30
+ apiKey: string;
31
+ /** True when the credential came from `MAKINE_API_KEY` or `--api-key` rather than a session. */
32
+ explicitKey: boolean;
33
+ fetchImpl?: typeof fetch;
34
+ }
35
+ export interface AgentsIo {
36
+ out: (line: string) => void;
37
+ err: (line: string) => void;
38
+ /**
39
+ * Reads the agent's credential. The default reads stdin to end of input; a terminal session
40
+ * supplies a hidden prompt. It returns the value and this module keeps no other copy of it.
41
+ */
42
+ readCredential: (prompt: string) => Promise<string>;
43
+ /** Reads the answer `repin` asks for without `--yes`. */
44
+ confirm: (prompt: string) => Promise<string>;
45
+ }
46
+ export type AgentsOutcome = "ok" | "usage" | "refused" | "auth" | "unavailable";
47
+ export declare function runAgents(invocation: AgentsInvocation, connection: AgentsConnection, io: AgentsIo): Promise<AgentsOutcome>;
48
+ export declare function isAgentsSubcommand(value: string): value is AgentsSubcommand;
49
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/agents/command.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,eAAO,MAAM,kBAAkB,wEAOrB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAanE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gGAAgG;IAChG,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,yDAAyD;IACzD,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC;AA8ChF,wBAAsB,SAAS,CAC7B,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,gBAAgB,EAC5B,EAAE,EAAE,QAAQ,GACX,OAAO,CAAC,aAAa,CAAC,CAgBxB;AA+XD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAE3E"}
@@ -0,0 +1,368 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * `makine agents`: register an outside A2A agent, read it, rotate its credential, re-pin its card
4
+ * and retire it (ADR 0016 § D16.5).
5
+ *
6
+ * The agent's credential is read from stdin or a hidden prompt only, never from an argument or an
7
+ * environment variable, where `ps` and shell history would see it, and it is never printed back.
8
+ * Every write needs `makine login`: a workspace key is refused, because this workspace's task input
9
+ * leaves Makine for whatever host a registration names.
10
+ */
11
+ export const AGENTS_SUBCOMMANDS = [
12
+ "register",
13
+ "list",
14
+ "show",
15
+ "credential",
16
+ "repin",
17
+ "retire",
18
+ ];
19
+ const SIGN_IN_NOTE = "This needs a signed-in account. Run `makine login`.";
20
+ /**
21
+ * Why `makine login` alone does not fix it when the environment carries a key: `resolveCredential`
22
+ * sends an explicit key in preference to a stored session, so a set `MAKINE_API_KEY` keeps the
23
+ * refusal in place however many times you sign in.
24
+ */
25
+ const API_KEY_OVERRIDES_LOGIN_NOTE = "MAKINE_API_KEY is set, and an explicit key is used in preference to a stored session. Unset it " +
26
+ "(or drop --api-key) and run `makine login`.";
27
+ const CREDENTIAL_PROMPT = "Agent credential (read from stdin; it is never echoed, stored on this machine, or passed as an argument): ";
28
+ export async function runAgents(invocation, connection, io) {
29
+ const call = makeCall(connection);
30
+ switch (invocation.subcommand) {
31
+ case "register":
32
+ return await registerAgent(invocation, call, io, connection);
33
+ case "list":
34
+ return await listAgents(invocation, call, io, connection);
35
+ case "show":
36
+ return await showAgent(invocation, call, io, connection);
37
+ case "credential":
38
+ return await setCredential(invocation, call, io, connection);
39
+ case "repin":
40
+ return await repinCard(invocation, call, io, connection);
41
+ case "retire":
42
+ return await retireAgent(invocation, call, io, connection);
43
+ }
44
+ }
45
+ /**
46
+ * Each declaration is `<role>:<artifact_type>[:<artifact_name>]`. The A2A artifact name is the name
47
+ * the agent gives its own artifact and the role is what the contract asks for; the two differ often
48
+ * enough to be separable, and the name defaults to the role when they agree.
49
+ */
50
+ function parseDeclarations(values) {
51
+ const declarations = [];
52
+ for (const value of values) {
53
+ const parts = value.split(":");
54
+ const [role, artifactType, artifactName] = parts;
55
+ if ((parts.length !== 2 && parts.length !== 3) ||
56
+ role === undefined ||
57
+ role.trim().length === 0 ||
58
+ artifactType === undefined ||
59
+ artifactType.trim().length === 0 ||
60
+ (parts.length === 3 && (artifactName === undefined || artifactName.trim().length === 0))) {
61
+ return {
62
+ ok: false,
63
+ message: `\`--artifact ${value}\` is not \`<role>:<artifact_type>[:<artifact_name>]\`. The artifact name defaults to the role.`,
64
+ };
65
+ }
66
+ declarations.push({
67
+ role: role.trim(),
68
+ artifact_type: artifactType.trim(),
69
+ required: true,
70
+ collection: {
71
+ kind: "a2a_artifact",
72
+ artifact_name: (artifactName ?? role).trim(),
73
+ },
74
+ });
75
+ }
76
+ return { ok: true, declarations };
77
+ }
78
+ async function registerAgent(invocation, call, io, connection) {
79
+ const host = invocation.target;
80
+ if (host === undefined || host.trim().length === 0) {
81
+ io.err('`makine agents register` needs the agent\'s host, e.g. `makine agents register agent.example.com --name "Acme" --artifact message:text`.');
82
+ return "usage";
83
+ }
84
+ const displayName = invocation.name;
85
+ if (displayName === undefined || displayName.trim().length === 0) {
86
+ io.err("`makine agents register` needs --name <display name>.");
87
+ return "usage";
88
+ }
89
+ const values = invocation.artifacts ?? [];
90
+ if (values.length === 0) {
91
+ io.err("`makine agents register` needs at least one --artifact <role>:<artifact_type>[:<artifact_name>], naming what the agent must deliver.");
92
+ return "usage";
93
+ }
94
+ const parsed = parseDeclarations(values);
95
+ if (!parsed.ok) {
96
+ io.err(parsed.message);
97
+ return "usage";
98
+ }
99
+ // The notice comes before the write, on both sides: the route refuses without the
100
+ // acknowledgement, and this prints the same sentences the route carries.
101
+ if (invocation.acknowledgeEgress !== true) {
102
+ const preview = await call("GET", "/agents");
103
+ if (preview.ok) {
104
+ for (const line of readNotice(preview.body))
105
+ io.err(`! ${line}`);
106
+ }
107
+ io.err("Re-run with --acknowledge-egress to confirm you have read what registering this agent opens. Nothing was registered.");
108
+ return "usage";
109
+ }
110
+ let credential;
111
+ if (invocation.credentialStdin === true) {
112
+ credential = await io.readCredential(CREDENTIAL_PROMPT);
113
+ if (credential.trim().length === 0) {
114
+ io.err("No credential was supplied on stdin.");
115
+ return "usage";
116
+ }
117
+ }
118
+ const result = await call("POST", "/agents", {
119
+ agent_host: host.trim(),
120
+ display_name: displayName,
121
+ acknowledged_agent_egress: true,
122
+ artifact_declarations: parsed.declarations,
123
+ ...(credential === undefined ? {} : { credential }),
124
+ });
125
+ if (!result.ok)
126
+ return report(io, result, connection, host.trim());
127
+ const body = result.body;
128
+ if (invocation.json) {
129
+ io.out(JSON.stringify(body, null, 2));
130
+ return "ok";
131
+ }
132
+ const agent = body.agent;
133
+ if (agent === null) {
134
+ io.err("Registered, but the agent could not be read back.");
135
+ return "ok";
136
+ }
137
+ io.err(`Registered ${agent.display_name} as ${agent.remote_agent_id}.`);
138
+ io.err(` card ${body.card.name} (${body.card.signature_state})`);
139
+ if (body.card.provider !== null)
140
+ io.err(` provider ${body.card.provider}`);
141
+ io.err(` skills ${body.card.skills.join(", ")}`);
142
+ io.err(` pinned ${agent.pinned_card_hash}`);
143
+ io.err(` credential ${agent.has_credential ? "stored, sent only to this agent's host" : "none"}`);
144
+ io.err(`Send it a task with \`makine runs submit --executor ${agent.executor_ref} --contract <id>@<version> --input <file.json>\`.`);
145
+ io.out(agent.executor_ref);
146
+ return "ok";
147
+ }
148
+ async function listAgents(invocation, call, io, connection) {
149
+ const result = await call("GET", "/agents");
150
+ if (!result.ok)
151
+ return report(io, result, connection);
152
+ const body = result.body;
153
+ if (invocation.json) {
154
+ io.out(JSON.stringify(body, null, 2));
155
+ return "ok";
156
+ }
157
+ if (body.agents.length === 0) {
158
+ io.out("No outside agents. Register one with `makine agents register <host> --name <name> --artifact <role>:<type>`.");
159
+ return "ok";
160
+ }
161
+ for (const agent of body.agents) {
162
+ const retired = agent.retired_at === null ? "" : `\tretired ${agent.retired_at}`;
163
+ io.out(`${agent.remote_agent_id}\t${agent.executor_ref}\t${agent.display_name}\t→ ${agent.agent_host}\t${agent.status}${retired}`);
164
+ }
165
+ for (const line of body.egress_notice ?? [])
166
+ io.out(`! ${line}`);
167
+ return "ok";
168
+ }
169
+ async function showAgent(invocation, call, io, connection) {
170
+ const target = invocation.target;
171
+ if (target === undefined) {
172
+ io.err("`makine agents show` needs an agent id. `makine agents list` prints them.");
173
+ return "usage";
174
+ }
175
+ const result = await call("GET", `/agents/${encodeURIComponent(target)}`);
176
+ if (!result.ok)
177
+ return report(io, result, connection);
178
+ const body = result.body;
179
+ if (invocation.json) {
180
+ io.out(JSON.stringify(body, null, 2));
181
+ return "ok";
182
+ }
183
+ const agent = body.agent;
184
+ io.out(`${agent.remote_agent_id}\t${agent.display_name}`);
185
+ io.out(` executor ${agent.executor_ref}`);
186
+ io.out(` address ${agent.agent_url}`);
187
+ io.out(` status ${agent.status}${agent.retired_at === null ? "" : ` (retired ${agent.retired_at})`}`);
188
+ io.out(` card now ${agent.card_hash} (${agent.card_state}, ${agent.card_signature_state})`);
189
+ io.out(` pinned ${agent.pinned_card_hash}`);
190
+ io.out(` skills ${agent.declared_skills.join(", ")}`);
191
+ io.out(` credential ${agent.has_credential ? "stored" : "none"}`);
192
+ if (agent.last_error_code !== null)
193
+ io.out(` last error ${agent.last_error_code}`);
194
+ for (const pin of body.card_pins) {
195
+ io.out(` pin ${pin.pinned_card_hash}\t${pin.card_signature_state}\t${pin.approved_at}`);
196
+ }
197
+ if (agent.card_hash !== agent.pinned_card_hash) {
198
+ io.out("The live card differs from the pinned one. `makine agents repin` pins what is live now.");
199
+ }
200
+ return "ok";
201
+ }
202
+ async function setCredential(invocation, call, io, connection) {
203
+ const target = invocation.target;
204
+ if (target === undefined) {
205
+ io.err("`makine agents credential` needs an agent id.");
206
+ return "usage";
207
+ }
208
+ const credential = await io.readCredential(CREDENTIAL_PROMPT);
209
+ if (credential.trim().length === 0) {
210
+ io.err("No credential was supplied on stdin.");
211
+ return "usage";
212
+ }
213
+ const result = await call("PUT", `/agents/${encodeURIComponent(target)}/credential`, {
214
+ credential,
215
+ });
216
+ if (!result.ok)
217
+ return report(io, result, connection);
218
+ const body = result.body;
219
+ if (invocation.json) {
220
+ io.out(JSON.stringify(body, null, 2));
221
+ return "ok";
222
+ }
223
+ io.err(`Stored a credential for ${body.remote_agent_id}; it is sent only to that agent's host.`);
224
+ io.out(body.remote_agent_id);
225
+ return "ok";
226
+ }
227
+ async function repinCard(invocation, call, io, connection) {
228
+ const target = invocation.target;
229
+ if (target === undefined) {
230
+ io.err("`makine agents repin` needs an agent id.");
231
+ return "usage";
232
+ }
233
+ const read = await call("GET", `/agents/${encodeURIComponent(target)}`);
234
+ if (!read.ok)
235
+ return report(io, read, connection);
236
+ const before = read.body.agent;
237
+ // What is being approved is the difference between the two hashes, so both are shown before the
238
+ // question rather than after the write.
239
+ io.err(`Agent ${before.remote_agent_id} (${before.display_name})`);
240
+ io.err(`Card now ${before.card_hash} (${before.card_signature_state})`);
241
+ io.err(`Pinned ${before.pinned_card_hash}`);
242
+ if (before.card_hash === before.pinned_card_hash) {
243
+ io.err("The live card is the one already pinned; re-pinning records a fresh approval.");
244
+ }
245
+ if (!invocation.yes) {
246
+ const answer = (await io.confirm("Type yes to pin the card above: ")).trim().toLowerCase();
247
+ if (answer !== "yes") {
248
+ io.err("Nothing was pinned.");
249
+ return "usage";
250
+ }
251
+ }
252
+ const result = await call("POST", `/agents/${encodeURIComponent(target)}/repin`);
253
+ if (!result.ok)
254
+ return report(io, result, connection);
255
+ const body = result.body;
256
+ if (invocation.json) {
257
+ io.out(JSON.stringify(body, null, 2));
258
+ return "ok";
259
+ }
260
+ const after = body.agent;
261
+ if (after === null) {
262
+ io.err("Re-pinned, but the agent could not be read back.");
263
+ return "ok";
264
+ }
265
+ io.err(`Pinned ${after.pinned_card_hash} (${after.card_signature_state}).`);
266
+ io.out(after.pinned_card_hash);
267
+ return "ok";
268
+ }
269
+ async function retireAgent(invocation, call, io, connection) {
270
+ const target = invocation.target;
271
+ if (target === undefined) {
272
+ io.err("`makine agents retire` needs an agent id.");
273
+ return "usage";
274
+ }
275
+ const result = await call("POST", `/agents/${encodeURIComponent(target)}/retire`);
276
+ if (!result.ok)
277
+ return report(io, result, connection);
278
+ const body = result.body;
279
+ if (invocation.json) {
280
+ io.out(JSON.stringify(body, null, 2));
281
+ return "ok";
282
+ }
283
+ io.err(`Retired ${body.remote_agent_id} at ${body.retired_at}.`);
284
+ if (body.note !== undefined)
285
+ io.err(body.note);
286
+ io.out(body.remote_agent_id);
287
+ return "ok";
288
+ }
289
+ function readNotice(body) {
290
+ const notice = body?.egress_notice;
291
+ return Array.isArray(notice)
292
+ ? notice.filter((line) => typeof line === "string")
293
+ : [];
294
+ }
295
+ function makeCall(connection) {
296
+ const send = connection.fetchImpl ?? fetch;
297
+ return async (method, path, payload) => {
298
+ let response;
299
+ try {
300
+ response = await send(`${connection.baseUrl.replace(/\/+$/, "")}${path}`, {
301
+ method,
302
+ redirect: "manual",
303
+ headers: {
304
+ authorization: `Bearer ${connection.apiKey}`,
305
+ ...(payload === undefined ? {} : { "content-type": "application/json" }),
306
+ },
307
+ ...(payload === undefined ? {} : { body: JSON.stringify(payload) }),
308
+ });
309
+ }
310
+ catch (error) {
311
+ return {
312
+ ok: false,
313
+ status: 0,
314
+ code: "unreachable",
315
+ message: `Could not reach Makine: ${error instanceof Error ? error.message : String(error)}`,
316
+ };
317
+ }
318
+ let parsed;
319
+ try {
320
+ parsed = await response.json();
321
+ }
322
+ catch {
323
+ parsed = undefined;
324
+ }
325
+ if (!response.ok) {
326
+ const error = parsed?.error ?? {};
327
+ return {
328
+ ok: false,
329
+ status: response.status,
330
+ code: error.code ?? "unexpected_error",
331
+ message: error.message ?? `Makine answered ${String(response.status)}.`,
332
+ ...(error.acknowledgement === undefined ? {} : { acknowledgement: error.acknowledgement }),
333
+ };
334
+ }
335
+ return { ok: true, body: parsed };
336
+ };
337
+ }
338
+ /** The route's own words first, then the one step that clears this refusal. */
339
+ function report(io, result, connection, host) {
340
+ io.err(result.message);
341
+ for (const line of result.acknowledgement ?? [])
342
+ io.err(`! ${line}`);
343
+ if (result.code === "sign_in_required") {
344
+ io.err(connection.explicitKey ? API_KEY_OVERRIDES_LOGIN_NOTE : SIGN_IN_NOTE);
345
+ }
346
+ if (result.code === "agent_host_not_allowed") {
347
+ io.err(`Approve it first: \`makine workflows approve-host ${host ?? "<host>"} --acknowledge-egress\`.`);
348
+ }
349
+ if (result.code === "agent_egress_acknowledgement_required") {
350
+ io.err("Re-run with --acknowledge-egress once you have read the lines above.");
351
+ }
352
+ // The route words this one as a plain `invalid_request`, so the flag that supplies the credential
353
+ // is named here rather than left to be guessed.
354
+ if (result.code === "invalid_request" && result.message.toLowerCase().includes("credential")) {
355
+ io.err("Pipe the credential in: `pbpaste | makine agents register ... --credential-stdin`.");
356
+ }
357
+ if (result.status === 0)
358
+ return "unavailable";
359
+ if (result.status === 401 || result.status === 403)
360
+ return "auth";
361
+ if (result.status >= 500)
362
+ return "unavailable";
363
+ return "refused";
364
+ }
365
+ export function isAgentsSubcommand(value) {
366
+ return AGENTS_SUBCOMMANDS.includes(value);
367
+ }
368
+ //# sourceMappingURL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,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7F,EAAE,CAAC,GAAG,CAAC,oFAAoF,CAAC,CAAC;IAC/F,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,MAAM,CAAC;IAClE,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,aAAa,CAAC;IAC/C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAQ,kBAAwC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `makine gov-id`: which cloud model vendors this workspace allows government-ID data to reach,
3
+ * and whether Makine hints when an input looks like it holds a national ID or tax number.
4
+ *
5
+ * `acknowledge` prints the warning first and sends the acknowledgement back on a second request,
6
+ * so nobody allows a vendor without the sentence that says what allowing it means.
7
+ */
8
+ export declare const GOV_ID_SUBCOMMANDS: readonly ["show", "acknowledge", "revoke", "detection"];
9
+ export type GovIdSubcommand = (typeof GOV_ID_SUBCOMMANDS)[number];
10
+ export interface GovIdInvocation {
11
+ subcommand: GovIdSubcommand;
12
+ /** `acknowledge` and `revoke`: the vendor, as a call's address resolves it. */
13
+ vendor?: string;
14
+ /** `detection`: `on` or `off`. */
15
+ detection?: string;
16
+ /** `acknowledge --yes` only: skips the confirmation. */
17
+ yes: boolean;
18
+ json: boolean;
19
+ }
20
+ export interface GovIdConnection {
21
+ baseUrl: string;
22
+ apiKey: string;
23
+ fetchImpl?: typeof fetch;
24
+ }
25
+ export interface GovIdIo {
26
+ out: (line: string) => void;
27
+ err: (line: string) => void;
28
+ /** Reads the confirmation for `acknowledge` without `--yes`. Defaults to stdin. */
29
+ confirm: (prompt: string) => Promise<string>;
30
+ }
31
+ export type GovIdOutcome = "ok" | "usage" | "refused" | "auth" | "unavailable";
32
+ export declare function runGovId(invocation: GovIdInvocation, connection: GovIdConnection, io: GovIdIo): Promise<GovIdOutcome>;
33
+ export declare function isGovIdSubcommand(value: string): value is GovIdSubcommand;
34
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/gov-id/command.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,yDAA0D,CAAC;AAE1F,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,eAAe,CAAC;IAC5B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,mFAAmF;IACnF,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC;AAW/E,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,eAAe,EAC3B,EAAE,EAAE,OAAO,GACV,OAAO,CAAC,YAAY,CAAC,CAiBvB;AA4LD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAEzE"}
@@ -0,0 +1,170 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * `makine gov-id`: which cloud model vendors this workspace allows government-ID data to reach,
4
+ * and whether Makine hints when an input looks like it holds a national ID or tax number.
5
+ *
6
+ * `acknowledge` prints the warning first and sends the acknowledgement back on a second request,
7
+ * so nobody allows a vendor without the sentence that says what allowing it means.
8
+ */
9
+ export const GOV_ID_SUBCOMMANDS = ["show", "acknowledge", "revoke", "detection"];
10
+ export async function runGovId(invocation, connection, io) {
11
+ try {
12
+ switch (invocation.subcommand) {
13
+ case "show":
14
+ return await showState(invocation, connection, io);
15
+ case "acknowledge":
16
+ return await acknowledgeVendor(invocation, connection, io);
17
+ case "revoke":
18
+ return await revokeVendor(invocation, connection, io);
19
+ case "detection":
20
+ return await setDetection(invocation, connection, io);
21
+ }
22
+ }
23
+ catch (error) {
24
+ const message = error instanceof Error ? error.message : String(error);
25
+ io.err(`Could not reach Makine: ${message}`);
26
+ return "unavailable";
27
+ }
28
+ }
29
+ async function showState(invocation, connection, io) {
30
+ const response = await call(connection, "GET", "/gov-id");
31
+ if (!response.ok) {
32
+ return await reportRefusal(response, io, "Could not read this workspace's settings");
33
+ }
34
+ const body = (await response.json());
35
+ if (invocation.json) {
36
+ io.out(JSON.stringify(body, null, 2));
37
+ return "ok";
38
+ }
39
+ const vendors = body.acknowledged_vendors;
40
+ if (vendors.length === 0) {
41
+ io.out("No cloud vendor may receive this workspace's government-ID data yet.");
42
+ io.out("A run of a contract that carries it stops and asks, naming the vendor it would call.");
43
+ }
44
+ else {
45
+ io.out("Government-ID data may be sent to:");
46
+ for (const entry of vendors)
47
+ io.out(` ${entry.vendor}\tallowed ${entry.acknowledged_at}`);
48
+ }
49
+ io.out("");
50
+ io.out(body.detection_enabled
51
+ ? "Hints are on: an input that looks like it holds a national ID or tax number is flagged beside the result."
52
+ : "Hints are off: Makine says nothing about what an input may contain. Nothing else changes.");
53
+ return "ok";
54
+ }
55
+ async function acknowledgeVendor(invocation, connection, io) {
56
+ const vendor = invocation.vendor?.trim().toLowerCase();
57
+ if (vendor === undefined || vendor.length === 0) {
58
+ io.err("`makine gov-id acknowledge` needs a vendor, the name a call's address resolves to: openai, anthropic, or a host name.");
59
+ return "usage";
60
+ }
61
+ // Sent without the acknowledgement first, so the warning printed here is the route's own text
62
+ // rather than a copy this command keeps in step by hand.
63
+ const warned = await call(connection, "POST", "/gov-id/acknowledgements", { vendor });
64
+ if (warned.ok) {
65
+ // A route that writes without the acknowledgement would be a rule change, not a shortcut.
66
+ io.err("Makine allowed the vendor without printing its warning; nothing was confirmed here.");
67
+ return "refused";
68
+ }
69
+ const warning = (await warned.json().catch(() => ({})));
70
+ if (warning.error?.code !== "gov_id_acknowledgement_required") {
71
+ io.err(`Could not read the warning: ${warning.error?.message ?? `the server answered ${warned.status}`}`);
72
+ if (warned.status === 401 || warned.status === 403)
73
+ return "auth";
74
+ if (warned.status >= 500)
75
+ return "unavailable";
76
+ return "refused";
77
+ }
78
+ io.err(warning.error.message ?? "");
79
+ io.err("");
80
+ if (!invocation.yes) {
81
+ const answer = (await io.confirm(`Type yes to allow government-ID data to reach ${vendor}: `))
82
+ .trim()
83
+ .toLowerCase();
84
+ if (answer !== "yes") {
85
+ io.err(`${vendor} was left unallowed.`);
86
+ return "usage";
87
+ }
88
+ }
89
+ const response = await call(connection, "POST", "/gov-id/acknowledgements", {
90
+ vendor,
91
+ acknowledged: true,
92
+ });
93
+ if (!response.ok)
94
+ return await reportRefusal(response, io, `Could not allow ${vendor}`);
95
+ const body = (await response.json());
96
+ if (invocation.json) {
97
+ io.out(JSON.stringify(body, null, 2));
98
+ return "ok";
99
+ }
100
+ io.out(`${body.vendor} may now receive this workspace's government-ID data. Runs that were waiting on ` +
101
+ `this will go through from now on; revoke it with \`makine gov-id revoke ${body.vendor}\`.`);
102
+ return "ok";
103
+ }
104
+ async function revokeVendor(invocation, connection, io) {
105
+ const vendor = invocation.vendor?.trim().toLowerCase();
106
+ if (vendor === undefined || vendor.length === 0) {
107
+ io.err("`makine gov-id revoke` needs a vendor. `makine gov-id show` lists what is allowed.");
108
+ return "usage";
109
+ }
110
+ const response = await call(connection, "DELETE", `/gov-id/acknowledgements/${encodeURIComponent(vendor)}`);
111
+ if (!response.ok)
112
+ return await reportRefusal(response, io, `Could not revoke ${vendor}`);
113
+ const body = (await response.json());
114
+ if (invocation.json) {
115
+ io.out(JSON.stringify(body, null, 2));
116
+ return "ok";
117
+ }
118
+ io.out(`${body.vendor} may no longer receive this workspace's government-ID data. The next run of a ` +
119
+ "contract that carries it will stop and ask again.");
120
+ return "ok";
121
+ }
122
+ async function setDetection(invocation, connection, io) {
123
+ const choice = invocation.detection?.trim().toLowerCase();
124
+ if (choice !== "on" && choice !== "off") {
125
+ io.err("`makine gov-id detection` needs `on` or `off`.");
126
+ return "usage";
127
+ }
128
+ const response = await call(connection, "POST", "/gov-id/detection", {
129
+ enabled: choice === "on",
130
+ });
131
+ if (!response.ok)
132
+ return await reportRefusal(response, io, `Could not switch hints ${choice}`);
133
+ const body = (await response.json());
134
+ if (invocation.json) {
135
+ io.out(JSON.stringify(body, null, 2));
136
+ return "ok";
137
+ }
138
+ io.out(body.detection_enabled
139
+ ? "Hints are on. An input that looks like it holds a national ID or tax number is flagged beside the result."
140
+ : "Hints are off. Nothing else changes: which vendors may receive government-ID data is a separate setting, and still applies.");
141
+ return "ok";
142
+ }
143
+ async function call(connection, method, path, payload) {
144
+ const send = connection.fetchImpl ?? fetch;
145
+ return send(`${connection.baseUrl.replace(/\/+$/, "")}${path}`, {
146
+ method,
147
+ redirect: "manual",
148
+ headers: {
149
+ authorization: `Bearer ${connection.apiKey}`,
150
+ ...(payload === undefined ? {} : { "content-type": "application/json" }),
151
+ },
152
+ ...(payload === undefined ? {} : { body: JSON.stringify(payload) }),
153
+ });
154
+ }
155
+ /** The route's own words, so a refusal reads the same here as it does in the dashboard. */
156
+ async function reportRefusal(response, io, prefix) {
157
+ const body = (await response.json().catch(() => ({})));
158
+ const code = body.error?.code;
159
+ const message = body.error?.message ?? `the server answered ${response.status}`;
160
+ io.err(`${prefix}: ${code === undefined ? message : `${code} — ${message}`}`);
161
+ if (response.status === 401 || response.status === 403)
162
+ return "auth";
163
+ if (response.status >= 500)
164
+ return "unavailable";
165
+ return "refused";
166
+ }
167
+ export function isGovIdSubcommand(value) {
168
+ return GOV_ID_SUBCOMMANDS.includes(value);
169
+ }
170
+ //# sourceMappingURL=command.js.map