@capxul/mcp 4.1.2 → 4.1.4
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 +78 -16
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -5177,6 +5177,7 @@ const ActivityFilterProps = {
|
|
|
5177
5177
|
filter_status: Schema.optional(Schema.Array(Schema.Literals([
|
|
5178
5178
|
"pending",
|
|
5179
5179
|
"settling",
|
|
5180
|
+
"unresolved",
|
|
5180
5181
|
"pending_claim",
|
|
5181
5182
|
"scheduled",
|
|
5182
5183
|
"streaming",
|
|
@@ -10353,6 +10354,7 @@ function verifiedOperationFields(attributes) {
|
|
|
10353
10354
|
/** Observe a public Effect that already uses the canonical CapxulError channel. */
|
|
10354
10355
|
async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.runtime.port, runPromise = Effect.runPromise) {
|
|
10355
10356
|
const invocation = readInvocationObservation(controls);
|
|
10357
|
+
let owningSpan;
|
|
10356
10358
|
const correlationId = safeEngineeringIdentifier(invocation?.context?.correlationId ?? controls?.correlation_id);
|
|
10357
10359
|
const context = invocation?.active === false ? void 0 : sanitizeObservationContext(invocation?.context);
|
|
10358
10360
|
const fields = {
|
|
@@ -10379,6 +10381,10 @@ async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.r
|
|
|
10379
10381
|
const failure = error instanceof CapxulError ? error : void 0;
|
|
10380
10382
|
const outcome = Exit.isSuccess(exit) ? "succeeded" : failure?.code === "CANCELLED" ? "cancelled" : failure !== void 0 && EXPECTED_OPERATION_OUTCOMES.has(failure.code) ? "refused" : "failed";
|
|
10381
10383
|
const span = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
10384
|
+
if (Exit.isFailure(exit) && invocation?.active === true) owningSpan = Object.freeze({
|
|
10385
|
+
traceId: span.traceId,
|
|
10386
|
+
spanId: span.spanId
|
|
10387
|
+
});
|
|
10382
10388
|
const completion = {
|
|
10383
10389
|
...fields,
|
|
10384
10390
|
...verifiedOperationFields(span.attributes),
|
|
@@ -10392,7 +10398,10 @@ async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.r
|
|
|
10392
10398
|
yield* (outcome === "failed" ? Effect.logError("capxul_sdk_operation") : Effect.logInfo("capxul_sdk_operation")).pipe(Effect.annotateLogs(completion), Effect.catchCause(() => Effect.void));
|
|
10393
10399
|
return yield* Exit.isSuccess(exit) ? Effect.succeed(exit.value) : Effect.failCause(exit.cause);
|
|
10394
10400
|
}).pipe(Effect.withSpan(operation)), controls));
|
|
10395
|
-
return !result.ok && invocation !== void 0 ? markFailureInvocationSnapshot(result,
|
|
10401
|
+
return !result.ok && invocation !== void 0 ? markFailureInvocationSnapshot(result, {
|
|
10402
|
+
...invocation,
|
|
10403
|
+
...owningSpan === void 0 ? {} : { owningSpan }
|
|
10404
|
+
}) : result;
|
|
10396
10405
|
}
|
|
10397
10406
|
/** Map machine-internal failure state onto the public SDK error vocabulary. */
|
|
10398
10407
|
function publicIdentityFailure(failure) {
|
|
@@ -11559,7 +11568,7 @@ const moneyExecutionContract = {
|
|
|
11559
11568
|
};
|
|
11560
11569
|
//#endregion
|
|
11561
11570
|
//#region ../../packages/sdk/package.json
|
|
11562
|
-
var version$1 = "4.1.
|
|
11571
|
+
var version$1 = "4.1.4";
|
|
11563
11572
|
//#endregion
|
|
11564
11573
|
//#region ../../packages/sdk/src/telemetry/exception-projection.ts
|
|
11565
11574
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -11698,7 +11707,8 @@ function report(adapter, kind, operation, cause, invocation, origin, authoritati
|
|
|
11698
11707
|
}, {
|
|
11699
11708
|
active: invocation.active,
|
|
11700
11709
|
...invocation.actorId === void 0 ? {} : { actorId: invocation.actorId },
|
|
11701
|
-
...context === void 0 ? {} : { context }
|
|
11710
|
+
...context === void 0 ? {} : { context },
|
|
11711
|
+
...invocation.owningSpan === void 0 ? {} : { owningSpan: invocation.owningSpan }
|
|
11702
11712
|
});
|
|
11703
11713
|
try {
|
|
11704
11714
|
ignoreDeliveryFailure(kind === "operation" ? adapter.captureOperationFailure(failure) : adapter.captureException(failure));
|
|
@@ -12421,8 +12431,18 @@ function parsePaymentRequestKeyState(value) {
|
|
|
12421
12431
|
if (typeof state.key !== "string" || !Array.isArray(state.active) || state.active.some((attempt) => typeof attempt !== "string") || typeof state.resolved !== "boolean") throw new TypeError("Invalid payment request key state");
|
|
12422
12432
|
return state;
|
|
12423
12433
|
}
|
|
12424
|
-
|
|
12425
|
-
|
|
12434
|
+
/** A persisted caller key cannot displace another unresolved or active intent. */
|
|
12435
|
+
function managedRequestKeyState(state, provided, hasActiveAttempt) {
|
|
12436
|
+
if (provided === void 0 || state.key === provided) return state;
|
|
12437
|
+
if (!state.resolved || hasActiveAttempt) throw Errors.invalidInput("requestKey", "another request key is unresolved");
|
|
12438
|
+
return {
|
|
12439
|
+
key: provided,
|
|
12440
|
+
active: [],
|
|
12441
|
+
resolved: false
|
|
12442
|
+
};
|
|
12443
|
+
}
|
|
12444
|
+
async function paymentRequestKeyLifecycle(operation, intent, provided, options) {
|
|
12445
|
+
if (provided !== void 0 && options?.manageProvidedKey !== true) return {
|
|
12426
12446
|
key: provided,
|
|
12427
12447
|
finish: async () => void 0
|
|
12428
12448
|
};
|
|
@@ -12435,11 +12455,12 @@ async function paymentRequestKeyLifecycle(operation, intent, provided) {
|
|
|
12435
12455
|
})}`;
|
|
12436
12456
|
if (typeof window === "undefined") {
|
|
12437
12457
|
const attemptId = randomPaymentRequestKey();
|
|
12438
|
-
|
|
12439
|
-
key: randomPaymentRequestKey(),
|
|
12458
|
+
let state = memoryPaymentRequestKeys.get(slot) ?? {
|
|
12459
|
+
key: provided ?? randomPaymentRequestKey(),
|
|
12440
12460
|
active: [],
|
|
12441
12461
|
resolved: false
|
|
12442
12462
|
};
|
|
12463
|
+
state = managedRequestKeyState(state, provided, state.active.length > 0);
|
|
12443
12464
|
state.active.push(attemptId);
|
|
12444
12465
|
memoryPaymentRequestKeys.set(slot, state);
|
|
12445
12466
|
let finished = false;
|
|
@@ -12463,14 +12484,15 @@ async function paymentRequestKeyLifecycle(operation, intent, provided) {
|
|
|
12463
12484
|
const key = await manager.request(slot, async () => {
|
|
12464
12485
|
const stored = window.localStorage.getItem(slot);
|
|
12465
12486
|
let state = stored === null ? {
|
|
12466
|
-
key: randomPaymentRequestKey(),
|
|
12487
|
+
key: provided ?? randomPaymentRequestKey(),
|
|
12467
12488
|
active: [],
|
|
12468
12489
|
resolved: false
|
|
12469
12490
|
} : parsePaymentRequestKeyState(stored);
|
|
12470
12491
|
const registered = state.active.includes(attemptId);
|
|
12471
12492
|
const active = await heldPaymentAttemptIds(manager, slot);
|
|
12493
|
+
state = managedRequestKeyState(state, provided, active.some((id) => id !== attemptId));
|
|
12472
12494
|
if (!registered && active.every((id) => id === attemptId) && state.resolved) state = {
|
|
12473
|
-
key: randomPaymentRequestKey(),
|
|
12495
|
+
key: provided ?? randomPaymentRequestKey(),
|
|
12474
12496
|
active: [],
|
|
12475
12497
|
resolved: false
|
|
12476
12498
|
};
|
|
@@ -43907,21 +43929,54 @@ function executionDependencies(deps) {
|
|
|
43907
43929
|
signer: deps.signer
|
|
43908
43930
|
};
|
|
43909
43931
|
}
|
|
43932
|
+
/** Read only the exact backend prepare receipt, never an arbitrary signer failure. */
|
|
43933
|
+
function payrollResolution(error, requestKey) {
|
|
43934
|
+
const details = error.details;
|
|
43935
|
+
if (error.code !== "WRONG_STATE" || details?.method !== AUTHORIZE_RUN || details.requestKey !== requestKey || typeof details.commandId !== "string" || typeof details.runId !== "string") return void 0;
|
|
43936
|
+
return details.payrollResolution === "failed" || details.payrollResolution === "settled" ? details.payrollResolution : void 0;
|
|
43937
|
+
}
|
|
43910
43938
|
function makePayrollMethods(deps, orgId) {
|
|
43911
43939
|
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
43912
|
-
async function authorize(input, controls) {
|
|
43940
|
+
async function authorize(input, controls, onRequestKey, onResolved) {
|
|
43913
43941
|
const signal = controls?.signal;
|
|
43914
43942
|
const execution = executionDependencies(deps);
|
|
43915
43943
|
if (execution === null) return {
|
|
43916
43944
|
ok: false,
|
|
43917
43945
|
error: Errors.notImplemented("payroll", "executionComposition")
|
|
43918
43946
|
};
|
|
43919
|
-
const requestKey
|
|
43947
|
+
const { requestKey: provided, ...canonicalInput } = input;
|
|
43948
|
+
const actorId = onRequestKey === void 0 ? void 0 : execution.actor.authSession()?.authUserId;
|
|
43949
|
+
if (onRequestKey !== void 0 && actorId === void 0) return {
|
|
43950
|
+
ok: false,
|
|
43951
|
+
error: Errors.notAuthenticated()
|
|
43952
|
+
};
|
|
43953
|
+
const requestKey = await paymentRequestKeyLifecycle(`${requestKeyScope}:${AUTHORIZE_RUN}`, onRequestKey === void 0 ? {
|
|
43920
43954
|
orgId,
|
|
43921
43955
|
input
|
|
43922
|
-
}
|
|
43956
|
+
} : {
|
|
43957
|
+
actorId,
|
|
43958
|
+
orgId,
|
|
43959
|
+
input: canonicalInput
|
|
43960
|
+
}, provided, onRequestKey === void 0 ? void 0 : { manageProvidedKey: true });
|
|
43961
|
+
try {
|
|
43962
|
+
await onRequestKey?.(requestKey.key);
|
|
43963
|
+
if (onRequestKey !== void 0 && execution.actor.authSession()?.authUserId !== actorId) {
|
|
43964
|
+
await requestKey.finish(false).catch(() => void 0);
|
|
43965
|
+
return {
|
|
43966
|
+
ok: false,
|
|
43967
|
+
error: Errors.notAuthenticated()
|
|
43968
|
+
};
|
|
43969
|
+
}
|
|
43970
|
+
} catch (cause) {
|
|
43971
|
+
await requestKey.finish(false).catch(() => void 0);
|
|
43972
|
+
return {
|
|
43973
|
+
ok: false,
|
|
43974
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43975
|
+
};
|
|
43976
|
+
}
|
|
43923
43977
|
let authorized;
|
|
43924
43978
|
let preparedClosed = false;
|
|
43979
|
+
let terminalReplay;
|
|
43925
43980
|
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
43926
43981
|
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(payrollContract.authorizeRun, copyInvocationObservation(controls, { input: {
|
|
43927
43982
|
orgId,
|
|
@@ -43931,7 +43986,10 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43931
43986
|
period: input.period,
|
|
43932
43987
|
items: input.items
|
|
43933
43988
|
} }))), controls), deps.runPromise);
|
|
43934
|
-
if (!prepared.ok)
|
|
43989
|
+
if (!prepared.ok) {
|
|
43990
|
+
terminalReplay = payrollResolution(prepared.error, requestKey.key);
|
|
43991
|
+
return prepared;
|
|
43992
|
+
}
|
|
43935
43993
|
authorized = prepared.value.run;
|
|
43936
43994
|
return {
|
|
43937
43995
|
ok: true,
|
|
@@ -43944,8 +44002,12 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43944
44002
|
runId: authorized.id,
|
|
43945
44003
|
items: input.items
|
|
43946
44004
|
})(request), true, () => preparedClosed = true, signal, controls);
|
|
44005
|
+
const resolution = preparedClosed ? "failed" : terminalReplay;
|
|
44006
|
+
if (resolution !== void 0) try {
|
|
44007
|
+
await onResolved?.(resolution);
|
|
44008
|
+
} catch {}
|
|
43947
44009
|
try {
|
|
43948
|
-
await requestKey.finish(submitted.ok ||
|
|
44010
|
+
await requestKey.finish(submitted.ok || resolution !== void 0);
|
|
43949
44011
|
} catch {}
|
|
43950
44012
|
if (!submitted.ok) return submitted;
|
|
43951
44013
|
return authorized === void 0 ? {
|
|
@@ -43967,7 +44029,7 @@ function makePayrollMethods(deps, orgId) {
|
|
|
43967
44029
|
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
43968
44030
|
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
43969
44031
|
const result = yield* Effect.tryPromise({
|
|
43970
|
-
try: () => authorize(input, carryInvocationParentSpan(controls, parent)),
|
|
44032
|
+
try: () => authorize(input, carryInvocationParentSpan(controls, parent), options?.onRequestKey, options?.onResolved),
|
|
43971
44033
|
catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
43972
44034
|
});
|
|
43973
44035
|
return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
|
|
@@ -46653,7 +46715,7 @@ function stdioIdentity(env = process.env, options = {}) {
|
|
|
46653
46715
|
}
|
|
46654
46716
|
//#endregion
|
|
46655
46717
|
//#region package.json
|
|
46656
|
-
var version = "4.1.
|
|
46718
|
+
var version = "4.1.4";
|
|
46657
46719
|
//#endregion
|
|
46658
46720
|
//#region src/deps.ts
|
|
46659
46721
|
const NO_IDENTITY = async () => void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
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.1.
|
|
54
|
+
"@capxul/sdk": "4.1.4",
|
|
55
55
|
"@capxul/typescript-config": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|