@almadar/integrations 2.34.0 → 2.35.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.
@@ -1,5 +1,5 @@
1
1
  import { g as IntegrationParams, I as IntegrationCallContext, d as IntegrationFactory } from '../BaseIntegration-BYlbMFlf.js';
2
- import { o as IntegrationName, m as IntegrationActionName, n as IntegrationContracts, e as CredentialStore } from '../store-DaPuMedl.js';
2
+ import { o as IntegrationName, m as IntegrationActionName, n as IntegrationContracts, e as CredentialStore } from '../store-BGNfuoFd.js';
3
3
  import '@almadar/core';
4
4
 
5
5
  /**
@@ -162,7 +162,8 @@ var serviceCredentials = {
162
162
  ],
163
163
  rigger: [
164
164
  { envVar: "RIGGER_BASE_URL", required: false, description: "Local rigger service base URL (default http://127.0.0.1:8181)" },
165
- { envVar: "RIGGER_TIMEOUT_MS", required: false, description: "Per-request timeout (ms)" }
165
+ { envVar: "RIGGER_TIMEOUT_MS", required: false, description: "Per-request timeout (ms)" },
166
+ { 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)" }
166
167
  ]
167
168
  };
168
169
  function allCredentialEnvVars() {
@@ -5347,11 +5348,24 @@ registerIntegration("arxiv", ArxivIntegration);
5347
5348
  // src/integrations/rigger/index.ts
5348
5349
  var DEFAULT_BASE_URL = "http://127.0.0.1:8181";
5349
5350
  var DEFAULT_TIMEOUT_MS5 = 3e4;
5351
+ var DEFAULT_GENERATE_TIMEOUT_MS = 6e5;
5352
+ async function riggerError(path, response) {
5353
+ let detail = "";
5354
+ try {
5355
+ const body = await response.json();
5356
+ if (typeof body.detail === "string") detail = body.detail;
5357
+ else if (body.detail !== void 0) detail = JSON.stringify(body.detail);
5358
+ } catch {
5359
+ detail = "";
5360
+ }
5361
+ return new Error(`Rigger ${path} returned ${response.status}${detail ? `: ${detail}` : ""}`);
5362
+ }
5350
5363
  var RiggerIntegration = class extends BaseIntegration {
5351
5364
  constructor(config) {
5352
5365
  super(config);
5353
5366
  this.baseUrl = config.env.RIGGER_BASE_URL || DEFAULT_BASE_URL;
5354
5367
  this.timeoutMs = Number(config.env.RIGGER_TIMEOUT_MS) || DEFAULT_TIMEOUT_MS5;
5368
+ this.generateTimeoutMs = Number(config.env.RIGGER_GENERATE_TIMEOUT_MS) || DEFAULT_GENERATE_TIMEOUT_MS;
5355
5369
  this.logger.info("Rigger integration initialized", { baseUrl: this.baseUrl });
5356
5370
  }
5357
5371
  async execute(action, params) {
@@ -5381,6 +5395,21 @@ var RiggerIntegration = class extends BaseIntegration {
5381
5395
  case "render":
5382
5396
  data = await this.executeWithRetry(() => this.render(params));
5383
5397
  break;
5398
+ case "listPresets":
5399
+ data = await this.executeWithRetry(() => this.listPresets());
5400
+ break;
5401
+ case "loadRig":
5402
+ data = await this.executeWithRetry(() => this.loadRig(params));
5403
+ break;
5404
+ case "saveRig":
5405
+ data = await this.executeWithRetry(() => this.saveRig(params));
5406
+ break;
5407
+ case "ownership":
5408
+ data = await this.executeWithRetry(() => this.ownership(params));
5409
+ break;
5410
+ case "generate":
5411
+ data = await this.executeWithRetry(() => this.generate(params));
5412
+ break;
5384
5413
  default:
5385
5414
  throw new UnknownActionError(this.config.name, action);
5386
5415
  }
@@ -5408,22 +5437,83 @@ var RiggerIntegration = class extends BaseIntegration {
5408
5437
  signal: AbortSignal.timeout(this.timeoutMs)
5409
5438
  });
5410
5439
  if (!response.ok) {
5411
- throw new Error(`Rigger /mesh/build returned ${response.status}`);
5440
+ throw await riggerError("/mesh/build", response);
5412
5441
  }
5413
5442
  return await response.json();
5414
5443
  }
5415
5444
  async render(params) {
5416
- const { imagePath, rig, preset, outDir } = params;
5445
+ const { imagePath, rig, preset, outDir, mode, supersample } = params;
5417
5446
  const response = await fetch(`${this.baseUrl}/render`, {
5418
5447
  method: "POST",
5419
5448
  headers: { "Content-Type": "application/json" },
5420
- body: JSON.stringify({ imagePath, rig, preset, outDir }),
5449
+ body: JSON.stringify({ imagePath, rig, preset, outDir, mode, supersample }),
5421
5450
  signal: AbortSignal.timeout(this.timeoutMs)
5422
5451
  });
5423
5452
  if (!response.ok) {
5424
- throw new Error(`Rigger /render returned ${response.status}`);
5453
+ throw await riggerError("/render", response);
5425
5454
  }
5426
- return response.json();
5455
+ return await response.json();
5456
+ }
5457
+ async listPresets() {
5458
+ const response = await fetch(`${this.baseUrl}/presets`, {
5459
+ signal: AbortSignal.timeout(this.timeoutMs)
5460
+ });
5461
+ if (!response.ok) {
5462
+ throw await riggerError("/presets", response);
5463
+ }
5464
+ return await response.json();
5465
+ }
5466
+ async loadRig(params) {
5467
+ const { rigPath } = params;
5468
+ const response = await fetch(`${this.baseUrl}/rig/load`, {
5469
+ method: "POST",
5470
+ headers: { "Content-Type": "application/json" },
5471
+ body: JSON.stringify({ rigPath }),
5472
+ signal: AbortSignal.timeout(this.timeoutMs)
5473
+ });
5474
+ if (!response.ok) {
5475
+ throw await riggerError("/rig/load", response);
5476
+ }
5477
+ return await response.json();
5478
+ }
5479
+ async saveRig(params) {
5480
+ const { rigPath, rig } = params;
5481
+ const response = await fetch(`${this.baseUrl}/rig/save`, {
5482
+ method: "POST",
5483
+ headers: { "Content-Type": "application/json" },
5484
+ body: JSON.stringify({ rigPath, rig }),
5485
+ signal: AbortSignal.timeout(this.timeoutMs)
5486
+ });
5487
+ if (!response.ok) {
5488
+ throw await riggerError("/rig/save", response);
5489
+ }
5490
+ return await response.json();
5491
+ }
5492
+ async ownership(params) {
5493
+ const { imagePath, rig, outPath } = params;
5494
+ const response = await fetch(`${this.baseUrl}/ownership`, {
5495
+ method: "POST",
5496
+ headers: { "Content-Type": "application/json" },
5497
+ body: JSON.stringify({ imagePath, rig, outPath }),
5498
+ signal: AbortSignal.timeout(this.timeoutMs)
5499
+ });
5500
+ if (!response.ok) {
5501
+ throw await riggerError("/ownership", response);
5502
+ }
5503
+ return await response.json();
5504
+ }
5505
+ async generate(params) {
5506
+ const { model, prompt, seed, size, steps, sourcePath, outDir } = params;
5507
+ const response = await fetch(`${this.baseUrl}/generate`, {
5508
+ method: "POST",
5509
+ headers: { "Content-Type": "application/json" },
5510
+ body: JSON.stringify({ model, prompt, seed, size, steps, sourcePath, outDir }),
5511
+ signal: AbortSignal.timeout(this.generateTimeoutMs)
5512
+ });
5513
+ if (!response.ok) {
5514
+ throw await riggerError("/generate", response);
5515
+ }
5516
+ return await response.json();
5427
5517
  }
5428
5518
  };
5429
5519
  registerIntegration("rigger", RiggerIntegration);