@parall/sdk 1.22.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
 
@@ -391,6 +415,10 @@ export interface WsTicketResponse {
391
415
  ws_url: string;
392
416
  }
393
417
 
418
+ export interface FeatureFlagsResponse {
419
+ flags: Record<string, boolean | string | number>;
420
+ }
421
+
394
422
  // ============================================================
395
423
  // API Request Types
396
424
  // ============================================================
@@ -479,10 +507,76 @@ export interface CreateAgentRequest {
479
507
  agent_provider?: string;
480
508
  agent_endpoint?: string;
481
509
  agent_model?: string;
510
+ model_management?: string; // "platform" | "self"; default by hosting type
482
511
  agent_permissions?: string[];
483
512
  runtime_type?: string; // "openclaw" | "claude-code" | "codex"; default "openclaw"
513
+ description?: string;
484
514
  machine_type?: string;
485
- 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;
520
+ provider_config?: AgentProviderConfig;
521
+ }
522
+
523
+ /**
524
+ * AgentProviderConfig is the WRITE shape: what a client sends on
525
+ * CreateAgent.provider_config or UpdateAgentProviderConfigRequest.
526
+ *
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_*
537
+ *
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.
543
+ */
544
+ export interface AgentProviderConfig {
545
+ openai_api_key?: string;
546
+ openai_base_url?: string;
547
+ anthropic_auth_token?: string;
548
+ anthropic_base_url?: string;
549
+ }
550
+
551
+ /**
552
+ * AgentProviderConfigRead is the READ shape returned by GET / list /
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.
557
+ */
558
+ export interface AgentProviderConfigRead {
559
+ openai_api_key_set: boolean;
560
+ openai_base_url?: string;
561
+ anthropic_auth_token_set: boolean;
562
+ anthropic_base_url?: string;
563
+ }
564
+
565
+ /**
566
+ * PATCH /orgs/{orgId}/agents/{id}/provider-config body.
567
+ * Same shape as the create-time write; PATCH semantics (nil=leave,
568
+ * ""=clear, value=set) are handled by the server, not by the type.
569
+ */
570
+ export type UpdateAgentProviderConfigRequest = AgentProviderConfig;
571
+
572
+ export interface UpdateAgentRequest {
573
+ display_name?: string;
574
+ agent_provider?: string;
575
+ agent_endpoint?: string;
576
+ agent_model?: string;
577
+ model_management?: string;
578
+ agent_permissions?: string[];
579
+ description?: string;
486
580
  }
487
581
 
488
582
  // ---- Machine types ----
@@ -493,6 +587,13 @@ export interface Machine {
493
587
  id: string;
494
588
  org_id: string;
495
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;
496
597
  status: MachineStatus;
497
598
  compute_provider: string;
498
599
  runtime_type: string;
@@ -513,12 +614,18 @@ export interface AgentProfile {
513
614
  provider: string | null;
514
615
  endpoint: string | null;
515
616
  model: string | null;
617
+ model_management: string | null; // "platform" | "self" | null
516
618
  permissions: string[];
517
619
  machine_id: string | null;
518
620
  runtime_type: string;
621
+ description: string | null;
519
622
  run_config?: RunConfig;
520
623
  created_by: string;
521
624
  created_at: string;
625
+ // provider_config is deliberately NOT on this shape. It is admin-only
626
+ // and the server strips it from the agents list response (tag
627
+ // json:"-" in Go). Fetch via `ParallClient.getAgentProviderConfig`
628
+ // from an admin context only.
522
629
  }
523
630
 
524
631
  export interface AgentPresence {
@@ -537,11 +644,12 @@ export interface AgentWithRuntime extends User {
537
644
  export interface PresignUploadRequest {
538
645
  file_name: string;
539
646
  file_size: number;
540
- mime_type: string;
647
+ mime_type?: string;
541
648
  }
542
649
 
543
650
  export interface FileUrlResponse {
544
651
  url: string;
652
+ is_proxy_url?: boolean;
545
653
  expires_in: number;
546
654
  width?: number;
547
655
  height?: number;
@@ -550,6 +658,10 @@ export interface FileUrlResponse {
550
658
  mime_type: string;
551
659
  }
552
660
 
661
+ export interface AvatarUploadResponse {
662
+ avatar_url: string;
663
+ }
664
+
553
665
  // ============================================================
554
666
  // Task Types
555
667
  // ============================================================
@@ -688,14 +800,13 @@ export interface UpdateProjectRequest {
688
800
 
689
801
  export type ScheduleSpecType = 'cron' | 'interval' | 'one_shot';
690
802
  export type ScheduleStatus = 'active' | 'paused' | 'completed' | 'cancelled';
691
- export type ScheduleCancelReason = 'user_cancel' | 'attached_gone' | 'target_ineligible';
803
+ export type ScheduleCancelReason = 'user_cancel' | 'attached_gone' | 'creator_ineligible';
692
804
  export type ScheduleRunStatus = 'delivered' | 'missed' | 'failed';
693
805
 
694
806
  export interface Schedule {
695
807
  id: string;
696
808
  org_id: string;
697
809
  creator_id: string;
698
- target_id: string;
699
810
  attached_to_uri: string | null;
700
811
  name: string;
701
812
  description: string;
@@ -708,6 +819,8 @@ export interface Schedule {
708
819
  end_at: string | null;
709
820
  max_runs: number | null;
710
821
  catchup_window_seconds: number;
822
+ duration_seconds: number | null;
823
+ target_ids: string[];
711
824
  status: ScheduleStatus;
712
825
  cancel_reason: ScheduleCancelReason | null;
713
826
  next_fire_at: string | null;
@@ -725,8 +838,6 @@ export interface ScheduleRun {
725
838
  status: ScheduleRunStatus;
726
839
  fired_description: string | null;
727
840
  fired_attached_uri: string | null;
728
- dispatch_event_id: string | null;
729
- inbox_item_id: string | null;
730
841
  error: string | null;
731
842
  created_at: string;
732
843
  }
@@ -734,7 +845,7 @@ export interface ScheduleRun {
734
845
  export interface CreateScheduleInput {
735
846
  name: string;
736
847
  description: string;
737
- target_id: string;
848
+ target_ids: string[];
738
849
  attached_to_uri?: string;
739
850
  spec_type: ScheduleSpecType;
740
851
  cron_expr?: string;
@@ -745,12 +856,13 @@ export interface CreateScheduleInput {
745
856
  end_at?: string;
746
857
  max_runs?: number;
747
858
  catchup_window_seconds?: number;
859
+ duration_seconds?: number;
748
860
  }
749
861
 
750
862
  export interface UpdateScheduleInput {
751
863
  name?: string;
752
864
  description?: string;
753
- target_id?: string;
865
+ target_ids?: string[];
754
866
  attached_to_uri?: string;
755
867
  /** Explicitly clear attached_to_uri. Server honors this over `attached_to_uri`. */
756
868
  attached_to_uri_clear?: boolean;
@@ -768,11 +880,13 @@ export interface UpdateScheduleInput {
768
880
  /** Explicitly clear max_runs. Server honors this over `max_runs`. */
769
881
  max_runs_clear?: boolean;
770
882
  catchup_window_seconds?: number;
883
+ duration_seconds?: number;
884
+ duration_seconds_clear?: boolean;
771
885
  }
772
886
 
773
887
  export interface ScheduleFilters {
774
888
  attached_to?: string;
775
- target_id?: string;
889
+ attendee_id?: string;
776
890
  creator_id?: string;
777
891
  /** Comma-separated list of statuses (e.g. 'active,paused'). */
778
892
  status?: string;
@@ -1242,12 +1356,15 @@ export type ApprovalUpdateData = CardUpdateData;
1242
1356
 
1243
1357
  export interface CardUpdateData {
1244
1358
  card_type: string;
1245
- approval_id?: string;
1359
+ entity_id: string;
1246
1360
  message_id: string;
1247
1361
  chat_id: string;
1248
1362
  status: string;
1363
+ execution_status?: ExecutionStatus | null;
1249
1364
  decided_by?: string;
1250
1365
  decided_at?: string;
1366
+ executed_at?: string | null;
1367
+ execution_error?: string | null;
1251
1368
  }
1252
1369
 
1253
1370
  export interface RecoveryOverflowData {
@@ -1466,6 +1583,7 @@ export interface InboxItem {
1466
1583
 
1467
1584
  export type DispatchEventType = 'message' | 'task_assign' | 'task_comment' | 'schedule.fire';
1468
1585
  export type DispatchStatus = 'pending' | 'acked';
1586
+ export type DispatchDeliveryReason = 'mention' | 'watcher';
1469
1587
 
1470
1588
  export interface DispatchEvent {
1471
1589
  id: string;
@@ -1484,6 +1602,12 @@ export interface DispatchEvent {
1484
1602
  * (@mention, DM, task assignment, active-mode fanout).
1485
1603
  */
1486
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;
1487
1611
  status: DispatchStatus;
1488
1612
  acked_at: string | null;
1489
1613
  created_at: string;
@@ -1570,6 +1694,11 @@ export type WsEventMap = {
1570
1694
  'schedule.updated': ScheduleUpdatedData;
1571
1695
  'schedule.deleted': ScheduleDeletedData;
1572
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;
1573
1702
  };
1574
1703
 
1575
1704
  // Invitation WS event data
@@ -1609,6 +1738,7 @@ export interface PlatformConfigResponse {
1609
1738
  version: string;
1610
1739
  schema_version: number;
1611
1740
  min_plugin_version?: string;
1741
+ mode?: string;
1612
1742
  config: Record<string, unknown>;
1613
1743
  }
1614
1744
 
@@ -1805,3 +1935,148 @@ export interface SetRuntimeModeRequest {
1805
1935
  update_mode: RuntimeUpdateMode;
1806
1936
  pinned_tag?: string | null;
1807
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
+ }