@playdrop/playdrop-cli 0.12.31 → 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 +23 -30
  7. package/dist/commands/worker.js +639 -656
  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 +100 -102
  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": 35,
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';
@@ -126,6 +126,14 @@ type WorkerTaskState = {
126
126
  leaseExpiresAt: string | null;
127
127
  claimedAt: string;
128
128
  };
129
+ type WorkerCodexModel = {
130
+ model: string;
131
+ reasoningEffort: string;
132
+ };
133
+ type WorkerClaudeModel = {
134
+ model: string;
135
+ effort: string | null;
136
+ };
129
137
  export declare function allocateWorkerDevPort(input: {
130
138
  activePorts: ReadonlySet<number>;
131
139
  basePort?: number;
@@ -133,7 +141,7 @@ export declare function allocateWorkerDevPort(input: {
133
141
  }): number;
134
142
  export declare function isWorkerContextCommandAllowed(argv: string[]): boolean;
135
143
  export declare function resolveWorkerExecutionTargetFromRole(role: unknown): AgentExecutionTarget;
136
- export declare function resolveWorkerClaimTaskAssignment(claim: WorkerClaimAgentTaskResponse): WorkerAgentTaskAssignmentResponse | null;
144
+ export declare function normalizeWorkerTaskAssignmentV2(claim: WorkerClaimAgentTaskResponse): WorkerTaskAssignmentV2 | null;
137
145
  export declare function nextClaimBackoffMs(currentMs: number): number;
138
146
  export declare function claimBackoffDelayMs(currentMs: number, random?: () => number): number;
139
147
  export declare function resolveWorkerHomeDir(): string;
@@ -163,20 +171,11 @@ export declare function assertTaskUploadResultMatchesContext(input: {
163
171
  creatorUsername: string;
164
172
  };
165
173
  }): void;
166
- export declare function stageAssignmentWorkspaceFiles(workspaceDir: string, files: readonly WorkerAgentTaskWorkspaceFileResponse[]): Promise<void>;
167
- export declare function stagePlaydropPluginReferences(input: {
168
- workspaceDir: string;
169
- pluginRoot: string;
170
- kind: AgentTaskKind;
171
- }): Promise<string[]>;
172
- export declare function stageCodexTaskSkills(input: {
173
- workspaceDir: string;
174
- stagedPluginPaths: readonly string[];
175
- }): Promise<string[]>;
174
+ export declare function stageAssignmentWorkspaceV2(workspaceDir: string, workspace: WorkerTaskAssignmentV2['workspace']): Promise<void>;
176
175
  export declare function assertAssignmentPluginBundleExtractionBounds(buffer: Buffer): void;
177
176
  export declare function stageAssignmentPluginBundle(input: {
178
177
  workspaceDir: string;
179
- pluginBundle: NonNullable<WorkerAgentTaskAssignmentResponse['pluginBundle']>;
178
+ pluginBundle: WorkerTaskPluginV2;
180
179
  }): Promise<string>;
181
180
  export declare function resolveDevPluginWorkingTree(input: {
182
181
  workingTree?: string;
@@ -216,25 +215,15 @@ export declare function buildWorkerClaimBody(input: {
216
215
  capabilities: AgentWorkerCapabilities;
217
216
  runningTaskCount?: number;
218
217
  }): {
218
+ protocolVersion: 2;
219
219
  workerKey: string;
220
220
  capabilities: AgentWorkerCapabilities;
221
221
  };
222
- export type WorkerBaseApp = {
223
- appName: string;
224
- version: string;
225
- appId: number;
226
- appVersionId: number;
227
- };
228
- export declare function resolveWorkerBaseSource(value: WorkerAgentTaskBaseSourceResponse | null | undefined): WorkerBaseApp;
229
222
  export declare function extractZipArchive(zipBuffer: Uint8Array, targetDir: string): string[];
230
- export declare function readWorkerProjectVersion(projectDir: string, appName: string): string;
231
223
  export declare function buildCataloguePreviewPayload(cataloguePath: string, workspaceDir?: string): Record<string, unknown>;
232
- export declare function assertWorkerProjectVersionBumped(input: {
233
- baseVersion: string;
234
- projectVersion: string;
235
- appName: string;
236
- }): void;
237
- export declare function removeStaleWorkerControlFilesFromBaseSource(stagingDir: string): Promise<void>;
224
+ export declare function removeStaleWorkerControlFiles(stagingDir: string): Promise<void>;
225
+ export declare function resolveCodexModel(model: string, reasoningEffortOverride?: string | null): WorkerCodexModel;
226
+ export declare function resolveClaudeModel(model: string, reasoningEffortOverride?: string | null): WorkerClaudeModel;
238
227
  export declare function prepareCodexRunHomes(input: {
239
228
  workspaceDir: string;
240
229
  workerUsername: string;
@@ -255,7 +244,10 @@ export declare function prepareClaudeRunConfig(input: {
255
244
  }>;
256
245
  export declare function removeAgentRunCredentials(workspaceDir: string): Promise<void>;
257
246
  export declare function removeStaleAgentRunCredentials(workerHomeDir?: string): Promise<void>;
258
- export declare function buildAgentFailureCode(agent: AgentRuntime, result: LoggedProcessResult): string;
247
+ export declare function buildAgentFailureCode(agent: AgentRuntime, result: LoggedProcessResult, request?: {
248
+ model: string;
249
+ reasoningEffort?: string | null;
250
+ }): string;
259
251
  export declare function describeAgentFailureForEvent(errorCode: string): string;
260
252
  export declare function createLocalPlaydropShim(input: {
261
253
  workspaceDir: string;
@@ -338,12 +330,12 @@ export declare function assertLaunchAgentPlistCompatible(input: {
338
330
  }): void;
339
331
  export declare function showWorkerStatus(options?: WorkerStatusOptions): Promise<WorkerStatusPayload>;
340
332
  export declare function setupWorker(options?: WorkerSetupOptions): Promise<void>;
341
- export declare function instrumentTaskChromeTitleMatchers(assignment: WorkerAgentTaskAssignmentResponse): string[];
333
+ export declare function instrumentTaskChromeTitleMatchers(assignment: WorkerTaskAssignmentV2): string[];
342
334
  type InstrumentBrowserHygieneRunner = (command: string, args: string[]) => Promise<{
343
335
  stdout: string;
344
336
  stderr: string;
345
337
  }>;
346
- export declare function enforceInstrumentBrowserHygiene(assignment: WorkerAgentTaskAssignmentResponse, options?: {
338
+ export declare function enforceInstrumentBrowserHygiene(assignment: WorkerTaskAssignmentV2, options?: {
347
339
  platform?: NodeJS.Platform;
348
340
  runner?: InstrumentBrowserHygieneRunner;
349
341
  }): Promise<{
@@ -352,6 +344,7 @@ export declare function enforceInstrumentBrowserHygiene(assignment: WorkerAgentT
352
344
  }>;
353
345
  export declare function startWorker(options?: WorkerStartOptions): Promise<void>;
354
346
  export declare function reportTask(options: TaskReportOptions): Promise<void>;
347
+ export declare function showTaskContext(): void;
355
348
  export declare function reportCatalogueTask(options: TaskCatalogueReportOptions): Promise<void>;
356
349
  export declare function uploadTask(options?: TaskUploadOptions): Promise<void>;
357
350
  export declare function claimSlugTask(options: TaskClaimSlugOptions): Promise<void>;