@kadoa/node-sdk 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4419,19 +4419,41 @@ var ExtractionService = class {
4419
4419
  );
4420
4420
  }
4421
4421
  let workflowId;
4422
- const resolvedEntity = await this.entityResolverService.resolveEntity(
4423
- options.entity || "ai-detection",
4424
- {
4425
- link: config.urls[0],
4426
- location: config.location,
4427
- navigationMode: config.navigationMode
4422
+ const isAgenticNavigation = config.navigationMode === "agentic-navigation";
4423
+ if (isAgenticNavigation) {
4424
+ if (!config.userPrompt) {
4425
+ throw new KadoaSdkException(
4426
+ "userPrompt is required when navigationMode is 'agentic-navigation'",
4427
+ {
4428
+ code: "VALIDATION_ERROR",
4429
+ details: { navigationMode: config.navigationMode }
4430
+ }
4431
+ );
4428
4432
  }
4429
- );
4433
+ }
4434
+ let resolvedEntity;
4435
+ if (isAgenticNavigation) {
4436
+ const entityConfig = options.entity || "ai-detection";
4437
+ resolvedEntity = {
4438
+ entity: typeof entityConfig === "object" && "name" in entityConfig ? entityConfig.name : void 0,
4439
+ fields: typeof entityConfig === "object" && "fields" in entityConfig ? entityConfig.fields : []
4440
+ };
4441
+ } else {
4442
+ resolvedEntity = await this.entityResolverService.resolveEntity(
4443
+ options.entity || "ai-detection",
4444
+ {
4445
+ link: config.urls[0],
4446
+ location: config.location,
4447
+ navigationMode: config.navigationMode
4448
+ }
4449
+ );
4450
+ }
4430
4451
  const hasNotifications = !!config.notifications;
4431
4452
  const workflowRequest = {
4432
4453
  ...config,
4433
4454
  fields: resolvedEntity.fields,
4434
- ...resolvedEntity.entity !== void 0 ? { entity: resolvedEntity.entity } : {}
4455
+ ...resolvedEntity.entity !== void 0 ? { entity: resolvedEntity.entity } : {},
4456
+ ...config.userPrompt ? { userPrompt: config.userPrompt } : {}
4435
4457
  };
4436
4458
  const result = await this.workflowsCoreService.create(workflowRequest);
4437
4459
  workflowId = result.id;
@@ -4619,20 +4641,46 @@ var ExtractionBuilderService = class {
4619
4641
  this._options.location = options;
4620
4642
  return this;
4621
4643
  }
4644
+ withPrompt(prompt) {
4645
+ assert(this._options, "Options are not set");
4646
+ this._userPrompt = prompt;
4647
+ this._options.userPrompt = prompt;
4648
+ return this;
4649
+ }
4622
4650
  async create() {
4623
4651
  assert(this._options, "Options are not set");
4624
4652
  const { urls, name, description, navigationMode, entity } = this.options;
4653
+ const isAgenticNavigation = navigationMode === "agentic-navigation";
4654
+ if (isAgenticNavigation) {
4655
+ if (!this._userPrompt) {
4656
+ throw new KadoaSdkException(
4657
+ "userPrompt is required when navigationMode is 'agentic-navigation'",
4658
+ {
4659
+ code: "VALIDATION_ERROR",
4660
+ details: { navigationMode }
4661
+ }
4662
+ );
4663
+ }
4664
+ }
4625
4665
  const isRealTime = this._options.interval === "REAL_TIME";
4626
4666
  const useSelectorMode = isRealTime && entity === "ai-detection";
4627
- const resolvedEntity = await this.entityResolverService.resolveEntity(
4628
- entity,
4629
- {
4630
- link: urls[0],
4631
- location: this._options.location,
4632
- navigationMode,
4633
- selectorMode: useSelectorMode
4634
- }
4635
- );
4667
+ let resolvedEntity;
4668
+ if (isAgenticNavigation) {
4669
+ resolvedEntity = {
4670
+ entity: typeof entity === "object" && "name" in entity ? entity.name : void 0,
4671
+ fields: typeof entity === "object" && "fields" in entity ? entity.fields : []
4672
+ };
4673
+ } else {
4674
+ resolvedEntity = await this.entityResolverService.resolveEntity(
4675
+ entity,
4676
+ {
4677
+ link: urls[0],
4678
+ location: this._options.location,
4679
+ navigationMode,
4680
+ selectorMode: useSelectorMode
4681
+ }
4682
+ );
4683
+ }
4636
4684
  const workflow = await this.workflowsCoreService.create({
4637
4685
  urls,
4638
4686
  name,
@@ -4646,7 +4694,8 @@ var ExtractionBuilderService = class {
4646
4694
  interval: this._options.interval,
4647
4695
  schedules: this._options.schedules,
4648
4696
  additionalData: this._options.additionalData,
4649
- bypassPreview: this._options.bypassPreview
4697
+ bypassPreview: this._options.bypassPreview,
4698
+ userPrompt: this._userPrompt
4650
4699
  });
4651
4700
  if (this._notificationOptions) {
4652
4701
  await this.notificationSetupService.setup({
@@ -5170,7 +5219,7 @@ var WSS_API_URI = process.env.KADOA_WSS_API_URI ?? "wss://realtime.kadoa.com";
5170
5219
  var REALTIME_API_URI = process.env.KADOA_REALTIME_API_URI ?? "https://realtime.kadoa.com";
5171
5220
 
5172
5221
  // src/version.ts
5173
- var SDK_VERSION = "0.18.1";
5222
+ var SDK_VERSION = "0.19.0";
5174
5223
  var SDK_NAME = "kadoa-node-sdk";
5175
5224
  var SDK_LANGUAGE = "node";
5176
5225
 
@@ -5775,6 +5824,48 @@ var WorkflowsCoreService = class {
5775
5824
  async create(input) {
5776
5825
  validateAdditionalData(input.additionalData);
5777
5826
  const domainName = new URL(input.urls[0]).hostname;
5827
+ if (input.navigationMode === "agentic-navigation") {
5828
+ if (!input.userPrompt) {
5829
+ throw new KadoaSdkException(
5830
+ "userPrompt is required when navigationMode is 'agentic-navigation'",
5831
+ {
5832
+ code: "VALIDATION_ERROR",
5833
+ details: { navigationMode: input.navigationMode }
5834
+ }
5835
+ );
5836
+ }
5837
+ const agenticRequest = {
5838
+ urls: input.urls,
5839
+ navigationMode: "agentic-navigation",
5840
+ name: input.name ?? domainName,
5841
+ description: input.description,
5842
+ userPrompt: input.userPrompt,
5843
+ schemaId: input.schemaId,
5844
+ entity: input.entity,
5845
+ fields: input.fields,
5846
+ bypassPreview: input.bypassPreview ?? true,
5847
+ tags: input.tags,
5848
+ interval: input.interval,
5849
+ monitoring: input.monitoring,
5850
+ location: input.location,
5851
+ autoStart: input.autoStart,
5852
+ schedules: input.schedules,
5853
+ additionalData: input.additionalData
5854
+ };
5855
+ const response2 = await this.workflowsApi.v4WorkflowsPost({
5856
+ createWorkflowBody: agenticRequest
5857
+ });
5858
+ const workflowId2 = response2.data?.workflowId;
5859
+ if (!workflowId2) {
5860
+ throw new KadoaSdkException(ERROR_MESSAGES.NO_WORKFLOW_ID, {
5861
+ code: "INTERNAL_ERROR",
5862
+ details: {
5863
+ response: response2.data
5864
+ }
5865
+ });
5866
+ }
5867
+ return { id: workflowId2 };
5868
+ }
5778
5869
  const request = {
5779
5870
  urls: input.urls,
5780
5871
  name: input.name ?? domainName,