@jini-ai/agent-plugins 0.7.3-next.1 → 0.7.3-next.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/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## 0.7.2
2
+
1
3
  ## 0.7.1
2
4
 
3
5
  ## 0.7.0
@@ -99,6 +99,7 @@ export interface PluginHostDeps<UninstallInput, Layout extends AgentPluginLayout
99
99
  /** @agent-note Your app's id; it is the namespace of every plugin identity this host reads and
100
100
  * admits, so it must not change between installs. */
101
101
  readonly namespace: string;
102
+ readonly legacySiteIdentityNamespace?: string;
102
103
  /** @agent-note Provider: the site-runtime plugin discovery owner. Metadata only, fresh per call. */
103
104
  readonly discoverPlugins: () => Promise<readonly PluginHostDiscoveryRecord[]>;
104
105
  /** @agent-note Provider: the site-runtime activation repo point read (same repo the runtime uses). */
@@ -29,7 +29,7 @@ async function listSiteProviders({ deps, forAdmission }) {
29
29
  }
30
30
  let parsed;
31
31
  try {
32
- parsed = readPluginIdentity({ manifest: record.manifest, name: record.id, namespace: deps.namespace });
32
+ parsed = readPluginIdentity({ manifest: record.manifest, name: record.id, namespace: deps.namespace, legacyNamespace: deps.legacySiteIdentityNamespace });
33
33
  }
34
34
  catch {
35
35
  warn(`Plugin '${record.id}': installed identity manifest is unreadable or invalid; omitted from metadata lookup.`);
@@ -1,7 +1,7 @@
1
1
  import { type AgentToolSideEffect, type ToolRegistration, type AgentToolDefinition } from "@jini-ai/core";
2
2
  import type { AgentPluginSearchCandidate } from "../search.js";
3
3
  import { type PluginMaturity } from "./identity.js";
4
- import type { AgentPluginHostToolPorts, HostToolMessages } from "./ports.js";
4
+ import type { AgentPluginHostToolPorts, HostToolMessages, RequireHostToolPermission } from "./ports.js";
5
5
  /** The narrow slice of the route-deps bag this tool's handler reads — only a workspace id, since
6
6
  * everything else it needs (`listInstalledPlugins`, `readAgentPluginActivations`) is resolved from
7
7
  * that id alone via `layout.ts`. Declared structurally, mirroring `PluginsToolDeps`'s own shape, so
@@ -70,5 +70,7 @@ export declare const agentPluginSearchDerivedRisk: ReadonlyMap<string, AgentTool
70
70
  * @complexity O(1) to build; see {@link loadAgentPluginSearchCandidates} and
71
71
  * {@link selectAgentPluginSearchCandidates} for the handler's per-call cost.
72
72
  */
73
- export declare function buildAgentPluginSearchRegistrations(routeDeps: AgentPluginSearchToolDeps, _optional?: Record<string, never>): ToolRegistration[];
73
+ export declare function buildAgentPluginSearchRegistrations(routeDeps: AgentPluginSearchToolDeps & {
74
+ requirePermission: RequireHostToolPermission;
75
+ }, _optional?: Record<string, never>): ToolRegistration[];
74
76
  //# sourceMappingURL=search-tool.d.ts.map
@@ -218,6 +218,7 @@ export function buildAgentPluginSearchRegistrations(routeDeps, _optional = {}) {
218
218
  const input = requireInputRecord({ input: ctx.input });
219
219
  const query = optionalString({ input, key: "query" }) ?? "";
220
220
  const { offset, limit } = readAgentPluginSearchWindow({ input });
221
+ await routeDeps.requirePermission({ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: routeDeps.ports.permissions.use }, { entityType: "workspace", entityId: routeDeps.workspaceId });
221
222
  const candidates = await loadAgentPluginSearchCandidates(routeDeps);
222
223
  const ranked = selectAgentPluginSearchCandidates({ query, candidates, ports: routeDeps.ports });
223
224
  return projectAgentPluginSearchPage({ candidates: ranked, offset, limit, totalInstalled: candidates.length });
@@ -181,10 +181,18 @@ export function createSiteCommitter(kit, _optional = {}) {
181
181
  return { ok: true, treeSha: sha };
182
182
  }
183
183
 
184
+ async function fetchManagedManifestResponse({ token, owner, repo, branch, scope }) {
185
+ const result = await githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.manifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
186
+ if (result.kind === "response" && result.response.status === 404 && scope.previousManagedManifestPath) {
187
+ return githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.previousManagedManifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
188
+ }
189
+ return result;
190
+ }
191
+
184
192
  /** @param {string} token @param {string} owner @param {string} repo @param {string} branch
185
193
  * @returns {Promise<{ ok: true, files: readonly PreviouslyManagedFile[] } | StepFailure>} */
186
194
  async function fetchManagedManifest(token, owner, repo, branch, scope) {
187
- const result = await githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.manifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
195
+ const result = await fetchManagedManifestResponse({ token, owner, repo, branch, scope });
188
196
  if (result.kind !== "response") return nonResponseFailure(result);
189
197
  const { response } = result;
190
198
  if (response.status === 404) return { ok: true, files: [] }; // verified: no manifest yet — safe, not "unreadable"
@@ -287,7 +295,7 @@ export function createSiteCommitter(kit, _optional = {}) {
287
295
  const fileTree = await buildFileTreeEntries(token, owner, repo, files);
288
296
  if (!fileTree.ok) return fileTree;
289
297
 
290
- const candidates = (previousManagedFiles ?? []).filter((f) => !fileTree.currentPaths.has(f.path) && f.path !== scope.manifestPath);
298
+ const candidates = (previousManagedFiles ?? []).filter((f) => !fileTree.currentPaths.has(f.path) && f.path !== scope.manifestPath && f.path !== scope.previousManagedManifestPath);
291
299
  const { deletions, deletedPaths, divergedPaths } = await resolveDeletionCandidates(token, owner, repo, branch, candidates);
292
300
 
293
301
  const sortedFiles = fileTree.currentFileShas.slice().sort((a, b) => {
@@ -336,26 +344,28 @@ export function createSiteCommitter(kit, _optional = {}) {
336
344
  /** A new branch has no parent, no base tree and no manifest. @param {string} token @param {string} owner
337
345
  * @param {string} repo @param {string} branch @param {string | undefined} parentSha */
338
346
  async function resolveCommitPrerequisites(token, owner, repo, branch, parentSha, scope) {
339
- if (parentSha === undefined) return /** @type {const} */ ({ ok: true, baseTreeSha: undefined, previousManagedFiles: undefined, parents: [] });
347
+ if (parentSha === undefined) return /** @type {const} */ ({ ok: true, baseTreeSha: undefined, previousManagedFiles: undefined, parents: [], readRef: branch });
340
348
 
341
349
  const parentTreeResult = await fetchParentTree(token, owner, repo, parentSha);
342
350
  if (!parentTreeResult.ok) return parentTreeResult;
343
- const manifestResult = await fetchManagedManifest(token, owner, repo, branch, scope);
351
+ const readRef = scope.previousManagedManifestPath ? parentSha : branch;
352
+ const manifestResult = await fetchManagedManifest(token, owner, repo, readRef, scope);
344
353
  if (!manifestResult.ok) return manifestResult;
345
- return /** @type {const} */ ({ ok: true, baseTreeSha: parentTreeResult.treeSha, previousManagedFiles: manifestResult.files, parents: [parentSha] });
354
+ return /** @type {const} */ ({ ok: true, baseTreeSha: parentTreeResult.treeSha, previousManagedFiles: manifestResult.files, parents: [parentSha], readRef });
346
355
  }
347
356
 
348
357
  /** Prefix payloads once and reserve the local ownership manifest before any provider I/O.
349
- * @param {{ input: { folder?: string, files: readonly CommitFile[] } }} required
358
+ * @param {{ input: { folder?: string, previousManagedManifestPath?: string, files: readonly CommitFile[] } }} required
350
359
  * @complexity O(file count + path bytes), no effects.
351
360
  */
352
361
  function prepareCommitScope({ input }, _options = {}) {
353
362
  try {
354
363
  const folder = kit.repositoryPaths.normalizeFolder({ folder: input.folder });
355
364
  const manifestPath = kit.repositoryPaths.prefixPath({ folder, path: MANAGED_MANIFEST_PATH });
365
+ const previousManagedManifestPath = input.previousManagedManifestPath ? kit.repositoryPaths.prefixPath({ folder, path: input.previousManagedManifestPath }) : undefined;
356
366
  const files = input.files.map(file => ({ ...file, path: kit.repositoryPaths.prefixPath({ folder, path: file.path }) }));
357
- if (files.some(file => file.path === manifestPath)) return { ok: false, code: PROVIDER_ERROR, message: "Export cannot overwrite the managed manifest." };
358
- return { ok: true, folder, manifestPath, files };
367
+ if (files.some(file => file.path === manifestPath || file.path === previousManagedManifestPath)) return { ok: false, code: PROVIDER_ERROR, message: "Export cannot overwrite the managed manifest." };
368
+ return { ok: true, folder, manifestPath, previousManagedManifestPath, files };
359
369
  } catch {
360
370
  return { ok: false, code: PROVIDER_ERROR, message: "Invalid target folder or repository file path." };
361
371
  }
@@ -372,7 +382,7 @@ export function createSiteCommitter(kit, _optional = {}) {
372
382
  }
373
383
 
374
384
  /**
375
- * @param {{ token: string, owner: string, repo: string, branch?: string, commitMessage: string, folder?: string, files: readonly CommitFile[] }} input
385
+ * @param {{ token: string, owner: string, repo: string, branch?: string, commitMessage: string, folder?: string, previousManagedManifestPath?: string, files: readonly CommitFile[] }} input
376
386
  * @complexity O(f) requests in the file count, plus one per path a previous export owned and dropped.
377
387
  */
378
388
  return async function commitSite(input) {
@@ -393,7 +403,7 @@ export function createSiteCommitter(kit, _optional = {}) {
393
403
  const prereqs = await resolveCommitPrerequisites(token, owner, repo, branch, parentSha, scope);
394
404
  if (!prereqs.ok) return prereqs;
395
405
 
396
- const treeResult = await buildTree(token, owner, repo, branch, files, prereqs.baseTreeSha, prereqs.previousManagedFiles, scope);
406
+ const treeResult = await buildTree(token, owner, repo, prereqs.readRef, files, prereqs.baseTreeSha, prereqs.previousManagedFiles, scope);
397
407
  if (!treeResult.ok) return treeResult;
398
408
 
399
409
  if (unchangedSiteTree({ baseTreeSha: prereqs.baseTreeSha, treeSha: treeResult.sha })) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/agent-plugins",
3
- "version": "0.7.3-next.1",
3
+ "version": "0.7.3-next.2",
4
4
  "description": "Support for Agent Plugins: vendor-neutral manifest types and validators, installation, activation, digests and trusted contribution loading. Every Jini agent plugin ships here as its own subpath (@jini-ai/agent-plugins/<id>); resolving one never loads another plugin's files.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -355,26 +355,26 @@
355
355
  "registry": "https://registry.npmjs.org"
356
356
  },
357
357
  "devDependencies": {
358
- "@vitest/coverage-v8": "^2.1.9",
358
+ "@vitest/coverage-v8": "^3.2.6",
359
359
  "yazl": "^3.3.1",
360
360
  "@cfworker/json-schema": "^4.1.1",
361
361
  "@types/semver": "^7.5.8",
362
362
  "semver": "^7.6.2",
363
363
  "fast-check": "4.3.0",
364
- "jsdom": "^25.0.1",
364
+ "jsdom": "^26.1.0",
365
365
  "esbuild": "^0.28.1",
366
- "@jini-ai/core": "^0.7.3-next.1",
367
- "@jini-ai/platform": "^0.7.3-next.1",
368
- "@jini-ai/plugins": "^0.7.3-next.1",
369
- "@jini-ai/oauth": "^0.7.3-next.1",
370
- "@jini-ai/cms": "^0.7.3-next.1"
366
+ "@jini-ai/core": "^0.7.3-next.2",
367
+ "@jini-ai/cms": "^0.7.3-next.2",
368
+ "@jini-ai/plugins": "^0.7.3-next.2",
369
+ "@jini-ai/oauth": "^0.7.3-next.2",
370
+ "@jini-ai/platform": "^0.7.3-next.2"
371
371
  },
372
372
  "peerDependencies": {
373
373
  "yauzl": "^3.4.0",
374
- "@jini-ai/core": "^0.7.3-next.1",
374
+ "@jini-ai/core": "^0.7.3-next.2",
375
375
  "@cfworker/json-schema": "^4.1.1",
376
376
  "semver": "^7.6.2",
377
- "@jini-ai/commerce": "^0.7.3-next.1"
377
+ "@jini-ai/commerce": "^0.7.3-next.2"
378
378
  },
379
379
  "peerDependenciesMeta": {
380
380
  "yauzl": {