@capxul/mcp 4.0.0 → 4.0.1
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 +422 -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";
|
|
@@ -4124,6 +4124,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4124
4124
|
createOrganization: "identity.CreateOrganization",
|
|
4125
4125
|
ensureAccount: "identity.EnsureAccount",
|
|
4126
4126
|
leaveOrganization: "identity.LeaveOrganization",
|
|
4127
|
+
loadByAuthUserId: "identity.loadByAuthUserId",
|
|
4127
4128
|
loadCurrent: "identity.loadCurrent",
|
|
4128
4129
|
orgAt: "identity.OrgAt",
|
|
4129
4130
|
orgFailed: "identity.OrgFailed",
|
|
@@ -4274,7 +4275,8 @@ const CAPXUL_OPERATIONS = {
|
|
|
4274
4275
|
organizationPayments: {
|
|
4275
4276
|
pay: "organizationPayments.pay",
|
|
4276
4277
|
payBatch: "organizationPayments.payBatch",
|
|
4277
|
-
prepareExecution: "organizationPayments.prepareExecution"
|
|
4278
|
+
prepareExecution: "organizationPayments.prepareExecution",
|
|
4279
|
+
retry: "organizationPayments.retry"
|
|
4278
4280
|
},
|
|
4279
4281
|
organizationSetup: { getProofReceipt: "organizationSetup.getProofReceipt" },
|
|
4280
4282
|
organizations: { detectAndAcceptPendingInvitations: "orgs.detectAndAcceptPendingInvitations" },
|
|
@@ -4289,6 +4291,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4289
4291
|
prepareExecution: "payments.prepareExecution",
|
|
4290
4292
|
prepareLifecycleExecution: "payments.prepareLifecycleExecution",
|
|
4291
4293
|
redirect: "payments.redirect",
|
|
4294
|
+
retry: "payments.retry",
|
|
4292
4295
|
submitCommandExecution: "payments.submitCommandExecution",
|
|
4293
4296
|
submitExecution: "payments.submitExecution"
|
|
4294
4297
|
},
|
|
@@ -4370,6 +4373,7 @@ const CAPXUL_OPERATIONS = {
|
|
|
4370
4373
|
smartAccount: {
|
|
4371
4374
|
claim: "smartAccount.claim",
|
|
4372
4375
|
confirmDeployment: "smartAccount.confirmDeployment",
|
|
4376
|
+
loadByAuthUserId: "smartAccount.loadByAuthUserId",
|
|
4373
4377
|
loadCurrent: "smartAccount.loadCurrent",
|
|
4374
4378
|
provision: "smartAccount.provision"
|
|
4375
4379
|
},
|
|
@@ -7091,9 +7095,10 @@ const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
|
|
|
7091
7095
|
const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
|
|
7092
7096
|
/** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
|
|
7093
7097
|
function attachInvocationObservation(target, source) {
|
|
7094
|
-
const snapshot = Object.freeze(
|
|
7098
|
+
const snapshot = Object.freeze({
|
|
7095
7099
|
active: source.active,
|
|
7096
|
-
|
|
7100
|
+
...source.actorId === void 0 ? {} : { actorId: source.actorId },
|
|
7101
|
+
...source.context === void 0 ? {} : { context: Object.freeze({ ...source.context }) }
|
|
7097
7102
|
});
|
|
7098
7103
|
Object.defineProperty(target, INVOCATION_OBSERVATION, {
|
|
7099
7104
|
configurable: false,
|
|
@@ -7123,6 +7128,12 @@ function markFailureInvocationSnapshot(failure, snapshot) {
|
|
|
7123
7128
|
});
|
|
7124
7129
|
return failure;
|
|
7125
7130
|
}
|
|
7131
|
+
/** @internal Read the call-start delivery decision; undefined means a direct adapter call. */
|
|
7132
|
+
function readFailureInvocationSnapshot(failure) {
|
|
7133
|
+
if (typeof failure !== "object" || failure === null) return void 0;
|
|
7134
|
+
const snapshot = failure[FAILURE_INVOCATION_SNAPSHOT];
|
|
7135
|
+
return typeof snapshot === "object" && snapshot !== null && "active" in snapshot ? snapshot : void 0;
|
|
7136
|
+
}
|
|
7126
7137
|
//#endregion
|
|
7127
7138
|
//#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
|
|
7128
7139
|
async function emitProvisioningTelemetry(telemetry, smartAccount) {
|
|
@@ -9740,10 +9751,10 @@ const logIdentityTransition = (record) => (record.outcome === "applied" ? Effect
|
|
|
9740
9751
|
//#region ../../packages/sdk/src/domain/machine/shell.ts
|
|
9741
9752
|
const INVOCATION_PARENT_SPAN = Symbol("@capxul/sdk/identity-invocation-parent-span");
|
|
9742
9753
|
function carryInvocationParentSpan(controls, parent) {
|
|
9743
|
-
return {
|
|
9754
|
+
return copyInvocationObservation(controls, {
|
|
9744
9755
|
...controls,
|
|
9745
9756
|
[INVOCATION_PARENT_SPAN]: parent
|
|
9746
|
-
};
|
|
9757
|
+
});
|
|
9747
9758
|
}
|
|
9748
9759
|
function withInvocationParentSpan(effect, controls) {
|
|
9749
9760
|
const parent = controls?.[INVOCATION_PARENT_SPAN];
|
|
@@ -10094,13 +10105,13 @@ async function toCapxulResult(program, layer) {
|
|
|
10094
10105
|
* with `{ publicError }` rather than a bare `CapxulError`, so the wrapper is
|
|
10095
10106
|
* unwrapped here — once — instead of at every call site.
|
|
10096
10107
|
*/
|
|
10097
|
-
async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise) {
|
|
10098
|
-
if (signal?.aborted === true) return {
|
|
10108
|
+
async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise, observe) {
|
|
10109
|
+
if (signal?.aborted === true && observe === void 0) return {
|
|
10099
10110
|
ok: false,
|
|
10100
10111
|
error: Errors.cancelled({ operation })
|
|
10101
10112
|
};
|
|
10102
|
-
const program =
|
|
10103
|
-
|
|
10113
|
+
const program = signal?.aborted === true ? Effect.fail(Errors.cancelled({ operation })) : Effect.suspend(effect).pipe(Effect.mapError((error) => error.publicError));
|
|
10114
|
+
const controlled = signal === void 0 ? program : Effect.raceFirst(program, Effect.callback((resume) => {
|
|
10104
10115
|
if (signal.aborted) {
|
|
10105
10116
|
resume(Effect.fail(Errors.cancelled({ operation })));
|
|
10106
10117
|
return Effect.void;
|
|
@@ -10108,7 +10119,8 @@ async function runIfActive(signal, operation, effect, runPromise = Effect.runPro
|
|
|
10108
10119
|
const onAbort = () => resume(Effect.fail(Errors.cancelled({ operation })));
|
|
10109
10120
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
10110
10121
|
return Effect.sync(() => signal.removeEventListener("abort", onAbort));
|
|
10111
|
-
}))
|
|
10122
|
+
}));
|
|
10123
|
+
return runProgram(observe === void 0 ? controlled : observe(controlled), runPromise);
|
|
10112
10124
|
}
|
|
10113
10125
|
//#endregion
|
|
10114
10126
|
//#region ../../packages/sdk/src/surface/_shared/effect-actor-bridge.ts
|
|
@@ -10159,22 +10171,52 @@ async function runPortEffect(effect, controls, operation = CAPXUL_OPERATIONS.run
|
|
|
10159
10171
|
orElse: () => Effect.fail({ publicError: Errors.providerTimeout("sdk", operation, timeoutMs) })
|
|
10160
10172
|
}))).pipe(Effect.mapError((failure) => failure.publicError)), controls, operation, runPromise);
|
|
10161
10173
|
}
|
|
10174
|
+
/** Keep observation metadata while the compound operation owns cancellation. */
|
|
10175
|
+
function observationOnlyControls(controls) {
|
|
10176
|
+
const { signal: _signal, timeoutMs: _timeoutMs, deadlineMs: _deadlineMs, ...observation } = controls ?? {};
|
|
10177
|
+
return copyInvocationObservation(controls, observation);
|
|
10178
|
+
}
|
|
10162
10179
|
/** Observe a public Effect that already uses the canonical CapxulError channel. */
|
|
10163
10180
|
async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.runtime.port, runPromise = Effect.runPromise) {
|
|
10164
10181
|
const invocation = readInvocationObservation(controls);
|
|
10165
|
-
const correlationId = safeEngineeringIdentifier(
|
|
10166
|
-
const
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10182
|
+
const correlationId = safeEngineeringIdentifier(invocation?.context?.correlationId ?? controls?.correlation_id);
|
|
10183
|
+
const context = invocation?.active === false ? void 0 : sanitizeObservationContext(invocation?.context);
|
|
10184
|
+
const fields = {
|
|
10185
|
+
operation,
|
|
10186
|
+
...correlationId === void 0 ? {} : { correlation_id: correlationId },
|
|
10187
|
+
...context?.sessionId === void 0 ? {} : {
|
|
10188
|
+
session_id: context.sessionId,
|
|
10189
|
+
sessionId: context.sessionId
|
|
10190
|
+
},
|
|
10191
|
+
...context?.journeyId === void 0 ? {} : { journey_id: context.journeyId },
|
|
10192
|
+
...context?.release === void 0 ? {} : { release: context.release },
|
|
10193
|
+
...context?.application === void 0 ? {} : { application: context.application },
|
|
10194
|
+
...safeEngineeringIdentifier(invocation?.actorId) === void 0 ? {} : {
|
|
10195
|
+
actor_id: invocation.actorId,
|
|
10196
|
+
actor_kind: "authenticated",
|
|
10197
|
+
posthogDistinctId: invocation.actorId
|
|
10198
|
+
}
|
|
10199
|
+
};
|
|
10200
|
+
const result = await runIfActive(controls?.signal, operation, () => effect.pipe(Effect.mapError((publicError) => ({ publicError }))), runPromise, (program) => withInvocationParentSpan(Effect.gen(function* () {
|
|
10201
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
10202
|
+
const exit = yield* Effect.exit(program.pipe(Effect.catchDefect((cause) => Effect.fail(Errors.unknown(cause)))));
|
|
10203
|
+
const duration_ms = (yield* Clock.currentTimeMillis) - startedAt;
|
|
10204
|
+
const error = Exit.isFailure(exit) ? Cause.squash(exit.cause) : void 0;
|
|
10205
|
+
const failure = error instanceof CapxulError ? error : void 0;
|
|
10206
|
+
const outcome = Exit.isSuccess(exit) ? "succeeded" : failure?.code === "CANCELLED" ? "cancelled" : failure !== void 0 && EXPECTED_OPERATION_OUTCOMES.has(failure.code) ? "refused" : "failed";
|
|
10207
|
+
const completion = {
|
|
10208
|
+
...fields,
|
|
10209
|
+
duration_ms,
|
|
10210
|
+
outcome,
|
|
10211
|
+
...failure === void 0 ? {} : { failure_code: failure.code },
|
|
10212
|
+
...typeof failure?.mode === "string" ? { mode: failure.mode } : {},
|
|
10213
|
+
...failure?.mode === void 0 && typeof failure?.details?.failure_mode === "string" ? { mode: failure.details.failure_mode } : {}
|
|
10214
|
+
};
|
|
10215
|
+
yield* Effect.annotateCurrentSpan(completion).pipe(Effect.catchCause(() => Effect.void));
|
|
10216
|
+
yield* (outcome === "failed" ? Effect.logError("capxul_sdk_operation") : Effect.logInfo("capxul_sdk_operation")).pipe(Effect.annotateLogs(completion), Effect.catchCause(() => Effect.void));
|
|
10217
|
+
return yield* Exit.isSuccess(exit) ? Effect.succeed(exit.value) : Effect.failCause(exit.cause);
|
|
10218
|
+
}).pipe(Effect.withSpan(operation)), controls));
|
|
10219
|
+
return !result.ok && invocation !== void 0 ? markFailureInvocationSnapshot(result, invocation) : result;
|
|
10178
10220
|
}
|
|
10179
10221
|
/** Map machine-internal failure state onto the public SDK error vocabulary. */
|
|
10180
10222
|
function publicIdentityFailure(failure) {
|
|
@@ -10733,76 +10775,110 @@ function makeActorRelationshipMethods(deps) {
|
|
|
10733
10775
|
const fns = actorScopeContract;
|
|
10734
10776
|
return {
|
|
10735
10777
|
addressBook: {
|
|
10736
|
-
list: (input, options) =>
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10778
|
+
list: (input, options) => {
|
|
10779
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10780
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.list, Effect.suspend(() => convexCall.query(fns.addressBookList, copyInvocationObservation(controls, {
|
|
10781
|
+
actor,
|
|
10782
|
+
...input?.includeHidden === void 0 ? {} : { includeHidden: input.includeHidden }
|
|
10783
|
+
}))), (entries) => entries.map(mapAddressBookEntry)), controls, CAPXUL_OPERATIONS.addressBook.list, deps.runPromise);
|
|
10784
|
+
},
|
|
10785
|
+
get: (entryId, options) => {
|
|
10786
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10787
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.get, Effect.suspend(() => convexCall.query(fns.addressBookGet, copyInvocationObservation(controls, {
|
|
10788
|
+
actor,
|
|
10789
|
+
partyId: entryId
|
|
10790
|
+
}))), (entry) => entry === null ? null : mapAddressBookEntry(entry)), controls, CAPXUL_OPERATIONS.addressBook.get, deps.runPromise);
|
|
10791
|
+
},
|
|
10792
|
+
add: (input, options) => {
|
|
10793
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10745
10794
|
const ref = normalizeRefForBackend$1(input.ref, "ref");
|
|
10746
|
-
if (!ref.ok) return ref;
|
|
10747
|
-
return
|
|
10795
|
+
if (!ref.ok) return runCapxulEffect(Effect.fail(ref.error), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
|
|
10796
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.add, Effect.suspend(() => convexCall.mutation(fns.addressBookAdd, copyInvocationObservation(controls, {
|
|
10748
10797
|
actor,
|
|
10749
10798
|
ref: ref.value,
|
|
10750
10799
|
...input.label === void 0 ? {} : { label: input.label }
|
|
10751
|
-
})), mapAddressBookEntry);
|
|
10800
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
|
|
10801
|
+
},
|
|
10802
|
+
hide: (entryId, options) => {
|
|
10803
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10804
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.hide, Effect.suspend(() => convexCall.mutation(fns.addressBookHide, copyInvocationObservation(controls, {
|
|
10805
|
+
actor,
|
|
10806
|
+
partyId: entryId
|
|
10807
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.hide, deps.runPromise);
|
|
10808
|
+
},
|
|
10809
|
+
unhide: (entryId, options) => {
|
|
10810
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10811
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.unhide, Effect.suspend(() => convexCall.mutation(fns.addressBookUnhide, copyInvocationObservation(controls, {
|
|
10812
|
+
actor,
|
|
10813
|
+
partyId: entryId
|
|
10814
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.unhide, deps.runPromise);
|
|
10752
10815
|
},
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
}
|
|
10761
|
-
label: (input, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.label, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.label, () => convexCall.mutation(fns.addressBookLabel, {
|
|
10762
|
-
actor,
|
|
10763
|
-
partyId: input.entryId,
|
|
10764
|
-
label: input.label
|
|
10765
|
-
})), mapAddressBookEntry)
|
|
10816
|
+
label: (input, options) => {
|
|
10817
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10818
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.label, Effect.suspend(() => convexCall.mutation(fns.addressBookLabel, copyInvocationObservation(controls, {
|
|
10819
|
+
actor,
|
|
10820
|
+
partyId: input.entryId,
|
|
10821
|
+
label: input.label
|
|
10822
|
+
}))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.label, deps.runPromise);
|
|
10823
|
+
}
|
|
10766
10824
|
},
|
|
10767
10825
|
requests: {
|
|
10768
|
-
issue:
|
|
10826
|
+
issue: (input, options) => {
|
|
10827
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10769
10828
|
const payer = normalizeRefForBackend$1(input.payer, "payer");
|
|
10770
|
-
if (!payer.ok) return payer;
|
|
10771
|
-
return
|
|
10829
|
+
if (!payer.ok) return runCapxulEffect(Effect.fail(payer.error), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
|
|
10830
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.issue, Effect.suspend(() => convexCall.mutation(fns.requestsIssue, copyInvocationObservation(controls, {
|
|
10772
10831
|
actor,
|
|
10773
10832
|
payer: payer.value,
|
|
10774
10833
|
amount: input.amount,
|
|
10775
10834
|
reference: input.reference,
|
|
10776
10835
|
...input.memo === void 0 ? {} : { memo: input.memo },
|
|
10777
10836
|
...input.expiresAt === void 0 ? {} : { expiresAt: input.expiresAt }
|
|
10778
|
-
})), (request) => mapActorRequest(request, input.payer));
|
|
10837
|
+
}))), (request) => mapActorRequest(request, input.payer)), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
|
|
10779
10838
|
},
|
|
10780
|
-
list: (options) =>
|
|
10781
|
-
|
|
10782
|
-
actor,
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10839
|
+
list: (options) => {
|
|
10840
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10841
|
+
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);
|
|
10842
|
+
},
|
|
10843
|
+
get: (requestId, options) => {
|
|
10844
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10845
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.get, Effect.suspend(() => convexCall.query(fns.requestsGet, copyInvocationObservation(controls, {
|
|
10846
|
+
actor,
|
|
10847
|
+
paymentRequestId: requestId
|
|
10848
|
+
}))), (request) => request === null ? null : mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.get, deps.runPromise);
|
|
10849
|
+
},
|
|
10850
|
+
cancel: (requestId, options) => {
|
|
10851
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10852
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.cancel, Effect.suspend(() => convexCall.mutation(fns.requestsCancel, copyInvocationObservation(controls, {
|
|
10853
|
+
actor,
|
|
10854
|
+
paymentRequestId: requestId
|
|
10855
|
+
}))), (request) => mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.cancel, deps.runPromise);
|
|
10856
|
+
}
|
|
10789
10857
|
},
|
|
10790
10858
|
inbox: {
|
|
10791
|
-
list: (options) =>
|
|
10792
|
-
|
|
10793
|
-
|
|
10859
|
+
list: (options) => {
|
|
10860
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10861
|
+
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);
|
|
10862
|
+
},
|
|
10863
|
+
approve: (input, options) => {
|
|
10864
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10865
|
+
return runPortEffect(Effect.suspend(() => convexCall.mutation(fns.inboxApprove, copyInvocationObservation(controls, {
|
|
10794
10866
|
actor,
|
|
10795
10867
|
paymentRequestId: input.requestId,
|
|
10796
10868
|
...input.timing === void 0 ? {} : { timing: input.timing },
|
|
10797
10869
|
...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
|
|
10798
|
-
}))
|
|
10799
|
-
|
|
10800
|
-
|
|
10870
|
+
}))).pipe(Effect.flatMap((prepared) => {
|
|
10871
|
+
const result = mapApprovedInboxPayment(prepared, input);
|
|
10872
|
+
return result.ok ? Effect.succeed(result.value) : Effect.fail({ publicError: result.error });
|
|
10873
|
+
})), controls, CAPXUL_OPERATIONS.inbox.approve, deps.runPromise);
|
|
10801
10874
|
},
|
|
10802
|
-
decline: (requestId, options) =>
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10875
|
+
decline: (requestId, options) => {
|
|
10876
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
10877
|
+
return runPortEffect(mapReply(CAPXUL_OPERATIONS.inbox.decline, Effect.suspend(() => convexCall.mutation(fns.inboxDecline, copyInvocationObservation(controls, {
|
|
10878
|
+
actor,
|
|
10879
|
+
paymentRequestId: requestId
|
|
10880
|
+
}))), mapInboxItem), controls, CAPXUL_OPERATIONS.inbox.decline, deps.runPromise);
|
|
10881
|
+
}
|
|
10806
10882
|
},
|
|
10807
10883
|
profile: {
|
|
10808
10884
|
get: (options) => {
|
|
@@ -10879,22 +10955,12 @@ function missingConvexCall(operation) {
|
|
|
10879
10955
|
* promise and the caller's `if (!result.ok)` never runs (ADR-0023: errors are
|
|
10880
10956
|
* values, and a code crosses the seam).
|
|
10881
10957
|
*/
|
|
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
|
-
}
|
|
10958
|
+
function mapReply(operation, program, project) {
|
|
10959
|
+
return program.pipe(Effect.flatMap((value) => Effect.try({
|
|
10960
|
+
try: () => project(value),
|
|
10961
|
+
catch: (cause) => ({ publicError: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause) })
|
|
10962
|
+
})));
|
|
10896
10963
|
}
|
|
10897
|
-
const awaitableConvex = runIfActive;
|
|
10898
10964
|
const ADDRESS_BOOK_RELATIONSHIPS = [
|
|
10899
10965
|
"paid",
|
|
10900
10966
|
"paidBy",
|
|
@@ -11262,6 +11328,8 @@ function makeAccountMethods(deps) {
|
|
|
11262
11328
|
return {
|
|
11263
11329
|
methods: {
|
|
11264
11330
|
...makeActorRelationshipMethods({
|
|
11331
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
11332
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
11265
11333
|
actor: { kind: "account" },
|
|
11266
11334
|
...deps.convexCall === void 0 ? {} : { convexCall: deps.convexCall },
|
|
11267
11335
|
...deps.profileMethods === void 0 ? {} : { accountProfileMethods: deps.profileMethods }
|
|
@@ -11315,7 +11383,7 @@ const moneyExecutionContract = {
|
|
|
11315
11383
|
};
|
|
11316
11384
|
//#endregion
|
|
11317
11385
|
//#region ../../packages/sdk/package.json
|
|
11318
|
-
var version$1 = "4.0.
|
|
11386
|
+
var version$1 = "4.0.1";
|
|
11319
11387
|
//#endregion
|
|
11320
11388
|
//#region ../../packages/sdk/src/telemetry/exception-projection.ts
|
|
11321
11389
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -11394,7 +11462,8 @@ function observeSdkClient(client, adapter, snapshot) {
|
|
|
11394
11462
|
};
|
|
11395
11463
|
const processOutput = (output, path, invocation) => {
|
|
11396
11464
|
if (isFailedResult(output)) {
|
|
11397
|
-
|
|
11465
|
+
const captured = readFailureInvocationSnapshot(output);
|
|
11466
|
+
report(adapter, "operation", path.join("."), output.error, captured ?? invocation, void 0, captured !== void 0);
|
|
11398
11467
|
return output;
|
|
11399
11468
|
}
|
|
11400
11469
|
if (isCapxulResult(output)) return output;
|
|
@@ -11426,7 +11495,7 @@ function reportedByMachine(cause) {
|
|
|
11426
11495
|
}
|
|
11427
11496
|
return false;
|
|
11428
11497
|
}
|
|
11429
|
-
function report(adapter, kind, operation, cause, invocation, origin) {
|
|
11498
|
+
function report(adapter, kind, operation, cause, invocation, origin, authoritativeSnapshot = false) {
|
|
11430
11499
|
if (origin === "machine") {
|
|
11431
11500
|
let link = cause;
|
|
11432
11501
|
for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
|
|
@@ -11438,7 +11507,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
|
|
|
11438
11507
|
const kindName = normalizeErrorKind(errorKind$1(cause));
|
|
11439
11508
|
const context = sanitizeObservationContext({
|
|
11440
11509
|
...invocation.context,
|
|
11441
|
-
|
|
11510
|
+
...!authoritativeSnapshot && isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
11442
11511
|
});
|
|
11443
11512
|
const detail = failureDetail(cause);
|
|
11444
11513
|
const evidence = failureEvidence(cause);
|
|
@@ -11452,6 +11521,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
|
|
|
11452
11521
|
...evidence
|
|
11453
11522
|
}, {
|
|
11454
11523
|
active: invocation.active,
|
|
11524
|
+
...invocation.actorId === void 0 ? {} : { actorId: invocation.actorId },
|
|
11455
11525
|
...context === void 0 ? {} : { context }
|
|
11456
11526
|
});
|
|
11457
11527
|
try {
|
|
@@ -11867,17 +11937,17 @@ async function fingerprintPaymentIntent(intent) {
|
|
|
11867
11937
|
function matchesIntent(expected) {
|
|
11868
11938
|
return async (request) => await fingerprintPaymentIntent(request) === await fingerprintPaymentIntent(expected);
|
|
11869
11939
|
}
|
|
11870
|
-
async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed) {
|
|
11940
|
+
async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed, controls) {
|
|
11871
11941
|
if (!closePayment) return result;
|
|
11872
|
-
const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => deps.convexCall.action(deps.functions.abandonPaymentExecution, { input: {
|
|
11942
|
+
const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.abandonPaymentExecution, copyInvocationObservation(controls, { input: {
|
|
11873
11943
|
executionId,
|
|
11874
11944
|
reason
|
|
11875
|
-
} }));
|
|
11945
|
+
} }))), controls), deps.runPromise);
|
|
11876
11946
|
if (!abandoned.ok) return abandoned;
|
|
11877
11947
|
if (abandoned.value) onPreparedClosed?.();
|
|
11878
11948
|
return result;
|
|
11879
11949
|
}
|
|
11880
|
-
async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal) {
|
|
11950
|
+
async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls) {
|
|
11881
11951
|
if (isAborted$2(signal)) return {
|
|
11882
11952
|
ok: false,
|
|
11883
11953
|
error: Errors.cancelled({ operation: "payments" })
|
|
@@ -11901,16 +11971,16 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
|
|
|
11901
11971
|
if (!await isExpectedRequest(prepared.value.request)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "prepared_mismatch", {
|
|
11902
11972
|
ok: false,
|
|
11903
11973
|
error: Errors.invalidInput("payment", "prepared command mismatch")
|
|
11904
|
-
}, onPreparedClosed);
|
|
11974
|
+
}, onPreparedClosed, controls);
|
|
11905
11975
|
const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
|
|
11906
11976
|
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
11977
|
ok: false,
|
|
11908
11978
|
error: Errors.invalidInput("payment", "prepared authority mismatch")
|
|
11909
|
-
}, onPreparedClosed);
|
|
11979
|
+
}, onPreparedClosed, controls);
|
|
11910
11980
|
if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
|
|
11911
11981
|
ok: false,
|
|
11912
11982
|
error: Errors.cancelled({ operation: "payments" })
|
|
11913
|
-
}, onPreparedClosed);
|
|
11983
|
+
}, onPreparedClosed, controls);
|
|
11914
11984
|
if (prepared.value.emitPaymentInitiated && "items" in prepared.value.request) for (const [index, item] of prepared.value.request.items.entries()) {
|
|
11915
11985
|
const paymentId = prepared.value.paymentIds[index];
|
|
11916
11986
|
const recipient = prepared.value.recipientObservations[index];
|
|
@@ -11931,28 +12001,28 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
|
|
|
11931
12001
|
return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "signer_rejected", {
|
|
11932
12002
|
ok: false,
|
|
11933
12003
|
error: signerFailure(deps.signer.source, "signUserOpHash", cause)
|
|
11934
|
-
}, onPreparedClosed);
|
|
12004
|
+
}, onPreparedClosed, controls);
|
|
11935
12005
|
}
|
|
11936
12006
|
if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
|
|
11937
12007
|
ok: false,
|
|
11938
12008
|
error: Errors.cancelled({ operation: "payments" })
|
|
11939
|
-
}, onPreparedClosed);
|
|
11940
|
-
return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, { input: {
|
|
12009
|
+
}, onPreparedClosed, controls);
|
|
12010
|
+
return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, copyInvocationObservation(controls, { input: {
|
|
11941
12011
|
executionId: prepared.value.executionId,
|
|
11942
12012
|
signature
|
|
11943
|
-
} }));
|
|
12013
|
+
} }))), controls), deps.runPromise);
|
|
11944
12014
|
}
|
|
11945
|
-
function executePaymentLifecycle(deps, intent, signal) {
|
|
11946
|
-
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, { input: {
|
|
12015
|
+
function executePaymentLifecycle(deps, intent, signal, controls) {
|
|
12016
|
+
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, copyInvocationObservation(controls, { input: {
|
|
11947
12017
|
signerAddress,
|
|
11948
12018
|
intent
|
|
11949
|
-
} })), matchesIntent(intent), false, void 0, signal);
|
|
12019
|
+
} }))), controls), deps.runPromise), matchesIntent(intent), false, void 0, signal, controls);
|
|
11950
12020
|
}
|
|
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: {
|
|
12021
|
+
function executeOrganizationPayment(deps, input, signal, onPreparedClosed, controls) {
|
|
12022
|
+
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, copyInvocationObservation(controls, { input: {
|
|
11953
12023
|
...input,
|
|
11954
12024
|
signerAddress
|
|
11955
|
-
} })), matchesIntent(input), true, onPreparedClosed, signal);
|
|
12025
|
+
} }))), controls), deps.runPromise), matchesIntent(input), true, onPreparedClosed, signal, controls);
|
|
11956
12026
|
}
|
|
11957
12027
|
//#endregion
|
|
11958
12028
|
//#region ../../packages/sdk/src/surface/payment-execution.ts
|
|
@@ -12391,51 +12461,52 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12391
12461
|
chainId: deps.chainId,
|
|
12392
12462
|
convexCall: deps.convexCall,
|
|
12393
12463
|
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
|
-
};
|
|
12464
|
+
signer: deps.signer,
|
|
12465
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise }
|
|
12437
12466
|
}
|
|
12438
12467
|
};
|
|
12468
|
+
const runLifecycle = (intent, controls, operation) => runCapxulEffect(Effect.gen(function* () {
|
|
12469
|
+
const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
|
|
12470
|
+
const result = yield* Effect.tryPromise({
|
|
12471
|
+
try: async () => {
|
|
12472
|
+
const execution = lifecycleDependencies();
|
|
12473
|
+
if (!execution.ok) return execution;
|
|
12474
|
+
const submitted = await executePaymentLifecycle(execution.value, intent, controls?.signal, captured);
|
|
12475
|
+
if (!submitted.ok) return submitted;
|
|
12476
|
+
const payments = submitted.value.payments;
|
|
12477
|
+
const payment = payments[0];
|
|
12478
|
+
if (payment === void 0 || payments.length !== 1) return {
|
|
12479
|
+
ok: false,
|
|
12480
|
+
error: Errors.unknown()
|
|
12481
|
+
};
|
|
12482
|
+
return {
|
|
12483
|
+
ok: true,
|
|
12484
|
+
value: normalizePaymentTiming(payment)
|
|
12485
|
+
};
|
|
12486
|
+
},
|
|
12487
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12488
|
+
});
|
|
12489
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
12490
|
+
}), observationOnlyControls(controls), operation, deps.runPromise);
|
|
12491
|
+
const retryPayment = (paymentId, controls) => runCapxulEffect(Effect.gen(function* () {
|
|
12492
|
+
const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
|
|
12493
|
+
const result = yield* Effect.tryPromise({
|
|
12494
|
+
try: async () => {
|
|
12495
|
+
const execution = lifecycleDependencies();
|
|
12496
|
+
if (!execution.ok) return execution;
|
|
12497
|
+
const submitted = await executePaymentLifecycle(execution.value, {
|
|
12498
|
+
kind: "retry",
|
|
12499
|
+
paymentId
|
|
12500
|
+
}, controls?.signal, captured);
|
|
12501
|
+
return submitted.ok ? {
|
|
12502
|
+
ok: true,
|
|
12503
|
+
value: submitted.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
12504
|
+
} : submitted;
|
|
12505
|
+
},
|
|
12506
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
12507
|
+
});
|
|
12508
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
12509
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.retry, deps.runPromise);
|
|
12439
12510
|
return {
|
|
12440
12511
|
me: {
|
|
12441
12512
|
get: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.me.get, () => deps.convexCall.query(fns.me, {})),
|
|
@@ -12487,58 +12558,64 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12487
12558
|
},
|
|
12488
12559
|
payments: {
|
|
12489
12560
|
pay,
|
|
12490
|
-
retry: (paymentId, options) => retryPayment(paymentId, options
|
|
12561
|
+
retry: (paymentId, options) => retryPayment(paymentId, deps.invocationControls?.(options) ?? options),
|
|
12491
12562
|
createCommitment: (input, options) => pay(input, options),
|
|
12492
12563
|
claim: (paymentId, options) => runLifecycle({
|
|
12493
12564
|
kind: "claim",
|
|
12494
12565
|
paymentId
|
|
12495
|
-
}, options
|
|
12566
|
+
}, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.claim),
|
|
12496
12567
|
list: async (options) => mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.payments.list, () => deps.convexCall.query(fns.listPayments, {})), (payments) => payments.map(normalizePaymentTiming)),
|
|
12497
12568
|
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
12569
|
cancel: (paymentId, options) => runLifecycle({
|
|
12499
12570
|
kind: "cancel",
|
|
12500
12571
|
paymentId
|
|
12501
|
-
}, options
|
|
12572
|
+
}, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.cancel),
|
|
12502
12573
|
redirect: async (input, options) => {
|
|
12574
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12503
12575
|
const recipient = normalizeTargetForBackend(input.to, "to");
|
|
12504
|
-
if (!recipient.ok) return recipient;
|
|
12576
|
+
if (!recipient.ok) return runCapxulEffect(Effect.fail(recipient.error), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.redirect, deps.runPromise);
|
|
12505
12577
|
return runLifecycle({
|
|
12506
12578
|
kind: "redirect",
|
|
12507
12579
|
paymentId: input.paymentId,
|
|
12508
12580
|
recipient: recipient.value
|
|
12509
|
-
},
|
|
12581
|
+
}, controls, CAPXUL_OPERATIONS.payments.redirect);
|
|
12510
12582
|
}
|
|
12511
12583
|
},
|
|
12512
12584
|
activity: {
|
|
12513
|
-
list: (params, options) =>
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12585
|
+
list: (params, options) => {
|
|
12586
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12587
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityList, copyInvocationObservation(controls, { input: {
|
|
12588
|
+
...activityActorField(params?.actor),
|
|
12589
|
+
...params?.cursor === void 0 ? {} : { cursor: params.cursor },
|
|
12590
|
+
...params?.limit === void 0 ? {} : { limit: params.limit },
|
|
12591
|
+
...params?.range === void 0 ? {} : { range: params.range },
|
|
12592
|
+
...params?.filter === void 0 ? {} : { filter: params.filter }
|
|
12593
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.list, deps.runPromise);
|
|
12594
|
+
},
|
|
12595
|
+
summary: (params, options) => {
|
|
12596
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12597
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activitySummary, copyInvocationObservation(controls, { input: {
|
|
12598
|
+
...activityActorField(params?.actor),
|
|
12599
|
+
...params?.window === void 0 ? {} : { window: params.window }
|
|
12600
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.summary, deps.runPromise);
|
|
12601
|
+
},
|
|
12524
12602
|
get: (reference, options) => {
|
|
12603
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12525
12604
|
const actor = actorReferenceToBackend(options?.actor);
|
|
12526
|
-
return
|
|
12605
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityGet, copyInvocationObservation(controls, {
|
|
12527
12606
|
input: {
|
|
12528
12607
|
kind: reference.kind,
|
|
12529
12608
|
id: reference.id,
|
|
12530
12609
|
...reference.kind === "payment" ? activityActorField(reference.actor) : {}
|
|
12531
12610
|
},
|
|
12532
12611
|
...actor === void 0 ? {} : { actor }
|
|
12533
|
-
}).pipe(Effect.map(normalizeActivityDetail)));
|
|
12612
|
+
}))).pipe(Effect.map(normalizeActivityDetail)), controls, CAPXUL_OPERATIONS.activity.get, deps.runPromise);
|
|
12534
12613
|
},
|
|
12535
12614
|
annotate: (input, options) => {
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
error: Errors.invalidInput("reference.actor", "must match the annotation actor")
|
|
12539
|
-
});
|
|
12615
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12616
|
+
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
12617
|
const referenceActor = input.reference.kind === "payment" ? activityActorField(input.reference.actor).actor : void 0;
|
|
12541
|
-
return
|
|
12618
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(fns.activityAnnotate, copyInvocationObservation(controls, { input: {
|
|
12542
12619
|
...activityActorField(input.actor),
|
|
12543
12620
|
reference: input.reference.kind === "payment" && referenceActor !== void 0 ? {
|
|
12544
12621
|
kind: "payment",
|
|
@@ -12551,7 +12628,7 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12551
12628
|
...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
|
|
12552
12629
|
...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
|
|
12553
12630
|
...input.memo === void 0 ? {} : { memo: input.memo }
|
|
12554
|
-
} }));
|
|
12631
|
+
} }))), controls, CAPXUL_OPERATIONS.activity.annotate, deps.runPromise);
|
|
12555
12632
|
}
|
|
12556
12633
|
},
|
|
12557
12634
|
offramp: {
|
|
@@ -12577,8 +12654,14 @@ function makeFinancialOpsMethods(deps) {
|
|
|
12577
12654
|
}
|
|
12578
12655
|
},
|
|
12579
12656
|
paymentDocuments: {
|
|
12580
|
-
verify: (documentHash, options) =>
|
|
12581
|
-
|
|
12657
|
+
verify: (documentHash, options) => {
|
|
12658
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12659
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.verifyPaymentDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.verify, deps.runPromise);
|
|
12660
|
+
},
|
|
12661
|
+
render: (documentHash, options) => {
|
|
12662
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
12663
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.renderStoredDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.render, deps.runPromise);
|
|
12664
|
+
}
|
|
12582
12665
|
}
|
|
12583
12666
|
};
|
|
12584
12667
|
}
|
|
@@ -17375,6 +17458,7 @@ function makeConnectionId() {
|
|
|
17375
17458
|
//#region ../../packages/sdk/src/adapters/convex-call/ConvexCallAdapter.ts
|
|
17376
17459
|
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
17377
17460
|
const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
|
|
17461
|
+
"payroll/actions:authorizeRun",
|
|
17378
17462
|
"account/actions:readBalance",
|
|
17379
17463
|
"holdings/actions:current",
|
|
17380
17464
|
"smartAccount/actions:claim",
|
|
@@ -17392,12 +17476,36 @@ const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
17392
17476
|
"moneyExecution/paymentCommandActions:submitPaymentCommandExecution"
|
|
17393
17477
|
]);
|
|
17394
17478
|
const OBSERVED_CONVEX_QUERIES = /* @__PURE__ */ new Set([
|
|
17479
|
+
"movement/activity:list",
|
|
17480
|
+
"movement/activity:summary",
|
|
17481
|
+
"movement/activity:get",
|
|
17482
|
+
"financialOps/queries:verifyPaymentDocument",
|
|
17483
|
+
"financialOps/queries:renderStoredDocument",
|
|
17484
|
+
"financialOps/addressBook:list",
|
|
17485
|
+
"financialOps/addressBook:get",
|
|
17486
|
+
"financialOps/requestsInbox:list",
|
|
17487
|
+
"financialOps/requestsInbox:get",
|
|
17488
|
+
"financialOps/requestsInbox:inboxList",
|
|
17489
|
+
"payroll/queries:runs",
|
|
17490
|
+
"payroll/queries:groups",
|
|
17491
|
+
"payroll/queries:terms",
|
|
17395
17492
|
"financialOps/queries:resolveRecipient",
|
|
17396
17493
|
"identity/queries:loadByAuthUserId",
|
|
17397
17494
|
"smartAccount/queries:loadByAuthUserId",
|
|
17398
17495
|
"org/lifecycle:load"
|
|
17399
17496
|
]);
|
|
17400
17497
|
const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
|
|
17498
|
+
"movement/activity:annotate",
|
|
17499
|
+
"financialOps/addressBook:add",
|
|
17500
|
+
"financialOps/addressBook:hide",
|
|
17501
|
+
"financialOps/addressBook:unhide",
|
|
17502
|
+
"financialOps/addressBook:label",
|
|
17503
|
+
"financialOps/requestsInbox:issue",
|
|
17504
|
+
"financialOps/requestsInbox:cancel",
|
|
17505
|
+
"financialOps/requestsInbox:approve",
|
|
17506
|
+
"financialOps/requestsInbox:decline",
|
|
17507
|
+
"payroll/mutations:saveGroup",
|
|
17508
|
+
"payroll/mutations:removeGroup",
|
|
17401
17509
|
"identity/mutations:create",
|
|
17402
17510
|
"identity/mutations:update",
|
|
17403
17511
|
"identity/mutations:completeOnboarding",
|
|
@@ -17466,7 +17574,7 @@ var ConvexCallAdapter = class {
|
|
|
17466
17574
|
const carriedContext = sanitizeObservationContext(args.observationContext);
|
|
17467
17575
|
let hostContext;
|
|
17468
17576
|
const invocationSnapshot = readInvocationObservation(args);
|
|
17469
|
-
if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.context;
|
|
17577
|
+
if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.active ? invocationSnapshot.context : void 0;
|
|
17470
17578
|
else {
|
|
17471
17579
|
const resolveContext = this.#observation?.resolveContext;
|
|
17472
17580
|
if (resolveContext !== void 0) try {
|
|
@@ -43307,13 +43415,14 @@ function executionDependencies$1(input) {
|
|
|
43307
43415
|
convexCall: input.convexCall,
|
|
43308
43416
|
functions: moneyExecutionContract,
|
|
43309
43417
|
signer: input.signer,
|
|
43418
|
+
...input.runPromise === void 0 ? {} : { runPromise: input.runPromise },
|
|
43310
43419
|
...input.telemetry === void 0 ? {} : { telemetry: input.telemetry }
|
|
43311
43420
|
};
|
|
43312
43421
|
}
|
|
43313
43422
|
function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
43314
43423
|
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
43315
43424
|
const inFlightOrganizationPayments = /* @__PURE__ */ new Map();
|
|
43316
|
-
const execute = async (input, signal, operation = "organization-pay-batch") => {
|
|
43425
|
+
const execute = async (input, signal, operation = "organization-pay-batch", controls) => {
|
|
43317
43426
|
if (signal?.aborted === true) return {
|
|
43318
43427
|
ok: false,
|
|
43319
43428
|
error: Errors.cancelled({ operation })
|
|
@@ -43346,7 +43455,7 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
43346
43455
|
requestKey: requestKey.key,
|
|
43347
43456
|
items: input.items,
|
|
43348
43457
|
...input.lineage === void 0 ? {} : { lineage: input.lineage }
|
|
43349
|
-
}, controller.signal, () => requestState.resolved = true);
|
|
43458
|
+
}, controller.signal, () => requestState.resolved = true, controls);
|
|
43350
43459
|
flight = {
|
|
43351
43460
|
controller,
|
|
43352
43461
|
promise: submission,
|
|
@@ -43395,41 +43504,73 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
43395
43504
|
return normalized;
|
|
43396
43505
|
};
|
|
43397
43506
|
return {
|
|
43398
|
-
retry:
|
|
43399
|
-
const
|
|
43400
|
-
|
|
43401
|
-
|
|
43402
|
-
|
|
43403
|
-
|
|
43404
|
-
|
|
43405
|
-
|
|
43406
|
-
|
|
43407
|
-
|
|
43408
|
-
|
|
43409
|
-
|
|
43410
|
-
|
|
43411
|
-
|
|
43412
|
-
|
|
43507
|
+
retry: (paymentId, options) => {
|
|
43508
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43509
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43510
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43511
|
+
const captured = carryInvocationParentSpan(controls, parent);
|
|
43512
|
+
const completed = yield* Effect.tryPromise({
|
|
43513
|
+
try: async () => {
|
|
43514
|
+
const execution = executionDependencies$1(deps);
|
|
43515
|
+
if (execution === null) return {
|
|
43516
|
+
ok: false,
|
|
43517
|
+
error: Errors.notImplemented("organizationPayments", "executionComposition")
|
|
43518
|
+
};
|
|
43519
|
+
const result = await executePaymentLifecycle(execution, {
|
|
43520
|
+
kind: "retry",
|
|
43521
|
+
paymentId
|
|
43522
|
+
}, controls?.signal, captured);
|
|
43523
|
+
if (!result.ok) return result;
|
|
43524
|
+
return {
|
|
43525
|
+
ok: true,
|
|
43526
|
+
value: result.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
43527
|
+
};
|
|
43528
|
+
},
|
|
43529
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43530
|
+
});
|
|
43531
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43532
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.retry, deps.runPromise);
|
|
43413
43533
|
},
|
|
43414
|
-
pay:
|
|
43415
|
-
const
|
|
43416
|
-
|
|
43417
|
-
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
|
|
43421
|
-
|
|
43422
|
-
|
|
43423
|
-
|
|
43424
|
-
|
|
43425
|
-
|
|
43426
|
-
|
|
43427
|
-
|
|
43428
|
-
|
|
43429
|
-
|
|
43430
|
-
|
|
43534
|
+
pay: (input, options) => {
|
|
43535
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43536
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43537
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43538
|
+
const captured = carryInvocationParentSpan(controls, parent);
|
|
43539
|
+
const completed = yield* Effect.tryPromise({
|
|
43540
|
+
try: async () => {
|
|
43541
|
+
const { permissionId, requestKey: providedRequestKey, lineage, ...item } = input;
|
|
43542
|
+
const result = await execute({
|
|
43543
|
+
permissionId,
|
|
43544
|
+
...providedRequestKey === void 0 ? {} : { requestKey: providedRequestKey },
|
|
43545
|
+
items: [item],
|
|
43546
|
+
...lineage === void 0 ? {} : { lineage }
|
|
43547
|
+
}, controls?.signal, "organization-pay", captured);
|
|
43548
|
+
if (!result.ok) return result;
|
|
43549
|
+
const payment = result.value[0];
|
|
43550
|
+
return payment === void 0 ? {
|
|
43551
|
+
ok: false,
|
|
43552
|
+
error: Errors.unknown()
|
|
43553
|
+
} : {
|
|
43554
|
+
ok: true,
|
|
43555
|
+
value: payment
|
|
43556
|
+
};
|
|
43557
|
+
},
|
|
43558
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43559
|
+
});
|
|
43560
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43561
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.pay, deps.runPromise);
|
|
43431
43562
|
},
|
|
43432
|
-
payBatch: (input, options) =>
|
|
43563
|
+
payBatch: (input, options) => {
|
|
43564
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43565
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43566
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43567
|
+
const completed = yield* Effect.tryPromise({
|
|
43568
|
+
try: () => execute(input, controls?.signal, void 0, carryInvocationParentSpan(controls, parent)),
|
|
43569
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43570
|
+
});
|
|
43571
|
+
return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
|
|
43572
|
+
}), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.payBatch, deps.runPromise);
|
|
43573
|
+
}
|
|
43433
43574
|
};
|
|
43434
43575
|
}
|
|
43435
43576
|
//#endregion
|
|
@@ -43526,12 +43667,14 @@ function executionDependencies(deps) {
|
|
|
43526
43667
|
chainId: deps.chainId,
|
|
43527
43668
|
convexCall: deps.convexCall,
|
|
43528
43669
|
functions: moneyExecutionContract,
|
|
43670
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
43529
43671
|
signer: deps.signer
|
|
43530
43672
|
};
|
|
43531
43673
|
}
|
|
43532
43674
|
function makePayrollMethods(deps, orgId) {
|
|
43533
43675
|
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
43534
|
-
async function authorize(input,
|
|
43676
|
+
async function authorize(input, controls) {
|
|
43677
|
+
const signal = controls?.signal;
|
|
43535
43678
|
const execution = executionDependencies(deps);
|
|
43536
43679
|
if (execution === null) return {
|
|
43537
43680
|
ok: false,
|
|
@@ -43544,14 +43687,14 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43544
43687
|
let authorized;
|
|
43545
43688
|
let preparedClosed = false;
|
|
43546
43689
|
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
43547
|
-
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => deps.convexCall.action(payrollContract.authorizeRun, { input: {
|
|
43690
|
+
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(payrollContract.authorizeRun, copyInvocationObservation(controls, { input: {
|
|
43548
43691
|
orgId,
|
|
43549
43692
|
permissionId: input.permissionId,
|
|
43550
43693
|
requestKey: requestKey.key,
|
|
43551
43694
|
signerAddress,
|
|
43552
43695
|
period: input.period,
|
|
43553
43696
|
items: input.items
|
|
43554
|
-
} }));
|
|
43697
|
+
} }))), controls), deps.runPromise);
|
|
43555
43698
|
if (!prepared.ok) return prepared;
|
|
43556
43699
|
authorized = prepared.value.run;
|
|
43557
43700
|
return {
|
|
@@ -43564,7 +43707,7 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43564
43707
|
requestKey: requestKey.key,
|
|
43565
43708
|
runId: authorized.id,
|
|
43566
43709
|
items: input.items
|
|
43567
|
-
})(request), true, () => preparedClosed = true, signal);
|
|
43710
|
+
})(request), true, () => preparedClosed = true, signal, controls);
|
|
43568
43711
|
try {
|
|
43569
43712
|
await requestKey.finish(submitted.ok || preparedClosed);
|
|
43570
43713
|
} catch {}
|
|
@@ -43578,35 +43721,48 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43578
43721
|
};
|
|
43579
43722
|
}
|
|
43580
43723
|
return {
|
|
43581
|
-
runs: (options) =>
|
|
43582
|
-
|
|
43583
|
-
|
|
43584
|
-
|
|
43585
|
-
|
|
43586
|
-
|
|
43587
|
-
|
|
43588
|
-
return
|
|
43589
|
-
|
|
43590
|
-
|
|
43591
|
-
|
|
43592
|
-
|
|
43593
|
-
};
|
|
43594
|
-
|
|
43724
|
+
runs: (options) => {
|
|
43725
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43726
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.runs, copyInvocationObservation(controls, { orgId }))).pipe(Effect.map(toPayrollRuns)), controls, CAPXUL_OPERATIONS.payroll.runs, deps.runPromise);
|
|
43727
|
+
},
|
|
43728
|
+
authorizeRun: (input, options) => {
|
|
43729
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43730
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
43731
|
+
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
43732
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43733
|
+
const result = yield* Effect.tryPromise({
|
|
43734
|
+
try: () => authorize(input, carryInvocationParentSpan(controls, parent)),
|
|
43735
|
+
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43736
|
+
});
|
|
43737
|
+
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
43738
|
+
}), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
|
|
43739
|
+
},
|
|
43740
|
+
terms: (options) => {
|
|
43741
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43742
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.terms, copyInvocationObservation(controls, { orgId }))), controls, CAPXUL_OPERATIONS.payroll.terms, deps.runPromise);
|
|
43595
43743
|
},
|
|
43596
|
-
terms: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.terms, () => deps.convexCall.query(payrollContract.terms, { orgId })),
|
|
43597
43744
|
groups: {
|
|
43598
|
-
list: (options) =>
|
|
43599
|
-
|
|
43600
|
-
orgId,
|
|
43601
|
-
|
|
43602
|
-
|
|
43603
|
-
|
|
43604
|
-
|
|
43605
|
-
|
|
43606
|
-
|
|
43607
|
-
|
|
43608
|
-
|
|
43609
|
-
|
|
43745
|
+
list: (options) => {
|
|
43746
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43747
|
+
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);
|
|
43748
|
+
},
|
|
43749
|
+
save: (input, options) => {
|
|
43750
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43751
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.saveGroup, copyInvocationObservation(controls, {
|
|
43752
|
+
orgId,
|
|
43753
|
+
...input.id === void 0 ? {} : { id: String(input.id) },
|
|
43754
|
+
name: input.name,
|
|
43755
|
+
tone: input.tone,
|
|
43756
|
+
members: input.members
|
|
43757
|
+
}))).pipe(Effect.map(toPayrollGroup)), controls, CAPXUL_OPERATIONS.payroll.groups.save, deps.runPromise);
|
|
43758
|
+
},
|
|
43759
|
+
remove: (id, options) => {
|
|
43760
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
43761
|
+
return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.removeGroup, copyInvocationObservation(controls, {
|
|
43762
|
+
orgId,
|
|
43763
|
+
id
|
|
43764
|
+
}))).pipe(Effect.asVoid), controls, CAPXUL_OPERATIONS.payroll.groups.remove, deps.runPromise);
|
|
43765
|
+
}
|
|
43610
43766
|
}
|
|
43611
43767
|
};
|
|
43612
43768
|
}
|
|
@@ -44055,6 +44211,8 @@ function makeOrgMethods(deps) {
|
|
|
44055
44211
|
const convexCall = deps.convexCall;
|
|
44056
44212
|
return {
|
|
44057
44213
|
...makeActorRelationshipMethods({
|
|
44214
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44215
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44058
44216
|
actor: {
|
|
44059
44217
|
kind: "org",
|
|
44060
44218
|
orgId: String(orgId)
|
|
@@ -44184,6 +44342,8 @@ function makeOrgMethods(deps) {
|
|
|
44184
44342
|
}, String(orgId)),
|
|
44185
44343
|
payments: convexCall === void 0 ? makeNotImplementedOrganizationPaymentsMethods() : makeOrganizationPaymentsMethods({
|
|
44186
44344
|
convexCall,
|
|
44345
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44346
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44187
44347
|
...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
|
|
44188
44348
|
...deps.actor === void 0 ? {} : { actor: deps.actor },
|
|
44189
44349
|
...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
|
|
@@ -44192,6 +44352,8 @@ function makeOrgMethods(deps) {
|
|
|
44192
44352
|
}, String(orgId)),
|
|
44193
44353
|
payroll: convexCall === void 0 ? makeUnavailablePayrollMethods() : makePayrollMethods({
|
|
44194
44354
|
convexCall,
|
|
44355
|
+
...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
|
|
44356
|
+
...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
|
|
44195
44357
|
...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
|
|
44196
44358
|
...deps.actor === void 0 ? {} : { actor: deps.actor },
|
|
44197
44359
|
...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
|
|
@@ -44601,6 +44763,8 @@ function assembleCapxulClient(input) {
|
|
|
44601
44763
|
let detectPendingOrgInvitations;
|
|
44602
44764
|
let kickProvisioning;
|
|
44603
44765
|
const financialOps = makeFinancialOpsMethods({
|
|
44766
|
+
runPromise: effectRunner.runPromise,
|
|
44767
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44604
44768
|
actor,
|
|
44605
44769
|
chainId: input.bootstrap.chainId,
|
|
44606
44770
|
convexCall: input.ports.convexCall,
|
|
@@ -44620,7 +44784,7 @@ function assembleCapxulClient(input) {
|
|
|
44620
44784
|
profileMethods: financialOps.me,
|
|
44621
44785
|
convexCall: input.ports.convexCall,
|
|
44622
44786
|
runPromise: effectRunner.runPromise,
|
|
44623
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
|
|
44787
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44624
44788
|
...input.signer === void 0 ? {} : { signer: input.signer }
|
|
44625
44789
|
});
|
|
44626
44790
|
kickProvisioning = accountBundle.kickProvisioning;
|
|
@@ -44673,21 +44837,21 @@ function assembleCapxulClient(input) {
|
|
|
44673
44837
|
convexCall: input.ports.convexCall,
|
|
44674
44838
|
telemetry: input.ports.telemetry,
|
|
44675
44839
|
runPromise: effectRunner.runPromise,
|
|
44676
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
|
|
44840
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
|
|
44677
44841
|
});
|
|
44678
44842
|
const accounts = makeAccountsMethods({
|
|
44679
44843
|
accountReadPort: input.ports.accountRead,
|
|
44680
44844
|
chainId: input.bootstrap.chainId,
|
|
44681
44845
|
telemetry: input.ports.telemetry,
|
|
44682
44846
|
runPromise: effectRunner.runPromise,
|
|
44683
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
|
|
44847
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
|
|
44684
44848
|
});
|
|
44685
44849
|
const orgMethods = makeOrgMethods({
|
|
44686
44850
|
actor,
|
|
44687
44851
|
chainId: input.bootstrap.chainId,
|
|
44688
44852
|
telemetry: input.ports.telemetry,
|
|
44689
44853
|
runPromise: effectRunner.runPromise,
|
|
44690
|
-
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
|
|
44854
|
+
invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
|
|
44691
44855
|
requestKeyScope: `${input.bootstrap.convexUrl}:${String(input.bootstrap.chainId)}`,
|
|
44692
44856
|
...selectedOrgPort === void 0 ? {} : { orgPort: selectedOrgPort },
|
|
44693
44857
|
convexCall: input.ports.convexCall,
|
|
@@ -44838,7 +45002,7 @@ function transitionError(record) {
|
|
|
44838
45002
|
}
|
|
44839
45003
|
function withHostObservation(actor, snapshot) {
|
|
44840
45004
|
if (snapshot === void 0) return actor;
|
|
44841
|
-
const controls = (input) => withHostObservationControls(snapshot, input);
|
|
45005
|
+
const controls = (input) => withHostObservationControls(snapshot, input, actor.authSession()?.authUserId);
|
|
44842
45006
|
return {
|
|
44843
45007
|
...actor,
|
|
44844
45008
|
ask: (event, input) => actor.ask(event, controls(input)),
|
|
@@ -44846,10 +45010,14 @@ function withHostObservation(actor, snapshot) {
|
|
|
44846
45010
|
restoreAuthSession: (session, input) => actor.restoreAuthSession(session, controls(input))
|
|
44847
45011
|
};
|
|
44848
45012
|
}
|
|
44849
|
-
function withHostObservationControls(snapshot, input) {
|
|
44850
|
-
const
|
|
44851
|
-
|
|
44852
|
-
|
|
45013
|
+
function withHostObservationControls(snapshot, input, actorId) {
|
|
45014
|
+
const previous = readInvocationObservation(input);
|
|
45015
|
+
if (previous !== void 0) return attachInvocationObservation({ ...input }, previous);
|
|
45016
|
+
const captured = snapshot?.() ?? { active: true };
|
|
45017
|
+
return attachInvocationObservation({ ...input }, {
|
|
45018
|
+
...captured,
|
|
45019
|
+
...actorId === void 0 ? {} : { actorId }
|
|
45020
|
+
});
|
|
44853
45021
|
}
|
|
44854
45022
|
//#endregion
|
|
44855
45023
|
//#region ../../packages/sdk/src/host-observability.ts
|
|
@@ -46247,7 +46415,7 @@ function stdioIdentity(env = process.env, options = {}) {
|
|
|
46247
46415
|
}
|
|
46248
46416
|
//#endregion
|
|
46249
46417
|
//#region package.json
|
|
46250
|
-
var version = "4.0.
|
|
46418
|
+
var version = "4.0.1";
|
|
46251
46419
|
//#endregion
|
|
46252
46420
|
//#region src/deps.ts
|
|
46253
46421
|
const NO_IDENTITY = async () => void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
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.0.
|
|
54
|
+
"@capxul/sdk": "4.0.1",
|
|
55
55
|
"@capxul/typescript-config": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|