@playdrop/playdrop-cli 0.12.32 → 0.12.33

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 (27) hide show
  1. package/config/client-meta.json +2 -2
  2. package/dist/apiClient.js +16 -1
  3. package/dist/commands/upload.js +2 -0
  4. package/dist/commands/worker/runtime.d.ts +2 -0
  5. package/dist/commands/worker/runtime.js +14 -10
  6. package/dist/commands/worker.d.ts +9 -29
  7. package/dist/commands/worker.js +604 -660
  8. package/dist/index.js +6 -0
  9. package/node_modules/@playdrop/api-client/dist/client.d.ts +2 -1
  10. package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
  11. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts +2 -1
  12. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts.map +1 -1
  13. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.js +11 -0
  14. package/node_modules/@playdrop/api-client/dist/index.d.ts +3 -2
  15. package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
  16. package/node_modules/@playdrop/api-client/dist/index.js +5 -0
  17. package/node_modules/@playdrop/config/client-meta.json +2 -2
  18. package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts +5 -0
  19. package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts.map +1 -0
  20. package/node_modules/@playdrop/types/dist/agent-task-terminal.js +117 -0
  21. package/node_modules/@playdrop/types/dist/api.d.ts +97 -103
  22. package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
  23. package/node_modules/@playdrop/types/dist/api.js +1 -1
  24. package/node_modules/@playdrop/types/dist/index.d.ts +1 -0
  25. package/node_modules/@playdrop/types/dist/index.d.ts.map +1 -1
  26. package/node_modules/@playdrop/types/dist/index.js +3 -1
  27. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.12.8",
3
- "build": 36,
2
+ "version": "0.12.9",
3
+ "build": 37,
4
4
  "runtimeSdkVersion": "0.12.5",
5
5
  "runtimeSdkBuild": 2,
6
6
  "clients": {
package/dist/apiClient.js CHANGED
@@ -14,14 +14,29 @@ function readPositiveIntEnv(name) {
14
14
  const parsed = Number(raw);
15
15
  return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
16
16
  }
17
+ function readWorkerTaskTokenEnv() {
18
+ if (process.env.PLAYDROP_WORKER_CONTEXT !== '1') {
19
+ return '';
20
+ }
21
+ const token = process.env.PLAYDROP_WORKER_TASK_TOKEN?.trim() ?? '';
22
+ if (!token) {
23
+ throw new Error('worker_task_token_missing');
24
+ }
25
+ return token;
26
+ }
17
27
  function createCliClientHeaders(input) {
18
28
  const onBehalfCreatorUsername = input.onBehalfCreatorUsername;
19
29
  const creatorUsername = typeof onBehalfCreatorUsername === 'string'
20
30
  ? onBehalfCreatorUsername.trim()
21
31
  : '';
22
- const agentTaskToken = typeof input.agentTaskToken === 'string'
32
+ const explicitAgentTaskToken = typeof input.agentTaskToken === 'string'
23
33
  ? input.agentTaskToken.trim()
24
34
  : '';
35
+ const workerTaskToken = readWorkerTaskTokenEnv();
36
+ if (explicitAgentTaskToken && workerTaskToken && explicitAgentTaskToken !== workerTaskToken) {
37
+ throw new Error('worker_task_token_mismatch');
38
+ }
39
+ const agentTaskToken = explicitAgentTaskToken || workerTaskToken;
25
40
  const agentTaskId = Number.isInteger(input.agentTaskId) && Number(input.agentTaskId) > 0
26
41
  ? Number(input.agentTaskId)
27
42
  : readPositiveIntEnv('PLAYDROP_WORKER_TASK_ID');
@@ -1224,6 +1224,8 @@ function resolveWorkerPlaydropAssetRequirement(value) {
1224
1224
  }
1225
1225
  const WORKER_SUPERVISOR_SOURCE_EXCLUDES = [
1226
1226
  'PLAYDROP_TASK.md',
1227
+ 'AGENTS.md',
1228
+ 'CLAUDE.md',
1227
1229
  '.playdrop/',
1228
1230
  '.playdrop-task-events/',
1229
1231
  'bin/playdrop',
@@ -61,6 +61,7 @@ export declare function buildCodexExecArgs(input: {
61
61
  reasoningEffort: string;
62
62
  networkAccess: boolean;
63
63
  sandboxMode?: CodexSandboxMode;
64
+ imagePaths?: string[];
64
65
  }): string[];
65
66
  export type CodexSandboxMode = 'danger-full-access' | 'workspace-write' | 'read-only';
66
67
  export declare function readCodexSandboxMode(env?: NodeJS.ProcessEnv): CodexSandboxMode;
@@ -89,6 +90,7 @@ export declare function buildClaudeDeniedPermissionRules(denyReadRoots?: string[
89
90
  export declare function buildWorkerChildEnv(input: {
90
91
  binDir: string;
91
92
  taskId: number;
93
+ taskToken: string;
92
94
  attempt: number;
93
95
  envName: string;
94
96
  eventDir?: string;
@@ -456,8 +456,6 @@ function buildCodexExecArgs(input) {
456
456
  'exec',
457
457
  '--json',
458
458
  '--ephemeral',
459
- '--ignore-user-config',
460
- '--ignore-rules',
461
459
  '--sandbox',
462
460
  sandboxMode,
463
461
  '--cd',
@@ -467,11 +465,14 @@ function buildCodexExecArgs(input) {
467
465
  input.model,
468
466
  '-c',
469
467
  `model_reasoning_effort="${input.reasoningEffort}"`,
470
- '-',
471
468
  ];
472
469
  if (sandboxMode === 'workspace-write') {
473
- args.splice(args.length - 3, 0, '-c', `sandbox_workspace_write.network_access=${input.networkAccess ? 'true' : 'false'}`);
470
+ args.push('-c', `sandbox_workspace_write.network_access=${input.networkAccess ? 'true' : 'false'}`);
474
471
  }
472
+ for (const imagePath of input.imagePaths ?? []) {
473
+ args.push('--image', imagePath);
474
+ }
475
+ args.push('-');
475
476
  return args;
476
477
  }
477
478
  function readCodexSandboxMode(env = process.env) {
@@ -516,15 +517,13 @@ function buildClaudeExecArgs(input) {
516
517
  : input.playwrightMcp
517
518
  ? [...allowedPermissionRules, PLAYWRIGHT_MCP_ALLOWED_TOOL_RULE]
518
519
  : allowedPermissionRules;
519
- // --safe-mode disables ALL MCP servers, including ones passed explicitly via --mcp-config
520
- // (verified empirically on claude 2.1.207). Playwright judge sessions therefore drop it:
521
- // their CLAUDE_CONFIG_DIR is an isolated per-task directory with no user customizations,
522
- // so the surface --safe-mode guards is already empty, while --strict-mcp-config and the
523
- // permission rules below stay in force.
524
520
  const args = [
525
521
  '-p',
526
- ...(input.playwrightMcp ? [] : ['--safe-mode']),
527
522
  '--strict-mcp-config',
523
+ '--setting-sources',
524
+ 'project',
525
+ '--input-format',
526
+ 'stream-json',
528
527
  '--model',
529
528
  model,
530
529
  '--output-format',
@@ -745,10 +744,15 @@ function buildWorkerChildEnv(input) {
745
744
  }
746
745
  }
747
746
  child.PLAYDROP_WORKER_CONTEXT = '1';
747
+ const taskToken = input.taskToken.trim();
748
+ if (!taskToken) {
749
+ throw new Error('invalid_worker_task_token');
750
+ }
748
751
  if (!Number.isInteger(input.attempt) || input.attempt <= 0) {
749
752
  throw new Error('invalid_worker_task_attempt');
750
753
  }
751
754
  child.PLAYDROP_WORKER_TASK_ID = String(input.taskId);
755
+ child.PLAYDROP_WORKER_TASK_TOKEN = taskToken;
752
756
  child.PLAYDROP_WORKER_TASK_ATTEMPT = String(input.attempt);
753
757
  if (input.devPort !== undefined) {
754
758
  if (!Number.isInteger(input.devPort) || input.devPort <= 0 || input.devPort > 65535) {
@@ -1,5 +1,5 @@
1
1
  import type { ApiClient } from '@playdrop/api-client';
2
- import { type AgentExecutionTarget, type AgentRuntime, type AgentTaskKind, type AgentTaskNextStepSuggestion, type AgentTaskResponse, type AgentWorkerCapabilities, type AgentWorkerResponse, type AgentWorkerUpdatePolicyResponse, type WorkerAgentTaskAssignmentResponse, type WorkerAgentTaskBaseSourceResponse, type WorkerAgentTaskWorkspaceFileResponse, type WorkerClaimAgentTaskResponse } from '@playdrop/types';
2
+ import { type AgentExecutionTarget, type AgentRuntime, type AgentTaskNextStepSuggestion, type AgentTaskResponse, type AgentWorkerCapabilities, type AgentWorkerResponse, type AgentWorkerUpdatePolicyResponse, type WorkerTaskAssignmentV2, type WorkerTaskPluginV2, type WorkerClaimAgentTaskResponse } from '@playdrop/types';
3
3
  import { loadConfig } from '../config';
4
4
  import { type WorkerPlaydropAssetRequirement } from './upload';
5
5
  import { type LoggedProcessResult, type LoggedProcessTranscriptChunk } from './worker/runtime';
@@ -141,7 +141,7 @@ export declare function allocateWorkerDevPort(input: {
141
141
  }): number;
142
142
  export declare function isWorkerContextCommandAllowed(argv: string[]): boolean;
143
143
  export declare function resolveWorkerExecutionTargetFromRole(role: unknown): AgentExecutionTarget;
144
- export declare function resolveWorkerClaimTaskAssignment(claim: WorkerClaimAgentTaskResponse): WorkerAgentTaskAssignmentResponse | null;
144
+ export declare function normalizeWorkerTaskAssignmentV2(claim: WorkerClaimAgentTaskResponse): WorkerTaskAssignmentV2 | null;
145
145
  export declare function nextClaimBackoffMs(currentMs: number): number;
146
146
  export declare function claimBackoffDelayMs(currentMs: number, random?: () => number): number;
147
147
  export declare function resolveWorkerHomeDir(): string;
@@ -171,20 +171,11 @@ export declare function assertTaskUploadResultMatchesContext(input: {
171
171
  creatorUsername: string;
172
172
  };
173
173
  }): void;
174
- export declare function stageAssignmentWorkspaceFiles(workspaceDir: string, files: readonly WorkerAgentTaskWorkspaceFileResponse[]): Promise<void>;
175
- export declare function stagePlaydropPluginReferences(input: {
176
- workspaceDir: string;
177
- pluginRoot: string;
178
- kind: AgentTaskKind;
179
- }): Promise<string[]>;
180
- export declare function stageCodexTaskSkills(input: {
181
- workspaceDir: string;
182
- stagedPluginPaths: readonly string[];
183
- }): Promise<string[]>;
174
+ export declare function stageAssignmentWorkspaceV2(workspaceDir: string, workspace: WorkerTaskAssignmentV2['workspace']): Promise<void>;
184
175
  export declare function assertAssignmentPluginBundleExtractionBounds(buffer: Buffer): void;
185
176
  export declare function stageAssignmentPluginBundle(input: {
186
177
  workspaceDir: string;
187
- pluginBundle: NonNullable<WorkerAgentTaskAssignmentResponse['pluginBundle']>;
178
+ pluginBundle: WorkerTaskPluginV2;
188
179
  }): Promise<string>;
189
180
  export declare function resolveDevPluginWorkingTree(input: {
190
181
  workingTree?: string;
@@ -224,25 +215,13 @@ export declare function buildWorkerClaimBody(input: {
224
215
  capabilities: AgentWorkerCapabilities;
225
216
  runningTaskCount?: number;
226
217
  }): {
218
+ protocolVersion: 2;
227
219
  workerKey: string;
228
220
  capabilities: AgentWorkerCapabilities;
229
221
  };
230
- export type WorkerBaseApp = {
231
- appName: string;
232
- version: string;
233
- appId: number;
234
- appVersionId: number;
235
- };
236
- export declare function resolveWorkerBaseSource(value: WorkerAgentTaskBaseSourceResponse | null | undefined): WorkerBaseApp;
237
222
  export declare function extractZipArchive(zipBuffer: Uint8Array, targetDir: string): string[];
238
- export declare function readWorkerProjectVersion(projectDir: string, appName: string): string;
239
223
  export declare function buildCataloguePreviewPayload(cataloguePath: string, workspaceDir?: string): Record<string, unknown>;
240
- export declare function assertWorkerProjectVersionBumped(input: {
241
- baseVersion: string;
242
- projectVersion: string;
243
- appName: string;
244
- }): void;
245
- export declare function removeStaleWorkerControlFilesFromBaseSource(stagingDir: string): Promise<void>;
224
+ export declare function removeStaleWorkerControlFiles(stagingDir: string): Promise<void>;
246
225
  export declare function resolveCodexModel(model: string, reasoningEffortOverride?: string | null): WorkerCodexModel;
247
226
  export declare function resolveClaudeModel(model: string, reasoningEffortOverride?: string | null): WorkerClaudeModel;
248
227
  export declare function prepareCodexRunHomes(input: {
@@ -351,12 +330,12 @@ export declare function assertLaunchAgentPlistCompatible(input: {
351
330
  }): void;
352
331
  export declare function showWorkerStatus(options?: WorkerStatusOptions): Promise<WorkerStatusPayload>;
353
332
  export declare function setupWorker(options?: WorkerSetupOptions): Promise<void>;
354
- export declare function instrumentTaskChromeTitleMatchers(assignment: WorkerAgentTaskAssignmentResponse): string[];
333
+ export declare function instrumentTaskChromeTitleMatchers(assignment: WorkerTaskAssignmentV2): string[];
355
334
  type InstrumentBrowserHygieneRunner = (command: string, args: string[]) => Promise<{
356
335
  stdout: string;
357
336
  stderr: string;
358
337
  }>;
359
- export declare function enforceInstrumentBrowserHygiene(assignment: WorkerAgentTaskAssignmentResponse, options?: {
338
+ export declare function enforceInstrumentBrowserHygiene(assignment: WorkerTaskAssignmentV2, options?: {
360
339
  platform?: NodeJS.Platform;
361
340
  runner?: InstrumentBrowserHygieneRunner;
362
341
  }): Promise<{
@@ -365,6 +344,7 @@ export declare function enforceInstrumentBrowserHygiene(assignment: WorkerAgentT
365
344
  }>;
366
345
  export declare function startWorker(options?: WorkerStartOptions): Promise<void>;
367
346
  export declare function reportTask(options: TaskReportOptions): Promise<void>;
347
+ export declare function showTaskContext(): void;
368
348
  export declare function reportCatalogueTask(options: TaskCatalogueReportOptions): Promise<void>;
369
349
  export declare function uploadTask(options?: TaskUploadOptions): Promise<void>;
370
350
  export declare function claimSlugTask(options: TaskClaimSlugOptions): Promise<void>;