@uniformdev/automations-sdk 20.72.3-alpha.25 → 20.72.3-alpha.45

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.
@@ -393,6 +393,8 @@ interface paths {
393
393
  query: {
394
394
  /** @description The project ID. */
395
395
  projectId: string;
396
+ /** @description Comma-separated list of automation public IDs to return. Omit to return all. */
397
+ automationIDs?: string;
396
398
  };
397
399
  header?: never;
398
400
  path?: never;
@@ -415,6 +417,13 @@ interface paths {
415
417
  name: string;
416
418
  /** @description Optional description. */
417
419
  description: string | null;
420
+ /**
421
+ * @description How the automation behaves: a bundled TypeScript handler, or Scout instructions.
422
+ * @enum {string}
423
+ */
424
+ kind: "typescript" | "scout";
425
+ /** @description The stored instructions for a `scout` automation; null for any other kind. */
426
+ instructions: string | null;
418
427
  /** @description The triggers this automation subscribes to. */
419
428
  triggers: {
420
429
  /** @description How the automation is triggered. */
@@ -490,6 +499,8 @@ interface paths {
490
499
  * @deprecated
491
500
  * @description Deploys (creates or updates) an automation.
492
501
  *
502
+ * Set `kind` to `typescript` to deploy a bundled handler module, or to `scout` to have the automation run the Scout agent against stored natural-language instructions on each trigger.
503
+ *
493
504
  * This is experimental functionality that is subject to change without notice.
494
505
  */
495
506
  put: {
@@ -548,10 +559,69 @@ interface paths {
548
559
  [key: string]: string | string[];
549
560
  };
550
561
  };
562
+ /**
563
+ * @description Runs a bundled TypeScript handler module.
564
+ * @enum {string}
565
+ */
566
+ kind: "typescript";
551
567
  /** @description Bundled JavaScript module for the automation handler. */
552
568
  code: string;
553
569
  /** @description Target date for runtime compatibility. Runtime changes after this date may not apply to this automation. */
554
570
  compatibilityDate?: string;
571
+ } | {
572
+ /** @description The project ID. */
573
+ projectId: string;
574
+ /** @description Stable public identifier for the automation. */
575
+ publicId: string;
576
+ /** @description Display name of the automation. */
577
+ name: string;
578
+ /** @description For automations triggered as an AI tool, this is used to determine when an LLM should call the automation. For other triggers, this is for your reference and optional. */
579
+ description?: string;
580
+ /** @description The triggers this automation subscribes to. */
581
+ triggers: ({
582
+ /**
583
+ * @description The internal webhook event name that triggers this automation.
584
+ * @enum {string}
585
+ */
586
+ type: "asset.deleted" | "asset.published" | "composition.changed" | "composition.deleted" | "composition.published" | "composition.release.changed" | "composition.release.deleted" | "composition.release.published" | "composition.release.restored" | "entry.changed" | "entry.deleted" | "entry.published" | "entry.release.changed" | "entry.release.deleted" | "entry.release.published" | "entry.release.restored" | "manifest.published" | "notification.created" | "projectmap.delete" | "projectmap.node.delete" | "projectmap.node.insert" | "projectmap.node.update" | "projectmap.update" | "redirect.delete" | "redirect.insert" | "redirect.update" | "release.changed" | "release.deleted" | "release.launch_started" | "release.launched" | "workflow.transition";
587
+ /** @description Optional CEL boolean expression evaluated against { input, trigger }; the automation runs only when it is true. */
588
+ filter?: string;
589
+ } | {
590
+ /** @enum {string} */
591
+ type: "schedule";
592
+ /** @description RFC 5545 recurrence rule for when the automation runs. */
593
+ rrule: string;
594
+ /** @description IANA timezone used to evaluate the recurrence rule. */
595
+ timezone: string;
596
+ } | {
597
+ /** @enum {string} */
598
+ type: "incomingWebhook";
599
+ /** @description Optional CEL boolean expression evaluated against { input, trigger }; the automation runs only when it is true. */
600
+ filter?: string;
601
+ } | {
602
+ /** @enum {string} */
603
+ type: "aiTool";
604
+ /** @description JSON Schema describing the AI tool arguments. */
605
+ inputSchema: {
606
+ [key: string]: unknown;
607
+ };
608
+ })[];
609
+ /** @description Role grants for the automation identity. The caller must hold each requested role (or be a team admin). Required: a Scout automation acts solely through its machine identity, so without a role grant it has no authority to act. */
610
+ permissions: {
611
+ /** @description Role grant(s) on the project the automation is deployed to. */
612
+ role: string | string[];
613
+ /** @description Additional project role grants keyed by project ID for cross-project access within the same team. */
614
+ projects?: {
615
+ [key: string]: string | string[];
616
+ };
617
+ };
618
+ /**
619
+ * @description Runs the Scout agent headlessly against stored instructions.
620
+ * @enum {string}
621
+ */
622
+ kind: "scout";
623
+ /** @description The instructions Scout runs on each trigger. */
624
+ instructions: string;
555
625
  };
556
626
  };
557
627
  };
@@ -747,8 +817,21 @@ type AutomationSummary = AutomationsListResponse['automations'][number];
747
817
  type AutomationTrigger = AutomationSummary['triggers'][number];
748
818
  type AutomationTriggerType = AutomationTrigger['config']['type'];
749
819
  type AutomationsDeployBody = paths['/api/v1/automations']['put']['requestBody']['content']['application/json'];
820
+ /**
821
+ * `Omit` over each member of a union separately, so the `kind` discriminant still narrows the
822
+ * result. Plain `Omit` would flatten the union into one object type and lose that.
823
+ */
824
+ type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;
750
825
  /** Deploy input without the project ID, which the client injects from its options. */
751
- type AutomationsDeployInput = Omit<AutomationsDeployBody, 'projectId'>;
826
+ type AutomationsDeployInput = DistributiveOmit<AutomationsDeployBody, 'projectId'>;
827
+ /** The `typescript` member of the deploy input — an automation with a bundled handler module. */
828
+ type TypeScriptAutomationDeployInput = Extract<AutomationsDeployInput, {
829
+ kind: 'typescript';
830
+ }>;
831
+ /** The `scout` member of the deploy input — an automation Scout runs from stored instructions. */
832
+ type ScoutAutomationDeployInput = Extract<AutomationsDeployInput, {
833
+ kind: 'scout';
834
+ }>;
752
835
  type AutomationRunsListResponse = paths$1['/api/v1/automation-runs']['get']['responses']['200']['content']['application/json'];
753
836
  type AutomationRunSummary = AutomationRunsListResponse['runs'][number];
754
837
  type AutomationRunStatus = AutomationRunSummary['status'];
@@ -764,14 +847,19 @@ type AutomationsClientOptions = Omit<ClientOptions, 'projectId'> & {
764
847
  */
765
848
  declare class AutomationsClient extends ApiClient<AutomationsClientOptions> {
766
849
  #private;
850
+ /**
851
+ * Fetches a single automation by public ID.
852
+ *
853
+ * @param publicId - The automation public ID.
854
+ * @throws ApiClientError with status 404 when no such automation exists.
855
+ */
856
+ get(publicId: string): Promise<AutomationSummary>;
767
857
  /**
768
858
  * Lists the automations configured for a project.
769
859
  */
770
860
  list(): Promise<AutomationsListResponse>;
771
861
  /**
772
862
  * Deploys (creates or updates) a single automation.
773
- *
774
- * @param input - The automation definition + bundled code.
775
863
  */
776
864
  deploy(input: AutomationsDeployInput): Promise<void>;
777
865
  /**
@@ -813,4 +901,4 @@ declare class AutomationsClient extends ApiClient<AutomationsClientOptions> {
813
901
  listRunLogs(runId: string): Promise<AutomationRunLogEntry[]>;
814
902
  }
815
903
 
816
- export { type AutomationRunLogEntry, type AutomationRunStatus, type AutomationRunSummary, type AutomationRunTriggerResponse, type AutomationRunsListResponse, type AutomationSummary, type AutomationTrigger, type AutomationTriggerType, AutomationsClient, type AutomationsClientOptions, type AutomationsDeployBody, type AutomationsDeployInput, type AutomationsListResponse };
904
+ export { type AutomationRunLogEntry, type AutomationRunStatus, type AutomationRunSummary, type AutomationRunTriggerResponse, type AutomationRunsListResponse, type AutomationSummary, type AutomationTrigger, type AutomationTriggerType, AutomationsClient, type AutomationsClientOptions, type AutomationsDeployBody, type AutomationsDeployInput, type AutomationsListResponse, type ScoutAutomationDeployInput, type TypeScriptAutomationDeployInput };
@@ -7,9 +7,28 @@ import {
7
7
  } from "../chunk-I6KKUHEY.mjs";
8
8
 
9
9
  // src/api/AutomationsClient.ts
10
- import { ApiClient } from "@uniformdev/context/api";
10
+ import { ApiClient, ApiClientError } from "@uniformdev/context/api";
11
11
  var _automationsUrl, _runsUrl, _logsUrl;
12
12
  var _AutomationsClient = class _AutomationsClient extends ApiClient {
13
+ /**
14
+ * Fetches a single automation by public ID.
15
+ *
16
+ * @param publicId - The automation public ID.
17
+ * @throws ApiClientError with status 404 when no such automation exists.
18
+ */
19
+ async get(publicId) {
20
+ const { projectId } = this.options;
21
+ const url = this.createUrl(__privateGet(_AutomationsClient, _automationsUrl), {
22
+ projectId,
23
+ automationIDs: [publicId]
24
+ });
25
+ const { automations } = await this.apiClient(url);
26
+ const automation = automations[0];
27
+ if (!automation) {
28
+ throw new ApiClientError("Automation not found", "GET", url.toString(), 404, "Not Found");
29
+ }
30
+ return automation;
31
+ }
13
32
  /**
14
33
  * Lists the automations configured for a project.
15
34
  */
@@ -21,8 +40,6 @@ var _AutomationsClient = class _AutomationsClient extends ApiClient {
21
40
  }
22
41
  /**
23
42
  * Deploys (creates or updates) a single automation.
24
- *
25
- * @param input - The automation definition + bundled code.
26
43
  */
27
44
  async deploy(input) {
28
45
  const { projectId } = this.options;
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { WebhookEventName, WebhookPayloadFor } from '@uniformdev/webhooks';
3
3
  import { AutomationResult, AutomationLogEntry } from './schemas/index.mjs';
4
4
  export { f as formatAutomationWebhookUrl } from './formatAutomationWebhookUrl-CD1HQmu6.mjs';
5
+ import { ApiClient, ClientOptions } from '@uniformdev/context/api';
5
6
  import 'zod';
6
7
 
7
8
  /**
@@ -74,6 +75,16 @@ type JsonSchemaObject = Record<string, unknown>;
74
75
  * Note: non-zod standard schema providers are not supported.
75
76
  */
76
77
  type AiToolInputSchema = StandardSchemaV1 | JsonSchemaObject;
78
+ /**
79
+ * Maximum length of a Scout automation's instructions, in UTF-16 code units (what `String.length`
80
+ * counts, and what the deploy API's `z.string().max()` measures).
81
+ *
82
+ * The instructions travel in the run's Cloudflare Queues message, which is hard-capped at 128 KB and
83
+ * already carries up to 64 KB of captured input plus credentials. 16 K is far more than authored
84
+ * instructions need and leaves the envelope with ample headroom. Like any ingress cap this can be
85
+ * raised later but never lowered.
86
+ */
87
+ declare const AUTOMATION_INSTRUCTIONS_MAX_LENGTH: number;
77
88
  /**
78
89
  * Role grants for the automation's identity.
79
90
  */
@@ -130,6 +141,28 @@ type AiToolAutomationMetadata = AutomationMetadataBase & {
130
141
  };
131
142
  /** Authored metadata declared via {@link defineAutomation}. */
132
143
  type AutomationMetadata = ComposedAutomationMetadata | AiToolAutomationMetadata;
144
+ /**
145
+ * Authored metadata for a Scout automation — one with no handler, whose behavior is the instructions
146
+ * the agent runs on each trigger.
147
+ *
148
+ * Two fields differ from a handler automation, both because the automation has no code of its own:
149
+ * - `permissions` is **required**. A Scout automation's only actions are the agent's tool calls, and
150
+ * every one of them acts as the automation's machine identity. With no role grant there is no
151
+ * identity, so the run has no authority to do anything at all.
152
+ * - there is no `compatibilityDate`. The runtime the agent runs on is Uniform's, not yours.
153
+ *
154
+ * `aiTool` is also absent from the trigger union: an `aiTool` automation *is* a tool the agent calls,
155
+ * so an agent-driven one would be circular.
156
+ */
157
+ type ScoutAutomationMetadata = {
158
+ /** Display name surfaced in the dashboard and run history. */
159
+ name: string;
160
+ description?: string;
161
+ /** One or more triggers this automation subscribes to. */
162
+ triggers: [ComposableTriggerConfig, ...ComposableTriggerConfig[]];
163
+ /** Role grants for the automation's identity. Required — see {@link ScoutAutomationMetadata}. */
164
+ permissions: AutomationPermissions;
165
+ };
133
166
 
134
167
  /**
135
168
  * Per-run Uniform API connection parameters.
@@ -331,6 +364,8 @@ type TriggersOf<M extends AutomationMetadata> = M extends {
331
364
  type HandlerFromAutomationMetadata<M extends AutomationMetadata> = AutomationHandler<InputFromAutomationMetadata<M>, TriggerFromAutomationMetadata<M>, CredentialsFromAutomationMetadata<M>>;
332
365
  /** A fully defined automation module: a callable invoke function with authored metadata attached. */
333
366
  type AutomationDefinition<M extends AutomationMetadata = AutomationMetadata> = AutomationInvoker & {
367
+ /** Discriminates a handler automation module from a Scout one (see `defineScoutAutomation`). */
368
+ kind: 'typescript';
334
369
  metadata: M;
335
370
  };
336
371
  /**
@@ -370,4 +405,411 @@ declare function defineAutomation<const M extends AutomationMetadata>(config: {
370
405
  handler: HandlerFromAutomationMetadata<M>;
371
406
  }): AutomationDefinition<M>;
372
407
 
373
- export { type AiToolAutomationMetadata, type AiToolInputSchema, type AiToolTriggerConfig, type AutomationContext, type AutomationDefinition, type AutomationHandler, type AutomationInvokePayload, type AutomationInvoker, AutomationLogEntry, type AutomationLogLevel, type AutomationLogger, type AutomationMetadata, type AutomationPermissions, AutomationResult, type ComposableTriggerConfig, type ComposedAutomationMetadata, type CredentialsFromAutomationMetadata, type EventTriggerConfig, type HandlerFromAutomationMetadata, type IncomingWebhookInput, type IncomingWebhookTriggerConfig, type InputFromAutomationMetadata, type JsonSchemaObject, type ScheduleRunInput, type ScheduleTriggerConfig, type TriggerConfig, type TriggerFromAutomationMetadata, type UniformConnectionParams, defineAutomation };
408
+ /**
409
+ * A fully defined Scout automation module: authored metadata plus the instructions the agent runs.
410
+ *
411
+ * Unlike {@link AutomationDefinition} this is *not* callable — a Scout automation has no local
412
+ * handler to invoke. The deploy API generates the runner from the instructions, so the module exists
413
+ * only to declare them.
414
+ */
415
+ type ScoutAutomationDefinition<M extends ScoutAutomationMetadata = ScoutAutomationMetadata> = {
416
+ /** Discriminates a Scout automation module from a handler one. */
417
+ kind: 'scout';
418
+ metadata: M;
419
+ /** The instructions the agent runs on each trigger. */
420
+ instructions: string;
421
+ };
422
+ /**
423
+ * Defines an automation that uses Scout to perform a task.
424
+ *
425
+ * @param metadata - Name, triggers, and the role grants the run acts under. `permissions` is required.
426
+ * @param instructions - What the agent should do on each trigger.
427
+ * @returns A default-exportable Scout automation definition.
428
+ */
429
+ declare function defineScoutAutomation<const M extends ScoutAutomationMetadata>(metadata: M, instructions: string): ScoutAutomationDefinition<M>;
430
+
431
+ interface paths {
432
+ "/api/v1/notifications": {
433
+ parameters: {
434
+ query?: never;
435
+ header?: never;
436
+ path?: never;
437
+ cookie?: never;
438
+ };
439
+ /**
440
+ * @deprecated
441
+ * @description Lists the current user's notifications. Results are cursor-paginated newest-first and may be scoped to the current team. Omit teamId to list every notification for the caller.
442
+ */
443
+ get: {
444
+ parameters: {
445
+ query?: {
446
+ /** @description Opaque cursor returned by the previous response. Omit to read the newest page of notifications. */
447
+ cursor?: string;
448
+ /** @description When true, only unread notifications are returned. */
449
+ unreadOnly?: boolean | null;
450
+ /** @description Optional team scope. Use teamId to limit results to one team. */
451
+ teamId?: string;
452
+ /** @description Maximum number of notifications to return. Defaults to 50. */
453
+ limit?: number;
454
+ };
455
+ header?: never;
456
+ path?: never;
457
+ cookie?: never;
458
+ };
459
+ requestBody?: never;
460
+ responses: {
461
+ /** @description OK */
462
+ 200: {
463
+ headers: {
464
+ [name: string]: unknown;
465
+ };
466
+ content: {
467
+ "application/json": {
468
+ notifications: {
469
+ id: string;
470
+ /**
471
+ * @description The notification content type. Currently, only text notifications are supported.
472
+ * @enum {string}
473
+ */
474
+ type: "text";
475
+ teamId: string;
476
+ project: {
477
+ id: string;
478
+ name: string;
479
+ } | null;
480
+ author: {
481
+ subject: string;
482
+ name: string;
483
+ } | null;
484
+ summary: {
485
+ /** @enum {string} */
486
+ format: "markdown";
487
+ value: string;
488
+ };
489
+ entity?: {
490
+ entityId: string;
491
+ /** @enum {string} */
492
+ type: "entry" | "composition";
493
+ releaseId?: string;
494
+ editionId?: string;
495
+ } | {
496
+ entityId: string;
497
+ /** @enum {string} */
498
+ type: "entryPattern" | "componentPattern" | "compositionPattern";
499
+ releaseId?: string;
500
+ } | {
501
+ entityId: string;
502
+ /** @enum {string} */
503
+ type: "component" | "contentType" | "blockType" | "asset" | "audience" | "intent" | "enrichment" | "signal" | "quirk" | "test" | "projectMapNode";
504
+ } | {
505
+ /** @enum {string} */
506
+ type: "external";
507
+ /** Format: uri */
508
+ url: string;
509
+ };
510
+ /** Format: date-time */
511
+ createdAt: string;
512
+ /** Format: date-time */
513
+ readAt?: string | null;
514
+ }[];
515
+ cursor?: string;
516
+ unreadCount: number;
517
+ };
518
+ };
519
+ };
520
+ 400: components["responses"]["BadRequestError"];
521
+ 401: components["responses"]["UnauthorizedError"];
522
+ 403: components["responses"]["ForbiddenError"];
523
+ 429: components["responses"]["RateLimitError"];
524
+ 500: components["responses"]["InternalServerError"];
525
+ };
526
+ };
527
+ put?: never;
528
+ /**
529
+ * @deprecated
530
+ * @description Creates a project-scoped notification for recipients who belong to the project's team. The caller must have access to the project. A missing or inaccessible project returns 404.
531
+ */
532
+ post: {
533
+ parameters: {
534
+ query?: never;
535
+ header?: never;
536
+ path?: never;
537
+ cookie?: never;
538
+ };
539
+ requestBody: {
540
+ content: {
541
+ "application/json": {
542
+ recipients: string[];
543
+ /**
544
+ * @description The notification content type. Currently, only text notifications are supported.
545
+ * @default text
546
+ * @enum {string}
547
+ */
548
+ type?: "text";
549
+ summary: {
550
+ /** @enum {string} */
551
+ format: "markdown";
552
+ value: string;
553
+ };
554
+ entity?: {
555
+ entityId: string;
556
+ /** @enum {string} */
557
+ type: "entry" | "composition";
558
+ releaseId?: string;
559
+ editionId?: string;
560
+ } | {
561
+ entityId: string;
562
+ /** @enum {string} */
563
+ type: "entryPattern" | "componentPattern" | "compositionPattern";
564
+ releaseId?: string;
565
+ } | {
566
+ entityId: string;
567
+ /** @enum {string} */
568
+ type: "component" | "contentType" | "blockType" | "asset" | "audience" | "intent" | "enrichment" | "signal" | "quirk" | "test" | "projectMapNode";
569
+ } | {
570
+ /** @enum {string} */
571
+ type: "external";
572
+ /** Format: uri */
573
+ url: string;
574
+ };
575
+ projectId: string;
576
+ };
577
+ };
578
+ };
579
+ responses: {
580
+ /** @description Created */
581
+ 201: {
582
+ headers: {
583
+ [name: string]: unknown;
584
+ };
585
+ content: {
586
+ "application/json": {
587
+ id: string;
588
+ /**
589
+ * @description The notification content type. Currently, only text notifications are supported.
590
+ * @enum {string}
591
+ */
592
+ type: "text";
593
+ teamId: string;
594
+ project: {
595
+ id: string;
596
+ name: string;
597
+ } | null;
598
+ author: {
599
+ subject: string;
600
+ name: string;
601
+ } | null;
602
+ summary: {
603
+ /** @enum {string} */
604
+ format: "markdown";
605
+ value: string;
606
+ };
607
+ entity?: {
608
+ entityId: string;
609
+ /** @enum {string} */
610
+ type: "entry" | "composition";
611
+ releaseId?: string;
612
+ editionId?: string;
613
+ } | {
614
+ entityId: string;
615
+ /** @enum {string} */
616
+ type: "entryPattern" | "componentPattern" | "compositionPattern";
617
+ releaseId?: string;
618
+ } | {
619
+ entityId: string;
620
+ /** @enum {string} */
621
+ type: "component" | "contentType" | "blockType" | "asset" | "audience" | "intent" | "enrichment" | "signal" | "quirk" | "test" | "projectMapNode";
622
+ } | {
623
+ /** @enum {string} */
624
+ type: "external";
625
+ /** Format: uri */
626
+ url: string;
627
+ };
628
+ /** Format: date-time */
629
+ createdAt: string;
630
+ /** Format: date-time */
631
+ readAt?: string | null;
632
+ };
633
+ };
634
+ };
635
+ 400: components["responses"]["BadRequestError"];
636
+ 401: components["responses"]["UnauthorizedError"];
637
+ 403: components["responses"]["ForbiddenError"];
638
+ /** @description Project not found or inaccessible to the caller */
639
+ 404: {
640
+ headers: {
641
+ [name: string]: unknown;
642
+ };
643
+ content?: never;
644
+ };
645
+ 429: components["responses"]["RateLimitError"];
646
+ 500: components["responses"]["InternalServerError"];
647
+ };
648
+ };
649
+ delete?: never;
650
+ /** @description Handles preflight requests. This endpoint allows CORS. */
651
+ options: {
652
+ parameters: {
653
+ query?: never;
654
+ header?: never;
655
+ path?: never;
656
+ cookie?: never;
657
+ };
658
+ requestBody?: never;
659
+ responses: {
660
+ /** @description ok */
661
+ 204: {
662
+ headers: {
663
+ [name: string]: unknown;
664
+ };
665
+ content?: never;
666
+ };
667
+ };
668
+ };
669
+ head?: never;
670
+ /**
671
+ * @deprecated
672
+ * @description Updates read state for the current user's notifications. Use target: ids to update specific notifications, or target: all to mark all notifications as read. Read-all may be scoped to a team.
673
+ */
674
+ patch: {
675
+ parameters: {
676
+ query?: never;
677
+ header?: never;
678
+ path?: never;
679
+ cookie?: never;
680
+ };
681
+ requestBody: {
682
+ content: {
683
+ "application/json": {
684
+ /** @enum {string} */
685
+ target: "ids";
686
+ ids: string[];
687
+ read: boolean;
688
+ } | {
689
+ /** @enum {string} */
690
+ target: "all";
691
+ teamId?: string;
692
+ };
693
+ };
694
+ };
695
+ responses: {
696
+ /** @description No Content */
697
+ 204: {
698
+ headers: {
699
+ [name: string]: unknown;
700
+ };
701
+ content: {
702
+ "application/json": unknown;
703
+ };
704
+ };
705
+ 400: components["responses"]["BadRequestError"];
706
+ 401: components["responses"]["UnauthorizedError"];
707
+ 403: components["responses"]["ForbiddenError"];
708
+ 429: components["responses"]["RateLimitError"];
709
+ 500: components["responses"]["InternalServerError"];
710
+ };
711
+ };
712
+ trace?: never;
713
+ };
714
+ }
715
+ interface components {
716
+ schemas: {
717
+ Error: {
718
+ /** @description Error message(s) that occurred while processing the request */
719
+ errorMessage?: string[] | string;
720
+ };
721
+ };
722
+ responses: {
723
+ /** @description Request input validation failed */
724
+ BadRequestError: {
725
+ headers: {
726
+ [name: string]: unknown;
727
+ };
728
+ content: {
729
+ "application/json": components["schemas"]["Error"];
730
+ };
731
+ };
732
+ /** @description API key or token was not valid */
733
+ UnauthorizedError: {
734
+ headers: {
735
+ [name: string]: unknown;
736
+ };
737
+ content: {
738
+ "application/json": components["schemas"]["Error"];
739
+ };
740
+ };
741
+ /** @description Permission was denied */
742
+ ForbiddenError: {
743
+ headers: {
744
+ [name: string]: unknown;
745
+ };
746
+ content: {
747
+ "application/json": components["schemas"]["Error"];
748
+ };
749
+ };
750
+ /** @description Too many requests in allowed time period */
751
+ RateLimitError: {
752
+ headers: {
753
+ [name: string]: unknown;
754
+ };
755
+ content?: never;
756
+ };
757
+ /** @description Execution error occurred */
758
+ InternalServerError: {
759
+ headers: {
760
+ [name: string]: unknown;
761
+ };
762
+ content?: never;
763
+ };
764
+ };
765
+ parameters: never;
766
+ requestBodies: never;
767
+ headers: never;
768
+ pathItems: never;
769
+ }
770
+
771
+ type NotificationsApi = paths['/api/v1/notifications'];
772
+ /** Query parameters for listing the current user's notifications. */
773
+ type NotificationsGetParameters = NonNullable<NotificationsApi['get']['parameters']['query']>;
774
+ /** A page of notifications for the current user. */
775
+ type NotificationsGetResponse = NotificationsApi['get']['responses']['200']['content']['application/json'];
776
+ /** A notification returned by the Notifications API. */
777
+ type Notification = NotificationsGetResponse['notifications'][number];
778
+ /** An entity referenced by a notification. */
779
+ type NotificationEntity = NonNullable<Notification['entity']>;
780
+ /** Parameters for creating a notification. */
781
+ type NotificationPostParameters = NotificationsApi['post']['requestBody']['content']['application/json'];
782
+ /** The notification created by the Notifications API. */
783
+ type NotificationPostResponse = NotificationsApi['post']['responses']['201']['content']['application/json'];
784
+ /** Parameters for updating notification read state. */
785
+ type NotificationPatchParameters = NotificationsApi['patch']['requestBody']['content']['application/json'];
786
+
787
+ /**
788
+ * API client for listing, creating, and updating notifications.
789
+ *
790
+ * @deprecated This API is experimental and may change without notice.
791
+ */
792
+ declare class NotificationsClient extends ApiClient {
793
+ #private;
794
+ constructor(options: ClientOptions);
795
+ /**
796
+ * Lists notifications for the current user.
797
+ *
798
+ * @deprecated This API is experimental and may change without notice.
799
+ */
800
+ list(options?: NotificationsGetParameters): Promise<NotificationsGetResponse>;
801
+ /**
802
+ * Creates a notification for one or more recipients.
803
+ *
804
+ * @deprecated This API is experimental and may change without notice.
805
+ */
806
+ create(body: NotificationPostParameters): Promise<NotificationPostResponse>;
807
+ /**
808
+ * Updates the read state of the current user's notifications.
809
+ *
810
+ * @deprecated This API is experimental and may change without notice.
811
+ */
812
+ setReadState(body: NotificationPatchParameters): Promise<void>;
813
+ }
814
+
815
+ export { AUTOMATION_INSTRUCTIONS_MAX_LENGTH, type AiToolAutomationMetadata, type AiToolInputSchema, type AiToolTriggerConfig, type AutomationContext, type AutomationDefinition, type AutomationHandler, type AutomationInvokePayload, type AutomationInvoker, AutomationLogEntry, type AutomationLogLevel, type AutomationLogger, type AutomationMetadata, type AutomationPermissions, AutomationResult, type ComposableTriggerConfig, type ComposedAutomationMetadata, type CredentialsFromAutomationMetadata, type EventTriggerConfig, type HandlerFromAutomationMetadata, type IncomingWebhookInput, type IncomingWebhookTriggerConfig, type InputFromAutomationMetadata, type JsonSchemaObject, type Notification, type NotificationEntity, type NotificationPatchParameters, type NotificationPostParameters, type NotificationPostResponse, NotificationsClient, type NotificationsGetParameters, type NotificationsGetResponse, type ScheduleRunInput, type ScheduleTriggerConfig, type ScoutAutomationDefinition, type ScoutAutomationMetadata, type TriggerConfig, type TriggerFromAutomationMetadata, type UniformConnectionParams, defineAutomation, defineScoutAutomation };
package/dist/index.mjs CHANGED
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  formatAutomationWebhookUrl
3
3
  } from "./chunk-TWKWPWN3.mjs";
4
- import "./chunk-I6KKUHEY.mjs";
4
+ import {
5
+ __privateAdd,
6
+ __privateGet
7
+ } from "./chunk-I6KKUHEY.mjs";
5
8
 
6
9
  // src/runtime.ts
7
10
  function captureLog(logs, level, message) {
@@ -63,9 +66,78 @@ function metadataRequiresUniformCredentials(metadata) {
63
66
  function defineAutomation(config) {
64
67
  const requireUniformCredentials = metadataRequiresUniformCredentials(config.metadata);
65
68
  const invoker = (payload) => runAutomationHandler(config.handler, payload, { requireUniformCredentials });
66
- return Object.assign(invoker, { metadata: config.metadata });
69
+ return Object.assign(invoker, { kind: "typescript", metadata: config.metadata });
70
+ }
71
+
72
+ // src/defineScoutAutomation.ts
73
+ function defineScoutAutomation(metadata, instructions) {
74
+ var _a;
75
+ if (!instructions.trim()) {
76
+ throw new Error("A Scout automation must be given instructions.");
77
+ }
78
+ if (!((_a = metadata.triggers) == null ? void 0 : _a.length)) {
79
+ throw new Error("A Scout automation must declare at least one trigger.");
80
+ }
81
+ if (metadata.triggers.some((trigger) => (trigger == null ? void 0 : trigger.type) === "aiTool")) {
82
+ throw new Error(
83
+ "A Scout automation cannot use an aiTool trigger: an aiTool automation is itself a tool the agent calls. Use defineAutomation for that."
84
+ );
85
+ }
86
+ return { kind: "scout", metadata, instructions };
67
87
  }
88
+
89
+ // src/metadata.ts
90
+ var AUTOMATION_INSTRUCTIONS_MAX_LENGTH = 16 * 1024;
91
+
92
+ // src/NotificationsClient.ts
93
+ import { ApiClient } from "@uniformdev/context/api";
94
+ var _url;
95
+ var _NotificationsClient = class _NotificationsClient extends ApiClient {
96
+ constructor(options) {
97
+ super(options);
98
+ }
99
+ /**
100
+ * Lists notifications for the current user.
101
+ *
102
+ * @deprecated This API is experimental and may change without notice.
103
+ */
104
+ async list(options) {
105
+ const fetchUri = this.createUrl(__privateGet(_NotificationsClient, _url), options);
106
+ return await this.apiClient(fetchUri);
107
+ }
108
+ /**
109
+ * Creates a notification for one or more recipients.
110
+ *
111
+ * @deprecated This API is experimental and may change without notice.
112
+ */
113
+ async create(body) {
114
+ const fetchUri = this.createUrl(__privateGet(_NotificationsClient, _url));
115
+ return await this.apiClient(fetchUri, {
116
+ method: "POST",
117
+ body: JSON.stringify(body)
118
+ });
119
+ }
120
+ /**
121
+ * Updates the read state of the current user's notifications.
122
+ *
123
+ * @deprecated This API is experimental and may change without notice.
124
+ */
125
+ async setReadState(body) {
126
+ const fetchUri = this.createUrl(__privateGet(_NotificationsClient, _url));
127
+ await this.apiClient(fetchUri, {
128
+ method: "PATCH",
129
+ body: JSON.stringify(body),
130
+ expectNoContent: true
131
+ });
132
+ }
133
+ };
134
+ _url = new WeakMap();
135
+ __privateAdd(_NotificationsClient, _url, "/api/v1/notifications");
136
+ var NotificationsClient = _NotificationsClient;
68
137
  export {
138
+ AUTOMATION_INSTRUCTIONS_MAX_LENGTH,
139
+ NotificationsClient,
69
140
  defineAutomation,
141
+ defineScoutAutomation,
70
142
  formatAutomationWebhookUrl
71
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/automations-sdk",
3
- "version": "20.72.3-alpha.25+cd10fe6e1e",
3
+ "version": "20.72.3-alpha.45+2b8b05d58a",
4
4
  "description": "Uniform Automations SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "exports": {
@@ -40,8 +40,8 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@standard-schema/spec": "^1.1.0",
43
- "@uniformdev/context": "20.72.3-alpha.25+cd10fe6e1e",
44
- "@uniformdev/webhooks": "20.72.3-alpha.25+cd10fe6e1e"
43
+ "@uniformdev/context": "20.72.3-alpha.45+2b8b05d58a",
44
+ "@uniformdev/webhooks": "20.72.3-alpha.45+2b8b05d58a"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "ai": "^6.0.0",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "cd10fe6e1e8877ed1ec45290d74ac160d597e84e"
65
+ "gitHead": "2b8b05d58ab275b4d29a9647feeaad47b0ab5cce"
66
66
  }