@miosa/cli 1.0.60 → 1.0.62
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/dist/bin/miosa.js +1 -0
- package/dist/bin/miosa.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -3
- package/dist/client.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +46 -0
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/capabilities.d.ts.map +1 -1
- package/dist/commands/capabilities.js +96 -0
- package/dist/commands/capabilities.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +3 -0
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/connectors.d.ts +3 -0
- package/dist/commands/connectors.d.ts.map +1 -0
- package/dist/commands/connectors.js +172 -0
- package/dist/commands/connectors.js.map +1 -0
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +66 -0
- package/dist/commands/sandbox.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { client, enc, runAction } from "./enterprise-util.js";
|
|
4
|
+
import { printJson } from "./util.js";
|
|
5
|
+
import { renderTable } from "../ui/table.js";
|
|
6
|
+
import { spin } from "../ui/spinner.js";
|
|
7
|
+
export function register(program) {
|
|
8
|
+
const connectors = program
|
|
9
|
+
.command("connectors")
|
|
10
|
+
.alias("provider")
|
|
11
|
+
.description("Manage MIOSA Connect provider connectors and runtime tokens");
|
|
12
|
+
connectors
|
|
13
|
+
.command("list")
|
|
14
|
+
.description("List Connect provider connectors")
|
|
15
|
+
.option("--json", "Output as JSON")
|
|
16
|
+
.action((opts) => runAction(async () => {
|
|
17
|
+
const spinner = isJson(opts) ? null : spin("Fetching connectors...");
|
|
18
|
+
const raw = await client().apiGet("/api/v1/connect/connectors");
|
|
19
|
+
spinner?.stop();
|
|
20
|
+
const rows = unwrapList(raw);
|
|
21
|
+
if (isJson(opts)) {
|
|
22
|
+
printJson(rows);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (rows.length === 0) {
|
|
26
|
+
console.log(chalk.dim("No connectors configured."));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
renderTable(rows, [
|
|
30
|
+
{ header: "UID", key: (row) => row.uid ?? row.id ?? "", width: 34 },
|
|
31
|
+
{ header: "PROVIDER", key: (row) => row.provider ?? "", width: 14 },
|
|
32
|
+
{ header: "TYPE", key: (row) => row.type ?? "", width: 12 },
|
|
33
|
+
{ header: "STATUS", key: (row) => row.status ?? "", width: 12 },
|
|
34
|
+
]);
|
|
35
|
+
}));
|
|
36
|
+
connectors
|
|
37
|
+
.command("show <connector>")
|
|
38
|
+
.description("Show a Connect provider connector")
|
|
39
|
+
.option("--json", "Output as JSON")
|
|
40
|
+
.action((connector, opts) => runAction(async () => {
|
|
41
|
+
const raw = await client().apiGet(`/api/v1/connect/connectors/${enc(connector)}`);
|
|
42
|
+
printMaybeJson(unwrapData(raw), opts);
|
|
43
|
+
}));
|
|
44
|
+
connectors
|
|
45
|
+
.command("create <provider>")
|
|
46
|
+
.description("Create an API-key backed Connect provider connector")
|
|
47
|
+
.option("--type <type>", "Connector type", "api-key")
|
|
48
|
+
.option("--name <name>", "Stable connector name, e.g. workspace-claude")
|
|
49
|
+
.option("--uid <uid>", "Full connector UID, e.g. anthropic/workspace-claude")
|
|
50
|
+
.option("--scope <scope>", "Credential scope: tenant, workspace, user")
|
|
51
|
+
.option("--workspace <id>", "Workspace ID for workspace-scoped connector")
|
|
52
|
+
.option("--value <value>", "Provider credential value")
|
|
53
|
+
.option("--stdin", "Read provider credential from stdin")
|
|
54
|
+
.option("--file <path>", "Read provider credential from a local file")
|
|
55
|
+
.option("--json", "Output as JSON")
|
|
56
|
+
.action((provider, opts) => runAction(async () => {
|
|
57
|
+
const credentialValue = await readCredentialValue(opts);
|
|
58
|
+
const uid = opts.uid ?? `${provider}/${opts.name ?? "default"}`;
|
|
59
|
+
const body = {
|
|
60
|
+
provider,
|
|
61
|
+
type: normalizeMode(opts.type ?? "api-key"),
|
|
62
|
+
uid,
|
|
63
|
+
scope: opts.scope ?? (opts.workspace ? "workspace" : "tenant"),
|
|
64
|
+
workspace_id: opts.workspace,
|
|
65
|
+
credential: {
|
|
66
|
+
field: "api_key",
|
|
67
|
+
value: credentialValue,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const spinner = isJson(opts) ? null : spin(`Creating connector ${uid}...`);
|
|
71
|
+
const raw = await client().apiPost("/api/v1/connect/connectors", body);
|
|
72
|
+
spinner?.succeed(`Created connector ${uid}`);
|
|
73
|
+
printMaybeJson(unwrapData(raw), opts);
|
|
74
|
+
}));
|
|
75
|
+
connectors
|
|
76
|
+
.command("token <connector>")
|
|
77
|
+
.description("Request a short-lived runtime provider token")
|
|
78
|
+
.option("--subject <subject>", "app, user:<id>, or jwt-bearer:<sub>", "app")
|
|
79
|
+
.option("--installation-id <id>", "Provider installation ID")
|
|
80
|
+
.option("--scope <scope>", "Provider scope. Repeatable.", collect, [])
|
|
81
|
+
.option("--audience <audience>", "Provider audience. Repeatable.", collect, [])
|
|
82
|
+
.option("--validity-buffer-ms <ms>", "Refresh buffer in milliseconds")
|
|
83
|
+
.option("--json", "Output as JSON")
|
|
84
|
+
.action((connector, opts) => runAction(async () => {
|
|
85
|
+
const body = {
|
|
86
|
+
subject: parseSubject(opts.subject ?? "app"),
|
|
87
|
+
installation_id: opts.installationId,
|
|
88
|
+
scopes: opts.scope?.length ? opts.scope : undefined,
|
|
89
|
+
audience: opts.audience?.length ? opts.audience : undefined,
|
|
90
|
+
validity_buffer_ms: opts.validityBufferMs
|
|
91
|
+
? Number.parseInt(opts.validityBufferMs, 10)
|
|
92
|
+
: undefined,
|
|
93
|
+
};
|
|
94
|
+
const raw = await client().apiPost(`/api/v1/connect/token/${enc(connector)}`, body);
|
|
95
|
+
printMaybeJson(unwrapData(raw), opts);
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
function collect(value, previous) {
|
|
99
|
+
previous.push(value);
|
|
100
|
+
return previous;
|
|
101
|
+
}
|
|
102
|
+
function parseSubject(value) {
|
|
103
|
+
if (value === "app")
|
|
104
|
+
return { type: "app" };
|
|
105
|
+
if (value.startsWith("user:"))
|
|
106
|
+
return { type: "user", id: value.slice(5) };
|
|
107
|
+
if (value.startsWith("jwt-bearer:")) {
|
|
108
|
+
return { type: "jwt-bearer", sub: value.slice("jwt-bearer:".length) };
|
|
109
|
+
}
|
|
110
|
+
throw new Error("Use --subject app, user:<id>, or jwt-bearer:<sub>");
|
|
111
|
+
}
|
|
112
|
+
async function readCredentialValue(opts) {
|
|
113
|
+
const sources = [opts.value, opts.stdin ? "stdin" : undefined, opts.file].filter(Boolean);
|
|
114
|
+
if (sources.length !== 1) {
|
|
115
|
+
throw new Error("Provide exactly one of --value, --stdin, or --file");
|
|
116
|
+
}
|
|
117
|
+
const raw = opts.value ??
|
|
118
|
+
(opts.file ? fs.readFileSync(opts.file, "utf8") : await readStdin());
|
|
119
|
+
const value = raw.trim();
|
|
120
|
+
if (!value)
|
|
121
|
+
throw new Error("Credential value cannot be empty");
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
async function readStdin() {
|
|
125
|
+
const chunks = [];
|
|
126
|
+
for await (const chunk of process.stdin) {
|
|
127
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
128
|
+
}
|
|
129
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
130
|
+
}
|
|
131
|
+
function normalizeMode(value) {
|
|
132
|
+
return value.replaceAll("_", "-");
|
|
133
|
+
}
|
|
134
|
+
function unwrapData(raw) {
|
|
135
|
+
if (raw && typeof raw === "object" && "data" in raw) {
|
|
136
|
+
return raw.data;
|
|
137
|
+
}
|
|
138
|
+
return raw;
|
|
139
|
+
}
|
|
140
|
+
function unwrapList(raw) {
|
|
141
|
+
const data = unwrapData(raw);
|
|
142
|
+
return Array.isArray(data) ? data : [];
|
|
143
|
+
}
|
|
144
|
+
function printMaybeJson(value, opts) {
|
|
145
|
+
if (isJson(opts)) {
|
|
146
|
+
printJson(value);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
printJson(value);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (value && typeof value === "object") {
|
|
154
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
155
|
+
console.log(`${chalk.bold(key.padEnd(18))} ${formatValue(entry)}`);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
console.log(String(value ?? ""));
|
|
160
|
+
}
|
|
161
|
+
function formatValue(value) {
|
|
162
|
+
if (value === null || value === undefined || value === "")
|
|
163
|
+
return chalk.dim("-");
|
|
164
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
165
|
+
return String(value);
|
|
166
|
+
}
|
|
167
|
+
return JSON.stringify(value);
|
|
168
|
+
}
|
|
169
|
+
function isJson(opts) {
|
|
170
|
+
return opts.json === true;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=connectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../../src/commands/connectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAoB,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAgCxC,MAAM,UAAU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I,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC5E,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,OAAO;IACT,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACzF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,MAAM,CAAC,IAAiB;IAC/B,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/commands/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2DzC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/commands/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2DzC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAksE/C"}
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -360,6 +360,7 @@ export function register(program) {
|
|
|
360
360
|
process.exitCode = 1;
|
|
361
361
|
}
|
|
362
362
|
}));
|
|
363
|
+
registerSandboxConnectorCommands(sandbox);
|
|
363
364
|
// prompt — invoke an in-Sandbox AI agent CLI (mirrors `box prompt`).
|
|
364
365
|
// Implemented as `exec claude/codex/claude-code <instruction>`.
|
|
365
366
|
sandbox
|
|
@@ -367,6 +368,8 @@ export function register(program) {
|
|
|
367
368
|
.description("Run an in-Sandbox AI agent (claude/codex) with the given instruction")
|
|
368
369
|
.option("--provider <name>", "AI provider: claude (default), codex, claude-code")
|
|
369
370
|
.option("--model <name>", "Provider-specific model name")
|
|
371
|
+
.option("--connector <uid>", "MIOSA Connect connector UID to preflight before running the agent")
|
|
372
|
+
.option("--preflight", "Verify the Sandbox has the requested provider connector before exec")
|
|
370
373
|
.option("--cwd <path>", "Working directory inside the Sandbox")
|
|
371
374
|
.option("--timeout <sec>", "Exec timeout in seconds", parseIntegerOption)
|
|
372
375
|
.option("--json", "Output as JSON")
|
|
@@ -376,6 +379,14 @@ export function register(program) {
|
|
|
376
379
|
if (!allowedProviders.includes(provider)) {
|
|
377
380
|
throw new Error(`Unsupported provider "${provider}". Use: ${allowedProviders.join(", ")}`);
|
|
378
381
|
}
|
|
382
|
+
if (opts.connector || opts.preflight) {
|
|
383
|
+
await preflightSandboxConnector(id, {
|
|
384
|
+
provider,
|
|
385
|
+
connector: opts.connector,
|
|
386
|
+
model: opts.model,
|
|
387
|
+
cwd: opts.cwd,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
379
390
|
const instruction = words.join(" ");
|
|
380
391
|
const modelFlag = opts.model
|
|
381
392
|
? ` --model ${`'${opts.model.replace(/'/g, "'\\''")}'`}`
|
|
@@ -1344,6 +1355,53 @@ export function register(program) {
|
|
|
1344
1355
|
.option("--json", "Output as JSON")
|
|
1345
1356
|
.action((id, opts) => runAction(() => getAndPrint(`/sandbox-templates/${enc(id)}`, opts)));
|
|
1346
1357
|
}
|
|
1358
|
+
function registerSandboxConnectorCommands(sandbox) {
|
|
1359
|
+
const connectors = sandbox
|
|
1360
|
+
.command("connectors")
|
|
1361
|
+
.alias("providers")
|
|
1362
|
+
.description("Manage brokered provider connector bindings for a Sandbox");
|
|
1363
|
+
connectors
|
|
1364
|
+
.command("list <sandbox-id>")
|
|
1365
|
+
.description("List provider connectors bound to a Sandbox")
|
|
1366
|
+
.option("--json", "Output as JSON")
|
|
1367
|
+
.action((id, opts) => runAction(async () => {
|
|
1368
|
+
const raw = unwrap(await client().apiGet(apiPath(`/sandboxes/${enc(id)}/connectors`)));
|
|
1369
|
+
printValue(raw, opts);
|
|
1370
|
+
}));
|
|
1371
|
+
connectors
|
|
1372
|
+
.command("attach <sandbox-id> <connector>")
|
|
1373
|
+
.description("Attach a connector to a Sandbox as brokered env")
|
|
1374
|
+
.requiredOption("--env <name>", "Environment variable name, e.g. ANTHROPIC_API_KEY")
|
|
1375
|
+
.option("--mode <mode>", "brokered-env or plain-env", "brokered-env")
|
|
1376
|
+
.option("--installation-id <id>", "Provider installation ID")
|
|
1377
|
+
.option("--json", "Output as JSON")
|
|
1378
|
+
.action((id, connector, opts) => runAction(async () => {
|
|
1379
|
+
const body = {
|
|
1380
|
+
connector,
|
|
1381
|
+
env_name: opts.env,
|
|
1382
|
+
mode: normalizeConnectorMode(opts.mode ?? "brokered-env"),
|
|
1383
|
+
installation_id: opts.installationId,
|
|
1384
|
+
};
|
|
1385
|
+
const raw = unwrap(await client().apiPost(apiPath(`/sandboxes/${enc(id)}/connectors`), body));
|
|
1386
|
+
printValue(raw, opts);
|
|
1387
|
+
}));
|
|
1388
|
+
connectors
|
|
1389
|
+
.command("detach <sandbox-id> <binding-id-or-connector>")
|
|
1390
|
+
.description("Detach a connector binding from a Sandbox")
|
|
1391
|
+
.option("--json", "Output as JSON")
|
|
1392
|
+
.action((id, binding, opts) => runAction(() => deleteAndPrint(`/sandboxes/${enc(id)}/connectors/${enc(binding)}`, opts)));
|
|
1393
|
+
connectors
|
|
1394
|
+
.command("sync <sandbox-id>")
|
|
1395
|
+
.description("Sync connector placeholder env vars into a running Sandbox")
|
|
1396
|
+
.option("--json", "Output as JSON")
|
|
1397
|
+
.action((id, opts) => runAction(async () => {
|
|
1398
|
+
const raw = unwrap(await client().apiPost(apiPath(`/sandboxes/${enc(id)}/connectors/sync`), {}));
|
|
1399
|
+
printValue(raw, opts);
|
|
1400
|
+
}));
|
|
1401
|
+
}
|
|
1402
|
+
function normalizeConnectorMode(value) {
|
|
1403
|
+
return value.replaceAll("_", "-");
|
|
1404
|
+
}
|
|
1347
1405
|
// ── sandbox ssh implementation ─────────────────────────────────────────────
|
|
1348
1406
|
//
|
|
1349
1407
|
// Protocol:
|
|
@@ -2304,6 +2362,14 @@ async function resumeSandboxAndPrint(sandboxId, opts) {
|
|
|
2304
2362
|
throw err;
|
|
2305
2363
|
}
|
|
2306
2364
|
}
|
|
2365
|
+
async function preflightSandboxConnector(sandboxId, params) {
|
|
2366
|
+
await client().apiPost(apiPath(`/sandboxes/${enc(sandboxId)}/connectors/preflight`), {
|
|
2367
|
+
provider: params.provider,
|
|
2368
|
+
connector: params.connector,
|
|
2369
|
+
model: params.model,
|
|
2370
|
+
cwd: params.cwd,
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2307
2373
|
async function postSandboxExecAndPrint(sandboxId, opts, body) {
|
|
2308
2374
|
try {
|
|
2309
2375
|
const value = unwrap(await client().apiPost(apiPath(`/sandboxes/${enc(sandboxId)}/exec`), body));
|