@capxul/mcp 4.0.0 → 4.1.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/main.mjs +566 -254
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { createHash } from "node:crypto";
|
|
|
8
8
|
import { createServer } from "node:http";
|
|
9
9
|
import { localhostHostValidation, localhostOriginValidation, toNodeHandler } from "@modelcontextprotocol/node";
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import { Cause, Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schedule, Schema, SchemaGetter, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
|
|
11
|
+
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schedule, Schema, SchemaGetter, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
|
|
12
12
|
import { FetchHttpClient, Headers, HttpClient } from "effect/unstable/http";
|
|
13
13
|
import { OtlpExporter, OtlpLogger, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
|
|
14
14
|
import { resolve } from "path";
|
|
@@ -4056,12 +4056,14 @@ const CAPXUL_OPERATIONS = {
|
|
|
4056
4056
|
},
|
|
4057
4057
|
activity: {
|
|
4058
4058
|
annotate: "activity.annotate",
|
|
4059
|
+
emitAnnotationSaved: "activity.emitAnnotationSaved",
|
|
4059
4060
|
get: "activity.get",
|
|
4060
4061
|
list: "activity.list",
|
|
4061
4062
|
summary: "activity.summary"
|
|
4062
4063
|
},
|
|
4063
4064
|
addressBook: {
|
|
4064
4065
|
add: "addressBook.add",
|
|
4066
|
+
emitRelationshipChanged: "addressBook.emitRelationshipChanged",
|
|
4065
4067
|
get: "addressBook.get",
|
|
4066
4068
|
hide: "addressBook.hide",
|
|
4067
4069
|
label: "addressBook.label",
|
|
@@ -4124,6 +4126,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4124
4126
|
createOrganization: "identity.CreateOrganization",
|
|
4125
4127
|
ensureAccount: "identity.EnsureAccount",
|
|
4126
4128
|
leaveOrganization: "identity.LeaveOrganization",
|
|
4129
|
+
loadByAuthUserId: "identity.loadByAuthUserId",
|
|
4127
4130
|
loadCurrent: "identity.loadCurrent",
|
|
4128
4131
|
orgAt: "identity.OrgAt",
|
|
4129
4132
|
orgFailed: "identity.OrgFailed",
|
|
@@ -4274,7 +4277,8 @@ const CAPXUL_OPERATIONS = {
|
|
|
4274
4277
|
organizationPayments: {
|
|
4275
4278
|
pay: "organizationPayments.pay",
|
|
4276
4279
|
payBatch: "organizationPayments.payBatch",
|
|
4277
|
-
prepareExecution: "organizationPayments.prepareExecution"
|
|
4280
|
+
prepareExecution: "organizationPayments.prepareExecution",
|
|
4281
|
+
retry: "organizationPayments.retry"
|
|
4278
4282
|
},
|
|
4279
4283
|
organizationSetup: { getProofReceipt: "organizationSetup.getProofReceipt" },
|
|
4280
4284
|
organizations: { detectAndAcceptPendingInvitations: "orgs.detectAndAcceptPendingInvitations" },
|
|
@@ -4289,6 +4293,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4289
4293
|
prepareExecution: "payments.prepareExecution",
|
|
4290
4294
|
prepareLifecycleExecution: "payments.prepareLifecycleExecution",
|
|
4291
4295
|
redirect: "payments.redirect",
|
|
4296
|
+
retry: "payments.retry",
|
|
4292
4297
|
submitCommandExecution: "payments.submitCommandExecution",
|
|
4293
4298
|
submitExecution: "payments.submitExecution"
|
|
4294
4299
|
},
|
|
@@ -4370,6 +4375,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4370
4375
|
smartAccount: {
|
|
4371
4376
|
claim: "smartAccount.claim",
|
|
4372
4377
|
confirmDeployment: "smartAccount.confirmDeployment",
|
|
4378
|
+
loadByAuthUserId: "smartAccount.loadByAuthUserId",
|
|
4373
4379
|
loadCurrent: "smartAccount.loadCurrent",
|
|
4374
4380
|
provision: "smartAccount.provision"
|
|
4375
4381
|
},
|
|
@@ -5139,6 +5145,148 @@ Schema.Struct({
|
|
|
5139
5145
|
name: Schema.Literal("movement_scan_incident"),
|
|
5140
5146
|
props: MovementScanIncidentProps
|
|
5141
5147
|
});
|
|
5148
|
+
const ActivityReferenceProps = {
|
|
5149
|
+
reference_kind: Schema.Literals(["payment", "movement"]),
|
|
5150
|
+
reference_id: Schema.String
|
|
5151
|
+
};
|
|
5152
|
+
const ActivityFilterProps = {
|
|
5153
|
+
filter_kind: Schema.optional(Schema.Literals([
|
|
5154
|
+
"all",
|
|
5155
|
+
"payment",
|
|
5156
|
+
"movement"
|
|
5157
|
+
])),
|
|
5158
|
+
filter_direction: Schema.optional(Schema.Literals([
|
|
5159
|
+
"all",
|
|
5160
|
+
"in",
|
|
5161
|
+
"out",
|
|
5162
|
+
"self"
|
|
5163
|
+
])),
|
|
5164
|
+
filter_status: Schema.optional(Schema.Array(Schema.Literals([
|
|
5165
|
+
"pending",
|
|
5166
|
+
"settling",
|
|
5167
|
+
"pending_claim",
|
|
5168
|
+
"scheduled",
|
|
5169
|
+
"streaming",
|
|
5170
|
+
"settled",
|
|
5171
|
+
"cancelled",
|
|
5172
|
+
"failed"
|
|
5173
|
+
])))
|
|
5174
|
+
};
|
|
5175
|
+
const ActivityActionProps = {
|
|
5176
|
+
...TelemetryEnvelopeProps,
|
|
5177
|
+
scope_kind: Schema.Literals(["account", "organization"]),
|
|
5178
|
+
reason_code: Schema.optional(Schema.Literals(CAPXUL_ERROR_CODES))
|
|
5179
|
+
};
|
|
5180
|
+
Schema.Struct({
|
|
5181
|
+
name: Schema.Literal("contact_relationship_changed"),
|
|
5182
|
+
props: Schema.Struct({
|
|
5183
|
+
...TelemetryEnvelopeProps,
|
|
5184
|
+
change: Schema.Literals([
|
|
5185
|
+
"added",
|
|
5186
|
+
"renamed",
|
|
5187
|
+
"hidden",
|
|
5188
|
+
"restored"
|
|
5189
|
+
]),
|
|
5190
|
+
scope_kind: Schema.Literals(["account", "organization"]),
|
|
5191
|
+
scope_id: Schema.String,
|
|
5192
|
+
owner_party_id: Schema.String,
|
|
5193
|
+
party_id: Schema.String,
|
|
5194
|
+
hidden: Schema.Boolean,
|
|
5195
|
+
occurred_at: Schema.Number,
|
|
5196
|
+
operation: Schema.Literals([
|
|
5197
|
+
CAPXUL_OPERATIONS.addressBook.add,
|
|
5198
|
+
CAPXUL_OPERATIONS.addressBook.label,
|
|
5199
|
+
CAPXUL_OPERATIONS.addressBook.hide,
|
|
5200
|
+
CAPXUL_OPERATIONS.addressBook.unhide
|
|
5201
|
+
])
|
|
5202
|
+
})
|
|
5203
|
+
});
|
|
5204
|
+
const ContactActionProps = {
|
|
5205
|
+
...TelemetryEnvelopeProps,
|
|
5206
|
+
scope_kind: Schema.Literals(["account", "organization"]),
|
|
5207
|
+
party_id: OptionalString,
|
|
5208
|
+
reason_code: Schema.optional(Schema.Literals(CAPXUL_ERROR_CODES))
|
|
5209
|
+
};
|
|
5210
|
+
Schema.Struct({
|
|
5211
|
+
name: Schema.Literal("ui_contact_action_completed"),
|
|
5212
|
+
props: Schema.Union([
|
|
5213
|
+
Schema.Struct({
|
|
5214
|
+
...ContactActionProps,
|
|
5215
|
+
action: Schema.Literal("add"),
|
|
5216
|
+
outcome: Schema.Literals(["opened", "cancelled"])
|
|
5217
|
+
}),
|
|
5218
|
+
Schema.Struct({
|
|
5219
|
+
...ContactActionProps,
|
|
5220
|
+
action: Schema.Literal("refusal"),
|
|
5221
|
+
outcome: Schema.Literal("displayed")
|
|
5222
|
+
}),
|
|
5223
|
+
Schema.Struct({
|
|
5224
|
+
...ContactActionProps,
|
|
5225
|
+
action: Schema.Literal("retry"),
|
|
5226
|
+
outcome: Schema.Literal("requested")
|
|
5227
|
+
})
|
|
5228
|
+
])
|
|
5229
|
+
});
|
|
5230
|
+
Schema.Struct({
|
|
5231
|
+
name: Schema.Literal("activity_annotation_saved"),
|
|
5232
|
+
props: Schema.Struct({
|
|
5233
|
+
...TelemetryEnvelopeProps,
|
|
5234
|
+
...ActivityReferenceProps,
|
|
5235
|
+
scope_kind: Schema.Literals(["account", "organization"]),
|
|
5236
|
+
scope_id: Schema.String,
|
|
5237
|
+
occurred_at: Schema.Number
|
|
5238
|
+
})
|
|
5239
|
+
});
|
|
5240
|
+
Schema.Struct({
|
|
5241
|
+
name: Schema.Literal("ui_activity_action_completed"),
|
|
5242
|
+
props: Schema.Union([
|
|
5243
|
+
Schema.Struct({
|
|
5244
|
+
...ActivityActionProps,
|
|
5245
|
+
...ActivityFilterProps,
|
|
5246
|
+
action: Schema.Literal("filter"),
|
|
5247
|
+
outcome: Schema.Literal("committed")
|
|
5248
|
+
}),
|
|
5249
|
+
Schema.Struct({
|
|
5250
|
+
...ActivityActionProps,
|
|
5251
|
+
action: Schema.Literal("refusal"),
|
|
5252
|
+
outcome: Schema.Literal("displayed")
|
|
5253
|
+
}),
|
|
5254
|
+
Schema.Struct({
|
|
5255
|
+
...ActivityActionProps,
|
|
5256
|
+
action: Schema.Literal("retry"),
|
|
5257
|
+
outcome: Schema.Literal("requested")
|
|
5258
|
+
}),
|
|
5259
|
+
Schema.Struct({
|
|
5260
|
+
...ActivityActionProps,
|
|
5261
|
+
...ActivityReferenceProps,
|
|
5262
|
+
action: Schema.Literal("detail"),
|
|
5263
|
+
outcome: Schema.Literals(["opened", "failed"])
|
|
5264
|
+
}),
|
|
5265
|
+
Schema.Struct({
|
|
5266
|
+
...ActivityActionProps,
|
|
5267
|
+
...ActivityReferenceProps,
|
|
5268
|
+
action: Schema.Literal("receipt"),
|
|
5269
|
+
outcome: Schema.Literals([
|
|
5270
|
+
"document_rendered",
|
|
5271
|
+
"explorer_opened",
|
|
5272
|
+
"popup_blocked",
|
|
5273
|
+
"failed"
|
|
5274
|
+
])
|
|
5275
|
+
}),
|
|
5276
|
+
Schema.Struct({
|
|
5277
|
+
...ActivityActionProps,
|
|
5278
|
+
...ActivityFilterProps,
|
|
5279
|
+
action: Schema.Literal("export"),
|
|
5280
|
+
outcome: Schema.Literals([
|
|
5281
|
+
"completed",
|
|
5282
|
+
"partial",
|
|
5283
|
+
"failed"
|
|
5284
|
+
]),
|
|
5285
|
+
row_count: Schema.optional(Schema.Number),
|
|
5286
|
+
truncated: Schema.optional(Schema.Boolean)
|
|
5287
|
+
})
|
|
5288
|
+
])
|
|
5289
|
+
});
|
|
5142
5290
|
function redactTelemetryProps(name, props, options = {}) {
|
|
5143
5291
|
if (props === void 0) return void 0;
|
|
5144
5292
|
const clone = cloneProps$1(props);
|
|
@@ -7091,9 +7239,10 @@ const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
|
|
|
7091
7239
|
const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
|
|
7092
7240
|
/** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
|
|
7093
7241
|
function attachInvocationObservation(target, source) {
|
|
7094
|
-
const snapshot = Object.freeze(
|
|
7242
|
+
const snapshot = Object.freeze({
|
|
7095
7243
|
active: source.active,
|
|
7096
|
-
|
|
7244
|
+
...source.actorId === void 0 ? {} : { actorId: source.actorId },
|
|
7245
|
+
...source.context === void 0 ? {} : { context: Object.freeze({ ...source.context }) }
|
|
7097
7246
|
});
|
|
7098
7247
|
Object.defineProperty(target, INVOCATION_OBSERVATION, {
|
|
7099
7248
|
configurable: false,
|
|
@@ -7123,6 +7272,12 @@ function markFailureInvocationSnapshot(failure, snapshot) {
|
|
|
7123
7272
|
});
|
|
7124
7273
|
return failure;
|
|
7125
7274
|
}
|
|
7275
|
+
/** @internal Read the call-start delivery decision; undefined means a direct adapter call. */
|
|
7276
|
+
function readFailureInvocationSnapshot(failure) {
|
|
7277
|
+
if (typeof failure !== "object" || failure === null) return void 0;
|
|
7278
|
+
const snapshot = failure[FAILURE_INVOCATION_SNAPSHOT];
|
|
7279
|
+
return typeof snapshot === "object" && snapshot !== null && "active" in snapshot ? snapshot : void 0;
|
|
7280
|
+
}
|
|
7126
7281
|
//#endregion
|
|
7127
7282
|
//#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
|
|
7128
7283
|
async function emitProvisioningTelemetry(telemetry, smartAccount) {
|
|
@@ -9740,10 +9895,10 @@ const logIdentityTransition = (record) => (record.outcome === "applied" ? Effect
|
|
|
9740
9895
|
//#region ../../packages/sdk/src/domain/machine/shell.ts
|
|
9741
9896
|
const INVOCATION_PARENT_SPAN = Symbol("@capxul/sdk/identity-invocation-parent-span");
|
|
9742
9897
|
function carryInvocationParentSpan(controls, parent) {
|
|
9743
|
-
return {
|
|
9898
|
+
return copyInvocationObservation(controls, {
|
|
9744
9899
|
...controls,
|
|
9745
9900
|
[INVOCATION_PARENT_SPAN]: parent
|
|
9746
|
-
};
|
|
9901
|
+
});
|
|
9747
9902
|
}
|
|
9748
9903
|
function withInvocationParentSpan(effect, controls) {
|
|
9749
9904
|
const parent = controls?.[INVOCATION_PARENT_SPAN];
|
|
@@ -10094,13 +10249,13 @@ async function toCapxulResult(program, layer) {
|
|
|
10094
10249
|
* with `{ publicError }` rather than a bare `CapxulError`, so the wrapper is
|
|
10095
10250
|
* unwrapped here — once — instead of at every call site.
|
|
10096
10251
|
*/
|
|
10097
|
-
async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise) {
|
|
10098
|
-
if (signal?.aborted === true) return {
|
|
10252
|
+
async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise, observe) {
|
|
10253
|
+
if (signal?.aborted === true && observe === void 0) return {
|
|
10099
10254
|
ok: false,
|
|
10100
10255
|
error: Errors.cancelled({ operation })
|
|
10101
10256
|
};
|
|
10102
|
-
const program =
|
|
10103
|
-
|
|
10257
|
+
const program = signal?.aborted === true ? Effect.fail(Errors.cancelled({ operation })) : Effect.suspend(effect).pipe(Effect.mapError((error) => error.publicError));
|
|
10258
|
+
const controlled = signal === void 0 ? program : Effect.raceFirst(program, Effect.callback((resume) => {
|
|
10104
10259
|
if (signal.aborted) {
|
|
10105
10260
|
resume(Effect.fail(Errors.cancelled({ operation })));
|
|
10106
10261
|
return Effect.void;
|
|
@@ -10108,7 +10263,8 @@ async function runIfActive(signal, operation, effect, runPromise = Effect.runPro
|
|
|
10108
10263
|
const onAbort = () => resume(Effect.fail(Errors.cancelled({ operation })));
|
|
10109
10264
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
10110
10265
|
return Effect.sync(() => signal.removeEventListener("abort", onAbort));
|
|
10111
|
-
}))
|
|
10266
|
+
}));
|
|
10267
|
+
return runProgram(observe === void 0 ? controlled : observe(controlled), runPromise);
|
|
10112
10268
|
}
|
|
10113
10269
|
//#endregion
|
|
10114
10270
|
//#region ../../packages/sdk/src/surface/_shared/effect-actor-bridge.ts
|
|
@@ -10159,22 +10315,52 @@ async function runPortEffect(effect, controls, operation = CAPXUL_OPERATIONS.run
|
|
|
10159
10315
|
orElse: () => Effect.fail({ publicError: Errors.providerTimeout("sdk", operation, timeoutMs) })
|
|
10160
10316
|
}))).pipe(Effect.mapError((failure) => failure.publicError)), controls, operation, runPromise);
|
|
10161
10317
|
}
|
|
10318
|
+
/** Keep observation metadata while the compound operation owns cancellation. */
|
|
10319
|
+
function observationOnlyControls(controls) {
|
|
10320
|
+
const { signal: _signal, timeoutMs: _timeoutMs, deadlineMs: _deadlineMs, ...observation } = controls ?? {};
|
|
10321
|
+
return copyInvocationObservation(controls, observation);
|
|
10322
|
+
}
|
|
10162
10323
|
/** Observe a public Effect that already uses the canonical CapxulError channel. */
|
|
10163
10324
|
async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.runtime.port, runPromise = Effect.runPromise) {
|
|
10164
10325
|
const invocation = readInvocationObservation(controls);
|
|
10165
|
-
const correlationId = safeEngineeringIdentifier(
|
|
10166
|
-
const
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10326
|
+
const correlationId = safeEngineeringIdentifier(invocation?.context?.correlationId ?? controls?.correlation_id);
|
|
10327
|
+
const context = invocation?.active === false ? void 0 : sanitizeObservationContext(invocation?.context);
|
|
10328
|
+
const fields = {
|
|
10329
|
+
operation,
|
|
10330
|
+
...correlationId === void 0 ? {} : { correlation_id: correlationId },
|
|
10331
|
+
...context?.sessionId === void 0 ? {} : {
|
|
10332
|
+
session_id: context.sessionId,
|
|
10333
|
+
sessionId: context.sessionId
|
|
10334
|
+
},
|
|
10335
|
+
...context?.journeyId === void 0 ? {} : { journey_id: context.journeyId },
|
|
10336
|
+
...context?.release === void 0 ? {} : { release: context.release },
|
|
10337
|
+
...context?.application === void 0 ? {} : { application: context.application },
|
|
10338
|
+
...safeEngineeringIdentifier(invocation?.actorId) === void 0 ? {} : {
|
|
10339
|
+
actor_id: invocation.actorId,
|
|
10340
|
+
actor_kind: "authenticated",
|
|
10341
|
+
posthogDistinctId: invocation.actorId
|
|
10342
|
+
}
|
|
10343
|
+
};
|
|
10344
|
+
const result = await runIfActive(controls?.signal, operation, () => effect.pipe(Effect.mapError((publicError) => ({ publicError }))), runPromise, (program) => withInvocationParentSpan(Effect.gen(function* () {
|
|
10345
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
10346
|
+
const exit = yield* Effect.exit(program.pipe(Effect.catchDefect((cause) => Effect.fail(Errors.unknown(cause)))));
|
|
10347
|
+
const duration_ms = (yield* Clock.currentTimeMillis) - startedAt;
|
|
10348
|
+
const error = Exit.isFailure(exit) ? Cause.squash(exit.cause) : void 0;
|
|
10349
|
+
const failure = error instanceof CapxulError ? error : void 0;
|
|
10350
|
+
const outcome = Exit.isSuccess(exit) ? "succeeded" : failure?.code === "CANCELLED" ? "cancelled" : failure !== void 0 && EXPECTED_OPERATION_OUTCOMES.has(failure.code) ? "refused" : "failed";
|
|
10351
|
+
const completion = {
|
|
10352
|
+
...fields,
|
|
10353
|
+
duration_ms,
|
|
10354
|
+
outcome,
|
|
10355
|
+
...failure === void 0 ? {} : { failure_code: failure.code },
|
|
10356
|
+
...typeof failure?.mode === "string" ? { mode: failure.mode } : {},
|
|
10357
|
+
...failure?.mode === void 0 && typeof failure?.details?.failure_mode === "string" ? { mode: failure.details.failure_mode } : {}
|
|
10358
|
+
};
|
|
10359
|
+
yield* Effect.annotateCurrentSpan(completion).pipe(Effect.catchCause(() => Effect.void));
|
|
10360
|
+
yield* (outcome === "failed" ? Effect.logError("capxul_sdk_operation") : Effect.logInfo("capxul_sdk_operation")).pipe(Effect.annotateLogs(completion), Effect.catchCause(() => Effect.void));
|
|
10361
|
+
return yield* Exit.isSuccess(exit) ? Effect.succeed(exit.value) : Effect.failCause(exit.cause);
|
|
10362
|
+
}).pipe(Effect.withSpan(operation)), controls));
|
|
10363
|
+
return !result.ok && invocation !== void 0 ? markFailureInvocationSnapshot(result, invocation) : result;
|
|
10178
10364
|
}
|
|
10179
10365
|
/** Map machine-internal failure state onto the public SDK error vocabulary. */
|
|
10180
10366
|
function publicIdentityFailure(failure) {
|
|
@@ -10733,76 +10919,110 @@ function makeActorRelationshipMethods(deps) {
|
|
|
10733
10919
|
const fns = actorScopeContract;
|
|
10734
10920
|
return {
|
|
10735
10921
|
addressBook: {
|
|
10736
|
-
list: (input, options) =>
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10922
|
+
list: (input, options) => {
|
|
10923
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10924
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.list, Effect.suspend(() => convexCall.query(fns.addressBookList, copyInvocationObservation(controls, {
|
|
10925
|
+
actor,
|
|
10926
|
+
...input?.includeHidden === void 0 ? {} : { includeHidden: input.includeHidden }
|
|
10927
|
+
}))), (entries) => entries.map(mapAddressBookEntry)), controls, CAPXUL_OPERATIONS.addressBook.list, deps.runPromise);
|
|
10928
|
+
},
|
|
10929
|
+
get: (entryId, options) => {
|
|
10930
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10931
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.get, Effect.suspend(() => convexCall.query(fns.addressBookGet, copyInvocationObservation(controls, {
|
|
10932
|
+
actor,
|
|
10933
|
+
partyId: entryId
|
|
10934
|
+
}))), (entry) => entry === null ? null : mapAddressBookEntry(entry)), controls, CAPXUL_OPERATIONS.addressBook.get, deps.runPromise);
|
|
10935
|
+
},
|
|
10936
|
+
add: (input, options) => {
|
|
10937
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10745
10938
|
const ref = normalizeRefForBackend$1(input.ref, "ref");
|
|
10746
|
-
if (!ref.ok) return ref;
|
|
10747
|
-
return
|
|
10939
|
+
if (!ref.ok) return runCapxulEffect(Effect.fail(ref.error), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
|
|
10940
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.add, Effect.suspend(() => convexCall.mutation(fns.addressBookAdd, copyInvocationObservation(controls, {
|
|
10748
10941
|
actor,
|
|
10749
10942
|
ref: ref.value,
|
|
10750
10943
|
...input.label === void 0 ? {} : { label: input.label }
|
|
10751
|
-
})), mapAddressBookEntry);
|
|
10944
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
|
|
10752
10945
|
},
|
|
10753
|
-
hide: (entryId, options) =>
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10946
|
+
hide: (entryId, options) => {
|
|
10947
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10948
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.hide, Effect.suspend(() => convexCall.mutation(fns.addressBookHide, copyInvocationObservation(controls, {
|
|
10949
|
+
actor,
|
|
10950
|
+
partyId: entryId
|
|
10951
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.hide, deps.runPromise);
|
|
10952
|
+
},
|
|
10953
|
+
unhide: (entryId, options) => {
|
|
10954
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10955
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.unhide, Effect.suspend(() => convexCall.mutation(fns.addressBookUnhide, copyInvocationObservation(controls, {
|
|
10956
|
+
actor,
|
|
10957
|
+
partyId: entryId
|
|
10958
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.unhide, deps.runPromise);
|
|
10959
|
+
},
|
|
10960
|
+
label: (input, options) => {
|
|
10961
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10962
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.label, Effect.suspend(() => convexCall.mutation(fns.addressBookLabel, copyInvocationObservation(controls, {
|
|
10963
|
+
actor,
|
|
10964
|
+
partyId: input.entryId,
|
|
10965
|
+
label: input.label
|
|
10966
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.label, deps.runPromise);
|
|
10967
|
+
}
|
|
10766
10968
|
},
|
|
10767
10969
|
requests: {
|
|
10768
|
-
issue:
|
|
10970
|
+
issue: (input, options) => {
|
|
10971
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10769
10972
|
const payer = normalizeRefForBackend$1(input.payer, "payer");
|
|
10770
|
-
if (!payer.ok) return payer;
|
|
10771
|
-
return
|
|
10973
|
+
if (!payer.ok) return runCapxulEffect(Effect.fail(payer.error), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
|
|
10974
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.issue, Effect.suspend(() => convexCall.mutation(fns.requestsIssue, copyInvocationObservation(controls, {
|
|
10772
10975
|
actor,
|
|
10773
10976
|
payer: payer.value,
|
|
10774
10977
|
amount: input.amount,
|
|
10775
10978
|
reference: input.reference,
|
|
10776
10979
|
...input.memo === void 0 ? {} : { memo: input.memo },
|
|
10777
10980
|
...input.expiresAt === void 0 ? {} : { expiresAt: input.expiresAt }
|
|
10778
|
-
})), (request) => mapActorRequest(request, input.payer));
|
|
10981
|
+
}))), (request) => mapActorRequest(request, input.payer)), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
|
|
10779
10982
|
},
|
|
10780
|
-
list: (options) =>
|
|
10781
|
-
|
|
10782
|
-
actor,
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10983
|
+
list: (options) => {
|
|
10984
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10985
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.list, Effect.suspend(() => convexCall.query(fns.requestsList, copyInvocationObservation(controls, { actor }))), (requests) => requests.map((request) => mapActorRequest(request))), controls, CAPXUL_OPERATIONS.requests.list, deps.runPromise);
|
|
10986
|
+
},
|
|
10987
|
+
get: (requestId, options) => {
|
|
10988
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10989
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.get, Effect.suspend(() => convexCall.query(fns.requestsGet, copyInvocationObservation(controls, {
|
|
10990
|
+
actor,
|
|
10991
|
+
paymentRequestId: requestId
|
|
10992
|
+
}))), (request) => request === null ? null : mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.get, deps.runPromise);
|
|
10993
|
+
},
|
|
10994
|
+
cancel: (requestId, options) => {
|
|
10995
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10996
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.cancel, Effect.suspend(() => convexCall.mutation(fns.requestsCancel, copyInvocationObservation(controls, {
|
|
10997
|
+
actor,
|
|
10998
|
+
paymentRequestId: requestId
|
|
10999
|
+
}))), (request) => mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.cancel, deps.runPromise);
|
|
11000
|
+
}
|
|
10789
11001
|
},
|
|
10790
11002
|
inbox: {
|
|
10791
|
-
list: (options) =>
|
|
10792
|
-
|
|
10793
|
-
|
|
11003
|
+
list: (options) => {
|
|
11004
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
11005
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.inbox.list, Effect.suspend(() => convexCall.query(fns.inboxList, copyInvocationObservation(controls, { actor }))), (items) => items.map(mapInboxItem)), controls, CAPXUL_OPERATIONS.inbox.list, deps.runPromise);
|
|
11006
|
+
},
|
|
11007
|
+
approve: (input, options) => {
|
|
11008
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
11009
|
+
return runPortEffect(Effect.suspend(() => convexCall.mutation(fns.inboxApprove, copyInvocationObservation(controls, {
|
|
10794
11010
|
actor,
|
|
10795
11011
|
paymentRequestId: input.requestId,
|
|
10796
11012
|
...input.timing === void 0 ? {} : { timing: input.timing },
|
|
10797
11013
|
...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
|
|
10798
|
-
}))
|
|
10799
|
-
|
|
10800
|
-
|
|
11014
|
+
}))).pipe(Effect.flatMap((prepared) => {
|
|
11015
|
+
const result = mapApprovedInboxPayment(prepared, input);
|
|
11016
|
+
return result.ok ? Effect.succeed(result.value) : Effect.fail({ publicError: result.error });
|
|
11017
|
+
})), controls, CAPXUL_OPERATIONS.inbox.approve, deps.runPromise);
|
|
10801
11018
|
},
|
|
10802
|
-
decline: (requestId, options) =>
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
11019
|
+
decline: (requestId, options) => {
|
|
11020
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
11021
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.inbox.decline, Effect.suspend(() => convexCall.mutation(fns.inboxDecline, copyInvocationObservation(controls, {
|
|
11022
|
+
actor,
|
|
11023
|
+
paymentRequestId: requestId
|
|
11024
|
+
}))), mapInboxItem), controls, CAPXUL_OPERATIONS.inbox.decline, deps.runPromise);
|
|
11025
|
+
}
|
|
10806
11026
|
},
|
|
10807
11027
|
profile: {
|
|
10808
11028
|
get: (options) => {
|
|
@@ -10879,22 +11099,12 @@ function missingConvexCall(operation) {
|
|
|
10879
11099
|
* promise and the caller's `if (!result.ok)` never runs (ADR-0023: errors are
|
|
10880
11100
|
* values, and a code crosses the seam).
|
|
10881
11101
|
*/
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
ok: true,
|
|
10888
|
-
value: f(result.value)
|
|
10889
|
-
};
|
|
10890
|
-
} catch (cause) {
|
|
10891
|
-
return {
|
|
10892
|
-
ok: false,
|
|
10893
|
-
error: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause)
|
|
10894
|
-
};
|
|
10895
|
-
}
|
|
11102
|
+
function mapReply(operation, program, project) {
|
|
11103
|
+
return program.pipe(Effect.flatMap((value) => Effect.try({
|
|
11104
|
+
try: () => project(value),
|
|
11105
|
+
catch: (cause) => ({ publicError: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause) })
|
|
11106
|
+
})));
|
|
10896
11107
|
}
|
|
10897
|
-
const awaitableConvex = runIfActive;
|
|
10898
11108
|
const ADDRESS_BOOK_RELATIONSHIPS = [
|
|
10899
11109
|
"paid",
|
|
10900
11110
|
"paidBy",
|
|
@@ -11262,6 +11472,8 @@ function makeAccountMethods(deps) {
|
|
|
11262
11472
|
return {
|
|
11263
11473
|
methods: {
|
|
11264
11474
|
...makeActorRelationshipMethods({
|
|
11475
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
11476
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
11265
11477
|
actor: { kind: "account" },
|
|
11266
11478
|
...deps.convexCall === void 0 ? {} : { convexCall: deps.convexCall },
|
|
11267
11479
|
...deps.profileMethods === void 0 ? {} : { accountProfileMethods: deps.profileMethods }
|
|
@@ -11315,7 +11527,7 @@ const moneyExecutionContract = {
|
|
|
11315
11527
|
};
|
|
11316
11528
|
//#endregion
|
|
11317
11529
|
//#region ../../packages/sdk/package.json
|
|
11318
|
-
var version$1 = "4.
|
|
11530
|
+
var version$1 = "4.1.0";
|
|
11319
11531
|
//#endregion
|
|
11320
11532
|
//#region ../../packages/sdk/src/telemetry/exception-projection.ts
|
|
11321
11533
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -11394,7 +11606,8 @@ function observeSdkClient(client, adapter, snapshot) {
|
|
|
11394
11606
|
};
|
|
11395
11607
|
const processOutput = (output, path, invocation) => {
|
|
11396
11608
|
if (isFailedResult(output)) {
|
|
11397
|
-
|
|
11609
|
+
const captured = readFailureInvocationSnapshot(output);
|
|
11610
|
+
report(adapter, "operation", path.join("."), output.error, captured ?? invocation, void 0, captured !== void 0);
|
|
11398
11611
|
return output;
|
|
11399
11612
|
}
|
|
11400
11613
|
if (isCapxulResult(output)) return output;
|
|
@@ -11426,7 +11639,7 @@ function reportedByMachine(cause) {
|
|
|
11426
11639
|
}
|
|
11427
11640
|
return false;
|
|
11428
11641
|
}
|
|
11429
|
-
function report(adapter, kind, operation, cause, invocation, origin) {
|
|
11642
|
+
function report(adapter, kind, operation, cause, invocation, origin, authoritativeSnapshot = false) {
|
|
11430
11643
|
if (origin === "machine") {
|
|
11431
11644
|
let link = cause;
|
|
11432
11645
|
for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
|
|
@@ -11438,7 +11651,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
|
|
|
11438
11651
|
const kindName = normalizeErrorKind(errorKind$1(cause));
|
|
11439
11652
|
const context = sanitizeObservationContext({
|
|
11440
11653
|
...invocation.context,
|
|
11441
|
-
|
|
11654
|
+
...!authoritativeSnapshot && isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
11442
11655
|
});
|
|
11443
11656
|
const detail = failureDetail(cause);
|
|
11444
11657
|
const evidence = failureEvidence(cause);
|
|
@@ -11452,6 +11665,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
|
|
|
11452
11665
|
...evidence
|
|
11453
11666
|
}, {
|
|
11454
11667
|
active: invocation.active,
|
|
11668
|
+
...invocation.actorId === void 0 ? {} : { actorId: invocation.actorId },
|
|
11455
11669
|
...context === void 0 ? {} : { context }
|
|
11456
11670
|
});
|
|
11457
11671
|
try {
|
|
@@ -11867,17 +12081,17 @@ async function fingerprintPaymentIntent(intent) {
|
|
|
11867
12081
|
function matchesIntent(expected) {
|
|
11868
12082
|
return async (request) => await fingerprintPaymentIntent(request) === await fingerprintPaymentIntent(expected);
|
|
11869
12083
|
}
|
|
11870
|
-
async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed) {
|
|
12084
|
+
async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed, controls) {
|
|
11871
12085
|
if (!closePayment) return result;
|
|
11872
|
-
const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => deps.convexCall.action(deps.functions.abandonPaymentExecution, { input: {
|
|
12086
|
+
const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.abandonPaymentExecution, copyInvocationObservation(controls, { input: {
|
|
11873
12087
|
executionId,
|
|
11874
12088
|
reason
|
|
11875
|
-
} }));
|
|
12089
|
+
} }))), controls), deps.runPromise);
|
|
11876
12090
|
if (!abandoned.ok) return abandoned;
|
|
11877
12091
|
if (abandoned.value) onPreparedClosed?.();
|
|
11878
12092
|
return result;
|
|
11879
12093
|
}
|
|
11880
|
-
async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal) {
|
|
12094
|
+
async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls) {
|
|
11881
12095
|
if (isAborted$2(signal)) return {
|
|
11882
12096
|
ok: false,
|
|
11883
12097
|
error: Errors.cancelled({ operation: "payments" })
|
|
@@ -11901,16 +12115,16 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
|
|
|
11901
12115
|
if (!await isExpectedRequest(prepared.value.request)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "prepared_mismatch", {
|
|
11902
12116
|
ok: false,
|
|
11903
12117
|
error: Errors.invalidInput("payment", "prepared command mismatch")
|
|
11904
|
-
}, onPreparedClosed);
|
|
12118
|
+
}, onPreparedClosed, controls);
|
|
11905
12119
|
const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
|
|
11906
12120
|
if (prepared.value.chainId !== deps.chainId || prepared.value.signerAddress.toLowerCase() !== signerAddress.toLowerCase() || prepared.value.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase()) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "prepared_mismatch", {
|
|
11907
12121
|
ok: false,
|
|
11908
12122
|
error: Errors.invalidInput("payment", "prepared authority mismatch")
|
|
11909
|
-
}, onPreparedClosed);
|
|
12123
|
+
}, onPreparedClosed, controls);
|
|
11910
12124
|
if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
|
|
11911
12125
|
ok: false,
|
|
11912
12126
|
error: Errors.cancelled({ operation: "payments" })
|
|
11913
|
-
}, onPreparedClosed);
|
|
12127
|
+
}, onPreparedClosed, controls);
|
|
11914
12128
|
if (prepared.value.emitPaymentInitiated && "items" in prepared.value.request) for (const [index, item] of prepared.value.request.items.entries()) {
|
|
11915
12129
|
const paymentId = prepared.value.paymentIds[index];
|
|
11916
12130
|
const recipient = prepared.value.recipientObservations[index];
|
|
@@ -11931,28 +12145,28 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
|
|
|
11931
12145
|
return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "signer_rejected", {
|
|
11932
12146
|
ok: false,
|
|
11933
12147
|
error: signerFailure(deps.signer.source, "signUserOpHash", cause)
|
|
11934
|
-
}, onPreparedClosed);
|
|
12148
|
+
}, onPreparedClosed, controls);
|
|
11935
12149
|
}
|
|
11936
12150
|
if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
|
|
11937
12151
|
ok: false,
|
|
11938
12152
|
error: Errors.cancelled({ operation: "payments" })
|
|
11939
|
-
}, onPreparedClosed);
|
|
11940
|
-
return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, { input: {
|
|
12153
|
+
}, onPreparedClosed, controls);
|
|
12154
|
+
return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, copyInvocationObservation(controls, { input: {
|
|
11941
12155
|
executionId: prepared.value.executionId,
|
|
11942
12156
|
signature
|
|
11943
|
-
} }));
|
|
12157
|
+
} }))), controls), deps.runPromise);
|
|
11944
12158
|
}
|
|
11945
|
-
function executePaymentLifecycle(deps, intent, signal) {
|
|
11946
|
-
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, { input: {
|
|
12159
|
+
function executePaymentLifecycle(deps, intent, signal, controls) {
|
|
12160
|
+
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, copyInvocationObservation(controls, { input: {
|
|
11947
12161
|
signerAddress,
|
|
11948
12162
|
intent
|
|
11949
|
-
} })), matchesIntent(intent), false, void 0, signal);
|
|
12163
|
+
} }))), controls), deps.runPromise), matchesIntent(intent), false, void 0, signal, controls);
|
|
11950
12164
|
}
|
|
11951
|
-
function executeOrganizationPayment(deps, input, signal, onPreparedClosed) {
|
|
11952
|
-
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, { input: {
|
|
12165
|
+
function executeOrganizationPayment(deps, input, signal, onPreparedClosed, controls) {
|
|
12166
|
+
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, copyInvocationObservation(controls, { input: {
|
|
11953
12167
|
...input,
|
|
11954
12168
|
signerAddress
|
|
11955
|
-
} })), matchesIntent(input), true, onPreparedClosed, signal);
|
|
12169
|
+
} }))), controls), deps.runPromise), matchesIntent(input), true, onPreparedClosed, signal, controls);
|
|
11956
12170
|
}
|
|
11957
12171
|
//#endregion
|
|
11958
12172
|
//#region ../../packages/sdk/src/surface/payment-execution.ts
|
|
@@ -12391,51 +12605,52 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12391
12605
|
chainId: deps.chainId,
|
|
12392
12606
|
convexCall: deps.convexCall,
|
|
12393
12607
|
functions: executionFns,
|
|
12394
|
-
signer: deps.signer
|
|
12395
|
-
|
|
12396
|
-
};
|
|
12397
|
-
const runLifecycle = async (intent, signal) => {
|
|
12398
|
-
const execution = lifecycleDependencies();
|
|
12399
|
-
if (!execution.ok) return execution;
|
|
12400
|
-
try {
|
|
12401
|
-
const submitted = await executePaymentLifecycle(execution.value, intent, signal);
|
|
12402
|
-
if (!submitted.ok) return submitted;
|
|
12403
|
-
const payments = submitted.value.payments;
|
|
12404
|
-
const payment = payments[0];
|
|
12405
|
-
if (payment === void 0 || payments.length !== 1) return {
|
|
12406
|
-
ok: false,
|
|
12407
|
-
error: Errors.unknown()
|
|
12408
|
-
};
|
|
12409
|
-
return {
|
|
12410
|
-
ok: true,
|
|
12411
|
-
value: normalizePaymentTiming(payment)
|
|
12412
|
-
};
|
|
12413
|
-
} catch (cause) {
|
|
12414
|
-
return {
|
|
12415
|
-
ok: false,
|
|
12416
|
-
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12417
|
-
};
|
|
12418
|
-
}
|
|
12419
|
-
};
|
|
12420
|
-
const retryPayment = async (paymentId, signal) => {
|
|
12421
|
-
const execution = lifecycleDependencies();
|
|
12422
|
-
if (!execution.ok) return execution;
|
|
12423
|
-
try {
|
|
12424
|
-
const submitted = await executePaymentLifecycle(execution.value, {
|
|
12425
|
-
kind: "retry",
|
|
12426
|
-
paymentId
|
|
12427
|
-
}, signal);
|
|
12428
|
-
return submitted.ok ? {
|
|
12429
|
-
ok: true,
|
|
12430
|
-
value: submitted.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
12431
|
-
} : submitted;
|
|
12432
|
-
} catch (cause) {
|
|
12433
|
-
return {
|
|
12434
|
-
ok: false,
|
|
12435
|
-
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12436
|
-
};
|
|
12608
|
+
signer: deps.signer,
|
|
12609
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise }
|
|
12437
12610
|
}
|
|
12438
12611
|
};
|
|
12612
|
+
const runLifecycle = (intent, controls, operation) => runCapxulEffect(Effect.gen(function* () {
|
|
12613
|
+
const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
|
|
12614
|
+
const result = yield* Effect.tryPromise({
|
|
12615
|
+
try: async () => {
|
|
12616
|
+
const execution = lifecycleDependencies();
|
|
12617
|
+
if (!execution.ok) return execution;
|
|
12618
|
+
const submitted = await executePaymentLifecycle(execution.value, intent, controls?.signal, captured);
|
|
12619
|
+
if (!submitted.ok) return submitted;
|
|
12620
|
+
const payments = submitted.value.payments;
|
|
12621
|
+
const payment = payments[0];
|
|
12622
|
+
if (payment === void 0 || payments.length !== 1) return {
|
|
12623
|
+
ok: false,
|
|
12624
|
+
error: Errors.unknown()
|
|
12625
|
+
};
|
|
12626
|
+
return {
|
|
12627
|
+
ok: true,
|
|
12628
|
+
value: normalizePaymentTiming(payment)
|
|
12629
|
+
};
|
|
12630
|
+
},
|
|
12631
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12632
|
+
});
|
|
12633
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
12634
|
+
}), observationOnlyControls(controls), operation, deps.runPromise);
|
|
12635
|
+
const retryPayment = (paymentId, controls) => runCapxulEffect(Effect.gen(function* () {
|
|
12636
|
+
const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
|
|
12637
|
+
const result = yield* Effect.tryPromise({
|
|
12638
|
+
try: async () => {
|
|
12639
|
+
const execution = lifecycleDependencies();
|
|
12640
|
+
if (!execution.ok) return execution;
|
|
12641
|
+
const submitted = await executePaymentLifecycle(execution.value, {
|
|
12642
|
+
kind: "retry",
|
|
12643
|
+
paymentId
|
|
12644
|
+
}, controls?.signal, captured);
|
|
12645
|
+
return submitted.ok ? {
|
|
12646
|
+
ok: true,
|
|
12647
|
+
value: submitted.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
12648
|
+
} : submitted;
|
|
12649
|
+
},
|
|
12650
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12651
|
+
});
|
|
12652
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
12653
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.retry, deps.runPromise);
|
|
12439
12654
|
return {
|
|
12440
12655
|
me: {
|
|
12441
12656
|
get: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.me.get, () => deps.convexCall.query(fns.me, {})),
|
|
@@ -12487,58 +12702,64 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12487
12702
|
},
|
|
12488
12703
|
payments: {
|
|
12489
12704
|
pay,
|
|
12490
|
-
retry: (paymentId, options) => retryPayment(paymentId, options
|
|
12705
|
+
retry: (paymentId, options) => retryPayment(paymentId, deps.invocationControls?.(options) ?? options),
|
|
12491
12706
|
createCommitment: (input, options) => pay(input, options),
|
|
12492
12707
|
claim: (paymentId, options) => runLifecycle({
|
|
12493
12708
|
kind: "claim",
|
|
12494
12709
|
paymentId
|
|
12495
|
-
}, options
|
|
12710
|
+
}, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.claim),
|
|
12496
12711
|
list: async (options) => mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.payments.list, () => deps.convexCall.query(fns.listPayments, {})), (payments) => payments.map(normalizePaymentTiming)),
|
|
12497
12712
|
get: async (paymentId, options) => mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.payments.get, () => deps.convexCall.query(fns.getPayment, { paymentId })), (payment) => payment === null ? null : normalizePaymentTiming(payment)),
|
|
12498
12713
|
cancel: (paymentId, options) => runLifecycle({
|
|
12499
12714
|
kind: "cancel",
|
|
12500
12715
|
paymentId
|
|
12501
|
-
}, options
|
|
12716
|
+
}, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.cancel),
|
|
12502
12717
|
redirect: async (input, options) => {
|
|
12718
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12503
12719
|
const recipient = normalizeTargetForBackend(input.to, "to");
|
|
12504
|
-
if (!recipient.ok) return recipient;
|
|
12720
|
+
if (!recipient.ok) return runCapxulEffect(Effect.fail(recipient.error), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.redirect, deps.runPromise);
|
|
12505
12721
|
return runLifecycle({
|
|
12506
12722
|
kind: "redirect",
|
|
12507
12723
|
paymentId: input.paymentId,
|
|
12508
12724
|
recipient: recipient.value
|
|
12509
|
-
},
|
|
12725
|
+
}, controls, CAPXUL_OPERATIONS.payments.redirect);
|
|
12510
12726
|
}
|
|
12511
12727
|
},
|
|
12512
12728
|
activity: {
|
|
12513
|
-
list: (params, options) =>
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12729
|
+
list: (params, options) => {
|
|
12730
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12731
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityList, copyInvocationObservation(controls, { input: {
|
|
12732
|
+
...activityActorField(params?.actor),
|
|
12733
|
+
...params?.cursor === void 0 ? {} : { cursor: params.cursor },
|
|
12734
|
+
...params?.limit === void 0 ? {} : { limit: params.limit },
|
|
12735
|
+
...params?.range === void 0 ? {} : { range: params.range },
|
|
12736
|
+
...params?.filter === void 0 ? {} : { filter: params.filter }
|
|
12737
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.list, deps.runPromise);
|
|
12738
|
+
},
|
|
12739
|
+
summary: (params, options) => {
|
|
12740
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12741
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activitySummary, copyInvocationObservation(controls, { input: {
|
|
12742
|
+
...activityActorField(params?.actor),
|
|
12743
|
+
...params?.window === void 0 ? {} : { window: params.window }
|
|
12744
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.summary, deps.runPromise);
|
|
12745
|
+
},
|
|
12524
12746
|
get: (reference, options) => {
|
|
12747
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12525
12748
|
const actor = actorReferenceToBackend(options?.actor);
|
|
12526
|
-
return
|
|
12749
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityGet, copyInvocationObservation(controls, {
|
|
12527
12750
|
input: {
|
|
12528
12751
|
kind: reference.kind,
|
|
12529
12752
|
id: reference.id,
|
|
12530
12753
|
...reference.kind === "payment" ? activityActorField(reference.actor) : {}
|
|
12531
12754
|
},
|
|
12532
12755
|
...actor === void 0 ? {} : { actor }
|
|
12533
|
-
}).pipe(Effect.map(normalizeActivityDetail)));
|
|
12756
|
+
}))).pipe(Effect.map(normalizeActivityDetail)), controls, CAPXUL_OPERATIONS.activity.get, deps.runPromise);
|
|
12534
12757
|
},
|
|
12535
12758
|
annotate: (input, options) => {
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
error: Errors.invalidInput("reference.actor", "must match the annotation actor")
|
|
12539
|
-
});
|
|
12759
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12760
|
+
if (input.actor !== void 0 && input.reference.kind === "payment" && input.reference.actor !== void 0 && !sameActor(input.actor, input.reference.actor)) return runCapxulEffect(Effect.fail(Errors.invalidInput("reference.actor", "must match the annotation actor")), controls, CAPXUL_OPERATIONS.activity.annotate, deps.runPromise);
|
|
12540
12761
|
const referenceActor = input.reference.kind === "payment" ? activityActorField(input.reference.actor).actor : void 0;
|
|
12541
|
-
return
|
|
12762
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(fns.activityAnnotate, copyInvocationObservation(controls, { input: {
|
|
12542
12763
|
...activityActorField(input.actor),
|
|
12543
12764
|
reference: input.reference.kind === "payment" && referenceActor !== void 0 ? {
|
|
12544
12765
|
kind: "payment",
|
|
@@ -12551,7 +12772,7 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12551
12772
|
...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
|
|
12552
12773
|
...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
|
|
12553
12774
|
...input.memo === void 0 ? {} : { memo: input.memo }
|
|
12554
|
-
} }));
|
|
12775
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.annotate, deps.runPromise);
|
|
12555
12776
|
}
|
|
12556
12777
|
},
|
|
12557
12778
|
offramp: {
|
|
@@ -12577,8 +12798,14 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12577
12798
|
}
|
|
12578
12799
|
},
|
|
12579
12800
|
paymentDocuments: {
|
|
12580
|
-
verify: (documentHash, options) =>
|
|
12581
|
-
|
|
12801
|
+
verify: (documentHash, options) => {
|
|
12802
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12803
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.verifyPaymentDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.verify, deps.runPromise);
|
|
12804
|
+
},
|
|
12805
|
+
render: (documentHash, options) => {
|
|
12806
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12807
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.renderStoredDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.render, deps.runPromise);
|
|
12808
|
+
}
|
|
12582
12809
|
}
|
|
12583
12810
|
};
|
|
12584
12811
|
}
|
|
@@ -17375,6 +17602,7 @@ function makeConnectionId() {
|
|
|
17375
17602
|
//#region ../../packages/sdk/src/adapters/convex-call/ConvexCallAdapter.ts
|
|
17376
17603
|
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
17377
17604
|
const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
|
|
17605
|
+
"payroll/actions:authorizeRun",
|
|
17378
17606
|
"account/actions:readBalance",
|
|
17379
17607
|
"holdings/actions:current",
|
|
17380
17608
|
"smartAccount/actions:claim",
|
|
@@ -17392,12 +17620,36 @@ const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
17392
17620
|
"moneyExecution/paymentCommandActions:submitPaymentCommandExecution"
|
|
17393
17621
|
]);
|
|
17394
17622
|
const OBSERVED_CONVEX_QUERIES = /* @__PURE__ */ new Set([
|
|
17623
|
+
"movement/activity:list",
|
|
17624
|
+
"movement/activity:summary",
|
|
17625
|
+
"movement/activity:get",
|
|
17626
|
+
"financialOps/queries:verifyPaymentDocument",
|
|
17627
|
+
"financialOps/queries:renderStoredDocument",
|
|
17628
|
+
"financialOps/addressBook:list",
|
|
17629
|
+
"financialOps/addressBook:get",
|
|
17630
|
+
"financialOps/requestsInbox:list",
|
|
17631
|
+
"financialOps/requestsInbox:get",
|
|
17632
|
+
"financialOps/requestsInbox:inboxList",
|
|
17633
|
+
"payroll/queries:runs",
|
|
17634
|
+
"payroll/queries:groups",
|
|
17635
|
+
"payroll/queries:terms",
|
|
17395
17636
|
"financialOps/queries:resolveRecipient",
|
|
17396
17637
|
"identity/queries:loadByAuthUserId",
|
|
17397
17638
|
"smartAccount/queries:loadByAuthUserId",
|
|
17398
17639
|
"org/lifecycle:load"
|
|
17399
17640
|
]);
|
|
17400
17641
|
const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
|
|
17642
|
+
"movement/activity:annotate",
|
|
17643
|
+
"financialOps/addressBook:add",
|
|
17644
|
+
"financialOps/addressBook:hide",
|
|
17645
|
+
"financialOps/addressBook:unhide",
|
|
17646
|
+
"financialOps/addressBook:label",
|
|
17647
|
+
"financialOps/requestsInbox:issue",
|
|
17648
|
+
"financialOps/requestsInbox:cancel",
|
|
17649
|
+
"financialOps/requestsInbox:approve",
|
|
17650
|
+
"financialOps/requestsInbox:decline",
|
|
17651
|
+
"payroll/mutations:saveGroup",
|
|
17652
|
+
"payroll/mutations:removeGroup",
|
|
17401
17653
|
"identity/mutations:create",
|
|
17402
17654
|
"identity/mutations:update",
|
|
17403
17655
|
"identity/mutations:completeOnboarding",
|
|
@@ -17466,7 +17718,7 @@ var ConvexCallAdapter = class {
|
|
|
17466
17718
|
const carriedContext = sanitizeObservationContext(args.observationContext);
|
|
17467
17719
|
let hostContext;
|
|
17468
17720
|
const invocationSnapshot = readInvocationObservation(args);
|
|
17469
|
-
if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.context;
|
|
17721
|
+
if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.active ? invocationSnapshot.context : void 0;
|
|
17470
17722
|
else {
|
|
17471
17723
|
const resolveContext = this.#observation?.resolveContext;
|
|
17472
17724
|
if (resolveContext !== void 0) try {
|
|
@@ -43307,13 +43559,14 @@ function executionDependencies$1(input) {
|
|
|
43307
43559
|
convexCall: input.convexCall,
|
|
43308
43560
|
functions: moneyExecutionContract,
|
|
43309
43561
|
signer: input.signer,
|
|
43562
|
+
...input.runPromise === void 0 ? {} : { runPromise: input.runPromise },
|
|
43310
43563
|
...input.telemetry === void 0 ? {} : { telemetry: input.telemetry }
|
|
43311
43564
|
};
|
|
43312
43565
|
}
|
|
43313
43566
|
function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
43314
43567
|
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
43315
43568
|
const inFlightOrganizationPayments = /* @__PURE__ */ new Map();
|
|
43316
|
-
const execute = async (input, signal, operation = "organization-pay-batch") => {
|
|
43569
|
+
const execute = async (input, signal, operation = "organization-pay-batch", controls) => {
|
|
43317
43570
|
if (signal?.aborted === true) return {
|
|
43318
43571
|
ok: false,
|
|
43319
43572
|
error: Errors.cancelled({ operation })
|
|
@@ -43346,7 +43599,7 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
43346
43599
|
requestKey: requestKey.key,
|
|
43347
43600
|
items: input.items,
|
|
43348
43601
|
...input.lineage === void 0 ? {} : { lineage: input.lineage }
|
|
43349
|
-
}, controller.signal, () => requestState.resolved = true);
|
|
43602
|
+
}, controller.signal, () => requestState.resolved = true, controls);
|
|
43350
43603
|
flight = {
|
|
43351
43604
|
controller,
|
|
43352
43605
|
promise: submission,
|
|
@@ -43395,41 +43648,73 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
43395
43648
|
return normalized;
|
|
43396
43649
|
};
|
|
43397
43650
|
return {
|
|
43398
|
-
retry:
|
|
43399
|
-
const
|
|
43400
|
-
|
|
43401
|
-
|
|
43402
|
-
|
|
43403
|
-
|
|
43404
|
-
|
|
43405
|
-
|
|
43406
|
-
|
|
43407
|
-
|
|
43408
|
-
|
|
43409
|
-
|
|
43410
|
-
|
|
43411
|
-
|
|
43412
|
-
|
|
43651
|
+
retry: (paymentId, options) => {
|
|
43652
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43653
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43654
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43655
|
+
const captured = carryInvocationParentSpan(controls, parent);
|
|
43656
|
+
const completed = yield* Effect.tryPromise({
|
|
43657
|
+
try: async () => {
|
|
43658
|
+
const execution = executionDependencies$1(deps);
|
|
43659
|
+
if (execution === null) return {
|
|
43660
|
+
ok: false,
|
|
43661
|
+
error: Errors.notImplemented("organizationPayments", "executionComposition")
|
|
43662
|
+
};
|
|
43663
|
+
const result = await executePaymentLifecycle(execution, {
|
|
43664
|
+
kind: "retry",
|
|
43665
|
+
paymentId
|
|
43666
|
+
}, controls?.signal, captured);
|
|
43667
|
+
if (!result.ok) return result;
|
|
43668
|
+
return {
|
|
43669
|
+
ok: true,
|
|
43670
|
+
value: result.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
43671
|
+
};
|
|
43672
|
+
},
|
|
43673
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43674
|
+
});
|
|
43675
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43676
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.retry, deps.runPromise);
|
|
43413
43677
|
},
|
|
43414
|
-
pay:
|
|
43415
|
-
const
|
|
43416
|
-
|
|
43417
|
-
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
|
|
43421
|
-
|
|
43422
|
-
|
|
43423
|
-
|
|
43424
|
-
|
|
43425
|
-
|
|
43426
|
-
|
|
43427
|
-
|
|
43428
|
-
|
|
43429
|
-
|
|
43430
|
-
|
|
43678
|
+
pay: (input, options) => {
|
|
43679
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43680
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43681
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43682
|
+
const captured = carryInvocationParentSpan(controls, parent);
|
|
43683
|
+
const completed = yield* Effect.tryPromise({
|
|
43684
|
+
try: async () => {
|
|
43685
|
+
const { permissionId, requestKey: providedRequestKey, lineage, ...item } = input;
|
|
43686
|
+
const result = await execute({
|
|
43687
|
+
permissionId,
|
|
43688
|
+
...providedRequestKey === void 0 ? {} : { requestKey: providedRequestKey },
|
|
43689
|
+
items: [item],
|
|
43690
|
+
...lineage === void 0 ? {} : { lineage }
|
|
43691
|
+
}, controls?.signal, "organization-pay", captured);
|
|
43692
|
+
if (!result.ok) return result;
|
|
43693
|
+
const payment = result.value[0];
|
|
43694
|
+
return payment === void 0 ? {
|
|
43695
|
+
ok: false,
|
|
43696
|
+
error: Errors.unknown()
|
|
43697
|
+
} : {
|
|
43698
|
+
ok: true,
|
|
43699
|
+
value: payment
|
|
43700
|
+
};
|
|
43701
|
+
},
|
|
43702
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43703
|
+
});
|
|
43704
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43705
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.pay, deps.runPromise);
|
|
43431
43706
|
},
|
|
43432
|
-
payBatch: (input, options) =>
|
|
43707
|
+
payBatch: (input, options) => {
|
|
43708
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43709
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43710
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43711
|
+
const completed = yield* Effect.tryPromise({
|
|
43712
|
+
try: () => execute(input, controls?.signal, void 0, carryInvocationParentSpan(controls, parent)),
|
|
43713
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43714
|
+
});
|
|
43715
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43716
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.payBatch, deps.runPromise);
|
|
43717
|
+
}
|
|
43433
43718
|
};
|
|
43434
43719
|
}
|
|
43435
43720
|
//#endregion
|
|
@@ -43526,12 +43811,14 @@ function executionDependencies(deps) {
|
|
|
43526
43811
|
chainId: deps.chainId,
|
|
43527
43812
|
convexCall: deps.convexCall,
|
|
43528
43813
|
functions: moneyExecutionContract,
|
|
43814
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
43529
43815
|
signer: deps.signer
|
|
43530
43816
|
};
|
|
43531
43817
|
}
|
|
43532
43818
|
function makePayrollMethods(deps, orgId) {
|
|
43533
43819
|
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
43534
|
-
async function authorize(input,
|
|
43820
|
+
async function authorize(input, controls) {
|
|
43821
|
+
const signal = controls?.signal;
|
|
43535
43822
|
const execution = executionDependencies(deps);
|
|
43536
43823
|
if (execution === null) return {
|
|
43537
43824
|
ok: false,
|
|
@@ -43544,14 +43831,14 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43544
43831
|
let authorized;
|
|
43545
43832
|
let preparedClosed = false;
|
|
43546
43833
|
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
43547
|
-
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => deps.convexCall.action(payrollContract.authorizeRun, { input: {
|
|
43834
|
+
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(payrollContract.authorizeRun, copyInvocationObservation(controls, { input: {
|
|
43548
43835
|
orgId,
|
|
43549
43836
|
permissionId: input.permissionId,
|
|
43550
43837
|
requestKey: requestKey.key,
|
|
43551
43838
|
signerAddress,
|
|
43552
43839
|
period: input.period,
|
|
43553
43840
|
items: input.items
|
|
43554
|
-
} }));
|
|
43841
|
+
} }))), controls), deps.runPromise);
|
|
43555
43842
|
if (!prepared.ok) return prepared;
|
|
43556
43843
|
authorized = prepared.value.run;
|
|
43557
43844
|
return {
|
|
@@ -43564,7 +43851,7 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43564
43851
|
requestKey: requestKey.key,
|
|
43565
43852
|
runId: authorized.id,
|
|
43566
43853
|
items: input.items
|
|
43567
|
-
})(request), true, () => preparedClosed = true, signal);
|
|
43854
|
+
})(request), true, () => preparedClosed = true, signal, controls);
|
|
43568
43855
|
try {
|
|
43569
43856
|
await requestKey.finish(submitted.ok || preparedClosed);
|
|
43570
43857
|
} catch {}
|
|
@@ -43578,35 +43865,48 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43578
43865
|
};
|
|
43579
43866
|
}
|
|
43580
43867
|
return {
|
|
43581
|
-
runs: (options) =>
|
|
43582
|
-
|
|
43583
|
-
|
|
43584
|
-
|
|
43585
|
-
|
|
43586
|
-
|
|
43587
|
-
|
|
43588
|
-
return
|
|
43589
|
-
|
|
43590
|
-
|
|
43591
|
-
|
|
43592
|
-
|
|
43593
|
-
};
|
|
43594
|
-
|
|
43868
|
+
runs: (options) => {
|
|
43869
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43870
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.runs, copyInvocationObservation(controls, { orgId }))).pipe(Effect.map(toPayrollRuns)), controls, CAPXUL_OPERATIONS.payroll.runs, deps.runPromise);
|
|
43871
|
+
},
|
|
43872
|
+
authorizeRun: (input, options) => {
|
|
43873
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43874
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43875
|
+
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
43876
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43877
|
+
const result = yield* Effect.tryPromise({
|
|
43878
|
+
try: () => authorize(input, carryInvocationParentSpan(controls, parent)),
|
|
43879
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43880
|
+
});
|
|
43881
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
43882
|
+
}), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
|
|
43883
|
+
},
|
|
43884
|
+
terms: (options) => {
|
|
43885
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43886
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.terms, copyInvocationObservation(controls, { orgId }))), controls, CAPXUL_OPERATIONS.payroll.terms, deps.runPromise);
|
|
43595
43887
|
},
|
|
43596
|
-
terms: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.terms, () => deps.convexCall.query(payrollContract.terms, { orgId })),
|
|
43597
43888
|
groups: {
|
|
43598
|
-
list: (options) =>
|
|
43599
|
-
|
|
43600
|
-
orgId,
|
|
43601
|
-
|
|
43602
|
-
|
|
43603
|
-
|
|
43604
|
-
|
|
43605
|
-
|
|
43606
|
-
|
|
43607
|
-
|
|
43608
|
-
|
|
43609
|
-
|
|
43889
|
+
list: (options) => {
|
|
43890
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43891
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.groups, copyInvocationObservation(controls, { orgId }))).pipe(Effect.map((groups) => groups.map(toPayrollGroup))), controls, CAPXUL_OPERATIONS.payroll.groups.list, deps.runPromise);
|
|
43892
|
+
},
|
|
43893
|
+
save: (input, options) => {
|
|
43894
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43895
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.saveGroup, copyInvocationObservation(controls, {
|
|
43896
|
+
orgId,
|
|
43897
|
+
...input.id === void 0 ? {} : { id: String(input.id) },
|
|
43898
|
+
name: input.name,
|
|
43899
|
+
tone: input.tone,
|
|
43900
|
+
members: input.members
|
|
43901
|
+
}))).pipe(Effect.map(toPayrollGroup)), controls, CAPXUL_OPERATIONS.payroll.groups.save, deps.runPromise);
|
|
43902
|
+
},
|
|
43903
|
+
remove: (id, options) => {
|
|
43904
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43905
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.removeGroup, copyInvocationObservation(controls, {
|
|
43906
|
+
orgId,
|
|
43907
|
+
id
|
|
43908
|
+
}))).pipe(Effect.asVoid), controls, CAPXUL_OPERATIONS.payroll.groups.remove, deps.runPromise);
|
|
43909
|
+
}
|
|
43610
43910
|
}
|
|
43611
43911
|
};
|
|
43612
43912
|
}
|
|
@@ -44055,6 +44355,8 @@ function makeOrgMethods(deps) {
|
|
|
44055
44355
|
const convexCall = deps.convexCall;
|
|
44056
44356
|
return {
|
|
44057
44357
|
...makeActorRelationshipMethods({
|
|
44358
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44359
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44058
44360
|
actor: {
|
|
44059
44361
|
kind: "org",
|
|
44060
44362
|
orgId: String(orgId)
|
|
@@ -44184,6 +44486,8 @@ function makeOrgMethods(deps) {
|
|
|
44184
44486
|
}, String(orgId)),
|
|
44185
44487
|
payments: convexCall === void 0 ? makeNotImplementedOrganizationPaymentsMethods() : makeOrganizationPaymentsMethods({
|
|
44186
44488
|
convexCall,
|
|
44489
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44490
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44187
44491
|
...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
|
|
44188
44492
|
...deps.actor === void 0 ? {} : { actor: deps.actor },
|
|
44189
44493
|
...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
|
|
@@ -44192,6 +44496,8 @@ function makeOrgMethods(deps) {
|
|
|
44192
44496
|
}, String(orgId)),
|
|
44193
44497
|
payroll: convexCall === void 0 ? makeUnavailablePayrollMethods() : makePayrollMethods({
|
|
44194
44498
|
convexCall,
|
|
44499
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44500
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44195
44501
|
...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
|
|
44196
44502
|
...deps.actor === void 0 ? {} : { actor: deps.actor },
|
|
44197
44503
|
...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
|
|
@@ -44601,6 +44907,8 @@ function assembleCapxulClient(input) {
|
|
|
44601
44907
|
let detectPendingOrgInvitations;
|
|
44602
44908
|
let kickProvisioning;
|
|
44603
44909
|
const financialOps = makeFinancialOpsMethods({
|
|
44910
|
+
runPromise: effectRunner.runPromise,
|
|
44911
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44604
44912
|
actor,
|
|
44605
44913
|
chainId: input.bootstrap.chainId,
|
|
44606
44914
|
convexCall: input.ports.convexCall,
|
|
@@ -44620,7 +44928,7 @@ function assembleCapxulClient(input) {
|
|
|
44620
44928
|
profileMethods: financialOps.me,
|
|
44621
44929
|
convexCall: input.ports.convexCall,
|
|
44622
44930
|
runPromise: effectRunner.runPromise,
|
|
44623
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
|
|
44931
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44624
44932
|
...input.signer === void 0 ? {} : { signer: input.signer }
|
|
44625
44933
|
});
|
|
44626
44934
|
kickProvisioning = accountBundle.kickProvisioning;
|
|
@@ -44673,21 +44981,21 @@ function assembleCapxulClient(input) {
|
|
|
44673
44981
|
convexCall: input.ports.convexCall,
|
|
44674
44982
|
telemetry: input.ports.telemetry,
|
|
44675
44983
|
runPromise: effectRunner.runPromise,
|
|
44676
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
|
|
44984
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
|
|
44677
44985
|
});
|
|
44678
44986
|
const accounts = makeAccountsMethods({
|
|
44679
44987
|
accountReadPort: input.ports.accountRead,
|
|
44680
44988
|
chainId: input.bootstrap.chainId,
|
|
44681
44989
|
telemetry: input.ports.telemetry,
|
|
44682
44990
|
runPromise: effectRunner.runPromise,
|
|
44683
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
|
|
44991
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
|
|
44684
44992
|
});
|
|
44685
44993
|
const orgMethods = makeOrgMethods({
|
|
44686
44994
|
actor,
|
|
44687
44995
|
chainId: input.bootstrap.chainId,
|
|
44688
44996
|
telemetry: input.ports.telemetry,
|
|
44689
44997
|
runPromise: effectRunner.runPromise,
|
|
44690
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
|
|
44998
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44691
44999
|
requestKeyScope: `${input.bootstrap.convexUrl}:${String(input.bootstrap.chainId)}`,
|
|
44692
45000
|
...selectedOrgPort === void 0 ? {} : { orgPort: selectedOrgPort },
|
|
44693
45001
|
convexCall: input.ports.convexCall,
|
|
@@ -44838,7 +45146,7 @@ function transitionError(record) {
|
|
|
44838
45146
|
}
|
|
44839
45147
|
function withHostObservation(actor, snapshot) {
|
|
44840
45148
|
if (snapshot === void 0) return actor;
|
|
44841
|
-
const controls = (input) => withHostObservationControls(snapshot, input);
|
|
45149
|
+
const controls = (input) => withHostObservationControls(snapshot, input, actor.authSession()?.authUserId);
|
|
44842
45150
|
return {
|
|
44843
45151
|
...actor,
|
|
44844
45152
|
ask: (event, input) => actor.ask(event, controls(input)),
|
|
@@ -44846,10 +45154,14 @@ function withHostObservation(actor, snapshot) {
|
|
|
44846
45154
|
restoreAuthSession: (session, input) => actor.restoreAuthSession(session, controls(input))
|
|
44847
45155
|
};
|
|
44848
45156
|
}
|
|
44849
|
-
function withHostObservationControls(snapshot, input) {
|
|
44850
|
-
const
|
|
44851
|
-
|
|
44852
|
-
|
|
45157
|
+
function withHostObservationControls(snapshot, input, actorId) {
|
|
45158
|
+
const previous = readInvocationObservation(input);
|
|
45159
|
+
if (previous !== void 0) return attachInvocationObservation({ ...input }, previous);
|
|
45160
|
+
const captured = snapshot?.() ?? { active: true };
|
|
45161
|
+
return attachInvocationObservation({ ...input }, {
|
|
45162
|
+
...captured,
|
|
45163
|
+
...actorId === void 0 ? {} : { actorId }
|
|
45164
|
+
});
|
|
44853
45165
|
}
|
|
44854
45166
|
//#endregion
|
|
44855
45167
|
//#region ../../packages/sdk/src/host-observability.ts
|
|
@@ -46247,7 +46559,7 @@ function stdioIdentity(env = process.env, options = {}) {
|
|
|
46247
46559
|
}
|
|
46248
46560
|
//#endregion
|
|
46249
46561
|
//#region package.json
|
|
46250
|
-
var version = "4.
|
|
46562
|
+
var version = "4.1.0";
|
|
46251
46563
|
//#endregion
|
|
46252
46564
|
//#region src/deps.ts
|
|
46253
46565
|
const NO_IDENTITY = async () => void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
|
|
52
52
|
"vite-plus": "0.3.0",
|
|
53
53
|
"@capxul/config": "0.3.0",
|
|
54
|
-
"@capxul/sdk": "4.
|
|
54
|
+
"@capxul/sdk": "4.1.0",
|
|
55
55
|
"@capxul/typescript-config": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|