@hasura/promptql 2.0.0-alpha.3 → 2.0.0-alpha.5

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/biome.json CHANGED
@@ -2,7 +2,14 @@
2
2
  "$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
3
3
  "root": false,
4
4
  "files": {
5
- "includes": ["**/*.ts", "**/*.gql", "!src/generated/*", "!dist/**/*"]
5
+ "includes": [
6
+ "**/*.ts",
7
+ "**/*.gql",
8
+ "!src/generated/*",
9
+ "!dist/**/*"
10
+ ]
6
11
  },
7
- "extends": ["@hasura/biome-config/base"]
8
- }
12
+ "extends": [
13
+ "../biome-config/base.json"
14
+ ]
15
+ }
package/dist/index.d.mts CHANGED
@@ -2585,6 +2585,10 @@ type Scalars = {
2585
2585
  input: any;
2586
2586
  output: any;
2587
2587
  };
2588
+ numeric: {
2589
+ input: number;
2590
+ output: number;
2591
+ };
2588
2592
  timestamptz: {
2589
2593
  input: string;
2590
2594
  output: string;
@@ -3354,6 +3358,7 @@ type Thread_Events_Bool_Exp = {
3354
3358
  _and?: InputMaybe<Array<Thread_Events_Bool_Exp>>;
3355
3359
  _not?: InputMaybe<Thread_Events_Bool_Exp>;
3356
3360
  _or?: InputMaybe<Array<Thread_Events_Bool_Exp>>;
3361
+ build_fqdn?: InputMaybe<String_Comparison_Exp>;
3357
3362
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3358
3363
  event_data?: InputMaybe<Jsonb_Comparison_Exp>;
3359
3364
  thread?: InputMaybe<Threads_V2_Bool_Exp>;
@@ -3365,18 +3370,20 @@ type Thread_Events_Bool_Exp = {
3365
3370
  };
3366
3371
  /** order by max() on columns of table "thread_events" */
3367
3372
  type Thread_Events_Max_Order_By = {
3373
+ build_fqdn?: InputMaybe<Order_By>;
3368
3374
  created_at?: InputMaybe<Order_By>;
3369
3375
  thread_event_id?: InputMaybe<Order_By>;
3370
3376
  thread_id?: InputMaybe<Order_By>;
3371
- /** promptql_user_id of creator */
3377
+ /** promptql_user_id of the event author. NULL for agent (PromptQL) messages because the agent HGE role does not set this column. Non-NULL for user messages (set by HGE permission). */
3372
3378
  user_id?: InputMaybe<Order_By>;
3373
3379
  };
3374
3380
  /** order by min() on columns of table "thread_events" */
3375
3381
  type Thread_Events_Min_Order_By = {
3382
+ build_fqdn?: InputMaybe<Order_By>;
3376
3383
  created_at?: InputMaybe<Order_By>;
3377
3384
  thread_event_id?: InputMaybe<Order_By>;
3378
3385
  thread_id?: InputMaybe<Order_By>;
3379
- /** promptql_user_id of creator */
3386
+ /** promptql_user_id of the event author. NULL for agent (PromptQL) messages because the agent HGE role does not set this column. Non-NULL for user messages (set by HGE permission). */
3380
3387
  user_id?: InputMaybe<Order_By>;
3381
3388
  };
3382
3389
  /** order by stddev() on columns of table "thread_events" */
@@ -3407,6 +3414,15 @@ type Thread_Events_Var_Samp_Order_By = {
3407
3414
  type Thread_Events_Variance_Order_By = {
3408
3415
  thread_event_id?: InputMaybe<Order_By>;
3409
3416
  };
3417
+ type Thread_Feedback_Aggregate_Bool_Exp = {
3418
+ count?: InputMaybe<Thread_Feedback_Aggregate_Bool_Exp_Count>;
3419
+ };
3420
+ type Thread_Feedback_Aggregate_Bool_Exp_Count = {
3421
+ arguments?: InputMaybe<Array<Thread_Feedback_Select_Column>>;
3422
+ distinct?: InputMaybe<Scalars['Boolean']['input']>;
3423
+ filter?: InputMaybe<Thread_Feedback_Bool_Exp>;
3424
+ predicate: Int_Comparison_Exp;
3425
+ };
3410
3426
  /** order by aggregate values of table "thread_feedback" */
3411
3427
  type Thread_Feedback_Aggregate_Order_By = {
3412
3428
  avg?: InputMaybe<Thread_Feedback_Avg_Order_By>;
@@ -3460,6 +3476,20 @@ type Thread_Feedback_Min_Order_By = {
3460
3476
  promptql_user_id?: InputMaybe<Order_By>;
3461
3477
  thread_id?: InputMaybe<Order_By>;
3462
3478
  };
3479
+ /** select columns of table "thread_feedback" */
3480
+ type Thread_Feedback_Select_Column =
3481
+ /** column name */
3482
+ 'created_at'
3483
+ /** column name */
3484
+ | 'details'
3485
+ /** column name */
3486
+ | 'feedback'
3487
+ /** column name */
3488
+ | 'message_id'
3489
+ /** column name */
3490
+ | 'promptql_user_id'
3491
+ /** column name */
3492
+ | 'thread_id';
3463
3493
  /** order by stddev() on columns of table "thread_feedback" */
3464
3494
  type Thread_Feedback_Stddev_Order_By = {
3465
3495
  /** -1 means negative, 1 means positive */
@@ -3600,7 +3630,6 @@ type Thread_Participants_Bool_Exp = {
3600
3630
  _and?: InputMaybe<Array<Thread_Participants_Bool_Exp>>;
3601
3631
  _not?: InputMaybe<Thread_Participants_Bool_Exp>;
3602
3632
  _or?: InputMaybe<Array<Thread_Participants_Bool_Exp>>;
3603
- added_by?: InputMaybe<String_Comparison_Exp>;
3604
3633
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3605
3634
  is_removed?: InputMaybe<Boolean_Comparison_Exp>;
3606
3635
  last_seen_event_id?: InputMaybe<Bigint_Comparison_Exp>;
@@ -3618,8 +3647,6 @@ type Thread_Participants_Bool_Exp = {
3618
3647
  };
3619
3648
  /** order by max() on columns of table "thread_participants" */
3620
3649
  type Thread_Participants_Max_Order_By = {
3621
- /** The promptql_user_id of the user who added this participant */
3622
- added_by?: InputMaybe<Order_By>;
3623
3650
  /** Timestamp when the participant was added to the thread */
3624
3651
  created_at?: InputMaybe<Order_By>;
3625
3652
  last_seen_event_id?: InputMaybe<Order_By>;
@@ -3629,8 +3656,6 @@ type Thread_Participants_Max_Order_By = {
3629
3656
  };
3630
3657
  /** order by min() on columns of table "thread_participants" */
3631
3658
  type Thread_Participants_Min_Order_By = {
3632
- /** The promptql_user_id of the user who added this participant */
3633
- added_by?: InputMaybe<Order_By>;
3634
3659
  /** Timestamp when the participant was added to the thread */
3635
3660
  created_at?: InputMaybe<Order_By>;
3636
3661
  last_seen_event_id?: InputMaybe<Order_By>;
@@ -3641,9 +3666,7 @@ type Thread_Participants_Min_Order_By = {
3641
3666
  /** select columns of table "thread_participants" */
3642
3667
  type Thread_Participants_Select_Column =
3643
3668
  /** column name */
3644
- 'added_by'
3645
- /** column name */
3646
- | 'created_at'
3669
+ 'created_at'
3647
3670
  /** column name */
3648
3671
  | 'is_removed'
3649
3672
  /** column name */
@@ -3727,7 +3750,9 @@ type Threads_V2_Bool_Exp = {
3727
3750
  _or?: InputMaybe<Array<Threads_V2_Bool_Exp>>;
3728
3751
  build_id?: InputMaybe<Uuid_Comparison_Exp>;
3729
3752
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3753
+ custom_title?: InputMaybe<String_Comparison_Exp>;
3730
3754
  deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3755
+ learning_suggestion?: InputMaybe<String_Comparison_Exp>;
3731
3756
  pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
3732
3757
  project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
3733
3758
  project_id?: InputMaybe<Uuid_Comparison_Exp>;
@@ -3740,6 +3765,7 @@ type Threads_V2_Bool_Exp = {
3740
3765
  thread_artifacts?: InputMaybe<Thread_Artifacts_Bool_Exp>;
3741
3766
  thread_events?: InputMaybe<Thread_Events_Bool_Exp>;
3742
3767
  thread_feedback?: InputMaybe<Thread_Feedback_Bool_Exp>;
3768
+ thread_feedback_aggregate?: InputMaybe<Thread_Feedback_Aggregate_Bool_Exp>;
3743
3769
  thread_id?: InputMaybe<Uuid_Comparison_Exp>;
3744
3770
  thread_participants?: InputMaybe<Thread_Participants_Bool_Exp>;
3745
3771
  thread_participants_aggregate?: InputMaybe<Thread_Participants_Aggregate_Bool_Exp>;
@@ -3753,6 +3779,7 @@ type Threads_V2_Bool_Exp = {
3753
3779
  type Threads_V2_Max_Order_By = {
3754
3780
  build_id?: InputMaybe<Order_By>;
3755
3781
  created_at?: InputMaybe<Order_By>;
3782
+ custom_title?: InputMaybe<Order_By>;
3756
3783
  deleted_at?: InputMaybe<Order_By>;
3757
3784
  project_id?: InputMaybe<Order_By>;
3758
3785
  /** The room this thread belongs to. Every thread must belong to exactly one room. */
@@ -3768,6 +3795,7 @@ type Threads_V2_Max_Order_By = {
3768
3795
  type Threads_V2_Min_Order_By = {
3769
3796
  build_id?: InputMaybe<Order_By>;
3770
3797
  created_at?: InputMaybe<Order_By>;
3798
+ custom_title?: InputMaybe<Order_By>;
3771
3799
  deleted_at?: InputMaybe<Order_By>;
3772
3800
  project_id?: InputMaybe<Order_By>;
3773
3801
  /** The room this thread belongs to. Every thread must belong to exactly one room. */
@@ -3783,7 +3811,9 @@ type Threads_V2_Min_Order_By = {
3783
3811
  type Threads_V2_Order_By = {
3784
3812
  build_id?: InputMaybe<Order_By>;
3785
3813
  created_at?: InputMaybe<Order_By>;
3814
+ custom_title?: InputMaybe<Order_By>;
3786
3815
  deleted_at?: InputMaybe<Order_By>;
3816
+ learning_suggestion?: InputMaybe<Order_By>;
3787
3817
  pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
3788
3818
  project_config?: InputMaybe<Project_Configuration_Order_By>;
3789
3819
  project_id?: InputMaybe<Order_By>;
@@ -3810,6 +3840,8 @@ type Threads_V2_Select_Column =
3810
3840
  'build_id'
3811
3841
  /** column name */
3812
3842
  | 'created_at'
3843
+ /** column name */
3844
+ | 'custom_title'
3813
3845
  /** column name */
3814
3846
  | 'deleted_at'
3815
3847
  /** column name */
@@ -3905,6 +3937,7 @@ type User_Preferences_Bool_Exp = {
3905
3937
  _or?: InputMaybe<Array<User_Preferences_Bool_Exp>>;
3906
3938
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3907
3939
  custom_instructions?: InputMaybe<String_Comparison_Exp>;
3940
+ feature_flags?: InputMaybe<Jsonb_Comparison_Exp>;
3908
3941
  promptql_user?: InputMaybe<Promptql_Users_Bool_Exp>;
3909
3942
  promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
3910
3943
  updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
@@ -3913,6 +3946,7 @@ type User_Preferences_Bool_Exp = {
3913
3946
  type User_Preferences_Order_By = {
3914
3947
  created_at?: InputMaybe<Order_By>;
3915
3948
  custom_instructions?: InputMaybe<Order_By>;
3949
+ feature_flags?: InputMaybe<Order_By>;
3916
3950
  promptql_user?: InputMaybe<Promptql_Users_Order_By>;
3917
3951
  promptql_user_id?: InputMaybe<Order_By>;
3918
3952
  updated_at?: InputMaybe<Order_By>;
@@ -4044,11 +4078,7 @@ type PromptQLSdkOptions = {
4044
4078
  */
4045
4079
  authHost?: string;
4046
4080
  /**
4047
- * Project ID of the PromptQL project. You can find it in Project Settings > General Settings tab on https://promptql.console.hasura.io.
4048
- */
4049
- projectId: string;
4050
- /**
4051
- * Base URL of the PromptQL data plane. You can find it in Project Settings > PromptQL > PromptQL API on https://promptql.console.hasura.io.
4081
+ * Base URL of the PromptQL data plane. You can find it in Project Settings > PromptQL > PromptQL API on https://prompt.ql.app.
4052
4082
  * The base URL must remove the request path, For example: https://promptql.ddn.hasura.app.
4053
4083
  */
4054
4084
  promptqlBaseUrl?: string;
@@ -4173,7 +4203,6 @@ type WikiExplorerCompleted = EventOfKind<WikiExplorerUpdate, "Completed">;
4173
4203
  */
4174
4204
  type PromptQLAuthTokenGeneratorOptions = {
4175
4205
  authHost?: string;
4176
- projectId: string;
4177
4206
  promptqlGraphQLUrl: string;
4178
4207
  serviceAccountToken: string;
4179
4208
  fetch?: typeof fetch;
@@ -4198,10 +4227,12 @@ declare function isEnrichTokenMutationResponse(input: unknown): input is {
4198
4227
  errors?: GraphQLError[];
4199
4228
  };
4200
4229
 
4230
+ /**
4231
+ * Internal client options.
4232
+ */
4201
4233
  type ClientOptions = {
4202
4234
  client: ApolloClient;
4203
- projectId: string;
4204
- buildId: string | undefined;
4235
+ buildId?: string;
4205
4236
  defaultTimezone: string;
4206
4237
  };
4207
4238
 
@@ -4212,7 +4243,7 @@ declare class Project {
4212
4243
  private _options;
4213
4244
  constructor(options: ClientOptions);
4214
4245
  /**
4215
- * Get the basic information of the PromptQL project.
4246
+ * Get the basic information of the current PromptQL project.
4216
4247
  */
4217
4248
  info(): Promise<GetProjectInfoOutput>;
4218
4249
  }
package/dist/index.d.ts CHANGED
@@ -2585,6 +2585,10 @@ type Scalars = {
2585
2585
  input: any;
2586
2586
  output: any;
2587
2587
  };
2588
+ numeric: {
2589
+ input: number;
2590
+ output: number;
2591
+ };
2588
2592
  timestamptz: {
2589
2593
  input: string;
2590
2594
  output: string;
@@ -3354,6 +3358,7 @@ type Thread_Events_Bool_Exp = {
3354
3358
  _and?: InputMaybe<Array<Thread_Events_Bool_Exp>>;
3355
3359
  _not?: InputMaybe<Thread_Events_Bool_Exp>;
3356
3360
  _or?: InputMaybe<Array<Thread_Events_Bool_Exp>>;
3361
+ build_fqdn?: InputMaybe<String_Comparison_Exp>;
3357
3362
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3358
3363
  event_data?: InputMaybe<Jsonb_Comparison_Exp>;
3359
3364
  thread?: InputMaybe<Threads_V2_Bool_Exp>;
@@ -3365,18 +3370,20 @@ type Thread_Events_Bool_Exp = {
3365
3370
  };
3366
3371
  /** order by max() on columns of table "thread_events" */
3367
3372
  type Thread_Events_Max_Order_By = {
3373
+ build_fqdn?: InputMaybe<Order_By>;
3368
3374
  created_at?: InputMaybe<Order_By>;
3369
3375
  thread_event_id?: InputMaybe<Order_By>;
3370
3376
  thread_id?: InputMaybe<Order_By>;
3371
- /** promptql_user_id of creator */
3377
+ /** promptql_user_id of the event author. NULL for agent (PromptQL) messages because the agent HGE role does not set this column. Non-NULL for user messages (set by HGE permission). */
3372
3378
  user_id?: InputMaybe<Order_By>;
3373
3379
  };
3374
3380
  /** order by min() on columns of table "thread_events" */
3375
3381
  type Thread_Events_Min_Order_By = {
3382
+ build_fqdn?: InputMaybe<Order_By>;
3376
3383
  created_at?: InputMaybe<Order_By>;
3377
3384
  thread_event_id?: InputMaybe<Order_By>;
3378
3385
  thread_id?: InputMaybe<Order_By>;
3379
- /** promptql_user_id of creator */
3386
+ /** promptql_user_id of the event author. NULL for agent (PromptQL) messages because the agent HGE role does not set this column. Non-NULL for user messages (set by HGE permission). */
3380
3387
  user_id?: InputMaybe<Order_By>;
3381
3388
  };
3382
3389
  /** order by stddev() on columns of table "thread_events" */
@@ -3407,6 +3414,15 @@ type Thread_Events_Var_Samp_Order_By = {
3407
3414
  type Thread_Events_Variance_Order_By = {
3408
3415
  thread_event_id?: InputMaybe<Order_By>;
3409
3416
  };
3417
+ type Thread_Feedback_Aggregate_Bool_Exp = {
3418
+ count?: InputMaybe<Thread_Feedback_Aggregate_Bool_Exp_Count>;
3419
+ };
3420
+ type Thread_Feedback_Aggregate_Bool_Exp_Count = {
3421
+ arguments?: InputMaybe<Array<Thread_Feedback_Select_Column>>;
3422
+ distinct?: InputMaybe<Scalars['Boolean']['input']>;
3423
+ filter?: InputMaybe<Thread_Feedback_Bool_Exp>;
3424
+ predicate: Int_Comparison_Exp;
3425
+ };
3410
3426
  /** order by aggregate values of table "thread_feedback" */
3411
3427
  type Thread_Feedback_Aggregate_Order_By = {
3412
3428
  avg?: InputMaybe<Thread_Feedback_Avg_Order_By>;
@@ -3460,6 +3476,20 @@ type Thread_Feedback_Min_Order_By = {
3460
3476
  promptql_user_id?: InputMaybe<Order_By>;
3461
3477
  thread_id?: InputMaybe<Order_By>;
3462
3478
  };
3479
+ /** select columns of table "thread_feedback" */
3480
+ type Thread_Feedback_Select_Column =
3481
+ /** column name */
3482
+ 'created_at'
3483
+ /** column name */
3484
+ | 'details'
3485
+ /** column name */
3486
+ | 'feedback'
3487
+ /** column name */
3488
+ | 'message_id'
3489
+ /** column name */
3490
+ | 'promptql_user_id'
3491
+ /** column name */
3492
+ | 'thread_id';
3463
3493
  /** order by stddev() on columns of table "thread_feedback" */
3464
3494
  type Thread_Feedback_Stddev_Order_By = {
3465
3495
  /** -1 means negative, 1 means positive */
@@ -3600,7 +3630,6 @@ type Thread_Participants_Bool_Exp = {
3600
3630
  _and?: InputMaybe<Array<Thread_Participants_Bool_Exp>>;
3601
3631
  _not?: InputMaybe<Thread_Participants_Bool_Exp>;
3602
3632
  _or?: InputMaybe<Array<Thread_Participants_Bool_Exp>>;
3603
- added_by?: InputMaybe<String_Comparison_Exp>;
3604
3633
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3605
3634
  is_removed?: InputMaybe<Boolean_Comparison_Exp>;
3606
3635
  last_seen_event_id?: InputMaybe<Bigint_Comparison_Exp>;
@@ -3618,8 +3647,6 @@ type Thread_Participants_Bool_Exp = {
3618
3647
  };
3619
3648
  /** order by max() on columns of table "thread_participants" */
3620
3649
  type Thread_Participants_Max_Order_By = {
3621
- /** The promptql_user_id of the user who added this participant */
3622
- added_by?: InputMaybe<Order_By>;
3623
3650
  /** Timestamp when the participant was added to the thread */
3624
3651
  created_at?: InputMaybe<Order_By>;
3625
3652
  last_seen_event_id?: InputMaybe<Order_By>;
@@ -3629,8 +3656,6 @@ type Thread_Participants_Max_Order_By = {
3629
3656
  };
3630
3657
  /** order by min() on columns of table "thread_participants" */
3631
3658
  type Thread_Participants_Min_Order_By = {
3632
- /** The promptql_user_id of the user who added this participant */
3633
- added_by?: InputMaybe<Order_By>;
3634
3659
  /** Timestamp when the participant was added to the thread */
3635
3660
  created_at?: InputMaybe<Order_By>;
3636
3661
  last_seen_event_id?: InputMaybe<Order_By>;
@@ -3641,9 +3666,7 @@ type Thread_Participants_Min_Order_By = {
3641
3666
  /** select columns of table "thread_participants" */
3642
3667
  type Thread_Participants_Select_Column =
3643
3668
  /** column name */
3644
- 'added_by'
3645
- /** column name */
3646
- | 'created_at'
3669
+ 'created_at'
3647
3670
  /** column name */
3648
3671
  | 'is_removed'
3649
3672
  /** column name */
@@ -3727,7 +3750,9 @@ type Threads_V2_Bool_Exp = {
3727
3750
  _or?: InputMaybe<Array<Threads_V2_Bool_Exp>>;
3728
3751
  build_id?: InputMaybe<Uuid_Comparison_Exp>;
3729
3752
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3753
+ custom_title?: InputMaybe<String_Comparison_Exp>;
3730
3754
  deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3755
+ learning_suggestion?: InputMaybe<String_Comparison_Exp>;
3731
3756
  pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
3732
3757
  project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
3733
3758
  project_id?: InputMaybe<Uuid_Comparison_Exp>;
@@ -3740,6 +3765,7 @@ type Threads_V2_Bool_Exp = {
3740
3765
  thread_artifacts?: InputMaybe<Thread_Artifacts_Bool_Exp>;
3741
3766
  thread_events?: InputMaybe<Thread_Events_Bool_Exp>;
3742
3767
  thread_feedback?: InputMaybe<Thread_Feedback_Bool_Exp>;
3768
+ thread_feedback_aggregate?: InputMaybe<Thread_Feedback_Aggregate_Bool_Exp>;
3743
3769
  thread_id?: InputMaybe<Uuid_Comparison_Exp>;
3744
3770
  thread_participants?: InputMaybe<Thread_Participants_Bool_Exp>;
3745
3771
  thread_participants_aggregate?: InputMaybe<Thread_Participants_Aggregate_Bool_Exp>;
@@ -3753,6 +3779,7 @@ type Threads_V2_Bool_Exp = {
3753
3779
  type Threads_V2_Max_Order_By = {
3754
3780
  build_id?: InputMaybe<Order_By>;
3755
3781
  created_at?: InputMaybe<Order_By>;
3782
+ custom_title?: InputMaybe<Order_By>;
3756
3783
  deleted_at?: InputMaybe<Order_By>;
3757
3784
  project_id?: InputMaybe<Order_By>;
3758
3785
  /** The room this thread belongs to. Every thread must belong to exactly one room. */
@@ -3768,6 +3795,7 @@ type Threads_V2_Max_Order_By = {
3768
3795
  type Threads_V2_Min_Order_By = {
3769
3796
  build_id?: InputMaybe<Order_By>;
3770
3797
  created_at?: InputMaybe<Order_By>;
3798
+ custom_title?: InputMaybe<Order_By>;
3771
3799
  deleted_at?: InputMaybe<Order_By>;
3772
3800
  project_id?: InputMaybe<Order_By>;
3773
3801
  /** The room this thread belongs to. Every thread must belong to exactly one room. */
@@ -3783,7 +3811,9 @@ type Threads_V2_Min_Order_By = {
3783
3811
  type Threads_V2_Order_By = {
3784
3812
  build_id?: InputMaybe<Order_By>;
3785
3813
  created_at?: InputMaybe<Order_By>;
3814
+ custom_title?: InputMaybe<Order_By>;
3786
3815
  deleted_at?: InputMaybe<Order_By>;
3816
+ learning_suggestion?: InputMaybe<Order_By>;
3787
3817
  pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
3788
3818
  project_config?: InputMaybe<Project_Configuration_Order_By>;
3789
3819
  project_id?: InputMaybe<Order_By>;
@@ -3810,6 +3840,8 @@ type Threads_V2_Select_Column =
3810
3840
  'build_id'
3811
3841
  /** column name */
3812
3842
  | 'created_at'
3843
+ /** column name */
3844
+ | 'custom_title'
3813
3845
  /** column name */
3814
3846
  | 'deleted_at'
3815
3847
  /** column name */
@@ -3905,6 +3937,7 @@ type User_Preferences_Bool_Exp = {
3905
3937
  _or?: InputMaybe<Array<User_Preferences_Bool_Exp>>;
3906
3938
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
3907
3939
  custom_instructions?: InputMaybe<String_Comparison_Exp>;
3940
+ feature_flags?: InputMaybe<Jsonb_Comparison_Exp>;
3908
3941
  promptql_user?: InputMaybe<Promptql_Users_Bool_Exp>;
3909
3942
  promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
3910
3943
  updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
@@ -3913,6 +3946,7 @@ type User_Preferences_Bool_Exp = {
3913
3946
  type User_Preferences_Order_By = {
3914
3947
  created_at?: InputMaybe<Order_By>;
3915
3948
  custom_instructions?: InputMaybe<Order_By>;
3949
+ feature_flags?: InputMaybe<Order_By>;
3916
3950
  promptql_user?: InputMaybe<Promptql_Users_Order_By>;
3917
3951
  promptql_user_id?: InputMaybe<Order_By>;
3918
3952
  updated_at?: InputMaybe<Order_By>;
@@ -4044,11 +4078,7 @@ type PromptQLSdkOptions = {
4044
4078
  */
4045
4079
  authHost?: string;
4046
4080
  /**
4047
- * Project ID of the PromptQL project. You can find it in Project Settings > General Settings tab on https://promptql.console.hasura.io.
4048
- */
4049
- projectId: string;
4050
- /**
4051
- * Base URL of the PromptQL data plane. You can find it in Project Settings > PromptQL > PromptQL API on https://promptql.console.hasura.io.
4081
+ * Base URL of the PromptQL data plane. You can find it in Project Settings > PromptQL > PromptQL API on https://prompt.ql.app.
4052
4082
  * The base URL must remove the request path, For example: https://promptql.ddn.hasura.app.
4053
4083
  */
4054
4084
  promptqlBaseUrl?: string;
@@ -4173,7 +4203,6 @@ type WikiExplorerCompleted = EventOfKind<WikiExplorerUpdate, "Completed">;
4173
4203
  */
4174
4204
  type PromptQLAuthTokenGeneratorOptions = {
4175
4205
  authHost?: string;
4176
- projectId: string;
4177
4206
  promptqlGraphQLUrl: string;
4178
4207
  serviceAccountToken: string;
4179
4208
  fetch?: typeof fetch;
@@ -4198,10 +4227,12 @@ declare function isEnrichTokenMutationResponse(input: unknown): input is {
4198
4227
  errors?: GraphQLError[];
4199
4228
  };
4200
4229
 
4230
+ /**
4231
+ * Internal client options.
4232
+ */
4201
4233
  type ClientOptions = {
4202
4234
  client: ApolloClient;
4203
- projectId: string;
4204
- buildId: string | undefined;
4235
+ buildId?: string;
4205
4236
  defaultTimezone: string;
4206
4237
  };
4207
4238
 
@@ -4212,7 +4243,7 @@ declare class Project {
4212
4243
  private _options;
4213
4244
  constructor(options: ClientOptions);
4214
4245
  /**
4215
- * Get the basic information of the PromptQL project.
4246
+ * Get the basic information of the current PromptQL project.
4216
4247
  */
4217
4248
  info(): Promise<GetProjectInfoOutput>;
4218
4249
  }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},D=(e,t,r,_)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of q(t))!z.call(e,a)&&a!==r&&h(e,a,{get:()=>t[a],enumerable:!(_=j(t,a))||_.enumerable});return e};var Q=e=>D(h({},"__esModule",{value:!0}),e);var fe={};G(fe,{PromptQLSdk:()=>v,createApolloClient:()=>k,createPromptQLAuthTokenGenerator:()=>B,diffThreadEvents:()=>K,getAgentGeneratedResponse:()=>Y,getAgentInteractionDecisionAcceptInteractionEvent:()=>X,getAgentInteractionDecisionDeclineInteractionEvent:()=>ee,getAgentMessageProcessingStartedEvent:()=>Z,getAgentOrchestratorContextExplorerCompletedEvent:()=>ie,getAgentOrchestratorContextExplorerStartedEvent:()=>ne,getAgentOrchestratorContextExplorerUpdateEvent:()=>d,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>me,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>be,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>le,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Ie,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Me,getAgentOrchestratorSchemaExplorerStartedEvent:()=>ce,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>de,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>ye,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>ue,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>S,getAgentOrchestratorStepProgrammerEvent:()=>Se,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>he,getAgentOrchestratorStepUiProgrammerEvent:()=>ge,getAgentOrchestratorStepUpdateEvent:()=>g,getAgentOrchestratorUpdateEvent:()=>O,getAgentOrchestratorWikiExplorerCompletedEvent:()=>oe,getAgentOrchestratorWikiExplorerStartedEvent:()=>pe,getAgentOrchestratorWikiExplorerUpdateEvent:()=>M,getAgentOrchestratorWikiInfoGeneratedEvent:()=>se,getAgentPlanGenerationStartedEvent:()=>J,getAgentPlanStepGeneratedEvent:()=>$,getAgentPlanningDecisionCompletedEvent:()=>re,getAgentPlanningDecisionPlanningRequiredEvent:()=>ae,getAgentPlanningDecisionStartedEvent:()=>te,getAgentPlanningDecisionUpdateEvent:()=>I,getAgentStartingOrchestratorEvent:()=>_e,getUserCancelEvent:()=>L,getUserMessageEvent:()=>H,isEnrichTokenMutationResponse:()=>A,isLuxAuthPromptQLTokenFailedResponse:()=>f,isLuxAuthPromptQLTokenSuccessResponse:()=>x});module.exports=Q(fe);function c(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function f(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function x(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function A(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function B(e){let r=`${c(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},a=e.fetch||fetch,o=async()=>{let n=await a(r,{method:"POST",headers:{Authorization:`pat ${e.serviceAccountToken}`}});switch(n.status){case 200:{let i=await n.json();if(x(i))return i;throw new Error("malformed token response")}case 401:{let i=await n.json();throw f(i)?new Error(i?.error||n.statusText):new Error(n.statusText)}default:{let i=await n.text();throw new Error(i)}}},s=async n=>{let i=await a(e.promptqlGraphQLUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid!) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:n.token,projectId:e.projectId},operationName:"EnrichToken"})});switch(i.status){case 200:{let p=await i.json();if(!A(p)||!p.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(p)}`);return p.data.enrich_token.userDirectoryJWT}default:{let p=await i.text();throw new Error(p)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let n=await o(),i=await s(n);_.token=i;let p=new Date(n.expiry);if(Number.isNaN(p.getTime())){let C=new Date;C.setHours(1),_.expiry=C}else _.expiry=p}return _.token}}var u=require("@apollo/client"),T=require("@apollo/client/link/context"),E=require("@apollo/client/link/subscriptions"),P=require("graphql"),R=require("graphql-ws"),k=e=>{let t=new u.HttpLink({uri:e.url,fetch:e.fetch,headers:e.headers}),r=async s=>{let n=await e.getAuthToken();return{headers:{...s,Authorization:`Bearer ${n}`}}},_=new E.GraphQLWsLink((0,R.createClient)({url:e.url,connectionParams:()=>r(e.headers)})),a=new T.SetContextLink(({headers:s})=>r(s)),o=u.ApolloLink.split(({operationType:s})=>s===P.OperationTypeNode.SUBSCRIPTION,_,a.concat(t));return new u.ApolloClient({link:o,cache:new u.InMemoryCache})};var U={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},w={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},arguments:[{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]};var l=class{_options;constructor(t){this._options=t}info(){return this._options.client.query({query:V,variables:{projectId:this._options.projectId}}).then(t=>{if(!t.data?.get_project_info)throw new Error(t.error?.message||"Project not found");return t.data.get_project_info})}};var b=require("rxjs/operators");var m=class{_options;constructor(t){this._options=t}list(t){return this._options.client.query({query:W,variables:{...t,limit:t.limit&&t.limit>0?t.limit:10},fetchPolicy:"no-cache"}).then(r=>r.data?.threads_v2??[])}get(t){if(!t)throw new Error("threadId is required");return this._options.client.query({query:F,variables:{id:t},fetchPolicy:"no-cache"}).then(r=>r.data?.threads_v2_by_pk)}start(t){if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:w,variables:{...t,projectId:this._options.projectId,buildId:t.buildId||this._options.buildId,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.start_thread)throw new Error(r.error?.message||"Failed to start thread");return r.data.start_thread})}sendMessage(t){if(!t.threadId)throw new Error("threadId is required");if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:U,variables:{...t,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.send_thread_message)throw new Error(r.error?.message||"Failed to continue thread");return r.data.send_thread_message})}subscribeEvents(t,r){if(!t)throw new Error("threadId is required");if(r!=null)try{Number.parseInt(r)}catch{throw new Error("invalid threadEventId")}let _={thread_id:{_eq:t}};return r&&(_.thread_event_id={_gte:r}),this._options.client.subscribe({query:N,variables:{where:_}}).pipe((0,b.map)(a=>{if(a.error)throw a.error;return a.data?.thread_events??[]}))}streamEvents(t,r){return this.subscribeEvents(t,r).pipe((0,b.takeWhile)(_=>{for(let a=_.length-1;a>0;a--){let o=_[a];if("AgentMessage"in o.event_data&&"InteractionFinished"in o.event_data.AgentMessage.update)return!1}return!0},!0))}};var v=class{constructor(t){let r=c(t.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!t.projectId)throw new Error("projectId must not be empty. You can find it in Project Settings > General Settings tab on https://promptql.console.hasura.io.");if(!t.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=r.endsWith("/v1/graphql")?r:`${r}/playground-v2-hge/v1/graphql`,a=B({promptqlGraphQLUrl:_,authHost:t.authHost,projectId:t.projectId,serviceAccountToken:t.serviceAccountToken,fetch:t.fetch});this._options={projectId:t.projectId,buildId:t.buildId,client:k({getAuthToken:a,url:_,fetch:t.fetch,headers:t.headers}),defaultTimezone:t.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new m(this._options),this.project=new l(this._options)}_options;thread;project};function K(e,t){if(!t.length)return[];if(!e.length)return t;let r=e[e.length-1];if(!r)return t;let _=BigInt(r.thread_event_id),a=t.length-1;for(;a>=0;a--){let o=t[a];if(BigInt(o?.thread_event_id)<=_)break}return t.slice(a+1)}function H(e){return"UserMessage"in e?e.UserMessage:null}function L(e){return"UserCancel"in e?e.UserCancel:null}function J(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanGenerationStarted"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function $(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanStepGenerated"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanStepGenerated}function Y(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("GeneratedResponse"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse}function Z(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("ProcessingStarted"in e.AgentMessage.update.MessageProcessingUpdate.update)?null:e.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function X(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function ee(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function I(e){return!("AgentMessage"in e)||!("PlanningDecisionUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.PlanningDecisionUpdate.update}function te(e){let t=I(e);return!t||!("Started"in t)?null:t.Started}function re(e){let t=I(e);return!t||!("Completed"in t)?null:t.Completed}function ae(e){let t=I(e);return!t||!("PlanningRequired"in t)?null:t.PlanningRequired}function _e(e){return!("AgentMessage"in e)||!("StartingOrchestrator"in e.AgentMessage.update)?null:e.AgentMessage.update.StartingOrchestrator}function O(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.OrchestratorUpdate.update}function d(e){let t=O(e);return!t||!("ContextExplorerUpdate"in t)?null:t.ContextExplorerUpdate.update}function ne(e){let t=d(e);return!t||!("Started"in t)?null:t.Started}function ie(e){let t=d(e);return!t||!("Completed"in t)?null:t.Completed}function M(e){let t=d(e);return!t||!("WikiExplorerUpdate"in t)?null:t.WikiExplorerUpdate.update}function pe(e){let t=M(e);return!t||!("Started"in t)?null:t.Started}function oe(e){let t=M(e);return!t||!("Completed"in t)?null:t.Completed}function se(e){let t=M(e);return!t||!("WikiInfoGenerated"in t)?null:t.WikiInfoGenerated}function S(e){let t=d(e);return!t||!("SchemaTasksGenerationUpdate"in t)?null:t.SchemaTasksGenerationUpdate.update}function ue(e){let t=S(e);return!t||!("Started"in t)?null:t.Started}function ye(e){let t=S(e);return!t||!("Completed"in t)?null:t.Completed}function de(e){let t=S(e);return!t||!("TasksGenerated"in t)?null:t.TasksGenerated}function y(e){let t=d(e);return!t||!("SchemaExplorerUpdate"in t)?null:t.SchemaExplorerUpdate.update}function ce(e){let t=y(e);return!t||!("Started"in t)?null:t.Started}function le(e){let t=y(e);return!t||!("Completed"in t)?null:t.Completed}function me(e){let t=y(e);return!t||!("CodeExecutionComplete"in t)?null:t.CodeExecutionComplete}function be(e){let t=y(e);return!t||!("CodeOutputAnalyzed"in t)?null:t.CodeOutputAnalyzed}function Ie(e){let t=y(e);return!t||!("GeneratedCode"in t)?null:t.GeneratedCode}function Me(e){let t=y(e);return!t||!("SchemaExplored"in t)?null:t.SchemaExplored}function g(e){let t=O(e);return!t||!("StepUpdate"in t)?null:t.StepUpdate}function Se(e){let t=g(e);return!t||!("Programmer"in t.update)?null:t.update.Programmer}function ge(e){let t=g(e);return!t||!("UiProgrammer"in t.update)?null:t.update.UiProgrammer}function he(e){let t=g(e);return!t||!("SavedProgramRunner"in t.update)?null:t.update.SavedProgramRunner}0&&(module.exports={PromptQLSdk,createApolloClient,createPromptQLAuthTokenGenerator,diffThreadEvents,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getUserCancelEvent,getUserMessageEvent,isEnrichTokenMutationResponse,isLuxAuthPromptQLTokenFailedResponse,isLuxAuthPromptQLTokenSuccessResponse});
1
+ "use strict";var h=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var a in t)h(e,a,{get:t[a],enumerable:!0})},Q=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let _ of z(t))!G.call(e,_)&&_!==a&&h(e,_,{get:()=>t[_],enumerable:!(r=q(t,_))||r.enumerable});return e};var K=e=>Q(h({},"__esModule",{value:!0}),e);var xe={};D(xe,{PromptQLSdk:()=>v,createApolloClient:()=>k,createPromptQLAuthTokenGenerator:()=>B,diffThreadEvents:()=>H,getAgentGeneratedResponse:()=>X,getAgentInteractionDecisionAcceptInteractionEvent:()=>ee,getAgentInteractionDecisionDeclineInteractionEvent:()=>te,getAgentMessageProcessingStartedEvent:()=>Y,getAgentOrchestratorContextExplorerCompletedEvent:()=>pe,getAgentOrchestratorContextExplorerStartedEvent:()=>ie,getAgentOrchestratorContextExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>me,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Ie,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>be,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Me,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Se,getAgentOrchestratorSchemaExplorerStartedEvent:()=>le,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>d,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>ce,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>ye,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>de,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>S,getAgentOrchestratorStepProgrammerEvent:()=>ge,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>fe,getAgentOrchestratorStepUiProgrammerEvent:()=>he,getAgentOrchestratorStepUpdateEvent:()=>g,getAgentOrchestratorUpdateEvent:()=>C,getAgentOrchestratorWikiExplorerCompletedEvent:()=>ue,getAgentOrchestratorWikiExplorerStartedEvent:()=>oe,getAgentOrchestratorWikiExplorerUpdateEvent:()=>M,getAgentOrchestratorWikiInfoGeneratedEvent:()=>se,getAgentPlanGenerationStartedEvent:()=>$,getAgentPlanStepGeneratedEvent:()=>Z,getAgentPlanningDecisionCompletedEvent:()=>re,getAgentPlanningDecisionPlanningRequiredEvent:()=>_e,getAgentPlanningDecisionStartedEvent:()=>ae,getAgentPlanningDecisionUpdateEvent:()=>I,getAgentStartingOrchestratorEvent:()=>ne,getUserCancelEvent:()=>J,getUserMessageEvent:()=>L,isEnrichTokenMutationResponse:()=>A,isLuxAuthPromptQLTokenFailedResponse:()=>f,isLuxAuthPromptQLTokenSuccessResponse:()=>x});module.exports=K(xe);function c(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function f(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function x(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function A(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function B(e){let a=`${c(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,r={token:"",expiry:new Date(0)},_=e.fetch||fetch,o=async()=>{let n=await _(a,{method:"POST",headers:{Authorization:`pat ${e.serviceAccountToken}`}});switch(n.status){case 200:{let i=await n.json();if(x(i))return i;throw new Error("malformed token response")}case 401:{let i=await n.json();throw f(i)?new Error(i?.error||n.statusText):new Error(n.statusText)}default:{let i=await n.text();throw new Error(i)}}},u=async n=>{let i=await _(e.promptqlGraphQLUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!) { enrich_token(luxJWT: $luxJWT) { userDirectoryJWT }}",variables:{luxJWT:n.token},operationName:"EnrichToken"})});switch(i.status){case 200:{let p=await i.json();if(!A(p)||!p.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(p)}`);return p.data.enrich_token.userDirectoryJWT}default:{let p=await i.text();throw new Error(p)}}};return async()=>{if(r.expiry.getTime()<=Date.now()-1e3){let n=await o(),i=await u(n);r.token=i;let p=new Date(n.expiry);if(Number.isNaN(p.getTime())){let T=new Date;T.setHours(1),r.expiry=T}else r.expiry=p}return r.token}}var s=require("@apollo/client"),E=require("@apollo/client/link/context"),P=require("@apollo/client/link/subscriptions"),R=require("graphql"),U=require("graphql-ws"),k=e=>{let t=new s.HttpLink({uri:e.url,fetch:e.fetch,headers:e.headers}),a=async u=>{let n=await e.getAuthToken();return{headers:{...u,Authorization:`Bearer ${n}`}}},r=new P.GraphQLWsLink((0,U.createClient)({url:e.url,connectionParams:()=>a(e.headers)})),_=new E.SetContextLink(({headers:u})=>a(u)),o=s.ApolloLink.split(({operationType:u})=>u===R.OperationTypeNode.SUBSCRIPTION,r,_.concat(t));return new s.ApolloClient({link:o,cache:new s.InMemoryCache})};var w={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},j={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]};var l=class{_options;constructor(t){this._options=t}info(){return O(this._options.client)}};function O(e){return e.query({query:V,fetchPolicy:"cache-first"}).then(t=>{if(!t.data?.get_project_info)throw new Error(t.error?.message||"Project not found");return t.data.get_project_info})}var m=require("rxjs/operators");var b=class{_options;constructor(t){this._options=t}list(t){return this._options.client.query({query:W,variables:{...t,limit:t.limit&&t.limit>0?t.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}get(t){if(!t)throw new Error("threadId is required");return this._options.client.query({query:N,variables:{id:t},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}async start(t){if(!t.message.trim())throw new Error("message must not be empty");let a=await O(this._options.client);return this._options.client.mutate({mutation:F,variables:{...t,projectId:a.projectId,buildId:t.buildId||this._options.buildId,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.start_thread)throw new Error(r.error?.message||"Failed to start thread");return r.data.start_thread})}sendMessage(t){if(!t.threadId)throw new Error("threadId is required");if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:w,variables:{...t,timezone:t.timezone||this._options.defaultTimezone}}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to continue thread");return a.data.send_thread_message})}subscribeEvents(t,a){if(!t)throw new Error("threadId is required");if(a!=null)try{Number.parseInt(a)}catch{throw new Error("invalid threadEventId")}let r={thread_id:{_eq:t}};return a&&(r.thread_event_id={_gte:a}),this._options.client.subscribe({query:j,variables:{where:r}}).pipe((0,m.map)(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}streamEvents(t,a){return this.subscribeEvents(t,a).pipe((0,m.takeWhile)(r=>{for(let _=r.length-1;_>0;_--){let o=r[_];if("AgentMessage"in o.event_data&&"InteractionFinished"in o.event_data.AgentMessage.update)return!1}return!0},!0))}};var v=class{constructor(t){let a=c(t.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!t.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let r=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`,_=B({promptqlGraphQLUrl:r,authHost:t.authHost,serviceAccountToken:t.serviceAccountToken,fetch:t.fetch});this._options={buildId:t.buildId,client:k({getAuthToken:_,url:r,fetch:t.fetch,headers:t.headers}),defaultTimezone:t.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new b(this._options),this.project=new l(this._options)}_options;thread;project};function H(e,t){if(!t.length)return[];if(!e.length)return t;let a=e[e.length-1];if(!a)return t;let r=BigInt(a.thread_event_id),_=t.length-1;for(;_>=0;_--){let o=t[_];if(BigInt(o?.thread_event_id)<=r)break}return t.slice(_+1)}function L(e){return"UserMessage"in e?e.UserMessage:null}function J(e){return"UserCancel"in e?e.UserCancel:null}function $(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanGenerationStarted"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function Z(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanStepGenerated"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanStepGenerated}function X(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("GeneratedResponse"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse}function Y(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("ProcessingStarted"in e.AgentMessage.update.MessageProcessingUpdate.update)?null:e.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function ee(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function te(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function I(e){return!("AgentMessage"in e)||!("PlanningDecisionUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.PlanningDecisionUpdate.update}function ae(e){let t=I(e);return!t||!("Started"in t)?null:t.Started}function re(e){let t=I(e);return!t||!("Completed"in t)?null:t.Completed}function _e(e){let t=I(e);return!t||!("PlanningRequired"in t)?null:t.PlanningRequired}function ne(e){return!("AgentMessage"in e)||!("StartingOrchestrator"in e.AgentMessage.update)?null:e.AgentMessage.update.StartingOrchestrator}function C(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.OrchestratorUpdate.update}function y(e){let t=C(e);return!t||!("ContextExplorerUpdate"in t)?null:t.ContextExplorerUpdate.update}function ie(e){let t=y(e);return!t||!("Started"in t)?null:t.Started}function pe(e){let t=y(e);return!t||!("Completed"in t)?null:t.Completed}function M(e){let t=y(e);return!t||!("WikiExplorerUpdate"in t)?null:t.WikiExplorerUpdate.update}function oe(e){let t=M(e);return!t||!("Started"in t)?null:t.Started}function ue(e){let t=M(e);return!t||!("Completed"in t)?null:t.Completed}function se(e){let t=M(e);return!t||!("WikiInfoGenerated"in t)?null:t.WikiInfoGenerated}function S(e){let t=y(e);return!t||!("SchemaTasksGenerationUpdate"in t)?null:t.SchemaTasksGenerationUpdate.update}function de(e){let t=S(e);return!t||!("Started"in t)?null:t.Started}function ye(e){let t=S(e);return!t||!("Completed"in t)?null:t.Completed}function ce(e){let t=S(e);return!t||!("TasksGenerated"in t)?null:t.TasksGenerated}function d(e){let t=y(e);return!t||!("SchemaExplorerUpdate"in t)?null:t.SchemaExplorerUpdate.update}function le(e){let t=d(e);return!t||!("Started"in t)?null:t.Started}function be(e){let t=d(e);return!t||!("Completed"in t)?null:t.Completed}function me(e){let t=d(e);return!t||!("CodeExecutionComplete"in t)?null:t.CodeExecutionComplete}function Ie(e){let t=d(e);return!t||!("CodeOutputAnalyzed"in t)?null:t.CodeOutputAnalyzed}function Me(e){let t=d(e);return!t||!("GeneratedCode"in t)?null:t.GeneratedCode}function Se(e){let t=d(e);return!t||!("SchemaExplored"in t)?null:t.SchemaExplored}function g(e){let t=C(e);return!t||!("StepUpdate"in t)?null:t.StepUpdate}function ge(e){let t=g(e);return!t||!("Programmer"in t.update)?null:t.update.Programmer}function he(e){let t=g(e);return!t||!("UiProgrammer"in t.update)?null:t.update.UiProgrammer}function fe(e){let t=g(e);return!t||!("SavedProgramRunner"in t.update)?null:t.update.SavedProgramRunner}0&&(module.exports={PromptQLSdk,createApolloClient,createPromptQLAuthTokenGenerator,diffThreadEvents,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getUserCancelEvent,getUserMessageEvent,isEnrichTokenMutationResponse,isLuxAuthPromptQLTokenFailedResponse,isLuxAuthPromptQLTokenSuccessResponse});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function d(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function g(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function h(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function f(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function x(e){let r=`${d(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},a=e.fetch||fetch,o=async()=>{let n=await a(r,{method:"POST",headers:{Authorization:`pat ${e.serviceAccountToken}`}});switch(n.status){case 200:{let i=await n.json();if(h(i))return i;throw new Error("malformed token response")}case 401:{let i=await n.json();throw g(i)?new Error(i?.error||n.statusText):new Error(n.statusText)}default:{let i=await n.text();throw new Error(i)}}},s=async n=>{let i=await a(e.promptqlGraphQLUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid!) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:n.token,projectId:e.projectId},operationName:"EnrichToken"})});switch(i.status){case 200:{let p=await i.json();if(!f(p)||!p.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(p)}`);return p.data.enrich_token.userDirectoryJWT}default:{let p=await i.text();throw new Error(p)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let n=await o(),i=await s(n);_.token=i;let p=new Date(n.expiry);if(Number.isNaN(p.getTime())){let S=new Date;S.setHours(1),_.expiry=S}else _.expiry=p}return _.token}}import{ApolloClient as R,ApolloLink as U,HttpLink as w,InMemoryCache as V}from"@apollo/client";import{SetContextLink as W}from"@apollo/client/link/context";import{GraphQLWsLink as F}from"@apollo/client/link/subscriptions";import{OperationTypeNode as N}from"graphql";import{createClient as j}from"graphql-ws";var A=e=>{let t=new w({uri:e.url,fetch:e.fetch,headers:e.headers}),r=async s=>{let n=await e.getAuthToken();return{headers:{...s,Authorization:`Bearer ${n}`}}},_=new F(j({url:e.url,connectionParams:()=>r(e.headers)})),a=new W(({headers:s})=>r(s)),o=U.split(({operationType:s})=>s===N.SUBSCRIPTION,_,a.concat(t));return new R({link:o,cache:new V})};var B={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},arguments:[{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},C={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]};var c=class{_options;constructor(t){this._options=t}info(){return this._options.client.query({query:v,variables:{projectId:this._options.projectId}}).then(t=>{if(!t.data?.get_project_info)throw new Error(t.error?.message||"Project not found");return t.data.get_project_info})}};import{map as q,takeWhile as z}from"rxjs/operators";var l=class{_options;constructor(t){this._options=t}list(t){return this._options.client.query({query:O,variables:{...t,limit:t.limit&&t.limit>0?t.limit:10},fetchPolicy:"no-cache"}).then(r=>r.data?.threads_v2??[])}get(t){if(!t)throw new Error("threadId is required");return this._options.client.query({query:C,variables:{id:t},fetchPolicy:"no-cache"}).then(r=>r.data?.threads_v2_by_pk)}start(t){if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:k,variables:{...t,projectId:this._options.projectId,buildId:t.buildId||this._options.buildId,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.start_thread)throw new Error(r.error?.message||"Failed to start thread");return r.data.start_thread})}sendMessage(t){if(!t.threadId)throw new Error("threadId is required");if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:B,variables:{...t,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.send_thread_message)throw new Error(r.error?.message||"Failed to continue thread");return r.data.send_thread_message})}subscribeEvents(t,r){if(!t)throw new Error("threadId is required");if(r!=null)try{Number.parseInt(r)}catch{throw new Error("invalid threadEventId")}let _={thread_id:{_eq:t}};return r&&(_.thread_event_id={_gte:r}),this._options.client.subscribe({query:T,variables:{where:_}}).pipe(q(a=>{if(a.error)throw a.error;return a.data?.thread_events??[]}))}streamEvents(t,r){return this.subscribeEvents(t,r).pipe(z(_=>{for(let a=_.length-1;a>0;a--){let o=_[a];if("AgentMessage"in o.event_data&&"InteractionFinished"in o.event_data.AgentMessage.update)return!1}return!0},!0))}};var E=class{constructor(t){let r=d(t.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!t.projectId)throw new Error("projectId must not be empty. You can find it in Project Settings > General Settings tab on https://promptql.console.hasura.io.");if(!t.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=r.endsWith("/v1/graphql")?r:`${r}/playground-v2-hge/v1/graphql`,a=x({promptqlGraphQLUrl:_,authHost:t.authHost,projectId:t.projectId,serviceAccountToken:t.serviceAccountToken,fetch:t.fetch});this._options={projectId:t.projectId,buildId:t.buildId,client:A({getAuthToken:a,url:_,fetch:t.fetch,headers:t.headers}),defaultTimezone:t.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new l(this._options),this.project=new c(this._options)}_options;thread;project};function be(e,t){if(!t.length)return[];if(!e.length)return t;let r=e[e.length-1];if(!r)return t;let _=BigInt(r.thread_event_id),a=t.length-1;for(;a>=0;a--){let o=t[a];if(BigInt(o?.thread_event_id)<=_)break}return t.slice(a+1)}function Ie(e){return"UserMessage"in e?e.UserMessage:null}function Me(e){return"UserCancel"in e?e.UserCancel:null}function Se(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanGenerationStarted"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function ge(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanStepGenerated"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanStepGenerated}function he(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("GeneratedResponse"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse}function fe(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("ProcessingStarted"in e.AgentMessage.update.MessageProcessingUpdate.update)?null:e.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function xe(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function Ae(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function m(e){return!("AgentMessage"in e)||!("PlanningDecisionUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.PlanningDecisionUpdate.update}function Be(e){let t=m(e);return!t||!("Started"in t)?null:t.Started}function ke(e){let t=m(e);return!t||!("Completed"in t)?null:t.Completed}function ve(e){let t=m(e);return!t||!("PlanningRequired"in t)?null:t.PlanningRequired}function Oe(e){return!("AgentMessage"in e)||!("StartingOrchestrator"in e.AgentMessage.update)?null:e.AgentMessage.update.StartingOrchestrator}function P(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.OrchestratorUpdate.update}function y(e){let t=P(e);return!t||!("ContextExplorerUpdate"in t)?null:t.ContextExplorerUpdate.update}function Ce(e){let t=y(e);return!t||!("Started"in t)?null:t.Started}function Te(e){let t=y(e);return!t||!("Completed"in t)?null:t.Completed}function b(e){let t=y(e);return!t||!("WikiExplorerUpdate"in t)?null:t.WikiExplorerUpdate.update}function Ee(e){let t=b(e);return!t||!("Started"in t)?null:t.Started}function Pe(e){let t=b(e);return!t||!("Completed"in t)?null:t.Completed}function Re(e){let t=b(e);return!t||!("WikiInfoGenerated"in t)?null:t.WikiInfoGenerated}function I(e){let t=y(e);return!t||!("SchemaTasksGenerationUpdate"in t)?null:t.SchemaTasksGenerationUpdate.update}function Ue(e){let t=I(e);return!t||!("Started"in t)?null:t.Started}function we(e){let t=I(e);return!t||!("Completed"in t)?null:t.Completed}function Ve(e){let t=I(e);return!t||!("TasksGenerated"in t)?null:t.TasksGenerated}function u(e){let t=y(e);return!t||!("SchemaExplorerUpdate"in t)?null:t.SchemaExplorerUpdate.update}function We(e){let t=u(e);return!t||!("Started"in t)?null:t.Started}function Fe(e){let t=u(e);return!t||!("Completed"in t)?null:t.Completed}function Ne(e){let t=u(e);return!t||!("CodeExecutionComplete"in t)?null:t.CodeExecutionComplete}function je(e){let t=u(e);return!t||!("CodeOutputAnalyzed"in t)?null:t.CodeOutputAnalyzed}function qe(e){let t=u(e);return!t||!("GeneratedCode"in t)?null:t.GeneratedCode}function ze(e){let t=u(e);return!t||!("SchemaExplored"in t)?null:t.SchemaExplored}function M(e){let t=P(e);return!t||!("StepUpdate"in t)?null:t.StepUpdate}function Ge(e){let t=M(e);return!t||!("Programmer"in t.update)?null:t.update.Programmer}function De(e){let t=M(e);return!t||!("UiProgrammer"in t.update)?null:t.update.UiProgrammer}function Qe(e){let t=M(e);return!t||!("SavedProgramRunner"in t.update)?null:t.update.SavedProgramRunner}export{E as PromptQLSdk,A as createApolloClient,x as createPromptQLAuthTokenGenerator,be as diffThreadEvents,he as getAgentGeneratedResponse,xe as getAgentInteractionDecisionAcceptInteractionEvent,Ae as getAgentInteractionDecisionDeclineInteractionEvent,fe as getAgentMessageProcessingStartedEvent,Te as getAgentOrchestratorContextExplorerCompletedEvent,Ce as getAgentOrchestratorContextExplorerStartedEvent,y as getAgentOrchestratorContextExplorerUpdateEvent,Ne as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,je as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,Fe as getAgentOrchestratorSchemaExplorerCompletedEvent,qe as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,ze as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,We as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,Ve as getAgentOrchestratorSchemaTasksGeneratedEvent,we as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Ue as getAgentOrchestratorSchemaTasksGenerationStartedEvent,I as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Ge as getAgentOrchestratorStepProgrammerEvent,Qe as getAgentOrchestratorStepSavedProgramRunnerEvent,De as getAgentOrchestratorStepUiProgrammerEvent,M as getAgentOrchestratorStepUpdateEvent,P as getAgentOrchestratorUpdateEvent,Pe as getAgentOrchestratorWikiExplorerCompletedEvent,Ee as getAgentOrchestratorWikiExplorerStartedEvent,b as getAgentOrchestratorWikiExplorerUpdateEvent,Re as getAgentOrchestratorWikiInfoGeneratedEvent,Se as getAgentPlanGenerationStartedEvent,ge as getAgentPlanStepGeneratedEvent,ke as getAgentPlanningDecisionCompletedEvent,ve as getAgentPlanningDecisionPlanningRequiredEvent,Be as getAgentPlanningDecisionStartedEvent,m as getAgentPlanningDecisionUpdateEvent,Oe as getAgentStartingOrchestratorEvent,Me as getUserCancelEvent,Ie as getUserMessageEvent,f as isEnrichTokenMutationResponse,g as isLuxAuthPromptQLTokenFailedResponse,h as isLuxAuthPromptQLTokenSuccessResponse};
1
+ function y(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function h(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function f(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function x(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function A(e){let a=`${y(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,r={token:"",expiry:new Date(0)},_=e.fetch||fetch,o=async()=>{let n=await _(a,{method:"POST",headers:{Authorization:`pat ${e.serviceAccountToken}`}});switch(n.status){case 200:{let i=await n.json();if(f(i))return i;throw new Error("malformed token response")}case 401:{let i=await n.json();throw h(i)?new Error(i?.error||n.statusText):new Error(n.statusText)}default:{let i=await n.text();throw new Error(i)}}},u=async n=>{let i=await _(e.promptqlGraphQLUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!) { enrich_token(luxJWT: $luxJWT) { userDirectoryJWT }}",variables:{luxJWT:n.token},operationName:"EnrichToken"})});switch(i.status){case 200:{let p=await i.json();if(!x(p)||!p.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(p)}`);return p.data.enrich_token.userDirectoryJWT}default:{let p=await i.text();throw new Error(p)}}};return async()=>{if(r.expiry.getTime()<=Date.now()-1e3){let n=await o(),i=await u(n);r.token=i;let p=new Date(n.expiry);if(Number.isNaN(p.getTime())){let g=new Date;g.setHours(1),r.expiry=g}else r.expiry=p}return r.token}}import{ApolloClient as U,ApolloLink as w,HttpLink as F,InMemoryCache as V}from"@apollo/client";import{SetContextLink as W}from"@apollo/client/link/context";import{GraphQLWsLink as N}from"@apollo/client/link/subscriptions";import{OperationTypeNode as j}from"graphql";import{createClient as q}from"graphql-ws";var B=e=>{let t=new F({uri:e.url,fetch:e.fetch,headers:e.headers}),a=async u=>{let n=await e.getAuthToken();return{headers:{...u,Authorization:`Bearer ${n}`}}},r=new N(q({url:e.url,connectionParams:()=>a(e.headers)})),_=new W(({headers:u})=>a(u)),o=w.split(({operationType:u})=>u===j.SUBSCRIPTION,r,_.concat(t));return new U({link:o,cache:new V})};var k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},C={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},E={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]};var c=class{_options;constructor(t){this._options=t}info(){return b(this._options.client)}};function b(e){return e.query({query:v,fetchPolicy:"cache-first"}).then(t=>{if(!t.data?.get_project_info)throw new Error(t.error?.message||"Project not found");return t.data.get_project_info})}import{map as z,takeWhile as G}from"rxjs/operators";var l=class{_options;constructor(t){this._options=t}list(t){return this._options.client.query({query:C,variables:{...t,limit:t.limit&&t.limit>0?t.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}get(t){if(!t)throw new Error("threadId is required");return this._options.client.query({query:T,variables:{id:t},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}async start(t){if(!t.message.trim())throw new Error("message must not be empty");let a=await b(this._options.client);return this._options.client.mutate({mutation:O,variables:{...t,projectId:a.projectId,buildId:t.buildId||this._options.buildId,timezone:t.timezone||this._options.defaultTimezone}}).then(r=>{if(!r.data?.start_thread)throw new Error(r.error?.message||"Failed to start thread");return r.data.start_thread})}sendMessage(t){if(!t.threadId)throw new Error("threadId is required");if(!t.message.trim())throw new Error("message must not be empty");return this._options.client.mutate({mutation:k,variables:{...t,timezone:t.timezone||this._options.defaultTimezone}}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to continue thread");return a.data.send_thread_message})}subscribeEvents(t,a){if(!t)throw new Error("threadId is required");if(a!=null)try{Number.parseInt(a)}catch{throw new Error("invalid threadEventId")}let r={thread_id:{_eq:t}};return a&&(r.thread_event_id={_gte:a}),this._options.client.subscribe({query:E,variables:{where:r}}).pipe(z(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}streamEvents(t,a){return this.subscribeEvents(t,a).pipe(G(r=>{for(let _=r.length-1;_>0;_--){let o=r[_];if("AgentMessage"in o.event_data&&"InteractionFinished"in o.event_data.AgentMessage.update)return!1}return!0},!0))}};var P=class{constructor(t){let a=y(t.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!t.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let r=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`,_=A({promptqlGraphQLUrl:r,authHost:t.authHost,serviceAccountToken:t.serviceAccountToken,fetch:t.fetch});this._options={buildId:t.buildId,client:B({getAuthToken:_,url:r,fetch:t.fetch,headers:t.headers}),defaultTimezone:t.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new l(this._options),this.project=new c(this._options)}_options;thread;project};function Me(e,t){if(!t.length)return[];if(!e.length)return t;let a=e[e.length-1];if(!a)return t;let r=BigInt(a.thread_event_id),_=t.length-1;for(;_>=0;_--){let o=t[_];if(BigInt(o?.thread_event_id)<=r)break}return t.slice(_+1)}function Se(e){return"UserMessage"in e?e.UserMessage:null}function ge(e){return"UserCancel"in e?e.UserCancel:null}function he(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanGenerationStarted"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function fe(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("PlanStepGenerated"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.PlanStepGenerated}function xe(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)||!("GeneratedResponse"in e.AgentMessage.update.OrchestratorUpdate.update)?null:e.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse}function Ae(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("ProcessingStarted"in e.AgentMessage.update.MessageProcessingUpdate.update)?null:e.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Be(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function ke(e){return!("AgentMessage"in e)||!("MessageProcessingUpdate"in e.AgentMessage.update)||!("InteractionDecision"in e.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:e.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function m(e){return!("AgentMessage"in e)||!("PlanningDecisionUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.PlanningDecisionUpdate.update}function Oe(e){let t=m(e);return!t||!("Started"in t)?null:t.Started}function ve(e){let t=m(e);return!t||!("Completed"in t)?null:t.Completed}function Ce(e){let t=m(e);return!t||!("PlanningRequired"in t)?null:t.PlanningRequired}function Te(e){return!("AgentMessage"in e)||!("StartingOrchestrator"in e.AgentMessage.update)?null:e.AgentMessage.update.StartingOrchestrator}function R(e){return!("AgentMessage"in e)||!("OrchestratorUpdate"in e.AgentMessage.update)?null:e.AgentMessage.update.OrchestratorUpdate.update}function d(e){let t=R(e);return!t||!("ContextExplorerUpdate"in t)?null:t.ContextExplorerUpdate.update}function Ee(e){let t=d(e);return!t||!("Started"in t)?null:t.Started}function Pe(e){let t=d(e);return!t||!("Completed"in t)?null:t.Completed}function I(e){let t=d(e);return!t||!("WikiExplorerUpdate"in t)?null:t.WikiExplorerUpdate.update}function Re(e){let t=I(e);return!t||!("Started"in t)?null:t.Started}function Ue(e){let t=I(e);return!t||!("Completed"in t)?null:t.Completed}function we(e){let t=I(e);return!t||!("WikiInfoGenerated"in t)?null:t.WikiInfoGenerated}function M(e){let t=d(e);return!t||!("SchemaTasksGenerationUpdate"in t)?null:t.SchemaTasksGenerationUpdate.update}function Fe(e){let t=M(e);return!t||!("Started"in t)?null:t.Started}function Ve(e){let t=M(e);return!t||!("Completed"in t)?null:t.Completed}function We(e){let t=M(e);return!t||!("TasksGenerated"in t)?null:t.TasksGenerated}function s(e){let t=d(e);return!t||!("SchemaExplorerUpdate"in t)?null:t.SchemaExplorerUpdate.update}function Ne(e){let t=s(e);return!t||!("Started"in t)?null:t.Started}function je(e){let t=s(e);return!t||!("Completed"in t)?null:t.Completed}function qe(e){let t=s(e);return!t||!("CodeExecutionComplete"in t)?null:t.CodeExecutionComplete}function ze(e){let t=s(e);return!t||!("CodeOutputAnalyzed"in t)?null:t.CodeOutputAnalyzed}function Ge(e){let t=s(e);return!t||!("GeneratedCode"in t)?null:t.GeneratedCode}function De(e){let t=s(e);return!t||!("SchemaExplored"in t)?null:t.SchemaExplored}function S(e){let t=R(e);return!t||!("StepUpdate"in t)?null:t.StepUpdate}function Qe(e){let t=S(e);return!t||!("Programmer"in t.update)?null:t.update.Programmer}function Ke(e){let t=S(e);return!t||!("UiProgrammer"in t.update)?null:t.update.UiProgrammer}function He(e){let t=S(e);return!t||!("SavedProgramRunner"in t.update)?null:t.update.SavedProgramRunner}export{P as PromptQLSdk,B as createApolloClient,A as createPromptQLAuthTokenGenerator,Me as diffThreadEvents,xe as getAgentGeneratedResponse,Be as getAgentInteractionDecisionAcceptInteractionEvent,ke as getAgentInteractionDecisionDeclineInteractionEvent,Ae as getAgentMessageProcessingStartedEvent,Pe as getAgentOrchestratorContextExplorerCompletedEvent,Ee as getAgentOrchestratorContextExplorerStartedEvent,d as getAgentOrchestratorContextExplorerUpdateEvent,qe as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,ze as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,je as getAgentOrchestratorSchemaExplorerCompletedEvent,Ge as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,De as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Ne as getAgentOrchestratorSchemaExplorerStartedEvent,s as getAgentOrchestratorSchemaExplorerUpdateEvent,We as getAgentOrchestratorSchemaTasksGeneratedEvent,Ve as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Fe as getAgentOrchestratorSchemaTasksGenerationStartedEvent,M as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Qe as getAgentOrchestratorStepProgrammerEvent,He as getAgentOrchestratorStepSavedProgramRunnerEvent,Ke as getAgentOrchestratorStepUiProgrammerEvent,S as getAgentOrchestratorStepUpdateEvent,R as getAgentOrchestratorUpdateEvent,Ue as getAgentOrchestratorWikiExplorerCompletedEvent,Re as getAgentOrchestratorWikiExplorerStartedEvent,I as getAgentOrchestratorWikiExplorerUpdateEvent,we as getAgentOrchestratorWikiInfoGeneratedEvent,he as getAgentPlanGenerationStartedEvent,fe as getAgentPlanStepGeneratedEvent,ve as getAgentPlanningDecisionCompletedEvent,Ce as getAgentPlanningDecisionPlanningRequiredEvent,Oe as getAgentPlanningDecisionStartedEvent,m as getAgentPlanningDecisionUpdateEvent,Te as getAgentStartingOrchestratorEvent,ge as getUserCancelEvent,Se as getUserMessageEvent,x as isEnrichTokenMutationResponse,h as isLuxAuthPromptQLTokenFailedResponse,f as isLuxAuthPromptQLTokenSuccessResponse};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hasura/promptql",
3
3
  "description": "A Typescript SDK allows you to interact with PromptQL API",
4
- "version": "2.0.0-alpha.3",
4
+ "version": "2.0.0-alpha.5",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hasura",
7
7
  "homepage": "https://promptql.hasura.io",
@@ -29,8 +29,6 @@
29
29
  "check-types": "tsc --noEmit"
30
30
  },
31
31
  "devDependencies": {
32
- "@hasura/biome-config": "workspace:*",
33
- "@hasura/typescript-config": "workspace:*",
34
32
  "@types/bun": "latest",
35
33
  "@types/node": "^25.1.0",
36
34
  "tsup": "^8.5.1",
package/tsconfig.json CHANGED
@@ -1,8 +1,29 @@
1
1
  {
2
- "extends": "@hasura/typescript-config/base.json",
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "esModuleInterop": true,
7
+ "incremental": false,
8
+ "isolatedModules": true,
9
+ "lib": [
10
+ "es2022"
11
+ ],
12
+ "module": "NodeNext",
13
+ "moduleDetection": "force",
14
+ "moduleResolution": "NodeNext",
15
+ "noUncheckedIndexedAccess": true,
16
+ "resolveJsonModule": true,
17
+ "skipLibCheck": true,
18
+ "strict": true,
19
+ "target": "ES2022",
4
20
  "outDir": "dist"
5
21
  },
6
- "include": ["src"],
7
- "exclude": ["node_modules", "dist"]
8
- }
22
+ "include": [
23
+ "src"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "dist"
28
+ ]
29
+ }