openany-cli-dev 0.1.0 → 0.1.1
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 +70 -59
- package/package.json +1 -1
- package/skills/openany/SKILL.md +8 -2
- package/skills/openany/SKILL.zh-CN.md +2 -2
- package/skills/openany-provider/SKILL.md +12 -12
- package/skills/openany-provider/SKILL.zh-CN.md +10 -10
- package/skills/openany-provider/references/apis.md +12 -12
- package/skills/openany-provider/references/apis.zh-CN.md +55 -0
- package/skills/openany-provider/references/application.md +2 -2
- package/skills/openany-provider/references/application.zh-CN.md +2 -2
- package/skills/openany-provider/references/auth.md +1 -57
- package/skills/openany-provider/references/auth.zh-CN.md +3 -0
- package/skills/openany-provider/references/connections.md +17 -19
- package/skills/openany-provider/references/connections.zh-CN.md +23 -20
- package/skills/openany-provider/references/imports.md +42 -23
- package/skills/openany-provider/references/imports.zh-CN.md +37 -35
- package/skills/openany-provider/references/listing.md +6 -6
- package/skills/openany-provider/references/listing.zh-CN.md +11 -0
- package/skills/openany-provider/references/login.md +19 -20
- package/skills/openany-provider/references/login.zh-CN.md +15 -17
- package/skills/openany-provider/references/model-import.md +11 -0
- package/skills/openany-provider/references/model-import.zh-CN.md +2 -3
- package/skills/openany-provider/references/models.zh-CN.md +68 -0
- package/skills/openany-provider/references/publishing.md +20 -63
- package/skills/openany-provider/references/publishing.zh-CN.md +17 -58
- package/skills/openany-provider/references/reviews.zh-CN.md +20 -0
- package/skills/openany-provider/templates/seller-agent-api-import-template.json +10 -27
- package/src/cli.js +4 -0
- package/src/http.js +2 -1
- package/src/native/connection-macos.js +10 -10
- package/src/native/setup-macos.js +10 -10
- package/src/tasks.js +53 -0
|
@@ -8,9 +8,9 @@ function run() {
|
|
|
8
8
|
var app = $.NSApplication.sharedApplication;
|
|
9
9
|
app.setActivationPolicy($.NSApplicationActivationPolicyRegular);
|
|
10
10
|
var menu = $.NSMenu.alloc.initWithTitle($(""));
|
|
11
|
-
var editItem = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($("
|
|
12
|
-
var editMenu = $.NSMenu.alloc.initWithTitle($("
|
|
13
|
-
[["
|
|
11
|
+
var editItem = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($("Edit"), null, $(""));
|
|
12
|
+
var editMenu = $.NSMenu.alloc.initWithTitle($("Edit"));
|
|
13
|
+
[["Cut", "cut:", "x"], ["Copy", "copy:", "c"], ["Paste", "paste:", "v"], ["Select All", "selectAll:", "a"]].forEach(function (entry) {
|
|
14
14
|
var item = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($(entry[0]), entry[1], $(entry[2]));
|
|
15
15
|
item.keyEquivalentModifierMask = $.NSEventModifierFlagCommand;
|
|
16
16
|
editMenu.addItem(item);
|
|
@@ -21,9 +21,9 @@ function run() {
|
|
|
21
21
|
|
|
22
22
|
var alert = $.NSAlert.alloc.init;
|
|
23
23
|
alert.messageText = $("Create OpenAny Provider Connection");
|
|
24
|
-
alert.informativeText = $(request.error || "
|
|
25
|
-
alert.addButtonWithTitle($("
|
|
26
|
-
var cancel = alert.addButtonWithTitle($("
|
|
24
|
+
alert.informativeText = $(request.error || "Connection details are sent to OpenAny. API keys are never saved locally or printed in command output.");
|
|
25
|
+
alert.addButtonWithTitle($("Create Connection"));
|
|
26
|
+
var cancel = alert.addButtonWithTitle($("Cancel"));
|
|
27
27
|
cancel.keyEquivalent = $("\u001b");
|
|
28
28
|
var view = $.NSView.alloc.initWithFrame($.NSMakeRect(0, 0, 480, 400));
|
|
29
29
|
function label(value, y) {
|
|
@@ -40,15 +40,15 @@ function run() {
|
|
|
40
40
|
view.addSubview(field);
|
|
41
41
|
return { field: field, caption: caption };
|
|
42
42
|
}
|
|
43
|
-
var name = input("
|
|
44
|
-
var baseUrl = input("Base URL
|
|
45
|
-
var authCaption = label("
|
|
43
|
+
var name = input("Connection Label", 332, false);
|
|
44
|
+
var baseUrl = input("Base URL (HTTP / HTTPS)", 252, false);
|
|
45
|
+
var authCaption = label("Authentication Type", 208);
|
|
46
46
|
var auth = $.NSPopUpButton.alloc.initWithFramePullsDown($.NSMakeRect(0, 172, 480, 32), false);
|
|
47
47
|
auth.font = $.NSFont.systemFontOfSize(14);
|
|
48
48
|
request.authTypes.forEach(function (type) { auth.addItemWithTitle($(type)); });
|
|
49
49
|
auth.selectItemWithTitle($("Authorization"));
|
|
50
50
|
view.addSubview(auth);
|
|
51
|
-
var param = input("
|
|
51
|
+
var param = input("Authentication Parameter Name", 92, false);
|
|
52
52
|
var secret = input("API Key", 12, true);
|
|
53
53
|
function layoutFields() {
|
|
54
54
|
var type = ObjC.unwrap(auth.titleOfSelectedItem).toLowerCase();
|
|
@@ -10,9 +10,9 @@ function run() {
|
|
|
10
10
|
// osascript has no default Edit menu. Route standard shortcuts through
|
|
11
11
|
// the responder chain so text fields receive paste without reading clipboard data here.
|
|
12
12
|
var menu = $.NSMenu.alloc.initWithTitle($(""));
|
|
13
|
-
var editItem = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($("
|
|
14
|
-
var editMenu = $.NSMenu.alloc.initWithTitle($("
|
|
15
|
-
[["
|
|
13
|
+
var editItem = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($("Edit"), null, $(""));
|
|
14
|
+
var editMenu = $.NSMenu.alloc.initWithTitle($("Edit"));
|
|
15
|
+
[["Cut", "cut:", "x"], ["Copy", "copy:", "c"], ["Paste", "paste:", "v"], ["Select All", "selectAll:", "a"]].forEach(function (entry) {
|
|
16
16
|
var item = $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent($(entry[0]), entry[1], $(entry[2]));
|
|
17
17
|
item.keyEquivalentModifierMask = $.NSEventModifierFlagCommand;
|
|
18
18
|
editMenu.addItem(item);
|
|
@@ -23,12 +23,12 @@ function run() {
|
|
|
23
23
|
var alert = $.NSAlert.alloc.init;
|
|
24
24
|
var confirm = request.mode === "confirm";
|
|
25
25
|
var wallet = request.mode === "wallet";
|
|
26
|
-
alert.messageText = $(confirm ? "
|
|
26
|
+
alert.messageText = $(confirm ? "Confirm Wallet Address" : wallet ? "Set Up OpenAny Wallet" : "Set Up OpenAny API Key");
|
|
27
27
|
alert.informativeText = $(confirm
|
|
28
|
-
? "
|
|
29
|
-
: (request.error || "
|
|
30
|
-
alert.addButtonWithTitle($(confirm ? "
|
|
31
|
-
var cancel = alert.addButtonWithTitle($("
|
|
28
|
+
? "Review the wallet address derived from your private key and the Agent ID before saving locally."
|
|
29
|
+
: (request.error || "OpenAny stores your credentials locally. Your agent receives only the setup status."));
|
|
30
|
+
alert.addButtonWithTitle($(confirm ? "Confirm and Save" : wallet ? "Review Address" : "Save Configuration"));
|
|
31
|
+
var cancel = alert.addButtonWithTitle($("Cancel"));
|
|
32
32
|
cancel.keyEquivalent = $("\u001b");
|
|
33
33
|
var view = $.NSView.alloc.initWithFrame($.NSMakeRect(0, 0, 420, confirm ? 100 : 220));
|
|
34
34
|
function label(value, y) {
|
|
@@ -42,12 +42,12 @@ function run() {
|
|
|
42
42
|
label(request.address, 64);
|
|
43
43
|
label("Agent ID: " + request.agentId, 24);
|
|
44
44
|
} else {
|
|
45
|
-
label(wallet ? "Agent ID" : "
|
|
45
|
+
label(wallet ? "Agent ID" : "Key Label", 188);
|
|
46
46
|
name = $.NSTextField.alloc.initWithFrame($.NSMakeRect(0, 152, 420, 32));
|
|
47
47
|
name.font = $.NSFont.systemFontOfSize(14);
|
|
48
48
|
name.stringValue = $(wallet ? request.agentId : request.label);
|
|
49
49
|
view.addSubview(name);
|
|
50
|
-
label(wallet ? "
|
|
50
|
+
label(wallet ? "Wallet Private Key (EVM / Solana)" : "API Key", 116);
|
|
51
51
|
secret = $.NSSecureTextField.alloc.initWithFrame($.NSMakeRect(0, 80, 420, 32));
|
|
52
52
|
secret.font = $.NSFont.systemFontOfSize(14);
|
|
53
53
|
view.addSubview(secret);
|
package/src/tasks.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
|
+
import { CLIError, requireValue } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
const taskIdPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
|
+
const terminalStatuses = new Set(["completed", "failed", "timed_out"]);
|
|
6
|
+
|
|
7
|
+
export async function runTasks(args, { options, http }) {
|
|
8
|
+
const action = args[1];
|
|
9
|
+
const allowed = ["id", "json", "output"];
|
|
10
|
+
if (action === "wait") allowed.push("timeout-seconds");
|
|
11
|
+
if (args.length !== 2 || !["get", "wait"].includes(action) ||
|
|
12
|
+
Object.keys(options).some(key => !allowed.includes(key))) {
|
|
13
|
+
throw new CLIError("INVALID_INPUT", "Use tasks get|wait --id TASK_ID. Only wait accepts --timeout-seconds.");
|
|
14
|
+
}
|
|
15
|
+
const taskId = requireValue(options.id, "--id").toLowerCase();
|
|
16
|
+
if (!taskIdPattern.test(taskId))
|
|
17
|
+
throw new CLIError("INVALID_INPUT", "Task ID must be a UUID returned by run");
|
|
18
|
+
const path = "/v1/agent-api-tasks/" + taskId;
|
|
19
|
+
|
|
20
|
+
async function readTask(timeoutMs) {
|
|
21
|
+
const { body, requestId } = await http.gateway(path, { auth: "apiKey", timeoutMs });
|
|
22
|
+
if (body?.task_id !== taskId || typeof body.status !== "string" || !body.status)
|
|
23
|
+
throw new CLIError("INVALID_RESPONSE", "Gateway returned an invalid task record", { requestId, taskId });
|
|
24
|
+
return body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (action === "get") return readTask();
|
|
28
|
+
|
|
29
|
+
const seconds = Number(options["timeout-seconds"] ?? 120);
|
|
30
|
+
if (!Number.isInteger(seconds) || seconds < 1 || seconds > 600)
|
|
31
|
+
throw new CLIError("INVALID_INPUT", "--timeout-seconds must be an integer between 1 and 600");
|
|
32
|
+
const deadline = performance.now() + seconds * 1000;
|
|
33
|
+
let delay = 1000;
|
|
34
|
+
let task;
|
|
35
|
+
while (performance.now() < deadline) {
|
|
36
|
+
try {
|
|
37
|
+
const remaining = Math.max(1, Math.ceil(deadline - performance.now()));
|
|
38
|
+
task = await readTask(remaining);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error.code === "REQUEST_TIMEOUT") break;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
if (terminalStatuses.has(task.status)) return task;
|
|
44
|
+
const remaining = deadline - performance.now();
|
|
45
|
+
if (remaining <= delay) {
|
|
46
|
+
if (remaining > 0) await sleep(Math.ceil(remaining));
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
await sleep(delay);
|
|
50
|
+
delay = Math.min(delay * 2, 10000);
|
|
51
|
+
}
|
|
52
|
+
return { task_id: taskId, ...task, timedOut: true };
|
|
53
|
+
}
|