@capxul/mcp 4.2.0-rc.3 → 4.2.0-rc.5
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/capxul-source.json +3 -3
- package/dist/main.mjs +380 -22
- package/package.json +3 -3
package/dist/capxul-source.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": {
|
|
3
|
-
"commit": "
|
|
4
|
-
"tree": "
|
|
3
|
+
"commit": "72be9c2d5c9b2dcdd27fa5c5acb22163ddec5c44",
|
|
4
|
+
"tree": "1529290d3427ecf12fece6ff70fbea35b077b6a9",
|
|
5
5
|
"branch": "codex/programme-rc",
|
|
6
6
|
"repository": "https://github.com/Xelmar-tech/infrastructure",
|
|
7
7
|
"lockfileSha256": "5870f53b72706d103220c1bcf733cb4fb71196aea32a9cfbdc277d73cc959264"
|
|
8
8
|
},
|
|
9
9
|
"name": "@capxul/mcp",
|
|
10
|
-
"version": "4.2.0-rc.
|
|
10
|
+
"version": "4.2.0-rc.5"
|
|
11
11
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -3738,6 +3738,12 @@ const USDX_BASE_SEPOLIA_TOKEN = {
|
|
|
3738
3738
|
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
3739
3739
|
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
3740
3740
|
10n ** BigInt(6);
|
|
3741
|
+
/**
|
|
3742
|
+
* The bootstrap manage role. It administers people and roles, cannot spend,
|
|
3743
|
+
* and is not a signer of the Organization Safe; "Owner" implied the latter,
|
|
3744
|
+
* so the label is Admin (ruled 2026-09-06).
|
|
3745
|
+
*/
|
|
3746
|
+
const ADMIN_ROLE_LABEL = "Admin";
|
|
3741
3747
|
function normalizeOrgRoleLabel(label) {
|
|
3742
3748
|
const normalized = label.trim().replace(/\s+/g, " ");
|
|
3743
3749
|
if (normalized.length === 0) throw Errors.invalidInput("role.label", "must be a non-empty role label");
|
|
@@ -7658,10 +7664,24 @@ const DepositSettledProps = Schema.Struct({
|
|
|
7658
7664
|
});
|
|
7659
7665
|
const PermissionMirrorVerificationProps = Schema.Struct({
|
|
7660
7666
|
...TelemetryEnvelopeProps,
|
|
7667
|
+
/** The RECEIPT verification outcome. What the mirror then did is separate. */
|
|
7661
7668
|
outcome: Schema.String,
|
|
7662
7669
|
reason: Schema.String,
|
|
7663
7670
|
chain_id: Schema.Number,
|
|
7664
|
-
retry_count: Schema.Number
|
|
7671
|
+
retry_count: Schema.Number,
|
|
7672
|
+
/**
|
|
7673
|
+
* #1960 R02, consumed by R03. A verified receipt is not an applied Permission:
|
|
7674
|
+
* these two optional fields let the producer say what the applying mutation
|
|
7675
|
+
* actually returned, and which command it was, without either fact rewriting
|
|
7676
|
+
* the receipt outcome above. Absent when application has not happened yet.
|
|
7677
|
+
*/
|
|
7678
|
+
application_result: Schema.optional(Schema.Literals([
|
|
7679
|
+
"applied",
|
|
7680
|
+
"replayed",
|
|
7681
|
+
"conflicting_replay",
|
|
7682
|
+
"revision_mismatch"
|
|
7683
|
+
])),
|
|
7684
|
+
command_id: OptionalString
|
|
7665
7685
|
});
|
|
7666
7686
|
const MovementScanWindowProps = Schema.Struct({
|
|
7667
7687
|
...TelemetryEnvelopeProps,
|
|
@@ -7887,6 +7907,10 @@ Schema.Struct({
|
|
|
7887
7907
|
name: Schema.Literal("movement_scan_incident"),
|
|
7888
7908
|
props: MovementScanIncidentProps
|
|
7889
7909
|
});
|
|
7910
|
+
/** The one spelling of "whose scope did this happen in" across every surface. */
|
|
7911
|
+
const ScopeKindSchema = Schema.Literals(["account", "organization"]);
|
|
7912
|
+
const AccountKindSchema = Schema.Literals(["personalSafe", "orgTreasury"]);
|
|
7913
|
+
const OptionalReasonCode = Schema.optional(Schema.Literals(CAPXUL_ERROR_CODES));
|
|
7890
7914
|
const ActivityReferenceProps = {
|
|
7891
7915
|
reference_kind: Schema.Literals(["payment", "movement"]),
|
|
7892
7916
|
reference_id: Schema.String
|
|
@@ -7917,8 +7941,8 @@ const ActivityFilterProps = {
|
|
|
7917
7941
|
};
|
|
7918
7942
|
const ActivityActionProps = {
|
|
7919
7943
|
...TelemetryEnvelopeProps,
|
|
7920
|
-
scope_kind:
|
|
7921
|
-
reason_code:
|
|
7944
|
+
scope_kind: ScopeKindSchema,
|
|
7945
|
+
reason_code: OptionalReasonCode
|
|
7922
7946
|
};
|
|
7923
7947
|
Schema.Struct({
|
|
7924
7948
|
name: Schema.Literal("contact_relationship_changed"),
|
|
@@ -7930,7 +7954,7 @@ Schema.Struct({
|
|
|
7930
7954
|
"hidden",
|
|
7931
7955
|
"restored"
|
|
7932
7956
|
]),
|
|
7933
|
-
scope_kind:
|
|
7957
|
+
scope_kind: ScopeKindSchema,
|
|
7934
7958
|
scope_id: Schema.String,
|
|
7935
7959
|
owner_party_id: Schema.String,
|
|
7936
7960
|
party_id: Schema.String,
|
|
@@ -7946,9 +7970,9 @@ Schema.Struct({
|
|
|
7946
7970
|
});
|
|
7947
7971
|
const ContactActionProps = {
|
|
7948
7972
|
...TelemetryEnvelopeProps,
|
|
7949
|
-
scope_kind:
|
|
7973
|
+
scope_kind: ScopeKindSchema,
|
|
7950
7974
|
party_id: OptionalString,
|
|
7951
|
-
reason_code:
|
|
7975
|
+
reason_code: OptionalReasonCode
|
|
7952
7976
|
};
|
|
7953
7977
|
Schema.Struct({
|
|
7954
7978
|
name: Schema.Literal("ui_contact_action_completed"),
|
|
@@ -7975,7 +7999,7 @@ Schema.Struct({
|
|
|
7975
7999
|
props: Schema.Struct({
|
|
7976
8000
|
...TelemetryEnvelopeProps,
|
|
7977
8001
|
...ActivityReferenceProps,
|
|
7978
|
-
scope_kind:
|
|
8002
|
+
scope_kind: ScopeKindSchema,
|
|
7979
8003
|
scope_id: Schema.String,
|
|
7980
8004
|
occurred_at: Schema.Number
|
|
7981
8005
|
})
|
|
@@ -8030,6 +8054,193 @@ Schema.Struct({
|
|
|
8030
8054
|
})
|
|
8031
8055
|
])
|
|
8032
8056
|
});
|
|
8057
|
+
/**
|
|
8058
|
+
* Reliability closeout (#1960 R02) — the shape every explicit UI observation
|
|
8059
|
+
* below shares. `scope_kind` says whose surface the person was looking at,
|
|
8060
|
+
* `organization_id` is the verified Organization the producer resolved (absent
|
|
8061
|
+
* on a personal action), and `reason_code` is a catalog error code, never copy.
|
|
8062
|
+
*/
|
|
8063
|
+
const UiStepProps = {
|
|
8064
|
+
...TelemetryEnvelopeProps,
|
|
8065
|
+
scope_kind: ScopeKindSchema,
|
|
8066
|
+
organization_id: OptionalOrgId,
|
|
8067
|
+
reason_code: OptionalReasonCode
|
|
8068
|
+
};
|
|
8069
|
+
const AccessRecoveryCompletedProps = Schema.Union([Schema.Struct({
|
|
8070
|
+
...TelemetryEnvelopeProps,
|
|
8071
|
+
recovery: Schema.Literal("session_restoration"),
|
|
8072
|
+
outcome: Schema.Literals([
|
|
8073
|
+
"restored",
|
|
8074
|
+
"absent",
|
|
8075
|
+
"failed"
|
|
8076
|
+
]),
|
|
8077
|
+
reason_code: OptionalReasonCode,
|
|
8078
|
+
organization_id: OptionalOrgId
|
|
8079
|
+
}), Schema.Struct({
|
|
8080
|
+
...TelemetryEnvelopeProps,
|
|
8081
|
+
recovery: Schema.Literal("signer_readiness"),
|
|
8082
|
+
outcome: Schema.Literals(["ready", "unavailable"]),
|
|
8083
|
+
reason_code: OptionalReasonCode,
|
|
8084
|
+
organization_id: OptionalOrgId
|
|
8085
|
+
})]);
|
|
8086
|
+
Schema.Struct({
|
|
8087
|
+
name: Schema.Literal("access_recovery_completed"),
|
|
8088
|
+
props: AccessRecoveryCompletedProps
|
|
8089
|
+
});
|
|
8090
|
+
Schema.Struct({
|
|
8091
|
+
name: Schema.Literal("ui_access_step_completed"),
|
|
8092
|
+
props: Schema.Struct({
|
|
8093
|
+
...UiStepProps,
|
|
8094
|
+
step: Schema.Literals([
|
|
8095
|
+
"dashboard_granted",
|
|
8096
|
+
"redirect_completed",
|
|
8097
|
+
"gate_error_displayed",
|
|
8098
|
+
"retry_selected",
|
|
8099
|
+
"capability_refusal_displayed",
|
|
8100
|
+
"signer_refusal_displayed"
|
|
8101
|
+
]),
|
|
8102
|
+
capability: Schema.optional(Schema.Literals(["spend", "managePeople"])),
|
|
8103
|
+
probe: Schema.optional(Schema.Literals([
|
|
8104
|
+
"session",
|
|
8105
|
+
"membership",
|
|
8106
|
+
"lifecycle"
|
|
8107
|
+
])),
|
|
8108
|
+
reason: Schema.optional(Schema.Literals([
|
|
8109
|
+
"loading",
|
|
8110
|
+
"no-permission",
|
|
8111
|
+
"org-unavailable"
|
|
8112
|
+
]))
|
|
8113
|
+
})
|
|
8114
|
+
});
|
|
8115
|
+
Schema.Struct({
|
|
8116
|
+
name: Schema.Literal("org_invite_progressed"),
|
|
8117
|
+
props: Schema.Struct({
|
|
8118
|
+
...TelemetryEnvelopeProps,
|
|
8119
|
+
organization_id: OrgIdTelemetrySchema,
|
|
8120
|
+
progress: Schema.Literals([
|
|
8121
|
+
"account_ready",
|
|
8122
|
+
"permission_applied",
|
|
8123
|
+
"membership_activated",
|
|
8124
|
+
"revoked"
|
|
8125
|
+
]),
|
|
8126
|
+
/** The invited Party. The initiating actor stays on the envelope's identity. */
|
|
8127
|
+
member_party_id: Schema.String,
|
|
8128
|
+
occurred_at: Schema.Number
|
|
8129
|
+
})
|
|
8130
|
+
});
|
|
8131
|
+
Schema.Struct({
|
|
8132
|
+
name: Schema.Literal("invoice_issued"),
|
|
8133
|
+
props: Schema.Struct({
|
|
8134
|
+
...TelemetryEnvelopeProps,
|
|
8135
|
+
request_id: Schema.String,
|
|
8136
|
+
issuer_scope_kind: ScopeKindSchema,
|
|
8137
|
+
issuer_scope_id: Schema.String,
|
|
8138
|
+
payer_party_id: OptionalString,
|
|
8139
|
+
occurred_at: Schema.Number
|
|
8140
|
+
})
|
|
8141
|
+
});
|
|
8142
|
+
Schema.Struct({
|
|
8143
|
+
name: Schema.Literal("invoice_request_transitioned"),
|
|
8144
|
+
props: Schema.Struct({
|
|
8145
|
+
...TelemetryEnvelopeProps,
|
|
8146
|
+
request_id: Schema.String,
|
|
8147
|
+
transition: Schema.Literals([
|
|
8148
|
+
"approval_prepared",
|
|
8149
|
+
"declined",
|
|
8150
|
+
"cancelled"
|
|
8151
|
+
]),
|
|
8152
|
+
actor_scope_kind: ScopeKindSchema,
|
|
8153
|
+
actor_scope_id: Schema.String,
|
|
8154
|
+
occurred_at: Schema.Number
|
|
8155
|
+
})
|
|
8156
|
+
});
|
|
8157
|
+
Schema.Struct({
|
|
8158
|
+
name: Schema.Literal("ui_invoice_step_completed"),
|
|
8159
|
+
props: Schema.Struct({
|
|
8160
|
+
...UiStepProps,
|
|
8161
|
+
step: Schema.Literals([
|
|
8162
|
+
"opened",
|
|
8163
|
+
"previewed",
|
|
8164
|
+
"dismissed",
|
|
8165
|
+
"submitted",
|
|
8166
|
+
"result_displayed",
|
|
8167
|
+
"refusal_displayed",
|
|
8168
|
+
"retry_selected"
|
|
8169
|
+
]),
|
|
8170
|
+
request_id: OptionalString
|
|
8171
|
+
})
|
|
8172
|
+
});
|
|
8173
|
+
Schema.Struct({
|
|
8174
|
+
name: Schema.Literal("ui_treasury_step_completed"),
|
|
8175
|
+
props: Schema.Struct({
|
|
8176
|
+
...UiStepProps,
|
|
8177
|
+
step: Schema.Literals([
|
|
8178
|
+
"balance_displayed",
|
|
8179
|
+
"read_refusal_displayed",
|
|
8180
|
+
"retry_selected",
|
|
8181
|
+
"recovery_completed"
|
|
8182
|
+
]),
|
|
8183
|
+
account_kind: Schema.optional(AccountKindSchema)
|
|
8184
|
+
})
|
|
8185
|
+
});
|
|
8186
|
+
Schema.Struct({
|
|
8187
|
+
name: Schema.Literal("ui_receive_step_completed"),
|
|
8188
|
+
props: Schema.Struct({
|
|
8189
|
+
...UiStepProps,
|
|
8190
|
+
step: Schema.Literals([
|
|
8191
|
+
"instructions_displayed",
|
|
8192
|
+
"address_copied",
|
|
8193
|
+
"copy_failed",
|
|
8194
|
+
"refusal_displayed",
|
|
8195
|
+
"retry_selected"
|
|
8196
|
+
]),
|
|
8197
|
+
account_kind: Schema.optional(AccountKindSchema)
|
|
8198
|
+
})
|
|
8199
|
+
});
|
|
8200
|
+
Schema.Struct({
|
|
8201
|
+
name: Schema.Literal("payroll_group_changed"),
|
|
8202
|
+
props: Schema.Struct({
|
|
8203
|
+
...TelemetryEnvelopeProps,
|
|
8204
|
+
organization_id: OrgIdTelemetrySchema,
|
|
8205
|
+
change: Schema.Literals([
|
|
8206
|
+
"created",
|
|
8207
|
+
"updated",
|
|
8208
|
+
"deleted"
|
|
8209
|
+
]),
|
|
8210
|
+
group_id: Schema.String,
|
|
8211
|
+
member_count: Schema.Number,
|
|
8212
|
+
occurred_at: Schema.Number
|
|
8213
|
+
})
|
|
8214
|
+
});
|
|
8215
|
+
Schema.Struct({
|
|
8216
|
+
name: Schema.Literal("payroll_run_transitioned"),
|
|
8217
|
+
props: Schema.Struct({
|
|
8218
|
+
...TelemetryEnvelopeProps,
|
|
8219
|
+
organization_id: OrgIdTelemetrySchema,
|
|
8220
|
+
transition: Schema.Literals([
|
|
8221
|
+
"prepared",
|
|
8222
|
+
"authorized",
|
|
8223
|
+
"settled"
|
|
8224
|
+
]),
|
|
8225
|
+
run_id: Schema.String,
|
|
8226
|
+
payment_count: Schema.optional(Schema.Number),
|
|
8227
|
+
occurred_at: Schema.Number
|
|
8228
|
+
})
|
|
8229
|
+
});
|
|
8230
|
+
Schema.Struct({
|
|
8231
|
+
name: Schema.Literal("ui_payroll_action_completed"),
|
|
8232
|
+
props: Schema.Struct({
|
|
8233
|
+
...UiStepProps,
|
|
8234
|
+
action: Schema.Literals([
|
|
8235
|
+
"opened",
|
|
8236
|
+
"refusal_displayed",
|
|
8237
|
+
"recovery_completed",
|
|
8238
|
+
"cancelled",
|
|
8239
|
+
"submitted_displayed"
|
|
8240
|
+
]),
|
|
8241
|
+
run_id: OptionalString
|
|
8242
|
+
})
|
|
8243
|
+
});
|
|
8033
8244
|
function redactTelemetryProps(name, props, options = {}) {
|
|
8034
8245
|
if (props === void 0) return void 0;
|
|
8035
8246
|
const clone = cloneProps$1(props);
|
|
@@ -8447,7 +8658,8 @@ const CAPXUL_FUNCTIONS = {
|
|
|
8447
8658
|
listMine: "org/queries:listMine",
|
|
8448
8659
|
listRolesByOrgId: "org/queries:listRolesByOrgId",
|
|
8449
8660
|
loadByOrgId: "org/queries:loadByOrgId",
|
|
8450
|
-
me: "org/queries:me"
|
|
8661
|
+
me: "org/queries:me",
|
|
8662
|
+
pendingSetup: "org/queries:pendingSetup"
|
|
8451
8663
|
},
|
|
8452
8664
|
"smartAccount/actions": {
|
|
8453
8665
|
claim: "smartAccount/actions:claim",
|
|
@@ -12046,7 +12258,7 @@ const moneyExecutionContract = {
|
|
|
12046
12258
|
};
|
|
12047
12259
|
//#endregion
|
|
12048
12260
|
//#region ../../packages/sdk/package.json
|
|
12049
|
-
var version$1 = "4.2.0-rc.
|
|
12261
|
+
var version$1 = "4.2.0-rc.5";
|
|
12050
12262
|
//#endregion
|
|
12051
12263
|
//#region ../../packages/sdk/src/telemetry/exception-projection.ts
|
|
12052
12264
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -12219,6 +12431,34 @@ function ignoreDeliveryFailure(delivery) {
|
|
|
12219
12431
|
Promise.resolve(delivery).catch(() => void 0);
|
|
12220
12432
|
} catch {}
|
|
12221
12433
|
}
|
|
12434
|
+
/**
|
|
12435
|
+
* Fold a caller-captured attempt identity into the host's resolved context.
|
|
12436
|
+
*
|
|
12437
|
+
* The host's `resolveContext` runs at the moment an SDK method is entered, so a
|
|
12438
|
+
* host that mints a correlation per resolve gives every operation of one user
|
|
12439
|
+
* attempt a different identity — and a user or Organization switch between the
|
|
12440
|
+
* click and the reply relabels an action that already started. When the caller
|
|
12441
|
+
* captured `correlation_id`/`journey_id` BEFORE the action started, that is the
|
|
12442
|
+
* attempt, and it replaces what the resolver returned for this one call. The
|
|
12443
|
+
* result is what the SDK span/Log, the failure envelope and the backend carrier
|
|
12444
|
+
* all read, so the three agree by construction rather than by convention.
|
|
12445
|
+
*
|
|
12446
|
+
* A caller that captured nothing gets the resolver's context unchanged, so
|
|
12447
|
+
* automatic reads keep their own invocation context.
|
|
12448
|
+
*/
|
|
12449
|
+
function withCapturedAttemptContext(context, controls) {
|
|
12450
|
+
const correlationId = controls?.correlation_id;
|
|
12451
|
+
const journeyId = controls?.journey_id;
|
|
12452
|
+
if (correlationId === void 0 && journeyId === void 0) return context;
|
|
12453
|
+
const captured = sanitizeObservationContext({
|
|
12454
|
+
...correlationId === void 0 ? {} : { correlationId },
|
|
12455
|
+
...journeyId === void 0 ? {} : { journeyId }
|
|
12456
|
+
});
|
|
12457
|
+
return captured === void 0 ? context : {
|
|
12458
|
+
...context,
|
|
12459
|
+
...captured
|
|
12460
|
+
};
|
|
12461
|
+
}
|
|
12222
12462
|
const MAX_EVIDENCE_TEXT = 4e3;
|
|
12223
12463
|
const MAX_CAUSE_DEPTH = 8;
|
|
12224
12464
|
function evidenceText(value) {
|
|
@@ -14445,7 +14685,8 @@ var BetterAuthBrowserAdapter = class {
|
|
|
14445
14685
|
try {
|
|
14446
14686
|
const res = await this.fetchImpl(this.url("/api/auth/get-session"), withSignal$1({
|
|
14447
14687
|
method: "GET",
|
|
14448
|
-
credentials: "include"
|
|
14688
|
+
credentials: "include",
|
|
14689
|
+
cache: "no-store"
|
|
14449
14690
|
}, options?.signal));
|
|
14450
14691
|
if (options?.signal?.aborted) return {
|
|
14451
14692
|
ok: false,
|
|
@@ -14517,7 +14758,8 @@ var BetterAuthBrowserAdapter = class {
|
|
|
14517
14758
|
try {
|
|
14518
14759
|
const res = await this.fetchImpl(this.url("/api/auth/convex/token"), withSignal$1({
|
|
14519
14760
|
method: "GET",
|
|
14520
|
-
credentials: "include"
|
|
14761
|
+
credentials: "include",
|
|
14762
|
+
cache: "no-store"
|
|
14521
14763
|
}, options?.signal));
|
|
14522
14764
|
if (options?.signal?.aborted) return {
|
|
14523
14765
|
ok: false,
|
|
@@ -18966,6 +19208,7 @@ function orgIdBody(orgId) {
|
|
|
18966
19208
|
//#region ../../packages/sdk/src/adapters/org/ConvexOrganizationAdapter.ts
|
|
18967
19209
|
const DEFAULT_FUNCTIONS$1 = {
|
|
18968
19210
|
listAll: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listAll),
|
|
19211
|
+
pendingSetup: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].pendingSetup),
|
|
18969
19212
|
listRoles: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listRolesByOrgId),
|
|
18970
19213
|
listMembers: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listMembersByOrgId),
|
|
18971
19214
|
readTreasury: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].readTreasury),
|
|
@@ -19001,6 +19244,9 @@ var ConvexOrganizationAdapter = class {
|
|
|
19001
19244
|
return brandOrgView(wire, treasury, viewerRole);
|
|
19002
19245
|
})))), Effect.catchDefect((cause) => Effect.fail(toOrgError("listOrgs", cause))));
|
|
19003
19246
|
}
|
|
19247
|
+
pendingSetup(input) {
|
|
19248
|
+
return this.#convex.query(this.#fns.pendingSetup, copyInvocationObservation(input, {})).pipe(Effect.mapError((error) => orgErrorFromCapxul("pendingSetup", error.publicError, error)), Effect.map((wire) => wire === null ? null : { orgId: toOrgId(wire.orgId) }), Effect.catchDefect((cause) => Effect.fail(toOrgError("pendingSetup", cause))));
|
|
19249
|
+
}
|
|
19004
19250
|
readTreasury(input) {
|
|
19005
19251
|
return this.#readTreasuryWire(input).pipe(Effect.catchDefect((cause) => Effect.fail(toOrgError("readTreasury", cause))));
|
|
19006
19252
|
}
|
|
@@ -19418,6 +19664,32 @@ var ConsoleDiagnosticAdapter = class {
|
|
|
19418
19664
|
}
|
|
19419
19665
|
};
|
|
19420
19666
|
//#endregion
|
|
19667
|
+
//#region ../../packages/sdk/src/adapters/diagnostic/EffectLogDiagnosticAdapter.ts
|
|
19668
|
+
/**
|
|
19669
|
+
* Diagnostic breadcrumbs as SDK log records. The signer's readiness cycle
|
|
19670
|
+
* traces (`openfort.*`) used to reach only the browser console; through this
|
|
19671
|
+
* adapter they run in the client's own Effect context, so the engineering
|
|
19672
|
+
* telemetry layer ships them to PostHog Logs beside `identity.transition`.
|
|
19673
|
+
* Logging never throws back into the cycle that emitted it.
|
|
19674
|
+
*/
|
|
19675
|
+
var EffectLogDiagnosticAdapter = class {
|
|
19676
|
+
#runPromise;
|
|
19677
|
+
#console;
|
|
19678
|
+
constructor(context, consoleFallback) {
|
|
19679
|
+
this.#runPromise = Effect.runPromiseWith(context);
|
|
19680
|
+
this.#console = consoleFallback;
|
|
19681
|
+
}
|
|
19682
|
+
trace(scope, detail) {
|
|
19683
|
+
this.#console?.trace(scope, detail);
|
|
19684
|
+
try {
|
|
19685
|
+
this.#runPromise(Effect.logInfo(scope).pipe(Effect.annotateLogs({
|
|
19686
|
+
...detail,
|
|
19687
|
+
diagnostic_scope: scope
|
|
19688
|
+
}), Effect.catchCause(() => Effect.void))).catch(() => void 0);
|
|
19689
|
+
} catch {}
|
|
19690
|
+
}
|
|
19691
|
+
};
|
|
19692
|
+
//#endregion
|
|
19421
19693
|
//#region ../../node_modules/.pnpm/axios@1.17.0/node_modules/axios/lib/helpers/bind.js
|
|
19422
19694
|
/**
|
|
19423
19695
|
* Create a bound version of a function with a specified `this` context
|
|
@@ -42502,9 +42774,28 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42502
42774
|
function encryptionSessionUrl() {
|
|
42503
42775
|
return `${authBaseUrl}/encryption-session`;
|
|
42504
42776
|
}
|
|
42777
|
+
let cycleStartedAt = null;
|
|
42778
|
+
let stepStartedAt = 0;
|
|
42779
|
+
let tokenCalls = 0;
|
|
42780
|
+
const sinceCycleStart = () => cycleStartedAt === null ? void 0 : Date.now() - cycleStartedAt;
|
|
42781
|
+
const step = (name, extra = {}) => {
|
|
42782
|
+
const now = Date.now();
|
|
42783
|
+
diagnostic?.trace("openfort.step", {
|
|
42784
|
+
step: name,
|
|
42785
|
+
duration_ms: now - stepStartedAt,
|
|
42786
|
+
elapsed_ms: sinceCycleStart(),
|
|
42787
|
+
...extra
|
|
42788
|
+
});
|
|
42789
|
+
stepStartedAt = now;
|
|
42790
|
+
};
|
|
42505
42791
|
async function fetchBetterAuthAccessToken() {
|
|
42792
|
+
tokenCalls += 1;
|
|
42793
|
+
const tokenStartedAt = Date.now();
|
|
42506
42794
|
try {
|
|
42507
|
-
const response = await fetch(betterAuthSessionUrl(), {
|
|
42795
|
+
const response = await fetch(betterAuthSessionUrl(), {
|
|
42796
|
+
credentials: "include",
|
|
42797
|
+
cache: "no-store"
|
|
42798
|
+
});
|
|
42508
42799
|
if (!response.ok) {
|
|
42509
42800
|
diagnostic?.trace("openfort.token", {
|
|
42510
42801
|
ok: false,
|
|
@@ -42525,7 +42816,10 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42525
42816
|
}
|
|
42526
42817
|
diagnostic?.trace("openfort.token", {
|
|
42527
42818
|
ok: true,
|
|
42528
|
-
tokenPresent: true
|
|
42819
|
+
tokenPresent: true,
|
|
42820
|
+
call: tokenCalls,
|
|
42821
|
+
duration_ms: Date.now() - tokenStartedAt,
|
|
42822
|
+
elapsed_ms: sinceCycleStart()
|
|
42529
42823
|
});
|
|
42530
42824
|
return token;
|
|
42531
42825
|
} catch (cause) {
|
|
@@ -42581,10 +42875,16 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42581
42875
|
let walletReadyPromise = null;
|
|
42582
42876
|
function startWalletReady() {
|
|
42583
42877
|
return (async () => {
|
|
42878
|
+
const startedAt = Date.now();
|
|
42879
|
+
cycleStartedAt = startedAt;
|
|
42880
|
+
stepStartedAt = startedAt;
|
|
42881
|
+
tokenCalls = 0;
|
|
42584
42882
|
if (isInsecureBrowserContext()) failNoSecureContext();
|
|
42585
42883
|
await openfort.waitForInitialization();
|
|
42884
|
+
step("initialize");
|
|
42586
42885
|
const accessToken = await fetchBetterAuthAccessToken();
|
|
42587
42886
|
if (accessToken === null) throw openfortProviderError("token", /* @__PURE__ */ new Error("Better Auth access token unavailable for Openfort"));
|
|
42887
|
+
step("token");
|
|
42588
42888
|
let encryptionResponse;
|
|
42589
42889
|
try {
|
|
42590
42890
|
encryptionResponse = await fetch(encryptionSessionUrl(), {
|
|
@@ -42627,10 +42927,12 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42627
42927
|
ok: true,
|
|
42628
42928
|
httpStatus: encryptionResponse.status
|
|
42629
42929
|
});
|
|
42930
|
+
step("encryptionSession", { httpStatus: encryptionResponse.status });
|
|
42630
42931
|
let embeddedState;
|
|
42631
42932
|
try {
|
|
42632
42933
|
embeddedState = await openfort.embeddedWallet.getEmbeddedState();
|
|
42633
42934
|
diagnostic?.trace("openfort.embeddedState", { state: embeddedState });
|
|
42935
|
+
step("embeddedState", { state: embeddedState });
|
|
42634
42936
|
} catch (cause) {
|
|
42635
42937
|
diagnostic?.trace("openfort.embeddedState", {
|
|
42636
42938
|
ok: false,
|
|
@@ -42644,6 +42946,7 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42644
42946
|
try {
|
|
42645
42947
|
await configureEmbeddedWallet(encryptionBody.sessionId);
|
|
42646
42948
|
diagnostic?.trace("openfort.configure", { ok: true });
|
|
42949
|
+
step("configure");
|
|
42647
42950
|
} catch (cause) {
|
|
42648
42951
|
const error = openfortProviderError("configure", cause);
|
|
42649
42952
|
diagnostic?.trace("openfort.configure", {
|
|
@@ -42656,6 +42959,7 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42656
42959
|
try {
|
|
42657
42960
|
await openfort.embeddedWallet.get();
|
|
42658
42961
|
diagnostic?.trace("openfort.get", { ok: true });
|
|
42962
|
+
step("get");
|
|
42659
42963
|
} catch (cause) {
|
|
42660
42964
|
if (!isStaleUserSignal(cause)) {
|
|
42661
42965
|
diagnostic?.trace("openfort.get", {
|
|
@@ -42669,7 +42973,13 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42669
42973
|
failure_mode: "stale-openfort-cache"
|
|
42670
42974
|
});
|
|
42671
42975
|
await healStaleOpenfortCache(encryptionBody.sessionId);
|
|
42976
|
+
step("healStaleCache");
|
|
42672
42977
|
}
|
|
42978
|
+
step("walletReady", {
|
|
42979
|
+
ok: true,
|
|
42980
|
+
total_ms: Date.now() - startedAt,
|
|
42981
|
+
token_calls: tokenCalls
|
|
42982
|
+
});
|
|
42673
42983
|
})();
|
|
42674
42984
|
}
|
|
42675
42985
|
async function ensureOpenfortWalletReady() {
|
|
@@ -42752,9 +43062,13 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
42752
43062
|
statusStore,
|
|
42753
43063
|
ensureWalletReady: ensureOpenfortWalletReady,
|
|
42754
43064
|
getAddress: async () => {
|
|
43065
|
+
const addressStartedAt = Date.now();
|
|
42755
43066
|
try {
|
|
42756
43067
|
const address = await signer.getAddress();
|
|
42757
|
-
diagnostic?.trace("openfort.address", {
|
|
43068
|
+
diagnostic?.trace("openfort.address", {
|
|
43069
|
+
ok: true,
|
|
43070
|
+
duration_ms: Date.now() - addressStartedAt
|
|
43071
|
+
});
|
|
42758
43072
|
return address;
|
|
42759
43073
|
} catch (cause) {
|
|
42760
43074
|
diagnostic?.trace("openfort.address", {
|
|
@@ -44917,7 +45231,7 @@ function hermeticOrgView(input) {
|
|
|
44917
45231
|
name: input.name,
|
|
44918
45232
|
handle: input.handle,
|
|
44919
45233
|
safeAddress: toAddress(placeholder),
|
|
44920
|
-
role:
|
|
45234
|
+
role: ADMIN_ROLE_LABEL,
|
|
44921
45235
|
treasury: zeroTreasury(orgId),
|
|
44922
45236
|
bio: null,
|
|
44923
45237
|
size: null,
|
|
@@ -45713,6 +46027,43 @@ function startSignerReadinessOnClaim(actor, signer) {
|
|
|
45713
46027
|
browserSigner.ensureWalletReady?.().catch(() => {});
|
|
45714
46028
|
});
|
|
45715
46029
|
}
|
|
46030
|
+
/**
|
|
46031
|
+
* Attach a pending Organization when the identity becomes claimed.
|
|
46032
|
+
*
|
|
46033
|
+
* A reload during Organization setup used to leave the app re-submitting the
|
|
46034
|
+
* stored draft, and that second submission raced the controller's resume on
|
|
46035
|
+
* `ReadSession` — the loser was refused with `SUPERSEDED`. The backend already
|
|
46036
|
+
* knows the truth: `pendingSetup()` reports the owner's Organization whose
|
|
46037
|
+
* setup has not finished. The SDK asks once per authenticated user and sends
|
|
46038
|
+
* `AttachOrganization`, which the identity flow runs as `orgLane(…, attach)`.
|
|
46039
|
+
* The app then re-submits nothing.
|
|
46040
|
+
*
|
|
46041
|
+
* The read is fire-and-forget, as the signer readiness cycle is: a failure is
|
|
46042
|
+
* swallowed and the ask is released, so the next state change retries. The ask
|
|
46043
|
+
* is held to ONE per authUserId, so the claimed transitions that follow (the
|
|
46044
|
+
* org lane's own) start no second read, and a new session asks again.
|
|
46045
|
+
*/
|
|
46046
|
+
function attachPendingOrganizationOnClaim(actor, organizationPort) {
|
|
46047
|
+
const pendingSetup = organizationPort?.pendingSetup?.bind(organizationPort);
|
|
46048
|
+
if (pendingSetup === void 0) return () => {};
|
|
46049
|
+
let askedFor = null;
|
|
46050
|
+
return actor.subscribe((state) => {
|
|
46051
|
+
if (state.phase !== "authenticated" || state.account.at !== "claimed") return;
|
|
46052
|
+
if (state.account.org !== null) return;
|
|
46053
|
+
const authUserId = state.session.authUserId;
|
|
46054
|
+
if (askedFor === authUserId) return;
|
|
46055
|
+
askedFor = authUserId;
|
|
46056
|
+
Effect.runPromise(pendingSetup({})).then((pending) => {
|
|
46057
|
+
if (pending === null) return;
|
|
46058
|
+
return Effect.runPromise(actor.ask({
|
|
46059
|
+
_tag: "AttachOrganization",
|
|
46060
|
+
orgId: String(pending.orgId)
|
|
46061
|
+
}));
|
|
46062
|
+
}).catch(() => {
|
|
46063
|
+
askedFor = null;
|
|
46064
|
+
});
|
|
46065
|
+
});
|
|
46066
|
+
}
|
|
45716
46067
|
function assembleCapxulClient(input) {
|
|
45717
46068
|
const observation = input;
|
|
45718
46069
|
const authCache = input.authCache ?? detectAuthCacheAdapter();
|
|
@@ -45742,18 +46093,20 @@ function assembleCapxulClient(input) {
|
|
|
45742
46093
|
}, failureObservation, normalizeCapxulOperation(`identity.${record.event}`), "machine");
|
|
45743
46094
|
});
|
|
45744
46095
|
const unsubscribeSignerReadiness = startSignerReadinessOnClaim(actor, input.signer);
|
|
46096
|
+
const selectedOrgPort = input.orgPort ?? input.orgDeploymentPort;
|
|
46097
|
+
const unsubscribePendingOrganization = attachPendingOrganizationOnClaim(actor, selectedOrgPort);
|
|
45745
46098
|
let stopPromise = null;
|
|
45746
46099
|
const stopActor = () => {
|
|
45747
46100
|
if (stopPromise === null) {
|
|
45748
46101
|
unsubscribeProductTelemetry();
|
|
45749
46102
|
unsubscribeFailureObservation();
|
|
45750
46103
|
unsubscribeSignerReadiness();
|
|
46104
|
+
unsubscribePendingOrganization();
|
|
45751
46105
|
stopPromise = effectRunner.runPromise(Scope.close(scope, Exit.void));
|
|
45752
46106
|
}
|
|
45753
46107
|
return stopPromise;
|
|
45754
46108
|
};
|
|
45755
46109
|
if (input.signal !== void 0) input.signal.addEventListener("abort", () => void stopActor(), { once: true });
|
|
45756
|
-
const selectedOrgPort = input.orgPort ?? input.orgDeploymentPort;
|
|
45757
46110
|
let detectPendingOrgInvitations;
|
|
45758
46111
|
let kickProvisioning;
|
|
45759
46112
|
const financialOps = makeFinancialOpsMethods({
|
|
@@ -45793,10 +46146,13 @@ function assembleCapxulClient(input) {
|
|
|
45793
46146
|
...input.invokeTimeoutMs === void 0 ? {} : { invokeTimeoutMs: input.invokeTimeoutMs },
|
|
45794
46147
|
afterVerifyOtp: async () => {
|
|
45795
46148
|
const browserSigner = input.signer;
|
|
45796
|
-
if (browserSigner !== void 0 && "resetSession" in browserSigner && typeof browserSigner.resetSession === "function")
|
|
45797
|
-
|
|
45798
|
-
|
|
45799
|
-
|
|
46149
|
+
if (browserSigner !== void 0 && "resetSession" in browserSigner && typeof browserSigner.resetSession === "function") {
|
|
46150
|
+
try {
|
|
46151
|
+
browserSigner.resetSession();
|
|
46152
|
+
} catch (cause) {
|
|
46153
|
+
throw signerFailure(browserSigner.source, "resetSession", cause);
|
|
46154
|
+
}
|
|
46155
|
+
if (browserSigner.statusStore?.status() === "unknown" && typeof browserSigner.ensureWalletReady === "function") browserSigner.ensureWalletReady().catch(() => {});
|
|
45800
46156
|
}
|
|
45801
46157
|
await detectPendingOrgInvitations?.();
|
|
45802
46158
|
kickProvisioning?.();
|
|
@@ -46015,8 +46371,10 @@ function withHostObservationControls(snapshot, input, actorId) {
|
|
|
46015
46371
|
const previous = readInvocationObservation(input);
|
|
46016
46372
|
if (previous !== void 0) return attachInvocationObservation({ ...input }, previous);
|
|
46017
46373
|
const captured = snapshot?.() ?? { active: true };
|
|
46374
|
+
const context = captured.active ? withCapturedAttemptContext(captured.context, input) : captured.context;
|
|
46018
46375
|
return attachInvocationObservation({ ...input }, {
|
|
46019
46376
|
...captured,
|
|
46377
|
+
...context === void 0 ? {} : { context },
|
|
46020
46378
|
...actorId === void 0 ? {} : { actorId }
|
|
46021
46379
|
});
|
|
46022
46380
|
}
|
|
@@ -46619,7 +46977,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
|
|
|
46619
46977
|
...adapters.value.bootstrap,
|
|
46620
46978
|
authBaseUrl: resolvedAuthBaseUrl
|
|
46621
46979
|
}, {
|
|
46622
|
-
diagnostic: new ConsoleDiagnosticAdapter(),
|
|
46980
|
+
diagnostic: new EffectLogDiagnosticAdapter(adapters.value.context, new ConsoleDiagnosticAdapter()),
|
|
46623
46981
|
signUserOpHash: controls.signEmbeddedUserOpHash
|
|
46624
46982
|
});
|
|
46625
46983
|
signer = withSignerControl(signer, controls.signUserOpHash);
|
|
@@ -47435,7 +47793,7 @@ function stdioIdentity(env = process.env, options = {}) {
|
|
|
47435
47793
|
}
|
|
47436
47794
|
//#endregion
|
|
47437
47795
|
//#region package.json
|
|
47438
|
-
var version = "4.2.0-rc.
|
|
47796
|
+
var version = "4.2.0-rc.5";
|
|
47439
47797
|
//#endregion
|
|
47440
47798
|
//#region src/deps.ts
|
|
47441
47799
|
const NO_IDENTITY = async () => void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "4.2.0-rc.
|
|
3
|
+
"version": "4.2.0-rc.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
|
|
6
6
|
"keywords": [
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
|
|
52
52
|
"vite-plus": "0.3.0",
|
|
53
53
|
"@capxul/config": "0.3.0",
|
|
54
|
-
"@capxul/
|
|
55
|
-
"@capxul/
|
|
54
|
+
"@capxul/typescript-config": "0.0.0",
|
|
55
|
+
"@capxul/sdk": "4.2.0-rc.5"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"dev": "vp exec tsx src/main.ts serve",
|