@parall/cli 1.93.0 → 1.94.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 (34) hide show
  1. package/dist/commands/apps-publish.d.ts.map +1 -1
  2. package/dist/commands/apps-publish.js +5 -2
  3. package/dist/commands/apps-scaffold.d.ts +3 -2
  4. package/dist/commands/apps-scaffold.d.ts.map +1 -1
  5. package/dist/commands/apps-scaffold.js +13 -4
  6. package/dist/commands/apps-shared-template-compose.d.ts +57 -0
  7. package/dist/commands/apps-shared-template-compose.d.ts.map +1 -0
  8. package/dist/commands/apps-shared-template-compose.js +176 -0
  9. package/dist/commands/apps-shared-template-init.d.ts +13 -0
  10. package/dist/commands/apps-shared-template-init.d.ts.map +1 -0
  11. package/dist/commands/apps-shared-template-init.js +130 -0
  12. package/dist/commands/apps-shared-template-package.d.ts +10 -0
  13. package/dist/commands/apps-shared-template-package.d.ts.map +1 -0
  14. package/dist/commands/apps-shared-template-package.js +112 -0
  15. package/dist/commands/apps-shared-template.d.ts +44 -0
  16. package/dist/commands/apps-shared-template.d.ts.map +1 -0
  17. package/dist/commands/apps-shared-template.js +214 -0
  18. package/dist/commands/apps-template-catalog.d.ts +5 -1
  19. package/dist/commands/apps-template-catalog.d.ts.map +1 -1
  20. package/dist/commands/apps-template-catalog.js +17 -4
  21. package/dist/commands/apps-template-download.d.ts +14 -1
  22. package/dist/commands/apps-template-download.d.ts.map +1 -1
  23. package/dist/commands/apps-template-download.js +6 -4
  24. package/dist/commands/apps-template-ref.d.ts +4 -0
  25. package/dist/commands/apps-template-ref.d.ts.map +1 -0
  26. package/dist/commands/apps-template-ref.js +31 -0
  27. package/dist/commands/apps-template-share-failure.d.ts +22 -0
  28. package/dist/commands/apps-template-share-failure.d.ts.map +1 -0
  29. package/dist/commands/apps-template-share-failure.js +201 -0
  30. package/dist/commands/apps-template-share.d.ts +19 -0
  31. package/dist/commands/apps-template-share.d.ts.map +1 -0
  32. package/dist/commands/apps-template-share.js +278 -0
  33. package/dist/commands/clip.js +8 -0
  34. package/package.json +4 -4
@@ -0,0 +1,278 @@
1
+ import { resolveCredentials } from '../lib/client.js';
2
+ import { printError, printJson, printProgress, stripPrllScheme } from '../lib/output.js';
3
+ import { readTextFileArg } from '../lib/text-input.js';
4
+ import { day } from './apps-shared-template.js';
5
+ import { sharedTemplateId } from './apps-template-ref.js';
6
+ import { shareCommandLine, shareFailure, } from './apps-template-share-failure.js';
7
+ /**
8
+ * `parall app templates share` and `unshare` (mini-app-template-sharing-design.md
9
+ * §6.1): the agent of an app's author or of an org owner/admin shares the
10
+ * app's current version — its source and table structure, never its data —
11
+ * behind one link, with a note on how the team runs the app. The server
12
+ * checks everything that would go out (§5.2) and stores nothing when it finds
13
+ * the app's data or a key's value in it; apps-template-share-failure.ts
14
+ * turns that, and every other refusal, into what to do next. Names and IDs
15
+ * of the organization do not stop a share (§5.3): share lists them after
16
+ * the link as needing no change, so the agent does not clean them out of
17
+ * its own app.
18
+ */
19
+ const NOTE_MAX = 20_000;
20
+ const EXPIRIES = ['7d', '30d', '90d', 'never'];
21
+ const SHARE_HELP = `
22
+ Share only when the app's author or an org owner/admin asks you to; the
23
+ platform checks that too. What is shared is the app's current version: its
24
+ source and the structure of its tables, never its data. Anyone signed in
25
+ who has the link can build their own app from it, here or in another
26
+ organization.
27
+
28
+ The note (Markdown, at most 20,000 characters) is what the other team's
29
+ agent builds from. Write four things:
30
+ 1. What the app does.
31
+ 2. How the team uses it.
32
+ 3. How data gets into it.
33
+ 4. What you do around it: when you are woken, what you read, the rules
34
+ you write by, what you do at what time.
35
+
36
+ The template page shows a clickable demo: the app's real built pages,
37
+ answered from made-up data. Before you publish, write demo/demo.js in the
38
+ project — a plain script, no import or export, shared as written:
39
+
40
+ function createDemo(now) {
41
+ const items = [{ id: 1, title: 'Sample order', status: 'new' }];
42
+ return {
43
+ viewer: { display_name: 'Alex Demo', role: 'member' },
44
+ responders: {
45
+ items_list: () => ({ items }),
46
+ item_close: ({ id }) => {
47
+ const item = items.find((i) => i.id === id);
48
+ if (!item) throw new Error('No such item');
49
+ item.status = 'closed';
50
+ return item;
51
+ },
52
+ },
53
+ };
54
+ }
55
+
56
+ Answer every action in public/manifest.json with what the real action
57
+ returns, and throw new Error('…') where it would fail. A share without
58
+ demo/demo.js in the published source is refused.
59
+
60
+ Before storing anything, the platform compares all of it — the source,
61
+ demo.js and the built pages — with the values in the app's Database and the
62
+ keys you can read. When it finds one, nothing is
63
+ stored and each place is listed: change the app and publish again; leave
64
+ the file out (--exclude <path>); or, for a value that is not data (a status
65
+ name stored as text), let it through (--allow-value <value>). A key's value
66
+ is never let through: read it as ctx.env.<NAME> in the action instead.
67
+
68
+ Names and IDs of your organization — the names of members, channels and the
69
+ organization, Parall IDs, prll:// links — do not stop a share: they are
70
+ shared as they are, and listed as hints once it is done. They need no
71
+ change: the agent that builds from the template replaces them with its own,
72
+ and changing them would change your own app.
73
+
74
+ The link stays open 30 days unless --expires says otherwise, counted again
75
+ from every share. Running this again while the link is open updates the
76
+ same link to the app's current version and the new note; once it has
77
+ expired or been revoked, you get a new link. To revoke it:
78
+ parall app templates unshare --app <app_…>
79
+
80
+ Example:
81
+ parall app templates share --app app_… --note-file note.md`;
82
+ function collect(value, previous) {
83
+ return [...previous, value];
84
+ }
85
+ /** The app of share / unshare: app_… or prll://app_…. Anything else stops
86
+ * before a request, with the command that finds the app. */
87
+ export function parseShareApp(raw, verb) {
88
+ const id = stripPrllScheme(raw.trim());
89
+ if (id.startsWith('app_'))
90
+ return id;
91
+ const shared = sharedTemplateId(raw);
92
+ const fix = shared
93
+ ? `${shared} is a shared template, not an app; ${verb} takes the app it was shared from. Find the app with: parall app list`
94
+ : id.startsWith('adb_')
95
+ ? `${id} is a Database. Its apps: parall db get ${id}`
96
+ : 'Find the app with: parall app list';
97
+ throw new Error(`parall app templates ${verb} --app takes an app ID (app_… or prll://app_…), got "${raw}". ${fix}`);
98
+ }
99
+ /** A path for --exclude, as the source has it: no leading ./ or trailing /. */
100
+ function excludePath(raw) {
101
+ const path = raw
102
+ .trim()
103
+ .replace(/^(\.\/)+/, '')
104
+ .replace(/\/+$/, '');
105
+ if (path === '' || path.startsWith('/') || path.split('/').includes('..')) {
106
+ throw new Error(`--exclude takes a file or folder of the app's source, like db/seed.sql or exports/, got "${raw}"`);
107
+ }
108
+ return path;
109
+ }
110
+ /** The request share sends, checked here first: the note is there and fits,
111
+ * the expiry is one the server offers. Nothing is sent for what was not given. */
112
+ export function shareRequest(opts) {
113
+ if (opts.expires !== undefined && !EXPIRIES.includes(opts.expires)) {
114
+ throw new Error(`--expires must be ${EXPIRIES.join(', ')}; got "${opts.expires}"`);
115
+ }
116
+ const note = readTextFileArg('--note-file', opts.noteFile);
117
+ if (note.trim() === '') {
118
+ throw new Error(`The note in ${opts.noteFile} is empty. Write what the app does, how the team uses it, how data gets into it and what you do around it, then run this again.`);
119
+ }
120
+ const length = [...note].length;
121
+ if (length > NOTE_MAX) {
122
+ throw new Error(`The note in ${opts.noteFile} is ${length} characters, and it can be at most ${NOTE_MAX}. Shorten it and run this again.`);
123
+ }
124
+ if (opts.allowValue.some((value) => value === '')) {
125
+ throw new Error('--allow-value takes the value to let through; an empty one lets nothing through');
126
+ }
127
+ const exclude = [...new Set(opts.exclude.map(excludePath))];
128
+ const allow = [...new Set(opts.allowValue)];
129
+ return {
130
+ note,
131
+ ...(exclude.length > 0 ? { exclude } : {}),
132
+ ...(allow.length > 0 ? { allow_values: allow } : {}),
133
+ ...(opts.expires !== undefined ? { expires: opts.expires } : {}),
134
+ };
135
+ }
136
+ /** How many names and IDs share writes out, and how many places for each;
137
+ * the result's `hints` has every one Parall listed. */
138
+ const HINTS_SHOWN = 30;
139
+ const HINT_PLACES_SHOWN = 3;
140
+ /** What each kind of hint is called, in the order they are written out. */
141
+ const HINT_KINDS = new Map([
142
+ ['org', 'organization name'],
143
+ ['member', 'member name'],
144
+ ['channel', 'channel name'],
145
+ ['parall_id', 'Parall ID'],
146
+ ['parall_link', 'Parall link'],
147
+ ]);
148
+ const HINT_ORDER = [...HINT_KINDS.keys()];
149
+ function isHint(value) {
150
+ const h = value;
151
+ return (typeof h === 'object' &&
152
+ h !== null &&
153
+ typeof h.kind === 'string' &&
154
+ typeof h.where === 'string' &&
155
+ typeof h.line === 'number' &&
156
+ typeof h.text === 'string');
157
+ }
158
+ /** The names and IDs of the organization the template holds as they are
159
+ * (design §5.3), each once with the first places it is in, after a line
160
+ * saying they need no change. None when there are none, or the server is
161
+ * one from before hints. */
162
+ export function shareHints(result) {
163
+ const hints = Array.isArray(result.hints) ? result.hints.filter(isHint) : [];
164
+ if (hints.length === 0)
165
+ return [];
166
+ const found = new Map();
167
+ for (const hint of hints) {
168
+ const key = JSON.stringify([hint.kind, hint.text]);
169
+ const group = found.get(key) ?? { kind: hint.kind, text: hint.text, places: [] };
170
+ found.set(key, group);
171
+ const place = hint.line > 0 ? `${hint.where}:${hint.line}` : hint.where;
172
+ if (!group.places.includes(place))
173
+ group.places.push(place);
174
+ }
175
+ const rank = (kind) => {
176
+ const at = HINT_ORDER.indexOf(kind);
177
+ return at < 0 ? HINT_ORDER.length : at;
178
+ };
179
+ const groups = [...found.values()].sort((a, b) => rank(a.kind) - rank(b.kind));
180
+ const lines = groups.slice(0, HINTS_SHOWN).map(({ kind, text, places }) => {
181
+ const rest = places.length > HINT_PLACES_SHOWN ? ` and ${places.length - HINT_PLACES_SHOWN} more` : '';
182
+ return ` ${HINT_KINDS.get(kind) ?? kind} ${JSON.stringify(text)}: ${places.slice(0, HINT_PLACES_SHOWN).join(', ')}${rest}`;
183
+ });
184
+ const more = [
185
+ ...(groups.length > HINTS_SHOWN
186
+ ? [`${groups.length - HINTS_SHOWN} more (all in the result's "hints")`]
187
+ : []),
188
+ ...(result.hints_truncated === true ? ['more that Parall did not list'] : []),
189
+ ];
190
+ if (more.length > 0)
191
+ lines.push(` … and ${more.join(', and ')}.`);
192
+ return [
193
+ 'These names and IDs of your organization were shared as they are and need no change: the agent that builds from the template replaces them with its own, and changing them would change your own app.',
194
+ ...lines,
195
+ ];
196
+ }
197
+ /** "a", "a and b", "a, b and c". */
198
+ function inWords(items) {
199
+ return items.length > 2
200
+ ? `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`
201
+ : items.join(' and ');
202
+ }
203
+ /** What share prints on stderr when it worked: the link, what to tell, and
204
+ * the names and IDs it holds that need no change. */
205
+ export function shareSummary(result, appId) {
206
+ const { share } = result;
207
+ const open = share.expires_at ? `open until ${day(share.expires_at)}` : 'open until revoked';
208
+ const first = result.created
209
+ ? `Shared version ${share.version_seq} of ${appId} as a template, ${open}: ${share.url} (a new link).`
210
+ : `Updated the open link to version ${share.version_seq} of ${appId}, ${open}: ${share.url} (the same link as before).`;
211
+ const hints = shareHints(result);
212
+ const tell = [
213
+ ...(result.removed.length > 0 ? [`what was left out (removed: ${result.removed.length})`] : []),
214
+ ...(result.tables.left_out.length > 0
215
+ ? [`which tables are not in it (tables.left_out: ${result.tables.left_out.join(', ')})`]
216
+ : []),
217
+ ...(hints.length > 0 ? ['which names and IDs of your organization it holds (below)'] : []),
218
+ ];
219
+ return [
220
+ first,
221
+ `Give the person this link${tell.length > 0 ? `, and say ${inWords(tell)}` : ''}.`,
222
+ ...hints,
223
+ ];
224
+ }
225
+ export function registerTemplateShareCommands(templates) {
226
+ templates
227
+ .command('share')
228
+ .description("Share an app as a template: a link anyone signed in can build their own app from (only when the app's author or an org owner/admin asks you)")
229
+ .requiredOption('--app <appId>', 'The app to share (app_… or prll://app_…)')
230
+ .requiredOption('--note-file <path>', "The note, Markdown, from a file ('-' = stdin): what it covers is below")
231
+ .option('--exclude <path>', "A file or folder of the app's source to leave out (repeatable)", collect, [])
232
+ .option('--allow-value <value>', "A value from the app's Database that is not data, to let through (repeatable)", collect, [])
233
+ .option('--expires <period>', 'How long the link stays open: 7d, 30d (default), 90d or never')
234
+ .addHelpText('after', SHARE_HELP)
235
+ .showHelpAfterError('Example: parall app templates share --app app_… --note-file note.md')
236
+ .action(async (opts) => {
237
+ try {
238
+ const appId = parseShareApp(opts.app, 'share');
239
+ const request = shareRequest(opts);
240
+ const { client, orgId } = resolveCredentials();
241
+ let result;
242
+ try {
243
+ result = await client.shareMiniAppTemplate(orgId, appId, request);
244
+ }
245
+ catch (err) {
246
+ const failure = shareFailure(err, appId, shareCommandLine(appId, opts));
247
+ return printError(failure.error, undefined, failure.step);
248
+ }
249
+ printJson(result);
250
+ for (const line of shareSummary(result, appId))
251
+ printProgress(line);
252
+ }
253
+ catch (err) {
254
+ printError(err);
255
+ }
256
+ });
257
+ templates
258
+ .command('unshare')
259
+ .description("Revoke an app's template link: it stops opening at once; apps already built from it are not affected")
260
+ .requiredOption('--app <appId>', 'The app whose link to revoke (app_… or prll://app_…)')
261
+ .showHelpAfterError('Example: parall app templates unshare --app app_…')
262
+ .action(async (opts) => {
263
+ try {
264
+ const appId = parseShareApp(opts.app, 'unshare');
265
+ const { client, orgId } = resolveCredentials();
266
+ const open = await client.getMiniAppTemplateShare(orgId, appId);
267
+ // Revoked even when none was open: one shared meanwhile goes too.
268
+ await client.revokeMiniAppTemplateShare(orgId, appId);
269
+ printJson({ app_id: appId, revoked: open ? { id: open.id, url: open.url } : null });
270
+ printProgress(open
271
+ ? `${open.url} no longer opens; apps already built from it are not affected.`
272
+ : `${appId} had no open template link; nothing changed.`);
273
+ }
274
+ catch (err) {
275
+ printError(err);
276
+ }
277
+ });
278
+ }
@@ -256,6 +256,14 @@ function registerClipTree(clip) {
256
256
  ...(entry.approved_version_id ? { approved_version_id: entry.approved_version_id } : {}),
257
257
  ...(entry.review_status ? { review_status: entry.review_status } : {}),
258
258
  ...(entry.review_note ? { review_note: entry.review_note } : {}),
259
+ // Your org's own connector: a display-name request awaiting Parall,
260
+ // or why the last one was rejected. Requests are made in the Web app.
261
+ ...(entry.display_name_request
262
+ ? { display_name_request: entry.display_name_request }
263
+ : {}),
264
+ ...(entry.display_name_review_note
265
+ ? { display_name_review_note: entry.display_name_review_note }
266
+ : {}),
259
267
  };
260
268
  printJson(info);
261
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parall/cli",
3
- "version": "1.93.0",
3
+ "version": "1.94.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/sdk": "1.93.0",
46
- "@parall/agent-core": "1.93.0"
45
+ "@parall/agent-core": "1.94.0",
46
+ "@parall/sdk": "1.94.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.93.0"
74
+ "@parall/agent-core": "1.94.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",