@spacefast/common 0.0.26 → 0.2.2
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/agents/connect-targets.d.ts +6 -146
- package/dist/agents/connect-targets.js +63 -295
- package/dist/agents/private-key-oauth.d.ts +31 -1
- package/dist/agents/private-key-oauth.js +124 -33
- package/dist/agents/registry/core.d.ts +292 -0
- package/dist/agents/registry/core.js +1388 -0
- package/dist/agents/registry/deeplink-probes.d.ts +23 -0
- package/dist/agents/registry/deeplink-probes.js +18 -0
- package/dist/agents/registry/node.d.ts +56 -0
- package/dist/agents/registry/node.js +339 -0
- package/dist/brand-assets-build.js +1 -2
- package/dist/brand-assets.js +4 -7
- package/dist/brand.d.ts +17 -0
- package/dist/brand.js +24 -4
- package/dist/config/domains.d.ts +55 -28
- package/dist/config/domains.js +85 -41
- package/dist/config/index.js +1 -2
- package/dist/contracts/abuse.js +9 -24
- package/dist/contracts/access-profiles.d.ts +86 -0
- package/dist/contracts/access-profiles.js +89 -0
- package/dist/contracts/access.d.ts +21 -27
- package/dist/contracts/access.js +33 -64
- package/dist/contracts/activity.d.ts +18 -1
- package/dist/contracts/activity.js +70 -26
- package/dist/contracts/analytics.js +8 -10
- package/dist/contracts/api-keys.d.ts +77 -52
- package/dist/contracts/api-keys.js +44 -24
- package/dist/contracts/application-journal.d.ts +216 -0
- package/dist/contracts/application-journal.js +167 -0
- package/dist/contracts/auth.d.ts +90 -17
- package/dist/contracts/auth.js +86 -17
- package/dist/contracts/beta.d.ts +9 -4
- package/dist/contracts/beta.js +20 -16
- package/dist/contracts/billing.js +7 -11
- package/dist/contracts/bootstrap.d.ts +791 -0
- package/dist/contracts/bootstrap.js +51 -0
- package/dist/contracts/builds.d.ts +192 -7
- package/dist/contracts/builds.js +84 -21
- package/dist/contracts/channels.d.ts +43 -0
- package/dist/contracts/channels.js +25 -9
- package/dist/contracts/cli.d.ts +7 -0
- package/dist/contracts/cli.js +6 -0
- package/dist/contracts/collab-public.d.ts +1 -1
- package/dist/contracts/collab-public.js +5 -8
- package/dist/contracts/comments.d.ts +45 -35
- package/dist/contracts/comments.js +107 -77
- package/dist/contracts/commerce.d.ts +165 -0
- package/dist/contracts/commerce.js +146 -0
- package/dist/contracts/common.d.ts +3 -3
- package/dist/contracts/common.js +18 -29
- package/dist/contracts/content-contract-verification.d.ts +521 -0
- package/dist/contracts/content-contract-verification.js +320 -0
- package/dist/contracts/content-platform-fixture.d.ts +1278 -0
- package/dist/contracts/content-platform-fixture.js +44 -0
- package/dist/contracts/content-program.d.ts +994 -0
- package/dist/contracts/content-program.js +658 -0
- package/dist/contracts/content-sync.d.ts +290 -0
- package/dist/contracts/content-sync.js +167 -0
- package/dist/contracts/content.d.ts +432 -0
- package/dist/contracts/content.js +303 -0
- package/dist/contracts/continuation.d.ts +17 -1
- package/dist/contracts/continuation.js +23 -23
- package/dist/contracts/countries.js +3 -4
- package/dist/contracts/crons.d.ts +17 -0
- package/dist/contracts/crons.js +33 -15
- package/dist/contracts/dashboard-prefs.d.ts +56 -0
- package/dist/contracts/dashboard-prefs.js +51 -0
- package/dist/contracts/device-auth.d.ts +234 -37
- package/dist/contracts/device-auth.js +267 -53
- package/dist/contracts/docs.d.ts +6 -10
- package/dist/contracts/docs.js +5 -13
- package/dist/contracts/domains.d.ts +499 -102
- package/dist/contracts/domains.js +169 -58
- package/dist/contracts/email-preferences.d.ts +3 -3
- package/dist/contracts/email-preferences.js +6 -7
- package/dist/contracts/enums.d.ts +26 -26
- package/dist/contracts/enums.js +61 -54
- package/dist/contracts/error-code-meta.d.ts +273 -7
- package/dist/contracts/error-code-meta.js +81 -5
- package/dist/contracts/error-codes.d.ts +5 -5
- package/dist/contracts/error-codes.js +79 -16
- package/dist/contracts/events.d.ts +100 -20
- package/dist/contracts/events.js +107 -20
- package/dist/contracts/execution.d.ts +47 -66
- package/dist/contracts/execution.js +51 -64
- package/dist/contracts/feature-lifecycle.d.ts +70 -14
- package/dist/contracts/feature-lifecycle.js +86 -15
- package/dist/contracts/features.d.ts +100 -37
- package/dist/contracts/features.js +21 -27
- package/dist/contracts/fixtures/content-platform-v1.json +1108 -0
- package/dist/contracts/frame-session.d.ts +192 -0
- package/dist/contracts/frame-session.js +164 -0
- package/dist/contracts/functions.d.ts +218 -211
- package/dist/contracts/functions.js +273 -260
- package/dist/contracts/grant-copy.d.ts +43 -0
- package/dist/contracts/grant-copy.js +44 -0
- package/dist/contracts/grants.d.ts +64 -56
- package/dist/contracts/grants.js +124 -23
- package/dist/contracts/ids.d.ts +4 -1
- package/dist/contracts/ids.js +4 -1
- package/dist/contracts/internal.d.ts +5 -4
- package/dist/contracts/internal.js +12 -3
- package/dist/contracts/mcp.d.ts +17 -0
- package/dist/contracts/mcp.js +23 -0
- package/dist/contracts/me.d.ts +6 -1
- package/dist/contracts/me.js +12 -6
- package/dist/contracts/notifications.d.ts +27 -29
- package/dist/contracts/notifications.js +9 -4
- package/dist/contracts/oauth-resources.d.ts +121 -10
- package/dist/contracts/oauth-resources.js +130 -11
- package/dist/contracts/oauth-scope-actions.d.ts +90 -0
- package/dist/contracts/oauth-scope-actions.js +126 -0
- package/dist/contracts/operations.d.ts +27 -4
- package/dist/contracts/operations.js +11 -5
- package/dist/contracts/pages.d.ts +29 -5
- package/dist/contracts/pages.js +22 -5
- package/dist/contracts/partner-notifications.d.ts +3 -0
- package/dist/contracts/partner-notifications.js +65 -0
- package/dist/contracts/{platform.d.ts → partner.d.ts} +29 -42
- package/dist/contracts/{platform.js → partner.js} +27 -40
- package/dist/contracts/plan-policy.d.ts +1 -1
- package/dist/contracts/principal-assertion.d.ts +43 -0
- package/dist/contracts/principal-assertion.js +67 -0
- package/dist/contracts/principals.d.ts +73 -0
- package/dist/contracts/principals.js +59 -0
- package/dist/contracts/privacy.d.ts +11 -0
- package/dist/contracts/privacy.js +17 -0
- package/dist/contracts/problem-document.js +3 -4
- package/dist/contracts/publish-archive.d.ts +116 -18
- package/dist/contracts/publish-archive.js +6 -3
- package/dist/contracts/push-new.d.ts +4 -4
- package/dist/contracts/quotas.js +3 -3
- package/dist/contracts/realtime.d.ts +52 -0
- package/dist/contracts/realtime.js +54 -0
- package/dist/contracts/repository-connections.d.ts +1 -1
- package/dist/contracts/repository-connections.js +6 -2
- package/dist/contracts/resources.d.ts +105 -14
- package/dist/contracts/resources.js +145 -21
- package/dist/contracts/route-inventory.d.ts +358 -0
- package/dist/contracts/route-inventory.js +141 -0
- package/dist/contracts/runtime-api.d.ts +112 -35
- package/dist/contracts/runtime-api.js +86 -66
- package/dist/contracts/runtime-app.d.ts +11 -21
- package/dist/contracts/runtime-app.js +39 -24
- package/dist/contracts/runtime-components.d.ts +143 -0
- package/dist/contracts/runtime-components.js +199 -0
- package/dist/contracts/runtime-db.d.ts +45 -19
- package/dist/contracts/runtime-db.js +85 -20
- package/dist/contracts/runtime-purge.js +3 -5
- package/dist/contracts/runtime-services.d.ts +43 -75
- package/dist/contracts/runtime-services.js +29 -49
- package/dist/contracts/runtime-storage.d.ts +14 -14
- package/dist/contracts/runtime-storage.js +28 -13
- package/dist/contracts/sf-config-v1.d.ts +14 -18
- package/dist/contracts/slugs.js +13 -4
- package/dist/contracts/space-config.d.ts +235 -28
- package/dist/contracts/space-config.js +246 -91
- package/dist/contracts/spaces.d.ts +360 -255
- package/dist/contracts/spaces.js +190 -122
- package/dist/contracts/superadmin-activity.d.ts +3 -43
- package/dist/contracts/superadmin-activity.js +6 -30
- package/dist/contracts/superadmin-emails.d.ts +1 -0
- package/dist/contracts/superadmin-emails.js +17 -1
- package/dist/contracts/superadmin-runtime.d.ts +199 -0
- package/dist/contracts/superadmin-runtime.js +141 -0
- package/dist/contracts/superadmin-search.d.ts +22 -2
- package/dist/contracts/superadmin-search.js +14 -6
- package/dist/contracts/superadmin-spaces.d.ts +435 -186
- package/dist/contracts/superadmin-spaces.js +131 -25
- package/dist/contracts/superadmin-teams.d.ts +3 -0
- package/dist/contracts/superadmin-teams.js +1 -2
- package/dist/contracts/superadmin-tenants.d.ts +627 -6
- package/dist/contracts/superadmin-tenants.js +32 -7
- package/dist/contracts/superadmin.d.ts +98 -16
- package/dist/contracts/superadmin.js +63 -10
- package/dist/contracts/tags.d.ts +85 -58
- package/dist/contracts/tags.js +44 -34
- package/dist/contracts/teams.d.ts +72 -9
- package/dist/contracts/teams.js +84 -25
- package/dist/contracts/tenants.d.ts +135 -0
- package/dist/contracts/tenants.js +120 -0
- package/dist/contracts/test-triggers.d.ts +70 -0
- package/dist/contracts/test-triggers.js +116 -0
- package/dist/contracts/theme-json.js +3 -8
- package/dist/contracts/transfers.d.ts +1 -0
- package/dist/contracts/transfers.js +1 -0
- package/dist/contracts/usage.d.ts +209 -0
- package/dist/contracts/usage.js +124 -12
- package/dist/contracts/variables.d.ts +2 -2
- package/dist/contracts/variables.js +9 -13
- package/dist/contracts/webhooks.d.ts +13 -5
- package/dist/contracts/webhooks.js +3 -1
- package/dist/contracts/zero.d.ts +57 -64
- package/dist/contracts/zero.js +68 -66
- package/dist/dashboard-paths/index.d.ts +24 -21
- package/dist/dashboard-paths/index.js +35 -47
- package/dist/dashboard-paths/route-reservations.generated.d.ts +2 -0
- package/dist/dashboard-paths/route-reservations.generated.js +36 -0
- package/dist/docs/agent-arrival.d.ts +92 -0
- package/dist/docs/agent-arrival.js +227 -0
- package/dist/docs/agent-output-policy.d.ts +6 -0
- package/dist/docs/agent-output-policy.js +22 -0
- package/dist/docs/agent-prose.d.ts +11 -17
- package/dist/docs/agent-prose.js +62 -37
- package/dist/docs/agent-setup.d.ts +72 -41
- package/dist/docs/agent-setup.js +336 -436
- package/dist/docs/catalog.d.ts +147 -89
- package/dist/docs/catalog.js +157 -42
- package/dist/docs/error-docs.d.ts +2102 -1
- package/dist/docs/error-docs.js +285 -16
- package/dist/docs/index-build.d.ts +0 -1
- package/dist/docs/index-build.js +2 -3
- package/dist/docs/page-context-prompt.d.ts +77 -0
- package/dist/docs/page-context-prompt.js +131 -0
- package/dist/docs/reference-urls.d.ts +46 -0
- package/dist/docs/reference-urls.js +79 -0
- package/dist/docs/search.d.ts +6 -8
- package/dist/docs/search.js +10 -13
- package/dist/docs/skill-distribution.d.ts +4 -1
- package/dist/docs/skill-distribution.js +10 -5
- package/dist/docs/skills.d.ts +117 -117
- package/dist/docs/skills.js +120 -72
- package/dist/docs/start-prompts.d.ts +45 -0
- package/dist/docs/start-prompts.js +62 -0
- package/dist/domain-exploration.js +9 -13
- package/dist/og-template.d.ts +56 -0
- package/dist/og-template.js +56 -0
- package/dist/slug-policy/index.js +5 -11
- package/dist/utils/browser-credential.d.ts +13 -6
- package/dist/utils/browser-credential.js +14 -7
- package/dist/utils/build-settings.d.ts +16 -0
- package/dist/utils/build-settings.js +63 -17
- package/dist/utils/canonical-json.d.ts +3 -5
- package/dist/utils/canonical-json.js +3 -5
- package/dist/utils/cast-transport.d.ts +5 -17
- package/dist/utils/cast-transport.js +6 -19
- package/dist/utils/claim-token.js +1 -2
- package/dist/utils/comment-avatars.js +4 -6
- package/dist/utils/concurrency.js +2 -3
- package/dist/utils/content-type.d.ts +7 -6
- package/dist/utils/content-type.js +73 -51
- package/dist/utils/credential-policy.d.ts +50 -6
- package/dist/utils/credential-policy.js +123 -57
- package/dist/utils/egress-policy.fixtures.json +1 -1
- package/dist/utils/generate-space-name.d.ts +3 -8
- package/dist/utils/generate-space-name.js +3 -8
- package/dist/utils/grants.d.ts +0 -1
- package/dist/utils/grants.js +4 -7
- package/dist/utils/gravatar.d.ts +2 -4
- package/dist/utils/gravatar.js +6 -12
- package/dist/utils/id-hints.js +14 -23
- package/dist/utils/idempotency.d.ts +3 -3
- package/dist/utils/idempotency.js +6 -7
- package/dist/utils/local-space-state.d.ts +15 -15
- package/dist/utils/local-space-state.js +34 -23
- package/dist/utils/oauth-signed-query.d.ts +3 -5
- package/dist/utils/oauth-signed-query.js +6 -9
- package/dist/utils/one-shot-replay.d.ts +3 -5
- package/dist/utils/one-shot-replay.js +3 -5
- package/dist/utils/page-colors.d.ts +4 -10
- package/dist/utils/page-colors.js +11 -35
- package/dist/utils/page-fonts.js +6 -11
- package/dist/utils/page-preview.d.ts +0 -1
- package/dist/utils/page-preview.js +0 -1
- package/dist/utils/pages.d.ts +22 -11
- package/dist/utils/pages.js +70 -30
- package/dist/utils/privacy-regions.d.ts +19 -0
- package/dist/utils/privacy-regions.js +91 -0
- package/dist/utils/publish-form-data.d.ts +4 -5
- package/dist/utils/publish-form-data.js +2 -3
- package/dist/utils/publish-policy.d.ts +10 -23
- package/dist/utils/publish-policy.js +63 -116
- package/dist/utils/query-client.d.ts +2 -0
- package/dist/utils/query-client.js +10 -1
- package/dist/utils/runtime-paths.d.ts +4 -4
- package/dist/utils/runtime-paths.js +6 -8
- package/dist/utils/runtime-upload.d.ts +4 -0
- package/dist/utils/runtime-upload.js +5 -0
- package/dist/utils/secure-local-file.d.ts +3 -3
- package/dist/utils/secure-local-file.js +18 -24
- package/dist/utils/space-config.d.ts +11 -14
- package/dist/utils/space-config.js +10 -16
- package/dist/utils/static-runtime-policy.d.ts +5 -8
- package/dist/utils/static-runtime-policy.generated.d.ts +16 -0
- package/dist/utils/static-runtime-policy.generated.js +70 -0
- package/dist/utils/static-runtime-policy.js +17 -84
- package/dist/utils/storage-policy.js +1 -2
- package/dist/utils/upload-session.js +8 -14
- package/dist/utils/version-path.js +11 -19
- package/dist/utils/wpcom-auth-redirects.d.ts +5 -14
- package/dist/utils/wpcom-auth-redirects.js +1 -4
- package/dist/vocabulary.d.ts +7 -7
- package/dist/vocabulary.js +30 -16
- package/package.json +14 -2
- package/dist/agents/client-registry.d.ts +0 -22
- package/dist/agents/client-registry.js +0 -41
- package/dist/docs/agent-handoff-document.d.ts +0 -15
- package/dist/docs/agent-handoff-document.js +0 -180
- package/dist/docs/agent-solutions.d.ts +0 -110
- package/dist/docs/agent-solutions.js +0 -183
- package/dist/utils/query-keys.d.ts +0 -84
- package/dist/utils/query-keys.js +0 -108
|
@@ -1,57 +1,92 @@
|
|
|
1
1
|
import { webcrypto } from "node:crypto";
|
|
2
2
|
import * as oauth from "oauth4webapi";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { OAUTH_API_RESOURCE_SCOPES, oauthApiResourceUrl } from "../contracts/oauth-resources.js";
|
|
4
5
|
const API_RESOURCE_SCOPES = new Set(OAUTH_API_RESOURCE_SCOPES);
|
|
5
6
|
const INVALID_PRIVATE_KEY_MESSAGE = "SPACEFAST_AGENT_CONFIG private_jwk must be an ES256 P-256 JWK.";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const parsedAgentPrivateJwkSchema = z.object({
|
|
8
|
+
alg: z.string().optional(),
|
|
9
|
+
crv: z.string().optional(),
|
|
10
|
+
d: z.string().optional(),
|
|
11
|
+
ext: z.boolean().optional(),
|
|
12
|
+
key_ops: z.array(z.string()).optional(),
|
|
13
|
+
kid: z.string().optional(),
|
|
14
|
+
kty: z.string().optional(),
|
|
15
|
+
use: z.string().optional(),
|
|
16
|
+
x: z.string().optional(),
|
|
17
|
+
y: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
const agentPrivateJwkSchema = parsedAgentPrivateJwkSchema.transform((parsed) => {
|
|
20
|
+
const jwk = {};
|
|
21
|
+
if (parsed.alg !== undefined)
|
|
22
|
+
jwk.alg = parsed.alg;
|
|
23
|
+
if (parsed.crv !== undefined)
|
|
24
|
+
jwk.crv = parsed.crv;
|
|
25
|
+
if (parsed.d !== undefined)
|
|
26
|
+
jwk.d = parsed.d;
|
|
27
|
+
if (parsed.ext !== undefined)
|
|
28
|
+
jwk.ext = parsed.ext;
|
|
29
|
+
if (parsed.key_ops !== undefined)
|
|
30
|
+
jwk.key_ops = parsed.key_ops;
|
|
31
|
+
if (parsed.kid !== undefined)
|
|
32
|
+
jwk.kid = parsed.kid;
|
|
33
|
+
if (parsed.kty !== undefined)
|
|
34
|
+
jwk.kty = parsed.kty;
|
|
35
|
+
if (parsed.use !== undefined)
|
|
36
|
+
jwk.use = parsed.use;
|
|
37
|
+
if (parsed.x !== undefined)
|
|
38
|
+
jwk.x = parsed.x;
|
|
39
|
+
if (parsed.y !== undefined)
|
|
40
|
+
jwk.y = parsed.y;
|
|
41
|
+
return jwk;
|
|
42
|
+
});
|
|
43
|
+
const bundledAgentAuthConfigSchema = z.object({
|
|
44
|
+
client_id: z.string().optional(),
|
|
45
|
+
token_endpoint: z.string().optional(),
|
|
46
|
+
private_jwk: agentPrivateJwkSchema.optional(),
|
|
47
|
+
scope: z.string().optional(),
|
|
48
|
+
resources: z.array(z.string()).optional(),
|
|
49
|
+
});
|
|
50
|
+
function readBundledAgentAuthConfig(value) {
|
|
15
51
|
if (!value?.trim()) {
|
|
16
52
|
return null;
|
|
17
53
|
}
|
|
18
|
-
|
|
19
|
-
return isRecord(parsed) ? parsed : null;
|
|
54
|
+
return bundledAgentAuthConfigSchema.parse(JSON.parse(value));
|
|
20
55
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
function readPrivateJwk(value) {
|
|
57
|
+
if (!value?.trim()) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return agentPrivateJwkSchema.parse(JSON.parse(value));
|
|
25
61
|
}
|
|
26
|
-
/** Parse private-key agent credentials using the
|
|
62
|
+
/** Parse private-key agent credentials using the bundled-over-split env precedence. */
|
|
27
63
|
export function readAgentAuthConfig(env, apiUrl) {
|
|
28
|
-
const bundled =
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
? bundledPrivateJwk
|
|
32
|
-
: readJsonObject(env.SPACEFAST_AGENT_PRIVATE_JWK);
|
|
33
|
-
const clientId = (typeof bundled?.client_id === "string" ? bundled.client_id : undefined) ??
|
|
34
|
-
env.SPACEFAST_AGENT_CLIENT_ID;
|
|
64
|
+
const bundled = readBundledAgentAuthConfig(env.SPACEFAST_AGENT_CONFIG);
|
|
65
|
+
const privateJwk = bundled?.private_jwk ?? readPrivateJwk(env.SPACEFAST_AGENT_PRIVATE_JWK);
|
|
66
|
+
const clientId = bundled?.client_id ?? env.SPACEFAST_AGENT_CLIENT_ID;
|
|
35
67
|
if (!clientId || !privateJwk) {
|
|
36
68
|
return null;
|
|
37
69
|
}
|
|
38
|
-
const tokenEndpoint =
|
|
70
|
+
const tokenEndpoint = bundled?.token_endpoint ??
|
|
39
71
|
env.SPACEFAST_AGENT_TOKEN_ENDPOINT ??
|
|
40
72
|
`${apiUrl}/v1/auth/oauth2/token`;
|
|
41
|
-
const scope =
|
|
42
|
-
const resources =
|
|
73
|
+
const scope = bundled?.scope ?? env.SPACEFAST_AGENT_SCOPE;
|
|
74
|
+
const resources = bundled?.resources ??
|
|
43
75
|
(env.SPACEFAST_AGENT_RESOURCES
|
|
44
76
|
? env.SPACEFAST_AGENT_RESOURCES.split(",")
|
|
45
77
|
.map((entry) => entry.trim())
|
|
46
78
|
.filter(Boolean)
|
|
47
79
|
: undefined);
|
|
48
|
-
|
|
80
|
+
const config = {
|
|
49
81
|
client_id: clientId,
|
|
50
82
|
token_endpoint: tokenEndpoint,
|
|
51
83
|
private_jwk: privateJwk,
|
|
52
|
-
...(scope ? { scope } : {}),
|
|
53
|
-
...(resources?.length ? { resources } : {}),
|
|
54
84
|
};
|
|
85
|
+
if (scope)
|
|
86
|
+
config.scope = scope;
|
|
87
|
+
if (resources?.length)
|
|
88
|
+
config.resources = resources;
|
|
89
|
+
return config;
|
|
55
90
|
}
|
|
56
91
|
export function resolveAgentApiAuthorization(config, apiUrl) {
|
|
57
92
|
const configuredResources = config.resources;
|
|
@@ -81,10 +116,10 @@ async function privateKeyJwtClientAuth(config, createInvalidConfigError = (messa
|
|
|
81
116
|
}
|
|
82
117
|
try {
|
|
83
118
|
const key = await webcrypto.subtle.importKey("jwk", config.private_jwk, { name: "ECDSA", namedCurve: "P-256" }, false, ["sign"]);
|
|
84
|
-
|
|
85
|
-
key,
|
|
86
|
-
|
|
87
|
-
});
|
|
119
|
+
if (config.private_jwk.kid) {
|
|
120
|
+
return oauth.PrivateKeyJwt({ key, kid: config.private_jwk.kid });
|
|
121
|
+
}
|
|
122
|
+
return oauth.PrivateKeyJwt({ key });
|
|
88
123
|
}
|
|
89
124
|
catch {
|
|
90
125
|
throw createInvalidConfigError(INVALID_PRIVATE_KEY_MESSAGE);
|
|
@@ -139,3 +174,59 @@ export async function exchangeAgentAccessToken(input) {
|
|
|
139
174
|
}
|
|
140
175
|
return { accessToken: tokens.access_token, expiresIn: tokens.expires_in ?? 300 };
|
|
141
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Refresh margin: a token this close to expiry is treated as already gone, so a
|
|
179
|
+
* request never leaves with a credential that dies in flight.
|
|
180
|
+
*/
|
|
181
|
+
const TOKEN_EXPIRY_SKEW_MS = 30_000;
|
|
182
|
+
/**
|
|
183
|
+
* One agent access token held across calls instead of re-exchanged per request.
|
|
184
|
+
*
|
|
185
|
+
* The client-credentials grant is a signed round trip to the token endpoint, and
|
|
186
|
+
* an agent identity issues the same token for the same authorization until it
|
|
187
|
+
* expires: paying for it on every command (the CLI) or every tool call (the MCP
|
|
188
|
+
* server) buys nothing. The cache key is the authorization itself — client,
|
|
189
|
+
* endpoint, and the scope/resources {@link resolveAgentApiAuthorization} settled
|
|
190
|
+
* on — so pointing a process at a second API never replays the first one's
|
|
191
|
+
* bearer.
|
|
192
|
+
*/
|
|
193
|
+
export function createCachedAgentTokenProvider(options) {
|
|
194
|
+
const now = options.now ?? (() => Date.now());
|
|
195
|
+
let cached = null;
|
|
196
|
+
return {
|
|
197
|
+
async accessToken(request) {
|
|
198
|
+
const { resources, scope } = resolveAgentApiAuthorization(request.config, request.apiUrl);
|
|
199
|
+
const key = JSON.stringify({
|
|
200
|
+
client_id: request.config.client_id,
|
|
201
|
+
token_endpoint: request.config.token_endpoint,
|
|
202
|
+
scope,
|
|
203
|
+
resources,
|
|
204
|
+
});
|
|
205
|
+
if (cached?.key === key && cached.expiresAtMs > now() + TOKEN_EXPIRY_SKEW_MS) {
|
|
206
|
+
return cached.accessToken;
|
|
207
|
+
}
|
|
208
|
+
const exchangeInput = {
|
|
209
|
+
apiUrl: request.apiUrl,
|
|
210
|
+
client: request.client,
|
|
211
|
+
config: request.config,
|
|
212
|
+
signal: request.signal,
|
|
213
|
+
createError: options.createError,
|
|
214
|
+
};
|
|
215
|
+
if (options.createInvalidConfigError) {
|
|
216
|
+
exchangeInput.createInvalidConfigError = options.createInvalidConfigError;
|
|
217
|
+
}
|
|
218
|
+
if (options.fetch)
|
|
219
|
+
exchangeInput.fetch = options.fetch;
|
|
220
|
+
const result = await exchangeAgentAccessToken(exchangeInput);
|
|
221
|
+
cached = {
|
|
222
|
+
key,
|
|
223
|
+
accessToken: result.accessToken,
|
|
224
|
+
expiresAtMs: now() + result.expiresIn * 1_000,
|
|
225
|
+
};
|
|
226
|
+
return result.accessToken;
|
|
227
|
+
},
|
|
228
|
+
invalidate() {
|
|
229
|
+
cached = null;
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical, browser-safe agent integration registry.
|
|
3
|
+
*
|
|
4
|
+
* Keep this module free of Node built-ins, filesystem access, and environment
|
|
5
|
+
* reads. Runtime-specific path and config mechanics live in ./node.ts.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_IDS: readonly ["claude-code", "claude-app", "claude-desktop", "cursor", "codex", "chatgpt", "vscode", "github-copilot", "devin-desktop", "devin-cloud", "zed", "gemini-cli", "opencode", "amp", "warp", "factory-droid", "cline", "continue", "raycast", "poke", "pi", "indent", "hermes", "openclaw"];
|
|
8
|
+
export declare const SKILLS_CLI_PACKAGE_SPEC = "skills";
|
|
9
|
+
export declare const SPACEFAST_CLI_PACKAGE_SPEC = "spacefast";
|
|
10
|
+
export declare const PLUGINS_CLI_PACKAGE_SPEC = "plugins";
|
|
11
|
+
/**
|
|
12
|
+
* The complete `-t` target set the universal plugin installer implements.
|
|
13
|
+
* Anything outside this list has no install
|
|
14
|
+
* mechanics upstream: `npx plugins add … -t <id>` either errors or synthesizes a
|
|
15
|
+
* manifest, so `sf plugins` must refuse it rather than run a command that cannot
|
|
16
|
+
* work. Capability flags are NOT a substitute — several entries carry a `plugin`
|
|
17
|
+
* capability because a vendor-native plugin lane exists, not because this
|
|
18
|
+
* installer can drive it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PLUGINS_CLI_INSTALLER_TARGETS: readonly ["claude-code", "cursor", "codex", "github-copilot", "vscode", "grok", "kimi"];
|
|
21
|
+
export type PluginsCliInstallerTarget = (typeof PLUGINS_CLI_INSTALLER_TARGETS)[number];
|
|
22
|
+
export declare const AGENT_DISTRIBUTION_PROFILE: {
|
|
23
|
+
readonly author: {
|
|
24
|
+
readonly name: "Automattic";
|
|
25
|
+
readonly url: "https://spacefast.com";
|
|
26
|
+
};
|
|
27
|
+
readonly description: "Spacefast publishes files and folders to permanent web URLs with immutable versions, scoped access, and resumable MCP workflows.";
|
|
28
|
+
readonly displayName: "Spacefast";
|
|
29
|
+
readonly homepage: "https://spacefast.com";
|
|
30
|
+
readonly keywords: readonly ["spacefast", "publish-to-spacefast", "artifact-sharing", "hosting"];
|
|
31
|
+
readonly license: "MIT";
|
|
32
|
+
readonly name: "spacefast";
|
|
33
|
+
readonly privacyPolicyUrl: "https://automattic.com/privacy/";
|
|
34
|
+
readonly repository: "https://github.com/spacefast/plugins";
|
|
35
|
+
readonly reviewerAccount: {
|
|
36
|
+
readonly environment: "marketplace-reviewers";
|
|
37
|
+
readonly secret: "SPACEFAST_REVIEWER_ACCOUNT";
|
|
38
|
+
};
|
|
39
|
+
readonly shortDescription: "Publish files and folders to the web instantly.";
|
|
40
|
+
readonly termsOfServiceUrl: "https://wordpress.com/tos/";
|
|
41
|
+
};
|
|
42
|
+
export type AgentId = (typeof AGENT_IDS)[number];
|
|
43
|
+
export type AgentAlias = string;
|
|
44
|
+
export type Platform = "darwin" | "linux" | "win32" | "web" | "ios" | "android";
|
|
45
|
+
export type PresentationContext = "interactive-primary" | "terminal-alternates" | "static-docs" | "machine-installer";
|
|
46
|
+
export type AgentCapability = "skills" | "mcp-local" | "mcp-oauth" | "plugin" | "deeplink-only" | "none";
|
|
47
|
+
export type ListingStatus = "live" | "submitted" | "planned";
|
|
48
|
+
export type SkillLane = "curl" | "mcp-only" | "plugin" | "cli";
|
|
49
|
+
export type TokenClass = "api-key" | "handoff" | "oauth-access-token" | "plugin-secret";
|
|
50
|
+
export type RegistryContext = Readonly<{
|
|
51
|
+
apiOrigin: string;
|
|
52
|
+
dashboardOrigin: string;
|
|
53
|
+
mcpEndpoint: string;
|
|
54
|
+
/** Override setup executables when a published artifact requires exact package versions. */
|
|
55
|
+
packageSpecs?: Readonly<{
|
|
56
|
+
skillsCli?: string;
|
|
57
|
+
spacefastCli?: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Origin that serves space git remotes. Optional so existing callers keep
|
|
61
|
+
* working; it falls back to this environment's push origin, which is what
|
|
62
|
+
* every caller would have passed anyway.
|
|
63
|
+
*/
|
|
64
|
+
pushOrigin?: string;
|
|
65
|
+
token?: string;
|
|
66
|
+
wwwOrigin: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* `declared` is what a hand-entered registry row can honestly claim: a human
|
|
70
|
+
* read the vendor source on `checkedAt`. Only the scheduled deeplink probe
|
|
71
|
+
* (scripts/marketplaces/probe-deeplinks.mjs) may write `probed` or `failed`, and
|
|
72
|
+
* a `failed` deeplink is demoted out of `interactive-primary` automatically.
|
|
73
|
+
* There is deliberately no "verified" value: nothing in this file can earn it.
|
|
74
|
+
*/
|
|
75
|
+
export type RegistryVerificationStatus = "declared" | "probed" | "failed";
|
|
76
|
+
export type RegistryVerification = Readonly<{
|
|
77
|
+
checkedAt: string;
|
|
78
|
+
evidence?: string;
|
|
79
|
+
sourceUrl: string;
|
|
80
|
+
status: RegistryVerificationStatus;
|
|
81
|
+
}>;
|
|
82
|
+
export type TokenSlot = Readonly<{
|
|
83
|
+
accepts: readonly TokenClass[];
|
|
84
|
+
location: "command" | "config-value" | "header";
|
|
85
|
+
placeholder: "{{token}}";
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* `checkedAt` is what stops a "soon" chip from aging silently (spec §8.2): the
|
|
89
|
+
* chip copy is date-free, so the age lives on the data and the release parity
|
|
90
|
+
* gate reports listing ages from here.
|
|
91
|
+
*/
|
|
92
|
+
export type MethodListing = Readonly<{
|
|
93
|
+
checkedAt: string;
|
|
94
|
+
status: ListingStatus;
|
|
95
|
+
url?: string;
|
|
96
|
+
}>;
|
|
97
|
+
type MethodBase = Readonly<{
|
|
98
|
+
authLane: "oauth" | "token-slot" | "anonymous";
|
|
99
|
+
availability: Readonly<{
|
|
100
|
+
clients: readonly AgentId[];
|
|
101
|
+
minClientVersion?: string;
|
|
102
|
+
platforms?: readonly Platform[];
|
|
103
|
+
}>;
|
|
104
|
+
docsUrl: string;
|
|
105
|
+
id: string;
|
|
106
|
+
label: string;
|
|
107
|
+
listing: MethodListing;
|
|
108
|
+
rank: Partial<Readonly<Record<PresentationContext, number>>>;
|
|
109
|
+
summary: string;
|
|
110
|
+
tokenSlot?: TokenSlot;
|
|
111
|
+
/** The vendor's own doc for this exact method, rendered beside the summary. */
|
|
112
|
+
vendorDocs?: Readonly<{
|
|
113
|
+
href: string;
|
|
114
|
+
label: string;
|
|
115
|
+
}>;
|
|
116
|
+
verification: RegistryVerification;
|
|
117
|
+
}>;
|
|
118
|
+
export type IntegrationMethod = MethodBase & (Readonly<{
|
|
119
|
+
authPolicy?: "on-install";
|
|
120
|
+
commands: Readonly<{
|
|
121
|
+
inSession: readonly string[];
|
|
122
|
+
shell: readonly string[];
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* Present only when the universal installer can actually drive
|
|
126
|
+
* this client. `sf plugins` and every rendered `npx plugins … -t` command
|
|
127
|
+
* gate on this, never on the `plugin` capability flag.
|
|
128
|
+
*/
|
|
129
|
+
installerTargets?: readonly PluginsCliInstallerTarget[];
|
|
130
|
+
kind: "plugin";
|
|
131
|
+
marketplace?: Readonly<{
|
|
132
|
+
id: string;
|
|
133
|
+
url: string;
|
|
134
|
+
}>;
|
|
135
|
+
}> | Readonly<{
|
|
136
|
+
badge?: Readonly<{
|
|
137
|
+
alt: string;
|
|
138
|
+
url: string;
|
|
139
|
+
}>;
|
|
140
|
+
build: (context: RegistryContext) => string;
|
|
141
|
+
/** Resolved against sibling methods at registry construction; never dangling. */
|
|
142
|
+
fallback: Readonly<{
|
|
143
|
+
id: string;
|
|
144
|
+
kind: IntegrationMethod["kind"];
|
|
145
|
+
}>;
|
|
146
|
+
kind: "deeplink";
|
|
147
|
+
}> | Readonly<{
|
|
148
|
+
build: (context: RegistryContext) => readonly string[];
|
|
149
|
+
kind: "command";
|
|
150
|
+
}> | Readonly<{
|
|
151
|
+
build: (context: RegistryContext) => string;
|
|
152
|
+
kind: "config";
|
|
153
|
+
/** `text` is a value pasted into a client's own settings form, not a file. */
|
|
154
|
+
language: "json" | "jsonc" | "text" | "toml" | "yaml";
|
|
155
|
+
path: string;
|
|
156
|
+
}> | Readonly<{
|
|
157
|
+
build: (context: RegistryContext) => string;
|
|
158
|
+
kind: "prompt";
|
|
159
|
+
}> | Readonly<{
|
|
160
|
+
kind: "download";
|
|
161
|
+
url: (context: RegistryContext) => string;
|
|
162
|
+
}> | Readonly<{
|
|
163
|
+
kind: "skill";
|
|
164
|
+
lane: SkillLane;
|
|
165
|
+
source: Readonly<{
|
|
166
|
+
id: string;
|
|
167
|
+
url: string;
|
|
168
|
+
}>;
|
|
169
|
+
}>);
|
|
170
|
+
export type AgentEntry = Readonly<{
|
|
171
|
+
agentsMd: "native" | "opt-in" | "none";
|
|
172
|
+
aliases: readonly AgentAlias[];
|
|
173
|
+
capabilities: readonly AgentCapability[];
|
|
174
|
+
description: string;
|
|
175
|
+
detectionHints: readonly string[];
|
|
176
|
+
docs: Readonly<{
|
|
177
|
+
spacefast: string;
|
|
178
|
+
vendor: string;
|
|
179
|
+
}>;
|
|
180
|
+
icon: string;
|
|
181
|
+
id: AgentId;
|
|
182
|
+
kind: "coding-agent" | "chat-app" | "mcp-app" | "editor";
|
|
183
|
+
legacyResultAliases: readonly string[];
|
|
184
|
+
machineClient?: boolean;
|
|
185
|
+
methods: readonly IntegrationMethod[];
|
|
186
|
+
monogram: string;
|
|
187
|
+
name: string;
|
|
188
|
+
notes?: readonly string[];
|
|
189
|
+
redeemableClientTargetId?: AgentId;
|
|
190
|
+
skills: Readonly<{
|
|
191
|
+
agentsDirs: boolean;
|
|
192
|
+
claudeDirs: boolean;
|
|
193
|
+
}>;
|
|
194
|
+
tier: "featured" | "listed";
|
|
195
|
+
verification: RegistryVerification;
|
|
196
|
+
vendor: string;
|
|
197
|
+
wizardGroup: "claude" | "openai" | "coding-agents" | "personal-agents" | "mcp-apps" | "prompt-first" | null;
|
|
198
|
+
}>;
|
|
199
|
+
export type PresentedMethod = Readonly<{
|
|
200
|
+
/**
|
|
201
|
+
* `disabled` is the registry's own answer for a method that has nothing to
|
|
202
|
+
* copy yet (a planned marketplace listing whose install command does not exist).
|
|
203
|
+
* Consumers render the "soon" chip from this; they never gate on an empty string.
|
|
204
|
+
*/
|
|
205
|
+
action: Readonly<{
|
|
206
|
+
kind: "copy" | "disabled" | "download" | "link";
|
|
207
|
+
label: string;
|
|
208
|
+
value: string;
|
|
209
|
+
}>;
|
|
210
|
+
docsUrl: string;
|
|
211
|
+
fallbackMethodId?: string;
|
|
212
|
+
id: string;
|
|
213
|
+
kind: IntegrationMethod["kind"];
|
|
214
|
+
label: string;
|
|
215
|
+
/** The fence language for `action.value`, so renderers never re-derive it. */
|
|
216
|
+
language: "bash" | "json" | "jsonc" | "text" | "toml" | "yaml";
|
|
217
|
+
listing: MethodListing;
|
|
218
|
+
/** Where the value goes: a config file path, or the client's own settings screen. */
|
|
219
|
+
path?: string;
|
|
220
|
+
rank: number;
|
|
221
|
+
summary: string;
|
|
222
|
+
vendorDocs?: Readonly<{
|
|
223
|
+
href: string;
|
|
224
|
+
label: string;
|
|
225
|
+
}>;
|
|
226
|
+
}>;
|
|
227
|
+
export type PresentedAgentEntry = Omit<AgentEntry, "methods"> & Readonly<{
|
|
228
|
+
methods: readonly PresentedMethod[];
|
|
229
|
+
/** The no-session, no-mint lane: docs pages and the machine artifacts. */
|
|
230
|
+
staticDocs: readonly PresentedMethod[];
|
|
231
|
+
terminalAlternates: readonly PresentedMethod[];
|
|
232
|
+
}>;
|
|
233
|
+
export declare const AGENTS_MD_SPACEFAST_START = "<!-- SPACEFAST START -->";
|
|
234
|
+
export declare const AGENTS_MD_SPACEFAST_END = "<!-- SPACEFAST END -->";
|
|
235
|
+
export declare const AGENTS_MD_SPACEFAST_SNIPPET: string;
|
|
236
|
+
export declare const SOURCE_LANES: readonly [{
|
|
237
|
+
readonly id: "drop";
|
|
238
|
+
readonly label: "Drop files";
|
|
239
|
+
readonly description: "Drop a folder or archive and put it live now.";
|
|
240
|
+
readonly href: "/drop";
|
|
241
|
+
readonly icon: "upload";
|
|
242
|
+
}, {
|
|
243
|
+
readonly id: "push";
|
|
244
|
+
readonly label: "Push directly";
|
|
245
|
+
readonly description: "Push a Git repository to Spacefast and publish every update.";
|
|
246
|
+
readonly href: "/push";
|
|
247
|
+
readonly icon: "git";
|
|
248
|
+
}, {
|
|
249
|
+
readonly id: "github";
|
|
250
|
+
readonly label: "Connect a GitHub repository";
|
|
251
|
+
readonly description: "Connect GitHub and build and publish on every push.";
|
|
252
|
+
readonly href: "https://spacefast.com/docs/builds";
|
|
253
|
+
readonly icon: "github";
|
|
254
|
+
}, {
|
|
255
|
+
readonly id: "terminal";
|
|
256
|
+
readonly label: "Command line";
|
|
257
|
+
readonly description: "Publish from the terminal with the Spacefast CLI.";
|
|
258
|
+
readonly href: "/start?step=terminal";
|
|
259
|
+
readonly icon: "terminal";
|
|
260
|
+
}, {
|
|
261
|
+
readonly id: "api";
|
|
262
|
+
readonly label: "API";
|
|
263
|
+
readonly description: "Publish or automate with the REST API and OpenAPI.";
|
|
264
|
+
readonly href: "https://spacefast.com/docs/api";
|
|
265
|
+
readonly icon: "api";
|
|
266
|
+
}];
|
|
267
|
+
/**
|
|
268
|
+
* The generic hosted-MCP entry, for any client whose config is an `mcpServers`
|
|
269
|
+
* map. `type: "http"` is load-bearing and not decoration: Claude Code rejects a
|
|
270
|
+
* bare `{ url }` outright and VS Code reads one as a stdio command, so a bare
|
|
271
|
+
* url is not a smaller version of this — it is a broken version of it.
|
|
272
|
+
*/
|
|
273
|
+
export declare function hostedMcpServersConfig(context: RegistryContext): string;
|
|
274
|
+
export declare const AGENT_REGISTRY: readonly AgentEntry[];
|
|
275
|
+
export declare function getAgentEntry(id: AgentId): AgentEntry;
|
|
276
|
+
export declare function resolveAgentId(value: string): AgentId | null;
|
|
277
|
+
/**
|
|
278
|
+
* The ranking rule, as a pure function so the demote path is testable without a
|
|
279
|
+
* registry entry: a deeplink whose last probe failed is dropped from the
|
|
280
|
+
* interactive lane, and everything else sorts by its per-context rank.
|
|
281
|
+
*/
|
|
282
|
+
export declare function methodsForContext(methods: readonly IntegrationMethod[], context: PresentationContext): readonly IntegrationMethod[];
|
|
283
|
+
export declare function agentMethodsForContext(agentId: AgentId, context: PresentationContext): readonly IntegrationMethod[];
|
|
284
|
+
/**
|
|
285
|
+
* The `sf plugins` gate. Returns the universal-installer targets this agent can
|
|
286
|
+
* actually be installed into — empty for every agent whose plugin lane is
|
|
287
|
+
* vendor-native or not live, including entries that carry a `plugin` capability.
|
|
288
|
+
*/
|
|
289
|
+
export declare function pluginInstallerTargetsFor(agentId: AgentId): readonly PluginsCliInstallerTarget[];
|
|
290
|
+
export declare function presentAgentEntry(agentId: AgentId, context: RegistryContext): PresentedAgentEntry;
|
|
291
|
+
export declare function base64Utf8(value: string): string;
|
|
292
|
+
export {};
|