@capxul/mcp 2.5.0 → 2.5.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.
Files changed (2) hide show
  1. package/dist/main.mjs +251 -25
  2. package/package.json +6 -6
package/dist/main.mjs CHANGED
@@ -9,7 +9,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
9
9
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
10
  import { concat, concatHex, createPublicClient, createWalletClient, custom, decodeAbiParameters, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getAddress, getContractAddress, hashMessage, hashTypedData, hexToBigInt, http, isAddress, isHex, keccak256, pad, padHex, parseUnits, recoverAddress, size, slice, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature, toHex, zeroAddress } from "viem";
11
11
  import { z } from "zod";
12
- import { Cause, Context, Data, Deferred, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, SchemaIssue, SchemaParser, Scope, Struct, Tracer } from "effect";
12
+ import { Cause, Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schedule, Schema, SchemaGetter, SchemaIssue, SchemaParser, Scope, Struct, Tracer } from "effect";
13
13
  import { privateKeyToAccount, toAccount } from "viem/accounts";
14
14
  import { FetchHttpClient, Headers, HttpClient } from "effect/unstable/http";
15
15
  import { OtlpExporter, OtlpLogger, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
@@ -240,7 +240,7 @@ function normalizeEmail(email) {
240
240
  }
241
241
  //#endregion
242
242
  //#region package.json
243
- var version$2 = "2.5.0";
243
+ var version$2 = "2.5.1";
244
244
  //#endregion
245
245
  //#region ../../packages/errors/src/errors.ts
246
246
  const CAPXUL_ERROR_CODES = [
@@ -339,10 +339,12 @@ const Errors = {
339
339
  accountNotFound: (accountId) => new CapxulError("ACCOUNT_NOT_FOUND", accountId ? `Openfort account ${accountId} not found` : "Openfort account not found", accountId === void 0 ? void 0 : { details: { accountId } }),
340
340
  providerError: (provider, operation, cause, opts) => {
341
341
  const details = {
342
+ ...opts?.details,
342
343
  provider,
343
344
  operation
344
345
  };
345
346
  if (opts?.failure_mode) details.failure_mode = opts.failure_mode;
347
+ if (opts?.httpStatus !== void 0) details.httpStatus = opts.httpStatus;
346
348
  return new CapxulError("PROVIDER_ERROR", `Provider error: ${provider} ${operation}`, {
347
349
  cause,
348
350
  details
@@ -4237,6 +4239,9 @@ const SENSITIVE_MATERIAL_PATTERNS = [
4237
4239
  /eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/u,
4238
4240
  /(?:(?: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
4239
4241
  ];
4242
+ const RAW_PRIVATE_KEY_MASK = /(^|[^a-fA-F0-9])[a-fA-F0-9]{64}(?=$|[^a-fA-F0-9])/gu;
4243
+ const KNOWN_CREDENTIAL_MASK = /(?:(?: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_-]*/giu;
4244
+ const LABELLED_SECRET_MASK = /\b(api[ _-]?key|access[ _-]?token|token|secret|password|passphrase|private[ _-]?key|authorization|cookie|signature|request[ _-]?body|credential|otp|one[ _-]?time[ _-]?(?:password|code)|verification[ _-]?code)\b\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu;
4240
4245
  /**
4241
4246
  * Reject: does the value carry any known secret material? Best effort — callers
4242
4247
  * drop the whole value on a match; a false negative is a leak, a false positive
@@ -4245,6 +4250,14 @@ const SENSITIVE_MATERIAL_PATTERNS = [
4245
4250
  function containsSensitiveMaterial(value) {
4246
4251
  return SENSITIVE_MATERIAL_PATTERNS.some((pattern) => pattern.test(value));
4247
4252
  }
4253
+ /**
4254
+ * Mask: return the value with every known secret rewritten to `[REDACTED]`,
4255
+ * preserving surrounding text. Used where a value must still be shown (log
4256
+ * lines, issue bodies) but must not carry live credentials.
4257
+ */
4258
+ function redactSecrets(value) {
4259
+ return value.replace(/\bBearer\s+[^\s,;]+/giu, "Bearer [REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu, "[REDACTED]").replace(/\b0x[a-fA-F0-9]{40,}\b/gu, "[REDACTED]").replace(RAW_PRIVATE_KEY_MASK, "$1[REDACTED]").replace(KNOWN_CREDENTIAL_MASK, "[REDACTED]").replace(LABELLED_SECRET_MASK, (_match, label) => `${label}=[REDACTED]`);
4260
+ }
4248
4261
  //#endregion
4249
4262
  //#region ../../packages/wire/src/observation-context.ts
4250
4263
  /** Single bounded HTTP carrier used before a Convex action envelope exists. */
@@ -6108,8 +6121,8 @@ var ActorFailure = class extends Error {
6108
6121
  event;
6109
6122
  details;
6110
6123
  _tag = "ActorFailure";
6111
- constructor(reason, machine, state, event, details) {
6112
- super(`${machine}:${state}:${event} ${reason}`);
6124
+ constructor(reason, machine, state, event, details, cause) {
6125
+ super(`${machine}:${state}:${event} ${reason}`, cause === void 0 ? void 0 : { cause });
6113
6126
  this.reason = reason;
6114
6127
  this.machine = machine;
6115
6128
  this.state = state;
@@ -6184,8 +6197,8 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
6184
6197
  defect(cause);
6185
6198
  }
6186
6199
  };
6187
- const makeFailure = (state, event, reason, details) => new ActorFailure(reason, spec.machine, spec.label(state), event._tag, details);
6188
- const nonApplied = (state, event, reason, outcome, env) => {
6200
+ const makeFailure = (state, event, reason, details, cause) => new ActorFailure(reason, spec.machine, spec.label(state), event._tag, details, cause);
6201
+ const nonApplied = (state, event, reason, outcome, env, failure) => {
6189
6202
  const slot = env.origin?.slot ?? spec.slot(event);
6190
6203
  return copyInvocationObservation(env.invocation, {
6191
6204
  machine: spec.machine,
@@ -6196,7 +6209,8 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
6196
6209
  outcome,
6197
6210
  duration_ms: duration(env.startedAt),
6198
6211
  ...withCarriage(env.invocation),
6199
- ...outcome === "refused" ? { refusal_code: reason } : { error_code: reason }
6212
+ ...outcome === "refused" ? { refusal_code: reason } : { error_code: reason },
6213
+ ...failure === void 0 ? {} : { failure }
6200
6214
  });
6201
6215
  };
6202
6216
  const applied = (from, to, event, slot, epoch, env) => copyInvocationObservation(env.invocation, {
@@ -6249,12 +6263,13 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
6249
6263
  slots.delete(env.origin.slot);
6250
6264
  defect(exit.defect);
6251
6265
  const event = { _tag: env.origin.event };
6252
- const failedState = yield* recoverFailure(state, env.origin, {
6266
+ const died = {
6253
6267
  code: "WORK_DIED",
6254
- message: "Identity work died"
6255
- });
6256
- yield* emit(nonApplied(failedState, event, "WORK_DIED", "failed", env));
6257
- yield* failReply(held.reply, makeFailure(failedState, event, "WORK_DIED"));
6268
+ message: exit.defect instanceof Error ? exit.defect.message : "Identity work died"
6269
+ };
6270
+ const failedState = yield* recoverFailure(state, env.origin, died);
6271
+ yield* emit(nonApplied(failedState, event, "WORK_DIED", "failed", env, died));
6272
+ yield* failReply(held.reply, makeFailure(failedState, event, "WORK_DIED", void 0, died));
6258
6273
  return;
6259
6274
  }
6260
6275
  if (exit.failure !== void 0) {
@@ -6262,9 +6277,9 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
6262
6277
  const outcome = exit.failure.code === "CANCELLED" ? "cancelled" : "failed";
6263
6278
  const event = { _tag: env.origin.event };
6264
6279
  const failedState = exit.failure === timeoutFailure || exit.failure === cancelledFailure ? yield* recoverFailure(state, env.origin, exit.failure) : state;
6265
- yield* emit(nonApplied(failedState, event, exit.failure.code, outcome, env));
6280
+ yield* emit(nonApplied(failedState, event, exit.failure.code, outcome, env, exit.failure));
6266
6281
  const details = exit.failure === timeoutFailure ? { reason: "timeout" } : void 0;
6267
- yield* failReply(held.reply, makeFailure(failedState, event, exit.failure.code, details));
6282
+ yield* failReply(held.reply, makeFailure(failedState, event, exit.failure.code, details, exit.failure.error ?? exit.failure));
6268
6283
  return;
6269
6284
  }
6270
6285
  yield* finish(env.origin, state);
@@ -8897,7 +8912,7 @@ async function recoverRawDigestSigner(input) {
8897
8912
  }
8898
8913
  //#endregion
8899
8914
  //#region ../../packages/sdk/package.json
8900
- var version = "2.5.0";
8915
+ var version = "2.5.1";
8901
8916
  //#endregion
8902
8917
  //#region ../../packages/observability/src/engineering.ts
8903
8918
  const ENGINEERING_CAPXUL_ENVS = [
@@ -9799,6 +9814,33 @@ function bootstrapErrorFromCapxul(kind, error) {
9799
9814
  var BootstrapPortTag = class extends Context.Service()("@capxul/sdk/ports/BootstrapPort") {};
9800
9815
  //#endregion
9801
9816
  //#region ../../packages/sdk/src/adapters/bootstrap/HttpBootstrapAdapter.ts
9817
+ const DEFAULT_RETRY = {
9818
+ attempts: 2,
9819
+ baseDelayMs: 400
9820
+ };
9821
+ /** Request-side statuses a proxy or backend returns while momentarily unable to serve. */
9822
+ const TRANSIENT_HTTP_STATUSES = new Set([
9823
+ 408,
9824
+ 425,
9825
+ 429
9826
+ ]);
9827
+ /** Every 5xx is a server-side condition worth one more try; the client sent nothing wrong. */
9828
+ function isTransientHttpStatus(status) {
9829
+ return status >= 500 || TRANSIENT_HTTP_STATUSES.has(status);
9830
+ }
9831
+ /**
9832
+ * A transient HTTP status is worth one more try. The bootstrap call crosses
9833
+ * the host's own proxy before it reaches Convex, and every observed failure
9834
+ * of that hop cleared on a retry seconds later. A network rejection (offline,
9835
+ * DNS, CORS) is not retried: it does not clear in a second, and the caller
9836
+ * surfaces it as `NETWORK_ERROR` at once. Auth and input rejections are
9837
+ * deterministic and never retried.
9838
+ */
9839
+ function isTransientBootstrapFailure(error) {
9840
+ if (error.kind !== "provider") return false;
9841
+ const status = error.details?.httpStatus;
9842
+ return typeof status === "number" && isTransientHttpStatus(status);
9843
+ }
9802
9844
  async function safeText(res) {
9803
9845
  try {
9804
9846
  return await res.text();
@@ -9810,12 +9852,21 @@ var HttpBootstrapAdapter = class {
9810
9852
  bootstrapBaseUrl;
9811
9853
  fetchImpl;
9812
9854
  observation;
9855
+ retry;
9813
9856
  constructor(deps) {
9814
9857
  this.bootstrapBaseUrl = deps.bootstrapBaseUrl.replace(/\/$/, "");
9815
9858
  this.observation = deps.observation;
9859
+ this.retry = deps.retry ?? DEFAULT_RETRY;
9816
9860
  this.fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
9817
9861
  }
9818
9862
  resolve(input) {
9863
+ return this.attempt(input).pipe(Effect.retry({
9864
+ times: this.retry.attempts,
9865
+ while: isTransientBootstrapFailure,
9866
+ schedule: Schedule.exponential(Duration.millis(this.retry.baseDelayMs))
9867
+ }));
9868
+ }
9869
+ attempt(input) {
9819
9870
  return Effect.tryPromise({
9820
9871
  try: () => {
9821
9872
  const headers = {
@@ -9868,7 +9919,17 @@ var HttpBootstrapAdapter = class {
9868
9919
  return Effect.promise(() => safeText(res)).pipe(Effect.flatMap((body) => {
9869
9920
  if (res.status === 401 || body.startsWith("NOT_AUTHENTICATED")) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", Errors.notAuthenticated()));
9870
9921
  if (res.status === 400 || body.startsWith("INVALID_INPUT")) return Effect.fail(bootstrapErrorFromCapxul("invalidInput", Errors.invalidInput("publishableKey", "rejected by bootstrap")));
9871
- return Effect.fail(bootstrapErrorFromCapxul("provider", Errors.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}`))));
9922
+ const responseBody = body.slice(0, 300);
9923
+ const edgeError = res.headers?.get?.("x-vercel-error") ?? void 0;
9924
+ const edgeRequestId = res.headers?.get?.("x-vercel-id") ?? void 0;
9925
+ return Effect.fail(bootstrapErrorFromCapxul("provider", Errors.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}${edgeError === void 0 ? "" : ` ${edgeError}`}`), {
9926
+ httpStatus: res.status,
9927
+ details: {
9928
+ ...responseBody.length === 0 ? {} : { responseBody },
9929
+ ...edgeError === void 0 ? {} : { edgeError },
9930
+ ...edgeRequestId === void 0 ? {} : { edgeRequestId }
9931
+ }
9932
+ })));
9872
9933
  }));
9873
9934
  }
9874
9935
  };
@@ -39712,23 +39773,50 @@ function observeSdkClient(client, adapter, snapshot) {
39712
39773
  }
39713
39774
  }
39714
39775
  /** @internal Reports a factory-level typed failure without changing its identity. */
39715
- function observeFailedResult(result, adapter, operation) {
39716
- if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterSnapshot(adapter));
39776
+ function observeFailedResult(result, adapter, operation, origin) {
39777
+ if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterSnapshot(adapter), origin);
39717
39778
  return result;
39718
39779
  }
39719
- function report(adapter, kind, operation, cause, invocation) {
39780
+ /**
39781
+ * One failure, one event. The identity machine reports a failed transition
39782
+ * first; when the same `CapxulError` then surfaces as a public method result
39783
+ * (directly or down its `cause` chain), the boundary drops that second report.
39784
+ * Only machine-reported errors are remembered, so a caller that reuses one
39785
+ * error object across unrelated public methods still sees every report.
39786
+ */
39787
+ const machineReportedCauses = /* @__PURE__ */ new WeakSet();
39788
+ function reportedByMachine(cause) {
39789
+ let link = cause;
39790
+ for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
39791
+ if (machineReportedCauses.has(link)) return true;
39792
+ link = link.cause;
39793
+ }
39794
+ return false;
39795
+ }
39796
+ function report(adapter, kind, operation, cause, invocation, origin) {
39797
+ if (origin === "machine") {
39798
+ let link = cause;
39799
+ for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
39800
+ machineReportedCauses.add(link);
39801
+ link = link.cause;
39802
+ }
39803
+ } else if (reportedByMachine(cause)) return;
39720
39804
  const operationName = normalizeOperation(operation);
39721
39805
  const kindName = normalizeErrorKind(errorKind(cause));
39722
39806
  const context = sanitizeObservationContext({
39723
39807
  ...invocation.context,
39724
39808
  ...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
39725
39809
  });
39810
+ const detail = failureDetail(cause);
39811
+ const evidence = failureEvidence(cause);
39726
39812
  const failure = markFailureInvocationSnapshot({
39727
- exception: syntheticException(operationName, kindName),
39813
+ exception: syntheticException(operationName, kindName, evidence.message, evidence.stack),
39728
39814
  sdkVersion: SDK_VERSION$1,
39729
39815
  operation: operationName,
39730
39816
  errorKind: kindName,
39731
- ...context === void 0 ? {} : { context }
39817
+ ...context === void 0 ? {} : { context },
39818
+ ...detail === void 0 ? {} : { detail },
39819
+ ...evidence
39732
39820
  }, {
39733
39821
  active: invocation.active,
39734
39822
  ...context === void 0 ? {} : { context }
@@ -39764,6 +39852,72 @@ function ignoreDeliveryFailure(delivery) {
39764
39852
  Promise.resolve(delivery).catch(() => void 0);
39765
39853
  } catch {}
39766
39854
  }
39855
+ const MAX_EVIDENCE_TEXT = 4e3;
39856
+ const MAX_CAUSE_DEPTH = 8;
39857
+ function evidenceText(value) {
39858
+ if (typeof value !== "string" || value.length === 0) return void 0;
39859
+ return redactSecrets(value).slice(0, MAX_EVIDENCE_TEXT);
39860
+ }
39861
+ /** A field whose NAME says credential is masked whatever its value looks like. */
39862
+ const CREDENTIAL_FIELD_NAME = /(?:otp|pass(?:word|wd|phrase)?|token|secret|credential|api[_-]?key|private[_-]?key|authorization|cookie|session)/iu;
39863
+ /** Copy a details object into a JSON-safe shape with every string masked. */
39864
+ function evidenceValue(value, depth = 0) {
39865
+ if (typeof value === "string") return evidenceText(value);
39866
+ if (typeof value === "number" || typeof value === "boolean" || value === null) return value;
39867
+ if (typeof value === "bigint") return value.toString();
39868
+ if (value instanceof Error) return evidenceText(value.message);
39869
+ if (depth >= 4 || typeof value !== "object") return void 0;
39870
+ if (Array.isArray(value)) return value.slice(0, 50).map((item) => evidenceValue(item, depth + 1));
39871
+ const copy = {};
39872
+ for (const [key, nested] of Object.entries(value)) {
39873
+ if (CREDENTIAL_FIELD_NAME.test(key)) {
39874
+ copy[key] = "[REDACTED]";
39875
+ continue;
39876
+ }
39877
+ const safe = evidenceValue(nested, depth + 1);
39878
+ if (safe !== void 0) copy[key] = safe;
39879
+ }
39880
+ return copy;
39881
+ }
39882
+ /**
39883
+ * @internal The evidence in PostHog property shape, for product events that
39884
+ * name a failure (`bootstrap_failed`). Same keys as the `$exception` event.
39885
+ */
39886
+ function failureEvidenceProps(cause) {
39887
+ const evidence = failureEvidence(cause);
39888
+ return {
39889
+ ...evidence.message === void 0 ? {} : { error_message: evidence.message },
39890
+ ...evidence.details === void 0 ? {} : { error_details: evidence.details },
39891
+ ...evidence.causeChain === void 0 ? {} : { error_cause: evidence.causeChain.join(" <- ") }
39892
+ };
39893
+ }
39894
+ /** The real failure, masked for secrets only. Never throws. */
39895
+ function failureEvidence(cause) {
39896
+ try {
39897
+ const message = cause instanceof Error ? evidenceText(cause.message) : evidenceText(cause);
39898
+ const stack = cause instanceof Error ? evidenceText(cause.stack) : void 0;
39899
+ const details = isCapxulError(cause) && typeof cause.details === "object" && cause.details !== null ? evidenceValue(cause.details) : void 0;
39900
+ const causeChain = [];
39901
+ let previous = message;
39902
+ let link = cause instanceof Error ? cause.cause : void 0;
39903
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && link !== void 0 && link !== null; depth++) {
39904
+ const text = link instanceof Error ? evidenceText(link.message) : evidenceText(link);
39905
+ if (text !== void 0 && text !== previous) {
39906
+ causeChain.push(text);
39907
+ previous = text;
39908
+ }
39909
+ link = link instanceof Error ? link.cause : void 0;
39910
+ }
39911
+ return {
39912
+ ...message === void 0 ? {} : { message },
39913
+ ...details === void 0 || Object.keys(details).length === 0 ? {} : { details },
39914
+ ...causeChain.length === 0 ? {} : { causeChain },
39915
+ ...stack === void 0 ? {} : { stack }
39916
+ };
39917
+ } catch {
39918
+ return {};
39919
+ }
39920
+ }
39767
39921
  function errorKind(cause) {
39768
39922
  try {
39769
39923
  if (isCapxulError(cause)) return normalizeErrorKind(cause.code);
@@ -39773,16 +39927,53 @@ function errorKind(cause) {
39773
39927
  return "Error";
39774
39928
  }
39775
39929
  }
39930
+ /**
39931
+ * @internal Lift the enumerated discriminators off a `CapxulError` so a
39932
+ * boundary event says WHICH provider failed and HOW, not just `PROVIDER_ERROR`.
39933
+ * Shared by the failure boundary and the `bootstrap_failed` product event.
39934
+ */
39935
+ function failureDetail(cause) {
39936
+ if (!isCapxulError(cause)) return void 0;
39937
+ const details = cause.details;
39938
+ if (typeof details !== "object" || details === null) return void 0;
39939
+ const source = details;
39940
+ return sanitizeFailureDetail({
39941
+ provider: source.provider,
39942
+ provider_operation: source.operation,
39943
+ failure_mode: source.failure_mode,
39944
+ reason: source.reason,
39945
+ http_status: source.httpStatus
39946
+ });
39947
+ }
39948
+ function sanitizeFailureDetail(input) {
39949
+ if (typeof input !== "object" || input === null) return void 0;
39950
+ const source = input;
39951
+ const detail = {};
39952
+ for (const key of [
39953
+ "provider",
39954
+ "provider_operation",
39955
+ "failure_mode",
39956
+ "reason"
39957
+ ]) {
39958
+ const value = source[key];
39959
+ if (typeof value === "string" && ENUMERATED_DETAIL_RE.test(value)) detail[key] = value;
39960
+ }
39961
+ const status = source.http_status;
39962
+ if (typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599) detail.http_status = status;
39963
+ return Object.keys(detail).length === 0 ? void 0 : detail;
39964
+ }
39965
+ /** Enumerated codes only (`convex`, `no-secure-context`, `bootstrap-encode`); free text fails. */
39966
+ const ENUMERATED_DETAIL_RE = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
39776
39967
  function normalizeOperation(value) {
39777
39968
  return typeof value === "string" && /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,255}$/u.test(value) ? value : "unknown";
39778
39969
  }
39779
39970
  function normalizeErrorKind(value) {
39780
39971
  return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value) ? value : "Error";
39781
39972
  }
39782
- function syntheticException(operation, kind) {
39783
- const error = /* @__PURE__ */ new Error(EXCEPTION_MESSAGE);
39973
+ function syntheticException(operation, kind, message = EXCEPTION_MESSAGE, stack) {
39974
+ const error = new Error(message);
39784
39975
  error.name = kind;
39785
- error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)`;
39976
+ error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)` + (stack === void 0 ? "" : `\nCaused by: ${stack}`);
39786
39977
  return error;
39787
39978
  }
39788
39979
  function isPromiseLike(value) {
@@ -39938,10 +40129,19 @@ function assembleCapxulClient(input) {
39938
40129
  const unsubscribeProductTelemetry = actor.subscribeTransitions((record) => {
39939
40130
  effectRunner.runPromise(executeIdentityProductObservation(input.ports.telemetry, record, actor.snapshot())).catch(() => {});
39940
40131
  });
40132
+ const failureObservation = observation.failureObservation;
40133
+ const unsubscribeFailureObservation = failureObservation === void 0 ? () => {} : actor.subscribeTransitions((record) => {
40134
+ if (record.outcome !== "failed") return;
40135
+ observeFailedResult({
40136
+ ok: false,
40137
+ error: transitionError(record)
40138
+ }, failureObservation, `identity.${record.event}`, "machine");
40139
+ });
39941
40140
  let stopPromise = null;
39942
40141
  const stopActor = () => {
39943
40142
  if (stopPromise === null) {
39944
40143
  unsubscribeProductTelemetry();
40144
+ unsubscribeFailureObservation();
39945
40145
  stopPromise = effectRunner.runPromise(Scope.close(scope, Exit.void));
39946
40146
  }
39947
40147
  return stopPromise;
@@ -40126,6 +40326,30 @@ function assembleCapxulClient(input) {
40126
40326
  }
40127
40327
  }, observation.failureObservation, observation.hostObservationSnapshot);
40128
40328
  }
40329
+ function transitionError(record) {
40330
+ const failure = record.failure;
40331
+ if (failure?.error !== void 0) {
40332
+ const error = failure.error;
40333
+ if (record.correlation_id === void 0 || error.correlationId !== void 0) return error;
40334
+ return new CapxulError(error.code, error.message, {
40335
+ cause: error,
40336
+ correlationId: record.correlation_id,
40337
+ ...error.details === void 0 ? {} : { details: error.details },
40338
+ ...error.layer === void 0 ? {} : { layer: error.layer }
40339
+ });
40340
+ }
40341
+ return new CapxulError(record.error_code, failure?.message ?? "Identity work failed", {
40342
+ ...failure === void 0 ? {} : { cause: failure },
40343
+ details: {
40344
+ machine: record.machine,
40345
+ state: record.state,
40346
+ event: record.event,
40347
+ slot: record.slot,
40348
+ ...failure?.mode === void 0 ? {} : { failure_mode: failure.mode }
40349
+ },
40350
+ ...record.correlation_id === void 0 ? {} : { correlationId: record.correlation_id }
40351
+ });
40352
+ }
40129
40353
  function withHostObservation(actor, snapshot) {
40130
40354
  if (snapshot === void 0) return actor;
40131
40355
  const controls = (input) => {
@@ -40335,7 +40559,9 @@ async function createProductionAdapters(input) {
40335
40559
  name: "bootstrap_failed",
40336
40560
  props: {
40337
40561
  ...bootstrapTelemetryEnvelope(input, resolvedInput.value),
40338
- reason: bootstrapResult.error.code
40562
+ reason: bootstrapResult.error.code,
40563
+ ...failureDetail(bootstrapResult.error),
40564
+ ...failureEvidenceProps(bootstrapResult.error)
40339
40565
  }
40340
40566
  });
40341
40567
  await closeScope().catch(() => void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "2.5.0",
3
+ "version": "2.5.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": [
@@ -47,12 +47,12 @@
47
47
  "typescript": "npm:@typescript/typescript6@6.0.2",
48
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
49
49
  "vite-plus": "0.1.23",
50
- "@capxul/backend": "0.2.7",
51
- "@capxul/config": "0.2.0",
52
- "@capxul/sdk": "2.5.0",
53
- "@capxul/types": "0.2.0",
50
+ "@capxul/backend": "0.2.8",
51
+ "@capxul/config": "0.2.1",
52
+ "@capxul/sdk": "2.5.1",
53
+ "@capxul/types": "0.2.1",
54
54
  "@capxul/typescript-config": "0.0.0",
55
- "@capxul/wire": "0.5.0"
55
+ "@capxul/wire": "0.5.1"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "vp exec tsx src/main.ts serve",