@capxul/mcp 1.2.1 → 1.2.3
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 +288 -172
- package/package.json +3 -3
package/dist/main.mjs
CHANGED
|
@@ -242,7 +242,7 @@ function normalizeEmail(email) {
|
|
|
242
242
|
}
|
|
243
243
|
//#endregion
|
|
244
244
|
//#region package.json
|
|
245
|
-
var version$2 = "1.2.
|
|
245
|
+
var version$2 = "1.2.3";
|
|
246
246
|
//#endregion
|
|
247
247
|
//#region src/tool-result.ts
|
|
248
248
|
function okResult(structured) {
|
|
@@ -887,6 +887,25 @@ const EpochMsSchema$1 = Schema.Number.pipe(Schema.refine((n) => Number.isSafeInt
|
|
|
887
887
|
const DurationMsSchema$1 = Schema.Number.pipe(Schema.refine((n) => Number.isSafeInteger(n) && n >= 0, { message: "must be a non-negative safe integer" }));
|
|
888
888
|
//#endregion
|
|
889
889
|
//#region ../../packages/wire/src/bootstrap.ts
|
|
890
|
+
const PUBLIC_POSTHOG_PROJECT_TOKEN = /^phc_[A-Za-z0-9_-]{1,191}$/u;
|
|
891
|
+
const PostHogIngestOrigin = Schema.String.pipe(Schema.refine((value) => {
|
|
892
|
+
try {
|
|
893
|
+
const url = new URL(value);
|
|
894
|
+
return url.protocol === "https:" && url.username.length === 0 && url.password.length === 0 && url.pathname === "/" && url.search.length === 0 && url.hash.length === 0 && (url.hostname === "posthog.com" || url.hostname.endsWith(".posthog.com"));
|
|
895
|
+
} catch {
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
}, { message: "must be a credential-free PostHog HTTPS ingest origin" }));
|
|
899
|
+
const EngineeringTelemetryBootstrapPolicy = Schema.Struct({
|
|
900
|
+
host: PostHogIngestOrigin,
|
|
901
|
+
projectToken: Schema.String.pipe(Schema.refine((value) => PUBLIC_POSTHOG_PROJECT_TOKEN.test(value), { message: "must be a public PostHog project token" })),
|
|
902
|
+
capxulEnv: Schema.Union([
|
|
903
|
+
Schema.Literal("development"),
|
|
904
|
+
Schema.Literal("e2e"),
|
|
905
|
+
Schema.Literal("staging"),
|
|
906
|
+
Schema.Literal("production")
|
|
907
|
+
])
|
|
908
|
+
});
|
|
890
909
|
/**
|
|
891
910
|
* `BootstrapEnvelope` v1.
|
|
892
911
|
*
|
|
@@ -912,7 +931,8 @@ const BootstrapEnvelope = Schema.Struct({
|
|
|
912
931
|
convexUrl: Schema.String,
|
|
913
932
|
siteBaseUrl: Schema.String,
|
|
914
933
|
openfortPublishableKey: Schema.String,
|
|
915
|
-
shieldPublishableKey: Schema.String
|
|
934
|
+
shieldPublishableKey: Schema.String,
|
|
935
|
+
engineeringTelemetry: Schema.optional(EngineeringTelemetryBootstrapPolicy)
|
|
916
936
|
})
|
|
917
937
|
});
|
|
918
938
|
//#endregion
|
|
@@ -4040,7 +4060,7 @@ const privateTransition = (state, event) => {
|
|
|
4040
4060
|
orgId: event.orgId,
|
|
4041
4061
|
step: event.step,
|
|
4042
4062
|
failure: event.failure,
|
|
4043
|
-
retryable: isRetryable(event.failure)
|
|
4063
|
+
retryable: event.retryable ?? isRetryable(event.failure)
|
|
4044
4064
|
}) } : WRONG;
|
|
4045
4065
|
}
|
|
4046
4066
|
}
|
|
@@ -4343,6 +4363,44 @@ function isProvisioningTelemetryDebugEnabled() {
|
|
|
4343
4363
|
return globalThis.process?.env?.CAPXUL_DEBUG_TELEMETRY === "1";
|
|
4344
4364
|
}
|
|
4345
4365
|
//#endregion
|
|
4366
|
+
//#region ../../packages/sdk/src/internal/invocation-observation.ts
|
|
4367
|
+
const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
|
|
4368
|
+
const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
|
|
4369
|
+
/** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
|
|
4370
|
+
function attachInvocationObservation(target, source) {
|
|
4371
|
+
const snapshot = Object.freeze(source.context === void 0 ? { active: source.active } : {
|
|
4372
|
+
active: source.active,
|
|
4373
|
+
context: Object.freeze({ ...source.context })
|
|
4374
|
+
});
|
|
4375
|
+
Object.defineProperty(target, INVOCATION_OBSERVATION, {
|
|
4376
|
+
configurable: false,
|
|
4377
|
+
enumerable: false,
|
|
4378
|
+
value: snapshot,
|
|
4379
|
+
writable: false
|
|
4380
|
+
});
|
|
4381
|
+
return target;
|
|
4382
|
+
}
|
|
4383
|
+
/** @internal Read the snapshot without exposing its symbol or adding a wire field. */
|
|
4384
|
+
function readInvocationObservation(source) {
|
|
4385
|
+
if (typeof source !== "object" || source === null) return void 0;
|
|
4386
|
+
return source[INVOCATION_OBSERVATION];
|
|
4387
|
+
}
|
|
4388
|
+
/** @internal Carry a snapshot across an SDK adapter projection without resolving again. */
|
|
4389
|
+
function copyInvocationObservation(source, target) {
|
|
4390
|
+
const snapshot = readInvocationObservation(source);
|
|
4391
|
+
return snapshot === void 0 ? target : attachInvocationObservation(target, snapshot);
|
|
4392
|
+
}
|
|
4393
|
+
/** @internal Carry the public call-start delivery decision with its failure envelope. */
|
|
4394
|
+
function markFailureInvocationSnapshot(failure, snapshot) {
|
|
4395
|
+
Object.defineProperty(failure, FAILURE_INVOCATION_SNAPSHOT, {
|
|
4396
|
+
configurable: false,
|
|
4397
|
+
enumerable: false,
|
|
4398
|
+
value: Object.freeze(snapshot),
|
|
4399
|
+
writable: false
|
|
4400
|
+
});
|
|
4401
|
+
return failure;
|
|
4402
|
+
}
|
|
4403
|
+
//#endregion
|
|
4346
4404
|
//#region ../../packages/sdk/src/domain/machine/telemetry.ts
|
|
4347
4405
|
const definedEntries = (values) => Object.fromEntries(Object.entries(values).filter((entry) => entry[1] !== void 0));
|
|
4348
4406
|
const SAFE_ENGINEERING_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
@@ -4485,7 +4543,7 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
|
|
|
4485
4543
|
const makeFailure = (state, event, reason, details) => new ActorFailure(reason, spec.machine, spec.label(state), event._tag, details);
|
|
4486
4544
|
const nonApplied = (state, event, reason, outcome, env) => {
|
|
4487
4545
|
const slot = env.origin?.slot ?? spec.slot(event);
|
|
4488
|
-
return {
|
|
4546
|
+
return copyInvocationObservation(env.invocation, {
|
|
4489
4547
|
machine: spec.machine,
|
|
4490
4548
|
state: spec.label(state),
|
|
4491
4549
|
event: event._tag,
|
|
@@ -4495,9 +4553,9 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
|
|
|
4495
4553
|
duration_ms: duration(env.startedAt),
|
|
4496
4554
|
...withCarriage(env.invocation),
|
|
4497
4555
|
...outcome === "refused" ? { refusal_code: reason } : { error_code: reason }
|
|
4498
|
-
};
|
|
4556
|
+
});
|
|
4499
4557
|
};
|
|
4500
|
-
const applied = (from, to, event, slot, epoch, env) => ({
|
|
4558
|
+
const applied = (from, to, event, slot, epoch, env) => copyInvocationObservation(env.invocation, {
|
|
4501
4559
|
machine: spec.machine,
|
|
4502
4560
|
from: spec.label(from),
|
|
4503
4561
|
event: event._tag,
|
|
@@ -6146,7 +6204,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
6146
6204
|
}
|
|
6147
6205
|
//#endregion
|
|
6148
6206
|
//#region ../../packages/sdk/package.json
|
|
6149
|
-
var version = "1.2.
|
|
6207
|
+
var version = "1.2.3";
|
|
6150
6208
|
//#endregion
|
|
6151
6209
|
//#region ../../packages/observability/src/engineering.ts
|
|
6152
6210
|
const SAFE_TRACED_HEADER_NAMES = [
|
|
@@ -6187,7 +6245,7 @@ const validateEngineeringTelemetryConfig = (config) => {
|
|
|
6187
6245
|
} catch {
|
|
6188
6246
|
throw new TypeError("engineering telemetry host must be an absolute HTTPS URL");
|
|
6189
6247
|
}
|
|
6190
|
-
if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0 || url.pathname !== "/" || url.search.length > 0 || url.hash.length > 0) throw new TypeError("engineering telemetry host must be a credential-free HTTPS origin");
|
|
6248
|
+
if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0 || url.pathname !== "/" || url.search.length > 0 || url.hash.length > 0 || !(url.hostname === "posthog.com" || url.hostname.endsWith(".posthog.com"))) throw new TypeError("engineering telemetry host must be a credential-free HTTPS origin");
|
|
6191
6249
|
if (!ENGINEERING_CAPXUL_ENVS.has(config.capxulEnv)) throw new TypeError("engineering telemetry capxulEnv is not canonical");
|
|
6192
6250
|
if (!ENGINEERING_PRODUCERS.has(config.producer)) throw new TypeError("engineering telemetry producer is not canonical");
|
|
6193
6251
|
if (!SAFE_RESOURCE_VALUE.test(config.sdkVersion)) throw new TypeError("engineering telemetry sdkVersion must be a bounded safe value");
|
|
@@ -6297,10 +6355,12 @@ function resolveAuthClientUrl(authBaseUrl, path) {
|
|
|
6297
6355
|
//#endregion
|
|
6298
6356
|
//#region ../../packages/sdk/src/internal/observation-http.ts
|
|
6299
6357
|
/** Resolve one bounded pre-auth snapshot for an outbound SDK HTTP request. */
|
|
6300
|
-
function observationRequestHeaders(adapter) {
|
|
6358
|
+
function observationRequestHeaders(adapter, source) {
|
|
6301
6359
|
if (adapter === void 0) return {};
|
|
6302
6360
|
try {
|
|
6303
|
-
const
|
|
6361
|
+
const invocation = readInvocationObservation(source);
|
|
6362
|
+
if (invocation !== void 0 && !invocation.active) return {};
|
|
6363
|
+
const encoded = encodeObservationContextHeader(invocation === void 0 ? adapter.resolveContext?.() : invocation.context);
|
|
6304
6364
|
return encoded === void 0 ? {} : { [OBSERVATION_CONTEXT_HEADER]: encoded };
|
|
6305
6365
|
} catch {
|
|
6306
6366
|
return {};
|
|
@@ -6396,7 +6456,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
6396
6456
|
method: "POST",
|
|
6397
6457
|
headers: {
|
|
6398
6458
|
"Content-Type": "application/json",
|
|
6399
|
-
...observationRequestHeaders(this.observation)
|
|
6459
|
+
...observationRequestHeaders(this.observation, input)
|
|
6400
6460
|
},
|
|
6401
6461
|
body: JSON.stringify({
|
|
6402
6462
|
email: input.email,
|
|
@@ -6814,7 +6874,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
6814
6874
|
headers: {
|
|
6815
6875
|
"content-type": "application/json",
|
|
6816
6876
|
...this.origin ? { origin: this.origin } : {},
|
|
6817
|
-
...observationRequestHeaders(this.observation)
|
|
6877
|
+
...observationRequestHeaders(this.observation, input)
|
|
6818
6878
|
},
|
|
6819
6879
|
body: JSON.stringify({
|
|
6820
6880
|
email: input.email,
|
|
@@ -7082,20 +7142,28 @@ var HttpBootstrapAdapter = class {
|
|
|
7082
7142
|
if (res.ok) return Effect.tryPromise({
|
|
7083
7143
|
try: async () => {
|
|
7084
7144
|
const body = await res.json();
|
|
7085
|
-
const
|
|
7145
|
+
const state = typeof body === "object" && body !== null && "state" in body && typeof body.state === "object" && body.state !== null ? body.state : void 0;
|
|
7146
|
+
const rawEngineeringTelemetry = state?.engineeringTelemetry;
|
|
7147
|
+
const baseBody = state === void 0 || rawEngineeringTelemetry === void 0 ? body : {
|
|
7148
|
+
...body,
|
|
7149
|
+
state: Object.fromEntries(Object.entries(state).filter(([key]) => key !== "engineeringTelemetry"))
|
|
7150
|
+
};
|
|
7151
|
+
const decoded = SchemaParser.decodeUnknownResult(BootstrapEnvelope)(baseBody);
|
|
7086
7152
|
if (Result.isFailure(decoded)) throw Errors.invalidInput("bootstrapEnvelope", SchemaIssue.makeFormatterDefault()(decoded.failure));
|
|
7087
|
-
const { state } = decoded.success;
|
|
7153
|
+
const { state: decodedState } = decoded.success;
|
|
7154
|
+
const decodedEngineeringTelemetry = rawEngineeringTelemetry === void 0 ? void 0 : SchemaParser.decodeUnknownResult(EngineeringTelemetryBootstrapPolicy)(rawEngineeringTelemetry, { onExcessProperty: "error" });
|
|
7088
7155
|
return {
|
|
7089
|
-
applicationId:
|
|
7090
|
-
chainId:
|
|
7091
|
-
sessionToken:
|
|
7092
|
-
issuedAt:
|
|
7093
|
-
expiresIn:
|
|
7094
|
-
authBaseUrl: normalizeRuntimeUrl("authBaseUrl",
|
|
7095
|
-
convexUrl: normalizeRuntimeUrl("convexUrl",
|
|
7096
|
-
siteBaseUrl: normalizeRuntimeUrl("siteBaseUrl",
|
|
7097
|
-
openfortPublishableKey:
|
|
7098
|
-
shieldPublishableKey:
|
|
7156
|
+
applicationId: decodedState.applicationId,
|
|
7157
|
+
chainId: decodedState.chainId,
|
|
7158
|
+
sessionToken: decodedState.sessionToken,
|
|
7159
|
+
issuedAt: decodedState.issuedAt,
|
|
7160
|
+
expiresIn: decodedState.expiresIn,
|
|
7161
|
+
authBaseUrl: normalizeRuntimeUrl("authBaseUrl", decodedState.authBaseUrl),
|
|
7162
|
+
convexUrl: normalizeRuntimeUrl("convexUrl", decodedState.convexUrl),
|
|
7163
|
+
siteBaseUrl: normalizeRuntimeUrl("siteBaseUrl", decodedState.siteBaseUrl),
|
|
7164
|
+
openfortPublishableKey: decodedState.openfortPublishableKey,
|
|
7165
|
+
shieldPublishableKey: decodedState.shieldPublishableKey,
|
|
7166
|
+
...decodedEngineeringTelemetry !== void 0 && Result.isSuccess(decodedEngineeringTelemetry) ? { engineeringTelemetry: decodedEngineeringTelemetry.success } : {}
|
|
7099
7167
|
};
|
|
7100
7168
|
},
|
|
7101
7169
|
catch: (cause) => {
|
|
@@ -10095,41 +10163,6 @@ function convexCallErrorFromCapxul(operation, error) {
|
|
|
10095
10163
|
}
|
|
10096
10164
|
var ConvexCallPortTag = class extends Context.Service()("@capxul/sdk/ports/ConvexCallPort") {};
|
|
10097
10165
|
//#endregion
|
|
10098
|
-
//#region ../../packages/sdk/src/internal/invocation-observation.ts
|
|
10099
|
-
const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
|
|
10100
|
-
const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
|
|
10101
|
-
/** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
|
|
10102
|
-
function attachInvocationObservation(target, context) {
|
|
10103
|
-
const snapshot = Object.freeze(context === void 0 ? {} : { context: Object.freeze({ ...context }) });
|
|
10104
|
-
Object.defineProperty(target, INVOCATION_OBSERVATION, {
|
|
10105
|
-
configurable: false,
|
|
10106
|
-
enumerable: false,
|
|
10107
|
-
value: snapshot,
|
|
10108
|
-
writable: false
|
|
10109
|
-
});
|
|
10110
|
-
return target;
|
|
10111
|
-
}
|
|
10112
|
-
/** @internal Read the snapshot without exposing its symbol or adding a wire field. */
|
|
10113
|
-
function readInvocationObservation(source) {
|
|
10114
|
-
if (typeof source !== "object" || source === null) return void 0;
|
|
10115
|
-
return source[INVOCATION_OBSERVATION];
|
|
10116
|
-
}
|
|
10117
|
-
/** @internal Carry a snapshot across an SDK adapter projection without resolving again. */
|
|
10118
|
-
function copyInvocationObservation(source, target) {
|
|
10119
|
-
const snapshot = readInvocationObservation(source);
|
|
10120
|
-
return snapshot === void 0 ? target : attachInvocationObservation(target, snapshot.context);
|
|
10121
|
-
}
|
|
10122
|
-
/** @internal Mark a failure envelope as already resolved at the public invocation boundary. */
|
|
10123
|
-
function markFailureInvocationSnapshot(failure) {
|
|
10124
|
-
Object.defineProperty(failure, FAILURE_INVOCATION_SNAPSHOT, {
|
|
10125
|
-
configurable: false,
|
|
10126
|
-
enumerable: false,
|
|
10127
|
-
value: true,
|
|
10128
|
-
writable: false
|
|
10129
|
-
});
|
|
10130
|
-
return failure;
|
|
10131
|
-
}
|
|
10132
|
-
//#endregion
|
|
10133
10166
|
//#region ../../packages/sdk/src/adapters/convex-call/ConvexCallAdapter.ts
|
|
10134
10167
|
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
10135
10168
|
const OBSERVED_CONVEX_ACTIONS = new Set([
|
|
@@ -10610,7 +10643,6 @@ var ConvexSmartAccountAdapter = class {
|
|
|
10610
10643
|
return this.#convex.action(this.#fns.confirmDeployment, {
|
|
10611
10644
|
chainId: wireChainId(input.chainId),
|
|
10612
10645
|
safeAddress: input.safeAddress,
|
|
10613
|
-
...input.telemetryRunId === void 0 ? {} : { telemetryRunId: input.telemetryRunId },
|
|
10614
10646
|
evidence
|
|
10615
10647
|
}).pipe(Effect.mapError((error) => smartAccountErrorFromCapxul("confirmDeployment", error.publicError, error)), Effect.flatMap((row) => Effect.try({
|
|
10616
10648
|
try: () => brandProvisionedSmartAccount(input.authUserId, row),
|
|
@@ -10620,8 +10652,7 @@ var ConvexSmartAccountAdapter = class {
|
|
|
10620
10652
|
claim(input) {
|
|
10621
10653
|
return this.#convex.action(this.#fns.claim, copyInvocationObservation(input, {
|
|
10622
10654
|
chainId: wireChainId(input.chainId),
|
|
10623
|
-
signerAddress: input.signerAddress
|
|
10624
|
-
...input.telemetryRunId === void 0 ? {} : { telemetryRunId: input.telemetryRunId }
|
|
10655
|
+
signerAddress: input.signerAddress
|
|
10625
10656
|
})).pipe(Effect.mapError((error) => smartAccountErrorFromCapxul("claim", error.publicError, error)), Effect.flatMap((row) => Effect.try({
|
|
10626
10657
|
try: () => brandProvisionedSmartAccount(input.authUserId, row),
|
|
10627
10658
|
catch: (cause) => smartAccountErrorFromUnknown("claim", cause)
|
|
@@ -11208,7 +11239,6 @@ const TelemetryEnvelopeProps = {
|
|
|
11208
11239
|
"mcp",
|
|
11209
11240
|
"e2e"
|
|
11210
11241
|
]),
|
|
11211
|
-
capxul_e2e_run_id: OptionalString,
|
|
11212
11242
|
journey_id: OptionalString,
|
|
11213
11243
|
correlation_id: OptionalString,
|
|
11214
11244
|
sdk_version: OptionalString
|
|
@@ -11984,7 +12014,7 @@ var PostHogTelemetryAdapter = class {
|
|
|
11984
12014
|
this.#reset = deps.reset ?? (() => void 0);
|
|
11985
12015
|
}
|
|
11986
12016
|
emit(event) {
|
|
11987
|
-
return this.#run(() => this.#capture(event.name, redactTelemetryProps(event.name, cloneProps(event.props))), "emit", event.name);
|
|
12017
|
+
return this.#run(() => this.#capture(event.name, redactTelemetryProps(event.name, cloneProps(event.props)), event), "emit", event.name);
|
|
11988
12018
|
}
|
|
11989
12019
|
identify(input) {
|
|
11990
12020
|
return this.#run(() => this.#identify(cloneIdentifyInput(input)), "identify");
|
|
@@ -35061,6 +35091,17 @@ const orgLane = (setup, start, send, controls) => Effect.gen(function* () {
|
|
|
35061
35091
|
orgId = start.orgId;
|
|
35062
35092
|
lifecycle = opened.success;
|
|
35063
35093
|
}
|
|
35094
|
+
if (lifecycle.status === "failed") {
|
|
35095
|
+
const failure = failureOf(lifecycle.error);
|
|
35096
|
+
yield* send({
|
|
35097
|
+
_tag: "OrgFailed",
|
|
35098
|
+
orgId,
|
|
35099
|
+
step: lifecycle.at,
|
|
35100
|
+
failure,
|
|
35101
|
+
retryable: lifecycle.retryable
|
|
35102
|
+
});
|
|
35103
|
+
return yield* Effect.fail(failure);
|
|
35104
|
+
}
|
|
35064
35105
|
let step = orgStep(lifecycle);
|
|
35065
35106
|
if (step === "ready") {
|
|
35066
35107
|
yield* send({
|
|
@@ -35074,7 +35115,7 @@ const orgLane = (setup, start, send, controls) => Effect.gen(function* () {
|
|
|
35074
35115
|
orgId,
|
|
35075
35116
|
step
|
|
35076
35117
|
});
|
|
35077
|
-
|
|
35118
|
+
while (step !== "ready") {
|
|
35078
35119
|
const current = step;
|
|
35079
35120
|
const advanced = yield* Effect.result(runOrgStep(setup, orgId, current, controls));
|
|
35080
35121
|
if (Result.isFailure(advanced)) {
|
|
@@ -35087,6 +35128,17 @@ const orgLane = (setup, start, send, controls) => Effect.gen(function* () {
|
|
|
35087
35128
|
return yield* Effect.fail(advanced.failure);
|
|
35088
35129
|
}
|
|
35089
35130
|
lifecycle = advanced.success;
|
|
35131
|
+
if (lifecycle.status === "failed") {
|
|
35132
|
+
const failure = failureOf(lifecycle.error);
|
|
35133
|
+
yield* send({
|
|
35134
|
+
_tag: "OrgFailed",
|
|
35135
|
+
orgId,
|
|
35136
|
+
step: lifecycle.at,
|
|
35137
|
+
failure,
|
|
35138
|
+
retryable: lifecycle.retryable
|
|
35139
|
+
});
|
|
35140
|
+
return yield* Effect.fail(failure);
|
|
35141
|
+
}
|
|
35090
35142
|
step = orgStep(lifecycle);
|
|
35091
35143
|
yield* step === "ready" ? send({
|
|
35092
35144
|
_tag: "OrgReady",
|
|
@@ -35096,6 +35148,7 @@ const orgLane = (setup, start, send, controls) => Effect.gen(function* () {
|
|
|
35096
35148
|
orgId,
|
|
35097
35149
|
step
|
|
35098
35150
|
});
|
|
35151
|
+
if (step === current) yield* Effect.sleep("1 second");
|
|
35099
35152
|
}
|
|
35100
35153
|
});
|
|
35101
35154
|
const recoverIdentityFailure = (state, event, failure) => {
|
|
@@ -35178,7 +35231,7 @@ const identitySpec = (input, sessionStore = { current: null }) => {
|
|
|
35178
35231
|
case "RequestOtp": return {
|
|
35179
35232
|
slot: IDENTITY_SLOT.auth,
|
|
35180
35233
|
port: "auth-client",
|
|
35181
|
-
run: (send) => call("auth-client.send-otp", input.ports.authClient.sendOtp({ email: toEmail(event.email) })).pipe(Effect.andThen(call("clock.now", input.ports.clock.now)), Effect.flatMap((at) => send({
|
|
35234
|
+
run: (send, controls) => call("auth-client.send-otp", input.ports.authClient.sendOtp(copyInvocationObservation(controls, { email: toEmail(event.email) }))).pipe(Effect.andThen(call("clock.now", input.ports.clock.now)), Effect.flatMap((at) => send({
|
|
35182
35235
|
_tag: "OtpSent",
|
|
35183
35236
|
at
|
|
35184
35237
|
})), Effect.catch((failure) => send({
|
|
@@ -35189,10 +35242,10 @@ const identitySpec = (input, sessionStore = { current: null }) => {
|
|
|
35189
35242
|
case "VerifyOtp": return {
|
|
35190
35243
|
slot: IDENTITY_SLOT.auth,
|
|
35191
35244
|
port: "auth-client",
|
|
35192
|
-
run: (send) => call("auth-client.verify-otp", input.ports.authClient.verifyOtp({
|
|
35245
|
+
run: (send, controls) => call("auth-client.verify-otp", input.ports.authClient.verifyOtp(copyInvocationObservation(controls, {
|
|
35193
35246
|
email: toEmail(event.email),
|
|
35194
35247
|
otp: event.otp
|
|
35195
|
-
})).pipe(Effect.tap((session) => Effect.sync(() => {
|
|
35248
|
+
}))).pipe(Effect.tap((session) => Effect.sync(() => {
|
|
35196
35249
|
sessionStore.current = session;
|
|
35197
35250
|
})), Effect.flatMap((session) => sessionProfile(input, session).pipe(Effect.flatMap((loaded) => send({
|
|
35198
35251
|
_tag: "Verified",
|
|
@@ -35206,7 +35259,7 @@ const identitySpec = (input, sessionStore = { current: null }) => {
|
|
|
35206
35259
|
case "ReadSession": return {
|
|
35207
35260
|
slot: IDENTITY_SLOT.session,
|
|
35208
35261
|
port: "auth-client",
|
|
35209
|
-
run: (send) => call("auth-client.get-session", input.ports.authClient.getSession()).pipe(Effect.tap((session) => Effect.sync(() => {
|
|
35262
|
+
run: (send, controls) => call("auth-client.get-session", input.ports.authClient.getSession(copyInvocationObservation(controls, {}))).pipe(Effect.tap((session) => Effect.sync(() => {
|
|
35210
35263
|
sessionStore.current = session;
|
|
35211
35264
|
})), Effect.flatMap((session) => sessionProfile(input, session)), Effect.flatMap((loaded) => send({
|
|
35212
35265
|
_tag: "SessionRead",
|
|
@@ -35221,7 +35274,7 @@ const identitySpec = (input, sessionStore = { current: null }) => {
|
|
|
35221
35274
|
case "SignOut": return {
|
|
35222
35275
|
slot: IDENTITY_SLOT.auth,
|
|
35223
35276
|
port: "auth-client",
|
|
35224
|
-
run: (send) => call("auth-client.sign-out", input.ports.authClient.signOut()).pipe(Effect.andThen(send({ _tag: "SignedOut" })), Effect.catch((failure) => send({
|
|
35277
|
+
run: (send, controls) => call("auth-client.sign-out", input.ports.authClient.signOut(copyInvocationObservation(controls, {}))).pipe(Effect.andThen(send({ _tag: "SignedOut" })), Effect.catch((failure) => send({
|
|
35225
35278
|
_tag: "SignOutFailed",
|
|
35226
35279
|
failure
|
|
35227
35280
|
}).pipe(Effect.andThen(Effect.fail(failure)))), Effect.ensuring(Effect.sync(() => {
|
|
@@ -37707,6 +37760,90 @@ function detectAuthCacheAdapter() {
|
|
|
37707
37760
|
return new InMemoryAuthCacheAdapter();
|
|
37708
37761
|
}
|
|
37709
37762
|
//#endregion
|
|
37763
|
+
//#region ../../packages/sdk/src/observation.ts
|
|
37764
|
+
const SDK_VERSION$1 = version;
|
|
37765
|
+
/** @internal Reports a factory-level typed failure without changing its identity. */
|
|
37766
|
+
function observeFailedResult(result, adapter, operation) {
|
|
37767
|
+
if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterContext(adapter));
|
|
37768
|
+
return result;
|
|
37769
|
+
}
|
|
37770
|
+
function report(adapter, kind, operation, cause, invocationContext) {
|
|
37771
|
+
const operationName = normalizeOperation(operation);
|
|
37772
|
+
const kindName = normalizeErrorKind(errorKind(cause));
|
|
37773
|
+
const context = sanitizeObservationContext({
|
|
37774
|
+
...invocationContext,
|
|
37775
|
+
...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
37776
|
+
});
|
|
37777
|
+
const failure = markFailureInvocationSnapshot({
|
|
37778
|
+
exception: syntheticException(operationName, kindName),
|
|
37779
|
+
sdkVersion: SDK_VERSION$1,
|
|
37780
|
+
operation: operationName,
|
|
37781
|
+
errorKind: kindName,
|
|
37782
|
+
...context === void 0 ? {} : { context }
|
|
37783
|
+
}, {
|
|
37784
|
+
active: invocationContext !== void 0,
|
|
37785
|
+
...context === void 0 ? {} : { context }
|
|
37786
|
+
});
|
|
37787
|
+
try {
|
|
37788
|
+
ignoreDeliveryFailure(kind === "operation" ? adapter.captureOperationFailure(failure) : adapter.captureException(failure));
|
|
37789
|
+
} catch {}
|
|
37790
|
+
}
|
|
37791
|
+
function resolveAdapterContext(adapter) {
|
|
37792
|
+
try {
|
|
37793
|
+
return adapter.resolveContext?.();
|
|
37794
|
+
} catch {
|
|
37795
|
+
return;
|
|
37796
|
+
}
|
|
37797
|
+
}
|
|
37798
|
+
function ignoreDeliveryFailure(delivery) {
|
|
37799
|
+
if (!isPromiseLike(delivery)) return;
|
|
37800
|
+
try {
|
|
37801
|
+
Promise.resolve(delivery).catch(() => void 0);
|
|
37802
|
+
} catch {}
|
|
37803
|
+
}
|
|
37804
|
+
function errorKind(cause) {
|
|
37805
|
+
try {
|
|
37806
|
+
if (isCapxulError(cause)) return normalizeErrorKind(cause.code);
|
|
37807
|
+
if (cause instanceof Error) return normalizeErrorKind(cause.name);
|
|
37808
|
+
return "UnknownFailure";
|
|
37809
|
+
} catch {
|
|
37810
|
+
return "Error";
|
|
37811
|
+
}
|
|
37812
|
+
}
|
|
37813
|
+
function normalizeOperation(value) {
|
|
37814
|
+
return typeof value === "string" && /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,255}$/u.test(value) ? value : "unknown";
|
|
37815
|
+
}
|
|
37816
|
+
function normalizeErrorKind(value) {
|
|
37817
|
+
return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value) ? value : "Error";
|
|
37818
|
+
}
|
|
37819
|
+
function syntheticException(operation, kind) {
|
|
37820
|
+
const error = /* @__PURE__ */ new Error(EXCEPTION_MESSAGE);
|
|
37821
|
+
error.name = kind;
|
|
37822
|
+
error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)`;
|
|
37823
|
+
return error;
|
|
37824
|
+
}
|
|
37825
|
+
function isPromiseLike(value) {
|
|
37826
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
37827
|
+
}
|
|
37828
|
+
function isPlainObject(value) {
|
|
37829
|
+
if (typeof value !== "object" || value === null) return false;
|
|
37830
|
+
const prototype = Object.getPrototypeOf(value);
|
|
37831
|
+
return prototype === Object.prototype || prototype === null;
|
|
37832
|
+
}
|
|
37833
|
+
function isCapxulResult(value) {
|
|
37834
|
+
return isPlainObject(value) && typeof value.ok === "boolean";
|
|
37835
|
+
}
|
|
37836
|
+
function isFailedResult(value) {
|
|
37837
|
+
return isCapxulResult(value) && value.ok === false && "error" in value;
|
|
37838
|
+
}
|
|
37839
|
+
//#endregion
|
|
37840
|
+
//#region ../../packages/sdk/src/telemetry/from-posthog.ts
|
|
37841
|
+
const PRODUCT_INVOCATION = Symbol("capxul.product-telemetry-invocation");
|
|
37842
|
+
/** @internal Bind paired emit/identify/reset work to one call-start snapshot. */
|
|
37843
|
+
function bindProductTelemetryInvocation(telemetry, source) {
|
|
37844
|
+
return telemetry[PRODUCT_INVOCATION]?.(source) ?? telemetry;
|
|
37845
|
+
}
|
|
37846
|
+
//#endregion
|
|
37710
37847
|
//#region ../../packages/sdk/src/telemetry/identity-product.ts
|
|
37711
37848
|
const NONE = null;
|
|
37712
37849
|
const IDENTITY_EVENT_TAG_SET = new Set(IDENTITY_EVENT_TAGS);
|
|
@@ -37789,13 +37926,15 @@ const ignoreTransportFailure = (operation, operationName, eventName) => Effect.s
|
|
|
37789
37926
|
product_event: eventName
|
|
37790
37927
|
}), Effect.catchCause(() => Effect.void))));
|
|
37791
37928
|
function executeIdentityProductObservation(telemetry, record, state) {
|
|
37792
|
-
const
|
|
37793
|
-
if (
|
|
37794
|
-
|
|
37929
|
+
const mapped = mapIdentityProductObservation(record, state);
|
|
37930
|
+
if (mapped === null) return Effect.void;
|
|
37931
|
+
copyInvocationObservation(record, mapped);
|
|
37932
|
+
const invocationTelemetry = bindProductTelemetryInvocation(telemetry, mapped);
|
|
37933
|
+
const after = () => mapped.name === "auth_verified" && state.phase === "authenticated" ? invocationTelemetry.identify({
|
|
37795
37934
|
distinctId: state.session.authUserId,
|
|
37796
37935
|
traits: { email_domain: emailDomain(state.session.email) }
|
|
37797
|
-
}) :
|
|
37798
|
-
return ignoreTransportFailure(() =>
|
|
37936
|
+
}) : mapped.name === "auth_signed_out" ? invocationTelemetry.reset() : Effect.void;
|
|
37937
|
+
return ignoreTransportFailure(() => invocationTelemetry.emit(mapped), "emit", mapped.name).pipe(Effect.andThen(ignoreTransportFailure(after, mapped.name === "auth_signed_out" ? "reset" : "identify", mapped.name)));
|
|
37799
37938
|
}
|
|
37800
37939
|
//#endregion
|
|
37801
37940
|
//#region ../../packages/sdk/src/surface/create-capxul-client.ts
|
|
@@ -37822,14 +37961,14 @@ function assembleCapxulClient(input) {
|
|
|
37822
37961
|
runPromise: Effect.runPromise
|
|
37823
37962
|
};
|
|
37824
37963
|
const scope = effectRunner.runSync(Scope.make());
|
|
37825
|
-
const actor = effectRunner.runSync(Scope.provide(bootIdentityFlow({
|
|
37964
|
+
const actor = withHostObservation(effectRunner.runSync(Scope.provide(bootIdentityFlow({
|
|
37826
37965
|
ports: input.ports,
|
|
37827
37966
|
chainId: input.bootstrap.chainId,
|
|
37828
37967
|
requirement: input.requirement,
|
|
37829
37968
|
...input.signer === void 0 ? {} : { signer: input.signer },
|
|
37830
37969
|
...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup },
|
|
37831
37970
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs }
|
|
37832
|
-
}), scope));
|
|
37971
|
+
}), scope)), input.hostObservationSnapshot);
|
|
37833
37972
|
const unsubscribeProductTelemetry = actor.subscribeTransitions((record) => {
|
|
37834
37973
|
effectRunner.runPromise(executeIdentityProductObservation(input.ports.telemetry, record, actor.snapshot())).catch(() => {});
|
|
37835
37974
|
});
|
|
@@ -38011,79 +38150,34 @@ function assembleCapxulClient(input) {
|
|
|
38011
38150
|
}
|
|
38012
38151
|
};
|
|
38013
38152
|
}
|
|
38014
|
-
|
|
38015
|
-
|
|
38016
|
-
const
|
|
38017
|
-
|
|
38018
|
-
|
|
38019
|
-
|
|
38020
|
-
|
|
38021
|
-
|
|
38022
|
-
|
|
38023
|
-
|
|
38024
|
-
|
|
38025
|
-
|
|
38026
|
-
|
|
38027
|
-
...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
38028
|
-
});
|
|
38029
|
-
const failure = markFailureInvocationSnapshot({
|
|
38030
|
-
exception: syntheticException(operationName, kindName),
|
|
38031
|
-
sdkVersion: SDK_VERSION$1,
|
|
38032
|
-
operation: operationName,
|
|
38033
|
-
errorKind: kindName,
|
|
38034
|
-
...context === void 0 ? {} : { context }
|
|
38035
|
-
});
|
|
38036
|
-
try {
|
|
38037
|
-
ignoreDeliveryFailure(kind === "operation" ? adapter.captureOperationFailure(failure) : adapter.captureException(failure));
|
|
38038
|
-
} catch {}
|
|
38039
|
-
}
|
|
38040
|
-
function resolveAdapterContext(adapter) {
|
|
38041
|
-
try {
|
|
38042
|
-
return adapter.resolveContext?.();
|
|
38043
|
-
} catch {
|
|
38044
|
-
return;
|
|
38045
|
-
}
|
|
38046
|
-
}
|
|
38047
|
-
function ignoreDeliveryFailure(delivery) {
|
|
38048
|
-
if (!isPromiseLike(delivery)) return;
|
|
38049
|
-
try {
|
|
38050
|
-
Promise.resolve(delivery).catch(() => void 0);
|
|
38051
|
-
} catch {}
|
|
38052
|
-
}
|
|
38053
|
-
function errorKind(cause) {
|
|
38054
|
-
try {
|
|
38055
|
-
if (isCapxulError(cause)) return normalizeErrorKind(cause.code);
|
|
38056
|
-
if (cause instanceof Error) return normalizeErrorKind(cause.name);
|
|
38057
|
-
return "UnknownFailure";
|
|
38058
|
-
} catch {
|
|
38059
|
-
return "Error";
|
|
38060
|
-
}
|
|
38061
|
-
}
|
|
38062
|
-
function normalizeOperation(value) {
|
|
38063
|
-
return typeof value === "string" && /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,255}$/u.test(value) ? value : "unknown";
|
|
38064
|
-
}
|
|
38065
|
-
function normalizeErrorKind(value) {
|
|
38066
|
-
return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value) ? value : "Error";
|
|
38067
|
-
}
|
|
38068
|
-
function syntheticException(operation, kind) {
|
|
38069
|
-
const error = /* @__PURE__ */ new Error(EXCEPTION_MESSAGE);
|
|
38070
|
-
error.name = kind;
|
|
38071
|
-
error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)`;
|
|
38072
|
-
return error;
|
|
38073
|
-
}
|
|
38074
|
-
function isPromiseLike(value) {
|
|
38075
|
-
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
38076
|
-
}
|
|
38077
|
-
function isPlainObject(value) {
|
|
38078
|
-
if (typeof value !== "object" || value === null) return false;
|
|
38079
|
-
const prototype = Object.getPrototypeOf(value);
|
|
38080
|
-
return prototype === Object.prototype || prototype === null;
|
|
38153
|
+
function withHostObservation(actor, snapshot) {
|
|
38154
|
+
if (snapshot === void 0) return actor;
|
|
38155
|
+
const controls = (input) => {
|
|
38156
|
+
const captured = snapshot();
|
|
38157
|
+
const copied = { ...input };
|
|
38158
|
+
return captured === void 0 ? copied : attachInvocationObservation(copied, captured);
|
|
38159
|
+
};
|
|
38160
|
+
return {
|
|
38161
|
+
...actor,
|
|
38162
|
+
ask: (event, input) => actor.ask(event, controls(input)),
|
|
38163
|
+
tell: (event, input) => actor.tell(event, controls(input)),
|
|
38164
|
+
restoreAuthSession: (session, input) => actor.restoreAuthSession(session, controls(input))
|
|
38165
|
+
};
|
|
38081
38166
|
}
|
|
38082
|
-
|
|
38083
|
-
|
|
38167
|
+
//#endregion
|
|
38168
|
+
//#region ../../packages/sdk/src/host-observability.ts
|
|
38169
|
+
const HOST_INVOCATION = Symbol("capxul.host-observability-invocation");
|
|
38170
|
+
/** @internal Bind both projections to one call-start decision/context snapshot. */
|
|
38171
|
+
function bindHostObservabilityInvocation(observability) {
|
|
38172
|
+
return observability?.[HOST_INVOCATION]?.bind() ?? observability;
|
|
38084
38173
|
}
|
|
38085
|
-
|
|
38086
|
-
|
|
38174
|
+
/** @internal Read one call-start snapshot for actor/transition carriage. */
|
|
38175
|
+
function snapshotHostObservability(observability) {
|
|
38176
|
+
const snapshot = observability?.[HOST_INVOCATION]?.snapshot();
|
|
38177
|
+
return snapshot === void 0 ? void 0 : {
|
|
38178
|
+
active: snapshot.active,
|
|
38179
|
+
...snapshot.context === void 0 ? {} : { context: snapshot.context }
|
|
38180
|
+
};
|
|
38087
38181
|
}
|
|
38088
38182
|
const SDK_VERSION = version;
|
|
38089
38183
|
/**
|
|
@@ -38236,7 +38330,19 @@ function productionConvexCallLayer(input, refreshConvexAuthRef) {
|
|
|
38236
38330
|
function isRefreshableConvexCallPort(convexCall) {
|
|
38237
38331
|
return "refreshAuth" in convexCall && typeof convexCall.refreshAuth === "function";
|
|
38238
38332
|
}
|
|
38333
|
+
function resolveProductionObservability(input) {
|
|
38334
|
+
const observation = input.observability?.failures ?? input.observation;
|
|
38335
|
+
const telemetry = input.observability?.product ?? input.telemetry;
|
|
38336
|
+
const invocationObservability = input.invocationObservability;
|
|
38337
|
+
return {
|
|
38338
|
+
observation,
|
|
38339
|
+
telemetry,
|
|
38340
|
+
invocationObservation: invocationObservability?.failures ?? observation,
|
|
38341
|
+
invocationTelemetry: invocationObservability?.product ?? telemetry
|
|
38342
|
+
};
|
|
38343
|
+
}
|
|
38239
38344
|
async function createProductionAdapters(input) {
|
|
38345
|
+
const { observation, telemetry, invocationObservation, invocationTelemetry } = resolveProductionObservability(input);
|
|
38240
38346
|
const resolvedInput = resolveInput(input);
|
|
38241
38347
|
if (!resolvedInput.ok) return resolvedInput;
|
|
38242
38348
|
const scope = await Effect.runPromise(Scope.make());
|
|
@@ -38244,7 +38350,7 @@ async function createProductionAdapters(input) {
|
|
|
38244
38350
|
const bootstrapLayer = HttpBootstrapLayer({
|
|
38245
38351
|
bootstrapBaseUrl: resolvedInput.value.bootstrapBaseUrl,
|
|
38246
38352
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38247
|
-
...
|
|
38353
|
+
...invocationObservation === void 0 ? {} : { observation: invocationObservation }
|
|
38248
38354
|
});
|
|
38249
38355
|
try {
|
|
38250
38356
|
const bootstrapContext = await Effect.runPromise(Layer.buildWithScope(bootstrapLayer, scope));
|
|
@@ -38254,7 +38360,7 @@ async function createProductionAdapters(input) {
|
|
|
38254
38360
|
...resolvedInput.value.origin === void 0 ? {} : { origin: resolvedInput.value.origin }
|
|
38255
38361
|
}));
|
|
38256
38362
|
if (!bootstrapResult.ok) {
|
|
38257
|
-
await emitBootstrapTelemetry(
|
|
38363
|
+
await emitBootstrapTelemetry(invocationTelemetry, {
|
|
38258
38364
|
name: "bootstrap_failed",
|
|
38259
38365
|
props: {
|
|
38260
38366
|
...bootstrapTelemetryEnvelope(input, resolvedInput.value),
|
|
@@ -38271,7 +38377,7 @@ async function createProductionAdapters(input) {
|
|
|
38271
38377
|
}
|
|
38272
38378
|
const runtimeUrlsResult = resolveRuntimeUrls(bootstrapResult.value, resolvedInput.value.runtime, input.authBaseUrl);
|
|
38273
38379
|
if (!runtimeUrlsResult.ok) {
|
|
38274
|
-
await emitBootstrapTelemetry(
|
|
38380
|
+
await emitBootstrapTelemetry(invocationTelemetry, {
|
|
38275
38381
|
name: "bootstrap_failed",
|
|
38276
38382
|
props: {
|
|
38277
38383
|
...bootstrapTelemetryEnvelope(input, resolvedInput.value),
|
|
@@ -38283,7 +38389,7 @@ async function createProductionAdapters(input) {
|
|
|
38283
38389
|
return runtimeUrlsResult;
|
|
38284
38390
|
}
|
|
38285
38391
|
const runtimeUrls = runtimeUrlsResult;
|
|
38286
|
-
await emitBootstrapTelemetry(
|
|
38392
|
+
await emitBootstrapTelemetry(invocationTelemetry, {
|
|
38287
38393
|
name: "bootstrap_resolved",
|
|
38288
38394
|
props: {
|
|
38289
38395
|
...bootstrapTelemetryEnvelope(input, resolvedInput.value),
|
|
@@ -38308,19 +38414,15 @@ async function createProductionAdapters(input) {
|
|
|
38308
38414
|
runtimeUrls: runtimeUrls.value,
|
|
38309
38415
|
chainId: bootstrapResult.value.chainId,
|
|
38310
38416
|
applicationId: bootstrapResult.value.applicationId,
|
|
38311
|
-
...
|
|
38417
|
+
...observation === void 0 ? {} : { observation },
|
|
38312
38418
|
...input.authCache === void 0 ? {} : { authCache: input.authCache },
|
|
38313
|
-
...
|
|
38419
|
+
...telemetry === void 0 ? {} : { telemetry },
|
|
38314
38420
|
...injectedClient === void 0 ? {} : { convexClient: injectedClient },
|
|
38315
38421
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38316
38422
|
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
38317
38423
|
...input.resetSignerSession === void 0 ? {} : { resetSignerSession: input.resetSignerSession }
|
|
38318
38424
|
}));
|
|
38319
|
-
const applicationLayer =
|
|
38320
|
-
...input.engineeringTelemetry,
|
|
38321
|
-
producer: resolvedInput.value.runtime === "browser" ? "browser" : "server",
|
|
38322
|
-
sdkVersion: SDK_VERSION
|
|
38323
|
-
}));
|
|
38425
|
+
const applicationLayer = Layer.merge(portsLayer, optionalEngineeringTelemetryLayer(bootstrapResult.value.engineeringTelemetry, resolvedInput.value.runtime));
|
|
38324
38426
|
const context = await Effect.runPromise(Layer.buildWithScope(applicationLayer, scope));
|
|
38325
38427
|
return {
|
|
38326
38428
|
ok: true,
|
|
@@ -38339,6 +38441,20 @@ async function createProductionAdapters(input) {
|
|
|
38339
38441
|
};
|
|
38340
38442
|
}
|
|
38341
38443
|
}
|
|
38444
|
+
function optionalEngineeringTelemetryLayer(policy, runtime) {
|
|
38445
|
+
if (policy === void 0) return Layer.empty;
|
|
38446
|
+
try {
|
|
38447
|
+
return makeEngineeringTelemetryLayer({
|
|
38448
|
+
host: policy.host,
|
|
38449
|
+
headers: { authorization: `Bearer ${policy.projectToken}` },
|
|
38450
|
+
capxulEnv: policy.capxulEnv,
|
|
38451
|
+
producer: runtime === "browser" ? "browser" : "server",
|
|
38452
|
+
sdkVersion: SDK_VERSION
|
|
38453
|
+
});
|
|
38454
|
+
} catch {
|
|
38455
|
+
return Layer.empty;
|
|
38456
|
+
}
|
|
38457
|
+
}
|
|
38342
38458
|
function refreshConvexAuthOnSession(authClient, refresh) {
|
|
38343
38459
|
return {
|
|
38344
38460
|
...authClient,
|
|
@@ -38368,14 +38484,17 @@ function resetSignerSessionOnSignOut(authClient, resetRef) {
|
|
|
38368
38484
|
};
|
|
38369
38485
|
}
|
|
38370
38486
|
async function createCapxulClient(input) {
|
|
38487
|
+
const invocationObservability = bindHostObservabilityInvocation(input.observability);
|
|
38488
|
+
const observation = invocationObservability?.failures ?? input.observation;
|
|
38371
38489
|
const validation = validateCreateCapxulClientInput(input);
|
|
38372
|
-
if (!validation.ok) return observeFailedResult(validation,
|
|
38490
|
+
if (!validation.ok) return observeFailedResult(validation, observation, "createCapxulClient");
|
|
38373
38491
|
const resetSignerSession = { current: null };
|
|
38374
38492
|
const adapters = await createProductionAdapters({
|
|
38375
38493
|
...input,
|
|
38376
|
-
resetSignerSession
|
|
38494
|
+
resetSignerSession,
|
|
38495
|
+
...invocationObservability === void 0 ? {} : { invocationObservability }
|
|
38377
38496
|
});
|
|
38378
|
-
if (!adapters.ok) return observeFailedResult(adapters,
|
|
38497
|
+
if (!adapters.ok) return observeFailedResult(adapters, observation, "createCapxulClient");
|
|
38379
38498
|
try {
|
|
38380
38499
|
const runtime = input.runtime ?? detectRuntime();
|
|
38381
38500
|
const resolvedAuthBaseUrl = resolveBrowserAuthBaseUrl({
|
|
@@ -38412,6 +38531,7 @@ async function createCapxulClient(input) {
|
|
|
38412
38531
|
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
38413
38532
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
|
|
38414
38533
|
invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
|
|
38534
|
+
...input.observability === void 0 ? {} : { hostObservationSnapshot: () => snapshotHostObservability(input.observability) },
|
|
38415
38535
|
effectRunner: {
|
|
38416
38536
|
runSync: Effect.runSyncWith(adapters.value.context),
|
|
38417
38537
|
runPromise: Effect.runPromiseWith(adapters.value.context)
|
|
@@ -38440,7 +38560,7 @@ async function createCapxulClient(input) {
|
|
|
38440
38560
|
return observeFailedResult({
|
|
38441
38561
|
ok: false,
|
|
38442
38562
|
error: toPublicError$1(cause, "createCapxulClient")
|
|
38443
|
-
},
|
|
38563
|
+
}, observation, "createCapxulClient");
|
|
38444
38564
|
}
|
|
38445
38565
|
}
|
|
38446
38566
|
function validateCreateCapxulClientInput(input) {
|
|
@@ -40751,8 +40871,7 @@ var LiveOrgDeploymentAdapter = class {
|
|
|
40751
40871
|
return this.#convex.action(orgInviteMemberAction, {
|
|
40752
40872
|
orgId: input.orgId,
|
|
40753
40873
|
email: input.input.email,
|
|
40754
|
-
role: input.input.role
|
|
40755
|
-
...process.env.CAPXUL_E2E_RUN_ID === void 0 ? {} : { telemetryRunId: process.env.CAPXUL_E2E_RUN_ID }
|
|
40874
|
+
role: input.input.role
|
|
40756
40875
|
}).pipe(Effect.mapError((error) => orgErrorFromCapxul("inviteMember", error.publicError, error)), Effect.map(brandOrgMember));
|
|
40757
40876
|
}
|
|
40758
40877
|
resendInviteToken(input) {
|
|
@@ -40762,7 +40881,7 @@ var LiveOrgDeploymentAdapter = class {
|
|
|
40762
40881
|
}).pipe(Effect.mapError((error) => orgErrorFromCapxul("resendInviteToken", error.publicError, error)), Effect.map(brandOrgMember));
|
|
40763
40882
|
}
|
|
40764
40883
|
detectAndAcceptPendingInvitations(_input) {
|
|
40765
|
-
return this.#convex.action(orgDetectAndAcceptPendingInvitationsAction,
|
|
40884
|
+
return this.#convex.action(orgDetectAndAcceptPendingInvitationsAction, {}).pipe(Effect.mapError((error) => orgErrorFromCapxul("detectAndAcceptPendingInvitations", error.publicError, error)), Effect.map((result) => ({ matched: result.matched.map(toOrgId) })));
|
|
40766
40885
|
}
|
|
40767
40886
|
deployRoles(input) {
|
|
40768
40887
|
return this.#convex.query(orgLoadByOrgIdQuery, { orgId: input.orgId }).pipe(Effect.mapError((error) => orgErrorFromCapxul("deployRoles", error.publicError, error)), Effect.flatMap((wire) => this.#convex.query(orgListRolesByOrgIdQuery, { orgId: input.orgId }).pipe(Effect.mapError((error) => orgErrorFromCapxul("deployRoles", error.publicError, error)), Effect.map((roles) => ({
|
|
@@ -40775,8 +40894,7 @@ var LiveOrgDeploymentAdapter = class {
|
|
|
40775
40894
|
orgId: input.orgId,
|
|
40776
40895
|
rolesModuleAddress: deployment.rolesModuleAddress,
|
|
40777
40896
|
allowanceModuleAddress: deployment.rolesModuleAddress,
|
|
40778
|
-
txHash: deployment.txHash
|
|
40779
|
-
...process.env.CAPXUL_E2E_RUN_ID === void 0 ? {} : { telemetryRunId: process.env.CAPXUL_E2E_RUN_ID }
|
|
40897
|
+
txHash: deployment.txHash
|
|
40780
40898
|
}).pipe(Effect.mapError((error) => orgErrorFromCapxul("deployRoles", error.publicError, error)))), Effect.flatMap(() => this.listRoles({ orgId: input.orgId })), Effect.map((roles) => ({
|
|
40781
40899
|
orgId: input.orgId,
|
|
40782
40900
|
roles
|
|
@@ -40793,8 +40911,7 @@ var LiveOrgDeploymentAdapter = class {
|
|
|
40793
40911
|
orgId: input.orgId,
|
|
40794
40912
|
memberSafeAddress: input.input.memberSafeAddress,
|
|
40795
40913
|
role: input.input.role,
|
|
40796
|
-
txHash
|
|
40797
|
-
...process.env.CAPXUL_E2E_RUN_ID === void 0 ? {} : { telemetryRunId: process.env.CAPXUL_E2E_RUN_ID }
|
|
40914
|
+
txHash
|
|
40798
40915
|
})), Effect.mapError((error) => orgErrorFromCapxul("grantRole", error.publicError, error)), Effect.map(brandOrgMember));
|
|
40799
40916
|
}
|
|
40800
40917
|
revokeRole(input) {
|
|
@@ -40811,8 +40928,7 @@ var LiveOrgDeploymentAdapter = class {
|
|
|
40811
40928
|
})), Effect.flatMap((txHash) => this.#convex.action(orgRemoveMemberAction, {
|
|
40812
40929
|
orgId: input.orgId,
|
|
40813
40930
|
memberSafeAddress: input.input.memberSafeAddress,
|
|
40814
|
-
txHash
|
|
40815
|
-
...process.env.CAPXUL_E2E_RUN_ID === void 0 ? {} : { telemetryRunId: process.env.CAPXUL_E2E_RUN_ID }
|
|
40931
|
+
txHash
|
|
40816
40932
|
}).pipe(Effect.mapError((error) => orgErrorFromCapxul("revokeRole", error.publicError, error)))), Effect.asVoid);
|
|
40817
40933
|
}
|
|
40818
40934
|
readSpendAuthority(input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
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": [
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"typescript": "5.9.2",
|
|
49
49
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
|
|
50
50
|
"vite-plus": "0.1.23",
|
|
51
|
-
"@capxul/backend": "0.1.
|
|
51
|
+
"@capxul/backend": "0.1.5",
|
|
52
52
|
"@capxul/config": "0.1.0",
|
|
53
|
-
"@capxul/sdk": "1.2.
|
|
53
|
+
"@capxul/sdk": "1.2.3",
|
|
54
54
|
"@capxul/types": "0.1.0",
|
|
55
55
|
"@capxul/wire": "0.1.0"
|
|
56
56
|
},
|