@uniformdev/automations-sdk 20.72.3-alpha.40 → 20.72.3-alpha.52
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/api/index.d.mts +83 -4
- package/dist/api/index.mjs +0 -2
- package/dist/index.d.mts +58 -1
- package/dist/index.mjs +23 -1
- package/package.json +4 -4
package/dist/api/index.d.mts
CHANGED
|
@@ -417,6 +417,13 @@ interface paths {
|
|
|
417
417
|
name: string;
|
|
418
418
|
/** @description Optional description. */
|
|
419
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;
|
|
420
427
|
/** @description The triggers this automation subscribes to. */
|
|
421
428
|
triggers: {
|
|
422
429
|
/** @description How the automation is triggered. */
|
|
@@ -492,6 +499,8 @@ interface paths {
|
|
|
492
499
|
* @deprecated
|
|
493
500
|
* @description Deploys (creates or updates) an automation.
|
|
494
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
|
+
*
|
|
495
504
|
* This is experimental functionality that is subject to change without notice.
|
|
496
505
|
*/
|
|
497
506
|
put: {
|
|
@@ -550,10 +559,69 @@ interface paths {
|
|
|
550
559
|
[key: string]: string | string[];
|
|
551
560
|
};
|
|
552
561
|
};
|
|
562
|
+
/**
|
|
563
|
+
* @description Runs a bundled TypeScript handler module.
|
|
564
|
+
* @enum {string}
|
|
565
|
+
*/
|
|
566
|
+
kind: "typescript";
|
|
553
567
|
/** @description Bundled JavaScript module for the automation handler. */
|
|
554
568
|
code: string;
|
|
555
569
|
/** @description Target date for runtime compatibility. Runtime changes after this date may not apply to this automation. */
|
|
556
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;
|
|
557
625
|
};
|
|
558
626
|
};
|
|
559
627
|
};
|
|
@@ -749,8 +817,21 @@ type AutomationSummary = AutomationsListResponse['automations'][number];
|
|
|
749
817
|
type AutomationTrigger = AutomationSummary['triggers'][number];
|
|
750
818
|
type AutomationTriggerType = AutomationTrigger['config']['type'];
|
|
751
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;
|
|
752
825
|
/** Deploy input without the project ID, which the client injects from its options. */
|
|
753
|
-
type AutomationsDeployInput =
|
|
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
|
+
}>;
|
|
754
835
|
type AutomationRunsListResponse = paths$1['/api/v1/automation-runs']['get']['responses']['200']['content']['application/json'];
|
|
755
836
|
type AutomationRunSummary = AutomationRunsListResponse['runs'][number];
|
|
756
837
|
type AutomationRunStatus = AutomationRunSummary['status'];
|
|
@@ -779,8 +860,6 @@ declare class AutomationsClient extends ApiClient<AutomationsClientOptions> {
|
|
|
779
860
|
list(): Promise<AutomationsListResponse>;
|
|
780
861
|
/**
|
|
781
862
|
* Deploys (creates or updates) a single automation.
|
|
782
|
-
*
|
|
783
|
-
* @param input - The automation definition + bundled code.
|
|
784
863
|
*/
|
|
785
864
|
deploy(input: AutomationsDeployInput): Promise<void>;
|
|
786
865
|
/**
|
|
@@ -822,4 +901,4 @@ declare class AutomationsClient extends ApiClient<AutomationsClientOptions> {
|
|
|
822
901
|
listRunLogs(runId: string): Promise<AutomationRunLogEntry[]>;
|
|
823
902
|
}
|
|
824
903
|
|
|
825
|
-
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 };
|
package/dist/api/index.mjs
CHANGED
|
@@ -40,8 +40,6 @@ var _AutomationsClient = class _AutomationsClient extends ApiClient {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Deploys (creates or updates) a single automation.
|
|
43
|
-
*
|
|
44
|
-
* @param input - The automation definition + bundled code.
|
|
45
43
|
*/
|
|
46
44
|
async deploy(input) {
|
|
47
45
|
const { projectId } = this.options;
|
package/dist/index.d.mts
CHANGED
|
@@ -75,6 +75,16 @@ type JsonSchemaObject = Record<string, unknown>;
|
|
|
75
75
|
* Note: non-zod standard schema providers are not supported.
|
|
76
76
|
*/
|
|
77
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;
|
|
78
88
|
/**
|
|
79
89
|
* Role grants for the automation's identity.
|
|
80
90
|
*/
|
|
@@ -131,6 +141,28 @@ type AiToolAutomationMetadata = AutomationMetadataBase & {
|
|
|
131
141
|
};
|
|
132
142
|
/** Authored metadata declared via {@link defineAutomation}. */
|
|
133
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
|
+
};
|
|
134
166
|
|
|
135
167
|
/**
|
|
136
168
|
* Per-run Uniform API connection parameters.
|
|
@@ -332,6 +364,8 @@ type TriggersOf<M extends AutomationMetadata> = M extends {
|
|
|
332
364
|
type HandlerFromAutomationMetadata<M extends AutomationMetadata> = AutomationHandler<InputFromAutomationMetadata<M>, TriggerFromAutomationMetadata<M>, CredentialsFromAutomationMetadata<M>>;
|
|
333
365
|
/** A fully defined automation module: a callable invoke function with authored metadata attached. */
|
|
334
366
|
type AutomationDefinition<M extends AutomationMetadata = AutomationMetadata> = AutomationInvoker & {
|
|
367
|
+
/** Discriminates a handler automation module from a Scout one (see `defineScoutAutomation`). */
|
|
368
|
+
kind: 'typescript';
|
|
335
369
|
metadata: M;
|
|
336
370
|
};
|
|
337
371
|
/**
|
|
@@ -371,6 +405,29 @@ declare function defineAutomation<const M extends AutomationMetadata>(config: {
|
|
|
371
405
|
handler: HandlerFromAutomationMetadata<M>;
|
|
372
406
|
}): AutomationDefinition<M>;
|
|
373
407
|
|
|
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
|
+
|
|
374
431
|
interface paths {
|
|
375
432
|
"/api/v1/notifications": {
|
|
376
433
|
parameters: {
|
|
@@ -755,4 +812,4 @@ declare class NotificationsClient extends ApiClient {
|
|
|
755
812
|
setReadState(body: NotificationPatchParameters): Promise<void>;
|
|
756
813
|
}
|
|
757
814
|
|
|
758
|
-
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 Notification, type NotificationEntity, type NotificationPatchParameters, type NotificationPostParameters, type NotificationPostResponse, NotificationsClient, type NotificationsGetParameters, type NotificationsGetResponse, type ScheduleRunInput, type ScheduleTriggerConfig, type TriggerConfig, type TriggerFromAutomationMetadata, type UniformConnectionParams, defineAutomation };
|
|
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
|
@@ -66,9 +66,29 @@ function metadataRequiresUniformCredentials(metadata) {
|
|
|
66
66
|
function defineAutomation(config) {
|
|
67
67
|
const requireUniformCredentials = metadataRequiresUniformCredentials(config.metadata);
|
|
68
68
|
const invoker = (payload) => runAutomationHandler(config.handler, payload, { requireUniformCredentials });
|
|
69
|
-
return Object.assign(invoker, { metadata: config.metadata });
|
|
69
|
+
return Object.assign(invoker, { kind: "typescript", metadata: config.metadata });
|
|
70
70
|
}
|
|
71
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 };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/metadata.ts
|
|
90
|
+
var AUTOMATION_INSTRUCTIONS_MAX_LENGTH = 16 * 1024;
|
|
91
|
+
|
|
72
92
|
// src/NotificationsClient.ts
|
|
73
93
|
import { ApiClient } from "@uniformdev/context/api";
|
|
74
94
|
var _url;
|
|
@@ -115,7 +135,9 @@ _url = new WeakMap();
|
|
|
115
135
|
__privateAdd(_NotificationsClient, _url, "/api/v1/notifications");
|
|
116
136
|
var NotificationsClient = _NotificationsClient;
|
|
117
137
|
export {
|
|
138
|
+
AUTOMATION_INSTRUCTIONS_MAX_LENGTH,
|
|
118
139
|
NotificationsClient,
|
|
119
140
|
defineAutomation,
|
|
141
|
+
defineScoutAutomation,
|
|
120
142
|
formatAutomationWebhookUrl
|
|
121
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/automations-sdk",
|
|
3
|
-
"version": "20.72.3-alpha.
|
|
3
|
+
"version": "20.72.3-alpha.52+f01685e1ef",
|
|
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.
|
|
44
|
-
"@uniformdev/webhooks": "20.72.3-alpha.
|
|
43
|
+
"@uniformdev/context": "20.72.3-alpha.52+f01685e1ef",
|
|
44
|
+
"@uniformdev/webhooks": "20.72.3-alpha.52+f01685e1ef"
|
|
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": "
|
|
65
|
+
"gitHead": "f01685e1ef0aeb05dc200ccdcdd5aba6f6cfc437"
|
|
66
66
|
}
|