@capxul/mcp 1.1.0 → 1.2.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 +200 -40
  2. 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.1.0";
245
+ var version$2 = "1.2.1";
246
246
  //#endregion
247
247
  //#region src/tool-result.ts
248
248
  function okResult(structured) {
@@ -3847,6 +3847,41 @@ const label = (state) => {
3847
3847
  const org = state.account.org;
3848
3848
  return org === null ? "authenticated:claimed" : `authenticated:claimed:${org.at}`;
3849
3849
  };
3850
+ const EVENT_TAGS = [
3851
+ "RequestOtp",
3852
+ "VerifyOtp",
3853
+ "ReadSession",
3854
+ "SignOut",
3855
+ "RestoreSession",
3856
+ "ResumeOtpEntry",
3857
+ "Reset",
3858
+ "EnsureAccount",
3859
+ "ClaimAccount",
3860
+ "RetryAccount",
3861
+ "CreateOrganization",
3862
+ "AttachOrganization",
3863
+ "RetryOrganization",
3864
+ "LeaveOrganization"
3865
+ ];
3866
+ const PRIVATE_EVENT_TAGS = [
3867
+ "OtpSent",
3868
+ "OtpFailed",
3869
+ "Verified",
3870
+ "VerifyFailed",
3871
+ "SessionRead",
3872
+ "SessionReadFailed",
3873
+ "SignedOut",
3874
+ "SignOutFailed",
3875
+ "AccountAt",
3876
+ "AccountDerived",
3877
+ "AccountClaiming",
3878
+ "AccountClaimed",
3879
+ "AccountFailed",
3880
+ "OrgAt",
3881
+ "OrgReady",
3882
+ "OrgFailed"
3883
+ ];
3884
+ const IDENTITY_EVENT_TAGS = [...EVENT_TAGS, ...PRIVATE_EVENT_TAGS];
3850
3885
  /** Valid in every `authenticated:*` position — the pre-S1 auth machine's row. */
3851
3886
  const SESSION_EVENTS = [
3852
3887
  "ReadSession",
@@ -4103,24 +4138,7 @@ const transition = (state, event, config = DEFAULT_CONFIG) => {
4103
4138
  }
4104
4139
  }
4105
4140
  };
4106
- const PRIVATE_TAGS = new Set([
4107
- "OtpSent",
4108
- "OtpFailed",
4109
- "Verified",
4110
- "VerifyFailed",
4111
- "SessionRead",
4112
- "SessionReadFailed",
4113
- "SignedOut",
4114
- "SignOutFailed",
4115
- "AccountAt",
4116
- "AccountDerived",
4117
- "AccountClaiming",
4118
- "AccountClaimed",
4119
- "AccountFailed",
4120
- "OrgAt",
4121
- "OrgReady",
4122
- "OrgFailed"
4123
- ]);
4141
+ const PRIVATE_TAGS = new Set(PRIVATE_EVENT_TAGS);
4124
4142
  const isPrivate = (event) => PRIVATE_TAGS.has(event._tag);
4125
4143
  //#endregion
4126
4144
  //#region ../../packages/sdk/src/telemetry/stack-frame-parser.ts
@@ -6128,7 +6146,7 @@ async function recoverRawDigestSigner(input) {
6128
6146
  }
6129
6147
  //#endregion
6130
6148
  //#region ../../packages/sdk/package.json
6131
- var version = "1.1.0";
6149
+ var version = "1.2.1";
6132
6150
  //#endregion
6133
6151
  //#region ../../packages/observability/src/engineering.ts
6134
6152
  const SAFE_TRACED_HEADER_NAMES = [
@@ -11369,6 +11387,28 @@ const OrganizationCreationFailedProps = Schema.Struct({
11369
11387
  error_code: Schema.String,
11370
11388
  retryable: Schema.Boolean
11371
11389
  });
11390
+ const OnboardingIntentSchema = Schema.Literals(["personal", "organization"]);
11391
+ const OnboardingIntentSelectedProps = Schema.Struct({
11392
+ ...TelemetryEnvelopeProps,
11393
+ journey_id: Schema.String,
11394
+ intent: OnboardingIntentSchema,
11395
+ entry_point: Schema.String
11396
+ });
11397
+ const OnboardingProfileSubmittedProps = Schema.Struct({
11398
+ ...TelemetryEnvelopeProps,
11399
+ journey_id: Schema.String,
11400
+ intent: OnboardingIntentSchema
11401
+ });
11402
+ const OnboardingOrganizationSubmittedProps = Schema.Struct({
11403
+ ...TelemetryEnvelopeProps,
11404
+ journey_id: Schema.String
11405
+ });
11406
+ const OnboardingDashboardReachedProps = Schema.Struct({
11407
+ ...TelemetryEnvelopeProps,
11408
+ journey_id: Schema.String,
11409
+ intent: OnboardingIntentSchema,
11410
+ organization_id: Schema.optional(OrgIdTelemetrySchema)
11411
+ });
11372
11412
  const OrgCreateStartedProps = Schema.Struct({
11373
11413
  ...TelemetryEnvelopeProps,
11374
11414
  org_id: OptionalOrgId,
@@ -11514,6 +11554,22 @@ Schema.Struct({
11514
11554
  name: Schema.Literal("auth_signed_out"),
11515
11555
  props: AuthSignedOutProps
11516
11556
  });
11557
+ Schema.Struct({
11558
+ name: Schema.Literal("onboarding_intent_selected"),
11559
+ props: OnboardingIntentSelectedProps
11560
+ });
11561
+ Schema.Struct({
11562
+ name: Schema.Literal("onboarding_profile_submitted"),
11563
+ props: OnboardingProfileSubmittedProps
11564
+ });
11565
+ Schema.Struct({
11566
+ name: Schema.Literal("onboarding_organization_submitted"),
11567
+ props: OnboardingOrganizationSubmittedProps
11568
+ });
11569
+ Schema.Struct({
11570
+ name: Schema.Literal("onboarding_dashboard_reached"),
11571
+ props: OnboardingDashboardReachedProps
11572
+ });
11517
11573
  Schema.Struct({
11518
11574
  name: Schema.Literal("provisioning_safe_created"),
11519
11575
  props: ProvisioningSafeCreatedProps
@@ -11928,29 +11984,36 @@ var PostHogTelemetryAdapter = class {
11928
11984
  this.#reset = deps.reset ?? (() => void 0);
11929
11985
  }
11930
11986
  emit(event) {
11931
- return Effect.sync(() => {
11932
- this.#runFireAndForget(() => this.#capture(event.name, redactTelemetryProps(event.name, cloneProps(event.props))));
11933
- });
11987
+ return this.#run(() => this.#capture(event.name, redactTelemetryProps(event.name, cloneProps(event.props))), "emit", event.name);
11934
11988
  }
11935
11989
  identify(input) {
11936
- return Effect.sync(() => {
11937
- this.#runFireAndForget(() => this.#identify(cloneIdentifyInput(input)));
11938
- });
11990
+ return this.#run(() => this.#identify(cloneIdentifyInput(input)), "identify");
11939
11991
  }
11940
11992
  group(input) {
11941
- return Effect.sync(() => {
11942
- this.#runFireAndForget(() => this.#group(cloneGroupInput(input)));
11943
- });
11993
+ return this.#run(() => this.#group(cloneGroupInput(input)), "group");
11944
11994
  }
11945
11995
  reset() {
11946
- return Effect.sync(() => {
11947
- this.#runFireAndForget(() => this.#reset());
11948
- });
11996
+ return this.#run(() => this.#reset(), "reset");
11949
11997
  }
11950
- #runFireAndForget(operation) {
11951
- try {
11952
- Promise.resolve(operation()).catch(() => {});
11953
- } catch {}
11998
+ #run(operation, operationName, eventName) {
11999
+ const diagnose = Effect.logWarning("product.telemetry.transport.dropped").pipe(Effect.annotateLogs({
12000
+ operation: operationName,
12001
+ ...eventName === void 0 ? {} : { product_event: eventName }
12002
+ }), Effect.catchCause(() => Effect.void));
12003
+ return Effect.suspend(() => {
12004
+ let pending;
12005
+ try {
12006
+ pending = operation();
12007
+ } catch {
12008
+ return diagnose;
12009
+ }
12010
+ if (pending === void 0) return Effect.void;
12011
+ const transport = Effect.tryPromise({
12012
+ try: () => pending,
12013
+ catch: () => void 0
12014
+ }).pipe(Effect.catch(() => diagnose));
12015
+ return Effect.forkDetach(transport, { startImmediately: true }).pipe(Effect.asVoid);
12016
+ });
11954
12017
  }
11955
12018
  };
11956
12019
  function PostHogTelemetryLayer(deps) {
@@ -36557,7 +36620,7 @@ const payrollContract = {
36557
36620
  //#endregion
36558
36621
  //#region ../../packages/sdk/src/surface/_shared/org-telemetry.ts
36559
36622
  /** Extract the domain from an email for telemetry (never the local part / PII). */
36560
- function emailDomain(email) {
36623
+ function emailDomain$1(email) {
36561
36624
  const at = email.lastIndexOf("@");
36562
36625
  if (at < 0 || at === email.length - 1) return void 0;
36563
36626
  return email.slice(at + 1).toLowerCase();
@@ -36568,7 +36631,7 @@ async function emitOrgTelemetry(telemetry, event) {
36568
36631
  await Effect.runPromise(telemetry.emit(event).pipe(Effect.catch((cause) => Effect.sync(() => reportOrgTelemetryFailure("error", event.name, cause))), Effect.catchDefect((cause) => Effect.sync(() => reportOrgTelemetryFailure("defect", event.name, cause)))));
36569
36632
  }
36570
36633
  function emitOrgCreateStarted(telemetry, input) {
36571
- const domain = input.email === void 0 ? void 0 : emailDomain(input.email);
36634
+ const domain = input.email === void 0 ? void 0 : emailDomain$1(input.email);
36572
36635
  return emitOrgTelemetry(telemetry, {
36573
36636
  name: "org_create_started",
36574
36637
  props: {
@@ -36627,7 +36690,7 @@ function emitOrgCreateFailed(telemetry, reason) {
36627
36690
  });
36628
36691
  }
36629
36692
  function emitOrgInviteSent(telemetry, input) {
36630
- const domain = emailDomain(input.email);
36693
+ const domain = emailDomain$1(input.email);
36631
36694
  return emitOrgTelemetry(telemetry, {
36632
36695
  name: "org_invite_sent",
36633
36696
  props: {
@@ -37644,6 +37707,97 @@ function detectAuthCacheAdapter() {
37644
37707
  return new InMemoryAuthCacheAdapter();
37645
37708
  }
37646
37709
  //#endregion
37710
+ //#region ../../packages/sdk/src/telemetry/identity-product.ts
37711
+ const NONE = null;
37712
+ const IDENTITY_EVENT_TAG_SET = new Set(IDENTITY_EVENT_TAGS);
37713
+ const APPLIED_ACTION_BY_EVENT = {
37714
+ RequestOtp: "none",
37715
+ VerifyOtp: "none",
37716
+ ReadSession: "none",
37717
+ SignOut: "none",
37718
+ RestoreSession: "none",
37719
+ ResumeOtpEntry: "none",
37720
+ Reset: "none",
37721
+ EnsureAccount: "none",
37722
+ ClaimAccount: "none",
37723
+ RetryAccount: "none",
37724
+ CreateOrganization: "none",
37725
+ AttachOrganization: "none",
37726
+ RetryOrganization: "none",
37727
+ LeaveOrganization: "none",
37728
+ OtpSent: "otp-requested",
37729
+ OtpFailed: "failed",
37730
+ Verified: "verified",
37731
+ VerifyFailed: "failed",
37732
+ SessionRead: "none",
37733
+ SessionReadFailed: "none",
37734
+ SignedOut: "signed-out",
37735
+ SignOutFailed: "failed",
37736
+ AccountAt: "none",
37737
+ AccountDerived: "none",
37738
+ AccountClaiming: "none",
37739
+ AccountClaimed: "none",
37740
+ AccountFailed: "none",
37741
+ OrgAt: "none",
37742
+ OrgReady: "none",
37743
+ OrgFailed: "none"
37744
+ };
37745
+ const linkage = (record) => ({
37746
+ ...record.correlation_id === void 0 ? {} : { correlation_id: record.correlation_id },
37747
+ ...record.journey_id === void 0 ? {} : { journey_id: record.journey_id }
37748
+ });
37749
+ const emailDomain = (email) => email.split("@")[1]?.toLowerCase() ?? "unknown";
37750
+ const authFailure = (record, reason) => ({
37751
+ name: "auth_failed",
37752
+ props: {
37753
+ auth_type: "otp",
37754
+ reason,
37755
+ ...linkage(record)
37756
+ }
37757
+ });
37758
+ function mapIdentityProductObservation(record, state) {
37759
+ if (record.machine !== "identity" || !IDENTITY_EVENT_TAG_SET.has(record.event)) return NONE;
37760
+ if (record.outcome === "cancelled") return NONE;
37761
+ if (record.slot === "identity:auth" && record.outcome === "refused") return authFailure(record, record.refusal_code);
37762
+ if (record.slot === "identity:auth" && record.outcome === "failed") return authFailure(record, record.error_code);
37763
+ if (record.outcome !== "applied") return NONE;
37764
+ switch (APPLIED_ACTION_BY_EVENT[record.event]) {
37765
+ case "none": return NONE;
37766
+ case "failed": return state.phase !== "faulted" || state.failure.code === "CANCELLED" ? NONE : authFailure(record, state.failure.code);
37767
+ case "otp-requested": return state.phase !== "otp_pending" ? NONE : {
37768
+ name: "auth_otp_requested",
37769
+ props: {
37770
+ email_domain: emailDomain(state.email),
37771
+ ...linkage(record)
37772
+ }
37773
+ };
37774
+ case "verified": return state.phase !== "authenticated" ? NONE : {
37775
+ name: "auth_verified",
37776
+ props: {
37777
+ auth_type: "otp",
37778
+ ...linkage(record)
37779
+ }
37780
+ };
37781
+ case "signed-out": return state.phase !== "signed_out" ? NONE : {
37782
+ name: "auth_signed_out",
37783
+ props: linkage(record)
37784
+ };
37785
+ }
37786
+ }
37787
+ const ignoreTransportFailure = (operation, operationName, eventName) => Effect.suspend(operation).pipe(Effect.catchCause(() => Effect.logWarning("identity.product.telemetry.dropped").pipe(Effect.annotateLogs({
37788
+ operation: operationName,
37789
+ product_event: eventName
37790
+ }), Effect.catchCause(() => Effect.void))));
37791
+ function executeIdentityProductObservation(telemetry, record, state) {
37792
+ const observation = mapIdentityProductObservation(record, state);
37793
+ if (observation === null) return Effect.void;
37794
+ const after = () => observation.name === "auth_verified" && state.phase === "authenticated" ? telemetry.identify({
37795
+ distinctId: state.session.authUserId,
37796
+ traits: { email_domain: emailDomain(state.session.email) }
37797
+ }) : observation.name === "auth_signed_out" ? telemetry.reset() : Effect.void;
37798
+ return ignoreTransportFailure(() => telemetry.emit(observation), "emit", observation.name).pipe(Effect.andThen(ignoreTransportFailure(after, observation.name === "auth_signed_out" ? "reset" : "identify", observation.name)));
37799
+ }
37800
+ //#endregion
37647
37801
  //#region ../../packages/sdk/src/surface/create-capxul-client.ts
37648
37802
  /** Join the assembled actor lifetime to the adapter lifetime for internal client factories. */
37649
37803
  function withAdapterClose(client, closeAdapter) {
@@ -37676,9 +37830,15 @@ function assembleCapxulClient(input) {
37676
37830
  ...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup },
37677
37831
  ...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs }
37678
37832
  }), scope));
37833
+ const unsubscribeProductTelemetry = actor.subscribeTransitions((record) => {
37834
+ effectRunner.runPromise(executeIdentityProductObservation(input.ports.telemetry, record, actor.snapshot())).catch(() => {});
37835
+ });
37679
37836
  let stopPromise = null;
37680
37837
  const stopActor = () => {
37681
- stopPromise ??= effectRunner.runPromise(Scope.close(scope, Exit.void));
37838
+ if (stopPromise === null) {
37839
+ unsubscribeProductTelemetry();
37840
+ stopPromise = effectRunner.runPromise(Scope.close(scope, Exit.void));
37841
+ }
37682
37842
  return stopPromise;
37683
37843
  };
37684
37844
  if (input.signal !== void 0) input.signal.addEventListener("abort", () => void stopActor(), { once: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
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.1",
51
+ "@capxul/backend": "0.1.3",
52
52
  "@capxul/config": "0.1.0",
53
- "@capxul/sdk": "1.1.0",
53
+ "@capxul/sdk": "1.2.1",
54
54
  "@capxul/types": "0.1.0",
55
55
  "@capxul/wire": "0.1.0"
56
56
  },