Lines 145-228javascript
145 merged["amp.permissions"] = perms;
150 * The in-process plugin loader written at `.amp/plugins/ory.ts`. Amp's Bun
151 * TypeScript runtime discovers direct `*.ts` files under `.amp/plugins/`, so
152 * this re-exports the resolved runtime's default-exported plugin factory by
153 * absolute path — a bare module id would depend on `@ory/amp` being resolvable
154 * from wherever Amp runs.
156function pluginLoaderSource(runtime) {
157 const entry = path.join(runtime.target.packageDir, "dist", "index.js");
158 return (`// Generated by ${PACKAGE_NAME}@${runtime.target.version} — do not edit by hand.\n` +
159 `// Re-exports the Ory in-process plugin for Amp's .amp/plugins/ loader.\n` +
160 `export { default } from ${JSON.stringify(entry)};\n`);
162function getPluginFile(args) {
163 return path.join(args.projectDir, ".amp", "plugins", PLUGIN_FILE);
166 if (process.argv.includes("--help") || process.argv.includes("-h")) {
167 (0, argus_1.printSetupHelp)("ory-amp-setup", "Amp");
170 const args = (0, argus_1.parseSetupArgs)();
LowAi Review Evidence
The setup behavior runs through its CLI entrypoint and has a print-only mode that returns before writing.
dist/cli/setup.jsView on unpkg · L165 172 // Nothing is resolved or written on a --print run.
173 console.log(JSON.stringify({ "amp.permissions": [delegateEntry("<resolved runtime shim>")] }, null, 2));
176 const settingsPath = getSettingsPath(args);
177 const pluginFile = getPluginFile(args);
178 const skillsDir = path.join(args.projectDir, ".agents", "skills");
179 const existing = (0, argus_1.readJsonFile)(settingsPath);
180 if (args.uninstall) {
181 if (fs.existsSync(settingsPath)) {
182 const updated = removePermissions(existing);
183 (0, argus_1.writeJsonFile)(settingsPath, updated);
184 console.log(`Removed Ory permission delegate from ${settingsPath}`);
189 if (fs.existsSync(pluginFile)) {
190 fs.rmSync(pluginFile, { force: true });
191 console.log(`Removed Ory in-process plugin from ${pluginFile}`);
193 (0, assets_js_1.uninstallAmpOryAssets)(args.projectDir);
194 console.log(`Removed Ory skills from ${skillsDir}`);
195 (0, argus_1.removeRuntimeWiring)("amp");
196 for (const pruned of (0, argus_1.pruneRuntimeStores)()) {
197 console.log(` Removed runtime: ${pruned}`);
201 const runtime = wireAmpRuntime(process.argv.slice(2));
202 console.log(runtime.target.kind === "linked"
203 ? `Runtime: linked to ${runtime.target.packageDir} (dev)`
204 : `Runtime: ${runtime.target.packageName}@${runtime.target.version} in ${runtime.target.storeDir}`);
205 for (const pruned of runtime.prunedStores) {
206 console.log(` Removed stale runtime: ${pruned}`);
208 // (a) Register the permission delegate (blocking gate).
209 const merged = mergePermissions(existing, runtime.hookShim);
210 (0, argus_1.writeJsonFile)(settingsPath, merged);
211 // (b) Write the in-process plugin loader (auth + activity auditing).
LowAi Review Evidence
The installer adds the Ory permission delegate and plugin loader to Amp configuration, consistent with the package's stated permission and auditing purpose.
dist/cli/setup.jsView on unpkg · L208 212 fs.mkdirSync(path.dirname(pluginFile), { recursive: true });
213 fs.writeFileSync(pluginFile, pluginLoaderSource(runtime));
214 // (c) Materialize the Ory skill catalog.
215 (0, assets_js_1.installAmpOryAssets)(args.projectDir);
216 console.log(`Ory permission delegate registered in ${settingsPath}`);
217 console.log(` Delegate: ${runtime.hookShim} (tool: "*", action: delegate)`);
218 console.log(`Ory in-process plugin written to ${pluginFile}`);
219 console.log(`Ory skills installed under ${skillsDir}`);
220 (0, argus_1.printNextSteps)("Amp", "npx -y -p @ory/amp ory-amp-setup --uninstall", {
226// When invoked directly as the `-setup` bin with `--uninstall`, also clear
227// stored Ory credentials. When required by the plugin's main CLI, that
228// command owns the purge, so the `require.main` guard prevents a double run.