@zapier/zapier-sdk 0.76.1 → 0.77.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.77.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 19303e0: `triggerWorkflow` (and `trigger-workflow`) now authenticates with Zapier credentials and runs the workflow as the authenticated account; triggering is limited to workflows that account can access. It now returns the trigger's `id`, `workflow_id`, and `created_at` on `data` (previously `{ workflow, status, body }`). The call is unchanged: pass the workflow id and optional `input`.
8
+
9
+ ## 0.76.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 27ca0c5: Add zapier-sdk-agent header to identify the AI agent using the SDK
14
+
3
15
  ## 0.76.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1744,7 +1744,7 @@ const result = await zapier.runDurable({
1744
1744
 
1745
1745
  #### `triggerWorkflow` 🧪 _experimental_
1746
1746
 
1747
- Look up a workflow's trigger URL and fire it manually. The trigger endpoint is tokenized (the URL contains a secret) and takes no auth header, so the SDK uses a raw fetch rather than the api plugin.
1747
+ Look up a workflow's trigger URL and fire it manually, as the authenticated account.
1748
1748
 
1749
1749
  **Parameters:**
1750
1750
 
@@ -1756,12 +1756,12 @@ Look up a workflow's trigger URL and fire it manually. The trigger endpoint is t
1756
1756
 
1757
1757
  **Returns:** `Promise<WorkflowRunItem>`
1758
1758
 
1759
- | Name | Type | Required | Possible Values | Description |
1760
- | -------------- | --------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
1761
- | `data` | `object` | ✅ | — | |
1762
- | ​ ↳ `workflow` | `string` | ✅ | — | The workflow ID that was triggered |
1763
- | ​ ↳ `status` | `number` | ✅ | — | HTTP status returned by the trigger endpoint |
1764
- | ​ ↳ `body` | `unknown` | ✅ | — | Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text. |
1759
+ | Name | Type | Required | Possible Values | Description |
1760
+ | ----------------- | -------- | -------- | --------------- | ---------------------------------------- |
1761
+ | `data` | `object` | ✅ | — | |
1762
+ | ​ ↳ `id` | `string` | ✅ | — | Trigger ID (UUID) |
1763
+ | ​ ↳ `workflow_id` | `string` | ✅ | — | The workflow that was triggered (UUID) |
1764
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the trigger was received (ISO-8601) |
1765
1765
 
1766
1766
  **Example:**
1767
1767
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AA0kDjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAglDjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
@@ -14,6 +14,7 @@ import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
14
14
  import { isPlainObject } from "../utils/type-guard-utils";
15
15
  import { isAbortError } from "../utils/abort-utils";
16
16
  import { getCallerContext } from "../utils/caller-context";
17
+ import { getAgent } from "../utils/agent";
17
18
  import { createSseParserStream, jsonFrames, } from "./sse-parser";
18
19
  import { consumeApprovalReviewStream } from "./approval-review-stream";
19
20
  import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
@@ -766,6 +767,10 @@ class ZapierApiClient {
766
767
  headers.set("zapier-service", sdkService);
767
768
  headers.set("x-zapier-service", sdkService);
768
769
  }
770
+ const agent = getAgent();
771
+ if (agent) {
772
+ headers.set("zapier-sdk-agent", agent);
773
+ }
769
774
  const callerPackage = this.options.callerPackage;
770
775
  if (callerPackage) {
771
776
  headers.set("zapier-sdk-package", callerPackage.name);
@@ -3220,6 +3220,38 @@ function getCallerContext() {
3220
3220
  }
3221
3221
  }
3222
3222
 
3223
+ // src/utils/agent.ts
3224
+ var isTruthy = (value) => {
3225
+ const lower = value.toLowerCase();
3226
+ return lower === "1" || lower === "true";
3227
+ };
3228
+ var isNonEmpty = (value) => value !== "";
3229
+ var agentDetectors = [
3230
+ { name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
3231
+ { name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
3232
+ { name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
3233
+ { name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
3234
+ { name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
3235
+ { name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
3236
+ { name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
3237
+ { name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
3238
+ ];
3239
+ function getAgent() {
3240
+ try {
3241
+ const env = globalThis.process?.env;
3242
+ if (!env) return null;
3243
+ for (const detector of agentDetectors) {
3244
+ const value = env[detector.key];
3245
+ if (value !== void 0 && detector.predicate(value)) {
3246
+ return detector.name;
3247
+ }
3248
+ }
3249
+ return null;
3250
+ } catch {
3251
+ return null;
3252
+ }
3253
+ }
3254
+
3223
3255
  // src/api/sse-parser.ts
3224
3256
  async function* jsonFrames(source) {
3225
3257
  for await (const { data } of source) {
@@ -3371,7 +3403,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
3371
3403
  }
3372
3404
 
3373
3405
  // src/sdk-version.ts
3374
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.76.1" : void 0) || "unknown";
3406
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.77.0" : void 0) || "unknown";
3375
3407
 
3376
3408
  // src/utils/open-url.ts
3377
3409
  var nodePrefix = "node:";
@@ -4089,6 +4121,10 @@ var ZapierApiClient = class {
4089
4121
  headers.set("zapier-service", sdkService);
4090
4122
  headers.set("x-zapier-service", sdkService);
4091
4123
  }
4124
+ const agent = getAgent();
4125
+ if (agent) {
4126
+ headers.set("zapier-sdk-agent", agent);
4127
+ }
4092
4128
  const callerPackage = this.options.callerPackage;
4093
4129
  if (callerPackage) {
4094
4130
  headers.set("zapier-sdk-package", callerPackage.name);
@@ -9602,36 +9638,6 @@ function getTtyContext() {
9602
9638
  return { stdin_is_tty: null, stdout_is_tty: null };
9603
9639
  }
9604
9640
  }
9605
- var isTruthy = (value) => {
9606
- const lower = value.toLowerCase();
9607
- return lower === "1" || lower === "true";
9608
- };
9609
- var isNonEmpty = (value) => value !== "";
9610
- var agentDetectors = [
9611
- { name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
9612
- { name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
9613
- { name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
9614
- { name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
9615
- { name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
9616
- { name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
9617
- { name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
9618
- { name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
9619
- ];
9620
- function getAgent() {
9621
- try {
9622
- const env = globalThis.process?.env;
9623
- if (!env) return null;
9624
- for (const detector of agentDetectors) {
9625
- const value = env[detector.key];
9626
- if (value !== void 0 && detector.predicate(value)) {
9627
- return detector.name;
9628
- }
9629
- }
9630
- return null;
9631
- } catch {
9632
- return null;
9633
- }
9634
- }
9635
9641
 
9636
9642
  // src/plugins/eventEmission/builders.ts
9637
9643
  function createBaseEvent(context = {}) {
@@ -13093,14 +13099,12 @@ var TriggerWorkflowOptionsSchema = zod.z.object({
13093
13099
  "JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
13094
13100
  )
13095
13101
  }).describe(
13096
- "Look up a workflow's trigger URL and fire it manually. The trigger endpoint is tokenized (the URL contains a secret) and takes no auth header, so the SDK uses a raw fetch rather than the api plugin."
13102
+ "Look up a workflow's trigger URL and fire it manually, as the authenticated account."
13097
13103
  );
13098
13104
  var TriggerWorkflowResponseSchema = zod.z.object({
13099
- workflow: zod.z.string().describe("The workflow ID that was triggered"),
13100
- status: zod.z.number().int().describe("HTTP status returned by the trigger endpoint"),
13101
- body: zod.z.unknown().describe(
13102
- "Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
13103
- )
13105
+ id: zod.z.string().describe("Trigger ID (UUID)"),
13106
+ workflow_id: zod.z.string().describe("The workflow that was triggered (UUID)"),
13107
+ created_at: zod.z.string().describe("When the trigger was received (ISO-8601)")
13104
13108
  });
13105
13109
 
13106
13110
  // src/plugins/codeSubstrate/triggerWorkflow/index.ts
@@ -13122,32 +13126,23 @@ var triggerWorkflowPlugin = definePlugin(
13122
13126
  }
13123
13127
  );
13124
13128
  const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
13125
- const fetch2 = sdk2.context.options.fetch ?? globalThis.fetch;
13126
- const response = await fetch2(workflow.trigger_url, {
13127
- method: "POST",
13128
- headers: { "Content-Type": "application/json" },
13129
- body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
13130
- });
13131
- const text = await response.text().catch(() => "");
13132
- let body = text;
13133
- if (text) {
13134
- try {
13135
- body = JSON.parse(text);
13136
- } catch {
13137
- body = text;
13138
- }
13139
- }
13140
- if (!response.ok) {
13129
+ const segments = new URL(workflow.trigger_url).pathname.split("/");
13130
+ const triggerToken = segments[segments.length - 1];
13131
+ if (!triggerToken) {
13141
13132
  throw new ZapierApiError(
13142
- `Trigger failed: ${response.status} ${response.statusText}: ${text || "(empty body)"}`,
13143
- { statusCode: response.status, response: body }
13133
+ `Workflow ${options.workflow} returned a malformed trigger_url`,
13134
+ { statusCode: 0, response: workflow.trigger_url }
13144
13135
  );
13145
13136
  }
13146
- const data = {
13147
- workflow: options.workflow,
13148
- status: response.status,
13149
- body
13150
- };
13137
+ const raw = await sdk2.context.api.post(
13138
+ `/durableworkflowzaps/api/v0/workflows/trigger/${encodeURIComponent(triggerToken)}`,
13139
+ options.input,
13140
+ {
13141
+ authRequired: true,
13142
+ resource: { type: "workflow", id: options.workflow }
13143
+ }
13144
+ );
13145
+ const data = TriggerWorkflowResponseSchema.parse(raw);
13151
13146
  return { data };
13152
13147
  }
13153
13148
  })
@@ -1,5 +1,5 @@
1
- import { B as BaseSdkOptions, P as PluginStack, a as PluginMeta, M as MethodHooks, C as CoreOptions, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, b as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, c as UpdateManifestEntryResult, d as AddActionEntryOptions, e as AddActionEntryResult, f as ActionEntry, g as findManifestEntry, r as readManifestFromFile, h as CapabilitiesContext, i as PaginatedSdkResult, G as GetConnectionStartUrlItem, W as WaitForNewConnectionItem, j as CreateConnectionItem, F as FieldsetItem, k as PositionalMetadata, O as OutputFormatter, l as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, m as DynamicResolver, n as WatchTriggerInboxOptions, o as ActionProxy, p as ZapierSdkApps, q as WithAddPlugin } from './index-Dlf9DlnJ.mjs';
2
- export { H as Action, ci as ActionExecutionOptions, Q as ActionExecutionResult, S as ActionField, V as ActionFieldChoice, aW as ActionItem, bw as ActionKeyProperty, b4 as ActionKeyPropertySchema, bx as ActionProperty, b5 as ActionPropertySchema, aK as ActionResolverItem, bI as ActionTimeoutMsProperty, bg as ActionTimeoutMsPropertySchema, aL as ActionTypeItem, bv as ActionTypeProperty, b3 as ActionTypePropertySchema, ce as ApiError, dL as ApiEvent, d0 as ApiPluginOptions, d2 as ApiPluginProvides, I as App, cj as AppFactoryInput, aU as AppItem, bt as AppKeyProperty, b1 as AppKeyPropertySchema, bu as AppProperty, b2 as AppPropertySchema, eV as ApplicationLifecycleEventData, ca as ApprovalStatus, ch as AppsPluginProvides, bN as AppsProperty, bl as AppsPropertySchema, a8 as ArrayResolver, dK as AuthEvent, dv as AuthMechanism, bB as AuthenticationIdProperty, b8 as AuthenticationIdPropertySchema, f1 as BaseEvent, ay as BaseSdkOptionsSchema, am as BatchOptions, cP as CONTEXT_CACHE_MAX_SIZE, cO as CONTEXT_CACHE_TTL_MS, aC as CORE_ERROR_SYMBOL, ai as CallerContext, K as Choice, dR as ClientCredentialsObject, e0 as ClientCredentialsObjectSchema, _ as Connection, e8 as ConnectionEntry, e7 as ConnectionEntrySchema, bz as ConnectionIdProperty, b7 as ConnectionIdPropertySchema, aV as ConnectionItem, bA as ConnectionProperty, b9 as ConnectionPropertySchema, ea as ConnectionsMap, e9 as ConnectionsMapSchema, ec as ConnectionsPluginProvides, bP as ConnectionsProperty, bn as ConnectionsPropertySchema, $ as ConnectionsResponse, aD as CoreErrorCode, cB as CreateClientCredentialsPluginProvides, eD as CreateTableFieldsPluginProvides, ex as CreateTablePluginProvides, eL as CreateTableRecordsPluginProvides, dO as Credentials, e5 as CredentialsFunction, e4 as CredentialsFunctionSchema, dQ as CredentialsObject, e2 as CredentialsObjectSchema, e6 as CredentialsSchema, eh as DEFAULT_ACTION_TIMEOUT_MS, eq as DEFAULT_APPROVAL_TIMEOUT_MS, cY as DEFAULT_CONFIG_PATH, er as DEFAULT_MAX_APPROVAL_RETRIES, eg as DEFAULT_PAGE_SIZE, bG as DebugProperty, be as DebugPropertySchema, cD as DeleteClientCredentialsPluginProvides, eF as DeleteTableFieldsPluginProvides, ez as DeleteTablePluginProvides, eN as DeleteTableRecordsPluginProvides, u as DrainTriggerInboxCallback, v as DrainTriggerInboxErrorObserver, ab as DynamicListResolver, ac as DynamicSearchResolver, eW as EnhancedErrorEventData, bV as ErrorOptions, dN as EventCallback, eU as EventContext, eR as EventEmissionConfig, eT as EventEmissionProvides, cl as FetchPluginProvides, J as Field, bM as FieldsProperty, bk as FieldsPropertySchema, ad as FieldsResolver, y as FindFirstAuthenticationPluginProvides, cL as FindFirstConnectionPluginProvides, z as FindUniqueAuthenticationPluginProvides, cN as FindUniqueConnectionPluginProvides, a6 as FormattedItem, ax as FunctionDeprecation, aw as FunctionRegistryEntry, cv as GetActionInputFieldsSchemaPluginProvides, cH as GetActionPluginProvides, cF as GetAppPluginProvides, x as GetAuthenticationPluginProvides, cJ as GetConnectionPluginProvides, c$ as GetProfilePluginProvides, ev as GetTablePluginProvides, eH as GetTableRecordPluginProvides, aY as InfoFieldItem, aX as InputFieldItem, by as InputFieldProperty, b6 as InputFieldPropertySchema, bC as InputsProperty, ba as InputsPropertySchema, aT as JsonSseMessage, bU as LeaseLimitProperty, bs as LeaseLimitPropertySchema, bS as LeaseProperty, bq as LeasePropertySchema, bT as LeaseSecondsProperty, br as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bD as LimitProperty, bb as LimitPropertySchema, ct as ListActionInputFieldChoicesPluginProvides, cr as ListActionInputFieldsPluginProvides, cp as ListActionsPluginProvides, cn as ListAppsPluginProvides, w as ListAuthenticationsPluginProvides, cz as ListClientCredentialsPluginProvides, cx as ListConnectionsPluginProvides, eB as ListTableFieldsPluginProvides, eJ as ListTableRecordsPluginProvides, et as ListTablesPluginProvides, dM as LoadingEvent, ek as MAX_CONCURRENCY_LIMIT, ef as MAX_PAGE_LIMIT, cZ as ManifestEntry, cU as ManifestPluginOptions, cX as ManifestPluginProvides, f2 as MethodCalledEvent, eX as MethodCalledEventData, N as Need, X as NeedsRequest, Y as NeedsResponse, bE as OffsetProperty, bc as OffsetPropertySchema, bF as OutputProperty, bd as OutputPropertySchema, b0 as PaginatedSdkFunction, bH as ParamsProperty, bf as ParamsPropertySchema, dS as PkceCredentialsObject, e1 as PkceCredentialsObjectSchema, aE as Plugin, aF as PluginProvides, aO as PollOptions, c8 as RateLimitInfo, bK as RecordProperty, bi as RecordPropertySchema, bL as RecordsProperty, bj as RecordsPropertySchema, ar as RelayFetchSchema, aq as RelayRequestSchema, aN as RequestOptions, cT as RequestPluginProvides, du as ResolveAuthTokenOptions, dX as ResolveCredentialsOptions, dw as ResolvedAuth, dP as ResolvedCredentials, e3 as ResolvedCredentialsSchema, a7 as Resolver, a9 as ResolverMetadata, aZ as RootFieldItem, cR as RunActionPluginProvides, dJ as SdkEvent, a$ as SdkPage, aS as SseMessage, aa as StaticResolver, bJ as TableProperty, bh as TablePropertySchema, bO as TablesProperty, bm as TablesPropertySchema, bR as TriggerInboxNameProperty, bp as TriggerInboxNamePropertySchema, bQ as TriggerInboxProperty, bo as TriggerInboxPropertySchema, T as TriggerMessageStatus, eP as UpdateTableRecordsPluginProvides, a0 as UserProfile, a_ as UserProfileItem, ed as ZAPIER_BASE_URL, em as ZAPIER_MAX_CONCURRENT_REQUESTS, ei as ZAPIER_MAX_NETWORK_RETRIES, ej as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, s as ZapierAbortDrainSignal, c6 as ZapierActionError, b$ as ZapierApiError, c0 as ZapierAppNotFoundError, cb as ZapierApprovalError, bZ as ZapierAuthenticationError, c4 as ZapierBundleError, dF as ZapierCache, dG as ZapierCacheEntry, dH as ZapierCacheSetOptions, c3 as ZapierConfigurationError, c7 as ZapierConflictError, bW as ZapierError, c1 as ZapierNotFoundError, c9 as ZapierRateLimitError, cc as ZapierRelayError, t as ZapierReleaseTriggerMessageSignal, c2 as ZapierResourceNotFoundError, cf as ZapierSignal, c5 as ZapierTimeoutError, bY as ZapierUnknownError, bX as ZapierValidationError, d5 as actionKeyResolver, d4 as actionTypeResolver, a5 as addPlugin, d1 as apiPlugin, d3 as appKeyResolver, cg as appsPlugin, d7 as authenticationIdGenericResolver, d6 as authenticationIdResolver, al as batch, eY as buildApplicationLifecycleEvent, an as buildCapabilityMessage, e_ as buildErrorEvent, eZ as buildErrorEventWithContext, f0 as buildMethodCalledEvent, eQ as cleanupEventListeners, dx as clearTokenCache, db as clientCredentialsNameResolver, dc as clientIdResolver, aJ as composePlugins, d7 as connectionIdGenericResolver, d6 as connectionIdResolver, eb as connectionsPlugin, e$ as createBaseEvent, cA as createClientCredentialsPlugin, a4 as createCorePlugin, a2 as createFunction, dI as createMemoryCache, au as createOptionsPlugin, aI as createPaginatedPluginMethod, aH as createPluginMethod, a3 as createPluginStack, at as createSdk, eC as createTableFieldsPlugin, ew as createTablePlugin, eK as createTableRecordsPlugin, aP as createZapierApi, av as createZapierCoreStack, as as createZapierSdkWithoutRegistry, aG as definePlugin, cC as deleteClientCredentialsPlugin, eE as deleteTableFieldsPlugin, ey as deleteTablePlugin, eM as deleteTableRecordsPlugin, dg as durableRunIdResolver, eS as eventEmissionPlugin, ck as fetchPlugin, cK as findFirstConnectionPlugin, cM as findUniqueConnectionPlugin, cd as formatErrorMessage, f3 as generateEventId, cu as getActionInputFieldsSchemaPlugin, cG as getActionPlugin, fd as getAgent, cE as getAppPlugin, d_ as getBaseUrlFromCredentials, ag as getCallerContext, f9 as getCiPlatform, d$ as getClientIdFromCredentials, cI as getConnectionPlugin, aB as getCoreErrorCause, aA as getCoreErrorCode, fb as getCpuTime, f4 as getCurrentTimestamp, fa as getMemoryUsage, aQ as getOrCreateApiClient, f6 as getOsInfo, f7 as getPlatformVersions, cV as getPreferredManifestEntryKey, c_ as getProfilePlugin, f5 as getReleaseId, eu as getTablePlugin, eG as getTableRecordPlugin, dB as getTokenFromCliLogin, fc as getTtyContext, en as getZapierApprovalMode, ep as getZapierDefaultApprovalMode, eo as getZapierOpenAutoModeApprovalsInBrowser, ee as getZapierSdkService, dz as injectCliLogin, da as inputFieldKeyResolver, d9 as inputsAllOptionalResolver, d8 as inputsResolver, dy as invalidateCachedToken, dE as invalidateCredentialsToken, f8 as isCi, dA as isCliLoginAvailable, dT as isClientCredentials, az as isCoreError, dW as isCredentialsFunction, dV as isCredentialsObject, aR as isPermanentHttpError, dU as isPkceCredentials, a1 as isPositional, cs as listActionInputFieldChoicesPlugin, cq as listActionInputFieldsPlugin, co as listActionsPlugin, cm as listAppsPlugin, cy as listClientCredentialsPlugin, cw as listConnectionsPlugin, eA as listTableFieldsPlugin, eI as listTableRecordsPlugin, es as listTablesPlugin, ao as logDeprecation, cW as manifestPlugin, el as parseConcurrencyEnvVar, aM as registryPlugin, cS as requestPlugin, ap as resetDeprecationWarnings, dC as resolveAuth, dD as resolveAuthToken, dZ as resolveCredentials, dY as resolveCredentialsFromEnv, cQ as runActionPlugin, ae as runInMethodScope, ah as runWithCallerContext, af as runWithTelemetryContext, dm as tableFieldIdsResolver, dp as tableFieldsResolver, ds as tableFiltersResolver, dd as tableIdResolver, dn as tableNameResolver, dk as tableRecordIdResolver, dl as tableRecordIdsResolver, dq as tableRecordsResolver, dt as tableSortResolver, dr as tableUpdateRecordsResolver, aj as toSnakeCase, ak as toTitleCase, de as triggerInboxResolver, dj as triggerMessagesResolver, eO as updateTableRecordsPlugin, df as workflowIdResolver, di as workflowRunIdResolver, dh as workflowVersionIdResolver, b_ as zapierAdaptError } from './index-Dlf9DlnJ.mjs';
1
+ import { B as BaseSdkOptions, P as PluginStack, a as PluginMeta, M as MethodHooks, C as CoreOptions, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, b as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, c as UpdateManifestEntryResult, d as AddActionEntryOptions, e as AddActionEntryResult, f as ActionEntry, g as findManifestEntry, r as readManifestFromFile, h as CapabilitiesContext, i as PaginatedSdkResult, G as GetConnectionStartUrlItem, W as WaitForNewConnectionItem, j as CreateConnectionItem, F as FieldsetItem, k as PositionalMetadata, O as OutputFormatter, l as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, m as DynamicResolver, n as WatchTriggerInboxOptions, o as ActionProxy, p as ZapierSdkApps, q as WithAddPlugin } from './index-BZShISEr.mjs';
2
+ export { H as Action, cj as ActionExecutionOptions, Q as ActionExecutionResult, S as ActionField, V as ActionFieldChoice, aX as ActionItem, bx as ActionKeyProperty, b5 as ActionKeyPropertySchema, by as ActionProperty, b6 as ActionPropertySchema, aK as ActionResolverItem, bJ as ActionTimeoutMsProperty, bh as ActionTimeoutMsPropertySchema, aL as ActionTypeItem, bw as ActionTypeProperty, b4 as ActionTypePropertySchema, cf as ApiError, dM as ApiEvent, d1 as ApiPluginOptions, d3 as ApiPluginProvides, I as App, ck as AppFactoryInput, aV as AppItem, bu as AppKeyProperty, b2 as AppKeyPropertySchema, bv as AppProperty, b3 as AppPropertySchema, eW as ApplicationLifecycleEventData, cb as ApprovalStatus, ci as AppsPluginProvides, bO as AppsProperty, bm as AppsPropertySchema, a8 as ArrayResolver, dL as AuthEvent, dw as AuthMechanism, bC as AuthenticationIdProperty, b9 as AuthenticationIdPropertySchema, f2 as BaseEvent, ay as BaseSdkOptionsSchema, am as BatchOptions, cQ as CONTEXT_CACHE_MAX_SIZE, cP as CONTEXT_CACHE_TTL_MS, aC as CORE_ERROR_SYMBOL, ai as CallerContext, K as Choice, dS as ClientCredentialsObject, e1 as ClientCredentialsObjectSchema, _ as Connection, e9 as ConnectionEntry, e8 as ConnectionEntrySchema, bA as ConnectionIdProperty, b8 as ConnectionIdPropertySchema, aW as ConnectionItem, bB as ConnectionProperty, ba as ConnectionPropertySchema, eb as ConnectionsMap, ea as ConnectionsMapSchema, ed as ConnectionsPluginProvides, bQ as ConnectionsProperty, bo as ConnectionsPropertySchema, $ as ConnectionsResponse, aD as CoreErrorCode, cC as CreateClientCredentialsPluginProvides, eE as CreateTableFieldsPluginProvides, ey as CreateTablePluginProvides, eM as CreateTableRecordsPluginProvides, dP as Credentials, e6 as CredentialsFunction, e5 as CredentialsFunctionSchema, dR as CredentialsObject, e3 as CredentialsObjectSchema, e7 as CredentialsSchema, ei as DEFAULT_ACTION_TIMEOUT_MS, er as DEFAULT_APPROVAL_TIMEOUT_MS, cZ as DEFAULT_CONFIG_PATH, es as DEFAULT_MAX_APPROVAL_RETRIES, eh as DEFAULT_PAGE_SIZE, bH as DebugProperty, bf as DebugPropertySchema, cE as DeleteClientCredentialsPluginProvides, eG as DeleteTableFieldsPluginProvides, eA as DeleteTablePluginProvides, eO as DeleteTableRecordsPluginProvides, u as DrainTriggerInboxCallback, v as DrainTriggerInboxErrorObserver, ab as DynamicListResolver, ac as DynamicSearchResolver, eX as EnhancedErrorEventData, bW as ErrorOptions, dO as EventCallback, eV as EventContext, eS as EventEmissionConfig, eU as EventEmissionProvides, cm as FetchPluginProvides, J as Field, bN as FieldsProperty, bl as FieldsPropertySchema, ad as FieldsResolver, y as FindFirstAuthenticationPluginProvides, cM as FindFirstConnectionPluginProvides, z as FindUniqueAuthenticationPluginProvides, cO as FindUniqueConnectionPluginProvides, a6 as FormattedItem, ax as FunctionDeprecation, aw as FunctionRegistryEntry, cw as GetActionInputFieldsSchemaPluginProvides, cI as GetActionPluginProvides, cG as GetAppPluginProvides, x as GetAuthenticationPluginProvides, cK as GetConnectionPluginProvides, d0 as GetProfilePluginProvides, ew as GetTablePluginProvides, eI as GetTableRecordPluginProvides, aZ as InfoFieldItem, aY as InputFieldItem, bz as InputFieldProperty, b7 as InputFieldPropertySchema, bD as InputsProperty, bb as InputsPropertySchema, aU as JsonSseMessage, bV as LeaseLimitProperty, bt as LeaseLimitPropertySchema, bT as LeaseProperty, br as LeasePropertySchema, bU as LeaseSecondsProperty, bs as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bE as LimitProperty, bc as LimitPropertySchema, cu as ListActionInputFieldChoicesPluginProvides, cs as ListActionInputFieldsPluginProvides, cq as ListActionsPluginProvides, co as ListAppsPluginProvides, w as ListAuthenticationsPluginProvides, cA as ListClientCredentialsPluginProvides, cy as ListConnectionsPluginProvides, eC as ListTableFieldsPluginProvides, eK as ListTableRecordsPluginProvides, eu as ListTablesPluginProvides, dN as LoadingEvent, el as MAX_CONCURRENCY_LIMIT, eg as MAX_PAGE_LIMIT, c_ as ManifestEntry, cV as ManifestPluginOptions, cY as ManifestPluginProvides, f3 as MethodCalledEvent, eY as MethodCalledEventData, N as Need, X as NeedsRequest, Y as NeedsResponse, bF as OffsetProperty, bd as OffsetPropertySchema, bG as OutputProperty, be as OutputPropertySchema, b1 as PaginatedSdkFunction, bI as ParamsProperty, bg as ParamsPropertySchema, dT as PkceCredentialsObject, e2 as PkceCredentialsObjectSchema, aE as Plugin, aF as PluginProvides, aP as PollOptions, c9 as RateLimitInfo, bL as RecordProperty, bj as RecordPropertySchema, bM as RecordsProperty, bk as RecordsPropertySchema, ar as RelayFetchSchema, aq as RelayRequestSchema, aO as RequestOptions, cU as RequestPluginProvides, dv as ResolveAuthTokenOptions, dY as ResolveCredentialsOptions, dx as ResolvedAuth, dQ as ResolvedCredentials, e4 as ResolvedCredentialsSchema, a7 as Resolver, a9 as ResolverMetadata, a_ as RootFieldItem, cS as RunActionPluginProvides, dK as SdkEvent, b0 as SdkPage, aT as SseMessage, aa as StaticResolver, bK as TableProperty, bi as TablePropertySchema, bP as TablesProperty, bn as TablesPropertySchema, bS as TriggerInboxNameProperty, bq as TriggerInboxNamePropertySchema, bR as TriggerInboxProperty, bp as TriggerInboxPropertySchema, T as TriggerMessageStatus, eQ as UpdateTableRecordsPluginProvides, a0 as UserProfile, a$ as UserProfileItem, ee as ZAPIER_BASE_URL, en as ZAPIER_MAX_CONCURRENT_REQUESTS, ej as ZAPIER_MAX_NETWORK_RETRIES, ek as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, s as ZapierAbortDrainSignal, c7 as ZapierActionError, c0 as ZapierApiError, c1 as ZapierAppNotFoundError, cc as ZapierApprovalError, b_ as ZapierAuthenticationError, c5 as ZapierBundleError, dG as ZapierCache, dH as ZapierCacheEntry, dI as ZapierCacheSetOptions, c4 as ZapierConfigurationError, c8 as ZapierConflictError, bX as ZapierError, c2 as ZapierNotFoundError, ca as ZapierRateLimitError, cd as ZapierRelayError, t as ZapierReleaseTriggerMessageSignal, c3 as ZapierResourceNotFoundError, cg as ZapierSignal, c6 as ZapierTimeoutError, bZ as ZapierUnknownError, bY as ZapierValidationError, d6 as actionKeyResolver, d5 as actionTypeResolver, a5 as addPlugin, d2 as apiPlugin, d4 as appKeyResolver, ch as appsPlugin, d8 as authenticationIdGenericResolver, d7 as authenticationIdResolver, al as batch, eZ as buildApplicationLifecycleEvent, an as buildCapabilityMessage, e$ as buildErrorEvent, e_ as buildErrorEventWithContext, f1 as buildMethodCalledEvent, eR as cleanupEventListeners, dy as clearTokenCache, dc as clientCredentialsNameResolver, dd as clientIdResolver, aJ as composePlugins, d8 as connectionIdGenericResolver, d7 as connectionIdResolver, ec as connectionsPlugin, f0 as createBaseEvent, cB as createClientCredentialsPlugin, a4 as createCorePlugin, a2 as createFunction, dJ as createMemoryCache, au as createOptionsPlugin, aI as createPaginatedPluginMethod, aH as createPluginMethod, a3 as createPluginStack, at as createSdk, eD as createTableFieldsPlugin, ex as createTablePlugin, eL as createTableRecordsPlugin, aQ as createZapierApi, av as createZapierCoreStack, as as createZapierSdkWithoutRegistry, aG as definePlugin, cD as deleteClientCredentialsPlugin, eF as deleteTableFieldsPlugin, ez as deleteTablePlugin, eN as deleteTableRecordsPlugin, dh as durableRunIdResolver, eT as eventEmissionPlugin, cl as fetchPlugin, cL as findFirstConnectionPlugin, cN as findUniqueConnectionPlugin, ce as formatErrorMessage, f4 as generateEventId, cv as getActionInputFieldsSchemaPlugin, cH as getActionPlugin, aM as getAgent, cF as getAppPlugin, d$ as getBaseUrlFromCredentials, ag as getCallerContext, fa as getCiPlatform, e0 as getClientIdFromCredentials, cJ as getConnectionPlugin, aB as getCoreErrorCause, aA as getCoreErrorCode, fc as getCpuTime, f5 as getCurrentTimestamp, fb as getMemoryUsage, aR as getOrCreateApiClient, f7 as getOsInfo, f8 as getPlatformVersions, cW as getPreferredManifestEntryKey, c$ as getProfilePlugin, f6 as getReleaseId, ev as getTablePlugin, eH as getTableRecordPlugin, dC as getTokenFromCliLogin, fd as getTtyContext, eo as getZapierApprovalMode, eq as getZapierDefaultApprovalMode, ep as getZapierOpenAutoModeApprovalsInBrowser, ef as getZapierSdkService, dA as injectCliLogin, db as inputFieldKeyResolver, da as inputsAllOptionalResolver, d9 as inputsResolver, dz as invalidateCachedToken, dF as invalidateCredentialsToken, f9 as isCi, dB as isCliLoginAvailable, dU as isClientCredentials, az as isCoreError, dX as isCredentialsFunction, dW as isCredentialsObject, aS as isPermanentHttpError, dV as isPkceCredentials, a1 as isPositional, ct as listActionInputFieldChoicesPlugin, cr as listActionInputFieldsPlugin, cp as listActionsPlugin, cn as listAppsPlugin, cz as listClientCredentialsPlugin, cx as listConnectionsPlugin, eB as listTableFieldsPlugin, eJ as listTableRecordsPlugin, et as listTablesPlugin, ao as logDeprecation, cX as manifestPlugin, em as parseConcurrencyEnvVar, aN as registryPlugin, cT as requestPlugin, ap as resetDeprecationWarnings, dD as resolveAuth, dE as resolveAuthToken, d_ as resolveCredentials, dZ as resolveCredentialsFromEnv, cR as runActionPlugin, ae as runInMethodScope, ah as runWithCallerContext, af as runWithTelemetryContext, dn as tableFieldIdsResolver, dq as tableFieldsResolver, dt as tableFiltersResolver, de as tableIdResolver, dp as tableNameResolver, dl as tableRecordIdResolver, dm as tableRecordIdsResolver, dr as tableRecordsResolver, du as tableSortResolver, ds as tableUpdateRecordsResolver, aj as toSnakeCase, ak as toTitleCase, df as triggerInboxResolver, dk as triggerMessagesResolver, eP as updateTableRecordsPlugin, dg as workflowIdResolver, dj as workflowRunIdResolver, di as workflowVersionIdResolver, b$ as zapierAdaptError } from './index-BZShISEr.mjs';
3
3
  import * as zod_v4_core from 'zod/v4/core';
4
4
  import * as zod from 'zod';
5
5
  import '@zapier/zapier-sdk-core/v0/schemas/connections';
@@ -3162,9 +3162,9 @@ declare function createZapierSdkStack(options?: ZapierSdkOptions): PluginStack<o
3162
3162
  input?: unknown;
3163
3163
  } | undefined) => Promise<{
3164
3164
  data: {
3165
- workflow: string;
3166
- status: number;
3167
- body: unknown;
3165
+ id: string;
3166
+ workflow_id: string;
3167
+ created_at: string;
3168
3168
  };
3169
3169
  }>;
3170
3170
  } & {
@@ -6365,9 +6365,9 @@ declare function createZapierSdk(options?: ZapierSdkOptions): WithAddPlugin<obje
6365
6365
  input?: unknown;
6366
6366
  } | undefined) => Promise<{
6367
6367
  data: {
6368
- workflow: string;
6369
- status: number;
6370
- body: unknown;
6368
+ id: string;
6369
+ workflow_id: string;
6370
+ created_at: string;
6371
6371
  };
6372
6372
  }>;
6373
6373
  } & {
@@ -3177,9 +3177,9 @@ export declare function createZapierSdkStack(options?: ZapierSdkOptions): import
3177
3177
  input?: unknown;
3178
3178
  } | undefined) => Promise<{
3179
3179
  data: {
3180
- workflow: string;
3181
- status: number;
3182
- body: unknown;
3180
+ id: string;
3181
+ workflow_id: string;
3182
+ created_at: string;
3183
3183
  };
3184
3184
  }>;
3185
3185
  } & {
@@ -6380,9 +6380,9 @@ export declare function createZapierSdk(options?: ZapierSdkOptions): import("kit
6380
6380
  input?: unknown;
6381
6381
  } | undefined) => Promise<{
6382
6382
  data: {
6383
- workflow: string;
6384
- status: number;
6385
- body: unknown;
6383
+ id: string;
6384
+ workflow_id: string;
6385
+ created_at: string;
6386
6386
  };
6387
6387
  }>;
6388
6388
  } & {
@@ -3218,6 +3218,38 @@ function getCallerContext() {
3218
3218
  }
3219
3219
  }
3220
3220
 
3221
+ // src/utils/agent.ts
3222
+ var isTruthy = (value) => {
3223
+ const lower = value.toLowerCase();
3224
+ return lower === "1" || lower === "true";
3225
+ };
3226
+ var isNonEmpty = (value) => value !== "";
3227
+ var agentDetectors = [
3228
+ { name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
3229
+ { name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
3230
+ { name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
3231
+ { name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
3232
+ { name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
3233
+ { name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
3234
+ { name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
3235
+ { name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
3236
+ ];
3237
+ function getAgent() {
3238
+ try {
3239
+ const env = globalThis.process?.env;
3240
+ if (!env) return null;
3241
+ for (const detector of agentDetectors) {
3242
+ const value = env[detector.key];
3243
+ if (value !== void 0 && detector.predicate(value)) {
3244
+ return detector.name;
3245
+ }
3246
+ }
3247
+ return null;
3248
+ } catch {
3249
+ return null;
3250
+ }
3251
+ }
3252
+
3221
3253
  // src/api/sse-parser.ts
3222
3254
  async function* jsonFrames(source) {
3223
3255
  for await (const { data } of source) {
@@ -3369,7 +3401,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
3369
3401
  }
3370
3402
 
3371
3403
  // src/sdk-version.ts
3372
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.76.1" : void 0) || "unknown";
3404
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.77.0" : void 0) || "unknown";
3373
3405
 
3374
3406
  // src/utils/open-url.ts
3375
3407
  var nodePrefix = "node:";
@@ -4087,6 +4119,10 @@ var ZapierApiClient = class {
4087
4119
  headers.set("zapier-service", sdkService);
4088
4120
  headers.set("x-zapier-service", sdkService);
4089
4121
  }
4122
+ const agent = getAgent();
4123
+ if (agent) {
4124
+ headers.set("zapier-sdk-agent", agent);
4125
+ }
4090
4126
  const callerPackage = this.options.callerPackage;
4091
4127
  if (callerPackage) {
4092
4128
  headers.set("zapier-sdk-package", callerPackage.name);
@@ -9600,36 +9636,6 @@ function getTtyContext() {
9600
9636
  return { stdin_is_tty: null, stdout_is_tty: null };
9601
9637
  }
9602
9638
  }
9603
- var isTruthy = (value) => {
9604
- const lower = value.toLowerCase();
9605
- return lower === "1" || lower === "true";
9606
- };
9607
- var isNonEmpty = (value) => value !== "";
9608
- var agentDetectors = [
9609
- { name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
9610
- { name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
9611
- { name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
9612
- { name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
9613
- { name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
9614
- { name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
9615
- { name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
9616
- { name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
9617
- ];
9618
- function getAgent() {
9619
- try {
9620
- const env = globalThis.process?.env;
9621
- if (!env) return null;
9622
- for (const detector of agentDetectors) {
9623
- const value = env[detector.key];
9624
- if (value !== void 0 && detector.predicate(value)) {
9625
- return detector.name;
9626
- }
9627
- }
9628
- return null;
9629
- } catch {
9630
- return null;
9631
- }
9632
- }
9633
9639
 
9634
9640
  // src/plugins/eventEmission/builders.ts
9635
9641
  function createBaseEvent(context = {}) {
@@ -13091,14 +13097,12 @@ var TriggerWorkflowOptionsSchema = z.object({
13091
13097
  "JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
13092
13098
  )
13093
13099
  }).describe(
13094
- "Look up a workflow's trigger URL and fire it manually. The trigger endpoint is tokenized (the URL contains a secret) and takes no auth header, so the SDK uses a raw fetch rather than the api plugin."
13100
+ "Look up a workflow's trigger URL and fire it manually, as the authenticated account."
13095
13101
  );
13096
13102
  var TriggerWorkflowResponseSchema = z.object({
13097
- workflow: z.string().describe("The workflow ID that was triggered"),
13098
- status: z.number().int().describe("HTTP status returned by the trigger endpoint"),
13099
- body: z.unknown().describe(
13100
- "Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
13101
- )
13103
+ id: z.string().describe("Trigger ID (UUID)"),
13104
+ workflow_id: z.string().describe("The workflow that was triggered (UUID)"),
13105
+ created_at: z.string().describe("When the trigger was received (ISO-8601)")
13102
13106
  });
13103
13107
 
13104
13108
  // src/plugins/codeSubstrate/triggerWorkflow/index.ts
@@ -13120,32 +13124,23 @@ var triggerWorkflowPlugin = definePlugin(
13120
13124
  }
13121
13125
  );
13122
13126
  const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
13123
- const fetch2 = sdk2.context.options.fetch ?? globalThis.fetch;
13124
- const response = await fetch2(workflow.trigger_url, {
13125
- method: "POST",
13126
- headers: { "Content-Type": "application/json" },
13127
- body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
13128
- });
13129
- const text = await response.text().catch(() => "");
13130
- let body = text;
13131
- if (text) {
13132
- try {
13133
- body = JSON.parse(text);
13134
- } catch {
13135
- body = text;
13136
- }
13137
- }
13138
- if (!response.ok) {
13127
+ const segments = new URL(workflow.trigger_url).pathname.split("/");
13128
+ const triggerToken = segments[segments.length - 1];
13129
+ if (!triggerToken) {
13139
13130
  throw new ZapierApiError(
13140
- `Trigger failed: ${response.status} ${response.statusText}: ${text || "(empty body)"}`,
13141
- { statusCode: response.status, response: body }
13131
+ `Workflow ${options.workflow} returned a malformed trigger_url`,
13132
+ { statusCode: 0, response: workflow.trigger_url }
13142
13133
  );
13143
13134
  }
13144
- const data = {
13145
- workflow: options.workflow,
13146
- status: response.status,
13147
- body
13148
- };
13135
+ const raw = await sdk2.context.api.post(
13136
+ `/durableworkflowzaps/api/v0/workflows/trigger/${encodeURIComponent(triggerToken)}`,
13137
+ options.input,
13138
+ {
13139
+ authRequired: true,
13140
+ resource: { type: "workflow", id: options.workflow }
13141
+ }
13142
+ );
13143
+ const data = TriggerWorkflowResponseSchema.parse(raw);
13149
13144
  return { data };
13150
13145
  }
13151
13146
  })