openany-cli-dev 0.1.3 → 0.1.5
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 +10 -0
- package/package.json +1 -1
- package/skills/openany-provider/SKILL.md +8 -4
- package/skills/openany-provider/SKILL.zh-CN.md +8 -4
- package/skills/openany-provider/references/apis.md +2 -0
- package/skills/openany-provider/references/apis.zh-CN.md +2 -0
- package/skills/openany-provider/references/application.md +1 -1
- package/skills/openany-provider/references/application.zh-CN.md +1 -1
- package/skills/openany-provider/references/connections.md +4 -4
- package/skills/openany-provider/references/connections.zh-CN.md +4 -4
- package/skills/openany-provider/references/hermes-auto-files.md +121 -0
- package/skills/openany-provider/references/hermes-files.md +133 -0
- package/skills/openany-provider/references/imports.md +2 -0
- package/skills/openany-provider/references/imports.zh-CN.md +2 -0
- package/skills/openany-provider/references/login.md +3 -3
- package/skills/openany-provider/references/login.zh-CN.md +3 -3
- package/skills/openany-provider/references/model-import.md +1 -1
- package/skills/openany-provider/references/model-import.zh-CN.md +1 -1
- package/skills/openany-provider/references/models.md +3 -1
- package/skills/openany-provider/references/models.zh-CN.md +3 -1
- package/skills/openany-provider/references/publishing.md +7 -3
- package/skills/openany-provider/references/publishing.zh-CN.md +6 -4
- package/skills/openany-provider/references/reviews.md +2 -0
- package/skills/openany-provider/references/reviews.zh-CN.md +2 -0
- package/skills/openany-provider/templates/provider-agent-api-template.json +1 -1
- package/skills/openany-provider/templates/seller-agent-api-import-template.json +1 -1
- package/src/artifact-collector.js +72 -0
- package/src/artifact-files.js +45 -0
- package/src/cli.js +7 -0
- package/src/hermes-delivery.js +228 -0
- package/src/http.js +7 -0
- package/src/poll-artifacts.js +48 -0
- package/src/provider-api-import-v2.js +1 -1
- package/src/provider-import-format.js +5 -5
- package/src/provider-imports.js +1 -1
- package/src/provider-models.js +3 -3
- package/src/provider-state.js +31 -14
- package/src/provider.js +8 -0
package/src/provider-models.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CLIError, requireValue } from "./errors.js";
|
|
2
2
|
import { assertNoSecrets, uuid } from "./provider-state.js";
|
|
3
|
-
export function checkConfiguration(value) {
|
|
4
|
-
assertNoSecrets(value);
|
|
3
|
+
export function checkConfiguration(value, kind) {
|
|
4
|
+
assertNoSecrets(value, "$", kind);
|
|
5
5
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
6
6
|
throw new CLIError("INVALID_INPUT", "Configuration must be an object");
|
|
7
7
|
for (const o of [value, value.price])
|
|
@@ -71,7 +71,7 @@ export async function runResource(kind, action, client, ctx) {
|
|
|
71
71
|
);
|
|
72
72
|
if (action === "create" || action === "update") {
|
|
73
73
|
const input = await ctx.input();
|
|
74
|
-
checkConfiguration(input);
|
|
74
|
+
checkConfiguration(input, kind);
|
|
75
75
|
const capabilities = await client.capabilities(kind);
|
|
76
76
|
let current;
|
|
77
77
|
if (action === "update") {
|
package/src/provider-state.js
CHANGED
|
@@ -13,13 +13,21 @@ export const uuid = (value, name = "id") => {
|
|
|
13
13
|
throw new CLIError("INVALID_INPUT", `${name} must be a UUID`);
|
|
14
14
|
return value;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
const authorizationPlaceholder = /^Bearer[ \t]+(?:YOUR_API_KEY|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})$/i;
|
|
17
|
+
const apiSampleHeaders = /^\$\.(?:(?:apis\[\d+\]|items\[\d+\]\.configuration)\.)?config\.(?:samples|requestResponseExamples)\[\d+\]\.request\.headers$/;
|
|
18
|
+
const apiDescription = /^\$\.(?:apis\[\d+\]\.apiDescription|(?:(?:items\[\d+\]\.configuration|info|paths\.\/.*\.(?:get|post|put|patch|delete))\.)?description)$/;
|
|
19
|
+
|
|
20
|
+
export function assertNoSecrets(value, path = "$", kind) {
|
|
17
21
|
if (Array.isArray(value)) {
|
|
18
|
-
value.forEach((v, i) => assertNoSecrets(v, `${path}[${i}]
|
|
22
|
+
value.forEach((v, i) => assertNoSecrets(v, `${path}[${i}]`, kind));
|
|
19
23
|
return;
|
|
20
24
|
}
|
|
21
25
|
if (value && typeof value === "object")
|
|
22
26
|
for (const [k, v] of Object.entries(value)) {
|
|
27
|
+
if (kind === "api" && /^authorization$/i.test(k) &&
|
|
28
|
+
apiSampleHeaders.test(path) && typeof v === "string" && authorizationPlaceholder.test(v)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
23
31
|
// OpenAPI uses arbitrary scheme names (including "apiKey") as map keys.
|
|
24
32
|
// Only schema declarations and scope arrays get this exception; their
|
|
25
33
|
// children are still inspected, and credential values remain forbidden.
|
|
@@ -46,19 +54,28 @@ export function assertNoSecrets(value, path = "$") {
|
|
|
46
54
|
"Local credential scan rejected this field. Remove authentication headers and credentials from documents; configure authentication through secure connection input.",
|
|
47
55
|
{ field: `${path}.${k}`, stage: "local" },
|
|
48
56
|
);
|
|
49
|
-
assertNoSecrets(v, `${path}.${k}
|
|
57
|
+
assertNoSecrets(v, `${path}.${k}`, kind);
|
|
50
58
|
}
|
|
51
|
-
else if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
else if (typeof value === "string") {
|
|
60
|
+
const modelCurl = kind === "model" &&
|
|
61
|
+
/^\$\.(?:price\.curlExample|items\[\d+\]\.configuration\.price\.curlExample|models\[\d+\]\.requestCurlExample)$/.test(path);
|
|
62
|
+
const curlExample = modelCurl || (kind === "api" && apiDescription.test(path));
|
|
63
|
+
// Ignore only a complete placeholder header while scanning. Send the original example.
|
|
64
|
+
const scanned = curlExample
|
|
65
|
+
? value.replace(/(?:^|\s)(?:-H\s*|--header(?:\s+|=))(["'])Authorization:[ \t]*Bearer[ \t]+(?:YOUR_API_KEY|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})\1(?=\s|$)/gi, " ")
|
|
66
|
+
: value;
|
|
67
|
+
if (
|
|
68
|
+
/\bBearer\s+[\w.+\/-]+/i.test(scanned) ||
|
|
69
|
+
/[?&](?:api[_-]?key|token|secret|password|key)=/i.test(scanned) ||
|
|
70
|
+
/^https?:\/\/[^/]+:[^/]+@/i.test(scanned) ||
|
|
71
|
+
(curlExample && /(?:^|\s)(?:-H\s*|--header(?:\s+|=))["']?Authorization:/i.test(scanned))
|
|
72
|
+
)
|
|
73
|
+
throw new CLIError(
|
|
74
|
+
"SECRET_IN_DOCUMENT",
|
|
75
|
+
"Local credential scan rejected possible credentials. Use a supported Authorization placeholder in cURL examples and configure actual authentication through secure connection input.",
|
|
76
|
+
{ field: path, stage: "local" },
|
|
77
|
+
);
|
|
78
|
+
}
|
|
62
79
|
}
|
|
63
80
|
export function receipt(value) {
|
|
64
81
|
const out = value?.price?.id ? { id: value.price.id } : {};
|
package/src/provider.js
CHANGED
|
@@ -8,6 +8,14 @@ import { runReviews } from "./provider-reviews.js";
|
|
|
8
8
|
import { runImports } from "./provider-imports.js";
|
|
9
9
|
import { parseProviderJSON, readProviderJSON } from "./provider-json.js";
|
|
10
10
|
export async function runProvider(args, ctx) {
|
|
11
|
+
if (args[1] === "hermes") {
|
|
12
|
+
const { runHermesDelivery } = await import("./hermes-delivery.js");
|
|
13
|
+
return runHermesDelivery(args, ctx);
|
|
14
|
+
}
|
|
15
|
+
if (args[1] === "tasks") {
|
|
16
|
+
const { uploadPollArtifact } = await import("./poll-artifacts.js");
|
|
17
|
+
return uploadPollArtifact(args, ctx);
|
|
18
|
+
}
|
|
11
19
|
const group = args[1],
|
|
12
20
|
action = args[2] || "list";
|
|
13
21
|
if (ctx.options.public || ctx.options.workspace || ctx.options["dry-run"])
|