@capxul/mcp 1.0.0-alpha.16 → 1.0.0-alpha.17
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 +214 -24
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -232,7 +232,7 @@ function normalizeEmail(email) {
|
|
|
232
232
|
}
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region package.json
|
|
235
|
-
var version$1 = "1.0.0-alpha.
|
|
235
|
+
var version$1 = "1.0.0-alpha.17";
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/tool-result.ts
|
|
238
238
|
function okResult(structured) {
|
|
@@ -1609,6 +1609,73 @@ function redactError(error, operation, replace) {
|
|
|
1609
1609
|
};
|
|
1610
1610
|
}
|
|
1611
1611
|
//#endregion
|
|
1612
|
+
//#region ../../packages/wire/src/observation-context.ts
|
|
1613
|
+
/** Single bounded HTTP carrier used before a Convex action envelope exists. */
|
|
1614
|
+
const OBSERVATION_CONTEXT_HEADER = "x-capxul-observation-context";
|
|
1615
|
+
const FIELD_RULES = {
|
|
1616
|
+
application: {
|
|
1617
|
+
maxLength: 64,
|
|
1618
|
+
pattern: /^[A-Za-z0-9][A-Za-z0-9._-]*$/u
|
|
1619
|
+
},
|
|
1620
|
+
applicationId: {
|
|
1621
|
+
maxLength: 30,
|
|
1622
|
+
pattern: APP_ID_RE
|
|
1623
|
+
},
|
|
1624
|
+
release: {
|
|
1625
|
+
maxLength: 128,
|
|
1626
|
+
pattern: /^[A-Za-z0-9][A-Za-z0-9._+@:/-]*$/u
|
|
1627
|
+
},
|
|
1628
|
+
sessionId: {
|
|
1629
|
+
maxLength: 128,
|
|
1630
|
+
pattern: /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u
|
|
1631
|
+
},
|
|
1632
|
+
organizationId: {
|
|
1633
|
+
maxLength: 128,
|
|
1634
|
+
pattern: /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u
|
|
1635
|
+
},
|
|
1636
|
+
correlationId: {
|
|
1637
|
+
maxLength: 128,
|
|
1638
|
+
pattern: /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u
|
|
1639
|
+
},
|
|
1640
|
+
anonymousId: {
|
|
1641
|
+
maxLength: 128,
|
|
1642
|
+
pattern: /^anon_[A-Za-z0-9-]+$/u
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
const EMBEDDED_WALLET_MATERIAL = /0x[a-fA-F0-9]{40,}/u;
|
|
1646
|
+
const RAW_PRIVATE_KEY_MATERIAL = /(?:^|[^a-fA-F0-9])[a-fA-F0-9]{64}(?:$|[^a-fA-F0-9])/u;
|
|
1647
|
+
const COMPACT_JWT = /eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/u;
|
|
1648
|
+
const KNOWN_CREDENTIAL_PREFIX = /(?:(?:sk|pk|rk)_(?:live|test)|(?:phc|phx|ghp|gho|ghu|ghs|ghr|whsec)_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza)[A-Za-z0-9_-]*/iu;
|
|
1649
|
+
/**
|
|
1650
|
+
* Copy only the canonical allowlist and silently omit malformed/sensitive
|
|
1651
|
+
* values. Observation metadata is best effort and may never reject a domain
|
|
1652
|
+
* operation.
|
|
1653
|
+
*/
|
|
1654
|
+
function sanitizeObservationContext(input) {
|
|
1655
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return void 0;
|
|
1656
|
+
const source = input;
|
|
1657
|
+
const sanitized = {};
|
|
1658
|
+
for (const field of Object.keys(FIELD_RULES)) {
|
|
1659
|
+
const value = source[field];
|
|
1660
|
+
if (!isSafeField(field, value)) continue;
|
|
1661
|
+
sanitized[field] = value;
|
|
1662
|
+
}
|
|
1663
|
+
return Object.keys(sanitized).length === 0 ? void 0 : sanitized;
|
|
1664
|
+
}
|
|
1665
|
+
/** Encode only the sanitized allowlist; absence stays absence. */
|
|
1666
|
+
function encodeObservationContextHeader(input) {
|
|
1667
|
+
const sanitized = sanitizeObservationContext(input);
|
|
1668
|
+
return sanitized === void 0 ? void 0 : JSON.stringify(sanitized);
|
|
1669
|
+
}
|
|
1670
|
+
function isSafeField(field, value) {
|
|
1671
|
+
if (typeof value !== "string") return false;
|
|
1672
|
+
const rule = FIELD_RULES[field];
|
|
1673
|
+
return value.length > 0 && value.length <= rule.maxLength && value === value.trim() && !value.includes("://") && !containsSensitiveMaterial(value) && rule.pattern.test(value);
|
|
1674
|
+
}
|
|
1675
|
+
function containsSensitiveMaterial(value) {
|
|
1676
|
+
return EMBEDDED_WALLET_MATERIAL.test(value) || RAW_PRIVATE_KEY_MATERIAL.test(value) || COMPACT_JWT.test(value) || KNOWN_CREDENTIAL_PREFIX.test(value);
|
|
1677
|
+
}
|
|
1678
|
+
//#endregion
|
|
1612
1679
|
//#region src/payment-wire.ts
|
|
1613
1680
|
const MONEY_RE$1 = /^\s*([0-9]+(?:\.[0-9]+)?)\s+([A-Za-z][A-Za-z0-9]*)\s*$/;
|
|
1614
1681
|
const MONEY_SCHEMA = z.object({
|
|
@@ -5192,7 +5259,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
5192
5259
|
}
|
|
5193
5260
|
//#endregion
|
|
5194
5261
|
//#region ../../packages/sdk/package.json
|
|
5195
|
-
var version = "1.0.0-alpha.
|
|
5262
|
+
var version = "1.0.0-alpha.17";
|
|
5196
5263
|
//#endregion
|
|
5197
5264
|
//#region ../../packages/sdk/src/ports/auth-client.ts
|
|
5198
5265
|
var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
|
|
@@ -5238,6 +5305,18 @@ function resolveAuthClientUrl(authBaseUrl, path) {
|
|
|
5238
5305
|
return `${base}${path}`;
|
|
5239
5306
|
}
|
|
5240
5307
|
//#endregion
|
|
5308
|
+
//#region ../../packages/sdk/src/internal/observation-http.ts
|
|
5309
|
+
/** Resolve one bounded pre-auth snapshot for an outbound SDK HTTP request. */
|
|
5310
|
+
function observationRequestHeaders(adapter) {
|
|
5311
|
+
if (adapter === void 0) return {};
|
|
5312
|
+
try {
|
|
5313
|
+
const encoded = encodeObservationContextHeader(adapter.resolveContext?.());
|
|
5314
|
+
return encoded === void 0 ? {} : { [OBSERVATION_CONTEXT_HEADER]: encoded };
|
|
5315
|
+
} catch {
|
|
5316
|
+
return {};
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
//#endregion
|
|
5241
5320
|
//#region ../../packages/sdk/src/adapters/auth-client/BetterAuthBrowserAdapter.ts
|
|
5242
5321
|
function withSignal$1(init, signal) {
|
|
5243
5322
|
return signal === void 0 ? init : {
|
|
@@ -5295,8 +5374,10 @@ function mapFetchError$1(operation, err, signal) {
|
|
|
5295
5374
|
var BetterAuthBrowserAdapter = class {
|
|
5296
5375
|
authBaseUrl;
|
|
5297
5376
|
fetchImpl;
|
|
5377
|
+
observation;
|
|
5298
5378
|
constructor(deps) {
|
|
5299
5379
|
this.authBaseUrl = deps.authBaseUrl.replace(/\/$/, "");
|
|
5380
|
+
this.observation = deps.observation;
|
|
5300
5381
|
this.fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
5301
5382
|
}
|
|
5302
5383
|
url(path) {
|
|
@@ -5323,7 +5404,10 @@ var BetterAuthBrowserAdapter = class {
|
|
|
5323
5404
|
try {
|
|
5324
5405
|
const res = await this.fetchImpl(this.url("/api/auth/email-otp/send-verification-otp"), withSignal$1({
|
|
5325
5406
|
method: "POST",
|
|
5326
|
-
headers: {
|
|
5407
|
+
headers: {
|
|
5408
|
+
"Content-Type": "application/json",
|
|
5409
|
+
...observationRequestHeaders(this.observation)
|
|
5410
|
+
},
|
|
5327
5411
|
body: JSON.stringify({
|
|
5328
5412
|
email: input.email,
|
|
5329
5413
|
type: "sign-in"
|
|
@@ -5697,12 +5781,14 @@ var BetterAuthNodeAdapter = class {
|
|
|
5697
5781
|
origin;
|
|
5698
5782
|
cookieJar;
|
|
5699
5783
|
fetchImpl;
|
|
5784
|
+
observation;
|
|
5700
5785
|
constructor(deps) {
|
|
5701
5786
|
this.authBaseUrl = deps.authBaseUrl.replace(/\/$/, "");
|
|
5702
5787
|
this.host = hostFromBaseUrl(this.authBaseUrl);
|
|
5703
5788
|
this.origin = deps.origin?.replace(/\/$/, "");
|
|
5704
5789
|
this.cookieJar = deps.cookieJar ?? new CookieJar();
|
|
5705
5790
|
this.fetchImpl = deps.fetch ?? fetch;
|
|
5791
|
+
this.observation = deps.observation;
|
|
5706
5792
|
}
|
|
5707
5793
|
url(path) {
|
|
5708
5794
|
return resolveAuthClientUrl(this.authBaseUrl, path);
|
|
@@ -5737,7 +5823,8 @@ var BetterAuthNodeAdapter = class {
|
|
|
5737
5823
|
method: "POST",
|
|
5738
5824
|
headers: {
|
|
5739
5825
|
"content-type": "application/json",
|
|
5740
|
-
...this.origin ? { origin: this.origin } : {}
|
|
5826
|
+
...this.origin ? { origin: this.origin } : {},
|
|
5827
|
+
...observationRequestHeaders(this.observation)
|
|
5741
5828
|
},
|
|
5742
5829
|
body: JSON.stringify({
|
|
5743
5830
|
email: input.email,
|
|
@@ -5978,8 +6065,10 @@ async function safeText(res) {
|
|
|
5978
6065
|
var HttpBootstrapAdapter = class {
|
|
5979
6066
|
bootstrapBaseUrl;
|
|
5980
6067
|
fetchImpl;
|
|
6068
|
+
observation;
|
|
5981
6069
|
constructor(deps) {
|
|
5982
6070
|
this.bootstrapBaseUrl = deps.bootstrapBaseUrl.replace(/\/$/, "");
|
|
6071
|
+
this.observation = deps.observation;
|
|
5983
6072
|
this.fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
5984
6073
|
}
|
|
5985
6074
|
resolve(input) {
|
|
@@ -5987,7 +6076,8 @@ var HttpBootstrapAdapter = class {
|
|
|
5987
6076
|
try: () => {
|
|
5988
6077
|
const headers = {
|
|
5989
6078
|
"content-type": "application/json",
|
|
5990
|
-
...input.origin === void 0 ? {} : { origin: input.origin }
|
|
6079
|
+
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
6080
|
+
...observationRequestHeaders(this.observation)
|
|
5991
6081
|
};
|
|
5992
6082
|
return this.fetchImpl(`${this.bootstrapBaseUrl}/v1/client/bootstrap`, {
|
|
5993
6083
|
method: "POST",
|
|
@@ -6081,13 +6171,54 @@ function convexCallErrorFromCapxul(operation, error) {
|
|
|
6081
6171
|
}
|
|
6082
6172
|
var ConvexCallPortTag = class extends Context.Tag("@capxul/sdk/ports/ConvexCallPort")() {};
|
|
6083
6173
|
//#endregion
|
|
6174
|
+
//#region ../../packages/sdk/src/internal/invocation-observation.ts
|
|
6175
|
+
const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
|
|
6176
|
+
const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
|
|
6177
|
+
/** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
|
|
6178
|
+
function attachInvocationObservation(target, context) {
|
|
6179
|
+
const snapshot = Object.freeze(context === void 0 ? {} : { context: Object.freeze({ ...context }) });
|
|
6180
|
+
Object.defineProperty(target, INVOCATION_OBSERVATION, {
|
|
6181
|
+
configurable: false,
|
|
6182
|
+
enumerable: false,
|
|
6183
|
+
value: snapshot,
|
|
6184
|
+
writable: false
|
|
6185
|
+
});
|
|
6186
|
+
return target;
|
|
6187
|
+
}
|
|
6188
|
+
/** @internal Read the snapshot without exposing its symbol or adding a wire field. */
|
|
6189
|
+
function readInvocationObservation(source) {
|
|
6190
|
+
if (typeof source !== "object" || source === null) return void 0;
|
|
6191
|
+
return source[INVOCATION_OBSERVATION];
|
|
6192
|
+
}
|
|
6193
|
+
/** @internal Carry a snapshot across an SDK adapter projection without resolving again. */
|
|
6194
|
+
function copyInvocationObservation(source, target) {
|
|
6195
|
+
const snapshot = readInvocationObservation(source);
|
|
6196
|
+
return snapshot === void 0 ? target : attachInvocationObservation(target, snapshot.context);
|
|
6197
|
+
}
|
|
6198
|
+
/** @internal Mark a failure envelope as already resolved at the public invocation boundary. */
|
|
6199
|
+
function markFailureInvocationSnapshot(failure) {
|
|
6200
|
+
Object.defineProperty(failure, FAILURE_INVOCATION_SNAPSHOT, {
|
|
6201
|
+
configurable: false,
|
|
6202
|
+
enumerable: false,
|
|
6203
|
+
value: true,
|
|
6204
|
+
writable: false
|
|
6205
|
+
});
|
|
6206
|
+
return failure;
|
|
6207
|
+
}
|
|
6208
|
+
//#endregion
|
|
6084
6209
|
//#region ../../packages/sdk/src/adapters/convex-call/ConvexCallAdapter.ts
|
|
6210
|
+
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
6211
|
+
const OBSERVED_CONVEX_ACTIONS = new Set(["subAccount/actions:transfer"]);
|
|
6085
6212
|
var ConvexCallAdapter = class {
|
|
6086
6213
|
#client;
|
|
6087
6214
|
#tokenProvider;
|
|
6215
|
+
#applicationId;
|
|
6216
|
+
#observation;
|
|
6088
6217
|
constructor(deps) {
|
|
6089
6218
|
this.#client = deps.client ?? new ConvexClient(deps.convexUrl);
|
|
6090
6219
|
this.#tokenProvider = deps.tokenProvider;
|
|
6220
|
+
this.#applicationId = deps.applicationId;
|
|
6221
|
+
this.#observation = deps.observation;
|
|
6091
6222
|
if (this.#tokenProvider) this.#client.setAuth(this.#tokenProvider);
|
|
6092
6223
|
}
|
|
6093
6224
|
refreshAuth() {
|
|
@@ -6106,10 +6237,36 @@ var ConvexCallAdapter = class {
|
|
|
6106
6237
|
});
|
|
6107
6238
|
}
|
|
6108
6239
|
action(fn, args) {
|
|
6240
|
+
const path = getFunctionName(fn);
|
|
6109
6241
|
return Effect.tryPromise({
|
|
6110
|
-
try: () => this.#client.action(fn, args),
|
|
6111
|
-
catch: (cause) => mapToConvexCallError(
|
|
6242
|
+
try: () => this.#client.action(fn, this.#observedActionArgs(path, args)),
|
|
6243
|
+
catch: (cause) => mapToConvexCallError(path, cause)
|
|
6244
|
+
});
|
|
6245
|
+
}
|
|
6246
|
+
#observedActionArgs(path, args) {
|
|
6247
|
+
if (!OBSERVED_CONVEX_ACTIONS.has(path)) return args;
|
|
6248
|
+
let hostContext;
|
|
6249
|
+
const invocationSnapshot = readInvocationObservation(args);
|
|
6250
|
+
if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.context;
|
|
6251
|
+
else {
|
|
6252
|
+
const resolveContext = this.#observation?.resolveContext;
|
|
6253
|
+
if (resolveContext === void 0) return args;
|
|
6254
|
+
try {
|
|
6255
|
+
hostContext = resolveContext();
|
|
6256
|
+
} catch {
|
|
6257
|
+
return args;
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
if (hostContext === void 0) return args;
|
|
6261
|
+
hostContext = sanitizeObservationContext({
|
|
6262
|
+
...hostContext,
|
|
6263
|
+
...this.#applicationId === void 0 ? {} : { applicationId: this.#applicationId }
|
|
6112
6264
|
});
|
|
6265
|
+
if (hostContext === void 0) return args;
|
|
6266
|
+
return {
|
|
6267
|
+
...args,
|
|
6268
|
+
observationContext: hostContext
|
|
6269
|
+
};
|
|
6113
6270
|
}
|
|
6114
6271
|
subscribe(fn, args, callback) {
|
|
6115
6272
|
return Effect.try({
|
|
@@ -6882,12 +7039,12 @@ var ConvexSubAccountAdapter = class {
|
|
|
6882
7039
|
const operation = "transfer";
|
|
6883
7040
|
return Effect.suspend(() => {
|
|
6884
7041
|
const rawAmount = toWei(input.amount);
|
|
6885
|
-
return this.#convex.action(this.#fns.transfer, {
|
|
7042
|
+
return this.#convex.action(this.#fns.transfer, copyInvocationObservation(input, {
|
|
6886
7043
|
chainId: this.#chainId,
|
|
6887
7044
|
from: input.from,
|
|
6888
7045
|
to: input.to,
|
|
6889
7046
|
rawAmount
|
|
6890
|
-
});
|
|
7047
|
+
}));
|
|
6891
7048
|
}).pipe(Effect.mapError((error) => subAccountErrorFromCapxul(operation, error.publicError, error)), Effect.map((wire) => brandTransferResult(wire)), Effect.catchAllDefect((cause) => Effect.fail(subAccountErrorFromUnknown(operation, cause))));
|
|
6892
7049
|
}
|
|
6893
7050
|
#runMutation(operation, ref, args) {
|
|
@@ -7184,6 +7341,10 @@ const TransferRequestedProps = Schema.Struct({
|
|
|
7184
7341
|
amount: OptionalWeiAmount,
|
|
7185
7342
|
direction: OptionalTransferDirection
|
|
7186
7343
|
});
|
|
7344
|
+
const TransferBackendReceivedProps = Schema.Struct({
|
|
7345
|
+
...TelemetryEnvelopeProps,
|
|
7346
|
+
direction: OptionalTransferDirection
|
|
7347
|
+
});
|
|
7187
7348
|
const TransferConfirmedProps = Schema.Struct({
|
|
7188
7349
|
...TelemetryEnvelopeProps,
|
|
7189
7350
|
amount: OptionalWeiAmount,
|
|
@@ -7400,6 +7561,10 @@ Schema.Struct({
|
|
|
7400
7561
|
name: Schema.Literal("transfer_requested"),
|
|
7401
7562
|
props: Schema.optional(TransferRequestedProps)
|
|
7402
7563
|
});
|
|
7564
|
+
Schema.Struct({
|
|
7565
|
+
name: Schema.Literal("transfer_backend_received"),
|
|
7566
|
+
props: Schema.optional(TransferBackendReceivedProps)
|
|
7567
|
+
});
|
|
7403
7568
|
Schema.Struct({
|
|
7404
7569
|
name: Schema.Literal("transfer_confirmed"),
|
|
7405
7570
|
props: Schema.optional(TransferConfirmedProps)
|
|
@@ -11224,18 +11389,20 @@ function observeSdkClient(client, adapter) {
|
|
|
11224
11389
|
if (cached !== void 0) return cached;
|
|
11225
11390
|
const wrapped = new Proxy(callable, {
|
|
11226
11391
|
apply(currentTarget, _thisArg, args) {
|
|
11392
|
+
const invocationContext = resolveAdapterContext(adapter);
|
|
11393
|
+
const invocationArgs = carryInvocationContext(operation, args, invocationContext);
|
|
11227
11394
|
let output;
|
|
11228
11395
|
try {
|
|
11229
|
-
output = Reflect.apply(currentTarget, owner,
|
|
11396
|
+
output = Reflect.apply(currentTarget, owner, invocationArgs);
|
|
11230
11397
|
} catch (cause) {
|
|
11231
|
-
report(adapter, "exception", operation, cause);
|
|
11398
|
+
report(adapter, "exception", operation, cause, invocationContext);
|
|
11232
11399
|
throw cause;
|
|
11233
11400
|
}
|
|
11234
|
-
if (isPromiseLike(output)) return Promise.resolve(output).then((result) => processOutput(result, path), (cause) => {
|
|
11235
|
-
report(adapter, "exception", operation, cause);
|
|
11401
|
+
if (isPromiseLike(output)) return Promise.resolve(output).then((result) => processOutput(result, path, invocationContext), (cause) => {
|
|
11402
|
+
report(adapter, "exception", operation, cause, invocationContext);
|
|
11236
11403
|
throw cause;
|
|
11237
11404
|
});
|
|
11238
|
-
return processOutput(output, path);
|
|
11405
|
+
return processOutput(output, path, invocationContext);
|
|
11239
11406
|
},
|
|
11240
11407
|
get(currentTarget, property) {
|
|
11241
11408
|
const attached = Reflect.get(currentTarget, property, currentTarget);
|
|
@@ -11248,9 +11415,9 @@ function observeSdkClient(client, adapter) {
|
|
|
11248
11415
|
}
|
|
11249
11416
|
return isPlainObject(value) ? wrapObject(value, path) : value;
|
|
11250
11417
|
};
|
|
11251
|
-
const processOutput = (output, path) => {
|
|
11418
|
+
const processOutput = (output, path, invocationContext) => {
|
|
11252
11419
|
if (isFailedResult(output)) {
|
|
11253
|
-
report(adapter, "operation", path.join("."), output.error);
|
|
11420
|
+
report(adapter, "operation", path.join("."), output.error, invocationContext);
|
|
11254
11421
|
return output;
|
|
11255
11422
|
}
|
|
11256
11423
|
if (isCapxulResult(output)) return output;
|
|
@@ -11258,24 +11425,40 @@ function observeSdkClient(client, adapter) {
|
|
|
11258
11425
|
};
|
|
11259
11426
|
return wrapObject(client, []);
|
|
11260
11427
|
}
|
|
11428
|
+
function carryInvocationContext(operation, args, context) {
|
|
11429
|
+
if (operation !== "subAccounts.transfer" || !isPlainObject(args[0])) return args;
|
|
11430
|
+
return [attachInvocationObservation({ ...args[0] }, context), ...args.slice(1)];
|
|
11431
|
+
}
|
|
11261
11432
|
/** @internal Reports a factory-level typed failure without changing its identity. */
|
|
11262
11433
|
function observeFailedResult(result, adapter, operation) {
|
|
11263
|
-
if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error);
|
|
11434
|
+
if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterContext(adapter));
|
|
11264
11435
|
return result;
|
|
11265
11436
|
}
|
|
11266
|
-
function report(adapter, kind, operation, cause) {
|
|
11437
|
+
function report(adapter, kind, operation, cause, invocationContext) {
|
|
11267
11438
|
const operationName = normalizeOperation(operation);
|
|
11268
11439
|
const kindName = normalizeErrorKind(errorKind(cause));
|
|
11269
|
-
const
|
|
11440
|
+
const context = sanitizeObservationContext({
|
|
11441
|
+
...invocationContext,
|
|
11442
|
+
...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
11443
|
+
});
|
|
11444
|
+
const failure = markFailureInvocationSnapshot({
|
|
11270
11445
|
exception: syntheticException(operationName, kindName),
|
|
11271
11446
|
sdkVersion: SDK_VERSION$1,
|
|
11272
11447
|
operation: operationName,
|
|
11273
|
-
errorKind: kindName
|
|
11274
|
-
|
|
11448
|
+
errorKind: kindName,
|
|
11449
|
+
...context === void 0 ? {} : { context }
|
|
11450
|
+
});
|
|
11275
11451
|
try {
|
|
11276
11452
|
ignoreDeliveryFailure(kind === "operation" ? adapter.captureOperationFailure(failure) : adapter.captureException(failure));
|
|
11277
11453
|
} catch {}
|
|
11278
11454
|
}
|
|
11455
|
+
function resolveAdapterContext(adapter) {
|
|
11456
|
+
try {
|
|
11457
|
+
return sanitizeObservationContext(adapter.resolveContext?.());
|
|
11458
|
+
} catch {
|
|
11459
|
+
return;
|
|
11460
|
+
}
|
|
11461
|
+
}
|
|
11279
11462
|
function ignoreDeliveryFailure(delivery) {
|
|
11280
11463
|
if (!isPromiseLike(delivery)) return;
|
|
11281
11464
|
try {
|
|
@@ -11424,11 +11607,13 @@ function productionBootstrapPortLayer(bootstrap) {
|
|
|
11424
11607
|
function productionAuthClientLayer(input, refreshConvexAuthRef) {
|
|
11425
11608
|
return (input.runtime === "browser" ? BetterAuthBrowserLayer({
|
|
11426
11609
|
authBaseUrl: input.runtimeUrls.authBaseUrl,
|
|
11427
|
-
...input.fetch === void 0 ? {} : { fetch: input.fetch }
|
|
11610
|
+
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
11611
|
+
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
11428
11612
|
}) : BetterAuthNodeLayer({
|
|
11429
11613
|
authBaseUrl: input.runtimeUrls.authBaseUrl,
|
|
11430
11614
|
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
11431
|
-
...input.fetch === void 0 ? {} : { fetch: input.fetch }
|
|
11615
|
+
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
11616
|
+
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
11432
11617
|
})).pipe(Layer.map((context) => {
|
|
11433
11618
|
const authClient = Context.get(context, AuthClientPortTag);
|
|
11434
11619
|
return Context.make(AuthClientPortTag, refreshConvexAuthOnSession(authClient, () => {
|
|
@@ -11447,6 +11632,8 @@ function productionAuthCacheLayer(input) {
|
|
|
11447
11632
|
function productionConvexCallLayer(input, refreshConvexAuthRef) {
|
|
11448
11633
|
return Layer.unwrapEffect(Effect.map(AuthClientPortTag, (authClient) => ConvexCallLayer({
|
|
11449
11634
|
convexUrl: input.runtimeUrls.convexUrl,
|
|
11635
|
+
...input.applicationId === void 0 ? {} : { applicationId: input.applicationId },
|
|
11636
|
+
...input.observation === void 0 ? {} : { observation: input.observation },
|
|
11450
11637
|
...input.convexClient === void 0 ? {} : { client: input.convexClient },
|
|
11451
11638
|
tokenProvider: async ({ forceRefreshToken }) => {
|
|
11452
11639
|
const tokenResult = await Effect.runPromise(Effect.either(authClient.getConvexJwt({
|
|
@@ -11478,7 +11665,8 @@ async function createProductionAdapters(input) {
|
|
|
11478
11665
|
const closeScope = idempotentClose(() => Effect.runPromise(Scope.close(scope, Exit.void)));
|
|
11479
11666
|
const bootstrapLayer = HttpBootstrapLayer({
|
|
11480
11667
|
bootstrapBaseUrl: resolvedInput.value.bootstrapBaseUrl,
|
|
11481
|
-
...input.fetch === void 0 ? {} : { fetch: input.fetch }
|
|
11668
|
+
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
11669
|
+
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
11482
11670
|
});
|
|
11483
11671
|
try {
|
|
11484
11672
|
const bootstrapContext = await Effect.runPromise(Layer.buildWithScope(bootstrapLayer, scope));
|
|
@@ -11536,6 +11724,8 @@ async function createProductionAdapters(input) {
|
|
|
11536
11724
|
...resolvedInput.value.origin === void 0 ? {} : { origin: resolvedInput.value.origin },
|
|
11537
11725
|
runtimeUrls: runtimeUrls.value,
|
|
11538
11726
|
chainId: bootstrapResult.value.chainId,
|
|
11727
|
+
applicationId: bootstrapResult.value.applicationId,
|
|
11728
|
+
...input.observation === void 0 ? {} : { observation: input.observation },
|
|
11539
11729
|
...input.authCache === void 0 ? {} : { authCache: input.authCache },
|
|
11540
11730
|
...input.telemetry === void 0 ? {} : { telemetry: input.telemetry },
|
|
11541
11731
|
...injectedClient === void 0 ? {} : { convexClient: injectedClient },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Capxul MCP server — agent-facing financial-ops tools (auth, account readiness, balances, testnet faucet, payments) exposed over Streamable HTTP with OAuth bearer auth and a dev-mode custody gate.",
|
|
6
6
|
"keywords": [
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vite-plus": "0.1.23",
|
|
55
55
|
"@capxul/backend": "0.1.0-alpha.2",
|
|
56
56
|
"@capxul/config": "0.1.0-alpha.1",
|
|
57
|
-
"@capxul/sdk": "1.0.0-alpha.
|
|
57
|
+
"@capxul/sdk": "1.0.0-alpha.17",
|
|
58
58
|
"@capxul/types": "0.1.0-alpha.0",
|
|
59
59
|
"@capxul/wire": "0.1.0-alpha.1",
|
|
60
60
|
"@capxul/errors": "0.0.0",
|