@parall/sdk 1.23.0 → 1.24.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.
package/src/types.ts CHANGED
@@ -154,29 +154,34 @@ export interface ToolResultContent {
154
154
  collapsible: boolean;
155
155
  }
156
156
 
157
- export interface ApprovalOption {
158
- key: string;
159
- label: string;
160
- style: 'primary' | 'danger' | 'secondary';
161
- }
162
-
157
+ // CardContent is the polymorphic content for 'card' message type.
158
+ // card_type discriminates the data payload.
163
159
  export interface ApprovalCardContent {
164
- approval_id: string;
165
- title: string;
166
- description: string;
167
- action_type: string;
168
- action_payload: Record<string, unknown>;
169
- risk_level: string;
170
- status: string;
171
- options: ApprovalOption[];
172
- expires_at: string;
160
+ card_type: 'approval';
161
+ entity_id: string;
162
+ display: {
163
+ title: string;
164
+ description?: string;
165
+ requester?: { id: string; name: string };
166
+ };
167
+ interaction: {
168
+ action: string;
169
+ resource_type?: string;
170
+ resource_id?: string;
171
+ action_payload?: Record<string, unknown>;
172
+ actions: string[];
173
+ status: string;
174
+ decided_by?: string;
175
+ decided_at?: string;
176
+ execution_status?: ExecutionStatus | null;
177
+ execution_error?: string | null;
178
+ executed_at?: string | null;
179
+ };
173
180
  }
174
181
 
175
- // CardContent is the polymorphic content for 'card' message type.
176
- // card_type discriminates the data payload.
177
182
  export type CardContent =
178
- | { card_type: 'approval'; data: ApprovalCardContent; approval_id?: string }
179
- | { card_type: string; data: Record<string, unknown>; approval_id?: string };
183
+ | ApprovalCardContent
184
+ | { card_type: string; entity_id?: string; data?: Record<string, unknown> };
180
185
 
181
186
  export type AgentState = 'thinking' | 'tool_calling' | 'streaming' | 'waiting_approval' | 'completed' | 'error';
182
187
 
@@ -245,22 +250,40 @@ export interface Attachment {
245
250
  created_at: string;
246
251
  }
247
252
 
248
- export type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
253
+ export type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired' | 'cancelled';
254
+
255
+ export type ExecutionStatus = 'succeeded' | 'failed';
249
256
 
250
257
  export interface Approval {
251
258
  id: string;
252
- message_id: string;
253
- chat_id: string;
254
- requester_id: string;
255
- status: ApprovalStatus;
259
+ org_id: string;
256
260
  action_type: string;
261
+ resource_uri: string;
257
262
  action_payload: Record<string, unknown>;
263
+ title: string;
264
+ requester_id: string;
258
265
  decided_by: string | null;
259
266
  decided_at: string | null;
267
+ status: ApprovalStatus;
260
268
  expires_at: string | null;
269
+ execution_status?: ExecutionStatus | null;
270
+ execution_error?: string | null;
271
+ executed_at?: string | null;
272
+ chat_id: string;
273
+ message_id?: string | null;
261
274
  created_at: string;
262
275
  }
263
276
 
277
+ export interface CreateApprovalRequest {
278
+ action_type: string;
279
+ resource_uri: string;
280
+ action_payload?: Record<string, unknown>;
281
+ chat_id: string;
282
+ title: string;
283
+ reason?: string;
284
+ expires_at?: string;
285
+ }
286
+
264
287
  export type OrgMemberRole = 'owner' | 'admin' | 'member';
265
288
 
266
289
  export interface Organization {
@@ -273,6 +296,7 @@ export interface Organization {
273
296
  smart_routing_strategy: string | null;
274
297
  /** Agent ID for strategy='agent'. NULL when strategy is 'llm' or unset. */
275
298
  smart_routing_agent_id: string | null;
299
+ onboarding_agent_id: string | null;
276
300
  created_at: string;
277
301
  }
278
302
 
@@ -486,8 +510,13 @@ export interface CreateAgentRequest {
486
510
  model_management?: string; // "platform" | "self"; default by hosting type
487
511
  agent_permissions?: string[];
488
512
  runtime_type?: string; // "openclaw" | "claude-code" | "codex"; default "openclaw"
513
+ description?: string;
489
514
  machine_type?: string;
490
- machine_label?: string;
515
+ machine_label?: string; // preset: "lite" | "standard" | "pro" | "custom"
516
+ // Required when machine_label === "custom". Validated server-side.
517
+ cpu_cores?: number;
518
+ memory_mb?: number;
519
+ storage_gb?: number;
491
520
  provider_config?: AgentProviderConfig;
492
521
  }
493
522
 
@@ -495,32 +524,42 @@ export interface CreateAgentRequest {
495
524
  * AgentProviderConfig is the WRITE shape: what a client sends on
496
525
  * CreateAgent.provider_config or UpdateAgentProviderConfigRequest.
497
526
  *
498
- * Product-default auth for hosted Codex is a ChatGPT subscription via
499
- * `codex login` OAuth (written to the PVC by the server-side device
500
- * flow). These fields exist as an admin-level escape hatch for CI,
501
- * Azure OpenAI, OpenAI-compatible proxies, or per-agent billing
502
- * isolation.
527
+ * Hosted agents default to "managed by Parall" the hosting service
528
+ * points the runtime CLI at Parall's LLM proxy and authenticates with
529
+ * the agent's own API key, keeping billing and attribution server-side.
530
+ * These per-agent fields are the BYO override: bring your own ChatGPT/
531
+ * Anthropic subscription, point at Azure OpenAI, or use an OpenAI/
532
+ * Anthropic-compatible proxy.
533
+ *
534
+ * Each runtime consumes exactly one credential family:
535
+ * - codex → openai_*
536
+ * - claude-code → anthropic_*
503
537
  *
504
- * Unset / empty-string fields are dropped at provisioning time (treated
505
- * as "no override" so a partial form doesn't mask the runtime default).
506
- * Sensitive fields (API key) are injected via K8s Secret-ref; endpoint
507
- * overrides land as plain env.
538
+ * The server rejects cross-family fields (e.g. anthropic_* on codex).
539
+ * Unset / empty-string fields are dropped at provisioning time, so a
540
+ * partial form doesn't mask the managed proxy path with an empty string.
541
+ * Sensitive fields (API key / auth token) are injected via K8s
542
+ * Secret-ref; endpoint overrides land as plain env.
508
543
  */
509
544
  export interface AgentProviderConfig {
510
545
  openai_api_key?: string;
511
546
  openai_base_url?: string;
547
+ anthropic_auth_token?: string;
548
+ anthropic_base_url?: string;
512
549
  }
513
550
 
514
551
  /**
515
552
  * AgentProviderConfigRead is the READ shape returned by GET / list /
516
- * PATCH-response paths. The server never echoes the raw API key — only
517
- * a presence flag — so no org admin (or log leak) can ever exfiltrate
518
- * a previously-configured key from the wire. The base URL is
519
- * non-sensitive and round-trips cleartext.
553
+ * PATCH-response paths. The server never echoes the raw secrets — only
554
+ * presence flags — so no org admin (or log leak) can ever exfiltrate
555
+ * a previously-configured value from the wire. Base URLs are
556
+ * non-sensitive and round-trip cleartext.
520
557
  */
521
558
  export interface AgentProviderConfigRead {
522
559
  openai_api_key_set: boolean;
523
560
  openai_base_url?: string;
561
+ anthropic_auth_token_set: boolean;
562
+ anthropic_base_url?: string;
524
563
  }
525
564
 
526
565
  /**
@@ -537,6 +576,7 @@ export interface UpdateAgentRequest {
537
576
  agent_model?: string;
538
577
  model_management?: string;
539
578
  agent_permissions?: string[];
579
+ description?: string;
540
580
  }
541
581
 
542
582
  // ---- Machine types ----
@@ -547,6 +587,13 @@ export interface Machine {
547
587
  id: string;
548
588
  org_id: string;
549
589
  label: string;
590
+ // Persisted spec — set at creation by agent.go from MachinePresets[label]
591
+ // or user-supplied custom values, and used by hosting.Service.Provision +
592
+ // billing.go as the authoritative source. Mirrors the server-side
593
+ // `model.Machine` Go struct.
594
+ cpu_cores: number;
595
+ memory_mb: number;
596
+ storage_gb: number;
550
597
  status: MachineStatus;
551
598
  compute_provider: string;
552
599
  runtime_type: string;
@@ -571,6 +618,7 @@ export interface AgentProfile {
571
618
  permissions: string[];
572
619
  machine_id: string | null;
573
620
  runtime_type: string;
621
+ description: string | null;
574
622
  run_config?: RunConfig;
575
623
  created_by: string;
576
624
  created_at: string;
@@ -596,11 +644,12 @@ export interface AgentWithRuntime extends User {
596
644
  export interface PresignUploadRequest {
597
645
  file_name: string;
598
646
  file_size: number;
599
- mime_type: string;
647
+ mime_type?: string;
600
648
  }
601
649
 
602
650
  export interface FileUrlResponse {
603
651
  url: string;
652
+ is_proxy_url?: boolean;
604
653
  expires_in: number;
605
654
  width?: number;
606
655
  height?: number;
@@ -609,6 +658,10 @@ export interface FileUrlResponse {
609
658
  mime_type: string;
610
659
  }
611
660
 
661
+ export interface AvatarUploadResponse {
662
+ avatar_url: string;
663
+ }
664
+
612
665
  // ============================================================
613
666
  // Task Types
614
667
  // ============================================================
@@ -747,14 +800,13 @@ export interface UpdateProjectRequest {
747
800
 
748
801
  export type ScheduleSpecType = 'cron' | 'interval' | 'one_shot';
749
802
  export type ScheduleStatus = 'active' | 'paused' | 'completed' | 'cancelled';
750
- export type ScheduleCancelReason = 'user_cancel' | 'attached_gone' | 'target_ineligible';
803
+ export type ScheduleCancelReason = 'user_cancel' | 'attached_gone' | 'creator_ineligible';
751
804
  export type ScheduleRunStatus = 'delivered' | 'missed' | 'failed';
752
805
 
753
806
  export interface Schedule {
754
807
  id: string;
755
808
  org_id: string;
756
809
  creator_id: string;
757
- target_id: string;
758
810
  attached_to_uri: string | null;
759
811
  name: string;
760
812
  description: string;
@@ -767,6 +819,8 @@ export interface Schedule {
767
819
  end_at: string | null;
768
820
  max_runs: number | null;
769
821
  catchup_window_seconds: number;
822
+ duration_seconds: number | null;
823
+ target_ids: string[];
770
824
  status: ScheduleStatus;
771
825
  cancel_reason: ScheduleCancelReason | null;
772
826
  next_fire_at: string | null;
@@ -784,8 +838,6 @@ export interface ScheduleRun {
784
838
  status: ScheduleRunStatus;
785
839
  fired_description: string | null;
786
840
  fired_attached_uri: string | null;
787
- dispatch_event_id: string | null;
788
- inbox_item_id: string | null;
789
841
  error: string | null;
790
842
  created_at: string;
791
843
  }
@@ -793,7 +845,7 @@ export interface ScheduleRun {
793
845
  export interface CreateScheduleInput {
794
846
  name: string;
795
847
  description: string;
796
- target_id: string;
848
+ target_ids: string[];
797
849
  attached_to_uri?: string;
798
850
  spec_type: ScheduleSpecType;
799
851
  cron_expr?: string;
@@ -804,12 +856,13 @@ export interface CreateScheduleInput {
804
856
  end_at?: string;
805
857
  max_runs?: number;
806
858
  catchup_window_seconds?: number;
859
+ duration_seconds?: number;
807
860
  }
808
861
 
809
862
  export interface UpdateScheduleInput {
810
863
  name?: string;
811
864
  description?: string;
812
- target_id?: string;
865
+ target_ids?: string[];
813
866
  attached_to_uri?: string;
814
867
  /** Explicitly clear attached_to_uri. Server honors this over `attached_to_uri`. */
815
868
  attached_to_uri_clear?: boolean;
@@ -827,11 +880,13 @@ export interface UpdateScheduleInput {
827
880
  /** Explicitly clear max_runs. Server honors this over `max_runs`. */
828
881
  max_runs_clear?: boolean;
829
882
  catchup_window_seconds?: number;
883
+ duration_seconds?: number;
884
+ duration_seconds_clear?: boolean;
830
885
  }
831
886
 
832
887
  export interface ScheduleFilters {
833
888
  attached_to?: string;
834
- target_id?: string;
889
+ attendee_id?: string;
835
890
  creator_id?: string;
836
891
  /** Comma-separated list of statuses (e.g. 'active,paused'). */
837
892
  status?: string;
@@ -1301,12 +1356,15 @@ export type ApprovalUpdateData = CardUpdateData;
1301
1356
 
1302
1357
  export interface CardUpdateData {
1303
1358
  card_type: string;
1304
- approval_id?: string;
1359
+ entity_id: string;
1305
1360
  message_id: string;
1306
1361
  chat_id: string;
1307
1362
  status: string;
1363
+ execution_status?: ExecutionStatus | null;
1308
1364
  decided_by?: string;
1309
1365
  decided_at?: string;
1366
+ executed_at?: string | null;
1367
+ execution_error?: string | null;
1310
1368
  }
1311
1369
 
1312
1370
  export interface RecoveryOverflowData {
@@ -1525,6 +1583,7 @@ export interface InboxItem {
1525
1583
 
1526
1584
  export type DispatchEventType = 'message' | 'task_assign' | 'task_comment' | 'schedule.fire';
1527
1585
  export type DispatchStatus = 'pending' | 'acked';
1586
+ export type DispatchDeliveryReason = 'mention' | 'watcher';
1528
1587
 
1529
1588
  export interface DispatchEvent {
1530
1589
  id: string;
@@ -1543,6 +1602,12 @@ export interface DispatchEvent {
1543
1602
  * (@mention, DM, task assignment, active-mode fanout).
1544
1603
  */
1545
1604
  source_mode: string | null;
1605
+ /**
1606
+ * Recipient-resolution hint. For task_comment dispatches this distinguishes
1607
+ * explicit @mention delivery from implicit task watcher delivery while the
1608
+ * dispatch event itself remains a source pointer.
1609
+ */
1610
+ delivery_reason: DispatchDeliveryReason | null;
1546
1611
  status: DispatchStatus;
1547
1612
  acked_at: string | null;
1548
1613
  created_at: string;
@@ -1629,6 +1694,11 @@ export type WsEventMap = {
1629
1694
  'schedule.updated': ScheduleUpdatedData;
1630
1695
  'schedule.deleted': ScheduleDeletedData;
1631
1696
  'schedule.fired': ScheduleFiredData;
1697
+ 'billing.balance_updated': BillingBalanceUpdatedEvent;
1698
+ 'billing.low_balance': BillingLowBalanceEvent;
1699
+ 'billing.machine_stopped': BillingMachineStoppedEvent;
1700
+ 'billing.insufficient': BillingInsufficientEvent;
1701
+ 'user.updated': User;
1632
1702
  };
1633
1703
 
1634
1704
  // Invitation WS event data
@@ -1865,3 +1935,148 @@ export interface SetRuntimeModeRequest {
1865
1935
  update_mode: RuntimeUpdateMode;
1866
1936
  pinned_tag?: string | null;
1867
1937
  }
1938
+
1939
+ // ============================================================
1940
+ // Billing & Credits
1941
+ // ============================================================
1942
+
1943
+ export interface CreditWallet {
1944
+ org_id: string;
1945
+ balance: number;
1946
+ updated_at: string;
1947
+ }
1948
+
1949
+ export interface CreditTransaction {
1950
+ id: string;
1951
+ org_id: string;
1952
+ type: 'topup' | 'auto_reload' | 'llm_deduct' | 'compute_deduct' | 'adjustment' | 'refund' | 'grant' | 'grant_expire';
1953
+ amount: number;
1954
+ balance_after: number;
1955
+ grant_id: string | null;
1956
+ description: string | null;
1957
+ reference_type: string | null;
1958
+ reference_id: string | null;
1959
+ metadata: Record<string, unknown> | null;
1960
+ created_at: string;
1961
+ }
1962
+
1963
+ export interface BillingSummary {
1964
+ balance: number;
1965
+ llm_usage_this_month: number;
1966
+ compute_usage_this_month: number;
1967
+ total_usage_this_month: number;
1968
+ grants?: CreditGrant[];
1969
+ }
1970
+
1971
+ // CreditGrant is shipped to user-facing clients via BillingSummary.grants
1972
+ // (read-only — issued only by admin). `type` stays `string` so a server-side
1973
+ // custom type (an ops one-off, e.g. "incident-1234") doesn't break typed
1974
+ // clients.
1975
+ //
1976
+ // IssueGrantRequest, GrantTypePreset, and GRANT_TYPE_PRESETS are intentionally
1977
+ // NOT exported here — those are admin-only contracts (POST body for
1978
+ // /internal/admin/orgs/{id}/grants and the admin dropdown defaults).
1979
+ // The admin dashboard maintains its own mirror in `ts/admin/lib/api.ts`
1980
+ // to stay decoupled from the public SDK ecosystem and its own deploy
1981
+ // (standalone Docker, internal network only).
1982
+ export interface CreditGrant {
1983
+ id: string;
1984
+ org_id: string;
1985
+ type: string;
1986
+ name: string;
1987
+ original_amount: number;
1988
+ remaining: number;
1989
+ priority: number;
1990
+ expires_at: string | null;
1991
+ metadata: Record<string, unknown> | null;
1992
+ created_by: string | null;
1993
+ created_at: string;
1994
+ }
1995
+
1996
+ // Read model — what GET /billing/auto-reload returns.
1997
+ // `has_payment_method` is server-derived from Stripe customer state.
1998
+ export interface AutoReloadSettings {
1999
+ enabled: boolean;
2000
+ threshold: number;
2001
+ reload_amount: number;
2002
+ stripe_price: number;
2003
+ has_payment_method: boolean;
2004
+ }
2005
+
2006
+ // Write model — what PUT /billing/auto-reload accepts. Excludes derived /
2007
+ // read-only fields (has_payment_method) so callers can't accidentally try
2008
+ // to clobber server-side state.
2009
+ export interface UpdateAutoReloadRequest {
2010
+ enabled: boolean;
2011
+ threshold: number;
2012
+ reload_amount: number;
2013
+ stripe_price: number;
2014
+ }
2015
+
2016
+ export interface ComputePricing {
2017
+ id: string;
2018
+ component: string;
2019
+ unit: string;
2020
+ price_per_hour: number;
2021
+ effective_from: string;
2022
+ created_at: string;
2023
+ }
2024
+
2025
+ // Response shape for GET /api/v1/billing/compute-pricing — map keyed by
2026
+ // component name ("cpu" | "memory" | "storage").
2027
+ export type ComputePricingResponse = Record<string, ComputePricing>;
2028
+
2029
+ export interface MachinePreset {
2030
+ key: string;
2031
+ cpu_cores: number;
2032
+ memory_mb: number;
2033
+ storage_gb: number;
2034
+ }
2035
+
2036
+ export interface CreateCheckoutRequest {
2037
+ amount_cents: number;
2038
+ }
2039
+
2040
+ export interface CreateCheckoutResponse {
2041
+ checkout_url: string;
2042
+ }
2043
+
2044
+ export interface CreateSetupIntentResponse {
2045
+ /** Stripe-hosted Checkout Session URL (mode=setup). The frontend redirects
2046
+ * with `window.location.href = setup_url`; Stripe handles the card form
2047
+ * and redirects back to /settings?tab=billing&setup={success|cancelled}.
2048
+ */
2049
+ setup_url: string;
2050
+ /** @deprecated Always empty string. Retained so legacy clients that
2051
+ * destructured `client_secret` from the response don't crash; new code
2052
+ * should use `setup_url`. The redirect-style flow superseded the
2053
+ * Payment Element flow before any consumer wired this field. */
2054
+ client_secret?: string;
2055
+ }
2056
+
2057
+ // ResizeMachineRequest was retired pending the server-side
2058
+ // `PATCH /machines/{id}/spec` route. Reintroduce alongside the route and
2059
+ // the matching ParallClient method when in-place resize is implemented.
2060
+
2061
+ // Invalidation signal: server publishes only { org_id } on any wallet
2062
+ // change; clients refetch `getBilling` / `listBillingTransactions` to get
2063
+ // the latest state.
2064
+ export interface BillingBalanceUpdatedEvent {
2065
+ org_id: string;
2066
+ }
2067
+
2068
+ export interface BillingLowBalanceEvent {
2069
+ org_id: string;
2070
+ machine_id: string;
2071
+ grace_ends: string;
2072
+ }
2073
+
2074
+ export interface BillingMachineStoppedEvent {
2075
+ org_id: string;
2076
+ machine_id: string;
2077
+ reason: string;
2078
+ }
2079
+
2080
+ export interface BillingInsufficientEvent {
2081
+ org_id: string;
2082
+ }