@parall/cli 1.86.0 → 1.88.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.
- package/dist/commands/apps-actions-sdk.generated.d.ts +1 -1
- package/dist/commands/apps-actions-sdk.generated.d.ts.map +1 -1
- package/dist/commands/apps-actions-sdk.generated.js +1 -1
- package/dist/commands/chat-bookmarks.d.ts +12 -0
- package/dist/commands/chat-bookmarks.d.ts.map +1 -0
- package/dist/commands/chat-bookmarks.js +129 -0
- package/dist/commands/chats.d.ts.map +1 -1
- package/dist/commands/chats.js +2 -0
- package/dist/commands/clip-connect.d.ts +3 -0
- package/dist/commands/clip-connect.d.ts.map +1 -0
- package/dist/commands/clip-connect.js +177 -0
- package/dist/commands/clip.d.ts.map +1 -1
- package/dist/commands/clip.js +28 -124
- package/dist/commands/cloud-profile.d.ts +3 -0
- package/dist/commands/cloud-profile.d.ts.map +1 -0
- package/dist/commands/cloud-profile.js +145 -0
- package/dist/commands/secrets.d.ts.map +1 -1
- package/dist/commands/secrets.js +122 -33
- package/dist/commands/wiki-page-shares.d.ts +5 -0
- package/dist/commands/wiki-page-shares.d.ts.map +1 -0
- package/dist/commands/wiki-page-shares.js +36 -0
- package/dist/commands/wiki.d.ts.map +1 -1
- package/dist/commands/wiki.js +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/browser-operation.js +1 -1
- package/dist/lib/connector-ref.d.ts +30 -0
- package/dist/lib/connector-ref.d.ts.map +1 -1
- package/dist/lib/connector-ref.js +108 -0
- package/package.json +4 -4
package/dist/commands/secrets.js
CHANGED
|
@@ -1,21 +1,106 @@
|
|
|
1
|
+
import { AGENT_SECRET_LAYER_ACTIONS, AGENT_SECRET_REQUEST_ACTION, } from '@parall/sdk';
|
|
1
2
|
import { printFiledApproval } from '../lib/approvers.js';
|
|
2
3
|
import { resolveCredentials } from '../lib/client.js';
|
|
3
4
|
import { printError, printJson, printProgress, stripPrllScheme } from '../lib/output.js';
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// The request action per layer: --from asks to use a key there, --in to have
|
|
6
|
+
// one made.
|
|
7
|
+
const ACTIONS = {
|
|
8
|
+
from: AGENT_SECRET_LAYER_ACTIONS.use,
|
|
9
|
+
in: AGENT_SECRET_LAYER_ACTIONS.new,
|
|
10
|
+
};
|
|
11
|
+
const WHERE_FORMS = 'org, team:<team_…> or user:<usr_…>';
|
|
12
|
+
/** The request an agent copies, filling in only its purpose and chat. */
|
|
13
|
+
function requestCommand(name, flag, where) {
|
|
14
|
+
return `parall secrets request ${name} ${flag} ${where} --purpose "<one line>" --chat <chat>`;
|
|
15
|
+
}
|
|
16
|
+
/** Where a key it may ask to use lives, as --from takes it. */
|
|
17
|
+
function fromOf(entry) {
|
|
18
|
+
if (entry.scope === 'org')
|
|
19
|
+
return 'org';
|
|
20
|
+
if ((entry.scope === 'user' || entry.scope === 'team') && entry.owner) {
|
|
21
|
+
return `${entry.scope}:${entry.owner.id}`;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/** The catalog with the next command beside each key and team it can act on. */
|
|
26
|
+
function withRequests(catalog) {
|
|
27
|
+
const data = (catalog.data ?? []).map((entry) => {
|
|
28
|
+
const from = entry.held ? undefined : fromOf(entry);
|
|
29
|
+
return from ? { ...entry, request: requestCommand(entry.name, '--from', from) } : entry;
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
...catalog,
|
|
33
|
+
data,
|
|
34
|
+
...(catalog.teams
|
|
35
|
+
? {
|
|
36
|
+
teams: catalog.teams.map((team) => ({
|
|
37
|
+
...team,
|
|
38
|
+
propose: requestCommand('<NAME>', '--in', `team:${team.id}`),
|
|
39
|
+
})),
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function printCatalog(q) {
|
|
45
|
+
const { client, orgId } = resolveCredentials();
|
|
46
|
+
const catalog = withRequests(await client.getMyAgentSecretCatalog(orgId, q));
|
|
47
|
+
printJson(catalog);
|
|
48
|
+
if (!catalog.deliverable) {
|
|
49
|
+
printProgress('You cannot be given keys in this organization: a request for one would be refused.');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const askable = catalog.data.filter((entry) => 'request' in entry).length;
|
|
53
|
+
if (q !== undefined && catalog.data.length === 0) {
|
|
54
|
+
printProgress(`No key matches "${q}". Propose a new one: ${requestCommand('<NAME>', '--in', '<where>')}, where <where> is org, user:<usr_…> for a person, or a team from "teams" above (copy its "propose" command); leave out --in for a key only you use.`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
printProgress(`${catalog.data.length} key(s)${q !== undefined ? ` match "${q}"` : ''}; ${askable} you can ask to use: run the "request" command beside it.`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Reads a --from or --in value: `org`, `team:<team_…>`, `user:<usr_…>`, or a
|
|
61
|
+
* bare id (with or without prll://) whose prefix says the layer.
|
|
62
|
+
*/
|
|
63
|
+
function parseWhere(flag, raw, orgId) {
|
|
64
|
+
const value = raw.trim();
|
|
65
|
+
if (value.toLowerCase() === 'org' || stripPrllScheme(value) === orgId) {
|
|
66
|
+
return { layer: 'org', id: orgId };
|
|
67
|
+
}
|
|
68
|
+
const named = /^(user|team):(.+)$/i.exec(value);
|
|
69
|
+
const said = named?.[1].toLowerCase();
|
|
70
|
+
const id = stripPrllScheme((named ? named[2] : value).trim());
|
|
71
|
+
const is = id.startsWith('usr_')
|
|
72
|
+
? 'user'
|
|
73
|
+
: id.startsWith('team_')
|
|
74
|
+
? 'team'
|
|
75
|
+
: undefined;
|
|
76
|
+
if (is && (!said || said === is))
|
|
77
|
+
return { layer: is, id };
|
|
78
|
+
throw new Error(is
|
|
79
|
+
? `${flag} ${raw}: ${id} is a ${is}, so write ${flag} ${is}:${id}`
|
|
80
|
+
: `${flag} takes ${WHERE_FORMS}, got "${raw}". Find where a key is with: parall secrets search <word>`);
|
|
81
|
+
}
|
|
8
82
|
export function registerSecretCommands(program) {
|
|
9
83
|
const secrets = program
|
|
10
84
|
.command('secrets')
|
|
11
|
-
.description('
|
|
85
|
+
.description('Find the keys you have or may ask for, and ask a person for one');
|
|
12
86
|
secrets
|
|
13
87
|
.command('list')
|
|
14
|
-
.description("List the keys you have and the
|
|
88
|
+
.description("List the keys you have and the ones you may ask to use — the organization's, your teams', other people's and agents' (names and purposes, never values) — your requests still waiting, and the teams you may propose a key in")
|
|
15
89
|
.action(async () => {
|
|
16
90
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
91
|
+
await printCatalog();
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
printError(err);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
secrets
|
|
98
|
+
.command('search')
|
|
99
|
+
.description('Like list, but only the keys whose name, purpose or owner contains the word (ignoring case); each one you may ask to use comes with the request to run')
|
|
100
|
+
.argument('<word>', 'A word from the key name, its purpose or its owner, e.g. github')
|
|
101
|
+
.action(async (word) => {
|
|
102
|
+
try {
|
|
103
|
+
await printCatalog(word);
|
|
19
104
|
}
|
|
20
105
|
catch (err) {
|
|
21
106
|
printError(err);
|
|
@@ -23,38 +108,42 @@ export function registerSecretCommands(program) {
|
|
|
23
108
|
});
|
|
24
109
|
secrets
|
|
25
110
|
.command('request')
|
|
26
|
-
.description('Post a request card for a key
|
|
111
|
+
.description('Post a request card for a key: to use one that exists (--from), to have a new one made (--in), or, with neither, for a key of your own — the person who manages you, or an org admin, enters it and a key of yours with the same name gets the new value.')
|
|
27
112
|
.argument('<name>', 'The key name your commands will read, e.g. GITHUB_TOKEN')
|
|
28
113
|
.requiredOption('--purpose <text>', 'One line for a non-engineer on what the key is for')
|
|
29
114
|
.requiredOption('--chat <chatId>', 'Chat to post the card in — the one you are working in (e.g. prll://cht_456)')
|
|
30
|
-
.option('--
|
|
31
|
-
.option('--
|
|
115
|
+
.option('--from <where>', `Ask to use a key that exists, in ${WHERE_FORMS} (a person or another agent); copy it from \`parall secrets search\`. Whoever decides for that key approves; nobody enters a value`)
|
|
116
|
+
.option('--in <where>', `Propose a new key in ${WHERE_FORMS} (a person); the person who approves types it, and the key stays there`)
|
|
117
|
+
.option('--where <text>', 'Where a person can get such a key, if you know (not with --from)')
|
|
118
|
+
.option('--shared', 'Same as --from org')
|
|
32
119
|
.action(async (name, opts) => {
|
|
33
120
|
try {
|
|
34
|
-
if (opts.shared && opts.
|
|
35
|
-
throw new Error('--
|
|
121
|
+
if (opts.shared && opts.from !== undefined) {
|
|
122
|
+
throw new Error('--shared is --from org: give one of them');
|
|
123
|
+
}
|
|
124
|
+
const fromRaw = opts.shared ? 'org' : opts.from;
|
|
125
|
+
if (fromRaw !== undefined && opts.in !== undefined) {
|
|
126
|
+
throw new Error('Give --from (use a key that exists) or --in (propose a new one), not both');
|
|
127
|
+
}
|
|
128
|
+
if (fromRaw !== undefined && opts.where !== undefined) {
|
|
129
|
+
throw new Error('--where does not apply with --from or --shared: nobody enters a value for a key that exists');
|
|
36
130
|
}
|
|
37
131
|
const { client, orgId } = resolveCredentials();
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...(opts.where !== undefined ? { source: opts.where } : {}),
|
|
54
|
-
},
|
|
55
|
-
chat_id: stripPrllScheme(opts.chat),
|
|
56
|
-
title: name,
|
|
57
|
-
});
|
|
132
|
+
const kind = fromRaw !== undefined ? 'from' : 'in';
|
|
133
|
+
const raw = fromRaw ?? opts.in;
|
|
134
|
+
const target = raw !== undefined ? parseWhere(`--${kind}`, raw, orgId) : undefined;
|
|
135
|
+
const result = await client.requestApproval(orgId, {
|
|
136
|
+
action_type: target ? ACTIONS[kind][target.layer] : AGENT_SECRET_REQUEST_ACTION,
|
|
137
|
+
resource_uri: `prll://${target ? target.id : (await client.getMe()).id}`,
|
|
138
|
+
action_payload: {
|
|
139
|
+
name,
|
|
140
|
+
purpose: opts.purpose,
|
|
141
|
+
...(opts.where !== undefined ? { source: opts.where } : {}),
|
|
142
|
+
},
|
|
143
|
+
chat_id: stripPrllScheme(opts.chat),
|
|
144
|
+
// The server writes the title; the endpoint still requires one.
|
|
145
|
+
title: name,
|
|
146
|
+
});
|
|
58
147
|
printJson(result);
|
|
59
148
|
printFiledApproval(result, result.deduplicated ? 'Already waiting' : 'Created');
|
|
60
149
|
printProgress('Now tell the people above, by name, what the key is for, then end your turn. You are woken when it is decided and the key is usable from that turn — do not wait with `parall approvals wait`.');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/** Accept a bare share ID or its canonical resource URI, never a Wiki ID. */
|
|
3
|
+
export declare function pageShareId(value: string): string;
|
|
4
|
+
export declare function registerWikiPageShareCommands(wiki: Command): void;
|
|
5
|
+
//# sourceMappingURL=wiki-page-shares.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-page-shares.d.ts","sourceRoot":"","sources":["../../src/commands/wiki-page-shares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQjD;AACD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,QAyB1D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { resolveCredentials } from '../lib/client.js';
|
|
2
|
+
import { printError, printProgress } from '../lib/output.js';
|
|
3
|
+
/** Accept a bare share ID or its canonical resource URI, never a Wiki ID. */
|
|
4
|
+
export function pageShareId(value) {
|
|
5
|
+
const id = value.startsWith('prll://') ? value.slice('prll://'.length) : value;
|
|
6
|
+
if (!/^wsh_[a-zA-Z0-9_-]+$/.test(id) || id.length > 64) {
|
|
7
|
+
throw new Error('Expected a wsh_ share ID or prll://wsh_…; use: parall wiki shared cat <share>');
|
|
8
|
+
}
|
|
9
|
+
return id;
|
|
10
|
+
}
|
|
11
|
+
export function registerWikiPageShareCommands(wiki) {
|
|
12
|
+
wiki
|
|
13
|
+
.command('shared')
|
|
14
|
+
.description('Read a page explicitly shared with your account')
|
|
15
|
+
.command('cat')
|
|
16
|
+
.description('Read the latest published version of a page shared with your account')
|
|
17
|
+
.argument('<share>', 'wsh_ share ID or prll://wsh_… provided by the page owner')
|
|
18
|
+
.action(async (value) => {
|
|
19
|
+
try {
|
|
20
|
+
const id = pageShareId(value);
|
|
21
|
+
const { client } = resolveCredentials();
|
|
22
|
+
const page = await client.getSharedWikiPage(id);
|
|
23
|
+
process.stdout.write(page.content);
|
|
24
|
+
if (!page.content.endsWith('\n'))
|
|
25
|
+
process.stdout.write('\n');
|
|
26
|
+
const name = page.shared_by?.display_name?.trim() || page.shared_by?.id;
|
|
27
|
+
const label = name && page.shared_by?.type === 'agent' ? `${name} [agent]` : name;
|
|
28
|
+
const source = [label, page.organization_name].filter(Boolean).join(' · ');
|
|
29
|
+
printProgress(`Read-only · latest published version · ${page.path}${source ? ` · Shared by ${source}` : ''}`);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
printError(error);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAktBpD"}
|
package/dist/commands/wiki.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { registerWikiPageShareCommands } from './wiki-page-shares.js';
|
|
1
2
|
import { registerWikiChangesetCommands } from './wiki-changesets.js';
|
|
2
3
|
import { promises as fs } from 'node:fs';
|
|
3
4
|
import { resolveCredentials } from '../lib/client.js';
|
|
@@ -8,6 +9,7 @@ import { registerWikiCommentCommands } from './wiki-comments.js';
|
|
|
8
9
|
import { registerWikiEditCommand } from './wiki-edit.js';
|
|
9
10
|
export function registerWikiCommands(program) {
|
|
10
11
|
const wiki = program.command('wiki').description('Parall Wiki — read, edit, and propose changes');
|
|
12
|
+
registerWikiPageShareCommands(wiki);
|
|
11
13
|
// ---- CRUD ----
|
|
12
14
|
wiki
|
|
13
15
|
.command('create')
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import { registerAgentCommands } from './commands/agents.js';
|
|
5
5
|
import { registerApprovalCommands } from './commands/approvals.js';
|
|
6
|
+
import { registerCloudProfileCommands } from './commands/cloud-profile.js';
|
|
6
7
|
import { registerBrowserCommands } from './commands/browser.js';
|
|
7
8
|
import { registerChatCommands } from './commands/chats.js';
|
|
8
9
|
import { registerClipCommands } from './commands/clip.js';
|
|
@@ -77,6 +78,7 @@ registerFileCommands(program);
|
|
|
77
78
|
registerMachineCommands(program);
|
|
78
79
|
registerClipCommands(program);
|
|
79
80
|
registerBrowserCommands(program);
|
|
81
|
+
registerCloudProfileCommands(program);
|
|
80
82
|
registerSlackCommands(program);
|
|
81
83
|
registerMSTeamsCommands(program);
|
|
82
84
|
registerWechatCommands(program);
|
|
@@ -30,7 +30,7 @@ export function browserError(err, anchor = {}, acceptanceUnknown = false) {
|
|
|
30
30
|
hint = `${hint ? `${hint} ` : ''}Stop and ask an org admin to enable Browser Use for this organization.`;
|
|
31
31
|
if (code === 'EDGE_ACTIVATING')
|
|
32
32
|
hint =
|
|
33
|
-
"The
|
|
33
|
+
"The hosted Profile is starting; this action has not run. Wait for Retry-After, then decide whether to try again within the user's budget.";
|
|
34
34
|
if (code === 'INSUFFICIENT_CREDITS' || code === 'CREDIT_UNAVAILABLE')
|
|
35
35
|
hint = 'Stop and tell the user about the balance or billing problem before another action.';
|
|
36
36
|
if (!hint && (code === 'UNKNOWN_OUTCOME' || code === 'OUTCOME_UNKNOWN'))
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
import type { ClipRegistryEntry, ParallClient } from '@parall/sdk';
|
|
1
2
|
/** Printed after a usage error (missing argument, unknown option) under `parall connector`. */
|
|
2
3
|
export declare const CONNECTOR_USAGE_HINT = "(list installed connectors with `parall connector list`; add --help for usage)";
|
|
4
|
+
export declare const CLIP_REF_HELP = "Registry connector id (crg_...), an exact connector name (your org first, then a unique public match), or org_<id>/<name> to pin the publisher (discover ids with `parall connector search`)";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an install/info argument to a registry entry with per-name queries
|
|
7
|
+
* only — never by listing the catalog, which spans every public clip on the
|
|
8
|
+
* platform. Bare names resolve in the CALLER'S org first (an authoritative
|
|
9
|
+
* point read immune to a third party publishing the same name), then fall
|
|
10
|
+
* back to a unique exact match among visible public clips; several publishers
|
|
11
|
+
* sharing the name is an explicit ambiguity error, never "first match wins".
|
|
12
|
+
* Returns null on a clean not-found; non-404 errors (e.g. 403
|
|
13
|
+
* CLIP_NOT_APPROVED) propagate untouched.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveRegistryRef(client: ParallClient, orgId: string, ref: string): Promise<ClipRegistryEntry | null>;
|
|
16
|
+
export declare function clipNotFoundError(ref: string): Error;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a connector reference installed-first (the historical semantic of
|
|
19
|
+
* `connector info`; the installed list is org-local and uncapped), then fall
|
|
20
|
+
* back to point-querying the registry: an author checking a connector they
|
|
21
|
+
* published but never installed — the publish→review→revise loop — must not
|
|
22
|
+
* dead-end, and a person can be asked to connect one nobody installed yet.
|
|
23
|
+
* The installed shortcut obeys the SAME bare-name contract as
|
|
24
|
+
* resolveRegistryRef: an org can install same-name connectors from several
|
|
25
|
+
* publishers (installs are keyed by id), so a plain first-match would pick an
|
|
26
|
+
* arbitrary one — own org wins, and a foreign tie is the same explicit
|
|
27
|
+
* ambiguity error, never a silent pick. Returns null on a clean not-found.
|
|
28
|
+
*/
|
|
29
|
+
export declare function findConnector(client: ParallClient, orgId: string, ref: string): Promise<{
|
|
30
|
+
entry: ClipRegistryEntry;
|
|
31
|
+
installed: boolean;
|
|
32
|
+
} | null>;
|
|
3
33
|
//# sourceMappingURL=connector-ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-ref.d.ts","sourceRoot":"","sources":["../../src/lib/connector-ref.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,mFACiD,CAAC"}
|
|
1
|
+
{"version":3,"file":"connector-ref.d.ts","sourceRoot":"","sources":["../../src/lib/connector-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnE,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,mFACiD,CAAC;AAEnF,eAAO,MAAM,aAAa,iMACsK,CAAC;AA2BjM;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA6CnC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAIpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,KAAK,EAAE,iBAAiB,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,CAelE"}
|
|
@@ -1,2 +1,110 @@
|
|
|
1
1
|
/** Printed after a usage error (missing argument, unknown option) under `parall connector`. */
|
|
2
2
|
export const CONNECTOR_USAGE_HINT = '(list installed connectors with `parall connector list`; add --help for usage)';
|
|
3
|
+
export const CLIP_REF_HELP = 'Registry connector id (crg_...), an exact connector name (your org first, then a unique public match), or org_<id>/<name> to pin the publisher (discover ids with `parall connector search`)';
|
|
4
|
+
/**
|
|
5
|
+
* The clip-ref grammar shared with the standalone Solo CLI
|
|
6
|
+
* (desktop/edge/cli/parall-clip.mjs, parseClipRef) — the two install surfaces
|
|
7
|
+
* must read the same ref the same way. Any slash makes a namespaced ref, and
|
|
8
|
+
* only org ids are authoritative namespaces; throws on a malformed ref.
|
|
9
|
+
*/
|
|
10
|
+
function parseClipRef(ref) {
|
|
11
|
+
if (ref.startsWith('crg_'))
|
|
12
|
+
return { id: ref };
|
|
13
|
+
const slash = ref.indexOf('/');
|
|
14
|
+
if (slash === -1)
|
|
15
|
+
return { name: ref };
|
|
16
|
+
const namespace = ref.slice(0, slash);
|
|
17
|
+
const name = ref.slice(slash + 1);
|
|
18
|
+
if (!namespace || !name || name.includes('/')) {
|
|
19
|
+
throw new Error(`Invalid connector reference "${ref}". ${CLIP_REF_HELP}.`);
|
|
20
|
+
}
|
|
21
|
+
if (!namespace.startsWith('org_')) {
|
|
22
|
+
throw new Error(`Publisher namespace "${namespace}" is not authoritative yet. Use an immutable crg_ id or org_<id>/${name}.`);
|
|
23
|
+
}
|
|
24
|
+
return { namespace, name };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve an install/info argument to a registry entry with per-name queries
|
|
28
|
+
* only — never by listing the catalog, which spans every public clip on the
|
|
29
|
+
* platform. Bare names resolve in the CALLER'S org first (an authoritative
|
|
30
|
+
* point read immune to a third party publishing the same name), then fall
|
|
31
|
+
* back to a unique exact match among visible public clips; several publishers
|
|
32
|
+
* sharing the name is an explicit ambiguity error, never "first match wins".
|
|
33
|
+
* Returns null on a clean not-found; non-404 errors (e.g. 403
|
|
34
|
+
* CLIP_NOT_APPROVED) propagate untouched.
|
|
35
|
+
*/
|
|
36
|
+
export async function resolveRegistryRef(client, orgId, ref) {
|
|
37
|
+
const notFoundToNull = (err) => {
|
|
38
|
+
if (err.status === 404)
|
|
39
|
+
return null;
|
|
40
|
+
throw err;
|
|
41
|
+
};
|
|
42
|
+
const parsed = parseClipRef(ref);
|
|
43
|
+
if ('id' in parsed) {
|
|
44
|
+
return client.getRegistryClip(orgId, parsed.id).catch(notFoundToNull);
|
|
45
|
+
}
|
|
46
|
+
if ('namespace' in parsed) {
|
|
47
|
+
return client.resolveRegistryClip(orgId, parsed.namespace, parsed.name).catch(notFoundToNull);
|
|
48
|
+
}
|
|
49
|
+
const own = await client.resolveRegistryClip(orgId, orgId, parsed.name).catch(notFoundToNull);
|
|
50
|
+
if (own)
|
|
51
|
+
return own;
|
|
52
|
+
// Bare name, not published by the caller's org: accept a UNIQUE exact match
|
|
53
|
+
// among visible clips. Search is fuzzy (name+description substrings), so
|
|
54
|
+
// exact-filter its max-size page; a page-sized crowd of lookalikes could
|
|
55
|
+
// still hide an exact match — the crg_ id and org_<id>/<name> forms stay
|
|
56
|
+
// the always-sound addresses. A 404 here is a server without the search
|
|
57
|
+
// route, not a lookup miss — degrade to "no matches" so the caller gets
|
|
58
|
+
// the guidance error instead of a bare route error.
|
|
59
|
+
const page = await client
|
|
60
|
+
.searchOrgRegistryClips(orgId, parsed.name, { limit: 100 })
|
|
61
|
+
.catch((err) => {
|
|
62
|
+
if (err.status === 404)
|
|
63
|
+
return [];
|
|
64
|
+
throw err;
|
|
65
|
+
});
|
|
66
|
+
const matches = page.filter((c) => c.name === parsed.name);
|
|
67
|
+
if (matches.length > 1) {
|
|
68
|
+
const candidates = matches.map((c) => `${c.org_id}/${c.name} (${c.id})`).join(', ');
|
|
69
|
+
throw new Error(`Connector name "${parsed.name}" is ambiguous across publishers: ${candidates}. Use the crg_ id or the org_<id>/<name> form.`);
|
|
70
|
+
}
|
|
71
|
+
// A FULL page proves nothing about uniqueness or absence: rows order by
|
|
72
|
+
// (name, id), so the exact-name block can straddle the page boundary and a
|
|
73
|
+
// single visible match — or none — may be a truncation artifact. Two exact
|
|
74
|
+
// matches on the page prove ambiguity outright (handled above); otherwise
|
|
75
|
+
// abstain rather than risk installing the wrong publisher's clip.
|
|
76
|
+
if (page.length >= 100) {
|
|
77
|
+
throw new Error(`Too many connectors have names or descriptions similar to "${parsed.name}" for a bare name to resolve safely. Pass the crg_ id or the org_<id>/<name> form (find them with \`parall connector search <text>\`).`);
|
|
78
|
+
}
|
|
79
|
+
return matches[0] ?? null;
|
|
80
|
+
}
|
|
81
|
+
export function clipNotFoundError(ref) {
|
|
82
|
+
return new Error(`No registry connector matching "${ref}". Pass a crg_ id, the exact name of a visible connector, or org_<id>/<name> to pin its publisher — discover ids with \`parall connector search <text>\`.`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a connector reference installed-first (the historical semantic of
|
|
86
|
+
* `connector info`; the installed list is org-local and uncapped), then fall
|
|
87
|
+
* back to point-querying the registry: an author checking a connector they
|
|
88
|
+
* published but never installed — the publish→review→revise loop — must not
|
|
89
|
+
* dead-end, and a person can be asked to connect one nobody installed yet.
|
|
90
|
+
* The installed shortcut obeys the SAME bare-name contract as
|
|
91
|
+
* resolveRegistryRef: an org can install same-name connectors from several
|
|
92
|
+
* publishers (installs are keyed by id), so a plain first-match would pick an
|
|
93
|
+
* arbitrary one — own org wins, and a foreign tie is the same explicit
|
|
94
|
+
* ambiguity error, never a silent pick. Returns null on a clean not-found.
|
|
95
|
+
*/
|
|
96
|
+
export async function findConnector(client, orgId, ref) {
|
|
97
|
+
const installed = await client.listInstalledRegistryClips(orgId);
|
|
98
|
+
const byId = installed.find((c) => c.id === ref);
|
|
99
|
+
const byName = byId ? [] : installed.filter((c) => c.name === ref);
|
|
100
|
+
const own = byId ?? byName.find((c) => c.org_id === orgId);
|
|
101
|
+
if (!own && byName.length > 1) {
|
|
102
|
+
const candidates = byName.map((c) => `${c.org_id}/${c.name} (${c.id})`).join(', ');
|
|
103
|
+
throw new Error(`Several installed connectors are named "${ref}": ${candidates}. Use the crg_ id or the org_<id>/<name> form.`);
|
|
104
|
+
}
|
|
105
|
+
const hit = own ?? byName[0];
|
|
106
|
+
if (hit)
|
|
107
|
+
return { entry: hit, installed: true };
|
|
108
|
+
const entry = await resolveRegistryRef(client, orgId, ref);
|
|
109
|
+
return entry ? { entry, installed: false } : null;
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.88.0",
|
|
4
4
|
"description": "CLI client for Parall — universal agent & human access to Parall API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"node-diff3": "3.2.1",
|
|
43
43
|
"tar-stream": "^3.2.1",
|
|
44
44
|
"zod": "^4.3.6",
|
|
45
|
-
"@parall/
|
|
46
|
-
"@parall/
|
|
45
|
+
"@parall/agent-core": "1.88.0",
|
|
46
|
+
"@parall/sdk": "1.88.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@dnd-kit/core": "6.3.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"tw-animate-css": "1.4.0",
|
|
72
72
|
"typescript": "^5.7.0",
|
|
73
73
|
"vite": "6.4.1",
|
|
74
|
-
"@parall/agent-core": "1.
|
|
74
|
+
"@parall/agent-core": "1.88.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "node scripts/generate-miniapp-sdk.mjs --check && node scripts/generate-local-runner.mjs --check && node scripts/generate-app-templates.mjs --check && tsc",
|