@membranehq/sdk 0.18.1 → 0.20.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.
Files changed (59) hide show
  1. package/dist/bundle.d.ts +203 -9
  2. package/dist/bundle.js +1078 -765
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/dts/accessors/connections-accessors.d.ts +8 -1
  5. package/dist/dts/accessors/integrations-accessors.d.ts +7 -0
  6. package/dist/dts/agent/session.d.ts +12 -2
  7. package/dist/dts/agent/worker-contracts.d.ts +4 -0
  8. package/dist/dts/auth/auth-context-permissions.d.ts +2 -0
  9. package/dist/dts/client-tokens/types.d.ts +1 -1
  10. package/dist/dts/functions/base.d.ts +1 -0
  11. package/dist/dts/functions/function-types/index.d.ts +2 -2
  12. package/dist/dts/functions/function-types/rest-api-mapping.d.ts +6 -6
  13. package/dist/dts/oauth/types.d.ts +1 -0
  14. package/dist/dts/oauth/types.test.d.ts +1 -0
  15. package/dist/dts/orgs/types.d.ts +5 -1
  16. package/dist/dts/ui.d.ts +5 -0
  17. package/dist/dts/validation/types.d.ts +1 -0
  18. package/dist/dts/workspace-elements/api/action-run-log-records-api.d.ts +32 -0
  19. package/dist/dts/workspace-elements/api/actions-api.d.ts +34 -0
  20. package/dist/dts/workspace-elements/api/app-data-schema-instances-api.d.ts +1 -0
  21. package/dist/dts/workspace-elements/api/connections-api.d.ts +52 -6
  22. package/dist/dts/workspace-elements/api/data-link-table-instances-api.d.ts +11 -0
  23. package/dist/dts/workspace-elements/api/data-sources-api.d.ts +44 -0
  24. package/dist/dts/workspace-elements/api/external-api-logs-api.d.ts +10 -0
  25. package/dist/dts/workspace-elements/api/external-event-log-records-api.d.ts +10 -0
  26. package/dist/dts/workspace-elements/api/external-event-pulls-api.d.ts +10 -0
  27. package/dist/dts/workspace-elements/api/external-event-subscriptions-api.d.ts +10 -0
  28. package/dist/dts/workspace-elements/api/field-mappings-api.d.ts +50 -0
  29. package/dist/dts/workspace-elements/api/flow-runs-api.d.ts +26 -0
  30. package/dist/dts/workspace-elements/api/flows-api.d.ts +44 -0
  31. package/dist/dts/workspace-elements/api/incoming-webhooks-api.d.ts +10 -0
  32. package/dist/dts/workspace-elements/api/integrations-api.d.ts +10 -0
  33. package/dist/dts/workspace-elements/api/packages-api.d.ts +12 -4
  34. package/dist/dts/workspace-elements/base/action-instances/index.d.ts +3 -0
  35. package/dist/dts/workspace-elements/base/actions/index.d.ts +10 -0
  36. package/dist/dts/workspace-elements/base/connection-requests/index.d.ts +8 -1
  37. package/dist/dts/workspace-elements/base/connections/index.d.ts +27 -0
  38. package/dist/dts/workspace-elements/base/connectors/index.d.ts +1 -1
  39. package/dist/dts/workspace-elements/base/data-sources/index.d.ts +13 -0
  40. package/dist/dts/workspace-elements/base/field-mappings/index.d.ts +10 -0
  41. package/dist/dts/workspace-elements/base/flows/index.d.ts +10 -0
  42. package/dist/dts/workspace-elements/base/integrations/index.d.ts +1 -1
  43. package/dist/dts/workspace-elements/base/packages/index.d.ts +7 -2
  44. package/dist/dts/workspace-elements/types.d.ts +13 -0
  45. package/dist/dts/workspace-elements-catalog/index.d.ts +3 -0
  46. package/dist/dts/workspaces/types.d.ts +6 -0
  47. package/dist/index.browser.d.mts +601 -100
  48. package/dist/index.browser.d.ts +601 -100
  49. package/dist/index.browser.js +244 -107
  50. package/dist/index.browser.js.map +1 -1
  51. package/dist/index.browser.mjs +236 -108
  52. package/dist/index.browser.mjs.map +1 -1
  53. package/dist/index.node.d.mts +601 -100
  54. package/dist/index.node.d.ts +601 -100
  55. package/dist/index.node.js +244 -107
  56. package/dist/index.node.js.map +1 -1
  57. package/dist/index.node.mjs +236 -108
  58. package/dist/index.node.mjs.map +1 -1
  59. package/package.json +1 -1
@@ -3411,6 +3411,13 @@ function getFormula(value) {
3411
3411
  return undefined;
3412
3412
  }
3413
3413
 
3414
+ const zodDateCoercion = () => z.z.preprocess((val) => {
3415
+ if (val instanceof Date)
3416
+ return val.toISOString();
3417
+ if (typeof val === 'number')
3418
+ return new Date(val).toISOString();
3419
+ return val;
3420
+ }, z.z.string().transform((s) => new Date(s)));
3414
3421
  const zodBooleanCoercion = () => z.z.preprocess((val) => {
3415
3422
  if (typeof val === 'boolean')
3416
3423
  return val;
@@ -3428,8 +3435,8 @@ const zodBooleanCoercion = () => z.z.preprocess((val) => {
3428
3435
  }, z.z.boolean());
3429
3436
 
3430
3437
  const PaginationQuery = z.z.object({
3431
- limit: z.z.coerce.number().int().min(1).max(1000).optional(),
3432
- cursor: z.z.string().optional(),
3438
+ limit: z.z.coerce.number().int().min(1).max(1000).optional().describe('Maximum number of items to return (1-1000)'),
3439
+ cursor: z.z.string().optional().describe('Pagination cursor from a previous response'),
3433
3440
  });
3434
3441
  function createPaginationResponseSchema(itemSchema) {
3435
3442
  return z.z.object({
@@ -3443,7 +3450,7 @@ const IncludeArchivedQuery = z.z.object({
3443
3450
  includeArchived: zodBooleanCoercion().optional(),
3444
3451
  });
3445
3452
  const SearchQuery = z.z.object({
3446
- search: z.z.string().optional(),
3453
+ search: z.z.string().optional().describe('Text search query to filter results'),
3447
3454
  });
3448
3455
  const CommonListElementsQuery = SearchQuery.merge(PaginationQuery).merge(IncludeArchivedQuery);
3449
3456
  const CommonFindElementsQuery = CommonListElementsQuery;
@@ -3515,6 +3522,8 @@ exports.WorkspaceEventType = void 0;
3515
3522
  })(exports.WorkspaceEventType || (exports.WorkspaceEventType = {}));
3516
3523
  exports.WorkspaceElementState = void 0;
3517
3524
  (function (WorkspaceElementState) {
3525
+ WorkspaceElementState["BUILDING"] = "BUILDING";
3526
+ WorkspaceElementState["CLIENT_ACTION_REQUIRED"] = "CLIENT_ACTION_REQUIRED";
3518
3527
  WorkspaceElementState["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
3519
3528
  WorkspaceElementState["SETUP_FAILED"] = "SETUP_FAILED";
3520
3529
  WorkspaceElementState["READY"] = "READY";
@@ -3546,7 +3555,7 @@ const BaseMembraneInterfaceReadOnlyProperties = z.z.object({
3546
3555
  state: z.z
3547
3556
  .enum(exports.WorkspaceElementState)
3548
3557
  .optional()
3549
- .describe('Current lifecycle or health state (e.g. READY, SETUP_FAILED, CONFIGURATION_ERROR). Set by the engine during setup and validation.'),
3558
+ .describe('Current lifecycle or health state (e.g. READY, SETUP_FAILED, CONFIGURATION_ERROR, BUILDING). Set by the engine during setup and validation.'),
3550
3559
  errors: z.z.array(ErrorDataSchema).optional().describe('Validation or setup errors when state is not READY.'),
3551
3560
  revision: z.z
3552
3561
  .string()
@@ -3568,6 +3577,12 @@ const BaseMembraneInterfaceReadOnlyProperties = z.z.object({
3568
3577
  .describe('When true, the element cannot be modified (e.g. published package elements or elements from another workspace).'),
3569
3578
  });
3570
3579
  const BaseMembraneInterface = BaseWorkspaceElement.merge(BaseMembraneInterfaceEditableProperties).merge(BaseMembraneInterfaceReadOnlyProperties);
3580
+ const IntentProperties = z.z.object({
3581
+ intent: z.z
3582
+ .string()
3583
+ .optional()
3584
+ .describe('[Experimental] Intent-based instruction for an agent to configure this element.'),
3585
+ });
3571
3586
  const BaseIntegrationLevelMembraneInterfaceEditableProperties = BaseMembraneInterfaceEditableProperties.extend({
3572
3587
  integrationId: z.z
3573
3588
  .string()
@@ -3605,6 +3620,18 @@ const BaseIntegrationLevelMembraneInterfaceEditableProperties = BaseMembraneInte
3605
3620
  .boolean()
3606
3621
  .optional()
3607
3622
  .describe('When true, the element is universal (shared across all integrations). Requires universal-element access. Omit or false for integration-specific elements.'),
3623
+ externalAppId: z.z
3624
+ .string()
3625
+ .optional()
3626
+ .describe('Internal ID of the external app this element belongs to. Auto-populated from the integration when integrationId is set and the integration has an externalAppId.'),
3627
+ externalAppUuid: z.z
3628
+ .string()
3629
+ .optional()
3630
+ .describe('UUID of the external app; alternative to externalAppId when creating from export. Resolved to externalAppId by the API.'),
3631
+ externalAppKey: z.z
3632
+ .string()
3633
+ .optional()
3634
+ .describe('Key of the external app; alternative to externalAppId. Resolved to externalAppId by the API.'),
3608
3635
  });
3609
3636
  const BaseIntegrationLevelMembraneInterfaceReadOnlyProperties = BaseMembraneInterfaceReadOnlyProperties.extend({
3610
3637
  isCustomized: z.z.boolean().optional(),
@@ -3612,6 +3639,7 @@ const BaseIntegrationLevelMembraneInterfaceReadOnlyProperties = BaseMembraneInte
3612
3639
  const BaseIntegrationLevelMembraneInterfaceExportProperties = BaseMembraneInterfaceEditableProperties.extend({
3613
3640
  integrationUuid: z.z.string().optional(),
3614
3641
  parentUuid: z.z.string().optional(),
3642
+ externalAppUuid: z.z.string().optional(),
3615
3643
  isCustomized: z.z.boolean().optional(),
3616
3644
  isUniversal: z.z.boolean().optional(),
3617
3645
  });
@@ -3936,6 +3964,10 @@ const ActionExportProperties = BaseIntegrationLevelMembraneInterfaceExportProper
3936
3964
  });
3937
3965
  const ActionReadOnlyProperties = BaseIntegrationLevelMembraneInterfaceReadOnlyProperties.extend({
3938
3966
  ...TenantLayerElement.partial().shape,
3967
+ agentSessionId: z.z
3968
+ .string()
3969
+ .optional()
3970
+ .describe('[INTERNAL] ID of the agent session building this action. Present when the action was created or updated with an intent.'),
3939
3971
  universalParentId: z.z
3940
3972
  .string()
3941
3973
  .optional()
@@ -3957,9 +3989,11 @@ const BaseAction = BaseMembraneInterface.merge(ActionEditableProperties).merge(A
3957
3989
  const BaseActionInstance = BaseAction;
3958
3990
 
3959
3991
  const CONNECTION_REQUEST_SCREEN_PATH = 'screens/connect';
3992
+ const AGENTIC_CONNECTION_REQUEST_SCREEN_PATH = 'screens/connections';
3960
3993
  const CONNECTION_REQUEST_ID_PARAM = 'connectionRequestId';
3961
- function getConnectionRequestUrl(baseUri, requestId) {
3962
- return `${baseUri}/${CONNECTION_REQUEST_SCREEN_PATH}?${CONNECTION_REQUEST_ID_PARAM}=${requestId}`;
3994
+ function getConnectionRequestUrl(baseUri, requestId, options) {
3995
+ const screenPath = (options === null || options === void 0 ? void 0 : options.prompt) ? AGENTIC_CONNECTION_REQUEST_SCREEN_PATH : CONNECTION_REQUEST_SCREEN_PATH;
3996
+ return `${baseUri}/${screenPath}?${CONNECTION_REQUEST_ID_PARAM}=${requestId}`;
3963
3997
  }
3964
3998
  const CreateConnectionRequestPayload = z.z.object({
3965
3999
  integrationId: z.z.string().optional(),
@@ -3972,7 +4006,9 @@ const CreateConnectionRequestPayload = z.z.object({
3972
4006
  allowMultipleConnections: z.z.boolean().optional(),
3973
4007
  connectorParameters: z.z.record(z.z.string(), z.z.unknown()).optional(),
3974
4008
  redirectUri: z.z.string().url().optional(),
4009
+ prompt: z.z.string().optional(),
3975
4010
  });
4011
+ const PatchConnectionRequestPayload = z.z.object({});
3976
4012
  const ConnectionRequest = z.z.object({
3977
4013
  requestId: z.z.string(),
3978
4014
  tenantId: z.z.string(),
@@ -3986,6 +4022,7 @@ const ConnectionRequest = z.z.object({
3986
4022
  allowMultipleConnections: z.z.boolean().optional(),
3987
4023
  connectorParameters: z.z.record(z.z.string(), z.z.unknown()).optional(),
3988
4024
  redirectUri: z.z.string().url().optional(),
4025
+ prompt: z.z.string().optional(),
3989
4026
  status: z.z.enum(['pending', 'success', 'cancelled', 'error']),
3990
4027
  resultConnectionId: z.z.string().optional(),
3991
4028
  resultError: ErrorDataSchema.optional(),
@@ -3997,12 +4034,25 @@ const ConnectionEditableProperties = z.z.object({
3997
4034
  name: z.z.string().optional(),
3998
4035
  meta: z.z.record(z.z.string(), z.z.any()).optional(),
3999
4036
  authOptionKey: z.z.string().optional(),
4037
+ integrationId: z.z.string().optional(),
4038
+ integrationUuid: z.z.string().optional(),
4039
+ integrationKey: z.z.string().optional(),
4040
+ connectorId: z.z.string().optional(),
4041
+ connectorUuid: z.z.string().optional(),
4042
+ connectorKey: z.z.string().optional(),
4043
+ connectorVersion: z.z.string().optional(),
4000
4044
  externalAppId: z.z.string().optional(),
4001
4045
  externalAppUuid: z.z.string().optional(),
4002
4046
  credentials: z.z.unknown().optional(),
4003
4047
  connectorParameters: z.z.unknown().optional(),
4004
4048
  input: z.z.unknown().optional(),
4005
4049
  });
4050
+ const ConnectionClientAction = z.z.object({
4051
+ type: z.z.enum(['connect', 'provide-input']),
4052
+ description: z.z.string(),
4053
+ uiUrl: z.z.string().optional(),
4054
+ agentInstructions: z.z.string().optional(),
4055
+ });
4006
4056
  const BaseConnection = BaseWorkspaceElement.extend({
4007
4057
  ...TenantLayerElement.shape,
4008
4058
  name: z.z.string(),
@@ -4027,6 +4077,11 @@ const BaseConnection = BaseWorkspaceElement.extend({
4027
4077
  archivedAt: z.z.string().optional(),
4028
4078
  isDeactivated: z.z.boolean().optional(),
4029
4079
  meta: z.z.record(z.z.string(), z.z.any()).optional(),
4080
+ buildingAgentSessionId: z.z
4081
+ .string()
4082
+ .optional()
4083
+ .describe('Session ID for building the element via intent-based endpoints (create/update with intent). Present when state is BUILDING.'),
4084
+ clientAction: ConnectionClientAction.optional().describe('Action the client must perform to advance this connection. Present if and only if state is CLIENT_ACTION_REQUIRED.'),
4030
4085
  });
4031
4086
  class ConnectionSpec {
4032
4087
  constructor(opts) {
@@ -4056,6 +4111,35 @@ const GenericFunctionDefinition = z.z
4056
4111
  type: z.z.enum(['mapping', 'operation-mapping', 'rest-api-mapping', 'graphql-api-mapping', 'javascript']).optional(),
4057
4112
  })
4058
4113
  .loose();
4114
+ function validateFunctionDefinitions(functions, schema) {
4115
+ const errors = [];
4116
+ for (const [name, funcDef] of Object.entries(functions)) {
4117
+ const result = schema.safeParse(funcDef);
4118
+ if (!result.success) {
4119
+ errors.push(`"${name}": ${formatZodUnionError(result.error, funcDef)}`);
4120
+ }
4121
+ }
4122
+ if (errors.length > 0) {
4123
+ throw new BadRequestError(`Invalid function definition(s): ${errors.join('; ')}`);
4124
+ }
4125
+ }
4126
+ function formatZodUnionError(error, funcDef) {
4127
+ for (const issue of error.issues) {
4128
+ const branchErrors = issue.errors;
4129
+ if (issue.code === 'invalid_union' && branchErrors) {
4130
+ const type = funcDef.type;
4131
+ if (type) {
4132
+ for (const branchIssues of branchErrors) {
4133
+ const hasTypeError = branchIssues.some((i) => i.path.includes('type') && i.code === 'invalid_type');
4134
+ if (!hasTypeError) {
4135
+ return branchIssues.map((i) => `${i.path.join('.') || 'root'}: ${i.message}`).join('; ');
4136
+ }
4137
+ }
4138
+ }
4139
+ }
4140
+ }
4141
+ return error.issues.map((i) => `${i.path.join('.') || 'root'}: ${i.message}`).join('; ');
4142
+ }
4059
4143
 
4060
4144
  const GraphQLFieldMappingSchema = z.z.lazy(() => z.z.object({
4061
4145
  field: z.z.string(),
@@ -4103,13 +4187,13 @@ const RequestMappingSchema = z.z.object({
4103
4187
  const RestApiMappingSchema = z.z.object({
4104
4188
  path: z.z.string(),
4105
4189
  method: z.z.string(),
4106
- requestMapping: RequestMappingSchema,
4190
+ requestMapping: RequestMappingSchema.optional(),
4107
4191
  responseMapping: z.z.any().optional(),
4108
4192
  });
4109
4193
  const OpenapiMappingSchema = z.z.object({
4110
4194
  path: z.z.string(),
4111
4195
  method: z.z.string(),
4112
- requestMapping: RequestMappingSchema,
4196
+ requestMapping: RequestMappingSchema.optional(),
4113
4197
  responseMapping: z.z.any().optional(),
4114
4198
  });
4115
4199
  const RestApiMappingFunction = z.z.object({
@@ -8113,7 +8197,7 @@ const DataCollectionMethodCreate = {
8113
8197
  }),
8114
8198
  };
8115
8199
  },
8116
- getOutputSchema: ({}) => ({
8200
+ getOutputSchema: (_) => ({
8117
8201
  type: 'object',
8118
8202
  properties: {
8119
8203
  id: { type: 'string' },
@@ -8379,7 +8463,7 @@ const DataCollectionMethodUpdate = {
8379
8463
  }),
8380
8464
  };
8381
8465
  },
8382
- getOutputSchema: ({}) => ({
8466
+ getOutputSchema: (_) => ({
8383
8467
  type: 'object',
8384
8468
  properties: {
8385
8469
  id: { type: 'string' },
@@ -8396,7 +8480,7 @@ const GetEventConfig = {
8396
8480
  parameters: collection.parametersSchema,
8397
8481
  },
8398
8482
  }),
8399
- getOutputSchema: ({}) => ({
8483
+ getOutputSchema: (_) => ({
8400
8484
  type: 'object',
8401
8485
  properties: {
8402
8486
  eventKey: {
@@ -8415,7 +8499,7 @@ const GetEventConfig = {
8415
8499
  };
8416
8500
  const ExtractEventsMethod = {
8417
8501
  fileKey: 'connector-event-extract-events',
8418
- getInputSchema: ({}) => ({
8502
+ getInputSchema: (_) => ({
8419
8503
  type: 'object',
8420
8504
  properties: {
8421
8505
  events: {
@@ -8457,7 +8541,7 @@ const SubscribeMethod = {
8457
8541
  parameters: collection.parametersSchema,
8458
8542
  },
8459
8543
  }),
8460
- getOutputSchema: ({}) => ({}),
8544
+ getOutputSchema: (_) => ({}),
8461
8545
  supportedImplementationTypes: [exports.ConnectorMethodImplementationType.javascript],
8462
8546
  };
8463
8547
  const CollectEventsMethod = {
@@ -9883,7 +9967,6 @@ const PackageElementExport = z.z.object({
9883
9967
  });
9884
9968
  const PackageEditableProperties = BaseIntegrationLevelMembraneInterfaceEditableProperties.extend({
9885
9969
  scenarioTemplateId: z.z.string().optional(),
9886
- externalAppId: z.z.string().optional(),
9887
9970
  elements: z.z.array(PackageElement).optional(),
9888
9971
  });
9889
9972
  const PackageExportProperties = BaseIntegrationLevelMembraneInterfaceExportProperties.extend({
@@ -10235,12 +10318,12 @@ const FindActionsQuery = FindIntegrationLevelMembraneInterfaceQuery.extend({
10235
10318
  .optional()
10236
10319
  .meta({ hidden: true }),
10237
10320
  });
10238
- const CreateActionRequest = ActionEditableProperties;
10321
+ const CreateActionRequest = ActionEditableProperties.merge(IntentProperties);
10239
10322
  const UpdateActionRequest = CreateActionRequest.partial();
10240
10323
  const CreateActionInstanceRequest = CreateActionRequest;
10241
10324
  const UpdateActionInstanceRequest = UpdateActionRequest;
10242
10325
  const RunActionRequest = z.z.object({
10243
- input: z.z.any().optional(),
10326
+ input: z.z.any().optional().describe('Input data for the action, matching the action inputSchema'),
10244
10327
  meta: z.z.record(z.z.string(), z.z.any()).optional(),
10245
10328
  });
10246
10329
  const ActionRunResponse = z.z.object({
@@ -10333,6 +10416,7 @@ const FindConnectionsQuery = PaginationQuery.merge(SearchQuery)
10333
10416
  integrationId: z.z
10334
10417
  .string()
10335
10418
  .optional()
10419
+ .describe('Filter by integration ID')
10336
10420
  .meta({
10337
10421
  filterTitle: 'Integration',
10338
10422
  referenceElementType: exports.WorkspaceElementType.Integration,
@@ -10340,6 +10424,7 @@ const FindConnectionsQuery = PaginationQuery.merge(SearchQuery)
10340
10424
  connectorId: z.z
10341
10425
  .string()
10342
10426
  .optional()
10427
+ .describe('Filter by connector ID')
10343
10428
  .meta({
10344
10429
  filterTitle: 'Connector',
10345
10430
  }),
@@ -10378,20 +10463,24 @@ const FindConnectionsQuery = PaginationQuery.merge(SearchQuery)
10378
10463
  .optional()
10379
10464
  .meta({ hidden: true }),
10380
10465
  });
10381
- const CreateConnectionRequest = ConnectionEditableProperties.extend({
10382
- integrationId: z.z.string().optional(),
10383
- integrationUuid: z.z.string().optional(),
10384
- integrationKey: z.z.string().optional(),
10385
- connectorId: z.z.string().optional(),
10386
- connectorUuid: z.z.string().optional(),
10387
- connectorKey: z.z.string().optional(),
10388
- connectorVersion: z.z.string().optional(),
10466
+ const EnsureConnectionRequest = z.z.object({
10467
+ intent: z.z.string().min(1).max(200),
10468
+ name: z.z
10469
+ .string()
10470
+ .optional()
10471
+ .describe('Custom name for the connection. Only used when a new connection is created; ignored if an existing one is returned.'),
10389
10472
  });
10390
- const UpdateConnectionRequest = ConnectionEditableProperties;
10473
+ const CreateConnectionRequest = ConnectionEditableProperties.merge(IntentProperties);
10474
+ const UpdateConnectionRequest = ConnectionEditableProperties.merge(IntentProperties);
10391
10475
  const ConnectionExportProperties = ConnectionEditableProperties.omit({
10392
10476
  credentials: true,
10393
10477
  connectorParameters: true,
10394
10478
  input: true,
10479
+ integrationId: true,
10480
+ integrationKey: true,
10481
+ connectorId: true,
10482
+ connectorKey: true,
10483
+ connectorVersion: true,
10395
10484
  externalAppId: true,
10396
10485
  });
10397
10486
  const ConnectionTestResponse = z.z.object({
@@ -10944,7 +11033,7 @@ const FindDataLinkTableInstancesQuery = PaginationQuery.extend({
10944
11033
  .meta({
10945
11034
  filterTitle: 'Instance Key',
10946
11035
  }),
10947
- });
11036
+ }).merge(IncludeArchivedQuery);
10948
11037
  const FindDataLinksInTableQuery = PaginationQuery.extend({
10949
11038
  direction: z.z.enum(exports.DataLinkDirection).optional(),
10950
11039
  appRecordId: z.z.string().optional(),
@@ -11068,7 +11157,7 @@ const FindAppDataSchemaInstancesQuery = PaginationQuery.extend({
11068
11157
  .meta({
11069
11158
  filterTitle: 'Instance Key',
11070
11159
  }),
11071
- });
11160
+ }).merge(IncludeArchivedQuery);
11072
11161
  const AppDataSchemaInstanceApiResponse = BaseAppDataSchema.extend({
11073
11162
  user: BaseCustomer.optional(),
11074
11163
  appDataSchema: BaseAppDataSchema.optional(),
@@ -11717,6 +11806,87 @@ function getFilterFieldMeta(meta) {
11717
11806
  return undefined;
11718
11807
  }
11719
11808
 
11809
+ exports.AgentSessionStatus = void 0;
11810
+ (function (AgentSessionStatus) {
11811
+ AgentSessionStatus["QUEUED"] = "queued";
11812
+ AgentSessionStatus["STARTING"] = "starting";
11813
+ AgentSessionStatus["RUNNING"] = "running";
11814
+ AgentSessionStatus["COMPLETED"] = "completed";
11815
+ AgentSessionStatus["FAILED"] = "failed";
11816
+ AgentSessionStatus["CANCELLED"] = "cancelled";
11817
+ })(exports.AgentSessionStatus || (exports.AgentSessionStatus = {}));
11818
+ exports.AgentSessionState = void 0;
11819
+ (function (AgentSessionState) {
11820
+ AgentSessionState["BUSY"] = "busy";
11821
+ AgentSessionState["IDLE"] = "idle";
11822
+ })(exports.AgentSessionState || (exports.AgentSessionState = {}));
11823
+ exports.AgentName = void 0;
11824
+ (function (AgentName) {
11825
+ AgentName["MEMBRANE"] = "membrane";
11826
+ AgentName["MEMBRANE_CORE"] = "membrane-core";
11827
+ AgentName["SELF_INTEGRATING"] = "self-integrating";
11828
+ AgentName["CONNECTION_BUILDING"] = "connection-building";
11829
+ AgentName["ACTION_BUILDING"] = "action-building";
11830
+ AgentName["UNIVERSE"] = "universe";
11831
+ })(exports.AgentName || (exports.AgentName = {}));
11832
+ const AgentSession = z.z.object({
11833
+ ...TenantLayerElement.partial().shape,
11834
+ id: z.z.string(),
11835
+ workspaceId: z.z.string(),
11836
+ orgWorkspaceId: z.z.string().optional(),
11837
+ workspaceElementType: z.z.enum(exports.WorkspaceElementType),
11838
+ workspaceElementId: z.z.string(),
11839
+ type: z.z.string(),
11840
+ status: z.z.enum(exports.AgentSessionStatus),
11841
+ prompt: z.z.string(),
11842
+ error: ErrorDataSchema.optional(),
11843
+ lastActivityAt: z.z.iso
11844
+ .datetime()
11845
+ .describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
11846
+ title: z.z.string().optional(),
11847
+ summary: z.z.string().optional(),
11848
+ cost: z.z.number().optional(),
11849
+ state: z.z.enum(exports.AgentSessionState).default(exports.AgentSessionState.BUSY),
11850
+ usage: z.z.number().optional(),
11851
+ hasWorker: z.z.boolean(),
11852
+ isExternal: z.z.boolean().optional(),
11853
+ agentName: z.z.enum(exports.AgentName).optional(),
11854
+ output: z.z.record(z.z.string(), z.z.unknown()).optional(),
11855
+ createdAt: z.z.iso.datetime(),
11856
+ updatedAt: z.z.iso.datetime(),
11857
+ });
11858
+ const CreateAgentSession = z.z.object({
11859
+ workspaceElementType: z.z.enum(exports.WorkspaceElementType).optional(),
11860
+ workspaceElementId: z.z.string().min(1).optional(),
11861
+ prompt: z.z.string().min(1),
11862
+ testCustomerId: z.z.string().optional(),
11863
+ isExternal: z.z.boolean().optional(),
11864
+ modelId: z.z.string().optional(),
11865
+ agentName: z.z.enum(exports.AgentName).optional(),
11866
+ });
11867
+ const AgentSessionAttachment = z.z.object({
11868
+ title: z.z.string(),
11869
+ data: z.z.unknown(),
11870
+ });
11871
+ const AgentSessionInputSchema = z.z.object({
11872
+ input: z.z.string().min(1),
11873
+ synthetic: z.z.boolean().optional(),
11874
+ attachments: z.z.array(AgentSessionAttachment).optional(),
11875
+ });
11876
+ const PatchAgentSessionSchema = z.z.object({
11877
+ state: z.z.enum(exports.AgentSessionState).optional(),
11878
+ lastActivityAt: zodDateCoercion()
11879
+ .optional()
11880
+ .describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
11881
+ title: z.z.string().optional(),
11882
+ summary: z.z.string().optional(),
11883
+ cost: z.z.number().optional(),
11884
+ error: ErrorDataSchema.optional(),
11885
+ opencodeSessionUuid: z.z.string().optional(),
11886
+ output: z.z.record(z.z.string(), z.z.unknown()).optional(),
11887
+ status: z.z.enum(exports.AgentSessionStatus).optional(),
11888
+ });
11889
+
11720
11890
  const SYSTEM_FIELDS = ['updatedAt', 'createdAt', 'revision', '__v', '_id', 'id'];
11721
11891
  function jsonPointerToDotPath(pointer) {
11722
11892
  if (!pointer || pointer === '/')
@@ -11877,6 +12047,8 @@ const WorkspaceElementSpecs = {
11877
12047
  exportPropertiesSchema: ConnectionExportProperties,
11878
12048
  hasKey: false,
11879
12049
  hasUuid: false,
12050
+ isAgentic: true,
12051
+ agentName: exports.AgentName.CONNECTION_BUILDING,
11880
12052
  statsKey: 'connections',
11881
12053
  relatedIntegrationLayerElements: [
11882
12054
  exports.WorkspaceElementType.Action,
@@ -11931,6 +12103,7 @@ const WorkspaceElementSpecs = {
11931
12103
  namePlural: 'Actions',
11932
12104
  parentFieldKey: 'parentId',
11933
12105
  editablePropertiesSchema: ActionEditableProperties,
12106
+ backwardCompatibleEditablePropertiesSchema: CreateActionRequest,
11934
12107
  exportPropertiesSchema: ActionExportProperties,
11935
12108
  apiResponseSchema: ActionApiResponse,
11936
12109
  findQuerySchema: FindActionsQuery,
@@ -11940,6 +12113,8 @@ const WorkspaceElementSpecs = {
11940
12113
  hasParentChildRelationship: true,
11941
12114
  hasKey: true,
11942
12115
  hasPublicLayer: true,
12116
+ isAgentic: true,
12117
+ agentName: exports.AgentName.ACTION_BUILDING,
11943
12118
  statsKey: 'actions',
11944
12119
  },
11945
12120
  [exports.WorkspaceElementType.ActionRunLogRecord]: {
@@ -12263,6 +12438,7 @@ const OrgPermissionsSchema = z.z.object({
12263
12438
  const WorkspacePermissionsSchema = z.z.object({
12264
12439
  workspaceId: z.z.string().optional(),
12265
12440
  isWorkspaceManager: z.z.boolean(),
12441
+ isReadOnly: z.z.boolean().default(false),
12266
12442
  scopes: z.z.array(z.z.string()),
12267
12443
  });
12268
12444
  const TenantPermissionsSchema = z.z.object({
@@ -13078,6 +13254,7 @@ const WorkspaceSettingsSchema = z.object({
13078
13254
  enableActionRunLogs: z.boolean().optional(),
13079
13255
  disableSecretKeyAuth: z.boolean().optional(),
13080
13256
  useMembraneUniverse: z.boolean().optional(),
13257
+ useInlineAgent: z.boolean().optional(),
13081
13258
  });
13082
13259
  const EngineWorkspaceSettingsSchema = WorkspaceSettingsSchema;
13083
13260
  const WorkspacePublicKey = z.object({
@@ -13112,6 +13289,7 @@ const Workspace = z.object({
13112
13289
  isThrottled: z.boolean().optional(),
13113
13290
  isDisabled: z.boolean().optional(),
13114
13291
  isBackgroundJobsDisabled: z.boolean().optional(),
13292
+ isReadOnly: z.boolean().optional(),
13115
13293
  lastExternalApiRequestDate: z.string().nullable().optional(),
13116
13294
  });
13117
13295
  const AppSchema = Workspace;
@@ -13320,6 +13498,7 @@ exports.OrgUserRole = void 0;
13320
13498
  (function (OrgUserRole) {
13321
13499
  OrgUserRole["Admin"] = "admin";
13322
13500
  OrgUserRole["Member"] = "member";
13501
+ OrgUserRole["ReadOnly"] = "read-only";
13323
13502
  })(exports.OrgUserRole || (exports.OrgUserRole = {}));
13324
13503
  exports.OrgUserStatus = void 0;
13325
13504
  (function (OrgUserStatus) {
@@ -14733,7 +14912,7 @@ class ConnectionAccessor {
14733
14912
  onPopupClosed,
14734
14913
  });
14735
14914
  }
14736
- async openReconnectUI({} = {}) {
14915
+ async openReconnectUI(_options = {}) {
14737
14916
  const uri = await this.client.getEmbedUri(`connections/${this.connectionSelector}/refresh`);
14738
14917
  return new Promise((resolve) => {
14739
14918
  void openIframe(uri, {
@@ -15475,83 +15654,6 @@ const ScenarioTemplate = z.z.object({
15475
15654
  handyElements: z.z.array(HandyScenarioTemplateElement).optional(),
15476
15655
  });
15477
15656
 
15478
- exports.AgentSessionStatus = void 0;
15479
- (function (AgentSessionStatus) {
15480
- AgentSessionStatus["QUEUED"] = "queued";
15481
- AgentSessionStatus["STARTING"] = "starting";
15482
- AgentSessionStatus["RUNNING"] = "running";
15483
- AgentSessionStatus["COMPLETED"] = "completed";
15484
- AgentSessionStatus["FAILED"] = "failed";
15485
- AgentSessionStatus["CANCELLED"] = "cancelled";
15486
- })(exports.AgentSessionStatus || (exports.AgentSessionStatus = {}));
15487
- exports.AgentSessionState = void 0;
15488
- (function (AgentSessionState) {
15489
- AgentSessionState["BUSY"] = "busy";
15490
- AgentSessionState["IDLE"] = "idle";
15491
- })(exports.AgentSessionState || (exports.AgentSessionState = {}));
15492
- exports.AgentName = void 0;
15493
- (function (AgentName) {
15494
- AgentName["MEMBRANE"] = "membrane";
15495
- AgentName["MEMBRANE_CORE"] = "membrane-core";
15496
- AgentName["SELF_INTEGRATING"] = "self-integrating";
15497
- AgentName["CONNECTION_BUILDING"] = "connection-building";
15498
- AgentName["ACTION_BUILDING"] = "action-building";
15499
- AgentName["UNIVERSE"] = "universe";
15500
- })(exports.AgentName || (exports.AgentName = {}));
15501
- const AgentSession = z.z.object({
15502
- id: z.z.string(),
15503
- workspaceId: z.z.string(),
15504
- orgWorkspaceId: z.z.string().optional(),
15505
- userId: z.z.string().optional(),
15506
- workspaceElementType: z.z.enum(exports.WorkspaceElementType),
15507
- workspaceElementId: z.z.string(),
15508
- type: z.z.string(),
15509
- status: z.z.enum(exports.AgentSessionStatus),
15510
- prompt: z.z.string(),
15511
- error: ErrorDataSchema.optional(),
15512
- lastActivityAt: z.z.iso
15513
- .datetime()
15514
- .describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
15515
- title: z.z.string().optional(),
15516
- summary: z.z.string().optional(),
15517
- cost: z.z.number().optional(),
15518
- state: z.z.enum(exports.AgentSessionState).default(exports.AgentSessionState.BUSY),
15519
- usage: z.z.number().optional(),
15520
- hasWorker: z.z.boolean(),
15521
- isExternal: z.z.boolean().optional(),
15522
- agentName: z.z.enum(exports.AgentName).optional(),
15523
- output: z.z.record(z.z.string(), z.z.unknown()).optional(),
15524
- createdAt: z.z.iso.datetime(),
15525
- updatedAt: z.z.iso.datetime(),
15526
- });
15527
- const CreateAgentSession = z.z.object({
15528
- workspaceElementType: z.z.enum(exports.WorkspaceElementType).optional(),
15529
- workspaceElementId: z.z.string().min(1).optional(),
15530
- prompt: z.z.string().min(1),
15531
- testCustomerId: z.z.string().optional(),
15532
- isExternal: z.z.boolean().optional(),
15533
- modelId: z.z.string().optional(),
15534
- agentName: z.z.enum(exports.AgentName).optional(),
15535
- });
15536
- const AgentSessionInputSchema = z.z.object({
15537
- input: z.z.string().min(1),
15538
- synthetic: z.z.boolean().optional(),
15539
- });
15540
- const PatchAgentSessionSchema = z.z.object({
15541
- state: z.z.enum(exports.AgentSessionState).optional(),
15542
- lastActivityAt: z.z.iso
15543
- .datetime()
15544
- .optional()
15545
- .describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
15546
- title: z.z.string().optional(),
15547
- summary: z.z.string().optional(),
15548
- cost: z.z.number().optional(),
15549
- error: ErrorDataSchema.optional(),
15550
- opencodeSessionUuid: z.z.string().optional(),
15551
- output: z.z.record(z.z.string(), z.z.unknown()).optional(),
15552
- status: z.z.enum(exports.AgentSessionStatus).optional(),
15553
- });
15554
-
15555
15657
  const SessionCredentials = z.z.object({
15556
15658
  accessKeyId: z.z.string().min(1),
15557
15659
  secretAccessKey: z.z.string().min(1),
@@ -15571,6 +15673,7 @@ const SessionParameters = z.z.object({
15571
15673
  openRouterApiKey: z.z.string().optional(),
15572
15674
  modelId: z.z.string().optional(),
15573
15675
  agentName: z.z.enum(exports.AgentName).optional(),
15676
+ engine: z.z.enum(['opencode', 'inline']).optional(),
15574
15677
  });
15575
15678
 
15576
15679
  exports.AsyncRequestStatus = void 0;
@@ -15631,7 +15734,7 @@ const CreateClientTokenRequest = z.z.object({
15631
15734
  grantId: z.z.string(),
15632
15735
  grantName: z.z.string(),
15633
15736
  tenantId: z.z.string().optional(),
15634
- productKey: z.z.string().optional(),
15737
+ clientKey: z.z.string().optional(),
15635
15738
  });
15636
15739
  const ClientTokenListResponse = z.z.object({
15637
15740
  items: z.z.array(ClientToken),
@@ -15641,6 +15744,19 @@ const MEMBRANE_CLI_CLIENT_ID = 'membrane-cli';
15641
15744
  const OAUTH_SCOPE_PLATFORM_USER = 'platform-user';
15642
15745
  const OAUTH_SCOPE_TENANT = 'tenant';
15643
15746
  const OAUTH_SCOPES = [OAUTH_SCOPE_PLATFORM_USER, OAUTH_SCOPE_TENANT];
15747
+ const SCOPE_PRIORITY = [OAUTH_SCOPE_PLATFORM_USER, OAUTH_SCOPE_TENANT];
15748
+ function selectHighestPriorityScope(scopes) {
15749
+ if (scopes.length === 0)
15750
+ return undefined;
15751
+ if (scopes.length === 1)
15752
+ return scopes[0];
15753
+ for (const priorityScope of SCOPE_PRIORITY) {
15754
+ if (scopes.includes(priorityScope)) {
15755
+ return priorityScope;
15756
+ }
15757
+ }
15758
+ return scopes[0];
15759
+ }
15644
15760
  const OAuthTokenResponse = z.z.object({
15645
15761
  access_token: z.z.string(),
15646
15762
  token_type: z.z.string(),
@@ -15662,7 +15778,7 @@ const DbBackedCountsSchema = z.z.object({
15662
15778
  eventLogs: PendingQueueCountSchema.describe('Created external event log records in MongoDB.'),
15663
15779
  });
15664
15780
  const PendingTasksSummarySchema = z.z.object({
15665
- instant: PendingQueueCountSchema.optional().describe('Instant (BullMQ) queue counts.'),
15781
+ instant: PendingQueueCountSchema.optional().describe('Instant (MongoDB-backed) queue counts.'),
15666
15782
  queued: PendingQueueCountSchema.optional().describe('Slow (Redis-backed) queue counts.'),
15667
15783
  dbBacked: DbBackedCountsSchema.optional().describe('DB-backed job counts from MongoDB (source of truth).'),
15668
15784
  total: z.z.number().describe('Sum of available pending task counts. Excludes unavailable queues.'),
@@ -15949,6 +16065,18 @@ class UI {
15949
16065
  });
15950
16066
  });
15951
16067
  }
16068
+ async connection(options) {
16069
+ const { url, postData } = await this.client.getScreensPostData('connection', {
16070
+ connectionId: options.connectionId,
16071
+ theme: options.theme,
16072
+ });
16073
+ return new Promise((resolve) => {
16074
+ return openIframeWithPost(url, postData, {
16075
+ onClose: () => resolve(null),
16076
+ onSuccess: (connection) => resolve(connection),
16077
+ });
16078
+ });
16079
+ }
15952
16080
  async UNSAFE_agentSession(options) {
15953
16081
  const { url, postData } = await this.client.getScreensPostData('agent-session', {
15954
16082
  sessionId: options.sessionId,
@@ -16307,6 +16435,7 @@ function hasMembraneCredentials(cwd) {
16307
16435
  }
16308
16436
 
16309
16437
  exports.ACTIONS = ACTIONS;
16438
+ exports.AGENTIC_CONNECTION_REQUEST_SCREEN_PATH = AGENTIC_CONNECTION_REQUEST_SCREEN_PATH;
16310
16439
  exports.ALERT_DELIVERY_METHODS = ALERT_DELIVERY_METHODS;
16311
16440
  exports.ALERT_TYPE_CATEGORIES = ALERT_TYPE_CATEGORIES;
16312
16441
  exports.AccessDeniedError = AccessDeniedError;
@@ -16328,6 +16457,7 @@ exports.ActionsAccessor = ActionsAccessor;
16328
16457
  exports.ActivityLogRecord = ActivityLogRecord;
16329
16458
  exports.ActivityStatsQuery = ActivityStatsQuery;
16330
16459
  exports.AgentSession = AgentSession;
16460
+ exports.AgentSessionAttachment = AgentSessionAttachment;
16331
16461
  exports.AgentSessionInputSchema = AgentSessionInputSchema;
16332
16462
  exports.AiAgentAudience = AiAgentAudience;
16333
16463
  exports.AiAgentParameters = AiAgentParameters;
@@ -16435,6 +16565,7 @@ exports.ConnectedProductType = ConnectedProductType;
16435
16565
  exports.ConnectionAccessor = ConnectionAccessor;
16436
16566
  exports.ConnectionApiResponse = ConnectionApiResponse;
16437
16567
  exports.ConnectionApiResponseWithSecrets = ConnectionApiResponseWithSecrets;
16568
+ exports.ConnectionClientAction = ConnectionClientAction;
16438
16569
  exports.ConnectionDataCollectionAccessor = ConnectionDataCollectionAccessor;
16439
16570
  exports.ConnectionEditableProperties = ConnectionEditableProperties;
16440
16571
  exports.ConnectionError = ConnectionError;
@@ -16626,6 +16757,7 @@ exports.ElementListAccessor = ElementListAccessor;
16626
16757
  exports.ElementsExportFields = ElementsExportFields;
16627
16758
  exports.EngineCreditsProjectionResponse = EngineCreditsProjectionResponse;
16628
16759
  exports.EngineWorkspaceSettingsSchema = EngineWorkspaceSettingsSchema;
16760
+ exports.EnsureConnectionRequest = EnsureConnectionRequest;
16629
16761
  exports.ErrorData = ErrorData;
16630
16762
  exports.ErrorDataSchema = ErrorDataSchema;
16631
16763
  exports.Eval = Eval;
@@ -16753,6 +16885,7 @@ exports.IntegrationOptionConfig = IntegrationOptionConfig;
16753
16885
  exports.IntegrationOptions = IntegrationOptions;
16754
16886
  exports.IntegrationSpecificElementSelector = IntegrationSpecificElementSelector;
16755
16887
  exports.IntegrationsAccessor = IntegrationsAccessor;
16888
+ exports.IntentProperties = IntentProperties;
16756
16889
  exports.InternalError = InternalError;
16757
16890
  exports.InvalidLocatorError = InvalidLocatorError;
16758
16891
  exports.JavascriptFunction = JavascriptFunction;
@@ -16819,6 +16952,7 @@ exports.PackagesAccessor = PackagesAccessor;
16819
16952
  exports.PaginationQuery = PaginationQuery;
16820
16953
  exports.PaginationResponse = PaginationResponse;
16821
16954
  exports.PatchAgentSessionSchema = PatchAgentSessionSchema;
16955
+ exports.PatchConnectionRequestPayload = PatchConnectionRequestPayload;
16822
16956
  exports.PendingQueueCountSchema = PendingQueueCountSchema;
16823
16957
  exports.PendingTasksSummarySchema = PendingTasksSummarySchema;
16824
16958
  exports.PlatformUser = PlatformUser;
@@ -17031,6 +17165,7 @@ exports.schemaIsNumber = schemaIsNumber;
17031
17165
  exports.schemaIsScalar = schemaIsScalar;
17032
17166
  exports.schemaTypeFromValue = schemaTypeFromValue;
17033
17167
  exports.schemaWithTitle = schemaWithTitle;
17168
+ exports.selectHighestPriorityScope = selectHighestPriorityScope;
17034
17169
  exports.setEditablePropertiesForWorkspaceElement = setEditablePropertiesForWorkspaceElement;
17035
17170
  exports.setSchemaAtLocator = setSchemaAtLocator;
17036
17171
  exports.setValueAtLocator = setValueAtLocator;
@@ -17043,9 +17178,11 @@ exports.unwrapSchema = unwrapSchema;
17043
17178
  exports.unwrapSchemas = unwrapSchemas;
17044
17179
  exports.updateFlowInstanceSchema = updateFlowInstanceSchema;
17045
17180
  exports.updateImpliedSchema = updateImpliedSchema;
17181
+ exports.validateFunctionDefinitions = validateFunctionDefinitions;
17046
17182
  exports.valueToSchema = valueToSchema;
17047
17183
  exports.valueToString = valueToString;
17048
17184
  exports.walkSchema = walkSchema;
17049
17185
  exports.wrapAnyOfSchema = wrapAnyOfSchema;
17050
17186
  exports.zodBooleanCoercion = zodBooleanCoercion;
17187
+ exports.zodDateCoercion = zodDateCoercion;
17051
17188
  //# sourceMappingURL=index.node.js.map