@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.3-next.3

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.
Files changed (231) hide show
  1. package/README.md +22 -4
  2. package/calendly/README.md +29 -0
  3. package/calendly/mcp.json +1 -1
  4. package/cloudflare/lib/assets.mjs +1 -1
  5. package/cloudflare/lib/cms-forms.mjs +1 -1
  6. package/core/persistent-state.d.ts +4 -1
  7. package/core/persistent-state.js +55 -21
  8. package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
  9. package/dist/admin-surfaces/connections/connections.d.ts +2 -6
  10. package/dist/admin-surfaces/connections/index.d.ts +3 -2
  11. package/dist/admin-surfaces/index.d.ts +3 -1
  12. package/dist/connect/access-token-tool.d.ts +1 -1
  13. package/dist/connect/access-token-tool.js +1 -1
  14. package/dist/connect/catalog.d.ts +26 -0
  15. package/dist/connect/catalog.js +42 -0
  16. package/dist/connect/connect-tool.d.ts +2 -294
  17. package/dist/connect/connect-tool.js +2 -53
  18. package/dist/connect/contracts.d.ts +257 -0
  19. package/dist/connect/contracts.js +2 -0
  20. package/dist/connect/credential-cards.d.ts +2 -0
  21. package/dist/connect/credential-cards.js +7 -4
  22. package/dist/connect/grant-signed-in-defaults.js +1 -1
  23. package/dist/connect/host-deps.d.ts +32 -0
  24. package/dist/connect/host-deps.js +35 -0
  25. package/dist/connect/import-access-token.js +1 -1
  26. package/dist/connect/index.d.ts +7 -2
  27. package/dist/connect/index.js +5 -2
  28. package/dist/connect/installed-plugin.d.ts +28 -0
  29. package/dist/connect/installed-plugin.js +19 -0
  30. package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
  31. package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
  32. package/dist/connect/plugin-host/index.d.ts +1 -2
  33. package/dist/connect/plugin-host/index.js +18 -9
  34. package/dist/connect/token-sign-in.d.ts +1 -14
  35. package/dist/connect/token-sign-in.js +4 -23
  36. package/dist/core/export-props.d.ts +10 -0
  37. package/dist/core/export-props.js +31 -0
  38. package/dist/core/folder-zip-error.d.ts +5 -0
  39. package/dist/core/folder-zip-error.js +8 -0
  40. package/dist/core/host-incompatible-error.d.ts +8 -0
  41. package/dist/core/host-incompatible-error.js +9 -0
  42. package/dist/core/identity-namespace.d.ts +27 -16
  43. package/dist/core/identity-namespace.js +25 -22
  44. package/dist/core/plugin-display-name.d.ts +7 -0
  45. package/dist/core/plugin-display-name.js +11 -0
  46. package/dist/core/provider-plugin-link.d.ts +7 -0
  47. package/dist/core/provider-plugin-link.js +5 -0
  48. package/dist/{connect → core}/token-map.d.ts +11 -1
  49. package/dist/{connect → core}/token-map.js +15 -0
  50. package/dist/core/token-sign-in-list.d.ts +18 -0
  51. package/dist/core/token-sign-in-list.js +23 -0
  52. package/dist/core/update-error.d.ts +8 -0
  53. package/dist/core/update-error.js +9 -0
  54. package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
  55. package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
  56. package/dist/ffmpeg-transcode/adapter.js +155 -0
  57. package/dist/folder-zip-node.d.ts +2 -1
  58. package/dist/folder-zip-node.js +6 -5
  59. package/dist/folder-zip.d.ts +0 -4
  60. package/dist/folder-zip.js +1 -7
  61. package/dist/index.d.ts +3 -1
  62. package/dist/lifecycle/activation.d.ts +39 -3
  63. package/dist/lifecycle/activation.js +467 -418
  64. package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
  65. package/dist/lifecycle/automatic-use-offer.js +52 -0
  66. package/dist/lifecycle/automatic-use.d.ts +33 -1
  67. package/dist/lifecycle/automatic-use.js +157 -38
  68. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  69. package/dist/lifecycle/capability-projection.d.ts +0 -1
  70. package/dist/lifecycle/capability-projection.js +92 -23
  71. package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
  72. package/dist/lifecycle/compatibility-metadata.js +6 -1
  73. package/dist/lifecycle/compatibility.d.ts +1 -8
  74. package/dist/lifecycle/compatibility.js +1 -8
  75. package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
  76. package/dist/lifecycle/exports.d.ts +2 -45
  77. package/dist/lifecycle/exports.js +1 -30
  78. package/dist/lifecycle/host-tools/identity.d.ts +5 -4
  79. package/dist/lifecycle/host-tools/identity.js +5 -5
  80. package/dist/lifecycle/host-tools/ports.d.ts +10 -1
  81. package/dist/lifecycle/host-tools/search-tool.js +18 -8
  82. package/dist/lifecycle/host-tools/skill-tool.js +1 -1
  83. package/dist/lifecycle/index.d.ts +20 -17
  84. package/dist/lifecycle/index.js +5 -4
  85. package/dist/lifecycle/install-from-url.d.ts +1 -2
  86. package/dist/lifecycle/install.d.ts +4 -34
  87. package/dist/lifecycle/install.js +3 -3
  88. package/dist/lifecycle/installed-package-index.d.ts +1 -1
  89. package/dist/lifecycle/installed-package-index.js +4 -4
  90. package/dist/lifecycle/layout.d.ts +21 -25
  91. package/dist/lifecycle/layout.js +79 -0
  92. package/dist/lifecycle/manifest.d.ts +10 -7
  93. package/dist/lifecycle/manifest.js +20 -15
  94. package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
  95. package/dist/lifecycle/metadata.d.ts +6 -3
  96. package/dist/lifecycle/metadata.js +2 -1
  97. package/dist/lifecycle/package-paths.js +59 -56
  98. package/dist/lifecycle/persistent-state.d.ts +10 -1
  99. package/dist/lifecycle/persistent-state.js +4 -2
  100. package/dist/lifecycle/ports.d.ts +18 -6
  101. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
  102. package/dist/lifecycle/retire-bundled.d.ts +1 -1
  103. package/dist/lifecycle/search-projection.d.ts +3 -1
  104. package/dist/lifecycle/search-projection.js +7 -3
  105. package/dist/lifecycle/search.d.ts +1 -0
  106. package/dist/lifecycle/seed-bundled.d.ts +86 -1
  107. package/dist/lifecycle/seed-bundled.js +48 -84
  108. package/dist/lifecycle/set-enabled.d.ts +1 -13
  109. package/dist/lifecycle/set-enabled.js +11 -7
  110. package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
  111. package/dist/lifecycle/trusted-plugin-files.js +33 -30
  112. package/dist/lifecycle/types.d.ts +13 -34
  113. package/dist/lifecycle/uninstall.d.ts +1 -33
  114. package/dist/lifecycle/update-store.d.ts +0 -7
  115. package/dist/lifecycle/update-store.js +1 -8
  116. package/dist/lifecycle/update.d.ts +1 -1
  117. package/dist/lifecycle/update.js +60 -10
  118. package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
  119. package/dist/lifecycle/yauzl-archive-reader.js +11 -6
  120. package/dist/manifest.d.ts +4 -8
  121. package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
  122. package/dist/react/AgentPluginDetailsModal.js +29 -0
  123. package/dist/react/agent-plugin-install-port.d.ts +24 -0
  124. package/dist/react/agent-plugin-install-port.js +15 -0
  125. package/dist/react/installed-skills-composer-source.d.ts +60 -0
  126. package/dist/react/installed-skills-composer-source.js +111 -0
  127. package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
  128. package/dist/react/use-agent-plugins.hooks.js +128 -0
  129. package/dist/site/activation-effects.d.ts +17 -0
  130. package/dist/site/activation-effects.js +31 -0
  131. package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
  132. package/dist/site/admin-surfaces/capabilities.js +30 -0
  133. package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
  134. package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
  135. package/dist/site/admin-surfaces/forms.d.ts +28 -0
  136. package/dist/site/admin-surfaces/forms.js +29 -0
  137. package/dist/site/admin-surfaces/handlers.d.ts +61 -0
  138. package/dist/site/admin-surfaces/handlers.js +35 -0
  139. package/dist/site/admin-surfaces/public-config.d.ts +12 -0
  140. package/dist/site/admin-surfaces/public-config.js +28 -0
  141. package/dist/site/analytics-provider-registry.d.ts +87 -0
  142. package/dist/site/analytics-provider-registry.js +87 -0
  143. package/dist/site/archive-reader-abi.d.ts +35 -0
  144. package/dist/site/archive-reader-abi.js +25 -0
  145. package/dist/site/auth-schemes.d.ts +110 -0
  146. package/dist/site/auth-schemes.js +119 -0
  147. package/dist/site/automatic-agent-plugins.d.ts +200 -0
  148. package/dist/site/automatic-agent-plugins.js +277 -0
  149. package/dist/site/bundled-contribution-sources.d.ts +24 -0
  150. package/dist/site/bundled-contribution-sources.js +17 -0
  151. package/dist/site/bundled-id-upgrade.d.ts +115 -0
  152. package/dist/site/bundled-id-upgrade.js +169 -0
  153. package/dist/site/customize-tool.d.ts +39 -0
  154. package/dist/site/customize-tool.js +31 -0
  155. package/dist/site/deploy-split-activation.d.ts +28 -0
  156. package/dist/site/deploy-split-activation.js +21 -0
  157. package/dist/site/exports/diagnostics.d.ts +37 -0
  158. package/dist/site/exports/diagnostics.js +55 -0
  159. package/dist/site/exports/runtime.d.ts +54 -0
  160. package/dist/site/exports/runtime.js +196 -0
  161. package/dist/site/exports/source.d.ts +42 -0
  162. package/dist/site/exports/source.js +58 -0
  163. package/dist/site/host-plugin-guidance.d.ts +137 -0
  164. package/dist/site/host-plugin-guidance.js +223 -0
  165. package/dist/site/host-signals.d.ts +78 -0
  166. package/dist/site/host-signals.js +83 -0
  167. package/dist/site/install-tool.d.ts +69 -0
  168. package/dist/site/install-tool.js +192 -0
  169. package/dist/site/install-upload.d.ts +175 -0
  170. package/dist/site/install-upload.js +324 -0
  171. package/dist/site/memory-i18n.d.ts +5 -0
  172. package/dist/site/memory-i18n.js +176 -0
  173. package/dist/site/memory.d.ts +80 -0
  174. package/dist/site/memory.js +83 -0
  175. package/dist/site/plugin-memory.d.ts +80 -0
  176. package/dist/site/plugin-memory.js +86 -0
  177. package/dist/site/provider-plugin-link.d.ts +112 -0
  178. package/dist/site/provider-plugin-link.js +100 -0
  179. package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
  180. package/dist/site/retired-plugin-tool-aliases.js +41 -0
  181. package/dist/site/service-ports.d.ts +108 -0
  182. package/dist/site/service-ports.js +2 -0
  183. package/dist/site/set-enabled.d.ts +80 -0
  184. package/dist/site/set-enabled.js +42 -0
  185. package/dist/site/soon-lock.d.ts +83 -0
  186. package/dist/site/soon-lock.js +78 -0
  187. package/dist/site/supersession.d.ts +61 -0
  188. package/dist/site/supersession.js +122 -0
  189. package/dist/site/uninstall-tool.d.ts +136 -0
  190. package/dist/site/uninstall-tool.js +203 -0
  191. package/dist/site/update-effects.d.ts +47 -0
  192. package/dist/site/update-effects.js +49 -0
  193. package/ffmpeg-transcode/plugin.json +16 -0
  194. package/github/source-control/backup-push.mjs +66 -46
  195. package/github/source-control/commit-site.mjs +112 -65
  196. package/github/source-control/write-files.mjs +86 -53
  197. package/github-pages/targets/github-pages.mjs +294 -233
  198. package/google-workspace/form-destinations/mapping.mjs +15 -7
  199. package/google-workspace/form-destinations/sheets.mjs +4 -2
  200. package/google-workspace/plugin.json +1 -0
  201. package/kuinetic/CHANGELOG.md +4 -0
  202. package/kuinetic/plugin.json +4 -1
  203. package/kuinetic/skills/kuinetic/SKILL.md +1 -2
  204. package/package.json +295 -18
  205. package/persistent-state.d.ts +4 -1
  206. package/resend/adapters/resend.mjs +5 -2
  207. package/resend/plugin.json +1 -1
  208. package/s3-compatible/jini-deploy-targets.json +1 -1
  209. package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
  210. package/s3-compatible/targets/s3-compatible.mjs +3 -3
  211. package/site-import/plugin.json +3 -3
  212. package/site-import/skills/site-import/SKILL.md +62 -54
  213. package/site-import/skills/site-import/references/content-mapping.md +26 -20
  214. package/slide-design/plugin.json +1 -1
  215. package/slide-design/skills/slide-design/SKILL.md +8 -2
  216. package/ui-ux-design/CHANGELOG.md +6 -0
  217. package/ui-ux-design/plugin.json +1 -1
  218. package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
  219. package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
  220. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
  221. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
  222. package/vercel/NOTES.md +2 -1
  223. package/vercel/object-stores/vercel-blob.mjs +3 -4
  224. package/vercel/targets/vercel.mjs +425 -351
  225. package/core/commerce-server.d.ts +0 -2
  226. package/core/commerce-server.mjs +0 -2
  227. package/dist/admin-surfaces/connections/ports.d.ts +0 -110
  228. package/dist/admin-surfaces/connections/ports.js +0 -2
  229. /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
  230. /package/dist/{lifecycle → core}/install-errors.js +0 -0
  231. /package/dist/{lifecycle → core}/update-plan.js +0 -0
@@ -0,0 +1,62 @@
1
+ /** Scope, replay and refusal rules for guidance offers; the controller owns delivery state. */
2
+ import type { AgentPluginGuidanceAttempt, AgentPluginGuidanceOffer } from '@jini-ai/core/contracts/site/daemon';
3
+ export type GuidanceAttemptLiveness = (required: AgentPluginGuidanceAttempt, optional?: {
4
+ signal?: AbortSignal;
5
+ }) => Promise<boolean>;
6
+ /** The one current offer of a logical-turn controller, plus its recorded commit once made. */
7
+ export interface StoredGuidanceOffer {
8
+ readonly scope: AgentPluginGuidanceAttempt;
9
+ offerId: string;
10
+ readonly offer: Omit<AgentPluginGuidanceOffer, 'offerId'>;
11
+ /** Display names of the offered full sections, in draft order. */
12
+ readonly offered: ReadonlyMap<string, string>;
13
+ /** Pins the offer saw; they enter the delivered set only when a commit succeeds. */
14
+ readonly loaded: readonly string[];
15
+ readonly isAttemptLive: GuidanceAttemptLiveness;
16
+ committed?: {
17
+ readonly ids: readonly string[];
18
+ readonly result: {
19
+ readonly guidanceIds: readonly string[];
20
+ };
21
+ };
22
+ }
23
+ export declare const GUIDANCE_REPLAY_REFUSAL = "This guidance choice was already recorded for this turn.";
24
+ /** A plain-words refusal; callers must not record any part of the choice after it. */
25
+ export declare function refuseGuidance({ reason }: {
26
+ reason: 'not-current' | 'replay' | 'unoffered' | 'unavailable' | 'cancelled';
27
+ }, _options?: {}): never;
28
+ export declare function guidanceScopeKey({ scope }: {
29
+ scope: AgentPluginGuidanceAttempt;
30
+ }, _options?: {}): string;
31
+ export declare function sameGuidanceScope({ left, right }: {
32
+ left: AgentPluginGuidanceAttempt;
33
+ right: AgentPluginGuidanceAttempt;
34
+ }, _options?: {}): boolean;
35
+ /** A replaced scope, or an older attempt of the current run, can never offer again. O(1). */
36
+ export declare function isRetiredGuidanceScope({ scope, current, retired }: {
37
+ scope: AgentPluginGuidanceAttempt;
38
+ current: StoredGuidanceOffer | undefined;
39
+ retired: ReadonlySet<string>;
40
+ }, _options?: {}): boolean;
41
+ /** Replays compare as sets: the same ids in another order are the same choice. O(n log n). */
42
+ export declare function sameGuidanceChoice({ left, right }: {
43
+ left: readonly string[];
44
+ right: readonly string[];
45
+ }, _options?: {}): boolean;
46
+ /** Only unique ids from this offer's full sections may be committed. O(n). */
47
+ export declare function assertOfferedChoice({ stored, deliveredIds }: {
48
+ stored: StoredGuidanceOffer;
49
+ deliveredIds: readonly string[];
50
+ }, _options?: {}): void;
51
+ /** The commit must name the stored scope and offer exactly. @returns The matching stored offer. */
52
+ export declare function currentGuidanceOffer({ stored, scope, offerId }: {
53
+ stored: StoredGuidanceOffer | undefined;
54
+ scope: AgentPluginGuidanceAttempt;
55
+ offerId: string;
56
+ }, _options?: {}): StoredGuidanceOffer;
57
+ /** The host's authoritative fence; an abort during the check also refuses. */
58
+ export declare function assertAttemptLive({ stored, signal }: {
59
+ stored: StoredGuidanceOffer;
60
+ signal?: AbortSignal | undefined;
61
+ }, _options?: {}): Promise<void>;
62
+ //# sourceMappingURL=automatic-use-offer.d.ts.map
@@ -0,0 +1,52 @@
1
+ export const GUIDANCE_REPLAY_REFUSAL = 'This guidance choice was already recorded for this turn.';
2
+ const NOT_CURRENT = 'This guidance offer is no longer current for this turn.';
3
+ /** A plain-words refusal; callers must not record any part of the choice after it. */
4
+ export function refuseGuidance({ reason }, _options = {}) {
5
+ const messages = {
6
+ 'not-current': NOT_CURRENT,
7
+ replay: GUIDANCE_REPLAY_REFUSAL,
8
+ unoffered: 'This guidance choice includes plugins that were not offered for this turn.',
9
+ unavailable: 'A selected plugin is no longer available, so no guidance was recorded.',
10
+ cancelled: 'Recording this guidance choice was cancelled.',
11
+ };
12
+ throw new Error(messages[reason]);
13
+ }
14
+ export function guidanceScopeKey({ scope }, _options = {}) {
15
+ return JSON.stringify([scope.runId, scope.attempt, scope.principalId]);
16
+ }
17
+ export function sameGuidanceScope({ left, right }, _options = {}) {
18
+ return guidanceScopeKey({ scope: left }) === guidanceScopeKey({ scope: right });
19
+ }
20
+ /** A replaced scope, or an older attempt of the current run, can never offer again. O(1). */
21
+ export function isRetiredGuidanceScope({ scope, current, retired }, _options = {}) {
22
+ if (retired.has(guidanceScopeKey({ scope })))
23
+ return true;
24
+ return !!current && current.scope.runId === scope.runId && scope.attempt < current.scope.attempt;
25
+ }
26
+ /** Replays compare as sets: the same ids in another order are the same choice. O(n log n). */
27
+ export function sameGuidanceChoice({ left, right }, _options = {}) {
28
+ const normalize = (ids) => JSON.stringify([...new Set(ids)].sort());
29
+ return normalize(left) === normalize(right);
30
+ }
31
+ /** Only unique ids from this offer's full sections may be committed. O(n). */
32
+ export function assertOfferedChoice({ stored, deliveredIds }, _options = {}) {
33
+ if (new Set(deliveredIds).size !== deliveredIds.length || deliveredIds.some(id => !stored.offered.has(id)))
34
+ refuseGuidance({ reason: 'unoffered' });
35
+ }
36
+ /** The commit must name the stored scope and offer exactly. @returns The matching stored offer. */
37
+ export function currentGuidanceOffer({ stored, scope, offerId }, _options = {}) {
38
+ if (!stored || stored.offerId !== offerId || !sameGuidanceScope({ left: stored.scope, right: scope }))
39
+ refuseGuidance({ reason: 'not-current' });
40
+ return stored;
41
+ }
42
+ /** The host's authoritative fence; an abort during the check also refuses. */
43
+ export async function assertAttemptLive({ stored, signal }, _options = {}) {
44
+ if (signal?.aborted)
45
+ refuseGuidance({ reason: 'cancelled' });
46
+ const live = await stored.isAttemptLive(stored.scope, signal ? { signal } : {});
47
+ if (signal?.aborted)
48
+ refuseGuidance({ reason: 'cancelled' });
49
+ if (!live)
50
+ refuseGuidance({ reason: 'not-current' });
51
+ }
52
+ //# sourceMappingURL=automatic-use-offer.js.map
@@ -2,6 +2,8 @@
2
2
  import type { AgentPluginSearchCandidate, AgentPluginSearchMatch } from './search.js';
3
3
  import type { AgentPluginSkillRequest, ResolveAgentPluginRefsResult } from './resolve-agent-plugin-refs.js';
4
4
  import type { AgentPluginLifecyclePorts } from './ports.js';
5
+ import type { AgentPluginGuidanceAttempt, AgentPluginGuidanceOffer } from '@jini-ai/core/contracts/site/daemon';
6
+ import { type GuidanceAttemptLiveness } from './automatic-use-offer.js';
5
7
  export type ChatAgentPlugins = 'auto' | 'ask' | 'off';
6
8
  export declare const DEFAULT_CHAT_AGENT_PLUGINS: ChatAgentPlugins;
7
9
  /** Browser-owned, per-conversation state. Clearing it deliberately permits a fresh question. */
@@ -36,7 +38,9 @@ export interface AutomaticAgentPluginPorts {
36
38
  /** Must recheck activation/trust and return real guidance, never a pointer to unopened guidance. */
37
39
  resolve(input: {
38
40
  pluginId: string;
39
- } & AgentPluginSkillRequest, options?: Record<string, never>): Promise<ResolveAgentPluginRefsResult>;
41
+ } & AgentPluginSkillRequest, options?: {
42
+ allowInactiveGuidance?: boolean;
43
+ }): Promise<ResolveAgentPluginRefsResult>;
40
44
  /** Only a principal-bound human exchange may return action=auto. */
41
45
  ask(input: {
42
46
  matches: readonly AutomaticAgentPluginMatch[];
@@ -67,6 +71,22 @@ type PrepareInput = {
67
71
  export declare function readChatAgentPluginState({ value }: {
68
72
  value: unknown;
69
73
  }, _options?: {}): ChatAgentPluginState;
74
+ type OfferInput = {
75
+ query: string;
76
+ loaded?: readonly string[];
77
+ signal?: AbortSignal;
78
+ };
79
+ type OfferRequired = {
80
+ scope: AgentPluginGuidanceAttempt;
81
+ offerId: string;
82
+ input: OfferInput;
83
+ isAttemptLive: GuidanceAttemptLiveness;
84
+ };
85
+ type CommitRequired = {
86
+ scope: AgentPluginGuidanceAttempt;
87
+ offerId: string;
88
+ deliveredIds: readonly string[];
89
+ };
70
90
  /** Create one run's preparation owner. Calls serialize so parallel tool writes share one question.
71
91
  * @param required Host effects and the person's mode; browser state is advisory selection only.
72
92
  * @returns prepare(): a relevance note or capability guidance; load(): a truthful admission/delivery outcome.
@@ -89,6 +109,18 @@ export declare function createAutomaticAgentPluginUse({ mode, state: initialStat
89
109
  pluginId: string;
90
110
  signal?: AbortSignal;
91
111
  } & AgentPluginSkillRequest, _options?: {}) => Promise<AutomaticAgentPluginLoadResult>;
112
+ /** Draft guidance for one live attempt without recording delivery; the host injects the offer id and liveness check.
113
+ * @example const draft = await controller.offer({ scope, offerId, input: { query }, isAttemptLive });
114
+ */
115
+ offer: (required: OfferRequired, _optional?: {}) => Promise<AgentPluginGuidanceOffer>;
116
+ /** Record the offered ids the host actually delivered; a same-choice replay returns the cached result.
117
+ * @example await controller.commit({ scope, offerId, deliveredIds: ['plugin-a'] });
118
+ */
119
+ commit: (required: CommitRequired, optional?: {
120
+ signal?: AbortSignal;
121
+ }) => Promise<{
122
+ readonly guidanceIds: readonly string[];
123
+ }>;
92
124
  };
93
125
  export {};
94
126
  //# sourceMappingURL=automatic-use.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { agentVisiblePluginCandidate } from './search-projection.js';
2
+ import { assertAttemptLive, assertOfferedChoice, currentGuidanceOffer, guidanceScopeKey, isRetiredGuidanceScope, refuseGuidance, sameGuidanceChoice, sameGuidanceScope, } from './automatic-use-offer.js';
2
3
  export const DEFAULT_CHAT_AGENT_PLUGINS = 'auto';
3
4
  const MAX_AUTOMATIC_GUIDANCE_BYTES = 8 * 1024;
4
5
  const MAX_QUERY_GUIDANCE_BYTES = 24 * 1024;
@@ -7,15 +8,17 @@ function describeMatch({ plugin }, _options = {}) {
7
8
  return { id: plugin.pluginId, name: (plugin.displayName ?? plugin.pluginId).replace(/\s+/g, ' '),
8
9
  why: (plugin.summary ?? plugin.description ?? `Provides ${(plugin.provides ?? plugin.keywords).join(', ')}`).split(/[\n.]/)[0].replace(/\s+/g, ' ').slice(0, 180) };
9
10
  }
10
- function enabledPluginCatalog({ ctx, candidates }, _options = {}) {
11
- const rows = [...candidates].filter(plugin => !ctx.state.excluded.includes(plugin.pluginId) && !ctx.delivered.has(plugin.pluginId))
11
+ /** `drafted` names full sections an offer carries but has not recorded; they leave the catalog too. */
12
+ function enabledPluginCatalog({ ctx, candidates, drafted }, _options = {}) {
13
+ const rows = [...candidates].filter(plugin => !ctx.state.excluded.includes(plugin.pluginId) && !ctx.delivered.has(plugin.pluginId) && !drafted.includes(plugin.pluginId))
12
14
  .sort((a, b) => a.pluginId.localeCompare(b.pluginId));
13
15
  return rows.length ? 'Enabled agent plugins (load one before acting on its part):\n' + rows.map(plugin => catalogRow({ ctx, plugin })).join('\n') : '';
14
16
  }
15
17
  function catalogRow({ ctx, plugin }, _options = {}) {
16
18
  const { id, name, why } = describeMatch({ plugin });
17
- const pointer = ctx.ports.formatPluginToolPointer?.({ pluginId: id, file: 'SKILL.md' }) ?? `search_agent_plugin_local({ query: "${id}" })`;
18
- return `- ${name} (${id}): ${why}` + (plugin.keywords.length ? `\n Use for: ${plugin.keywords.slice(0, 8).join(', ')}` : '') + `\n Load: ${pointer}`;
19
+ const pointer = ctx.ports.formatPluginToolPointer?.({ pluginId: id, file: 'SKILL.md' }) ?? "use the current host's plugin guidance reader";
20
+ const cue = (plugin.keywords.length ? plugin.keywords : plugin.skills.length ? plugin.skills.map(skill => skill.summary || skill.name) : plugin.provides ?? []).slice(0, 8).join(', ').replace(/\s+/g, ' ').slice(0, 180);
21
+ return `- ${name} (${id}): ${why}` + (cue ? `\n Use for: ${cue}` : '') + `\n Load: ${pointer}`;
19
22
  }
20
23
  /** A guarded capability admits its providers outright; a query is ranked for relevance. */
21
24
  function rankCandidates({ candidates, input, ports }, _options = {}) {
@@ -23,15 +26,17 @@ function rankCandidates({ candidates, input, ports }, _options = {}) {
23
26
  const admit = (plugins) => plugins.map(plugin => ({ ...plugin, score: 4 }));
24
27
  if (capabilities)
25
28
  return admit(candidates.filter(plugin => plugin.provides?.some(capability => capabilities.includes(capability))));
26
- return withRequiredProviders({ ranked: ports.rank({ query: input.query ?? '', candidates, limit: candidates.length }, {}), candidates });
29
+ return ports.rank({ query: input.query ?? '', candidates, limit: candidates.length }, {});
27
30
  }
28
31
  function withRequiredProviders({ ranked, candidates }, _options = {}) {
29
32
  const top = ranked[0];
30
33
  if (!top)
31
34
  return ranked;
35
+ const companions = (top.companions ?? []).flatMap(id => candidates.filter(plugin => plugin.enabled && plugin.pluginId === id).map(plugin => ranked.find(match => match.pluginId === id) ?? { ...plugin, score: 4 }));
32
36
  const required = candidates.filter(plugin => plugin.enabled && plugin.provides?.some(capability => top.requires?.includes(capability)))
37
+ .sort((a, b) => a.pluginId.localeCompare(b.pluginId))
33
38
  .map(plugin => ranked.find(match => match.pluginId === plugin.pluginId) ?? { ...plugin, score: 4 });
34
- const ordered = [top, ...required, ...ranked];
39
+ const ordered = [top, ...companions, ...required, ...ranked];
35
40
  return ordered.filter((plugin, index) => ordered.findIndex(match => match.pluginId === plugin.pluginId) === index);
36
41
  }
37
42
  /** Validate the request's small browser state; malformed state means no previous decision.
@@ -85,11 +90,11 @@ async function askConsent({ ctx, matches }, { signal } = {}) {
85
90
  * Explicit content requests retain safe resolver refusals so the model can correct its request;
86
91
  * thrown host diagnostics remain private. Failures stay retryable. O(1) bookkeeping.
87
92
  */
88
- async function resolveOneGuidance(ctx, { plugin, ...request }, { signal } = {}) {
93
+ async function resolveOneGuidance(ctx, { plugin, ...request }, { signal, ...options } = {}) {
89
94
  if (signal?.aborted)
90
95
  return { status: 'cancelled', guidance: '' };
91
96
  try {
92
- const result = await ctx.ports.resolve({ pluginId: plugin.pluginId, ...request }, {});
97
+ const result = await ctx.ports.resolve({ pluginId: plugin.pluginId, ...request }, options);
93
98
  if (!result.ok)
94
99
  return { status: result.code ?? 'unavailable', guidance: request.skill !== undefined || request.file !== undefined ? result.reason : '' };
95
100
  if (!result.promptPrefix.trim())
@@ -107,6 +112,7 @@ function recordDelivery({ ctx, plugin, result }) {
107
112
  ctx.delivered.set(plugin.pluginId, plugin.displayName ?? plugin.pluginId);
108
113
  }
109
114
  /** Bound automatic attachments before recording delivery; explicit loads retain complete text.
115
+ * The bounded sections land in a draft; recording delivery is the caller's separate step.
110
116
  * O(p*b) in resolved plugins and guidance bytes; a deferred plugin remains retryable.
111
117
  */
112
118
  async function resolveGuidance({ ctx, matches }, { budget, signal } = {}) {
@@ -116,15 +122,17 @@ async function resolveGuidance({ ctx, matches }, { budget, signal } = {}) {
116
122
  const result = await resolveOneGuidance(ctx, { plugin: match }, { signal });
117
123
  if (result.status !== 'loaded')
118
124
  return undefined;
119
- if (new TextEncoder().encode(result.guidance).length > (budget ?? MAX_AUTOMATIC_GUIDANCE_BYTES)) {
125
+ const bytes = new TextEncoder().encode(result.guidance).length + (budget !== undefined && guidance.length ? 2 : 0);
126
+ if (bytes > (budget ?? MAX_AUTOMATIC_GUIDANCE_BYTES)) {
127
+ if (budget !== undefined)
128
+ return undefined;
120
129
  const pointer = ctx.ports.formatPluginToolPointer?.({ pluginId: match.pluginId, skill: match.pluginId, file: 'SKILL.md' });
121
130
  const howToLoad = pointer === undefined ? '' : ` Load the full instructions with ${pointer}; use the same call with file '<relative path>' for supporting references.`;
122
- return `Agent Plugin '${match.pluginId}' guidance is deferred because it exceeds the automatic byte limit.${howToLoad}`;
131
+ return { plugin: match, full: false, text: `Agent Plugin '${match.pluginId}' guidance is deferred because it exceeds the automatic byte limit.${howToLoad}` };
123
132
  }
124
- recordDelivery({ ctx, plugin: match, result });
125
133
  if (budget !== undefined)
126
- budget -= new TextEncoder().encode(result.guidance).length;
127
- return result.guidance;
134
+ budget -= bytes;
135
+ return { plugin: match, full: true, text: result.guidance };
128
136
  };
129
137
  for (const match of matches) {
130
138
  if (signal?.aborted)
@@ -165,47 +173,69 @@ async function prepare({ ctx, input }) {
165
173
  ctx.alreadyLoaded.add(id);
166
174
  if (ctx.mode === 'off' || input.signal?.aborted)
167
175
  return '';
168
- const installed = (await ctx.ports.list({}, {})).filter(plugin => !ctx.state.excluded.includes(plugin.pluginId));
169
- const candidates = installed.filter(plugin => plugin.enabled);
170
- for (const id of ctx.alreadyLoaded)
171
- if (!candidates.some(plugin => plugin.pluginId === id))
172
- ctx.alreadyLoaded.delete(id);
173
- const matches = await consentedMatches({ ctx, candidates, input });
174
- const result = await preparedGuidance({ ctx, matches, input });
176
+ const { installed, candidates } = await admittedCatalog(ctx);
177
+ pruneUnavailablePins({ ctx, pinned: ctx.alreadyLoaded, candidates });
178
+ const matches = await consentedMatches({ ctx, candidates, input, pinned: ctx.alreadyLoaded });
179
+ const sections = await preparedGuidance({ ctx, matches, input, pinned: ctx.alreadyLoaded });
180
+ // Obtaining consent and resolving bytes do not prove full guidance was selected for delivery;
181
+ // one-shot preparation selects every full section it drafted, so it records them all here.
182
+ for (const section of sections)
183
+ if (section.full)
184
+ recordDelivery({ ctx, plugin: section.plugin, result: { status: 'loaded', guidance: section.text } });
175
185
  rememberDelivery(ctx);
176
186
  await publishUsage(ctx);
177
- return withPluginNotes({ ctx, input, installed, candidates, result });
187
+ return withPluginNotes({ ctx, input, installed, candidates, result: joinSections({ sections }), drafted: [] });
188
+ }
189
+ /** Installed packages minus exclusions, and the enabled subset automatic use may draft from. */
190
+ async function admittedCatalog(ctx) {
191
+ const installed = (await ctx.ports.list({}, {})).filter(plugin => !ctx.state.excluded.includes(plugin.pluginId));
192
+ return { installed, candidates: installed.filter(plugin => plugin.enabled) };
193
+ }
194
+ /** Pins whose plugin is no longer enabled stop counting as delivered. O(p*c). */
195
+ function pruneUnavailablePins({ pinned, candidates }) {
196
+ for (const id of pinned)
197
+ if (!candidates.some(plugin => plugin.pluginId === id))
198
+ pinned.delete(id);
199
+ }
200
+ function joinSections({ sections }) {
201
+ return sections.map(section => section.text).join('\n\n');
178
202
  }
179
203
  /** Appends the enabled-plugin catalog and the off-plugin note to the prepared guidance. */
180
- function withPluginNotes({ ctx, input, installed, candidates, result }) {
204
+ function withPluginNotes({ ctx, input, installed, candidates, result, drafted }) {
181
205
  // Preflight never resolves off packages implicitly. A catalog line offers an explicit read;
182
206
  // its setup guidance may explain whether enabling or credentials are needed.
183
207
  const off = offPluginNote(ctx, { catalog: installed, input });
184
- const catalog = input.query !== undefined && !input.capabilities?.length ? enabledPluginCatalog({ ctx, candidates }) : '';
208
+ const catalog = input.query !== undefined && !input.capabilities?.length ? enabledPluginCatalog({ ctx, candidates: candidates.filter(plugin => !input.loaded?.includes(plugin.pluginId)), drafted }) : '';
185
209
  return [result, catalog, off].filter(Boolean).join('\n\n');
186
210
  }
187
211
  /** Rank enabled candidates, drop plugins this run already has, then apply the person's consent. */
188
- async function consentedMatches({ ctx, candidates, input }) {
212
+ async function consentedMatches({ ctx, candidates, input, pinned }) {
189
213
  const ranked = rankCandidates({ candidates, input, ports: ctx.ports });
190
214
  // Owner decision 2026-10-18: no per-chat plugin count; the relevance threshold and vendor gate decide.
191
- const relevant = ranked.filter(plugin => !ctx.delivered.has(plugin.pluginId) && !input.loaded?.includes(plugin.pluginId) && (!ctx.alreadyLoaded.has(plugin.pluginId) || !!input.query));
192
- return applyConsent({ ctx, matches: relevant }, { signal: input.signal });
215
+ const planned = input.capabilities ? ranked : withRequiredProviders({ ranked, candidates });
216
+ const relevant = planned.filter(plugin => !ctx.delivered.has(plugin.pluginId) && !input.loaded?.includes(plugin.pluginId) && (!pinned.has(plugin.pluginId) || !!input.query));
217
+ const consented = await applyConsent({ ctx, matches: relevant }, { signal: input.signal });
218
+ const topAccepted = consented.some(plugin => plugin.pluginId === ranked[0]?.pluginId);
219
+ return consented.filter(plugin => topAccepted || !ranked[0]?.companions?.includes(plugin.pluginId) || ranked.some(match => match.pluginId === plugin.pluginId));
193
220
  }
194
221
  /** Capability calls resolve every match; a query resolves the top and required providers. */
195
- async function preparedGuidance({ ctx, matches, input }) {
196
- const shouldLoad = !!input.capabilities?.length;
197
- const primary = primaryMatch({ ctx, matches, input });
198
- return shouldLoad ? (await resolveGuidance({ ctx, matches }, { signal: input.signal })).join('\n\n') : (await resolveGuidance({ ctx, matches: primary }, { budget: MAX_QUERY_GUIDANCE_BYTES, signal: input.signal })).join('\n\n');
222
+ async function preparedGuidance({ ctx, matches, input, pinned }) {
223
+ if (input.capabilities?.length)
224
+ return resolveGuidance({ ctx, matches }, { signal: input.signal });
225
+ return resolveGuidance({ ctx, matches: primaryMatch({ matches, input, pinned }) }, { budget: MAX_QUERY_GUIDANCE_BYTES, signal: input.signal });
199
226
  }
200
227
  /** The top match and required providers a fresh, unbounded query preflight delivers in full; otherwise none. */
201
- function primaryMatch({ ctx, matches, input }) {
202
- if (!(input.maxPromptArgBytes === undefined && input.query && !input.loaded?.length && !ctx.alreadyLoaded.has(matches[0]?.pluginId ?? '')))
228
+ function primaryMatch({ matches, input, pinned }) {
229
+ // The argument-size skip applies only to legacy one-shot preparation: an offer carries no
230
+ // maxPromptArgBytes because the launcher sizes the full and catalog variants itself.
231
+ if (!(input.maxPromptArgBytes === undefined && input.query && !input.loaded?.length && !pinned.has(matches[0]?.pluginId ?? '')))
203
232
  return [];
204
233
  const [top, ...rest] = matches;
205
234
  if (!top)
206
235
  return [];
207
- const required = rest.filter(plugin => !ctx.alreadyLoaded.has(plugin.pluginId) && plugin.provides?.some(capability => top.requires?.includes(capability)));
208
- return [top, ...required].slice(0, 3);
236
+ const companions = rest.filter(plugin => top.companions?.includes(plugin.pluginId) && !pinned.has(plugin.pluginId));
237
+ const additional = rest.filter(plugin => !top.companions?.includes(plugin.pluginId) && !pinned.has(plugin.pluginId));
238
+ return [top, ...companions, ...additional.slice(0, 3)];
209
239
  }
210
240
  /** Rank readable metadata for off plugins; never load their tools or guidance implicitly. O(p*t). */
211
241
  function offPluginNote(ctx, { catalog, input }) {
@@ -243,7 +273,7 @@ async function loadPermitted(ctx, { plugin, ...request }, { signal } = {}) {
243
273
  await publishUsage(ctx);
244
274
  return { status: 'excluded', guidance: '' };
245
275
  }
246
- let result = await resolveOneGuidance(ctx, { plugin, ...request }, { signal });
276
+ let result = await resolveOneGuidance(ctx, { plugin, ...request }, { signal, ...(!plugin.enabled ? { allowInactiveGuidance: true } : {}) });
247
277
  if (!plugin.enabled && result.status === 'loaded') {
248
278
  result = { status: 'installed-but-inactive', guidance: `Plugin '${plugin.pluginId}' is off; its tools are unavailable.\n\n${result.guidance}` };
249
279
  }
@@ -253,7 +283,88 @@ async function loadPermitted(ctx, { plugin, ...request }, { signal } = {}) {
253
283
  await publishUsage(ctx);
254
284
  return result;
255
285
  }
256
- /** Share one queue between preflight, explicit reads and simultaneous guarded writes. */
286
+ /** Draft or reuse this attempt's offer. It may ask for consent or save Auto, but records and publishes nothing.
287
+ * A newer attempt retires the older scope first, so that scope can never commit or offer again.
288
+ */
289
+ async function offer(ctx, { scope, offerId, input, isAttemptLive }) {
290
+ const current = ctx.offer;
291
+ if (isRetiredGuidanceScope({ scope, current, retired: ctx.retired }))
292
+ refuseGuidance({ reason: 'not-current' });
293
+ if (!(await isAttemptLive(scope, input.signal ? { signal: input.signal } : {})))
294
+ refuseGuidance({ reason: 'not-current' });
295
+ if (current && sameGuidanceScope({ left: current.scope, right: scope })) {
296
+ if (current.offerId !== offerId && current.committed)
297
+ refuseGuidance({ reason: 'not-current' });
298
+ current.offerId = offerId;
299
+ return { offerId, ...current.offer };
300
+ }
301
+ if (current)
302
+ ctx.retired.add(guidanceScopeKey({ scope: current.scope }));
303
+ ctx.offer = undefined;
304
+ const draft = await draftOffer(ctx, { input });
305
+ ctx.offer = { scope: { runId: scope.runId, attempt: scope.attempt, principalId: scope.principalId }, offerId, isAttemptLive, ...draft };
306
+ return { offerId, ...draft.offer };
307
+ }
308
+ /** The legacy query draft without its argument-size skip; pins are read, not added to the delivered set. */
309
+ async function draftOffer(ctx, { input }) {
310
+ const loaded = [...(input.loaded ?? [])];
311
+ if (ctx.mode === 'off' || input.signal?.aborted)
312
+ return { loaded, offered: new Map(), offer: { fullSections: [], fullPrefix: '', catalogPrefix: '' } };
313
+ const { installed, candidates } = await admittedCatalog(ctx);
314
+ const pinned = new Set([...ctx.alreadyLoaded, ...loaded]);
315
+ pruneUnavailablePins({ ctx, pinned, candidates });
316
+ const query = { query: input.query, ...(input.loaded ? { loaded: input.loaded } : {}), ...(input.signal ? { signal: input.signal } : {}) };
317
+ const matches = await consentedMatches({ ctx, candidates, input: query, pinned });
318
+ const sections = await preparedGuidance({ ctx, matches, input: query, pinned });
319
+ // Obtaining consent and resolving bytes do not prove full guidance was selected for delivery;
320
+ // only a matching commit records the sections the host actually delivered.
321
+ const full = sections.filter(section => section.full);
322
+ const notes = (kept, drafted) => withPluginNotes({ ctx, input: query, installed, candidates, result: joinSections({ sections: kept }), drafted });
323
+ return { loaded, offered: new Map(full.map(({ plugin }) => [plugin.pluginId, plugin.displayName ?? plugin.pluginId])), offer: {
324
+ fullSections: full.map(({ plugin, text }) => ({ pluginId: plugin.pluginId, text })),
325
+ fullPrefix: notes(sections, full.map(({ plugin }) => plugin.pluginId)),
326
+ catalogPrefix: notes(sections.filter(section => !section.full), []),
327
+ } };
328
+ }
329
+ /** Record exactly the delivered ids of the current offer, all or nothing.
330
+ * The live-attempt check is the last await before recording, inside the serialized queue.
331
+ */
332
+ async function commit(ctx, { scope, offerId, deliveredIds }, { signal } = {}) {
333
+ const stored = currentGuidanceOffer({ stored: ctx.offer, scope, offerId });
334
+ if (stored.committed) {
335
+ if (!sameGuidanceChoice({ left: stored.committed.ids, right: deliveredIds }))
336
+ refuseGuidance({ reason: 'replay' });
337
+ await assertAttemptLive({ stored, signal });
338
+ return stored.committed.result;
339
+ }
340
+ assertOfferedChoice({ stored, deliveredIds });
341
+ const { candidates, selected } = await recheckAdmission(ctx, { deliveredIds, signal });
342
+ await assertAttemptLive({ stored, signal });
343
+ for (const id of stored.loaded)
344
+ ctx.alreadyLoaded.add(id);
345
+ if (ctx.mode !== 'off')
346
+ pruneUnavailablePins({ ctx, pinned: ctx.alreadyLoaded, candidates });
347
+ for (const plugin of selected)
348
+ recordDelivery({ ctx, plugin, result: { status: 'loaded', guidance: '' } });
349
+ rememberDelivery(ctx);
350
+ const result = { guidanceIds: currentGuidanceIds(ctx) };
351
+ stored.committed = { ids: [...deliveredIds], result };
352
+ await publishUsage(ctx);
353
+ return result;
354
+ }
355
+ /** Selected ids must still be enabled and not excluded; one unavailable id refuses the whole choice. */
356
+ async function recheckAdmission(ctx, { deliveredIds, signal }) {
357
+ if (signal?.aborted)
358
+ refuseGuidance({ reason: 'cancelled' });
359
+ const { candidates } = await admittedCatalog(ctx);
360
+ const selected = deliveredIds.map(id => candidates.find(plugin => plugin.pluginId === id) ?? refuseGuidance({ reason: 'unavailable' }));
361
+ return { candidates, selected };
362
+ }
363
+ /** Pinned or delivered ids this run can truthfully claim, minus later exclusions. */
364
+ function currentGuidanceIds(ctx) {
365
+ return [...new Set([...ctx.alreadyLoaded, ...ctx.delivered.keys()])].filter(id => !ctx.state.excluded.includes(id));
366
+ }
367
+ /** Share one queue between preflight, offers, commits, explicit reads and simultaneous guarded writes. */
257
368
  function enqueue({ ctx, operation }) {
258
369
  const next = ctx.queue.then(operation);
259
370
  ctx.queue = next.catch(() => undefined);
@@ -268,11 +379,11 @@ function enqueue({ ctx, operation }) {
268
379
  export function createAutomaticAgentPluginUse({ mode, state: initialState, ports }, _options = {}) {
269
380
  const state = readChatAgentPluginState({ value: initialState });
270
381
  const ctx = {
271
- mode, state, ports, delivered: new Map(), publishedSize: undefined, queue: Promise.resolve(),
382
+ mode, state, ports, delivered: new Map(), publishedSize: undefined, queue: Promise.resolve(), offer: undefined, retired: new Set(),
272
383
  alreadyLoaded: new Set(mode === 'off' ? [] : state.decision?.delivered?.filter(id => !state.excluded.includes(id))),
273
384
  };
274
385
  return {
275
- guidanceIds: (_required, _options = {}) => [...new Set([...ctx.alreadyLoaded, ...ctx.delivered.keys()])].filter(id => !ctx.state.excluded.includes(id)),
386
+ guidanceIds: (_required, _options = {}) => currentGuidanceIds(ctx),
276
387
  /** Suggest relevant metadata for a query; capability calls load only their providers. */
277
388
  prepare: (input, _options = {}) => enqueue({ ctx, operation: () => prepare({ ctx, input }) }),
278
389
  /** Resolve one active, permitted id and publish usage only after real guidance is read.
@@ -280,6 +391,14 @@ export function createAutomaticAgentPluginUse({ mode, state: initialState, ports
280
391
  * @example await controller.load({ pluginId: 'my-plugin' });
281
392
  */
282
393
  load: (input, _options = {}) => enqueue({ ctx, operation: () => load(ctx, input) }),
394
+ /** Draft guidance for one live attempt without recording delivery; the host injects the offer id and liveness check.
395
+ * @example const draft = await controller.offer({ scope, offerId, input: { query }, isAttemptLive });
396
+ */
397
+ offer: (required, _optional = {}) => enqueue({ ctx, operation: () => offer(ctx, required) }),
398
+ /** Record the offered ids the host actually delivered; a same-choice replay returns the cached result.
399
+ * @example await controller.commit({ scope, offerId, deliveredIds: ['plugin-a'] });
400
+ */
401
+ commit: (required, optional = {}) => enqueue({ ctx, operation: () => commit(ctx, required, optional) }),
283
402
  };
284
403
  }
285
404
  //# sourceMappingURL=automatic-use.js.map
@@ -1,5 +1,5 @@
1
- import type { AgentPluginArchiveReaderPort } from "./install.js";
2
1
  import type { AgentPluginLifecyclePorts } from "./ports.js";
2
+ import type { AgentPluginArchiveReaderPort } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
3
3
  export interface PackedAgentPluginArchive {
4
4
  /** Bundled archive bytes, or a 32-byte canonical token requiring the paired archiveReader. */
5
5
  readonly bytes: Uint8Array;
@@ -1,4 +1,3 @@
1
- /** Extracted from the host plugin lifecycle. Effects are supplied per host context. */
2
1
  import type { McpServerConfig } from "./manifest.js";
3
2
  import type { AgentPluginLifecyclePorts } from "./ports.js";
4
3
  import { type SkillFileResult } from "./skill-file-reader.js";