openany-cli-dev 0.0.0-stage → 0.1.0

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 (73) hide show
  1. package/README.md +461 -2
  2. package/bin/openany.js +3 -0
  3. package/package.json +27 -4
  4. package/skills/openany/SKILL.md +347 -0
  5. package/skills/openany/SKILL.zh-CN.md +496 -0
  6. package/skills/openany-provider/SKILL.md +26 -0
  7. package/skills/openany-provider/SKILL.zh-CN.md +26 -0
  8. package/skills/openany-provider/references/apis.md +60 -0
  9. package/skills/openany-provider/references/application.md +49 -0
  10. package/skills/openany-provider/references/application.zh-CN.md +51 -0
  11. package/skills/openany-provider/references/auth.md +59 -0
  12. package/skills/openany-provider/references/connections.md +38 -0
  13. package/skills/openany-provider/references/connections.zh-CN.md +33 -0
  14. package/skills/openany-provider/references/imports.md +38 -0
  15. package/skills/openany-provider/references/imports.zh-CN.md +55 -0
  16. package/skills/openany-provider/references/listing.md +29 -0
  17. package/skills/openany-provider/references/login.md +58 -0
  18. package/skills/openany-provider/references/login.zh-CN.md +59 -0
  19. package/skills/openany-provider/references/model-import.zh-CN.md +12 -0
  20. package/skills/openany-provider/references/models.md +107 -0
  21. package/skills/openany-provider/references/publishing.md +83 -0
  22. package/skills/openany-provider/references/publishing.zh-CN.md +81 -0
  23. package/skills/openany-provider/references/reviews.md +22 -0
  24. package/skills/openany-provider/templates/api-metadata.json +27 -0
  25. package/skills/openany-provider/templates/bindings.json +1 -0
  26. package/skills/openany-provider/templates/models-v2.json +545 -0
  27. package/skills/openany-provider/templates/models.json +10 -0
  28. package/skills/openany-provider/templates/provider-agent-api-template.json +697 -0
  29. package/skills/openany-provider/templates/seller-agent-api-import-template.json +839 -0
  30. package/skills/openany-provider/templates/seller-registration.json +26 -0
  31. package/src/auth-recovery.js +179 -0
  32. package/src/auth.js +1001 -0
  33. package/src/catalog.js +306 -0
  34. package/src/cli.js +601 -0
  35. package/src/config.js +260 -0
  36. package/src/errors.js +53 -0
  37. package/src/http.js +237 -0
  38. package/src/model-curl.js +359 -0
  39. package/src/model-materials.js +58 -0
  40. package/src/model-request.js +402 -0
  41. package/src/model-validation.js +56 -0
  42. package/src/models.js +188 -0
  43. package/src/native/config-acl.ps1 +34 -0
  44. package/src/native/connection-macos.js +109 -0
  45. package/src/native/connection-windows.ps1 +98 -0
  46. package/src/native/setup-macos.js +72 -0
  47. package/src/native/setup-windows.ps1 +83 -0
  48. package/src/native-prompt.js +85 -0
  49. package/src/payment-signing.js +362 -0
  50. package/src/prompt.js +69 -0
  51. package/src/provider-api-import-v2.js +72 -0
  52. package/src/provider-apis.js +3 -0
  53. package/src/provider-client.js +153 -0
  54. package/src/provider-connections.js +152 -0
  55. package/src/provider-import-format.js +289 -0
  56. package/src/provider-imports.js +402 -0
  57. package/src/provider-json.js +49 -0
  58. package/src/provider-model-import-v2.js +61 -0
  59. package/src/provider-models.js +253 -0
  60. package/src/provider-profile.js +65 -0
  61. package/src/provider-reviews.js +61 -0
  62. package/src/provider-state.js +176 -0
  63. package/src/provider.js +75 -0
  64. package/src/setup.js +201 -0
  65. package/src/topups.js +845 -0
  66. package/src/vendor/provider-apply/market-taxonomy.mjs +22 -0
  67. package/src/vendor/provider-apply/provenance.json +8 -0
  68. package/src/vendor/provider-apply/registration.mjs +151 -0
  69. package/src/vendor/provider-import/api-categories.json +29 -0
  70. package/src/vendor/provider-import/api-fields.json +33 -0
  71. package/src/vendor/provider-import/model-fields.json +44 -0
  72. package/src/wallet.js +213 -0
  73. package/src/windows-permissions.js +22 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "seller": {
3
+ "name": "Example Research",
4
+ "email": "seller@example.com",
5
+ "slug": "example-research",
6
+ "bio": "Public company research tools for teams."
7
+ },
8
+ "seller_types": ["api"],
9
+ "resource": {
10
+ "name": "Example Research",
11
+ "description": "Search company profiles by domain. Returns public company information.",
12
+ "type": "service",
13
+ "primary_category": "search-research",
14
+ "secondary_categories": [],
15
+ "contains_personal_data": false
16
+ },
17
+ "connection": {
18
+ "documentation_url": "https://example.com/docs",
19
+ "authentication": { "type": "none" }
20
+ },
21
+ "endpoints": [],
22
+ "consents": {
23
+ "authorized": false,
24
+ "automated_checks": false
25
+ }
26
+ }
@@ -0,0 +1,179 @@
1
+ import { open, lstat } from "node:fs/promises";
2
+ import { constants } from "node:fs";
3
+ import { basename, dirname, resolve } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ import { CLIError } from "./errors.js";
6
+ import { sameWallet } from "./wallet.js";
7
+
8
+ export const fingerprint = (value) =>
9
+ createHash("sha256")
10
+ .update(JSON.stringify(value ?? null))
11
+ .digest("hex");
12
+ const invalid = () => {
13
+ throw new CLIError(
14
+ "RECOVERY_INVALID",
15
+ "The recovery file or associated identity state does not match; credentials were not changed.",
16
+ );
17
+ };
18
+ export async function readRecovery(path, directory) {
19
+ if (
20
+ typeof path !== "string" ||
21
+ dirname(resolve(path)) !== resolve(directory) ||
22
+ !/^recovery-[a-z-]+-[0-9a-f-]{36}\.json$/.test(basename(path))
23
+ )
24
+ invalid();
25
+ const dir = await lstat(directory);
26
+ if (!dir.isDirectory() || dir.isSymbolicLink()) invalid();
27
+ const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
28
+ try {
29
+ const stat = await file.stat();
30
+ if (
31
+ !stat.isFile() ||
32
+ (stat.mode & 0o777) !== 0o600 ||
33
+ stat.size > 1024 * 1024
34
+ )
35
+ invalid();
36
+ let record;
37
+ try {
38
+ record = JSON.parse(await file.readFile("utf8"));
39
+ } catch {
40
+ invalid();
41
+ }
42
+ if (basename(path) !== `recovery-${record.kind}-${record.id}.json`)
43
+ invalid();
44
+ return record;
45
+ } finally {
46
+ await file.close();
47
+ }
48
+ }
49
+ export function applyRecovery(state, record, now) {
50
+ const { kind, data, context: c, id } = record;
51
+ if (
52
+ record.version !== 1 ||
53
+ !/^[0-9a-f-]{36}$/.test(id || "") ||
54
+ !data ||
55
+ !c ||
56
+ !["wallet-key", "wallet-session", "email-key", "email-session"].includes(
57
+ kind,
58
+ )
59
+ )
60
+ invalid();
61
+ if (state.credentialRecoveries?.[id])
62
+ throw new CLIError("RECOVERY_ALREADY_APPLIED", "This credential recovery record has already been processed.");
63
+ let pending;
64
+ if (kind.startsWith("wallet-")) {
65
+ pending = state.authChallenges?.[c.challengeId];
66
+ if (
67
+ !pending ||
68
+ !["submitting", "uncertain"].includes(pending.status) ||
69
+ pending.operation !== c.operation ||
70
+ pending.label !== c.label ||
71
+ pending.agentId !== c.agentId ||
72
+ !sameWallet(pending.walletAddress, c.walletAddress) ||
73
+ !sameWallet(data.walletAddress, c.walletAddress)
74
+ )
75
+ invalid();
76
+ if (
77
+ kind === "wallet-key" &&
78
+ (!["create_key", "rotate_key"].includes(c.operation) ||
79
+ data.agentId !== c.agentId)
80
+ )
81
+ invalid();
82
+ if (kind === "wallet-session" && c.operation !== "session") invalid();
83
+ } else if (kind === "email-key") {
84
+ if (
85
+ c.operation !== "create_key" ||
86
+ state.keyReservations?.[c.label] !== c.reservation ||
87
+ state.sessions.email?.userId !== c.userId ||
88
+ !state.sessions.email?.workspaces?.some((w) => w.id === c.workspaceId) ||
89
+ data.workspaceId !== c.workspaceId
90
+ )
91
+ invalid();
92
+ } else if (c.operation === "verify") {
93
+ pending = state.emailChallenge;
94
+ if (
95
+ !pending ||
96
+ pending.challengeId !== c.challengeId ||
97
+ pending.email !== c.email ||
98
+ !["submitting", "uncertain"].includes(pending.status) ||
99
+ data.email !== c.email
100
+ )
101
+ invalid();
102
+ } else if (c.operation === "refresh") {
103
+ if (
104
+ state.emailRefreshPending !== c.reservation ||
105
+ fingerprint(state.sessions.email) !== c.previousSession ||
106
+ data.userId !== state.sessions.email?.userId ||
107
+ data.email !== state.sessions.email?.email
108
+ )
109
+ invalid();
110
+ } else invalid();
111
+ if (kind.endsWith("-key")) {
112
+ if (
113
+ typeof c.label !== "string" ||
114
+ !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(c.label) ||
115
+ ["__proto__", "constructor", "prototype"].includes(c.label) ||
116
+ data.label !== c.label ||
117
+ typeof data.plaintextKey !== "string" ||
118
+ !data.plaintextKey ||
119
+ !c.metadata ||
120
+ c.metadata.identity !== (kind === "wallet-key" ? "wallet" : "email") ||
121
+ c.metadata.keyId !== (data.keyId || data.id)
122
+ )
123
+ invalid();
124
+ if (
125
+ kind === "wallet-key" &&
126
+ (c.metadata.agentId !== c.agentId ||
127
+ !sameWallet(c.metadata.walletAddress, c.walletAddress))
128
+ )
129
+ invalid();
130
+ if (c.metadata.workspaceId !== data.workspaceId) invalid();
131
+ const index = state.keys.findIndex((k) => k.label === c.label);
132
+ if (fingerprint(index < 0 ? null : state.keys[index]) !== c.previousKey)
133
+ invalid();
134
+ const entry = {
135
+ label: c.label,
136
+ key: data.plaintextKey,
137
+ metadata: c.metadata,
138
+ };
139
+ if (index < 0) state.keys.push(entry);
140
+ else state.keys[index] = entry;
141
+ state.activeKey = c.label;
142
+ if (kind === "email-key") delete state.keyReservations[c.label];
143
+ } else if (kind === "wallet-session") {
144
+ if (
145
+ typeof data.token !== "string" ||
146
+ !data.token ||
147
+ !Number.isFinite(Date.parse(data.expiresAt)) ||
148
+ Date.parse(data.expiresAt) <= now ||
149
+ fingerprint(state.sessions.wallet) !== c.previousSession
150
+ )
151
+ invalid();
152
+ state.sessions.wallet = {
153
+ token: data.token,
154
+ walletAddress: c.walletAddress,
155
+ expiresAt: data.expiresAt,
156
+ };
157
+ } else {
158
+ if (
159
+ typeof data.accessToken !== "string" ||
160
+ !data.accessToken ||
161
+ !Array.isArray(data.workspaces) ||
162
+ !Array.isArray(data.cookies) ||
163
+ fingerprint(state.sessions.email) !== c.previousSession
164
+ )
165
+ invalid();
166
+ state.sessions.email = data;
167
+ if (
168
+ c.operation === "refresh" ||
169
+ state.emailRefreshPending === c.previousRefresh
170
+ )
171
+ delete state.emailRefreshPending;
172
+ }
173
+ if (pending) pending.status = "completed";
174
+ state.credentialRecoveries ||= {};
175
+ state.credentialRecoveries[id] = {
176
+ kind,
177
+ appliedAt: new Date(now).toISOString(),
178
+ };
179
+ }