@almadar/integrations 2.34.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { e as IntegrationLogger, c as IntegrationErrorCode, a as IntegrationConfig, B as BaseIntegration, d as IntegrationFactory, g as IntegrationParams, h as IntegrationResult, I as IntegrationCallContext } from './BaseIntegration-BYlbMFlf.js';
2
2
  export { b as IntegrationError, f as IntegrationParamValue, U as UnknownActionError, V as ValidationError, i as ValidationResult, j as getIntegrationFactory, r as resetIntegrationFactory, v as validateParams } from './BaseIntegration-BYlbMFlf.js';
3
- import { e as CredentialStore, d as CredentialPersistence, H as HookDeclaration } from './store-DaPuMedl.js';
4
- export { A as ArxivActions, C as CLIActions, a as CREDENTIAL_ENTITY_TYPE, b as CREDENTIAL_MASTER_KEY_ENV, c as CredentialEntry, D as DatabaseActions, f as DatabaseDriver, g as DatabaseQueryParamValue, h as DatabaseQueryParams, i as DatabaseQueryResult, j as DatabaseRow, k as DeepAgentActions, l as DockerActions, E as EmailActions, G as GitHubActions, I as IconifyActions, m as IntegrationActionName, n as IntegrationContracts, o as IntegrationName, L as LLMIntegrationActions, M as MLActions, O as OAuthActions, p as OtelActions, Q as QueueActions, R as RedisActions, S as StorageActions, q as StripeActions, T as TwilioActions, W as WebhookActions, r as WikimediaActions, Y as YouTubeActions, s as allCredentialEnvVars, t as declaredCredentialEnvVars, u as serviceHooks } from './store-DaPuMedl.js';
3
+ import { e as CredentialStore, d as CredentialPersistence, H as HookDeclaration } from './store-OiFX0Tkn.js';
4
+ export { A as ArxivActions, C as CLIActions, a as CREDENTIAL_ENTITY_TYPE, b as CREDENTIAL_MASTER_KEY_ENV, c as CredentialEntry, D as DatabaseActions, f as DatabaseDriver, g as DatabaseQueryParamValue, h as DatabaseQueryParams, i as DatabaseQueryResult, j as DatabaseRow, k as DeepAgentActions, l as DockerActions, E as EmailActions, G as GitHubActions, I as IconifyActions, m as IntegrationActionName, n as IntegrationContracts, o as IntegrationName, L as LLMIntegrationActions, M as MLActions, O as OAuthActions, p as OtelActions, Q as QueueActions, R as RedisActions, S as StorageActions, q as StripeActions, T as TwilioActions, W as WebhookActions, r as WikimediaActions, Y as YouTubeActions, s as allCredentialEnvVars, t as declaredCredentialEnvVars, u as serviceHooks } from './store-OiFX0Tkn.js';
5
5
  import { LogMeta, EntityRow, EventPayload } from '@almadar/core';
6
6
  export { GitHubIntegration } from './integrations/github/index.js';
7
7
 
@@ -1024,11 +1024,19 @@ declare class ArxivIntegration extends BaseIntegration {
1024
1024
  declare class RiggerIntegration extends BaseIntegration {
1025
1025
  private readonly baseUrl;
1026
1026
  private readonly timeoutMs;
1027
+ private readonly generateTimeoutMs;
1027
1028
  constructor(config: IntegrationConfig);
1028
1029
  execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1029
1030
  private health;
1030
1031
  private buildMesh;
1031
1032
  private render;
1033
+ private listPresets;
1034
+ private loadRig;
1035
+ private saveRig;
1036
+ private ownership;
1037
+ private buildLayers;
1038
+ private pose;
1039
+ private generate;
1032
1040
  }
1033
1041
 
1034
1042
  export { AccountingIntegration, type AlmadarCheckoutSession, type AlmadarCustomer, type AlmadarInvoiceFailure, type AlmadarInvoicePayment, type AlmadarPortalSession, type AlmadarStripeEvent, type AlmadarStripeEventOk, type AlmadarSubscription, type AlmadarSubscriptionStatus, type AlmadarTier, ArxivIntegration, type ArxivResult, BankingIntegration, BaseIntegration, CLIIntegration, CREDENTIALS_FILE_ENV, CalendarIntegration, type CancelSubscriptionInput, ConsoleLogger, type CreateCheckoutInput, type CreateCustomerInput, type CreatePortalInput, CredentialPersistence, CredentialStore, CredentialsIntegration, DatabaseIntegration, DeepAgentIntegration, DockerIntegration, DriveIntegration, EmailIntegration, EsignIntegration, FileCredentialPersistence, HookDeclaration, type HookProviderInput, type HookProviderResult, IconifyIntegration, InMemoryPendingGrantStore, IntegrationCallContext, IntegrationConfig, type IntegrationConstructor, IntegrationErrorCode, IntegrationFactory, IntegrationLogger, IntegrationParams, IntegrationResult, LLMIntegration, MLIntegration, MetaAdsIntegration, OAuthIntegration, OtelIntegration, type PendingGrantStore, PushIntegration, QueueIntegration, RedisIntegration, type RegisteredHookProvider, type RetryConfig, RiggerIntegration, type SqlGuardResult, StorageIntegration, StripeIntegration, type StripePriceMap, TwilioIntegration, type UpdateSubscriptionInput, type VerifyAndParseInput, WebhookIntegration, WikimediaIntegration, YouTubeIntegration, allHookDeclarations, assertReadOnlySelect, getActiveFactory, getInstalledCredentialStore, getIntegration, getRegisteredIntegrations, googleCalendarHookProvider, installActiveFactory, installCredentialStore, installPendingGrantStore, isKnownIntegration, parseCalendarPushNotification, registerIntegration, registeredHookProviders, resolveCredentialRef, uninstallCredentialStore, verifyAndParseStripeEvent, withRetry };
package/dist/index.js CHANGED
@@ -161,7 +161,8 @@ var serviceCredentials = {
161
161
  ],
162
162
  rigger: [
163
163
  { envVar: "RIGGER_BASE_URL", required: false, description: "Local rigger service base URL (default http://127.0.0.1:8181)" },
164
- { envVar: "RIGGER_TIMEOUT_MS", required: false, description: "Per-request timeout (ms)" }
164
+ { envVar: "RIGGER_TIMEOUT_MS", required: false, description: "Per-request timeout (ms)" },
165
+ { envVar: "RIGGER_GENERATE_TIMEOUT_MS", required: false, description: "Timeout (ms) for the 'generate' action; a local z-image-turbo run takes ~60-90 s and a kontext edit at 1024px several minutes (default 600000)" }
165
166
  ]
166
167
  };
167
168
  function allCredentialEnvVars() {
@@ -5836,11 +5837,36 @@ registerIntegration("arxiv", ArxivIntegration);
5836
5837
  // src/integrations/rigger/index.ts
5837
5838
  var DEFAULT_BASE_URL = "http://127.0.0.1:8181";
5838
5839
  var DEFAULT_TIMEOUT_MS5 = 3e4;
5840
+ var DEFAULT_GENERATE_TIMEOUT_MS = 6e5;
5841
+ var GENERATE_MODELS = ["z-image-turbo", "kontext"];
5842
+ function generateParamErrors(params) {
5843
+ const errors = [];
5844
+ const model = params.model;
5845
+ if (typeof model !== "string" || !GENERATE_MODELS.includes(model)) {
5846
+ errors.push(`model must be one of ${GENERATE_MODELS.join(", ")}`);
5847
+ }
5848
+ if (model === "kontext" && (typeof params.sourcePath !== "string" || params.sourcePath === "")) {
5849
+ errors.push("sourcePath is required when model is kontext");
5850
+ }
5851
+ return errors;
5852
+ }
5853
+ async function riggerError(path, response) {
5854
+ let detail = "";
5855
+ try {
5856
+ const body = await response.json();
5857
+ if (typeof body.detail === "string") detail = body.detail;
5858
+ else if (body.detail !== void 0) detail = JSON.stringify(body.detail);
5859
+ } catch {
5860
+ detail = "";
5861
+ }
5862
+ return new Error(`Rigger ${path} returned ${response.status}${detail ? `: ${detail}` : ""}`);
5863
+ }
5839
5864
  var RiggerIntegration = class extends BaseIntegration {
5840
5865
  constructor(config) {
5841
5866
  super(config);
5842
5867
  this.baseUrl = config.env.RIGGER_BASE_URL || DEFAULT_BASE_URL;
5843
5868
  this.timeoutMs = Number(config.env.RIGGER_TIMEOUT_MS) || DEFAULT_TIMEOUT_MS5;
5869
+ this.generateTimeoutMs = Number(config.env.RIGGER_GENERATE_TIMEOUT_MS) || DEFAULT_GENERATE_TIMEOUT_MS;
5844
5870
  this.logger.info("Rigger integration initialized", { baseUrl: this.baseUrl });
5845
5871
  }
5846
5872
  async execute(action, params) {
@@ -5857,6 +5883,21 @@ var RiggerIntegration = class extends BaseIntegration {
5857
5883
  metadata: this.createMetadata(action, 0)
5858
5884
  };
5859
5885
  }
5886
+ if (action === "generate") {
5887
+ const invalid = generateParamErrors(params);
5888
+ if (invalid.length > 0) {
5889
+ return {
5890
+ success: false,
5891
+ error: {
5892
+ name: "IntegrationError",
5893
+ message: "Validation failed",
5894
+ code: "VALIDATION_ERROR",
5895
+ details: invalid
5896
+ },
5897
+ metadata: this.createMetadata(action, 0)
5898
+ };
5899
+ }
5900
+ }
5860
5901
  const startTime = Date.now();
5861
5902
  try {
5862
5903
  let data;
@@ -5870,6 +5911,27 @@ var RiggerIntegration = class extends BaseIntegration {
5870
5911
  case "render":
5871
5912
  data = await this.executeWithRetry(() => this.render(params));
5872
5913
  break;
5914
+ case "listPresets":
5915
+ data = await this.executeWithRetry(() => this.listPresets());
5916
+ break;
5917
+ case "loadRig":
5918
+ data = await this.executeWithRetry(() => this.loadRig(params));
5919
+ break;
5920
+ case "saveRig":
5921
+ data = await this.executeWithRetry(() => this.saveRig(params));
5922
+ break;
5923
+ case "ownership":
5924
+ data = await this.executeWithRetry(() => this.ownership(params));
5925
+ break;
5926
+ case "buildLayers":
5927
+ data = await this.executeWithRetry(() => this.buildLayers(params));
5928
+ break;
5929
+ case "pose":
5930
+ data = await this.executeWithRetry(() => this.pose(params));
5931
+ break;
5932
+ case "generate":
5933
+ data = await this.executeWithRetry(() => this.generate(params));
5934
+ break;
5873
5935
  default:
5874
5936
  throw new UnknownActionError(this.config.name, action);
5875
5937
  }
@@ -5897,22 +5959,109 @@ var RiggerIntegration = class extends BaseIntegration {
5897
5959
  signal: AbortSignal.timeout(this.timeoutMs)
5898
5960
  });
5899
5961
  if (!response.ok) {
5900
- throw new Error(`Rigger /mesh/build returned ${response.status}`);
5962
+ throw await riggerError("/mesh/build", response);
5901
5963
  }
5902
5964
  return await response.json();
5903
5965
  }
5904
5966
  async render(params) {
5905
- const { imagePath, rig, preset, outDir } = params;
5967
+ const { imagePath, rig, preset, outDir, mode, supersample } = params;
5906
5968
  const response = await fetch(`${this.baseUrl}/render`, {
5907
5969
  method: "POST",
5908
5970
  headers: { "Content-Type": "application/json" },
5909
- body: JSON.stringify({ imagePath, rig, preset, outDir }),
5971
+ body: JSON.stringify({ imagePath, rig, preset, outDir, mode, supersample }),
5910
5972
  signal: AbortSignal.timeout(this.timeoutMs)
5911
5973
  });
5912
5974
  if (!response.ok) {
5913
- throw new Error(`Rigger /render returned ${response.status}`);
5975
+ throw await riggerError("/render", response);
5914
5976
  }
5915
- return response.json();
5977
+ return await response.json();
5978
+ }
5979
+ async listPresets() {
5980
+ const response = await fetch(`${this.baseUrl}/presets`, {
5981
+ signal: AbortSignal.timeout(this.timeoutMs)
5982
+ });
5983
+ if (!response.ok) {
5984
+ throw await riggerError("/presets", response);
5985
+ }
5986
+ return await response.json();
5987
+ }
5988
+ async loadRig(params) {
5989
+ const { rigPath } = params;
5990
+ const response = await fetch(`${this.baseUrl}/rig/load`, {
5991
+ method: "POST",
5992
+ headers: { "Content-Type": "application/json" },
5993
+ body: JSON.stringify({ rigPath }),
5994
+ signal: AbortSignal.timeout(this.timeoutMs)
5995
+ });
5996
+ if (!response.ok) {
5997
+ throw await riggerError("/rig/load", response);
5998
+ }
5999
+ return await response.json();
6000
+ }
6001
+ async saveRig(params) {
6002
+ const { rigPath, rig } = params;
6003
+ const response = await fetch(`${this.baseUrl}/rig/save`, {
6004
+ method: "POST",
6005
+ headers: { "Content-Type": "application/json" },
6006
+ body: JSON.stringify({ rigPath, rig }),
6007
+ signal: AbortSignal.timeout(this.timeoutMs)
6008
+ });
6009
+ if (!response.ok) {
6010
+ throw await riggerError("/rig/save", response);
6011
+ }
6012
+ return await response.json();
6013
+ }
6014
+ async ownership(params) {
6015
+ const { imagePath, rig, outPath } = params;
6016
+ const response = await fetch(`${this.baseUrl}/ownership`, {
6017
+ method: "POST",
6018
+ headers: { "Content-Type": "application/json" },
6019
+ body: JSON.stringify({ imagePath, rig, outPath }),
6020
+ signal: AbortSignal.timeout(this.timeoutMs)
6021
+ });
6022
+ if (!response.ok) {
6023
+ throw await riggerError("/ownership", response);
6024
+ }
6025
+ return await response.json();
6026
+ }
6027
+ async buildLayers(params) {
6028
+ const { imagePath, rig, outDir } = params;
6029
+ const response = await fetch(`${this.baseUrl}/layers`, {
6030
+ method: "POST",
6031
+ headers: { "Content-Type": "application/json" },
6032
+ body: JSON.stringify({ imagePath, rig, outDir }),
6033
+ signal: AbortSignal.timeout(this.timeoutMs)
6034
+ });
6035
+ if (!response.ok) {
6036
+ throw await riggerError("/layers", response);
6037
+ }
6038
+ return await response.json();
6039
+ }
6040
+ async pose(params) {
6041
+ const { imagePath, rig, roles, preset, overrides } = params;
6042
+ const response = await fetch(`${this.baseUrl}/pose`, {
6043
+ method: "POST",
6044
+ headers: { "Content-Type": "application/json" },
6045
+ body: JSON.stringify({ imagePath, rig, roles, preset, overrides }),
6046
+ signal: AbortSignal.timeout(this.timeoutMs)
6047
+ });
6048
+ if (!response.ok) {
6049
+ throw await riggerError("/pose", response);
6050
+ }
6051
+ return await response.json();
6052
+ }
6053
+ async generate(params) {
6054
+ const { model, prompt, seed, size, steps, sourcePath, outDir } = params;
6055
+ const response = await fetch(`${this.baseUrl}/generate`, {
6056
+ method: "POST",
6057
+ headers: { "Content-Type": "application/json" },
6058
+ body: JSON.stringify({ model, prompt, seed, size, steps, sourcePath, outDir }),
6059
+ signal: AbortSignal.timeout(this.generateTimeoutMs)
6060
+ });
6061
+ if (!response.ok) {
6062
+ throw await riggerError("/generate", response);
6063
+ }
6064
+ return await response.json();
5916
6065
  }
5917
6066
  };
5918
6067
  registerIntegration("rigger", RiggerIntegration);