@parall/cli 1.76.0 → 1.78.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.
@@ -1 +1 @@
1
- {"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,QA8KxD"}
1
+ {"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,QAgLxD"}
@@ -22,6 +22,7 @@ export function registerApprovalCommands(program) {
22
22
  .requiredOption('--title <title>', 'Human-readable title for the request')
23
23
  .option('--reason <text>', 'Why this action is needed')
24
24
  .option('--payload <json>', PAYLOAD_HELP)
25
+ .option('--thread-root-id <id>', 'Post the card as a reply in this thread of --chat')
25
26
  .action(async (opts) => {
26
27
  try {
27
28
  const { client, orgId } = resolveCredentials();
@@ -32,6 +33,7 @@ export function registerApprovalCommands(program) {
32
33
  chat_id: stripPrllScheme(opts.chat),
33
34
  title: opts.title,
34
35
  reason: opts.reason,
36
+ ...(opts.threadRootId ? { thread_root_id: stripPrllScheme(opts.threadRootId) } : {}),
35
37
  });
36
38
  printJson(result);
37
39
  printFiledApproval(result, result.deduplicated ? 'Already waiting' : 'Created');
@@ -1 +1 @@
1
- {"version":3,"file":"apps-publish.d.ts","sourceRoot":"","sources":["../../src/commands/apps-publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC;;;;;;wEAMwE;AACxE,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,QAiJtD;AAgCD,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;yBAEyB;AACzB,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,eAAe,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8D7F;AA4BD,iBAAe,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCrE;AAGD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"apps-publish.d.ts","sourceRoot":"","sources":["../../src/commands/apps-publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC;;;;;;wEAMwE;AACxE,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,QAiJtD;AAwCD,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;yBAEyB;AACzB,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,eAAe,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8D7F;AA4BD,iBAAe,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCrE;AAGD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
@@ -10,6 +10,7 @@ import { resolveCredentials } from '../lib/client.js';
10
10
  import { printError, printJson, printProgress, stripPrllScheme } from '../lib/output.js';
11
11
  import { appIdFrom, outputPath, withApp } from './apps-args.js';
12
12
  import { checkActions } from './apps-check.js';
13
+ import { DEV_VARS_FILE } from './apps-dev-vars.js';
13
14
  /** `parall app publish / versions / rollback / pull` (design §7.3): the
14
15
  * agent's machine builds, the platform accepts. publish = tar the dist and
15
16
  * the source, reserve a seq, PUT both content-addressed tarballs, finalize
@@ -159,6 +160,13 @@ async function assertBundleRoot(dist) {
159
160
  }
160
161
  /** Anything a source tree drags along that is never source. */
161
162
  const sourceExcludes = new Set(['node_modules', '.git', 'dist', '.DS_Store']);
163
+ /** The source archive is kept for `parall app pull`, so it must not carry
164
+ * the local secrets file — `.dev.vars` and its variants, as the scaffold's
165
+ * .gitignore lists them (`.dev.vars*`): secret values never leave this
166
+ * machine (mini-app-network-design.md §7.6). */
167
+ function excludedFromSource(name) {
168
+ return sourceExcludes.has(name) || name.startsWith(DEV_VARS_FILE);
169
+ }
162
170
  // Mirrors the server's archive caps (model.MiniAppBundleArchiveMaxBytes /
163
171
  // MiniAppSourceArchiveMaxBytes).
164
172
  const BUNDLE_ARCHIVE_MAX_BYTES = 22 * 1024 * 1024;
@@ -177,7 +185,7 @@ async function packDirectory(dir, opts) {
177
185
  const files = [];
178
186
  const walk = async (current) => {
179
187
  for (const entry of await fs.readdir(current, { withFileTypes: true })) {
180
- if (opts.excludeDefaults && sourceExcludes.has(entry.name))
188
+ if (opts.excludeDefaults && excludedFromSource(entry.name))
181
189
  continue;
182
190
  const full = join(current, entry.name);
183
191
  if (entry.isDirectory()) {
@@ -65,7 +65,7 @@ export const TEMPLATE_WITH_ACTIONS = {
65
65
  "actions/items.ts": "import type { Item, ItemInput, ItemStatus } from '@shared/items';\nimport { type ActionContext, ActionError } from './parall-actions';\nimport { rememberViewer } from './people';\n\n// The example list behind src/pages/items: everyone in the organization\n// reads every item; the creator or an org owner/admin changes or deletes it.\n// The rule lives in SQL, keyed on ctx.viewer (see db/schema.sql for an\n// access-list variant).\n\nconst COLUMNS = `id, title, notes, status, created_by, created_by_name, created_at, updated_at`;\n// Whether the caller ($1 = ctx.viewer.id, $2 = ctx.viewer.role) may change a row.\nconst CAN_EDIT = `(created_by = $1 OR $2 IN ('owner', 'admin'))`;\nconst STATUSES: ItemStatus[] = ['open', 'done'];\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction checkId(id: unknown): string {\n if (typeof id !== 'string' || !UUID.test(id)) throw new ActionError('This item does not exist.');\n return id;\n}\n\nexport const itemActions = {\n /** read: every item, most recently changed first. */\n async items_list(ctx: ActionContext): Promise<Item[]> {\n const { rows } = await ctx.db.query(\n `SELECT ${COLUMNS}, ${CAN_EDIT} AS can_edit\n FROM items\n ORDER BY updated_at DESC\n LIMIT 1000`,\n [ctx.viewer.id, ctx.viewer.role],\n );\n return rows as unknown as Item[];\n },\n\n /** write: creates an item (no id) or updates one the caller may change. */\n async items_save(ctx: ActionContext, input: ItemInput): Promise<Item> {\n const title = input.title.trim();\n if (!title) throw new ActionError('A title is required.');\n const notes = (input.notes ?? '').trim();\n const status = input.status ?? 'open';\n if (!STATUSES.includes(status)) throw new ActionError(`Unknown status ${status}.`);\n\n if (input.id === undefined) {\n const { results } = await ctx.db.batch([\n rememberViewer(ctx),\n {\n sql: `INSERT INTO items (title, notes, status, created_by, created_by_name)\n VALUES ($1, $2, $3, $4, $5)\n RETURNING ${COLUMNS}, true AS can_edit`,\n params: [title, notes, status, ctx.viewer.id, ctx.viewer.display_name],\n },\n ]);\n return results[1]?.rows[0] as unknown as Item;\n }\n\n const id = checkId(input.id);\n const { results } = await ctx.db.batch([\n rememberViewer(ctx),\n {\n sql: `UPDATE items\n SET title = $3, notes = $4, status = $5, updated_at = now()\n WHERE id = $6 AND ${CAN_EDIT}\n RETURNING ${COLUMNS}, true AS can_edit`,\n params: [ctx.viewer.id, ctx.viewer.role, title, notes, status, id],\n },\n ]);\n const row = results[1]?.rows[0];\n if (!row) throw new ActionError('Only its creator or an org admin can change this item.');\n return row as unknown as Item;\n },\n\n /** write: deletes an item the caller may change. */\n async items_delete(ctx: ActionContext, params: { id: string }): Promise<{ id: string }> {\n const id = checkId(params.id);\n const { rows_affected } = await ctx.db.exec(`DELETE FROM items WHERE id = $3 AND ${CAN_EDIT}`, [\n ctx.viewer.id,\n ctx.viewer.role,\n id,\n ]);\n if (rows_affected === 0) {\n throw new ActionError('Only its creator or an org admin can delete this item.');\n }\n return { id };\n },\n};\n",
66
66
  "actions/people.ts": "import type { Person } from '@shared/people';\nimport type { ActionBatchStatement, ActionContext, ActionViewer } from './parall-actions';\n\n/** Org owners and admins may change anything; members their own rows. */\nexport function isOrgAdmin(viewer: ActionViewer): boolean {\n return viewer.role === 'owner' || viewer.role === 'admin';\n}\n\n/**\n * Remembers the caller in app_people, so pages can offer the people who use\n * the app (as assignees, for an access list…). Put it in the same\n * ctx.db.batch as the write: one round trip, one transaction.\n */\nexport function rememberViewer(ctx: ActionContext): ActionBatchStatement {\n return {\n sql: `INSERT INTO app_people (user_id, display_name, is_agent, last_seen_at)\n VALUES ($1, $2, $3, now())\n ON CONFLICT (user_id) DO UPDATE\n SET display_name = EXCLUDED.display_name,\n is_agent = EXCLUDED.is_agent,\n last_seen_at = now()`,\n params: [ctx.viewer.id, ctx.viewer.display_name, ctx.viewer.is_agent],\n };\n}\n\nexport const peopleActions = {\n /** read: the people who used the app, most recent first. */\n async people_list(ctx: ActionContext): Promise<Person[]> {\n const { rows } = await ctx.db.query(\n `SELECT user_id AS id, display_name, is_agent\n FROM app_people\n ORDER BY last_seen_at DESC\n LIMIT 500`,\n );\n return rows as unknown as Person[];\n },\n};\n",
67
67
  "actions/tsconfig.json": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"moduleResolution\": \"bundler\",\n \"lib\": [\"ES2022\", \"WebWorker\"],\n \"strict\": true,\n \"noEmit\": true,\n \"skipLibCheck\": true,\n \"isolatedModules\": true,\n \"paths\": {\n \"@shared/*\": [\"../shared/*\"]\n },\n \"types\": []\n },\n \"include\": [\".\", \"../shared\"]\n}\n",
68
- "db/schema.sql": "-- The app's tables. The Database is PostgreSQL (not SQLite): uuid,\n-- timestamptz, jsonb, ILIKE, ON CONFLICT and gen_random_uuid() all work.\n--\n-- Apply (safe to run again — everything is IF NOT EXISTS):\n-- parall app db exec --app <app_…> --file db/schema.sql\n--\n-- To change a table later, add to it (ALTER TABLE … ADD COLUMN IF NOT\n-- EXISTS …): an agent cannot DROP or TRUNCATE a table or drop a column.\n-- Add a column before publishing code that uses it; stop using one before\n-- a person removes it.\n\n-- People who used the app. Write actions remember the caller here\n-- (actions/people.ts rememberViewer), so pages can offer them as assignees\n-- or for an access list. ctx.viewer is the only trustworthy identity.\nCREATE TABLE IF NOT EXISTS app_people (\n user_id text PRIMARY KEY,\n display_name text NOT NULL,\n is_agent boolean NOT NULL DEFAULT false,\n last_seen_at timestamptz NOT NULL DEFAULT now()\n);\n\n-- The example list (src/pages/items, actions/items.ts).\nCREATE TABLE IF NOT EXISTS items (\n id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n title text NOT NULL CHECK (length(title) BETWEEN 1 AND 200),\n notes text NOT NULL DEFAULT '',\n status text NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'done')),\n created_by text NOT NULL,\n created_by_name text NOT NULL,\n created_at timestamptz NOT NULL DEFAULT now(),\n updated_at timestamptz NOT NULL DEFAULT now()\n);\nCREATE INDEX IF NOT EXISTS items_updated_at_idx ON items (updated_at DESC);\n\n-- Who may see or change a row is decided in SQL, from ctx.viewer — every\n-- member of the organization can call every action, so the action is the\n-- only gate. Pass the viewer from the action; never take a user id from\n-- params for this.\n--\n-- 1. Everyone reads; the creator or an org owner/admin changes\n-- (what actions/items.ts does, $1 = ctx.viewer.id, $2 = ctx.viewer.role):\n--\n-- UPDATE items SET … WHERE id = $3 AND (created_by = $1 OR $2 IN ('owner', 'admin'))\n--\n-- 2. Private rows shared through an access list:\n--\n-- CREATE TABLE IF NOT EXISTS item_access (\n-- item_id uuid NOT NULL REFERENCES items (id) ON DELETE CASCADE,\n-- user_id text NOT NULL,\n-- can_edit boolean NOT NULL DEFAULT false,\n-- PRIMARY KEY (item_id, user_id)\n-- );\n--\n-- -- what the caller may read\n-- SELECT i.* FROM items i\n-- WHERE i.created_by = $1\n-- OR $2 IN ('owner', 'admin')\n-- OR EXISTS (SELECT 1 FROM item_access a WHERE a.item_id = i.id AND a.user_id = $1);\n--\n-- -- what the caller may change: the same, with a.can_edit\n-- … OR EXISTS (SELECT 1 FROM item_access a\n-- WHERE a.item_id = i.id AND a.user_id = $1 AND a.can_edit)\n--\n-- Pick who to share with from app_people (the people_list action).\n",
68
+ "db/schema.sql": "-- The app's tables. The Database is PostgreSQL (not SQLite): uuid,\n-- timestamptz, jsonb, ILIKE, ON CONFLICT and gen_random_uuid() all work.\n--\n-- Apply (safe to run again — everything is IF NOT EXISTS):\n-- parall app db exec --app <app_…> --file db/schema.sql\n--\n-- To change a table later, add to it (ALTER TABLE … ADD COLUMN IF NOT\n-- EXISTS …): an agent cannot DROP or TRUNCATE a table or drop a column.\n-- Add a column before publishing code that uses it; stop using one before\n-- a person removes it.\n\n-- People who used the app. Write actions remember the caller here\n-- (actions/people.ts rememberViewer), so pages can offer them as assignees\n-- or for an access list. ctx.viewer is the only trustworthy identity.\nCREATE TABLE IF NOT EXISTS app_people (\n user_id text PRIMARY KEY,\n display_name text NOT NULL,\n is_agent boolean NOT NULL DEFAULT false,\n last_seen_at timestamptz NOT NULL DEFAULT now()\n);\n\n-- The example list (src/pages/items, actions/items.ts).\nCREATE TABLE IF NOT EXISTS items (\n id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n title text NOT NULL CHECK (length(title) BETWEEN 1 AND 200),\n notes text NOT NULL DEFAULT '',\n status text NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'done')),\n created_by text NOT NULL,\n created_by_name text NOT NULL,\n created_at timestamptz NOT NULL DEFAULT now(),\n updated_at timestamptz NOT NULL DEFAULT now()\n);\nCREATE INDEX IF NOT EXISTS items_updated_at_idx ON items (updated_at DESC);\n\n-- Who may see or change a row is decided in SQL, from ctx.viewer — every\n-- member of the organization can call every action, so the action is the\n-- only gate. Pass the viewer from the action; never take a user id from\n-- params for this.\n--\n-- 1. Everyone reads; the creator or an org owner/admin changes\n-- (what actions/items.ts does, $1 = ctx.viewer.id, $2 = ctx.viewer.role):\n--\n-- UPDATE items SET … WHERE id = $3 AND (created_by = $1 OR $2 IN ('owner', 'admin'))\n--\n-- 2. Private rows shared through an access list. It limits only what the\n-- app's pages and actions show: what a write action is passed is kept in\n-- the app's call log, which everyone who can open the app can read.\n--\n-- CREATE TABLE IF NOT EXISTS item_access (\n-- item_id uuid NOT NULL REFERENCES items (id) ON DELETE CASCADE,\n-- user_id text NOT NULL,\n-- can_edit boolean NOT NULL DEFAULT false,\n-- PRIMARY KEY (item_id, user_id)\n-- );\n--\n-- -- what the caller may read\n-- SELECT i.* FROM items i\n-- WHERE i.created_by = $1\n-- OR $2 IN ('owner', 'admin')\n-- OR EXISTS (SELECT 1 FROM item_access a WHERE a.item_id = i.id AND a.user_id = $1);\n--\n-- -- what the caller may change: the same, with a.can_edit\n-- … OR EXISTS (SELECT 1 FROM item_access a\n-- WHERE a.item_id = i.id AND a.user_id = $1 AND a.can_edit)\n--\n-- Pick who to share with from app_people (the people_list action).\n",
69
69
  "package.json": "{\n \"scripts\": {\n \"typecheck\": \"tsc -p tsconfig.json && tsc -p actions/tsconfig.json\",\n \"build\": \"tsc -p tsconfig.json && tsc -p actions/tsconfig.json && vite build && vite build --config vite.actions.config.ts\"\n },\n \"devDependencies\": {\n \"miniflare\": \"^4.20260415.0\"\n },\n \"pnpm\": {\n \"onlyBuiltDependencies\": [\n \"esbuild\",\n \"workerd\"\n ]\n }\n}\n",
70
70
  "public/manifest.json": "{\n \"actions\": {\n \"entry\": \"_actions/index.js\",\n \"functions\": {\n \"people_list\": { \"kind\": \"read\" },\n \"items_list\": { \"kind\": \"read\" },\n \"items_save\": {\n \"kind\": \"write\",\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\", \"maxLength\": 64 },\n \"title\": { \"type\": \"string\", \"minLength\": 1, \"maxLength\": 200 },\n \"notes\": { \"type\": \"string\", \"maxLength\": 10000 },\n \"status\": { \"type\": \"string\", \"enum\": [\"open\", \"done\"] }\n },\n \"required\": [\"title\"]\n }\n },\n \"items_delete\": {\n \"kind\": \"write\",\n \"params\": {\n \"type\": \"object\",\n \"properties\": { \"id\": { \"type\": \"string\", \"maxLength\": 64 } },\n \"required\": [\"id\"]\n }\n }\n }\n }\n}\n",
71
71
  "shared/items.ts": "// Types shared by the actions (actions/items.ts) and the page\n// (src/pages/items): the action returns rows of this shape.\n\nexport type ItemStatus = 'open' | 'done';\n\nexport interface Item {\n id: string;\n title: string;\n notes: string;\n status: ItemStatus;\n created_by: string;\n created_by_name: string;\n /** ISO timestamps. */\n created_at: string;\n updated_at: string;\n /** Whether the caller may change or delete it (creator or org owner/admin). */\n can_edit: boolean;\n}\n\n/** items_save params: no id creates an item, an id updates it. */\nexport interface ItemInput {\n id?: string;\n title: string;\n notes?: string;\n status?: ItemStatus;\n}\n",
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCnD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC9D"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAwCnD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC9D"}
@@ -34,6 +34,7 @@ export function browserHelp(action) {
34
34
  'read: exactly one of --url or a tab target. get: --prop title/url need no locator; text/html/value/attr require one; attr also needs --name.',
35
35
  'wait: --selector, or --state load (no selector). Boolean values are explicit true/false.',
36
36
  'open <url> and eval <javascript> also accept positional values. eval is bounded, not streaming.',
37
+ 'DIALOG_OPEN: the page is paused on an alert/confirm. dialog with no options reads it; --accept true|false answers it (--text needs --accept). navigate or close also dismiss it. Nothing answers it for you.',
37
38
  '--json prints the result on stdout or the error and next step on stderr. Save the operation ID for later checks.',
38
39
  'read --url uses a temporary page that closes after reading; use open to keep a page for the user.',
39
40
  'Decode screenshot PNG base64 into a file before viewing it. Expired result data cannot be recovered by checking again; do not rerun an action to recover old data.',
@@ -519,9 +519,9 @@ export function registerClipCommands(program) {
519
519
  }
520
520
  }
521
521
  // Strict grammar, validated BEFORE the wire: parseInt would accept
522
- // "5000ms" or "1.5", and the server silently replaces an out-of-range
523
- // timeout with its 30s default — so a malformed flag would run with a
524
- // deadline the caller never asked for. printError never returns.
522
+ // "5000ms" or "1.5", and the server runs an out-of-range timeout at
523
+ // its 120s ceiling — so a malformed flag would run with a deadline
524
+ // the caller never asked for. printError never returns.
525
525
  let timeoutMs;
526
526
  if (opts?.timeout) {
527
527
  timeoutMs = parsePositiveInt(opts.timeout);
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/commands/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QA6DpD"}
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/commands/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAI5C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAkFpD"}
@@ -1,3 +1,4 @@
1
+ import { Option } from 'commander';
1
2
  import { resolveCredentials } from '../lib/client.js';
2
3
  import { printJson, printError, stripPrllScheme } from '../lib/output.js';
3
4
  export function registerUserCommands(program) {
@@ -46,6 +47,25 @@ export function registerUserCommands(program) {
46
47
  printError(err);
47
48
  }
48
49
  });
50
+ members
51
+ .command('set-role')
52
+ .description("Change a member's org role (org owner/admin; others get an approval command)")
53
+ .argument('<userId>', 'User ID (human or agent; your own id to ask for a role yourself)')
54
+ .addOption(new Option('--role <role>', 'New org role')
55
+ .choices(['admin', 'member'])
56
+ .makeOptionMandatory())
57
+ .action(async (userId, opts) => {
58
+ // The org.member.role.update proposal payload is exactly this write.
59
+ const body = { user_id: stripPrllScheme(userId), role: opts.role };
60
+ try {
61
+ const { client, orgId } = resolveCredentials();
62
+ await client.updateOrgMember(orgId, body.user_id, body.role);
63
+ printJson({ updated: body.user_id, role: body.role });
64
+ }
65
+ catch (err) {
66
+ printError(err, body);
67
+ }
68
+ });
49
69
  members
50
70
  .command('profile')
51
71
  .description("Get a member's org-scoped public profile (title / description)")
@@ -6,8 +6,8 @@ import type { Command } from 'commander';
6
6
  * the vendor token + device id never reach the runtime — api-server
7
7
  * performs the vendor call in-process.
8
8
  *
9
- * Verb surface = the vendor's in-scope interface aggregated: postText
10
- * (send), platform-retained context (history), fetchContactsList +
9
+ * Verb surface = the vendor's in-scope interface aggregated: postText, postImage, postFile
10
+ * (send), lazy image/file download, platform-retained context (history), fetchContactsList +
11
11
  * getBriefInfo + getChatroomInfo (contacts), getProfile (profile),
12
12
  * checkOnline (status). History always emits its stable page JSON; the other
13
13
  * verbs render agent-readable text by default and accept `--json`.
@@ -1 +1 @@
1
- {"version":3,"file":"wechat.d.ts","sourceRoot":"","sources":["../../src/commands/wechat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QA6LtD"}
1
+ {"version":3,"file":"wechat.d.ts","sourceRoot":"","sources":["../../src/commands/wechat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QAmNtD"}
@@ -2,6 +2,7 @@ import { resolveCredentials } from '../lib/client.js';
2
2
  import { downloadAttachment } from '../lib/download-attachment.js';
3
3
  import { printError, printJson } from '../lib/output.js';
4
4
  import { resolveMessageText, TEXT_FILE_OPTION_DESC, TEXT_OPTION_DESC } from '../lib/text-input.js';
5
+ import { uploadFile } from '../lib/upload.js';
5
6
  /**
6
7
  * `parall wechat …` — the per-vendor platform verb for the personal-WeChat
7
8
  * protocol channel (wechatapi.net, tier B in the multi-channel
@@ -9,8 +10,8 @@ import { resolveMessageText, TEXT_FILE_OPTION_DESC, TEXT_OPTION_DESC } from '../
9
10
  * the vendor token + device id never reach the runtime — api-server
10
11
  * performs the vendor call in-process.
11
12
  *
12
- * Verb surface = the vendor's in-scope interface aggregated: postText
13
- * (send), platform-retained context (history), fetchContactsList +
13
+ * Verb surface = the vendor's in-scope interface aggregated: postText, postImage, postFile
14
+ * (send), lazy image/file download, platform-retained context (history), fetchContactsList +
14
15
  * getBriefInfo + getChatroomInfo (contacts), getProfile (profile),
15
16
  * checkOnline (status). History always emits its stable page JSON; the other
16
17
  * verbs render agent-readable text by default and accept `--json`.
@@ -28,21 +29,37 @@ export function registerWechatCommands(program) {
28
29
  .requiredOption('--to <wxid>', 'Vendor-native conversation id from the inbound event (a friend wxid, or a room id ending in @chatroom)')
29
30
  .option('--text <text>', TEXT_OPTION_DESC)
30
31
  .option('--text-file <path>', TEXT_FILE_OPTION_DESC)
32
+ .option('--image <path>', 'Send a local image as a WeChat image message')
33
+ .option('--file <path>', 'Send a local file as a WeChat file message')
31
34
  .option('--at <wxid>', 'In group replies: @-mention one member (wxid of the person you are answering)')
32
35
  .option('--json', 'Emit the full machine-readable response instead of the readable summary')
33
36
  .action(async (opts) => {
34
37
  try {
35
- const text = resolveMessageText(opts);
36
- if (text === undefined || text === '') {
37
- throw new Error('Provide --text or --text-file');
38
+ const hasText = opts.text !== undefined || opts.textFile !== undefined;
39
+ if ([hasText, opts.image !== undefined, opts.file !== undefined].filter(Boolean).length !==
40
+ 1) {
41
+ throw new Error('Choose exactly one of --text/--text-file, --image or --file');
38
42
  }
43
+ const mediaPath = opts.image ?? opts.file;
44
+ if (mediaPath !== undefined && opts.at !== undefined) {
45
+ throw new Error('--at is only supported with text messages; send explanatory text separately');
46
+ }
47
+ const text = hasText ? resolveMessageText(opts) : undefined;
48
+ if (hasText && !text)
49
+ throw new Error('Text must not be empty');
39
50
  const { client, orgId } = resolveCredentials();
40
- const sent = await client.sendChannelMessage(orgId, {
41
- channel_type: 'wechat',
42
- conversation_id: opts.to,
43
- text,
44
- ...(opts.at ? { at: opts.at } : {}),
45
- });
51
+ const sent = mediaPath !== undefined
52
+ ? await client.sendWechatMedia(orgId, {
53
+ conversation_id: opts.to,
54
+ attachment_id: (await uploadFile(client, orgId, mediaPath)).attachmentId,
55
+ kind: opts.image !== undefined ? 'image' : 'file',
56
+ })
57
+ : await client.sendChannelMessage(orgId, {
58
+ channel_type: 'wechat',
59
+ conversation_id: opts.to,
60
+ text: text,
61
+ ...(opts.at ? { at: opts.at } : {}),
62
+ });
46
63
  if (opts.json) {
47
64
  printJson(sent);
48
65
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"browser-operation.d.ts","sourceRoot":"","sources":["../../src/lib/browser-operation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAG1B,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,KAAK,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM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E,OAAO,GAAG,IAAI,CA8BjF"}
@@ -1,6 +1,7 @@
1
1
  import { randomBytes, webcrypto } from 'node:crypto';
2
2
  import { ApiError, BrowserUseValidationError, validateBrowserUseReceipt } from '@parall/sdk';
3
3
  const recovery = (operationId, profileId) => `Do not retry the action. Check the original operation without running it again: parall browser operation get ${operationId} --profile ${profileId} --json`;
4
+ const dialogRecovery = (receipt) => `The page is paused on a JavaScript dialog; do not repeat the action. Read it: parall browser dialog --profile ${receipt.profile_id}${receipt.tab_id ? ` --tab ${receipt.tab_id} --browser-generation ${receipt.browser_generation}` : ' --tab <btab_id> --browser-generation <n>'} --json, then answer it with --accept true or --accept false. Nothing answers it for you.`;
4
5
  const publicText = (value) => value.length <= 1024 &&
5
6
  !/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u.test(value) &&
6
7
  !/\b(?:agk_|pk_|sk_|edg_)|dispatch[_ -]?claim|grant[_ -]?proof/iu.test(value)
@@ -86,7 +87,9 @@ export function browserReceiptOutcome(receipt, waitExpired = false) {
86
87
  message: publicText(receipt.error.message ?? 'Browser Use did not succeed.'),
87
88
  hint: receipt.error.code === 'CANCELLED'
88
89
  ? 'Stop and report the cancellation to the user. Do not resume the task automatically.'
89
- : recovery(receipt.operation_id, receipt.profile_id),
90
+ : receipt.error.code === 'DIALOG_OPEN'
91
+ ? dialogRecovery(receipt)
92
+ : recovery(receipt.operation_id, receipt.profile_id),
90
93
  },
91
94
  };
92
95
  return { ok: true, ...base, ...(receipt.result_available ? { data: receipt.data } : {}) };
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/lib/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6BhD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgFzF"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/lib/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6BhD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAmFzF"}
@@ -33,6 +33,9 @@ export function inferMimeType(filePath) {
33
33
  export async function uploadFile(client, orgId, filePath) {
34
34
  const resolved = path.resolve(filePath);
35
35
  const stat = fs.statSync(resolved);
36
+ if (!stat.isFile()) {
37
+ throw new Error(`Not a regular file: ${resolved}`);
38
+ }
36
39
  const fileName = path.basename(resolved);
37
40
  const mimeType = inferMimeType(fileName);
38
41
  const presign = await client.getUploadPresignUrl(orgId, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parall/cli",
3
- "version": "1.76.0",
3
+ "version": "1.78.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/agent-core": "1.76.0",
46
- "@parall/sdk": "1.76.0"
45
+ "@parall/sdk": "1.78.0",
46
+ "@parall/agent-core": "1.78.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.76.0"
74
+ "@parall/agent-core": "1.78.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",