@sentropic/artifacts 0.2.17 → 0.2.18
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/CHANGELOG.md +18 -0
- package/dist/adapters/github-forge.d.ts +4 -0
- package/dist/adapters/github-forge.js +88 -0
- package/dist/adapters/github-git-port.d.ts +5 -0
- package/dist/adapters/github-git-port.js +102 -0
- package/dist/adapters/github-http.d.ts +5 -0
- package/dist/adapters/github-http.js +57 -0
- package/dist/adapters/github-receive-pack.d.ts +4 -0
- package/dist/adapters/github-receive-pack.js +49 -0
- package/dist/adapters/postgres-git-bindings.d.ts +7 -0
- package/dist/adapters/postgres-git-bindings.js +110 -0
- package/dist/adapters/postgres-live.d.ts +4 -0
- package/dist/adapters/postgres-live.js +97 -0
- package/dist/adapters/postgres.d.ts +1 -0
- package/dist/adapters/postgres.js +1 -0
- package/dist/git-tool-definitions.d.ts +606 -0
- package/dist/git-tool-definitions.js +14 -0
- package/dist/http.d.ts +6 -0
- package/dist/http.js +20 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/mcp-core.d.ts +3 -3
- package/dist/mcp-core.js +15 -2
- package/dist/profile/contracts.d.ts +1 -1
- package/dist/profile/contracts.js +4 -0
- package/dist/profile/index.js +8 -1
- package/dist/profile/schemas.js +19 -0
- package/dist/profile/validation.js +5 -1
- package/dist/server/build-contract.d.ts +64 -0
- package/dist/server/build-contract.js +58 -0
- package/dist/server/build-dependencies.d.ts +3 -0
- package/dist/server/build-dependencies.js +122 -0
- package/dist/server/consent-grant.d.ts +91 -0
- package/dist/server/consent-grant.js +89 -0
- package/dist/server/consent-screen.d.ts +21 -0
- package/dist/server/consent-screen.js +52 -0
- package/dist/server/failures.d.ts +3 -2
- package/dist/server/failures.js +30 -0
- package/dist/server/git-bindings.d.ts +8 -0
- package/dist/server/git-bindings.js +113 -0
- package/dist/server/git-contracts.d.ts +98 -0
- package/dist/server/git-contracts.js +1 -0
- package/dist/server/git-port-policy.d.ts +9 -0
- package/dist/server/git-port-policy.js +76 -0
- package/dist/server/git-port-read.d.ts +3 -0
- package/dist/server/git-port-read.js +95 -0
- package/dist/server/git-port-session.d.ts +38 -0
- package/dist/server/git-port-session.js +59 -0
- package/dist/server/git-port-tree.d.ts +8 -0
- package/dist/server/git-port-tree.js +92 -0
- package/dist/server/git-port-write.d.ts +6 -0
- package/dist/server/git-port-write.js +102 -0
- package/dist/server/git-port.d.ts +147 -0
- package/dist/server/git-port.js +8 -0
- package/dist/server/git-projection.d.ts +16 -0
- package/dist/server/git-projection.js +20 -0
- package/dist/server/git-registry.d.ts +37 -0
- package/dist/server/git-registry.js +39 -0
- package/dist/server/live-body.d.ts +3 -0
- package/dist/server/live-body.js +28 -0
- package/dist/server/live-commit-outcome.d.ts +6 -0
- package/dist/server/live-commit-outcome.js +10 -0
- package/dist/server/live-commit.d.ts +11 -0
- package/dist/server/live-commit.js +133 -0
- package/dist/server/live-contracts.d.ts +62 -0
- package/dist/server/live-contracts.js +8 -0
- package/dist/server/live-crypto.d.ts +14 -0
- package/dist/server/live-crypto.js +50 -0
- package/dist/server/live-drafts.d.ts +61 -0
- package/dist/server/live-drafts.js +119 -0
- package/dist/server/live-errors.d.ts +23 -0
- package/dist/server/live-errors.js +9 -0
- package/dist/server/live-mutations.d.ts +18 -0
- package/dist/server/live-mutations.js +83 -0
- package/dist/server/live-read.d.ts +15 -0
- package/dist/server/live-read.js +95 -0
- package/dist/server/live-service.d.ts +3 -0
- package/dist/server/live-service.js +181 -0
- package/dist/server/live-store.d.ts +111 -0
- package/dist/server/live-store.js +80 -0
- package/dist/server/live-tree.d.ts +22 -0
- package/dist/server/live-tree.js +148 -0
- package/dist/server/live-worker.d.ts +10 -0
- package/dist/server/live-worker.js +55 -0
- package/migrations/0010_git_bindings.sql +82 -0
- package/migrations/0011_live_drafts.sql +42 -0
- package/package.json +13 -1
package/dist/http.js
CHANGED
|
@@ -19,6 +19,9 @@ import { ArtifactOperationError, classifyArtifactFailure } from './server/failur
|
|
|
19
19
|
import { projectArtifactHttpOutcome } from './server/outcome-projection.js';
|
|
20
20
|
import { readArtifactSource } from './server/source-read.js';
|
|
21
21
|
import { artifactSummary } from './server/summary.js';
|
|
22
|
+
import { projectGitBinding } from './server/git-projection.js';
|
|
23
|
+
import { isLiveBodyStream, readBoundedLiveJson } from './server/live-body.js';
|
|
24
|
+
import { LiveCommitUnknownError } from './server/live-commit-outcome.js';
|
|
22
25
|
import { artifactVersions } from './server/versions.js';
|
|
23
26
|
import { manageArtifact } from './server/management.js';
|
|
24
27
|
import { createPostgresManagementUnit } from './adapters/postgres-management.js';
|
|
@@ -46,7 +49,8 @@ export function assertArtifactsTransportProfile(value) {
|
|
|
46
49
|
'artifacts_lookup_people', 'artifacts_list_access',
|
|
47
50
|
'artifacts_create_upload', 'artifacts_commit_upload', 'artifacts_publish_bundle',
|
|
48
51
|
'artifacts_create_upload_page', 'artifacts_list_assets', 'artifacts_publish_bundle_v2',
|
|
49
|
-
'artifacts_revoke_reader_consent'
|
|
52
|
+
'artifacts_revoke_reader_consent', 'artifacts_git_commit', 'artifacts_live_write',
|
|
53
|
+
'artifacts_live_read', 'artifacts_live_reset', 'artifacts_live_status', 'artifacts_live_control'];
|
|
50
54
|
if (value.selectedCapabilities.some((name) => !supported.includes(name))) {
|
|
51
55
|
throw new Error('unsupported artifacts transport capability');
|
|
52
56
|
}
|
|
@@ -527,7 +531,8 @@ export function createHttpArtifactApp(deps) {
|
|
|
527
531
|
args = { artifactId: request.path.slice(getPrefix.length) };
|
|
528
532
|
}
|
|
529
533
|
else {
|
|
530
|
-
args =
|
|
534
|
+
args = (capability.startsWith('artifacts_live_') || capability === 'artifacts_git_commit') && isLiveBodyStream(request.body)
|
|
535
|
+
? await readBoundedLiveJson(request.body, operation) : { ...object(request.body ?? {}) };
|
|
531
536
|
if (Object.hasOwn(args, 'storageScopeId')) {
|
|
532
537
|
if (args.storageScopeId !== invocation.storageScopeId)
|
|
533
538
|
throw new ArtifactProfileInputError();
|
|
@@ -535,6 +540,15 @@ export function createHttpArtifactApp(deps) {
|
|
|
535
540
|
}
|
|
536
541
|
}
|
|
537
542
|
const normalized = profile.validate(capability, args, request.idempotencyKey, { deferPrecondition: true });
|
|
543
|
+
if (capability.startsWith('artifacts_live_') || capability === 'artifacts_git_commit') {
|
|
544
|
+
if (!deps.live)
|
|
545
|
+
throw new ArtifactOperationError('capability_unselected');
|
|
546
|
+
phase = 'dispatch';
|
|
547
|
+
const result = await deps.live.execute(operation, normalized, invocation);
|
|
548
|
+
return { ok: true, invocationId: invocation.invocationId,
|
|
549
|
+
commitState: ['live_read', 'live_status'].includes(operation) ? 'not_committed' : 'committed',
|
|
550
|
+
replayed: result.replayed === true, result: { status: 200, body: result } };
|
|
551
|
+
}
|
|
538
552
|
const command = ['artifacts_ensure', 'artifacts_publish', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
|
|
539
553
|
'artifacts_commit_upload', 'artifacts_publish_bundle', 'artifacts_publish_bundle_v2'].includes(capability)
|
|
540
554
|
? createArtifactCommand(profile, capability, args, invocation, deps.derivation, request.idempotencyKey, { deferPrecondition: true }) : undefined;
|
|
@@ -1011,6 +1025,8 @@ export function createHttpArtifactApp(deps) {
|
|
|
1011
1025
|
result: { status: 200, body: { ...await projectSummary(artifactSummary({ artifactId, acl, state, current,
|
|
1012
1026
|
actorId: invocation.actorId, urls: deps.publicationUrls, approved: deps.isApprovedAccount,
|
|
1013
1027
|
policy: await sharingPolicyContext(invocation.storageScopeId) }), invocation.storageScopeId),
|
|
1028
|
+
...await projectGitBinding(deps.git, { artifactId, storageScopeId: invocation.storageScopeId,
|
|
1029
|
+
actorId: invocation.actorId, ownerId: acl.ownerId }),
|
|
1014
1030
|
...(acl.metadata !== undefined ? { metadata: acl.metadata } : {}),
|
|
1015
1031
|
...(acl.ownerId === invocation.actorId
|
|
1016
1032
|
? { grants: await projectGrants(acl.grants, invocation.storageScopeId) } : {}) } } };
|
|
@@ -1110,6 +1126,8 @@ export function createHttpArtifactApp(deps) {
|
|
|
1110
1126
|
artifacts: visibleArtifacts.slice(offset, offset + normalized.limit) } } };
|
|
1111
1127
|
}
|
|
1112
1128
|
catch (cause) {
|
|
1129
|
+
if (cause instanceof LiveCommitUnknownError)
|
|
1130
|
+
commitState = 'unknown';
|
|
1113
1131
|
const failure = classifyArtifactFailure(cause, { invocationId: invocation?.invocationId ?? '',
|
|
1114
1132
|
operation, phase, commitState }, (error) => error instanceof ArtifactProfileInputError
|
|
1115
1133
|
? new ArtifactOperationError(error.category, { publicDetails: error.details }) : deps.mapHostError?.(error));
|
package/dist/index.d.ts
CHANGED
|
@@ -27,4 +27,17 @@ export * from './server/commit-contract.js';
|
|
|
27
27
|
export * from './server/outcome-contract.js';
|
|
28
28
|
export * from './server/source-read.js';
|
|
29
29
|
export * from './server/management.js';
|
|
30
|
+
export * from './server/git-bindings.js';
|
|
31
|
+
export * from './server/git-registry.js';
|
|
32
|
+
export * from './server/git-projection.js';
|
|
30
33
|
export * from './adapters/postgres-management.js';
|
|
34
|
+
export * from './server/git-port.js';
|
|
35
|
+
export type { GitPortOptions } from './server/git-port-session.js';
|
|
36
|
+
export { GitPortAdvanceUnknown } from './server/git-port-session.js';
|
|
37
|
+
export * from './adapters/github-git-port.js';
|
|
38
|
+
export * from './adapters/github-forge.js';
|
|
39
|
+
export * from './server/live-service.js';
|
|
40
|
+
export * from './server/live-drafts.js';
|
|
41
|
+
export * from './server/live-errors.js';
|
|
42
|
+
export * from './adapters/postgres-live.js';
|
|
43
|
+
export * from './server/live-body.js';
|
package/dist/index.js
CHANGED
|
@@ -31,4 +31,16 @@ export * from './server/commit-contract.js';
|
|
|
31
31
|
export * from './server/outcome-contract.js';
|
|
32
32
|
export * from './server/source-read.js';
|
|
33
33
|
export * from './server/management.js';
|
|
34
|
+
export * from './server/git-bindings.js';
|
|
35
|
+
export * from './server/git-registry.js';
|
|
36
|
+
export * from './server/git-projection.js';
|
|
34
37
|
export * from './adapters/postgres-management.js';
|
|
38
|
+
export * from './server/git-port.js';
|
|
39
|
+
export { GitPortAdvanceUnknown } from './server/git-port-session.js';
|
|
40
|
+
export * from './adapters/github-git-port.js';
|
|
41
|
+
export * from './adapters/github-forge.js';
|
|
42
|
+
export * from './server/live-service.js';
|
|
43
|
+
export * from './server/live-drafts.js';
|
|
44
|
+
export * from './server/live-errors.js';
|
|
45
|
+
export * from './adapters/postgres-live.js';
|
|
46
|
+
export * from './server/live-body.js';
|
package/dist/mcp-core.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
|
10
10
|
export type { ArtifactKeyDerivationBinding } from './server/command-identity.js';
|
|
11
11
|
export declare const ARTIFACTS_PROVIDER_ID = "sentropic.artifacts";
|
|
12
12
|
export declare const ARTIFACTS_APP_ID = "sentropic-artifacts";
|
|
13
|
-
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.
|
|
14
|
-
export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2"];
|
|
13
|
+
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.18";
|
|
14
|
+
export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2", "artifacts_list_app_sources", "artifacts_fetch_app_source", "artifacts_git_attach", "artifacts_git_commit", "artifacts_git_publish", "artifacts_git_live", "artifacts_live_write", "artifacts_live_read", "artifacts_live_reset", "artifacts_live_status", "artifacts_live_control"];
|
|
15
15
|
export type ArtifactsToolName = (typeof ARTIFACTS_TOOL_NAMES)[number];
|
|
16
16
|
export interface ArtifactsToolDefinition {
|
|
17
17
|
readonly description: string;
|
|
@@ -24,7 +24,7 @@ export interface ArtifactsToolDefinition {
|
|
|
24
24
|
/** Static wire definitions for every artifacts tool; identical across deployments and profiles. */
|
|
25
25
|
export declare const ARTIFACTS_TOOL_DEFINITIONS: Readonly<Record<ArtifactsToolName, ArtifactsToolDefinition>>;
|
|
26
26
|
export declare const ARTIFACTS_TOOL_SPECS: {
|
|
27
|
-
name: "artifacts_get_template" | "artifacts_get_api_guide" | "artifacts_ensure" | "artifacts_publish" | "artifacts_create_upload" | "artifacts_commit_upload" | "artifacts_list" | "artifacts_get" | "artifacts_get_source" | "artifacts_fork" | "artifacts_set_access" | "artifacts_promote" | "artifacts_renew" | "artifacts_delete" | "artifacts_restore" | "artifacts_list_versions" | "artifacts_revert" | "artifacts_lookup_people" | "artifacts_list_access" | "artifacts_publish_bundle" | "artifacts_revoke_reader_consent" | "artifacts_create_upload_page" | "artifacts_list_assets" | "artifacts_publish_bundle_v2";
|
|
27
|
+
name: "artifacts_get_template" | "artifacts_get_api_guide" | "artifacts_ensure" | "artifacts_publish" | "artifacts_create_upload" | "artifacts_commit_upload" | "artifacts_list" | "artifacts_get" | "artifacts_get_source" | "artifacts_fork" | "artifacts_set_access" | "artifacts_promote" | "artifacts_renew" | "artifacts_delete" | "artifacts_restore" | "artifacts_list_versions" | "artifacts_revert" | "artifacts_lookup_people" | "artifacts_list_access" | "artifacts_publish_bundle" | "artifacts_revoke_reader_consent" | "artifacts_create_upload_page" | "artifacts_list_assets" | "artifacts_publish_bundle_v2" | "artifacts_list_app_sources" | "artifacts_fetch_app_source" | "artifacts_git_attach" | "artifacts_git_commit" | "artifacts_git_publish" | "artifacts_git_live" | "artifacts_live_write" | "artifacts_live_read" | "artifacts_live_reset" | "artifacts_live_status" | "artifacts_live_control";
|
|
28
28
|
description: string;
|
|
29
29
|
mutability: import("@sentropic/mcp-platform").Mutability;
|
|
30
30
|
}[];
|
package/dist/mcp-core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertArtifactsTransportProfile } from './http.js';
|
|
2
|
+
import { GIT_TOOL_DEFINITIONS } from './git-tool-definitions.js';
|
|
2
3
|
import { ARTIFACT_CAPABILITY_NAMES, ArtifactProfileInputError } from './profile/index.js';
|
|
3
4
|
import { ArtifactOperationError, classifyArtifactFailure } from './server/failures.js';
|
|
4
5
|
import { projectArtifactHttpOutcome, projectArtifactMcpOutcome } from './server/outcome-projection.js';
|
|
@@ -6,7 +7,7 @@ export * from './profile/index.js';
|
|
|
6
7
|
export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
7
8
|
export const ARTIFACTS_PROVIDER_ID = 'sentropic.artifacts';
|
|
8
9
|
export const ARTIFACTS_APP_ID = 'sentropic-artifacts';
|
|
9
|
-
export const ARTIFACTS_PROVIDER_VERSION = '0.2.
|
|
10
|
+
export const ARTIFACTS_PROVIDER_VERSION = '0.2.18';
|
|
10
11
|
export const ARTIFACTS_TOOL_NAMES = ARTIFACT_CAPABILITY_NAMES;
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
// Byte-stable tool definitions (MCP tool-definition stability rule).
|
|
@@ -46,9 +47,12 @@ const edit = obj({ path, oldStr: str, newStr: { type: 'string' } }, ['path', 'ol
|
|
|
46
47
|
const idOnly = obj({ artifactId: id }, ['artifactId']);
|
|
47
48
|
const ARTIFACTS_OUTPUT_SCHEMA = { type: 'object', additionalProperties: true };
|
|
48
49
|
const READ_ONLY_TOOLS = ['artifacts_list', 'artifacts_get',
|
|
50
|
+
'artifacts_list_app_sources', 'artifacts_fetch_app_source', 'artifacts_live_read', 'artifacts_live_status',
|
|
49
51
|
'artifacts_get_template', 'artifacts_get_api_guide', 'artifacts_get_source', 'artifacts_list_versions',
|
|
50
52
|
'artifacts_lookup_people', 'artifacts_list_access', 'artifacts_list_assets'];
|
|
51
53
|
const IDEMPOTENT_WRITERS = ['artifacts_ensure', 'artifacts_publish',
|
|
54
|
+
'artifacts_git_attach', 'artifacts_git_commit', 'artifacts_git_publish', 'artifacts_git_live',
|
|
55
|
+
'artifacts_live_write', 'artifacts_live_reset', 'artifacts_live_control',
|
|
52
56
|
'artifacts_commit_upload', 'artifacts_publish_bundle', 'artifacts_publish_bundle_v2',
|
|
53
57
|
'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
|
|
54
58
|
'artifacts_revoke_reader_consent'];
|
|
@@ -59,7 +63,7 @@ function staticTool(name, inputSchema, description) {
|
|
|
59
63
|
outputSchema: ARTIFACTS_OUTPUT_SCHEMA,
|
|
60
64
|
mutability: READ_ONLY_TOOLS.includes(name) ? 'read-only'
|
|
61
65
|
: name === 'artifacts_publish' || name === 'artifacts_publish_bundle' ||
|
|
62
|
-
name === 'artifacts_publish_bundle_v2' ? 'append' : 'state-transition',
|
|
66
|
+
name === 'artifacts_publish_bundle_v2' || name === 'artifacts_git_publish' ? 'append' : 'state-transition',
|
|
63
67
|
idempotency: IDEMPOTENT_WRITERS.includes(name) ? { required: true, scope: 'principal' } : { required: false },
|
|
64
68
|
gates: { requiresElicitation: false, requiresHumanConfirmation: name === 'artifacts_delete',
|
|
65
69
|
requiresPrincipalGate: false },
|
|
@@ -67,6 +71,7 @@ function staticTool(name, inputSchema, description) {
|
|
|
67
71
|
}
|
|
68
72
|
/** Static wire definitions for every artifacts tool; identical across deployments and profiles. */
|
|
69
73
|
export const ARTIFACTS_TOOL_DEFINITIONS = {
|
|
74
|
+
...GIT_TOOL_DEFINITIONS,
|
|
70
75
|
artifacts_get_template: staticTool('artifacts_get_template', obj({ templateId: str }, ['templateId'])),
|
|
71
76
|
artifacts_get_api_guide: staticTool('artifacts_get_api_guide', obj({ version: str })),
|
|
72
77
|
artifacts_ensure: staticTool('artifacts_ensure', obj({ bindingName: str, parameters: obj({}),
|
|
@@ -208,6 +213,14 @@ export function createArtifactsToolExecutor(deps) {
|
|
|
208
213
|
const args = profile.validate(input.tool, input.args, input.idempotencyKey, { deferPrecondition: true });
|
|
209
214
|
let request;
|
|
210
215
|
switch (input.tool) {
|
|
216
|
+
case 'artifacts_live_write':
|
|
217
|
+
case 'artifacts_live_read':
|
|
218
|
+
case 'artifacts_live_reset':
|
|
219
|
+
case 'artifacts_live_status':
|
|
220
|
+
case 'artifacts_live_control':
|
|
221
|
+
case 'artifacts_git_commit':
|
|
222
|
+
request = { method: 'POST', path: '/' + input.tool.slice(10), body: args };
|
|
223
|
+
break;
|
|
211
224
|
case 'artifacts_ensure':
|
|
212
225
|
request = { method: 'POST', path: '/ensure', body: args };
|
|
213
226
|
break;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JsonValue } from '../contracts.js';
|
|
2
2
|
import type { EffectiveArtifactCommand } from '../server/command-identity.js';
|
|
3
3
|
export declare const PROFILE_CONTRACT_VERSION: "artifacts-profile/v1";
|
|
4
|
-
export declare const ARTIFACT_CAPABILITY_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2"];
|
|
4
|
+
export declare const ARTIFACT_CAPABILITY_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2", "artifacts_list_app_sources", "artifacts_fetch_app_source", "artifacts_git_attach", "artifacts_git_commit", "artifacts_git_publish", "artifacts_git_live", "artifacts_live_write", "artifacts_live_read", "artifacts_live_reset", "artifacts_live_status", "artifacts_live_control"];
|
|
5
5
|
export type ArtifactCapabilityName = (typeof ARTIFACT_CAPABILITY_NAMES)[number];
|
|
6
6
|
export type ArtifactSchema = Readonly<Record<string, unknown>>;
|
|
7
7
|
export interface OperationProfile {
|
|
@@ -12,6 +12,10 @@ export const ARTIFACT_CAPABILITY_NAMES = [
|
|
|
12
12
|
'artifacts_create_upload_page',
|
|
13
13
|
'artifacts_list_assets',
|
|
14
14
|
'artifacts_publish_bundle_v2',
|
|
15
|
+
'artifacts_list_app_sources', 'artifacts_fetch_app_source',
|
|
16
|
+
'artifacts_git_attach', 'artifacts_git_commit', 'artifacts_git_publish', 'artifacts_git_live',
|
|
17
|
+
'artifacts_live_write', 'artifacts_live_read', 'artifacts_live_reset',
|
|
18
|
+
'artifacts_live_status', 'artifacts_live_control',
|
|
15
19
|
];
|
|
16
20
|
/** Projection fields are data-only; invocation correlation is added by L6. */
|
|
17
21
|
export const PRECONDITION_REQUIRED_MESSAGE = 'expectedCurrentReleaseId is required by the active artifact profile. Re-read this artifact with artifacts_get or artifacts_list, then send expectedCurrentReleaseId using the currentReleaseId returned by that read. Send null only if the read confirms that there is no current release. Before editing an existing release, read it with artifacts_get_source and use that releaseId. The server will not infer this value.';
|
package/dist/profile/index.js
CHANGED
|
@@ -125,7 +125,9 @@ export function compileArtifactsProfile(input) {
|
|
|
125
125
|
throw new Error('profile/schema default mismatch');
|
|
126
126
|
}
|
|
127
127
|
if (['artifacts_ensure', 'artifacts_publish', 'artifacts_commit_upload', 'artifacts_publish_bundle',
|
|
128
|
-
'artifacts_publish_bundle_v2', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert'
|
|
128
|
+
'artifacts_publish_bundle_v2', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
|
|
129
|
+
'artifacts_git_attach', 'artifacts_git_commit', 'artifacts_git_publish', 'artifacts_git_live',
|
|
130
|
+
'artifacts_live_write', 'artifacts_live_reset', 'artifacts_live_control'].includes(name)) {
|
|
129
131
|
idempotency[name] = { required: true, scope: 'principal' };
|
|
130
132
|
}
|
|
131
133
|
}
|
|
@@ -146,6 +148,11 @@ export function compileArtifactsProfile(input) {
|
|
|
146
148
|
},
|
|
147
149
|
capabilityForRoute(method, path) {
|
|
148
150
|
let name;
|
|
151
|
+
const gitRoutes = ['list_app_sources', 'fetch_app_source', 'git_attach', 'git_commit', 'git_publish',
|
|
152
|
+
'live_write', 'live_read', 'live_reset', 'live_status', 'live_control'];
|
|
153
|
+
if (method === 'POST' && gitRoutes.some(route => path === '/' + route)) {
|
|
154
|
+
name = `artifacts_${path.slice(1)}`;
|
|
155
|
+
}
|
|
149
156
|
if (method === 'POST' && path === '/ensure')
|
|
150
157
|
name = 'artifacts_ensure';
|
|
151
158
|
if (method === 'POST' && path === '/publish')
|
package/dist/profile/schemas.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SERVER_MAX_FILE_BYTES, SERVER_MAX_FILES_PER_RELEASE, SERVER_MAX_TOTAL_BYTES } from '../server/publication-limits.js';
|
|
2
|
+
import { GIT_TOOL_DEFINITIONS } from '../git-tool-definitions.js';
|
|
2
3
|
const str = { type: 'string', minLength: 1 };
|
|
3
4
|
const integer = (minimum, maximum) => ({ type: 'integer', minimum,
|
|
4
5
|
...(maximum === undefined ? {} : { maximum }) });
|
|
@@ -16,6 +17,13 @@ const metadata = {
|
|
|
16
17
|
/** Required configuration includes semantic limits absent from JSON Schema. */
|
|
17
18
|
export function assertCompleteOperation(config) {
|
|
18
19
|
const required = {
|
|
20
|
+
git_attach: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
21
|
+
git_commit: { limits: ['idempotencyKeyMaxUnits', 'gitMessageMaxUnits'], defaults: [] },
|
|
22
|
+
git_publish: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
23
|
+
git_live: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
24
|
+
live_write: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
25
|
+
live_reset: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
26
|
+
live_control: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
|
|
19
27
|
ensure: { limits: ['bindingNameMinUnits', 'bindingNameMaxUnits', 'idempotencyKeyMaxUnits'],
|
|
20
28
|
defaults: ['parameters'] },
|
|
21
29
|
// publish additionally accepts the optional release-budget keys
|
|
@@ -55,6 +63,17 @@ export function capabilitySchema(name, profile) {
|
|
|
55
63
|
const part1 = profile.profileRevisionId === undefined || profile.resultEnvelopeVersion === 2;
|
|
56
64
|
const config = operationProfile(profile, operation);
|
|
57
65
|
const limits = config.limits;
|
|
66
|
+
if (Object.hasOwn(GIT_TOOL_DEFINITIONS, name)) {
|
|
67
|
+
const definition = GIT_TOOL_DEFINITIONS[name];
|
|
68
|
+
const schema = structuredClone(definition.inputSchema);
|
|
69
|
+
if (schema.properties.idempotencyKey)
|
|
70
|
+
schema.properties.idempotencyKey.maxLength = limits.idempotencyKeyMaxUnits;
|
|
71
|
+
if (schema.properties.message)
|
|
72
|
+
schema.properties.message.maxLength = limits.gitMessageMaxUnits;
|
|
73
|
+
if (schema.properties.cursor)
|
|
74
|
+
schema.properties.cursor.maxLength = 4096;
|
|
75
|
+
return schema;
|
|
76
|
+
}
|
|
58
77
|
const key = { type: 'string', minLength: 1, maxLength: limits.idempotencyKeyMaxUnits,
|
|
59
78
|
description: 'Nonblank by JavaScript trim(); length is UTF-16 units; original bytes retained.' };
|
|
60
79
|
const idOnly = obj({ artifactId: id }, ['artifactId']);
|
|
@@ -103,7 +103,8 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
|
|
|
103
103
|
const { defaults, limits } = operationProfile(profile, operation);
|
|
104
104
|
const normalized = { ...copyJson(defaults), ...args };
|
|
105
105
|
if (['ensure', 'publish', 'commit_upload', 'publish_bundle', 'publish_bundle_v2',
|
|
106
|
-
'set_access', 'delete', 'revert'
|
|
106
|
+
'set_access', 'delete', 'revert', 'git_attach', 'git_commit', 'git_publish', 'git_live',
|
|
107
|
+
'live_write', 'live_reset', 'live_control'].includes(operation)) {
|
|
107
108
|
const key = args.idempotencyKey;
|
|
108
109
|
requireInput(typeof key === 'string' && key.trim().length > 0 && key.length <= limits.idempotencyKeyMaxUnits);
|
|
109
110
|
requireInput(envelopeKey === undefined || envelopeKey === key);
|
|
@@ -112,6 +113,9 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
|
|
|
112
113
|
requireInput(envelopeKey === undefined);
|
|
113
114
|
if (Object.hasOwn(args, 'artifactId'))
|
|
114
115
|
requireInput(isArtifactId(args.artifactId));
|
|
116
|
+
if (operation === 'git_commit')
|
|
117
|
+
requireInput(typeof args.message === 'string' &&
|
|
118
|
+
args.message.trim().length > 0 && args.message.length <= limits.gitMessageMaxUnits);
|
|
115
119
|
if (operation === 'get_source' && args.paths !== undefined) {
|
|
116
120
|
const paths = args.paths;
|
|
117
121
|
requireInput(new Set(paths).size === paths.length && paths.every((path) => Buffer.byteLength(path, 'utf8') <= profile.rules.pathMaxBytes));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Frozen G0 v3 §4.1 fields. Install permissions belong to the host. */
|
|
2
|
+
export interface ArtifactBuildDescriptor {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly buildScript: string;
|
|
5
|
+
readonly outputDir: string;
|
|
6
|
+
readonly lockfilePath: string;
|
|
7
|
+
readonly entry?: string;
|
|
8
|
+
readonly publicEnvNames?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface PostinstallAllowlistEntry {
|
|
11
|
+
readonly package: string;
|
|
12
|
+
readonly version: string;
|
|
13
|
+
readonly integrity: string;
|
|
14
|
+
}
|
|
15
|
+
/** Host supplies files from one exact SHA, rooted at the repository, never the live draft. */
|
|
16
|
+
export interface ArtifactBuildSnapshot {
|
|
17
|
+
readonly subPath: string;
|
|
18
|
+
readonly files: Readonly<Record<string, string>>;
|
|
19
|
+
readonly postinstallAllowlist?: readonly PostinstallAllowlistEntry[];
|
|
20
|
+
readonly allowedRegistries?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface ArtifactBuildTuple {
|
|
23
|
+
readonly commitSha: string;
|
|
24
|
+
readonly treeSha: string;
|
|
25
|
+
readonly lockfileDigest: string;
|
|
26
|
+
readonly descriptorDigest: string;
|
|
27
|
+
readonly builderImageDigest: string;
|
|
28
|
+
readonly nodeVersion: string;
|
|
29
|
+
readonly npmVersion: string;
|
|
30
|
+
readonly publicEnvHashes: Readonly<Record<string, string>>;
|
|
31
|
+
}
|
|
32
|
+
export interface ArtifactBuildCandidate {
|
|
33
|
+
readonly candidateDigest: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ArtifactBuildReceipt extends ArtifactBuildCandidate {
|
|
36
|
+
readonly jobId: string;
|
|
37
|
+
readonly tuple: ArtifactBuildTuple;
|
|
38
|
+
readonly releaseId: string;
|
|
39
|
+
readonly manifestDigest: string;
|
|
40
|
+
readonly executor: 'caller' | 'ci' | 'sandbox';
|
|
41
|
+
readonly producer: {
|
|
42
|
+
readonly runId: string;
|
|
43
|
+
readonly attempt: number;
|
|
44
|
+
};
|
|
45
|
+
readonly verification: 'declared' | 'sha-verified' | 'builder-attested';
|
|
46
|
+
}
|
|
47
|
+
export declare function buildRecord(value: unknown): value is Record<string, unknown>;
|
|
48
|
+
export declare function buildJson(text: string | undefined): Record<string, unknown>;
|
|
49
|
+
export declare function buildPath(value: unknown): value is string;
|
|
50
|
+
/** Validation only: no filesystem, network, install, shell or script execution. */
|
|
51
|
+
export declare function validateArtifactBuild(snapshot: ArtifactBuildSnapshot): {
|
|
52
|
+
readonly descriptor: ArtifactBuildDescriptor;
|
|
53
|
+
readonly installDirectory: string;
|
|
54
|
+
readonly scriptDirectory: string;
|
|
55
|
+
readonly install: {
|
|
56
|
+
readonly command: "npm";
|
|
57
|
+
readonly args: readonly ["ci", "--ignore-scripts"];
|
|
58
|
+
};
|
|
59
|
+
readonly build: {
|
|
60
|
+
readonly command: "npm";
|
|
61
|
+
readonly args: readonly ["run", string];
|
|
62
|
+
};
|
|
63
|
+
readonly postinstall: readonly PostinstallAllowlistEntry[];
|
|
64
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ArtifactOperationError } from './failures.js';
|
|
2
|
+
import { validateBuildDependencies } from './build-dependencies.js';
|
|
3
|
+
export function buildRecord(value) {
|
|
4
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
export function buildJson(text) {
|
|
7
|
+
try {
|
|
8
|
+
const value = JSON.parse(text ?? '');
|
|
9
|
+
if (buildRecord(value))
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
catch { /* Refuse malformed input without exposing source bytes. */ }
|
|
13
|
+
throw new ArtifactOperationError('build_descriptor_invalid');
|
|
14
|
+
}
|
|
15
|
+
export function buildPath(value) {
|
|
16
|
+
return typeof value === 'string' && value.length > 0
|
|
17
|
+
&& !/[\\\u0000-\u001f\u007f:%?#]/.test(value)
|
|
18
|
+
&& value.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..');
|
|
19
|
+
}
|
|
20
|
+
const join = (root, path) => root ? `${root}/${path}` : path;
|
|
21
|
+
/** Validation only: no filesystem, network, install, shell or script execution. */
|
|
22
|
+
export function validateArtifactBuild(snapshot) {
|
|
23
|
+
const invalid = () => { throw new ArtifactOperationError('build_descriptor_invalid'); };
|
|
24
|
+
if (snapshot.subPath !== '' && !buildPath(snapshot.subPath))
|
|
25
|
+
invalid();
|
|
26
|
+
const value = buildJson(snapshot.files[join(snapshot.subPath, 'sentropic.artifact.json')]);
|
|
27
|
+
const fields = ['version', 'buildScript', 'outputDir', 'lockfilePath', 'entry', 'publicEnvNames'];
|
|
28
|
+
if (Object.keys(value).some(key => !fields.includes(key)) || value.version !== 1
|
|
29
|
+
|| typeof value.buildScript !== 'string' || !/^[A-Za-z0-9:_-]+$/.test(value.buildScript)
|
|
30
|
+
|| value.buildScript.trim() !== value.buildScript
|
|
31
|
+
|| !buildPath(value.outputDir) || !buildPath(value.lockfilePath)
|
|
32
|
+
|| (value.entry !== undefined && !buildPath(value.entry))
|
|
33
|
+
|| (value.publicEnvNames !== undefined && (!Array.isArray(value.publicEnvNames)
|
|
34
|
+
|| value.publicEnvNames.some(name => typeof name !== 'string' || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)
|
|
35
|
+
|| name.trim() !== name))))
|
|
36
|
+
invalid();
|
|
37
|
+
const descriptor = value;
|
|
38
|
+
const manifest = buildJson(snapshot.files[join(snapshot.subPath, 'package.json')]);
|
|
39
|
+
const script = buildRecord(manifest.scripts) && Object.hasOwn(manifest.scripts, descriptor.buildScript)
|
|
40
|
+
? manifest.scripts[descriptor.buildScript] : undefined;
|
|
41
|
+
if (typeof script !== 'string' || !script.trim())
|
|
42
|
+
throw new ArtifactOperationError('build_script_missing');
|
|
43
|
+
if (!Object.hasOwn(snapshot.files, descriptor.lockfilePath))
|
|
44
|
+
throw new ArtifactOperationError('lock_missing');
|
|
45
|
+
const lock = buildJson(snapshot.files[descriptor.lockfilePath]);
|
|
46
|
+
const installDirectory = descriptor.lockfilePath.includes('/')
|
|
47
|
+
? descriptor.lockfilePath.slice(0, descriptor.lockfilePath.lastIndexOf('/')) : '';
|
|
48
|
+
if (installDirectory && snapshot.subPath !== installDirectory
|
|
49
|
+
&& !snapshot.subPath.startsWith(`${installDirectory}/`))
|
|
50
|
+
invalid();
|
|
51
|
+
const postinstall = validateBuildDependencies(snapshot, lock, installDirectory);
|
|
52
|
+
return {
|
|
53
|
+
descriptor, installDirectory, scriptDirectory: snapshot.subPath,
|
|
54
|
+
install: { command: 'npm', args: ['ci', '--ignore-scripts'] },
|
|
55
|
+
build: { command: 'npm', args: ['run', descriptor.buildScript] },
|
|
56
|
+
postinstall,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ArtifactBuildSnapshot, PostinstallAllowlistEntry } from './build-contract.js';
|
|
2
|
+
/** Validate the lock-indexed install closure, including host-owned lifecycle permissions. */
|
|
3
|
+
export declare function validateBuildDependencies(snapshot: ArtifactBuildSnapshot, lock: Record<string, unknown>, installDirectory: string): readonly PostinstallAllowlistEntry[];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ArtifactOperationError } from './failures.js';
|
|
2
|
+
import { buildJson, buildPath, buildRecord } from './build-contract.js';
|
|
3
|
+
const sections = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
|
4
|
+
function refuse() { throw new ArtifactOperationError('dep_outside_lock'); }
|
|
5
|
+
function registryUrl(value, registries) {
|
|
6
|
+
if (typeof value !== 'string')
|
|
7
|
+
return false;
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(value);
|
|
10
|
+
return url.protocol === 'https:' && !url.username && !url.password && !url.hash && !url.search
|
|
11
|
+
&& registries.some(registry => {
|
|
12
|
+
const base = new URL(registry.endsWith('/') ? registry : `${registry}/`);
|
|
13
|
+
return base.protocol === 'https:' && !base.username && !base.password
|
|
14
|
+
&& url.origin === base.origin && url.pathname.startsWith(base.pathname);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function registrySpec(value) {
|
|
22
|
+
if (typeof value !== 'string' || !value.trim())
|
|
23
|
+
return false;
|
|
24
|
+
const alias = /^npm:(?:@[^/]+\/)?[^@]+@(.+)$/.exec(value);
|
|
25
|
+
return /^[A-Za-z0-9~^*<>=| .+-]+$/.test(alias ? alias[1] : value);
|
|
26
|
+
}
|
|
27
|
+
/** Validate the lock-indexed install closure, including host-owned lifecycle permissions. */
|
|
28
|
+
export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
29
|
+
if ((lock.lockfileVersion !== 2 && lock.lockfileVersion !== 3) || !buildRecord(lock.packages)
|
|
30
|
+
|| !buildRecord(lock.packages['']))
|
|
31
|
+
throw new ArtifactOperationError('build_descriptor_invalid');
|
|
32
|
+
const packages = lock.packages;
|
|
33
|
+
const lockedPackage = (path, name) => {
|
|
34
|
+
let directory = path;
|
|
35
|
+
for (;;) {
|
|
36
|
+
if (Object.hasOwn(packages, `${directory ? `${directory}/` : ''}node_modules/${name}`))
|
|
37
|
+
return true;
|
|
38
|
+
if (!directory)
|
|
39
|
+
return false;
|
|
40
|
+
directory = directory.includes('/') ? directory.slice(0, directory.lastIndexOf('/')) : '';
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const registries = snapshot.allowedRegistries ?? ['https://registry.npmjs.org/'];
|
|
44
|
+
const allowlist = snapshot.postinstallAllowlist ?? [];
|
|
45
|
+
const postinstall = [];
|
|
46
|
+
const repositoryPath = (path) => installDirectory ? `${installDirectory}/${path}` : path;
|
|
47
|
+
const workspaceTargets = new Set();
|
|
48
|
+
for (const [path, raw] of Object.entries(packages)) {
|
|
49
|
+
if (!buildRecord(raw) || (path !== '' && !buildPath(path))
|
|
50
|
+
|| (raw.hasInstallScript !== undefined && typeof raw.hasInstallScript !== 'boolean'))
|
|
51
|
+
refuse();
|
|
52
|
+
if (raw.link === true) {
|
|
53
|
+
if (!path.includes('node_modules/') || !buildPath(raw.resolved)
|
|
54
|
+
|| raw.resolved.split('/').includes('node_modules') || !buildRecord(packages[raw.resolved])
|
|
55
|
+
|| !Object.hasOwn(snapshot.files, repositoryPath(`${raw.resolved}/package.json`)))
|
|
56
|
+
refuse();
|
|
57
|
+
workspaceTargets.add(raw.resolved);
|
|
58
|
+
const workspace = buildJson(snapshot.files[repositoryPath(`${raw.resolved}/package.json`)]);
|
|
59
|
+
if (path.split('node_modules/').at(-1) !== workspace.name)
|
|
60
|
+
refuse();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const [path, raw] of Object.entries(packages)) {
|
|
64
|
+
if (!buildRecord(raw))
|
|
65
|
+
refuse();
|
|
66
|
+
if (raw.link === true)
|
|
67
|
+
continue;
|
|
68
|
+
const local = path === '' || workspaceTargets.has(path);
|
|
69
|
+
if (!local && (!registryUrl(raw.resolved, registries) || typeof raw.version !== 'string'
|
|
70
|
+
|| !/^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/.test(raw.version)
|
|
71
|
+
|| typeof raw.integrity !== 'string' || !raw.integrity))
|
|
72
|
+
refuse();
|
|
73
|
+
const manifestPath = repositoryPath(path ? `${path}/package.json` : 'package.json');
|
|
74
|
+
const manifest = local ? buildJson(snapshot.files[manifestPath]) : raw;
|
|
75
|
+
for (const source of [raw, manifest]) {
|
|
76
|
+
for (const section of sections) {
|
|
77
|
+
const dependencies = source[section];
|
|
78
|
+
if (dependencies === undefined)
|
|
79
|
+
continue;
|
|
80
|
+
if (!buildRecord(dependencies))
|
|
81
|
+
refuse();
|
|
82
|
+
for (const [name, spec] of Object.entries(dependencies)) {
|
|
83
|
+
if (!registrySpec(spec) || !/^(?:@[A-Za-z0-9._-]+\/)?[A-Za-z0-9._-]+$/.test(name))
|
|
84
|
+
refuse();
|
|
85
|
+
if ((section === 'dependencies' || (local && section === 'devDependencies'))
|
|
86
|
+
&& !lockedPackage(path, name))
|
|
87
|
+
refuse();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// npm ci must not resolve an edited workspace manifest beyond its committed lock entry.
|
|
92
|
+
if (local) {
|
|
93
|
+
for (const section of sections) {
|
|
94
|
+
const declared = manifest[section];
|
|
95
|
+
const locked = raw[section];
|
|
96
|
+
if (declared === undefined && locked === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
if (!buildRecord(declared) || !buildRecord(locked)
|
|
99
|
+
|| Object.keys(declared).length !== Object.keys(locked).length
|
|
100
|
+
|| Object.entries(declared).some(([name, spec]) => locked[name] !== spec))
|
|
101
|
+
refuse();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const scripts = buildRecord(manifest.scripts) ? manifest.scripts : {};
|
|
105
|
+
const hasScript = raw.hasInstallScript === true
|
|
106
|
+
|| ['preinstall', 'install', 'postinstall', 'prepare'].some(name => Object.hasOwn(scripts, name));
|
|
107
|
+
if (!hasScript)
|
|
108
|
+
continue;
|
|
109
|
+
const name = typeof raw.name === 'string' ? raw.name : path.split('node_modules/').at(-1);
|
|
110
|
+
const entry = { package: local ? manifest.name : name, version: raw.version, integrity: raw.integrity };
|
|
111
|
+
if (typeof entry.package !== 'string' || typeof entry.version !== 'string' || typeof entry.integrity !== 'string'
|
|
112
|
+
|| !entry.integrity || !allowlist.some(allowed => allowed.package === entry.package
|
|
113
|
+
&& allowed.version === entry.version && allowed.integrity === entry.integrity)) {
|
|
114
|
+
throw new ArtifactOperationError('install_script_not_allowlisted');
|
|
115
|
+
}
|
|
116
|
+
postinstall.push({ package: entry.package, version: entry.version, integrity: entry.integrity });
|
|
117
|
+
}
|
|
118
|
+
const scriptKey = snapshot.subPath.slice(installDirectory ? installDirectory.length + 1 : 0);
|
|
119
|
+
if (scriptKey && !workspaceTargets.has(scriptKey))
|
|
120
|
+
refuse();
|
|
121
|
+
return postinstall;
|
|
122
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic host binding for persistent reader consent
|
|
3
|
+
* (design-merged §4.1, §4.3). Thin host binding over the generic
|
|
4
|
+
* ArtifactReaderStore, scoped to one storage scope per service instance: the
|
|
5
|
+
* reader revokes only their own consents resolved from the verified session
|
|
6
|
+
* (never a body field); a platform admin may revoke any reader's consent
|
|
7
|
+
* (incident response, never grant); the artifact owner cannot revoke consent
|
|
8
|
+
* — the owner's instrument is share revocation. Revoking for an unreadable
|
|
9
|
+
* artifact reads `not_found`, never 403, so the existence oracle stays closed.
|
|
10
|
+
*/
|
|
11
|
+
import { type FreshRights, type GateBDecision } from './consent.js';
|
|
12
|
+
import type { ArtifactReaderStore } from './reader-store.js';
|
|
13
|
+
export { consentScreenPath, renderConsentScreen, type ConsentScreenParams } from './consent-screen.js';
|
|
14
|
+
/** Stable first-party grant refusal; hosts return this body with HTTP 403. */
|
|
15
|
+
export interface ReaderConsentRequired {
|
|
16
|
+
code: 'reader_consent_required';
|
|
17
|
+
scopeId: string;
|
|
18
|
+
retryable: false;
|
|
19
|
+
}
|
|
20
|
+
export declare function readerConsentRequired(scopeId: string): ReaderConsentRequired;
|
|
21
|
+
export interface ConsentGrantInput {
|
|
22
|
+
readerAccountId: string;
|
|
23
|
+
artifactId: string;
|
|
24
|
+
scopeId: string;
|
|
25
|
+
scopeVersion: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ConsentRevokeInput {
|
|
28
|
+
readerAccountId: string;
|
|
29
|
+
artifactId: string;
|
|
30
|
+
scopeId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface GateCheckInput {
|
|
33
|
+
readerAccountId: string;
|
|
34
|
+
artifactId: string;
|
|
35
|
+
scopeId: string;
|
|
36
|
+
scopeVersion: string;
|
|
37
|
+
rights: FreshRights;
|
|
38
|
+
}
|
|
39
|
+
export declare function createReaderConsentService(deps: {
|
|
40
|
+
store: ArtifactReaderStore;
|
|
41
|
+
storageScopeId: string;
|
|
42
|
+
canReadArtifact: (artifactId: string, readerAccountId: string) => Promise<boolean>;
|
|
43
|
+
isAdmin: (accountId: string) => Promise<boolean>;
|
|
44
|
+
resolveTitle?: (artifactId: string) => Promise<string | undefined>;
|
|
45
|
+
now?: () => string;
|
|
46
|
+
}): {
|
|
47
|
+
/**
|
|
48
|
+
* First-party grant with a locked fresh-rights re-check: the host's
|
|
49
|
+
* checkRights (immo getRights) runs immediately before the store write,
|
|
50
|
+
* under the host's own authority discipline.
|
|
51
|
+
*/
|
|
52
|
+
grantWithFreshRights(input: ConsentGrantInput, checkRights: () => Promise<boolean>): Promise<import("./consent.js").ReaderConsentRecord>;
|
|
53
|
+
/**
|
|
54
|
+
* J1.3b — fresh-rights probe for the first-party grant route: the same
|
|
55
|
+
* readability check the service was built with, so the grant route never
|
|
56
|
+
* invents its own authority rule.
|
|
57
|
+
*/
|
|
58
|
+
checkReaderFreshRights(input: {
|
|
59
|
+
readerAccountId: string;
|
|
60
|
+
artifactId: string;
|
|
61
|
+
}): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* J1.3b — Gate B for the generic reader gate route: live consent at the
|
|
64
|
+
* host-declared version plus fresh rights, evaluated on this call.
|
|
65
|
+
*/
|
|
66
|
+
evaluateGate(input: GateCheckInput): Promise<GateBDecision>;
|
|
67
|
+
listOwnConsents(readerAccountId: string): Promise<{
|
|
68
|
+
artifactId: string;
|
|
69
|
+
title: string;
|
|
70
|
+
scopeId: string;
|
|
71
|
+
scopeVersion: string;
|
|
72
|
+
grantedAt: string;
|
|
73
|
+
}[]>;
|
|
74
|
+
revokeOwnConsent(input: ConsentRevokeInput): Promise<{
|
|
75
|
+
changed: boolean;
|
|
76
|
+
revokedAt: string | null;
|
|
77
|
+
}>;
|
|
78
|
+
revokeAllOwnConsents(input: Omit<ConsentRevokeInput, 'scopeId'>): Promise<{
|
|
79
|
+
changed: boolean;
|
|
80
|
+
revoked: number;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Platform-admin incident revocation. The admin never grants (reduce-only,
|
|
84
|
+
* mirroring canManageAccess); the artifact owner is refused here.
|
|
85
|
+
*/
|
|
86
|
+
adminRevokeConsent(input: ConsentRevokeInput, adminAccountId: string): Promise<{
|
|
87
|
+
changed: boolean;
|
|
88
|
+
revokedAt: string | null;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
export type ReaderConsentService = ReturnType<typeof createReaderConsentService>;
|