openany-cli-dev 0.1.1 → 0.1.3

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.
Files changed (32) hide show
  1. package/README.md +19 -19
  2. package/package.json +1 -1
  3. package/skills/openany/SKILL.md +17 -336
  4. package/skills/openany/calls.md +116 -0
  5. package/skills/openany/setup.md +235 -0
  6. package/skills/openany/topups.md +70 -0
  7. package/skills/openany-provider/SKILL.md +6 -2
  8. package/skills/openany-provider/SKILL.zh-CN.md +6 -2
  9. package/skills/openany-provider/references/apis.md +5 -5
  10. package/skills/openany-provider/references/apis.zh-CN.md +4 -4
  11. package/skills/openany-provider/references/application.md +1 -1
  12. package/skills/openany-provider/references/application.zh-CN.md +1 -1
  13. package/skills/openany-provider/references/connections.md +8 -8
  14. package/skills/openany-provider/references/connections.zh-CN.md +7 -7
  15. package/skills/openany-provider/references/imports.md +3 -3
  16. package/skills/openany-provider/references/imports.zh-CN.md +3 -3
  17. package/skills/openany-provider/references/models.md +8 -8
  18. package/skills/openany-provider/references/models.zh-CN.md +5 -5
  19. package/skills/openany-provider/references/publishing.md +3 -3
  20. package/skills/openany-provider/references/publishing.zh-CN.md +4 -4
  21. package/skills/openany-provider/references/reviews.md +2 -2
  22. package/skills/openany-provider/templates/bindings.json +1 -1
  23. package/skills/openany-provider/templates/models-v2.json +12 -12
  24. package/skills/openany-provider/templates/models.json +2 -2
  25. package/skills/openany-provider/templates/provider-agent-api-template.json +12 -12
  26. package/skills/openany-provider/templates/seller-agent-api-import-template.json +16 -16
  27. package/src/cli.js +12 -4
  28. package/src/provider-connections.js +2 -2
  29. package/src/provider-imports.js +5 -4
  30. package/src/provider-model-import-v2.js +10 -1
  31. package/src/provider.js +5 -3
  32. package/src/seller-fields.js +57 -0
@@ -14,7 +14,7 @@
14
14
  "apiDescription must contain at least 150 Unicode characters after trimming, covering core capabilities, how to call the API, and use cases. Incomplete drafts can be previewed and edited; this requirement must be met before importing and saving.",
15
15
  "Select a catalogType: skill, bot, service, data, or digital. Fill in includedContentHtml, usageInstructionsHtml, and at least one complete effect example.",
16
16
  "For synchronous delivery, keep executionMode set to sync and asyncConfig set to null. For asynchronous delivery, use POST and copy the callback or poll option below. Update the API description and request and response examples to match your service.",
17
- "The asynchronous examples show fixed billing and an upstream acknowledgement. For polling, implement GET /v1/jobs/{task_id} and return the documented status and result fields. Keep credentials in the connection and webhook settings."
17
+ "The asynchronous examples show fixed billing and a service acknowledgement. For polling, implement GET /v1/jobs/{task_id} and return the documented status and result fields. Keep credentials in the connection and webhook settings."
18
18
  ],
19
19
  "pricingExample": "1,000 micro-USD per call, equivalent to USD 0.001.",
20
20
  "billingInstructions": "Each API must use exactly one billing method: fixed (per call) or usage (based on consumption). The example under apis uses fixed by default. For usage billing, replace config.billing in its entirety with billingOptions.usage.billing, then update the usage field and response example to match the actual response. Do not mix fields from the two billing methods or add both options from the guide to apis.",
@@ -154,10 +154,10 @@
154
154
  "example": "POST"
155
155
  },
156
156
  "apis[].publicPath": {
157
- "label": "Upstream API relative path",
157
+ "label": "Service API relative path",
158
158
  "type": "string",
159
159
  "required": true,
160
- "description": "Enter the upstream API's relative path. V2 uses it as both the public path and upstreamPathTemplate, including for async dispatch. The selected connection supplies the base URL.",
160
+ "description": "Enter the service API's relative path. V2 uses it as both the public path and servicePathTemplate, including for async dispatch. The selected connection supplies the base URL.",
161
161
  "constraints": "Required; must start with /; at most 2048 characters; use {parameterName} for path parameters.",
162
162
  "example": "/v1/text/process"
163
163
  },
@@ -165,7 +165,7 @@
165
165
  "label": "Request body format",
166
166
  "type": "string",
167
167
  "required": true,
168
- "description": "Enter the request body encoding accepted by the upstream API.",
168
+ "description": "Enter the request body encoding accepted by the service API.",
169
169
  "constraints": "Only none / application/json / application/x-www-form-urlencoded.",
170
170
  "example": "application/json"
171
171
  },
@@ -335,26 +335,26 @@
335
335
  "example": []
336
336
  },
337
337
  "apis[].config.parameterMappings": {
338
- "label": "Upstream parameter mappings",
338
+ "label": "Service parameter mappings",
339
339
  "type": "array<object>",
340
340
  "required": true,
341
- "description": "Forward caller parameters to specified upstream locations.",
342
- "constraints": "source references a declared parameter; target specifies an upstream location.",
341
+ "description": "Forward caller parameters to specified service locations.",
342
+ "constraints": "source references a declared parameter; target specifies a service location.",
343
343
  "example": []
344
344
  },
345
345
  "apis[].config.fixedHeaders": {
346
- "label": "Fixed upstream request headers",
346
+ "label": "Fixed service request headers",
347
347
  "type": "object",
348
348
  "required": false,
349
- "description": "Enter non-sensitive headers added to every forwarded upstream request.",
349
+ "description": "Enter non-sensitive headers added to every forwarded service request.",
350
350
  "constraints": "Values must be strings. Do not include credentials such as Authorization or Cookie, or reserved headers. Use {} if none.",
351
351
  "example": {}
352
352
  },
353
353
  "apis[].config.fixedBody": {
354
- "label": "Fixed upstream request body fields",
354
+ "label": "Fixed service request body fields",
355
355
  "type": "object",
356
356
  "required": false,
357
- "description": "Enter JSON fields added to every forwarded upstream request.",
357
+ "description": "Enter JSON fields added to every forwarded service request.",
358
358
  "constraints": "Enter a JSON object without secrets. Use {} if none.",
359
359
  "example": {}
360
360
  },
@@ -487,10 +487,10 @@
487
487
  "example": "body:/text"
488
488
  },
489
489
  "apis[].config.parameterMappings[].target": {
490
- "label": "Upstream parameter target",
490
+ "label": "Service parameter target",
491
491
  "type": "string",
492
492
  "required": true,
493
- "description": "Enter where the upstream API receives the parameter.",
493
+ "description": "Enter where the service API receives the parameter.",
494
494
  "constraints": "For example, body:/text refers to the /text field in the JSON request body. An identical source and target forwards it without changing its location.",
495
495
  "example": "body:/text"
496
496
  },
@@ -698,13 +698,13 @@
698
698
  "apis[].asyncConfig.adapter_type": {
699
699
  "type": "string",
700
700
  "required": "Required for async",
701
- "description": "Choose webhook or grok_bot, according to the upstream adapter.",
701
+ "description": "Choose webhook or grok_bot, according to the service adapter.",
702
702
  "example": "webhook"
703
703
  },
704
704
  "apis[].asyncConfig.delivery_mode": {
705
705
  "type": "string",
706
706
  "required": "Required for async",
707
- "description": "Use callback when the upstream sends the result, or poll when the gateway queries the upstream for the result.",
707
+ "description": "Use callback when the service sends the result, or poll when the gateway queries your service for the result.",
708
708
  "example": "callback"
709
709
  },
710
710
  "apis[].asyncConfig.timeout_secs": {
@@ -724,7 +724,7 @@
724
724
  "apis[].asyncConfig.poll": {
725
725
  "type": "object",
726
726
  "required": "Required for poll",
727
- "description": "Copy the poll option and use the fixed upstream path GET /v1/jobs/{task_id}. Use the platform task ID from task_id in the submission body or from the Idempotency-Key header for native HTTP JSON. Return HTTP 200 with a top-level status of running, succeeded, or failed. Include a top-level result on success. The optional polling interval is 1 to 300 seconds.",
727
+ "description": "Copy the poll option and use the fixed service path GET /v1/jobs/{task_id}. Use the platform task ID from task_id in the submission body or from the Idempotency-Key header for native HTTP JSON. Return HTTP 200 with a top-level status of running, succeeded, or failed. Include a top-level result on success. The optional polling interval is 1 to 300 seconds.",
728
728
  "example": {
729
729
  "publication": {},
730
730
  "path": "/v1/jobs/{task_id}",
package/src/cli.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { sellerOutput, sellerText } from "./seller-fields.js";
1
2
  import packageInfo from "../package.json" with { type: "json" };
2
3
  import { tmpdir } from "node:os";
3
4
  import { join } from "node:path";
@@ -45,7 +46,7 @@ Model execution uses the OpenAny gateway with the path and query from curlExampl
45
46
  seller status [--application ID]
46
47
  seller applications list|create --file REGISTRATION_JSON --operation NAME
47
48
  seller connections list|get|create --application ID [--id ID]
48
- create --file JSON --operation NAME [--stdin] (or OPENANY_DEV_UPSTREAM_API_KEY)
49
+ create --file JSON --operation NAME [--stdin] (or OPENANY_CONNECTION_API_KEY)
49
50
  create --gui --operation NAME [-j] (native connection dialog; macOS/Windows)
50
51
  seller models|apis list|get|create|update|verify|publish|unpublish --application ID
51
52
  [--id ID] [--file PATH | --input JSON] [--operation NAME] [--verification-id ID]
@@ -492,15 +493,23 @@ export async function main(
492
493
  stdin = process.stdin,
493
494
  } = {},
494
495
  ) {
496
+ let seller = argv[0] === "seller";
495
497
  const secrets = [
496
498
  env.OPENANY_DEV_API_KEY,
499
+ env.OPENANY_CONNECTION_API_KEY,
497
500
  env.OPENANY_DEV_UPSTREAM_API_KEY,
498
501
  env.OPENANY_DEV_ACCESS_TOKEN,
499
502
  env.OPENANY_DEV_SESSION_TOKEN,
500
503
  env.OPENANY_DEV_WALLET_PRIVATE_KEY,
501
504
  ].filter(Boolean);
505
+ const format = (value, space) => {
506
+ if (!seller) return redact(value, secrets, space);
507
+ const sellerSecrets = secrets.filter(secret => typeof secret === "string").map(sellerText);
508
+ return redact(sellerOutput(value), [...secrets, ...sellerSecrets], space);
509
+ };
502
510
  try {
503
511
  const { args, options } = parseArgs(argv);
512
+ seller = args[0] === "seller";
504
513
  if (options.version || options.help || !args.length) {
505
514
  const value = options.version ? { version: packageInfo.version } : { help: HELP };
506
515
  const text = options.json
@@ -589,8 +598,7 @@ export async function main(
589
598
  );
590
599
  return 0;
591
600
  }
592
- const content =
593
- bytes ?? redact(result, secrets, options.json ? 0 : 2) + "\n";
601
+ const content = bytes ?? format(result, options.json ? 0 : 2) + "\n";
594
602
  if (options.output) {
595
603
  await writeFile(options.output, content, { flag: "wx", mode: 0o600 });
596
604
  stdout.write(
@@ -599,7 +607,7 @@ export async function main(
599
607
  } else stdout.write(content);
600
608
  return 0;
601
609
  } catch (error) {
602
- stderr.write(redact(errorRecord(error), secrets) + "\n");
610
+ stderr.write(format(errorRecord(error)) + "\n");
603
611
  return 1;
604
612
  }
605
613
  }
@@ -126,7 +126,7 @@ export async function runConnections(action, client, ctx) {
126
126
  "Specify a supported authentication type explicitly",
127
127
  );
128
128
  if (input.authType.toLowerCase() !== "none") {
129
- let key = gui ? gui.secret : ctx.env.OPENANY_DEV_UPSTREAM_API_KEY;
129
+ let key = gui ? gui.secret : (ctx.env.OPENANY_CONNECTION_API_KEY || ctx.env.OPENANY_DEV_UPSTREAM_API_KEY);
130
130
  if (ctx.options.stdin) {
131
131
  key = "";
132
132
  for await (const chunk of ctx.stdin) {
@@ -143,7 +143,7 @@ export async function runConnections(action, client, ctx) {
143
143
  if (!key)
144
144
  throw new CLIError(
145
145
  "UPSTREAM_CREDENTIAL_REQUIRED",
146
- "Set OPENANY_DEV_UPSTREAM_API_KEY or provide the key with --stdin; never put it in configuration files",
146
+ "Set OPENANY_CONNECTION_API_KEY or provide the key with --stdin; never put it in configuration files",
147
147
  );
148
148
  ctx.secrets.push(key);
149
149
  input.apiKey = key;
@@ -1,3 +1,4 @@
1
+ import { sellerInput } from "./seller-fields.js";
1
2
  import { apiImportVersion, validateApiImportCategories } from "./provider-api-import-v2.js";
2
3
  import { modelImportVersion } from "./provider-model-import-v2.js";
3
4
  import { randomUUID } from "node:crypto";
@@ -219,11 +220,11 @@ export async function runImports(action, client, ctx) {
219
220
  if (o.type === "model") await client.request("/schemas/model-import");
220
221
  const document = await ctx.input();
221
222
  const metadata = o["metadata-file"]
222
- ? await readProviderJSON(o["metadata-file"])
223
+ ? sellerInput(await readProviderJSON(o["metadata-file"]))
223
224
  : undefined;
224
225
  let items = parseImport(o.type, document, metadata);
225
226
  if (o["bindings-file"])
226
- items = applyBindings(items, await readProviderJSON(o["bindings-file"]), o.type);
227
+ items = applyBindings(items, sellerInput(await readProviderJSON(o["bindings-file"])), o.type);
227
228
  batch = {
228
229
  id: randomUUID(),
229
230
  userId: client.identity.userId,
@@ -259,7 +260,7 @@ export async function runImports(action, client, ctx) {
259
260
  const changed = structuredClone(batch.items);
260
261
  if (o["metadata-file"])
261
262
  for (const entry of manifest(
262
- await readProviderJSON(o["metadata-file"]),
263
+ sellerInput(await readProviderJSON(o["metadata-file"])),
263
264
  "Metadata",
264
265
  batch.type,
265
266
  )) {
@@ -298,7 +299,7 @@ export async function runImports(action, client, ctx) {
298
299
  validateApiImportCategories(item.configuration.categories, item.itemId);
299
300
  }
300
301
  const bound = o["bindings-file"]
301
- ? applyBindings(changed, await readProviderJSON(o["bindings-file"]), batch.type)
302
+ ? applyBindings(changed, sellerInput(await readProviderJSON(o["bindings-file"])), batch.type)
302
303
  : changed;
303
304
  for (let i = 0; i < bound.length; i++)
304
305
  if (
@@ -41,7 +41,16 @@ export function modelImportV2(document) {
41
41
  if (!Object.hasOwn(price, key)) continue;
42
42
  const sourceKey = key === "upstreamPath" ? "endpoints" : key;
43
43
  if (!Array.isArray(price[key])) throw new CLIError("IMPORT_FORMAT", `${path}.${sourceKey} must be an array`);
44
- price[key] = price[key].map((value, i) => rename(value, fields[group], `${path}.${sourceKey}[${i}]`));
44
+ price[key] = price[key].map((value, i) => {
45
+ const entryPath = `${path}.${sourceKey}[${i}]`;
46
+ if (group === "endpoint" && object(value) && Object.hasOwn(value, "servicePath")) {
47
+ if (Object.hasOwn(value, "upstreamPath"))
48
+ throw new CLIError("IMPORT_FORMAT", `${entryPath}: supply servicePath only once`);
49
+ const { servicePath, ...entry } = value;
50
+ value = { ...entry, upstreamPath: servicePath };
51
+ }
52
+ return rename(value, fields[group], entryPath);
53
+ });
45
54
  }
46
55
  const publicModel = Object.hasOwn(price, "publicModel") ? price.publicModel : price.model;
47
56
  if (typeof price.model !== "string" || !price.model.trim() || typeof publicModel !== "string" || !publicModel.trim())
package/src/provider.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { sellerInput } from "./seller-fields.js";
1
2
  import { ProviderClient } from "./provider-client.js";
2
3
  import { CLIError } from "./errors.js";
3
4
  import { runProfile } from "./provider-profile.js";
@@ -15,17 +16,18 @@ export async function runProvider(args, ctx) {
15
16
  "Seller commands require an account session and do not accept public/workspace/dry-run flags",
16
17
  );
17
18
  const input = ctx.input;
19
+ const normalize = ["models", "apis", "imports"].includes(group) ? sellerInput : value => value;
18
20
  ctx.input = async () => {
19
21
  if (ctx.options.file !== undefined && ctx.options.input !== undefined)
20
22
  throw new CLIError("INVALID_INPUT", "Choose --file or --input");
21
23
  if (ctx.options.file !== undefined)
22
- return readProviderJSON(ctx.options.file);
24
+ return normalize(await readProviderJSON(ctx.options.file));
23
25
  if (ctx.options.input !== undefined)
24
- return parseProviderJSON(ctx.options.input);
26
+ return normalize(parseProviderJSON(ctx.options.input));
25
27
  const value = await input();
26
28
  if (value === undefined)
27
29
  throw new CLIError("INPUT_REQUIRED", "Supply JSON configuration with --file PATH or --input JSON (choose one)");
28
- return value;
30
+ return normalize(value);
29
31
  };
30
32
  let client;
31
33
  try {
@@ -0,0 +1,57 @@
1
+ import { CLIError } from "./errors.js";
2
+
3
+ const fields = {
4
+ expectedConnectionRevision: "expectedUpstreamRevision",
5
+ connectionId: "upstreamKeyId",
6
+ connectionRevision: "upstreamRevision",
7
+ servicePathTemplate: "upstreamPathTemplate",
8
+ servicePath: "upstreamPath",
9
+ serviceProtocol: "upstreamProtocol",
10
+ };
11
+ const displays = Object.fromEntries(Object.entries(fields).map(([seller, internal]) => [internal, seller]));
12
+ const inputContainers = ["price", "routes", "items", "data", "configuration"];
13
+
14
+ export function sellerInput(value) {
15
+ if (Array.isArray(value)) return value.map(sellerInput);
16
+ if (!value || typeof value !== "object") return value;
17
+ const result = { ...value };
18
+ for (const [seller, internal] of Object.entries(fields)) {
19
+ if (!Object.hasOwn(value, seller)) continue;
20
+ if (Object.hasOwn(value, internal))
21
+ throw new CLIError("INVALID_INPUT", `Supply ${seller} only once`, { field: seller });
22
+ result[internal] = value[seller];
23
+ delete result[seller];
24
+ }
25
+ // Traverse configuration envelopes only. Request data, schemas, and samples
26
+ // can contain arbitrary business field names and must pass through unchanged.
27
+ for (const key of inputContainers) {
28
+ if (Object.hasOwn(value, key)) result[key] = sellerInput(value[key]);
29
+ }
30
+ return result;
31
+ }
32
+
33
+ export function sellerText(value) {
34
+ return value.replace(/\w*upstream\w*|上游(?:连接)?/gi, word => {
35
+ if (word.startsWith("上游")) return word === "上游连接" ? "连接" : "服务";
36
+ if (Object.hasOwn(displays, word)) return displays[word];
37
+ if (word === "OPENANY_DEV_UPSTREAM_API_KEY") return "OPENANY_CONNECTION_API_KEY";
38
+ return word
39
+ .replace(/UPSTREAM_KEY_/g, "CONNECTION_")
40
+ .replace(/upstream_key_/g, "connection_")
41
+ .replace(/upstreamKey/g, "connection")
42
+ .replace(/Upstream/g, "Service")
43
+ .replace(/UPSTREAM/g, "SERVICE")
44
+ .replace(/upstream/gi, "service");
45
+ });
46
+ }
47
+
48
+ export function sellerOutput(value) {
49
+ if (typeof value === "string") return sellerText(value);
50
+ if (Array.isArray(value)) return value.map(sellerOutput);
51
+ if (!value || typeof value !== "object") return value;
52
+ // Prefer an existing seller-facing name if a receipt contains both forms.
53
+ return Object.fromEntries(Object.entries(value).flatMap(([key, child]) => {
54
+ const label = sellerText(key);
55
+ return label !== key && Object.hasOwn(value, label) ? [] : [[label, sellerOutput(child)]];
56
+ }));
57
+ }