primcli 3.0.0-preview.3 → 3.0.0-preview.30
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 +110 -39
- package/bin/run.js +21 -2
- package/dist/api-command-JSxKMsEp.js +67356 -0
- package/dist/cli-command-names-A9nkSBH6.js +380 -0
- package/dist/cli-config-BEo5mbDK.js +1750 -0
- package/dist/help-inputs-NGARVZL_.js +109 -0
- package/dist/{json-output-DWrJMakZ.js → json-output-BMZrLH47.js} +25 -6
- package/dist/{listen-background-C0F9gNDD.js → listen-background-DyBYca28.js} +323 -36
- package/dist/{machine-session-BG4getHB.js → machine-session-CDLKmg8U.js} +10 -10
- package/dist/{notify-session-8Jv4jJzI.js → notify-session-BeYhiOD0.js} +71 -32
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +1 -1
- package/dist/oclif/command-not-found.js +133 -0
- package/dist/oclif/command-stdin.js +9 -0
- package/dist/oclif/help.js +82 -17
- package/dist/oclif/index.js +5814 -105060
- package/dist/oclif/listen-supervisor.js +1 -1
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +4 -4
- package/dist/oclif/root-signup-hint.js +16 -16
- package/dist/receiver.d.ts +1 -1
- package/dist/{repeats-Dj_o6c-X-BKHiZsYv.js → repeats-Dj_o6c-X-r9r6uQOb.js} +15081 -14000
- package/dist/retry-ids-04ZPJCZY.js +59 -0
- package/dist/{scoped-chat-_AEpylPV.js → scoped-chat-BqmFQ1yz.js} +1 -1
- package/dist/{shared-mail-watch-BAPMsFNv.js → shared-mail-watch-DdtgJOrV.js} +12 -0
- package/dist/{signal-command-CBHAR7zj.js → signal-command-CCfFQ72M.js} +19 -9
- package/dist/skills/primitive-connect/SKILL.md +5 -6
- package/dist/skills/primitive-connect/references/access-passes.md +32 -0
- package/dist/skills/primitive-connect/references/contact-requests.md +4 -4
- package/dist/skills/primitive-connect/references/contacts.md +1 -1
- package/dist/skills/primitive-connect.json +6 -5
- package/man/primitive.1 +27 -12
- package/package.json +35 -13
- package/dist/api-command-DWjtyqH9.js +0 -3675
- package/dist/cli-config-Ms_0vNjq.js +0 -949
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { r as retryIdFields } from "./retry-ids-04ZPJCZY.js";
|
|
2
|
+
import { Errors } from "@oclif/core";
|
|
3
|
+
// src/oclif/required-body-fields.ts
|
|
4
|
+
function object(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function jsonPath(parts) {
|
|
8
|
+
return parts.reduce((path, part) => typeof part === "number" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(part) ? `${path}[${JSON.stringify(part)}]` : `${path}.${part}`, "$");
|
|
9
|
+
}
|
|
10
|
+
/** Only exclude a union branch when a supplied literal contradicts it. */
|
|
11
|
+
function compatible(schema, value) {
|
|
12
|
+
if (!object(schema) || !object(value)) return true;
|
|
13
|
+
const properties = object(schema.properties) ? schema.properties : {};
|
|
14
|
+
for (const [name, property] of Object.entries(properties)) {
|
|
15
|
+
if (!Object.hasOwn(value, name) || !object(property)) continue;
|
|
16
|
+
const literal = value[name];
|
|
17
|
+
if (literal === void 0 || literal !== null && typeof literal === "object") continue;
|
|
18
|
+
if (Object.hasOwn(property, "const") && !object(property.const) && !Array.isArray(property.const) && property.const !== literal) return false;
|
|
19
|
+
if (Array.isArray(property.enum) && !property.enum.includes(literal)) return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Report missing properties, not type or permission failures. Alternative
|
|
25
|
+
* schemas contribute only omissions shared by every still-possible branch.
|
|
26
|
+
*/
|
|
27
|
+
function missingBodyFields(schema, body, flags, required) {
|
|
28
|
+
if (body === void 0 && !required) return [];
|
|
29
|
+
function visit(node, value, path) {
|
|
30
|
+
if (!object(node)) return [];
|
|
31
|
+
const missing = [];
|
|
32
|
+
if (object(value)) {
|
|
33
|
+
const names = Array.isArray(node.required) ? node.required : [];
|
|
34
|
+
for (const name of names) {
|
|
35
|
+
if (typeof name !== "string") continue;
|
|
36
|
+
if (Object.hasOwn(value, name) && value[name] !== void 0) continue;
|
|
37
|
+
missing.push({
|
|
38
|
+
field: name,
|
|
39
|
+
flag: path.length === 0 ? flags.get(name) ?? null : null,
|
|
40
|
+
json_path: jsonPath([...path, name])
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (object(node.properties)) {
|
|
44
|
+
for (const [name, property] of Object.entries(node.properties)) if (Object.hasOwn(value, name) && value[name] !== void 0) missing.push(...visit(property, value[name], [...path, name]));
|
|
45
|
+
}
|
|
46
|
+
} else if (Array.isArray(value)) for (const [index, item] of value.entries()) missing.push(...visit(node.items, item, [...path, index]));
|
|
47
|
+
if (Array.isArray(node.allOf)) for (const branch of node.allOf) missing.push(...visit(branch, value, path));
|
|
48
|
+
for (const union of [node.oneOf, node.anyOf]) {
|
|
49
|
+
if (!Array.isArray(union)) continue;
|
|
50
|
+
const branches = union.filter((branch) => compatible(branch, value)).map((branch) => visit(branch, value, path));
|
|
51
|
+
if (branches.length === 0) continue;
|
|
52
|
+
missing.push(...branches[0].filter((field) => branches.every((branch) => branch.some((other) => other.json_path === field.json_path))));
|
|
53
|
+
}
|
|
54
|
+
return missing;
|
|
55
|
+
}
|
|
56
|
+
const missing = visit(schema, body === void 0 ? {} : body, []);
|
|
57
|
+
return [...new Map(missing.map((field) => [field.json_path, field])).values()];
|
|
58
|
+
}
|
|
59
|
+
function assertRequiredBodyFields(schema, body, flags, required) {
|
|
60
|
+
const missing = missingBodyFields(schema, body, flags, required);
|
|
61
|
+
if (missing.length === 0 && (!required || body !== void 0)) return;
|
|
62
|
+
const fields = missing.length ? missing : [{
|
|
63
|
+
field: "body",
|
|
64
|
+
flag: null,
|
|
65
|
+
json_path: "$"
|
|
66
|
+
}];
|
|
67
|
+
const message = `Missing required fields: ${fields.map((field) => field.flag ?? field.json_path).join(", ")}. Supply the fields as flags where available, or use --raw-body / --body-file JSON.`;
|
|
68
|
+
throw Object.assign(new Errors.CLIError(message, { exit: 2 }), {
|
|
69
|
+
code: "usage_error",
|
|
70
|
+
details: { missing: fields }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// src/oclif/help-inputs.ts
|
|
74
|
+
const HELP_GROUPS = [
|
|
75
|
+
"required",
|
|
76
|
+
"command",
|
|
77
|
+
"common"
|
|
78
|
+
];
|
|
79
|
+
const HELP_GROUP_HEADERS = {
|
|
80
|
+
required: "REQUIRED INPUTS",
|
|
81
|
+
command: "COMMAND OPTIONS",
|
|
82
|
+
common: "COMMON FLAGS"
|
|
83
|
+
};
|
|
84
|
+
const COMMON_FLAGS = /* @__PURE__ */ new Set([
|
|
85
|
+
"api-key",
|
|
86
|
+
"api-base-url",
|
|
87
|
+
"json",
|
|
88
|
+
"time",
|
|
89
|
+
"raw-body",
|
|
90
|
+
"envelope",
|
|
91
|
+
"output",
|
|
92
|
+
"idempotency-key",
|
|
93
|
+
"step-up-token"
|
|
94
|
+
]);
|
|
95
|
+
function helpFlagGroup(name, flag, inputs, flagNames) {
|
|
96
|
+
if (flag.required || flag.exactlyOne?.length || inputs?.requiredFlags.includes(name)) return "required";
|
|
97
|
+
if (COMMON_FLAGS.has(name) || name === "body-file" && flagNames.has("raw-body")) return "common";
|
|
98
|
+
return "command";
|
|
99
|
+
}
|
|
100
|
+
function operationHelpInputs(operation, bodyFlagToProperty, positionalFlag) {
|
|
101
|
+
const propertyFlags = new Map([...bodyFlagToProperty].map(([flag, property]) => [property, `--${flag}`]));
|
|
102
|
+
const generated = new Set(retryIdFields(operation.requestSchema));
|
|
103
|
+
const missing = operation.bodyRequired || generated.size > 0 ? missingBodyFields(operation.requestSchema, {}, propertyFlags, true).filter((field) => !generated.has(field.field)) : [];
|
|
104
|
+
return {
|
|
105
|
+
requiredFlags: [...missing.flatMap((field) => field.flag ? [field.flag.slice(2)] : []), ...positionalFlag ? [positionalFlag] : []],
|
|
106
|
+
requiredJsonFields: operation.bodyRequired && missing.length === 0 && generated.size === 0 ? ["$"] : missing.filter((field) => field.flag === null).map((field) => field.json_path)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export { assertRequiredBodyFields as a, operationHelpInputs as i, HELP_GROUP_HEADERS as n, helpFlagGroup as r, HELP_GROUPS as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as takeRetryIds } from "./retry-ids-04ZPJCZY.js";
|
|
1
2
|
import { Flags } from "@oclif/core";
|
|
2
3
|
import { format } from "node:util";
|
|
3
4
|
// src/oclif/json-output.ts
|
|
@@ -145,11 +146,18 @@ function errorExitCode(error) {
|
|
|
145
146
|
function isExitSignal(error) {
|
|
146
147
|
return error?.code === "EEXIT";
|
|
147
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The `error` a `--json` document carries for a thrown error: its message,
|
|
151
|
+
* and its `code` and `details` when it has them (a refusal the CLI makes in
|
|
152
|
+
* an API error's shape, such as a send without mail:send).
|
|
153
|
+
*/
|
|
148
154
|
function thrownErrorBody(error) {
|
|
149
155
|
if (error instanceof Error) {
|
|
150
156
|
const body = { message: error.message };
|
|
151
157
|
const code = error.code;
|
|
152
158
|
if (typeof code === "string" && code !== "EEXIT") body.code = code;
|
|
159
|
+
const details = error.details;
|
|
160
|
+
if (isPlainObject(details)) body.details = details;
|
|
153
161
|
return body;
|
|
154
162
|
}
|
|
155
163
|
return { message: String(error) };
|
|
@@ -159,13 +167,25 @@ function thrownErrorBody(error) {
|
|
|
159
167
|
* what it wrote to stdout and stderr and how it ended.
|
|
160
168
|
*/
|
|
161
169
|
function composeJsonDocument(input) {
|
|
170
|
+
const document = composeResult(input);
|
|
171
|
+
if (!input.retryIds?.length) return document;
|
|
172
|
+
return {
|
|
173
|
+
...isPlainObject(document) ? document : { data: document },
|
|
174
|
+
cli_retry_ids: input.retryIds
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function composeResult(input) {
|
|
162
178
|
const { errorPayload, warnings: stderrLines } = summarizeStderr(input.stderr);
|
|
163
179
|
const failed = input.exitCode !== 0;
|
|
164
180
|
let warnings = stderrLines;
|
|
165
181
|
if (!failed && errorPayload !== null) warnings = [...warnings, JSON.stringify(errorPayload)];
|
|
166
182
|
const failure = () => {
|
|
167
183
|
if (errorPayload !== null) return errorPayload;
|
|
168
|
-
if (input.thrown && !isExitSignal(input.thrown.error))
|
|
184
|
+
if (input.thrown && !isExitSignal(input.thrown.error)) {
|
|
185
|
+
const body = thrownErrorBody(input.thrown.error);
|
|
186
|
+
if (body.code === void 0) body.code = errorExitCode(input.thrown.error) === 2 ? "usage_error" : "cli_error";
|
|
187
|
+
return body;
|
|
188
|
+
}
|
|
169
189
|
return { message: warnings.at(-1) ?? `The command failed with exit code ${input.exitCode}.` };
|
|
170
190
|
};
|
|
171
191
|
const text = input.stdout.trim();
|
|
@@ -201,9 +221,7 @@ function composeJsonDocument(input) {
|
|
|
201
221
|
if (merged.exit_code === void 0) merged.exit_code = input.exitCode;
|
|
202
222
|
}
|
|
203
223
|
if (warnings.length > 0) {
|
|
204
|
-
|
|
205
|
-
if (existing === void 0 || existing === null) merged.warnings = warnings;
|
|
206
|
-
else if (Array.isArray(existing)) merged.warnings = [...existing, ...warnings.filter((warning) => !existing.includes(warning))];
|
|
224
|
+
if (merged.warnings === void 0 || merged.warnings === null) merged.warnings = warnings;
|
|
207
225
|
else merged.cli_warnings = warnings;
|
|
208
226
|
}
|
|
209
227
|
return merged;
|
|
@@ -233,7 +251,8 @@ function guardJsonOutput(cls) {
|
|
|
233
251
|
exitCode: thrown ? isExitSignal(thrown.error) ? errorExitCode(thrown.error) ?? 0 : errorExitCode(thrown.error) ?? (typeof process.exitCode === "number" && process.exitCode !== 0 ? process.exitCode : 1) : typeof process.exitCode === "number" ? process.exitCode : 0,
|
|
234
252
|
stderr: capture.stderr,
|
|
235
253
|
stdout: capture.stdout.join(""),
|
|
236
|
-
thrown
|
|
254
|
+
thrown,
|
|
255
|
+
retryIds: takeRetryIds(this)
|
|
237
256
|
});
|
|
238
257
|
console.log(JSON.stringify(document, null, 2));
|
|
239
258
|
if (thrown) {
|
|
@@ -324,4 +343,4 @@ function guardJsonOutputCommands(commands) {
|
|
|
324
343
|
if (flags && "json" in flags || enableJsonFlag === true) guardJsonOutput(command);
|
|
325
344
|
}
|
|
326
345
|
}
|
|
327
|
-
export { runStreamingJson as i,
|
|
346
|
+
export { runStreamingJson as a, jsonOutputRequested as i, captureOutput as n, thrownErrorBody as o, guardJsonOutputCommands as r, JSON_OUTPUT_FLAG as t };
|