run402-mcp 4.26.0 → 4.28.0
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.
|
@@ -11,11 +11,19 @@ export interface ActiveProjectState {
|
|
|
11
11
|
profile: string;
|
|
12
12
|
updated_at: string;
|
|
13
13
|
}
|
|
14
|
+
export interface ActiveOrgState {
|
|
15
|
+
org_id: string;
|
|
16
|
+
api_base: string;
|
|
17
|
+
principal?: string | null;
|
|
18
|
+
profile: string;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
}
|
|
14
21
|
export interface ProfileState {
|
|
15
22
|
version?: 1;
|
|
16
23
|
active_project_id?: string;
|
|
17
24
|
previous_active_project_id?: string;
|
|
18
25
|
active_projects?: Record<string, ActiveProjectState>;
|
|
26
|
+
active_orgs?: Record<string, ActiveOrgState>;
|
|
19
27
|
migrations?: Record<string, unknown>;
|
|
20
28
|
}
|
|
21
29
|
export declare function loadProfileState(path?: string): ProfileState;
|
|
@@ -25,5 +33,8 @@ export declare function activeProjectScopeKey(scope?: ActiveProjectScope): strin
|
|
|
25
33
|
export declare function getActiveProjectId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
26
34
|
export declare function setActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
27
35
|
export declare function clearActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
36
|
+
export declare function getActiveOrgId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
37
|
+
export declare function setActiveOrgId(orgId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
38
|
+
export declare function clearActiveOrgId(path?: string, scope?: ActiveProjectScope): void;
|
|
28
39
|
export declare function recordMigration(marker: string, value: unknown, path?: string): void;
|
|
29
40
|
//# sourceMappingURL=profile-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-state.d.ts","sourceRoot":"","sources":["../src/profile-state.ts"],"names":[],"mappings":"AAKA,MAAM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M,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAOnF"}
|
|
@@ -126,6 +126,52 @@ export function clearActiveProjectId(projectId, path, scope = {}) {
|
|
|
126
126
|
saveProfileState(state, p);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// Selected organization (add-cli-current-org, design D3).
|
|
131
|
+
//
|
|
132
|
+
// Scoped exactly like the active project id — by api_base, profile, and
|
|
133
|
+
// principal — and stored in the SAME per-profile state.json, never in the
|
|
134
|
+
// base-level config.json beside `active_wallet`. The chain is
|
|
135
|
+
// wallet -> principal -> memberships, so a globally-selected org survives
|
|
136
|
+
// `wallets use other` and then either 403s or, worse, silently resolves to a
|
|
137
|
+
// valid-but-wrong org when both principals are members. Per-profile makes the
|
|
138
|
+
// failure mode "this profile has no current org", which the ORG_REQUIRED
|
|
139
|
+
// envelope already knows how to explain.
|
|
140
|
+
//
|
|
141
|
+
// There is deliberately no top-level `active_org_id` mirror: the project one
|
|
142
|
+
// exists only to carry pre-scoping installs forward, and this key is new.
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
export function getActiveOrgId(path, scope = {}) {
|
|
145
|
+
const state = loadProfileState(path);
|
|
146
|
+
return state.active_orgs?.[activeProjectScopeKey(scope)]?.org_id;
|
|
147
|
+
}
|
|
148
|
+
export function setActiveOrgId(orgId, path, scope = {}) {
|
|
149
|
+
const p = path ?? getProfileStatePath();
|
|
150
|
+
withFileLock(p, () => {
|
|
151
|
+
const state = loadProfileState(p);
|
|
152
|
+
const key = activeProjectScopeKey(scope);
|
|
153
|
+
const resolved = defaultActiveProjectScope(scope);
|
|
154
|
+
state.active_orgs = state.active_orgs ?? {};
|
|
155
|
+
state.active_orgs[key] = {
|
|
156
|
+
org_id: orgId,
|
|
157
|
+
api_base: resolved.api_base,
|
|
158
|
+
principal: resolved.principal ?? null,
|
|
159
|
+
profile: resolved.profile,
|
|
160
|
+
updated_at: new Date().toISOString(),
|
|
161
|
+
};
|
|
162
|
+
saveProfileState(state, p);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export function clearActiveOrgId(path, scope = {}) {
|
|
166
|
+
const p = path ?? getProfileStatePath();
|
|
167
|
+
withFileLock(p, () => {
|
|
168
|
+
const state = loadProfileState(p);
|
|
169
|
+
const key = activeProjectScopeKey(scope);
|
|
170
|
+
if (state.active_orgs?.[key])
|
|
171
|
+
delete state.active_orgs[key];
|
|
172
|
+
saveProfileState(state, p);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
129
175
|
export function recordMigration(marker, value, path) {
|
|
130
176
|
const p = path ?? getProfileStatePath();
|
|
131
177
|
withFileLock(p, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-state.js","sourceRoot":"","sources":["../src/profile-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"profile-state.js","sourceRoot":"","sources":["../src/profile-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAA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AC;QACpE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402-mcp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.0",
|
|
4
4
|
"packageManager": "npm@11.19.0",
|
|
5
5
|
"mcpName": "com.run402/mcp",
|
|
6
6
|
"description": "MCP server for Run402 — pay-per-call infrastructure for AI agents over x402 USDC micropayments. Generate an image for $0.03 with no signup, or provision Postgres databases with REST API, auth, storage and row-level security.",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"test:sync": "node --test --import tsx sync.test.ts examples/tenant-x402-wallet-stats/example.test.mjs",
|
|
34
34
|
"test:run402-app-schema-drift": "node scripts/check-run402-app-schema-drift.mjs",
|
|
35
35
|
"test:docs": "node scripts/check-typed-config-docs.mjs && npm run check:docs --workspace=@run402/sdk -- --skip-build",
|
|
36
|
-
"test": "npm run build && node scripts/build-agent-skills-index.mjs --check && node --experimental-test-module-mocks --test --import tsx SKILL.test.ts sync.test.ts buzz/setup.test.mjs buzz/helper.test.mjs buzz/package.test.mjs scripts/build-agent-skills-index.test.mjs examples/tenant-x402-wallet-stats/example.test.mjs 'core/src/**/*.test.ts' 'sdk/src/**/*.test.ts' 'src/**/*.test.ts' && node --test cli-core-target.test.mjs && node --experimental-test-module-mocks --test cli-up-argv.test.mjs cli-gitvault-surface.test.mjs cli-identity-link.test.mjs cli-identity-link-matrix.test.mjs cli-redeem.test.mjs cli/lib/buzz.test.mjs && node --test cli-output-contract.test.mjs cli-e2e.test.mjs cli-help.test.mjs cli-provision-active.test.mjs cli-typed-config-modes.test.mjs cli-argv.test.mjs cli-conventions-gate.test.mjs paid-stack-deps.test.mjs profile-guidance.test.mjs settlement-disclosure.test.mjs cli-suggestions-gate.test.mjs cli-env.test.mjs cli-wallets.test.mjs cli-org.test.mjs cli-ci.test.mjs cli-deploy-ci.test.mjs cli-operator-loopback.test.mjs cli-gitvault-remote-helper.test.mjs cli-deploy-gitvault-advisory.test.mjs cli/lib/buzz-doctor-contract.test.mjs cli/lib/buzz-doctor.test.mjs cli/lib/diagnostic-telemetry.test.mjs cli/lib/doctor-source-scan.test.mjs cli/lib/errors.test.mjs cli/lib/pay.test.mjs cli-bootstrap-next-actions.test.mjs && npm run test:docs",
|
|
37
|
-
"test:e2e": "npm run build && node --test cli-core-target.test.mjs && node --experimental-test-module-mocks --test cli-gitvault-surface.test.mjs cli-identity-link.test.mjs cli-identity-link-matrix.test.mjs cli-redeem.test.mjs && node --test cli-output-contract.test.mjs cli-e2e.test.mjs cli-help.test.mjs cli-provision-active.test.mjs cli-typed-config-modes.test.mjs cli-argv.test.mjs cli-conventions-gate.test.mjs paid-stack-deps.test.mjs profile-guidance.test.mjs settlement-disclosure.test.mjs cli-suggestions-gate.test.mjs cli-env.test.mjs cli-wallets.test.mjs cli-org.test.mjs cli-ci.test.mjs cli-deploy-ci.test.mjs cli-operator-loopback.test.mjs cli-gitvault-remote-helper.test.mjs cli-deploy-gitvault-advisory.test.mjs cli/lib/buzz-doctor-contract.test.mjs cli/lib/buzz-doctor.test.mjs cli/lib/diagnostic-telemetry.test.mjs cli/lib/doctor-source-scan.test.mjs cli/lib/errors.test.mjs cli-bootstrap-next-actions.test.mjs",
|
|
36
|
+
"test": "npm run build && node scripts/build-agent-skills-index.mjs --check && node --experimental-test-module-mocks --test --import tsx SKILL.test.ts sync.test.ts buzz/setup.test.mjs buzz/helper.test.mjs buzz/package.test.mjs scripts/build-agent-skills-index.test.mjs examples/tenant-x402-wallet-stats/example.test.mjs 'core/src/**/*.test.ts' 'sdk/src/**/*.test.ts' 'src/**/*.test.ts' && node --test cli-core-target.test.mjs && node --experimental-test-module-mocks --test cli-up-argv.test.mjs cli-gitvault-surface.test.mjs cli-identity-link.test.mjs cli-identity-link-matrix.test.mjs cli-redeem.test.mjs cli/lib/buzz.test.mjs && node --test cli-output-contract.test.mjs cli-e2e.test.mjs cli-help.test.mjs cli-provision-active.test.mjs cli-typed-config-modes.test.mjs cli-argv.test.mjs cli-conventions-gate.test.mjs paid-stack-deps.test.mjs profile-guidance.test.mjs settlement-disclosure.test.mjs cli-suggestions-gate.test.mjs cli-env.test.mjs cli-wallets.test.mjs cli-org.test.mjs cli-org-context.test.mjs cli-ci.test.mjs cli-deploy-ci.test.mjs cli-operator-loopback.test.mjs cli-gitvault-remote-helper.test.mjs cli-deploy-gitvault-advisory.test.mjs cli/lib/buzz-doctor-contract.test.mjs cli/lib/buzz-doctor.test.mjs cli/lib/diagnostic-telemetry.test.mjs cli/lib/doctor-source-scan.test.mjs cli/lib/errors.test.mjs cli/lib/pay.test.mjs cli-bootstrap-next-actions.test.mjs && npm run test:docs",
|
|
37
|
+
"test:e2e": "npm run build && node --test cli-core-target.test.mjs && node --experimental-test-module-mocks --test cli-gitvault-surface.test.mjs cli-identity-link.test.mjs cli-identity-link-matrix.test.mjs cli-redeem.test.mjs && node --test cli-output-contract.test.mjs cli-e2e.test.mjs cli-help.test.mjs cli-provision-active.test.mjs cli-typed-config-modes.test.mjs cli-argv.test.mjs cli-conventions-gate.test.mjs paid-stack-deps.test.mjs profile-guidance.test.mjs settlement-disclosure.test.mjs cli-suggestions-gate.test.mjs cli-env.test.mjs cli-wallets.test.mjs cli-org.test.mjs cli-org-context.test.mjs cli-ci.test.mjs cli-deploy-ci.test.mjs cli-operator-loopback.test.mjs cli-gitvault-remote-helper.test.mjs cli-deploy-gitvault-advisory.test.mjs cli/lib/buzz-doctor-contract.test.mjs cli/lib/buzz-doctor.test.mjs cli/lib/diagnostic-telemetry.test.mjs cli/lib/doctor-source-scan.test.mjs cli/lib/errors.test.mjs cli-bootstrap-next-actions.test.mjs",
|
|
38
38
|
"test:help": "npm run build && node --test cli-help.test.mjs",
|
|
39
39
|
"test:integration": "node --test --import tsx core/src/siwx-integration.integ.ts",
|
|
40
40
|
"test:integration:full": "node --test --import tsx cli-integration.test.ts",
|
|
@@ -11,11 +11,19 @@ export interface ActiveProjectState {
|
|
|
11
11
|
profile: string;
|
|
12
12
|
updated_at: string;
|
|
13
13
|
}
|
|
14
|
+
export interface ActiveOrgState {
|
|
15
|
+
org_id: string;
|
|
16
|
+
api_base: string;
|
|
17
|
+
principal?: string | null;
|
|
18
|
+
profile: string;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
}
|
|
14
21
|
export interface ProfileState {
|
|
15
22
|
version?: 1;
|
|
16
23
|
active_project_id?: string;
|
|
17
24
|
previous_active_project_id?: string;
|
|
18
25
|
active_projects?: Record<string, ActiveProjectState>;
|
|
26
|
+
active_orgs?: Record<string, ActiveOrgState>;
|
|
19
27
|
migrations?: Record<string, unknown>;
|
|
20
28
|
}
|
|
21
29
|
export declare function loadProfileState(path?: string): ProfileState;
|
|
@@ -25,5 +33,8 @@ export declare function activeProjectScopeKey(scope?: ActiveProjectScope): strin
|
|
|
25
33
|
export declare function getActiveProjectId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
26
34
|
export declare function setActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
27
35
|
export declare function clearActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
36
|
+
export declare function getActiveOrgId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
37
|
+
export declare function setActiveOrgId(orgId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
38
|
+
export declare function clearActiveOrgId(path?: string, scope?: ActiveProjectScope): void;
|
|
28
39
|
export declare function recordMigration(marker: string, value: unknown, path?: string): void;
|
|
29
40
|
//# sourceMappingURL=profile-state.d.ts.map
|
|
@@ -126,6 +126,52 @@ export function clearActiveProjectId(projectId, path, scope = {}) {
|
|
|
126
126
|
saveProfileState(state, p);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// Selected organization (add-cli-current-org, design D3).
|
|
131
|
+
//
|
|
132
|
+
// Scoped exactly like the active project id — by api_base, profile, and
|
|
133
|
+
// principal — and stored in the SAME per-profile state.json, never in the
|
|
134
|
+
// base-level config.json beside `active_wallet`. The chain is
|
|
135
|
+
// wallet -> principal -> memberships, so a globally-selected org survives
|
|
136
|
+
// `wallets use other` and then either 403s or, worse, silently resolves to a
|
|
137
|
+
// valid-but-wrong org when both principals are members. Per-profile makes the
|
|
138
|
+
// failure mode "this profile has no current org", which the ORG_REQUIRED
|
|
139
|
+
// envelope already knows how to explain.
|
|
140
|
+
//
|
|
141
|
+
// There is deliberately no top-level `active_org_id` mirror: the project one
|
|
142
|
+
// exists only to carry pre-scoping installs forward, and this key is new.
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
export function getActiveOrgId(path, scope = {}) {
|
|
145
|
+
const state = loadProfileState(path);
|
|
146
|
+
return state.active_orgs?.[activeProjectScopeKey(scope)]?.org_id;
|
|
147
|
+
}
|
|
148
|
+
export function setActiveOrgId(orgId, path, scope = {}) {
|
|
149
|
+
const p = path ?? getProfileStatePath();
|
|
150
|
+
withFileLock(p, () => {
|
|
151
|
+
const state = loadProfileState(p);
|
|
152
|
+
const key = activeProjectScopeKey(scope);
|
|
153
|
+
const resolved = defaultActiveProjectScope(scope);
|
|
154
|
+
state.active_orgs = state.active_orgs ?? {};
|
|
155
|
+
state.active_orgs[key] = {
|
|
156
|
+
org_id: orgId,
|
|
157
|
+
api_base: resolved.api_base,
|
|
158
|
+
principal: resolved.principal ?? null,
|
|
159
|
+
profile: resolved.profile,
|
|
160
|
+
updated_at: new Date().toISOString(),
|
|
161
|
+
};
|
|
162
|
+
saveProfileState(state, p);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export function clearActiveOrgId(path, scope = {}) {
|
|
166
|
+
const p = path ?? getProfileStatePath();
|
|
167
|
+
withFileLock(p, () => {
|
|
168
|
+
const state = loadProfileState(p);
|
|
169
|
+
const key = activeProjectScopeKey(scope);
|
|
170
|
+
if (state.active_orgs?.[key])
|
|
171
|
+
delete state.active_orgs[key];
|
|
172
|
+
saveProfileState(state, p);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
129
175
|
export function recordMigration(marker, value, path) {
|
|
130
176
|
const p = path ?? getProfileStatePath();
|
|
131
177
|
withFileLock(p, () => {
|