@sentropic/artifacts 0.2.22 → 0.2.23

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.23
4
+
5
+ - `createGitHubForge` resolves a branch through `GET /repos/{owner}/{repo}/git/ref/heads/{branch}`
6
+ (each ref segment encoded on its own, so `artifact/p/<id>/<app>` keeps its slashes) and reads the
7
+ exact `refs/heads/<branch>` commit `object.sha`; a full 40-hex commit SHA goes straight to
8
+ `/commits/<sha>`. Another registered ref (a tag, an abbreviated SHA) that is not a branch still
9
+ resolves through `/commits/{ref}` (per-segment encoding); an `artifact/` branch never does.
10
+ - An absent ref is `missing` on every lookup: GitHub answers 422 « No commit found » (not 404) for an
11
+ unknown ref, and that 422 no longer maps to `conflict`/`git_ref_not_allowed`. `resolveRef` on the
12
+ bound branch reports `git_branch_missing` and `artifacts_git_attach` now treats it as an absent
13
+ branch, so a new personal branch is created from `baseRef` instead of failing the attach.
14
+ `createBranch` on an existing branch stays `conflict`.
15
+ - `ARTIFACTS_PROVIDER_VERSION` follows the package (0.2.23): the APP-P1 manifest digest changes through
16
+ its version field only (four-tool selection and tool definitions unchanged).
17
+
3
18
  ## 0.2.22
4
19
 
5
20
  - Generic live invitations through MCP (A-LIVE v2 §8.2, §9): four tools appended last and frozen at
@@ -8,9 +8,38 @@ const sha = (value) => {
8
8
  throw new GitForgeError('unavailable');
9
9
  return value;
10
10
  };
11
+ /** GitHub answers 422 « No commit found » (not 404) for an unknown ref: both mean absent, never a ref refusal. */
12
+ async function absentAsMissing(request) {
13
+ try {
14
+ return await request;
15
+ }
16
+ catch (error) {
17
+ if (error instanceof GitForgeError && (error.code === 'missing' || error.code === 'conflict'))
18
+ throw new GitForgeError('missing');
19
+ throw error;
20
+ }
21
+ }
11
22
  /** Fixed public GitHub origins. The SG0-net host owns network admission and egress receipts. */
12
23
  export function createGitHubForge(fetcher = globalThis.fetch) {
13
24
  const api = githubApi(fetcher);
25
+ /** Each ref segment is encoded on its own so « artifact/p/x » keeps its path slashes. */
26
+ const segments = (ref) => ref.split('/').map(encodeURIComponent).join('/');
27
+ /** Exact branch lookup first; artifact branches never resolve as anything else. */
28
+ async function refHead(context, ref) {
29
+ try {
30
+ const result = await absentAsMissing(api(context, `/git/ref/heads/${segments(ref)}`));
31
+ if (result?.ref !== `refs/heads/${ref}` || result?.object?.type !== 'commit')
32
+ throw new GitForgeError('unavailable');
33
+ return sha(result.object.sha);
34
+ }
35
+ catch (error) {
36
+ if (ref.startsWith('artifact/') || !(error instanceof GitForgeError && error.code === 'missing'))
37
+ throw error;
38
+ }
39
+ // Registered sources may also be read at a tag or an abbreviated commit SHA (docs/git-port.md).
40
+ const result = await absentAsMissing(api(context, `/commits/${segments(ref)}`));
41
+ return sha(result?.sha);
42
+ }
14
43
  return {
15
44
  async repositoryId(context) {
16
45
  const result = await api(context, '');
@@ -20,8 +49,9 @@ export function createGitHubForge(fetcher = globalThis.fetch) {
20
49
  return String(result.id);
21
50
  },
22
51
  async resolve(context, ref) {
23
- const result = await api(context, `/commits/${encodeURIComponent(ref)}`);
24
- if (!Array.isArray(result?.parents) || typeof result?.commit?.message !== 'string' ||
52
+ const commitSha = /^[0-9a-f]{40}$/.test(ref) ? ref : await refHead(context, ref);
53
+ const result = await absentAsMissing(api(context, `/commits/${commitSha}`));
54
+ if (result?.sha !== commitSha || !Array.isArray(result?.parents) || typeof result?.commit?.message !== 'string' ||
25
55
  [result.commit.author, result.commit.committer].some(person => typeof person?.name !== 'string' || typeof person?.email !== 'string')) {
26
56
  throw new GitForgeError('unavailable');
27
57
  }
@@ -10,7 +10,7 @@ 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.22";
13
+ export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.23";
14
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", "artifacts_live_invite", "artifacts_live_accept_invitation", "artifacts_live_revoke_invitation", "artifacts_live_invitations"];
15
15
  export type ArtifactsToolName = (typeof ARTIFACTS_TOOL_NAMES)[number];
16
16
  export interface ArtifactsToolDefinition {
package/dist/mcp-core.js CHANGED
@@ -7,7 +7,7 @@ export * from './profile/index.js';
7
7
  export { createRadarKeyDerivation } from './server/command-identity.js';
8
8
  export const ARTIFACTS_PROVIDER_ID = 'sentropic.artifacts';
9
9
  export const ARTIFACTS_APP_ID = 'sentropic-artifacts';
10
- export const ARTIFACTS_PROVIDER_VERSION = '0.2.22';
10
+ export const ARTIFACTS_PROVIDER_VERSION = '0.2.23';
11
11
  export const ARTIFACTS_TOOL_NAMES = ARTIFACT_CAPABILITY_NAMES;
12
12
  // ---------------------------------------------------------------------------
13
13
  // Byte-stable tool definitions (MCP tool-definition stability rule).
@@ -5,7 +5,9 @@ import { validateGitBindingTarget } from './git-registry.js';
5
5
  import { requireCodeRight, requireOwner } from './git-tools-publish.js';
6
6
  const FIELDS = ['repoId', 'branch', 'baseRef', 'subPath', 'autoPublish', 'executor', 'pause'];
7
7
  const id8 = (value) => createHash('sha256').update(value).digest('hex').slice(0, 8);
8
- const notFound = (error) => error instanceof ArtifactOperationError && error.kind === 'not_found';
8
+ /** The git port reports an absent bound branch as git_branch_missing and any other absent ref as not_found. */
9
+ const notFound = (error) => error instanceof ArtifactOperationError &&
10
+ (error.kind === 'not_found' || error.kind === 'git_branch_missing');
9
11
  /** G0 v3 §1.2 Tool 3 / A-LIVE S03: attach, configure, pause, resume or detach one binding. */
10
12
  export async function attachGit(deps, args, inv) {
11
13
  await requireOwner(deps, inv, args.artifactId, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentropic/artifacts",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "Generic configurable artifacts MCP and artifact service: StorageScope/Artifact/Binding/Release model, canonical manifests, object authorization, idempotent intents (spec-v8 §9).",
5
5
  "type": "module",
6
6
  "license": "MIT",