@ixo/editor 5.26.0 → 5.28.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.
@@ -260,6 +260,22 @@ function buildServicesFromHandlers(handlers) {
260
260
  updateOracleDomain: handlers.updateOracleDomain || (async () => {
261
261
  throw new Error("updateOracleDomain handler not configured");
262
262
  })
263
+ } : void 0,
264
+ // Carbon credit batch service (IXO-2675). The consumer exposes a
265
+ // fully-formed `handlers.carbon` service group (loadBatches + harvest +
266
+ // retire); wire each method straight through. The harvest/retire calls are
267
+ // user-signed inside the consumer handler — we only forward here.
268
+ carbon: handlers?.carbon?.loadBatches && handlers?.carbon?.harvest && handlers?.carbon?.retire ? {
269
+ loadBatches: async (params) => handlers.carbon.loadBatches(params),
270
+ harvest: async (params) => handlers.carbon.harvest(params),
271
+ retire: async (params) => handlers.carbon.retire(params)
272
+ } : void 0,
273
+ // Entity (domain) ownership service (IXO-2696). The consumer exposes a
274
+ // fully-formed `handlers.entity` service group; the transfer is user-signed
275
+ // inside the consumer handler (resolve recipient + IID guard + broadcast) —
276
+ // we only forward the call here.
277
+ entity: handlers?.entity?.transfer ? {
278
+ transfer: async (params) => handlers.entity.transfer(params)
263
279
  } : void 0
264
280
  };
265
281
  }
@@ -5236,6 +5252,178 @@ registerAction({
5236
5252
  }
5237
5253
  });
5238
5254
 
5255
+ // src/core/lib/actionRegistry/actions/carbon/schemas.ts
5256
+ var HARVESTABLE_ITEM_SCHEMA = [
5257
+ { path: "id", displayName: "Batch ID", type: "string" },
5258
+ { path: "entityDid", displayName: "Entity DID", type: "string" },
5259
+ { path: "adminAddress", displayName: "Admin Address", type: "string" },
5260
+ { path: "claimable", displayName: "Claimable", type: "number" },
5261
+ { path: "alsoKnownAs", displayName: "Entity Name", type: "string" }
5262
+ ];
5263
+ var RETIREABLE_ITEM_SCHEMA = [
5264
+ { path: "id", displayName: "Batch ID", type: "string" },
5265
+ { path: "amount", displayName: "Amount", type: "number" },
5266
+ { path: "entityDid", displayName: "Entity DID", type: "string" },
5267
+ { path: "alsoKnownAs", displayName: "Entity Name", type: "string" }
5268
+ ];
5269
+ var CARBON_LOAD_OUTPUT = [
5270
+ { path: "harvestableBatches", displayName: "Harvestable Batches", type: "array", itemSchema: HARVESTABLE_ITEM_SCHEMA, description: "Batches with claimable credits" },
5271
+ { path: "retireableBatches", displayName: "Retireable Batches", type: "array", itemSchema: RETIREABLE_ITEM_SCHEMA, description: "Batches with credits available to retire" },
5272
+ { path: "totalClaimable", displayName: "Total Claimable", type: "number", description: "Sum of all claimable credits" },
5273
+ { path: "totalAvailable", displayName: "Total Available", type: "number", description: "Sum of all retireable credits" },
5274
+ { path: "totalRetired", displayName: "Total Retired", type: "number", description: "Sum of all retired credits" }
5275
+ ];
5276
+ var CARBON_HARVEST_OUTPUT = [
5277
+ { path: "transactionHash", displayName: "Transaction Hash", type: "string", description: "The harvest transaction hash" },
5278
+ {
5279
+ path: "harvestedBatchIds",
5280
+ displayName: "Harvested Batch IDs",
5281
+ type: "array",
5282
+ itemSchema: [{ path: "", displayName: "Batch ID", type: "string" }],
5283
+ description: "Ids of the harvested batches"
5284
+ },
5285
+ { path: "harvestedAmount", displayName: "Harvested Amount", type: "number", description: "Total credits harvested into the wallet" }
5286
+ ];
5287
+ var CARBON_RETIRE_OUTPUT = [
5288
+ { path: "transactionHash", displayName: "Transaction Hash", type: "string", description: "The retire transaction hash" },
5289
+ {
5290
+ path: "retiredBatchIds",
5291
+ displayName: "Retired Batch IDs",
5292
+ type: "array",
5293
+ itemSchema: [{ path: "", displayName: "Batch ID", type: "string" }],
5294
+ description: "Ids of the retired batches"
5295
+ },
5296
+ { path: "retiredAmount", displayName: "Retired Amount", type: "number", description: "Total credits permanently retired" },
5297
+ { path: "jurisdiction", displayName: "Jurisdiction", type: "string", description: "Jurisdiction recorded on the retirement" }
5298
+ ];
5299
+
5300
+ // src/core/lib/actionRegistry/actions/carbon/loadBatches.ts
5301
+ registerAction({
5302
+ type: "qi/carbon.loadBatches",
5303
+ can: "carbon/load",
5304
+ sideEffect: false,
5305
+ defaultRequiresConfirmation: false,
5306
+ outputSchema: CARBON_LOAD_OUTPUT,
5307
+ run: async (inputs, ctx) => {
5308
+ if (!ctx.services.carbon?.loadBatches) {
5309
+ throw new Error("carbon.loadBatches handler not available");
5310
+ }
5311
+ if (!inputs.ownerAddress) throw new Error("ownerAddress is required");
5312
+ const result = await ctx.services.carbon.loadBatches({
5313
+ ownerAddress: inputs.ownerAddress
5314
+ });
5315
+ return { output: result };
5316
+ }
5317
+ });
5318
+
5319
+ // src/core/lib/actionRegistry/actions/carbon/harvest.ts
5320
+ registerAction({
5321
+ type: "qi/carbon.harvest",
5322
+ can: "carbon/harvest",
5323
+ sideEffect: true,
5324
+ defaultRequiresConfirmation: true,
5325
+ outputSchema: CARBON_HARVEST_OUTPUT,
5326
+ run: async (inputs, ctx) => {
5327
+ if (!ctx.services.carbon?.harvest) {
5328
+ throw new Error("carbon.harvest handler not available");
5329
+ }
5330
+ if (!inputs.ownerAddress) throw new Error("ownerAddress is required");
5331
+ const tokens = Array.isArray(inputs.tokens) ? inputs.tokens : [];
5332
+ if (tokens.length === 0) throw new Error("No batches selected to harvest");
5333
+ for (const t of tokens) {
5334
+ if (!t.id) throw new Error("Each harvest token requires an id");
5335
+ if (!t.entityDid) throw new Error(`Batch ${t.id} is missing entityDid (cannot construct harvest)`);
5336
+ if (!t.adminAddress) throw new Error(`Batch ${t.id} is missing adminAddress (cannot construct harvest)`);
5337
+ if (!(Number(t.claimable) > 0)) throw new Error(`Batch ${t.id} has no claimable amount`);
5338
+ }
5339
+ const result = await ctx.services.carbon.harvest({
5340
+ ownerAddress: inputs.ownerAddress,
5341
+ tokens: tokens.map((t) => ({ id: t.id, entityDid: t.entityDid, adminAddress: t.adminAddress, claimable: Number(t.claimable) }))
5342
+ });
5343
+ if (!result?.transactionHash) {
5344
+ throw new Error("carbon.harvest returned no transaction hash. Check the [carbon:harvest] handler logs.");
5345
+ }
5346
+ return { output: result };
5347
+ }
5348
+ });
5349
+
5350
+ // src/core/lib/actionRegistry/actions/carbon/retire.ts
5351
+ registerAction({
5352
+ type: "qi/carbon.retire",
5353
+ can: "carbon/retire",
5354
+ sideEffect: true,
5355
+ defaultRequiresConfirmation: true,
5356
+ outputSchema: CARBON_RETIRE_OUTPUT,
5357
+ run: async (inputs, ctx) => {
5358
+ if (!ctx.services.carbon?.retire) {
5359
+ throw new Error("carbon.retire handler not available");
5360
+ }
5361
+ if (!inputs.owner) throw new Error("owner is required");
5362
+ const tokens = Array.isArray(inputs.tokens) ? inputs.tokens : [];
5363
+ if (tokens.length === 0) throw new Error("No batches selected to retire");
5364
+ for (const t of tokens) {
5365
+ if (!t.id) throw new Error("Each retire token requires an id");
5366
+ if (!(Number(t.amount) > 0)) throw new Error(`Batch ${t.id} has no amount to retire`);
5367
+ }
5368
+ const reason = inputs.reason || "offset";
5369
+ const jurisdiction = inputs.jurisdiction || "Global";
5370
+ const result = await ctx.services.carbon.retire({
5371
+ owner: inputs.owner,
5372
+ reason,
5373
+ jurisdiction,
5374
+ tokens: tokens.map((t) => ({ id: t.id, amount: Number(t.amount) }))
5375
+ });
5376
+ if (!result?.transactionHash) {
5377
+ throw new Error("carbon.retire returned no transaction hash. Check the [carbon:retire] handler logs.");
5378
+ }
5379
+ return { output: { ...result, jurisdiction } };
5380
+ }
5381
+ });
5382
+
5383
+ // src/core/lib/actionRegistry/actions/entityTransfer/schemas.ts
5384
+ var ENTITY_TRANSFER_OUTPUT = [
5385
+ { path: "transactionHash", displayName: "Transaction Hash", type: "string", description: "The entity transfer transaction hash" },
5386
+ { path: "recipientDid", displayName: "Recipient DID", type: "string", description: "The new owner DID the entity was transferred to" },
5387
+ {
5388
+ path: "recipientResolved",
5389
+ displayName: "Resolved Recipient",
5390
+ type: "string",
5391
+ description: "The resolved recipient when a group entity was mapped to its DAO controller"
5392
+ },
5393
+ {
5394
+ path: "createdRecipientIid",
5395
+ displayName: "Created Recipient IID",
5396
+ type: "boolean",
5397
+ description: "True when the host created the recipient's IID document before transferring"
5398
+ }
5399
+ ];
5400
+
5401
+ // src/core/lib/actionRegistry/actions/entityTransfer/entityTransfer.ts
5402
+ registerAction({
5403
+ type: "qi/entity.transfer",
5404
+ can: "entity/transfer",
5405
+ sideEffect: true,
5406
+ defaultRequiresConfirmation: true,
5407
+ outputSchema: ENTITY_TRANSFER_OUTPUT,
5408
+ run: async (inputs, ctx) => {
5409
+ if (!ctx.services.entity?.transfer) {
5410
+ throw new Error("entity.transfer handler not available");
5411
+ }
5412
+ if (!inputs.entityDid) throw new Error("entityDid is required");
5413
+ if (!inputs.recipientDid) throw new Error("recipientDid is required");
5414
+ const result = await ctx.services.entity.transfer({
5415
+ entityDid: inputs.entityDid,
5416
+ recipientDid: inputs.recipientDid,
5417
+ ...inputs.ownerDid ? { ownerDid: inputs.ownerDid } : {},
5418
+ ...inputs.ownerAddress ? { ownerAddress: inputs.ownerAddress } : {}
5419
+ });
5420
+ if (!result?.transactionHash) {
5421
+ throw new Error("entity.transfer returned no transaction hash. Check the [entity:transfer] handler logs.");
5422
+ }
5423
+ return { output: { ...result, recipientDid: inputs.recipientDid } };
5424
+ }
5425
+ });
5426
+
5239
5427
  // src/core/lib/actionRegistry/actions/calendar/eventCreate.types.ts
5240
5428
  var EMPTY = {
5241
5429
  connection: null,
@@ -6909,6 +7097,98 @@ registerDiffResolver(COLLECTION_USERS_ACTION_TYPE, {
6909
7097
  }
6910
7098
  });
6911
7099
 
7100
+ // src/core/lib/actionRegistry/actions/carbon/harvest.diff.ts
7101
+ registerDiffResolver("qi/carbon.harvest", {
7102
+ resolver: async (inputs, _ctx) => {
7103
+ const selected = Array.isArray(inputs.selectedBatches) ? inputs.selectedBatches : [];
7104
+ if (selected.length === 0) return [];
7105
+ const rows = selected.map((b) => {
7106
+ const claimable = Number(b?.claimable) || 0;
7107
+ return {
7108
+ key: `batch-${b?.id}`,
7109
+ label: b?.alsoKnownAs || b?.id || "Batch",
7110
+ before: 0,
7111
+ after: claimable,
7112
+ changeType: "increase",
7113
+ unit: "CARBON"
7114
+ };
7115
+ });
7116
+ const total = selected.reduce((s, b) => s + (Number(b?.claimable) || 0), 0);
7117
+ rows.push({
7118
+ key: "total",
7119
+ label: "Total harvested to wallet",
7120
+ before: 0,
7121
+ after: total,
7122
+ changeType: "increase",
7123
+ unit: "CARBON",
7124
+ severity: "info"
7125
+ });
7126
+ return rows;
7127
+ }
7128
+ });
7129
+
7130
+ // src/core/lib/actionRegistry/actions/carbon/retire.diff.ts
7131
+ registerDiffResolver("qi/carbon.retire", {
7132
+ resolver: async (inputs, _ctx) => {
7133
+ const selected = Array.isArray(inputs.selectedBatches) ? inputs.selectedBatches : [];
7134
+ if (selected.length === 0) return [];
7135
+ const rows = selected.map((b) => {
7136
+ const amount = Number(b?.amount) || 0;
7137
+ return {
7138
+ key: `batch-${b?.id}`,
7139
+ label: b?.alsoKnownAs || b?.id || "Batch",
7140
+ before: amount,
7141
+ after: 0,
7142
+ changeType: "decrease",
7143
+ unit: "CARBON",
7144
+ severity: "warning"
7145
+ };
7146
+ });
7147
+ const total = selected.reduce((s, b) => s + (Number(b?.amount) || 0), 0);
7148
+ rows.push({
7149
+ key: "total",
7150
+ label: "Total retired (permanent, irreversible)",
7151
+ before: total,
7152
+ after: 0,
7153
+ changeType: "decrease",
7154
+ unit: "CARBON",
7155
+ severity: "critical"
7156
+ });
7157
+ return rows;
7158
+ }
7159
+ });
7160
+
7161
+ // src/core/lib/actionRegistry/actions/entityTransfer/entityTransfer.diff.ts
7162
+ registerDiffResolver("qi/entity.transfer", {
7163
+ resolver: async (inputs, ctx) => {
7164
+ const recipient = String(inputs.recipientDid || "").trim();
7165
+ if (!recipient) return [];
7166
+ const entityDid = String(inputs.entityDid || "").trim();
7167
+ const currentOwner = String(inputs.ownerDid || "").trim() || ctx.actorDid || "current owner";
7168
+ const rows = [
7169
+ {
7170
+ key: "owner",
7171
+ label: "Owner",
7172
+ before: currentOwner,
7173
+ after: recipient,
7174
+ changeType: "replace",
7175
+ severity: "critical"
7176
+ }
7177
+ ];
7178
+ if (entityDid) {
7179
+ rows.push({
7180
+ key: "entity",
7181
+ label: "Entity",
7182
+ before: entityDid,
7183
+ after: entityDid,
7184
+ changeType: "unchanged",
7185
+ severity: "info"
7186
+ });
7187
+ }
7188
+ return rows;
7189
+ }
7190
+ });
7191
+
6912
7192
  // src/core/services/ucanService.ts
6913
7193
  import {
6914
7194
  createDelegation as ucanCreateDelegation,
@@ -11530,4 +11810,4 @@ export {
11530
11810
  executeQueuedFlowAgentCoreCommands,
11531
11811
  FlowAgentService
11532
11812
  };
11533
- //# sourceMappingURL=chunk-RIDIYR53.mjs.map
11813
+ //# sourceMappingURL=chunk-KWN34HVF.mjs.map