@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
@@ -0,0 +1,117 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var agent_task_terminal_exports = {};
19
+ __export(agent_task_terminal_exports, {
20
+ cancelledTerminalReason: () => cancelledTerminalReason,
21
+ classifyAgentTaskTerminalReason: () => classifyAgentTaskTerminalReason,
22
+ queueExpiredTerminalReason: () => queueExpiredTerminalReason
23
+ });
24
+ module.exports = __toCommonJS(agent_task_terminal_exports);
25
+ function classifyAgentTaskTerminalReason(rawError, source) {
26
+ const raw = rawError.trim() || "agent_failure";
27
+ const lower = raw.toLowerCase();
28
+ const candidates = [
29
+ matchFailure(lower, /(upload_validation(?::[a-z0-9_.-]+)?|upload[^\n.!?]{0,80}validat|validat(?:e|ion)[^\n.!?]{0,80}upload|invalid[^\n.!?]{0,80}archive|invalid[^\n.!?]{0,80}catalogue)/, {
30
+ category: "upload_validation",
31
+ retryable: false,
32
+ source,
33
+ message: "The uploaded result did not pass validation."
34
+ }),
35
+ matchFailure(lower, /(instrument_error(?::[a-z0-9_.-]+)?|browser_control|renderer|screenshot|playwright|chrome instrument|waitforselector|(?:native )?listing recorder)/, {
36
+ category: "instrument_error",
37
+ retryable: true,
38
+ source: "instrument",
39
+ message: "The required browser or capture instrument failed."
40
+ }),
41
+ matchFailure(lower, /(capacity|overloaded|rate.?limit|too many requests|quota|(?:^|\D)429(?:\D|$))/, {
42
+ category: "provider_capacity",
43
+ retryable: true,
44
+ source: "provider",
45
+ message: "The agent provider had no available capacity."
46
+ }),
47
+ matchFailure(lower, /(econnreset|econnrefused|connection|network|socket|disconnected|dns|fetch failed)/, {
48
+ category: "provider_connection",
49
+ retryable: true,
50
+ source: "provider",
51
+ message: "The connection to the agent provider was lost."
52
+ }),
53
+ matchFailure(lower, /(timed? ?out|timeout|deadline exceeded)/, {
54
+ category: "provider_timeout",
55
+ retryable: true,
56
+ source: "provider",
57
+ message: "The agent provider did not finish before the timeout."
58
+ })
59
+ ].filter((candidate) => candidate !== null).sort((a, b) => a.index - b.index);
60
+ const firstSpecificFailure = candidates[0];
61
+ if (firstSpecificFailure) {
62
+ return terminal(firstSpecificFailure.category, raw, firstSpecificFailure.retryable, firstSpecificFailure.source, firstSpecificFailure.message, firstSpecificFailure.code);
63
+ }
64
+ const interrupted = /(worker_shutdown|worker_session_expired|agent_task_stale_running_reaped|lease_expired|signal_|sigterm|sigkill|interrupted)/.test(lower);
65
+ return terminal("agent_failure", raw, interrupted, source, interrupted ? "The agent process was interrupted." : "The agent failed to complete the task.", interrupted ? "interrupted_worker_process" : "agent_failure");
66
+ }
67
+ function matchFailure(raw, pattern, failure) {
68
+ const match = pattern.exec(raw);
69
+ if (!match) {
70
+ return null;
71
+ }
72
+ const specificCode = /^(?:instrument_error|upload_validation):[a-z0-9_.-]+$/.test(match[0]) ? match[0] : failure.category;
73
+ return {
74
+ ...failure,
75
+ index: match.index,
76
+ code: specificCode
77
+ };
78
+ }
79
+ function queueExpiredTerminalReason(rawError) {
80
+ return {
81
+ kind: "expiration",
82
+ category: "queue_expired",
83
+ code: rawError.trim() || "queue_expired",
84
+ message: "The task expired before a compatible worker could start it.",
85
+ retryable: true,
86
+ rawError: rawError.trim() || null,
87
+ source: "server"
88
+ };
89
+ }
90
+ function cancelledTerminalReason(code = "cancelled") {
91
+ return {
92
+ kind: "cancellation",
93
+ category: "cancelled",
94
+ code,
95
+ message: "The task was cancelled.",
96
+ retryable: false,
97
+ rawError: null,
98
+ source: "server"
99
+ };
100
+ }
101
+ function terminal(category, rawError, retryable, source, message, code = category) {
102
+ return {
103
+ kind: "failure",
104
+ category,
105
+ code,
106
+ message,
107
+ retryable,
108
+ rawError,
109
+ source
110
+ };
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ cancelledTerminalReason,
115
+ classifyAgentTaskTerminalReason,
116
+ queueExpiredTerminalReason
117
+ });
@@ -130,8 +130,11 @@ export interface ContentTagSummary {
130
130
  slug: string;
131
131
  displayName: string;
132
132
  }
133
- export declare const AGENT_TASK_STATUS_VALUES: readonly ["QUEUED", "RUNNING", "DONE", "FAILED", "CANCELLED"];
133
+ export declare const AGENT_TASK_STATUS_VALUES: readonly ["QUEUED", "RUNNING", "DONE", "FAILED", "EXPIRED", "CANCELLED"];
134
134
  export type AgentTaskStatus = typeof AGENT_TASK_STATUS_VALUES[number];
135
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
136
+ [key: string]: JsonValue;
137
+ };
135
138
  export declare const AGENT_TASK_CREATOR_FEEDBACK_STATUS_VALUES: readonly ["UNSEEN", "VIEWED", "PLAYED", "APPROVED", "DISAPPROVED"];
136
139
  export type AgentTaskCreatorFeedbackStatus = typeof AGENT_TASK_CREATOR_FEEDBACK_STATUS_VALUES[number];
137
140
  export declare const AGENT_TASK_KIND_VALUES: readonly ["NEW_GAME", "REMIX_GAME", "GAME_UPDATE", "GAME_REVIEW", "GAME_EVAL"];
@@ -272,6 +275,18 @@ export interface AgentTaskAgentModelSelection {
272
275
  export interface AgentTaskAgentModelOption extends AgentTaskAgentModelSelection {
273
276
  label: string;
274
277
  onlineWorkers: number;
278
+ totalSlots: number;
279
+ runningTasks: number;
280
+ availableSlots: number;
281
+ }
282
+ export interface AgentTaskTerminalReason {
283
+ kind: 'failure' | 'expiration' | 'cancellation';
284
+ category: 'provider_capacity' | 'provider_connection' | 'provider_timeout' | 'instrument_error' | 'upload_validation' | 'agent_failure' | 'queue_expired' | 'cancelled';
285
+ code: string;
286
+ message: string;
287
+ retryable: boolean;
288
+ rawError: string | null;
289
+ source: 'server' | 'worker' | 'agent' | 'provider' | 'instrument';
275
290
  }
276
291
  export interface AgentTaskRefundResponse {
277
292
  state: 'refunded' | 'withheld';
@@ -298,7 +313,7 @@ export interface AgentTaskNextStepSuggestion {
298
313
  }
299
314
  export interface AgentTaskResponse {
300
315
  id: number;
301
- pluginBundleSha?: string | null;
316
+ agentBundleSha?: string | null;
302
317
  workerCliVersion: string | null;
303
318
  platformReleaseSha: string | null;
304
319
  kind: AgentTaskKind;
@@ -338,6 +353,7 @@ export interface AgentTaskResponse {
338
353
  nextSteps: AgentTaskNextStepSuggestion[];
339
354
  creatorFeedbackStatus: AgentTaskCreatorFeedbackStatus;
340
355
  error: string | null;
356
+ terminalReason: AgentTaskTerminalReason | null;
341
357
  workerId?: number | null;
342
358
  workerName?: string | null;
343
359
  lastHeartbeatAt: string | null;
@@ -385,7 +401,7 @@ export interface AgentTaskAttachmentInput {
385
401
  export interface AgentTaskAttachmentUploadResponse {
386
402
  attachment: AgentTaskAttachmentInput;
387
403
  }
388
- export type AgentTaskInputKind = 'prompt' | 'MEDIA' | 'GAME_PLAN' | 'REFERENCE_GAME' | 'REFERENCE_ASSET' | 'REFERENCE_PACK';
404
+ export type AgentTaskInputKind = 'MEDIA' | 'GAME_PLAN' | 'REFERENCE_GAME' | 'REFERENCE_ASSET' | 'REFERENCE_PACK';
389
405
  export type GamePlanQuestionId = 'graphics' | 'surface_targets' | 'genre' | 'theme' | 'controls' | 'player_goal' | 'challenge' | 'first_version_scope' | 'notes';
390
406
  export type GamePlanQuestionKind = 'SINGLE_CHOICE' | 'MULTI_CHOICE' | 'TEXT';
391
407
  export interface GamePlanSelectedOption {
@@ -405,10 +421,6 @@ export interface AgentTaskInputBase {
405
421
  kind: AgentTaskInputKind;
406
422
  note?: string | null;
407
423
  }
408
- export interface AgentTaskPromptInput extends AgentTaskInputBase {
409
- kind: 'prompt';
410
- text?: string | null;
411
- }
412
424
  export interface AgentTaskMediaInput extends AgentTaskInputBase {
413
425
  kind: 'MEDIA';
414
426
  media: AgentTaskAttachmentInput;
@@ -429,7 +441,7 @@ export interface AgentTaskReferenceInput extends AgentTaskInputBase {
429
441
  displayName?: string | null;
430
442
  };
431
443
  }
432
- export type AgentTaskInput = AgentTaskPromptInput | AgentTaskMediaInput | AgentTaskGamePlanInput | AgentTaskReferenceInput;
444
+ export type AgentTaskInput = AgentTaskMediaInput | AgentTaskGamePlanInput | AgentTaskReferenceInput;
433
445
  export interface CreateNewGameAgentTaskRequest {
434
446
  target: AgentExecutionTarget;
435
447
  agent?: AgentRuntime;
@@ -438,8 +450,7 @@ export interface CreateNewGameAgentTaskRequest {
438
450
  prompt: string;
439
451
  surfaceContext?: AgentTaskSurfaceContextRequest;
440
452
  inputs?: AgentTaskInput[];
441
- pluginBundleBase64?: string;
442
- pluginBundleFileName?: string;
453
+ agentBundleSha?: string;
443
454
  }
444
455
  export interface CreateNewGameAgentTaskResponse {
445
456
  task: AgentTaskResponse;
@@ -454,8 +465,7 @@ export interface CreateRemixGameAgentTaskRequest {
454
465
  sourceAppVersionRef: string;
455
466
  surfaceContext?: AgentTaskSurfaceContextRequest;
456
467
  inputs?: AgentTaskInput[];
457
- pluginBundleBase64?: string;
458
- pluginBundleFileName?: string;
468
+ agentBundleSha?: string;
459
469
  }
460
470
  export interface CreateRemixGameAgentTaskResponse {
461
471
  task: AgentTaskResponse;
@@ -474,8 +484,7 @@ export interface CreateGameEvalAgentTaskRequest {
474
484
  judgePromptVersion: string;
475
485
  tieBand?: number | null;
476
486
  targets: GameEvalTargetInput[];
477
- pluginBundleBase64?: string;
478
- pluginBundleFileName?: string;
487
+ agentBundleSha?: string;
479
488
  }
480
489
  export interface CreateGameEvalAgentTaskResponse {
481
490
  task: AgentTaskResponse;
@@ -533,115 +542,98 @@ export interface WorkerPresenceResponse {
533
542
  action?: 'continue' | 'quiesce_for_update';
534
543
  updatePolicy?: AgentWorkerUpdatePolicyResponse | null;
535
544
  }
536
- export interface WorkerClaimAgentTaskRequest {
545
+ export interface WorkerClaimTaskRequestV2 {
546
+ protocolVersion: 2;
537
547
  workerKey: string;
538
548
  capabilities: AgentWorkerCapabilities;
539
549
  }
540
- export interface WorkerAgentTaskBaseSourceResponse {
541
- creatorUsername: string;
542
- appName: string;
543
- version: string;
544
- appId: number;
545
- appVersionId: number;
546
- }
547
- export interface WorkerAgentTaskRemixSourceResponse extends WorkerAgentTaskBaseSourceResponse {
548
- ref: string;
549
- appDisplayName?: string | null;
550
- }
551
- export interface WorkerAgentTaskReviewTargetResponse {
552
- creatorUsername: string;
553
- appName: string;
554
- appDisplayName: string | null;
555
- version: string;
556
- appId: number;
557
- appVersionId: number;
558
- reviewState: ReviewState;
559
- surfaceTargets: AppSurface[];
560
- launchUrl: string;
561
- }
562
- export interface WorkerAgentTaskEvalTargetResponse {
563
- targetId: string;
564
- creatorUsername: string;
565
- appName: string;
566
- appDisplayName: string | null;
567
- version: string;
568
- appId: number;
569
- appVersionId: number;
570
- appVersionRef: string;
571
- creatorPrompt: string | null;
572
- surfaceTargets: AppSurface[];
573
- heroImageUrl: string | null;
574
- iconImageUrl: string | null;
575
- launchUrl: string;
576
- }
577
- export interface WorkerAgentTaskEvalResponse {
578
- mode: GameEvalMode;
579
- judgePromptVersion: string;
580
- tieBand: number | null;
581
- targets: WorkerAgentTaskEvalTargetResponse[];
582
- }
583
- export interface WorkerAgentTaskPluginBundleResponse {
550
+ export interface WorkerTaskPluginV2 {
584
551
  sha256: string;
585
552
  fileName: string;
586
553
  sizeBytes: number;
587
554
  contentBase64: string;
588
555
  }
589
- export interface WorkerAgentTaskWorkspaceFileResponse {
590
- relativePath: string;
556
+ export interface WorkerTaskWorkspaceArchiveV2 {
557
+ path: string;
558
+ format: 'zip';
559
+ sha256: string;
560
+ sizeBytes: number;
561
+ contentBase64: string;
562
+ }
563
+ export interface WorkerTaskWorkspaceFileV2 {
564
+ path: string;
565
+ sha256: string;
566
+ sizeBytes: number;
567
+ contentType: string;
591
568
  contentBase64: string;
592
- contentType?: string;
593
569
  }
594
- export interface WorkerAgentTaskAttachmentResponse {
570
+ export interface WorkerTaskAttachmentV2 {
595
571
  id: string;
572
+ path: string;
596
573
  fileName: string;
597
574
  contentType: string;
598
575
  sizeBytes: number;
599
- relativePath: string;
576
+ sha256: string;
600
577
  description?: string | null;
601
578
  }
602
- export interface WorkerAgentTaskAssignmentResponse {
603
- taskId: number;
604
- taskToken: string;
605
- kind: AgentTaskKind;
606
- target: AgentExecutionTarget;
607
- agent: AgentRuntime;
608
- model: string;
609
- reasoningEffort?: string | null;
610
- attemptPlan?: AgentAttemptPlan | null;
611
- selectedAttempt?: AgentAttemptOption | null;
579
+ export interface WorkerTaskAssignmentV2 {
580
+ task: {
581
+ id: number;
582
+ token: string;
583
+ type: string;
584
+ executionTarget: AgentExecutionTarget;
585
+ attempt: number;
586
+ metadata: Record<string, JsonValue>;
587
+ };
612
588
  workspace: {
613
589
  folderName: string;
614
- files: WorkerAgentTaskWorkspaceFileResponse[];
590
+ archives: WorkerTaskWorkspaceArchiveV2[];
591
+ files: WorkerTaskWorkspaceFileV2[];
615
592
  };
616
- inputs: {
617
- request: {
618
- prompt: string;
619
- surfaceContext?: AgentTaskSurfaceContext;
620
- };
621
- taskInputs?: AgentTaskInput[];
622
- attachments: WorkerAgentTaskAttachmentResponse[];
623
- baseSource: WorkerAgentTaskBaseSourceResponse | null;
624
- remixSource?: WorkerAgentTaskRemixSourceResponse | null;
625
- reviewTarget?: WorkerAgentTaskReviewTargetResponse | null;
626
- evalTarget?: WorkerAgentTaskEvalResponse | null;
627
- allowedTemplateKeys?: string[];
593
+ plugin: WorkerTaskPluginV2 | null;
594
+ request: {
595
+ prompt: string;
596
+ attachments: WorkerTaskAttachmentV2[];
628
597
  };
629
- pluginBundle: WorkerAgentTaskPluginBundleResponse;
630
- output: {
631
- appId: number | null;
632
- appName: string | null;
633
- version: string;
634
- releaseNoteRequired: boolean;
598
+ agent: {
599
+ runtime: AgentRuntime;
600
+ model: string;
601
+ reasoningEffort: string | null;
602
+ browser: 'NONE' | 'CHROME' | 'PLAYWRIGHT';
635
603
  };
636
- prompt: string;
637
604
  }
638
- export interface WorkerClaimAgentTaskResponse {
639
- task: AgentTaskResponse | null;
640
- action?: 'continue' | 'quiesce_for_update';
641
- updatePolicy?: AgentWorkerUpdatePolicyResponse | null;
642
- taskAssignment?: WorkerAgentTaskAssignmentResponse;
643
- leaseToken?: string;
644
- leaseExpiresAt?: string;
605
+ export type WorkerClaimTaskResponseV2 = {
606
+ protocolVersion: 2;
607
+ action: 'idle' | 'quiesce_for_update';
608
+ assignment: null;
609
+ lease: null;
610
+ updatePolicy: AgentWorkerUpdatePolicyResponse | null;
611
+ } | {
612
+ protocolVersion: 2;
613
+ action: 'run';
614
+ assignment: WorkerTaskAssignmentV2;
615
+ lease: {
616
+ token: string;
617
+ expiresAt: string;
618
+ };
619
+ updatePolicy: AgentWorkerUpdatePolicyResponse | null;
620
+ };
621
+ export type WorkerClaimAgentTaskRequest = WorkerClaimTaskRequestV2;
622
+ export type WorkerClaimAgentTaskResponse = WorkerClaimTaskResponseV2;
623
+ export interface RegisterAgentBundleRequest {
624
+ sha256: string;
625
+ fileName: string;
626
+ contentBase64: string;
627
+ }
628
+ export interface RegisterAgentBundleResponse {
629
+ created: boolean;
630
+ bundle: {
631
+ sha256: string;
632
+ fileName: string;
633
+ sizeBytes: number;
634
+ registrationSource: 'EVAL';
635
+ createdAt: string;
636
+ };
645
637
  }
646
638
  export interface WorkerClaimAgentTaskSlugRequest {
647
639
  appName: string;
@@ -750,6 +742,7 @@ export interface AgentTaskRunResponse {
750
742
  tokenUsage: AgentTaskRunTokenUsageResponse;
751
743
  availableSkillPaths: string[];
752
744
  observedSkillPaths: string[];
745
+ terminalReason: AgentTaskTerminalReason | null;
753
746
  startedAt: string | null;
754
747
  completedAt: string | null;
755
748
  createdAt: string;
@@ -793,6 +786,7 @@ export interface WorkerRecordAgentTaskRunTelemetryRequest {
793
786
  observedSkillPaths?: string[];
794
787
  startedAt?: string | null;
795
788
  completedAt?: string | null;
789
+ terminalReason?: AgentTaskTerminalReason | null;
796
790
  }
797
791
  export interface WorkerRecordAgentTaskRunTelemetryResponse {
798
792
  run: AgentTaskRunResponse;
@@ -873,6 +867,7 @@ export interface WorkerFailAgentTaskRequest {
873
867
  workerKey?: string;
874
868
  leaseToken?: string;
875
869
  error: string;
870
+ terminalReason: AgentTaskTerminalReason;
876
871
  result?: Record<string, unknown>;
877
872
  }
878
873
  export interface AdminAgentTasksResponse {
@@ -954,8 +949,7 @@ export interface CreateAppAgentTaskRequest {
954
949
  prompt: string;
955
950
  surfaceContext?: AgentTaskSurfaceContextRequest;
956
951
  inputs?: AgentTaskInput[];
957
- pluginBundleBase64?: string;
958
- pluginBundleFileName?: string;
952
+ agentBundleSha?: string;
959
953
  }
960
954
  export interface CreateAppAgentTaskResponse {
961
955
  task: AgentTaskResponse;