@ory/amp 0.11.0 → 0.12.0
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/README.md +85 -65
- package/dist/cli/main.js +11 -8
- package/dist/cli/setup.js +13 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,117 +1,137 @@
|
|
|
1
1
|
# Ory Agent Plugin: Amp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Security and developer experience for [Amp](https://ampcode.com) (Sourcegraph's coding agent), powered by [Ory](https://ory.com).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Security.** Amp runs real actions on your machine — editing files, running shell commands, calling APIs. The plugin gives every session a verifiable identity (you sign in once; Amp and any sub-agents it spawns each get their own), checks every tool call against permissions you control, and records each decision as an audit trace you can ship to your observability stack. It starts in watch mode so nothing is blocked on day one, and if Ory is ever unreachable it steps aside rather than locking you out.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Developer experience.** A single command installs the plugin and walks you through connecting — choose Ory Network, a local Docker stack, or audit-only, and it wires up the project, sign-in client, login, and permissions for you. It also helps you build Ory into your own app: ask in plain language to scaffold login, registration, and recovery pages, run a local Ory, or manage identities and permissions through the bundled MCP server.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What you'll need
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- **
|
|
11
|
+
- [Amp](https://ampcode.com), installed
|
|
12
|
+
- Node.js **22 or newer**
|
|
13
|
+
- [Docker](https://docs.docker.com/get-docker/) — only if you want to run Ory locally
|
|
14
|
+
- macOS or Linux (Windows works via WSL2)
|
|
13
15
|
|
|
14
|
-
##
|
|
16
|
+
## Get started
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
Run one command. It installs the plugin and walks you through connecting:
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
```bash
|
|
21
|
+
npx -y -p @ory/amp ory-amp install
|
|
22
|
+
```
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
You'll be asked how you want to connect — **press Enter for the default**:
|
|
22
25
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- macOS or Linux. Windows works via WSL2.
|
|
26
|
+
- **Ory Network** *(default)* — sign in, or create a free account, in your browser. The project, keys, permissions, and login are all set up for you. Nothing to configure by hand.
|
|
27
|
+
- **Local** — run a complete Ory on your laptop with Docker. No account, no signup, no keys. Great for trying it out.
|
|
28
|
+
- **Audit-only** — skip Ory entirely and just log what Amp does.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
That's it. Confirm everything landed with:
|
|
29
31
|
|
|
30
32
|
```bash
|
|
31
|
-
npx -y -p @ory/amp ory-amp
|
|
33
|
+
npx -y -p @ory/amp ory-amp status
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
`
|
|
36
|
+
`status` is your one-stop check: what's configured, who's signed in, which tools are covered by permissions, whether the plugin is wired into Amp, and recent activity.
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
2. Writes the **in-process plugin** loader at `<project>/.amp/plugins/ory.ts` so Amp's Bun TypeScript runtime discovers it for session auth and audit tracing.
|
|
38
|
+
Re-run install with `--reconfigure` to change your connection later, or `--no-configure` to skip the wizard and configure by hand.
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
## What you get
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
npx -y -p @ory/amp ory-amp status # confirm delegate + plugin registration
|
|
43
|
-
npx -y -p @ory/amp ory-amp uninstall # remove the delegate, plugin, and skills
|
|
44
|
-
```
|
|
42
|
+
Once connected, every tool Amp runs is governed by Ory — three things happen automatically:
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
- **Who's driving.** You sign in once in your browser; Amp gets its own identity too, and registers it automatically on first run. No tokens to copy around, and the "who acted on whose behalf" trail stays queryable later.
|
|
45
|
+
- **What it's allowed to do.** Before a tool runs, Ory checks whether it's permitted. It starts in **watch mode** — nothing is blocked, you just *see* what would be — so it never gets in your way on day one.
|
|
46
|
+
- **A record of everything.** Every decision (allowed, denied, skipped) is logged as a trace you can send to a viewer like Jaeger or Honeycomb, or just a file.
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
If Ory is ever slow or unreachable, the plugin gets out of the way and lets Amp keep working — so it can't lock you out.
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
### See what's happening
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
2. **Scaffold Ory into your project.** Ask Amp *"add Ory auth to this app"* (the `ory-auth-setup` skill). It installs Ory Elements, wires the SDK, and generates the login / registration / recovery / settings pages, all targeting the local stack.
|
|
54
|
-
3. **Sign in.** Start your app, visit the login page, and sign in with the seeded credentials. You now have a real Ory session backed by a real Ory stack — locally, offline, zero configuration.
|
|
52
|
+
Everything the plugin does is observable out of the box — no configuration required:
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
- **Status at a glance.** `npx -y -p @ory/amp ory-amp status` shows what's configured, who's signed in, how many built-in tools your permissions cover, and the most recent tool-call activity.
|
|
55
|
+
- **Live traces.** Every tool call is recorded as an OpenTelemetry-style span. Watch them stream as the agent works:
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
```bash
|
|
58
|
+
npx -y -p @ory/amp ory-amp watch
|
|
59
|
+
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
Spans are also written to `~/.config/ory-agent-plugins/amp/ory-agent-trace.ndjson` (NDJSON, one span per line) — tail that file, or point `OTEL_EXPORTER_OTLP_ENDPOINT` at a collector to ship them straight to Jaeger, Honeycomb, or Grafana.
|
|
62
|
+
- **Debug log.** For a verbose play-by-play, set `ORY_AGENT_DEBUG=true`; structured logs land in `~/.config/ory-agent-plugins/amp/ory-agent-debug.log`.
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
- **Advisory in-process plugin (`.amp/plugins/ory.ts`).** Discovered by Amp's Bun runtime, it handles session-start auth (advisory — it cannot hard-block at session start) and post-tool audit tracing.
|
|
64
|
+
### Ready to enforce?
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
When the watch-mode logs look right, turn on blocking with one command (setup already granted you the built-in tools):
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
68
|
+
```bash
|
|
69
|
+
npx -y -p @ory/amp ory-amp permissions enforce
|
|
70
|
+
```
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
Now a denied tool is actually blocked and Amp shows why. Go back to watch mode anytime with `permissions observe`. Use `permissions status` to see what's covered and `permissions bootstrap` to (re-)grant the built-in tools.
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
<details>
|
|
75
|
+
<summary>How the plugin plugs into Amp</summary>
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
Amp gets the plugin in two pieces that work together:
|
|
76
78
|
|
|
77
|
-
- **
|
|
78
|
-
- **
|
|
79
|
-
- **Audit.** Every decision is recorded as a structured trace span (NDJSON file and/or OTLP export).
|
|
79
|
+
- **A permission gate** registered in Amp's settings (`~/.config/amp/settings.json`) under the `amp.permissions` key. Before every tool call, Amp hands the tool and its params to this gate and reads the answer from its **exit code**: `0` = allow, `1` = ask, `≥2` = reject (the reason on stderr is shown to Amp). This is the piece that can actually block.
|
|
80
|
+
- **An in-process plugin** at `<project>/.amp/plugins/ory.ts`, which Amp's built-in TypeScript runtime loads to sign you in at the start of a session and record what happened after each tool runs. It can't block from there, so it's advisory only — the gate above does the blocking.
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
Amp gives the gate 10 seconds to answer and treats a slower gate as a reject, so the plugin sets its own shorter deadline (5 seconds, adjustable with `ORY_AMP_CHECK_TIMEOUT_MS`) and lets the tool through if the Ory check is slow, stuck, or unreachable — it never leaves you hanging.
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
The Ory skills land under `<project>/.agents/skills/`. `uninstall` removes the gate, the plugin, and the skills.
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
# Grant the current user `use` on every built-in tool (idempotent):
|
|
87
|
-
npx -y -p @ory/amp ory-amp permissions bootstrap
|
|
86
|
+
</details>
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
npx -y -p @ory/amp ory-amp permissions status
|
|
88
|
+
## Also: add login to your own app
|
|
91
89
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
Beyond securing Amp, the plugin helps you build Ory into whatever you're working on. The Ory skills are **model-invoked** — just ask Amp in plain language and the right one takes over (Amp doesn't use slash commands for these). Ask Amp *"add Ory login to this app"* and it scaffolds the login, registration, recovery, and settings pages (using [Ory Elements](https://github.com/ory/elements)) wired to a local Ory — no signup or keys needed. Start that local Ory by asking *"start the local Ory stack"* (it prints a test email + password to sign in with).
|
|
91
|
+
|
|
92
|
+
More bundled **skills** cover login and social sign-in (Google, GitHub, Apple…), permissions onboarding, and playbooks for wiring Ory into your own agents, E2B sandboxes, or Temporal workers.
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
The local Ory runs entirely on your laptop: the Ory APIs at `http://localhost:4000`, a login UI on `:4455` (not `:3000`, to avoid clashing with Next.js dev servers), the Ory Console on `:4100`, and a trace viewer (Jaeger) on `:16686`.
|
|
97
95
|
|
|
98
|
-
##
|
|
96
|
+
## Configure by hand (CI / advanced)
|
|
99
97
|
|
|
100
|
-
The
|
|
98
|
+
The guided setup covers most people. For scripted or CI setups, or to point at an existing Ory Network project, configure directly. Settings are saved to `~/.config/ory-agent-plugins/config.json` and shared across all your Ory agent plugins; environment variables win when both are set.
|
|
101
99
|
|
|
102
100
|
```bash
|
|
103
101
|
npx -y -p @ory/amp ory-amp configure \
|
|
104
|
-
--project-url https://<
|
|
105
|
-
--oauth2-client-id <
|
|
102
|
+
--project-url https://<slug>.projects.oryapis.com \
|
|
103
|
+
--oauth2-client-id <sign-in client id> \
|
|
104
|
+
--user-login
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Amp's own identity registers itself automatically on first run — nothing to create. The `--oauth2-client-id` is the one piece browser sign-in needs (the public client registered with the four loopback callback URLs `http://127.0.0.1:47823..47826/callback`); the guided setup makes it for you. Pass `--api-key ory_pat_...` only to override Amp's auto-created identity with a static token. For logging-only with no checks, use `--audit-only`. The matching env vars are `ORY_PROJECT_URL`, `ORY_OAUTH2_CLIENT_ID`, `ORY_USER_LOGIN`, and `ORY_AGENT_API_KEY`.
|
|
108
|
+
|
|
109
|
+
With nothing configured, the plugin still loads and runs in **pass-through mode**: skills and logging work, but no checks run and nothing is blocked. Perfectly fine if you only want the app-building features.
|
|
110
|
+
|
|
111
|
+
## Commands
|
|
112
|
+
|
|
106
113
|
```
|
|
114
|
+
ory-amp install | uninstall Install/remove; --reconfigure re-runs setup, --no-configure skips it
|
|
115
|
+
ory-amp status Show configuration, identities, permission coverage, and recent activity
|
|
116
|
+
ory-amp watch Tail the live trace stream (OTel spans)
|
|
117
|
+
ory-amp permissions <cmd> status | bootstrap | observe (watch) | enforce (block)
|
|
118
|
+
ory-amp configure <flags> Point at a project by hand (--project-url, --oauth2-client-id, --user-login, --audit-only)
|
|
119
|
+
ory-amp agent <status|unregister> Manage Amp's own auto-created identity
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
All prefixed with `npx -y -p @ory/amp`.
|
|
107
123
|
|
|
108
|
-
|
|
124
|
+
## Troubleshooting
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
- **Local Ory fails to start** — make sure Docker is running and ports `4000`, `4100`, `4455`, and `16686` are free.
|
|
127
|
+
- **Browser sign-in loops** — reset with `ory-amp agent unregister` and try again.
|
|
128
|
+
- **`npx` grabbed an old version** — force the latest: `npx -y -p @ory/amp@latest ory-amp …`.
|
|
129
|
+
- **A tool check feels slow** — the plugin gives up on a stalled Ory check and lets the tool through; tune the deadline with `ORY_AMP_CHECK_TIMEOUT_MS`.
|
|
130
|
+
- **Want to see what's happening** — `npx -y -p @ory/amp ory-amp status` for a snapshot, `npx -y -p @ory/amp ory-amp watch` for the live trace stream, or set `ORY_AGENT_DEBUG=true` for a verbose log. Traces and logs live under `~/.config/ory-agent-plugins/amp/` (see [See what's happening](#see-whats-happening)).
|
|
111
131
|
|
|
112
|
-
##
|
|
132
|
+
## Learn more
|
|
113
133
|
|
|
114
|
-
- [Ory documentation](https://www.ory.com/docs/)
|
|
134
|
+
- [Ory documentation](https://www.ory.com/docs/) · [Ory Console](https://console.ory.sh) · [Ory Elements](https://github.com/ory/elements)
|
|
115
135
|
- [Amp documentation](https://ampcode.com)
|
|
116
136
|
- [Repo README](../../README.md) and [AGENTS.md](../../AGENTS.md) — full env-var and permission-mode reference
|
|
117
137
|
|
package/dist/cli/main.js
CHANGED
|
@@ -52,14 +52,19 @@ function main() {
|
|
|
52
52
|
const [command, ...args] = process.argv.slice(2);
|
|
53
53
|
switch (command) {
|
|
54
54
|
case "install":
|
|
55
|
+
(0, argus_1.beginDeferNextSteps)();
|
|
55
56
|
install(args);
|
|
56
|
-
|
|
57
|
+
(0, argus_1.runPostInstall)("ory-amp", "amp", args).then(() => process.exit(0), (err) => {
|
|
57
58
|
console.error(err.message ?? err);
|
|
58
59
|
process.exit(1);
|
|
59
60
|
});
|
|
60
61
|
break;
|
|
61
62
|
case "uninstall":
|
|
62
63
|
uninstall(args);
|
|
64
|
+
(0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
|
|
65
|
+
console.error(err.message ?? err);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
63
68
|
break;
|
|
64
69
|
case "configure":
|
|
65
70
|
(0, argus_1.runConfigureCommand)("ory-amp", args);
|
|
@@ -91,6 +96,9 @@ function main() {
|
|
|
91
96
|
process.exit(1);
|
|
92
97
|
});
|
|
93
98
|
break;
|
|
99
|
+
case "watch":
|
|
100
|
+
(0, argus_1.runWatchCommand)("amp", args);
|
|
101
|
+
break;
|
|
94
102
|
case "help":
|
|
95
103
|
case "--help":
|
|
96
104
|
case "-h":
|
|
@@ -117,12 +125,6 @@ function uninstall(args) {
|
|
|
117
125
|
process.argv = ["node", "setup.js", "--uninstall", ...args];
|
|
118
126
|
require("./setup.js");
|
|
119
127
|
}
|
|
120
|
-
async function postInstallPermissions(binName, harness) {
|
|
121
|
-
const bootstrapped = await (0, argus_1.maybeAutoBootstrap)(binName, harness);
|
|
122
|
-
(0, argus_1.printPermissionsOnboardingHelp)(binName, harness, {
|
|
123
|
-
bootstrappedAutomatically: bootstrapped,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
128
|
function parseProjectDir(args) {
|
|
127
129
|
const idx = args.indexOf("--project-dir");
|
|
128
130
|
if (idx !== -1 && args[idx + 1])
|
|
@@ -175,6 +177,7 @@ Commands:
|
|
|
175
177
|
(status, bootstrap, observe, enforce)
|
|
176
178
|
setup [--project-dir <path>] Write config directly (fallback)
|
|
177
179
|
status [--project-dir <path>] Show plugin configuration and status
|
|
180
|
+
watch [trace-file] Tail the trace stream (OTel spans) live
|
|
178
181
|
local <cmd> Manage local Ory dev environment
|
|
179
182
|
(up, down, status, seed, logs, env, configure, reset)
|
|
180
183
|
|
|
@@ -184,7 +187,7 @@ After installing, the Ory integration runs in two parts:
|
|
|
184
187
|
|
|
185
188
|
Examples:
|
|
186
189
|
npx -y -p @ory/amp ory-amp install
|
|
187
|
-
npx -y -p @ory/amp ory-amp configure --project-url https://<
|
|
190
|
+
npx -y -p @ory/amp ory-amp configure --project-url https://<slug>.projects.oryapis.com
|
|
188
191
|
npx -y -p @ory/amp ory-amp permissions bootstrap
|
|
189
192
|
npx -y -p @ory/amp ory-amp status
|
|
190
193
|
`);
|
package/dist/cli/setup.js
CHANGED
|
@@ -192,6 +192,18 @@ function main() {
|
|
|
192
192
|
console.log(` Delegate: ${DELEGATE_BIN} (tool: "*", action: delegate)`);
|
|
193
193
|
console.log(`Ory in-process plugin written to ${pluginFile}`);
|
|
194
194
|
console.log(`Ory skills installed under ${skillsDir}`);
|
|
195
|
-
(0, argus_1.printNextSteps)("Amp", "npx ory-amp-setup --uninstall"
|
|
195
|
+
(0, argus_1.printNextSteps)("Amp", "npx -y -p @ory/amp ory-amp-setup --uninstall", {
|
|
196
|
+
binName: "ory-amp",
|
|
197
|
+
harness: "amp",
|
|
198
|
+
});
|
|
196
199
|
}
|
|
197
200
|
main();
|
|
201
|
+
// When invoked directly as the `-setup` bin with `--uninstall`, also clear
|
|
202
|
+
// stored Ory credentials. When required by the plugin's main CLI, that
|
|
203
|
+
// command owns the purge, so the `require.main` guard prevents a double run.
|
|
204
|
+
if (require.main === module && process.argv.includes("--uninstall")) {
|
|
205
|
+
(0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
|
|
206
|
+
console.error(err.message ?? err);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
});
|
|
209
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/amp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Ory plugin for Amp (Sourcegraph's coding agent): a permission delegate that authorizes every tool call plus an in-process plugin for session auth and audit tracing",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://ory.com",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"!dist/**/*.tsbuildinfo"
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@ory/argus": "0.
|
|
70
|
+
"@ory/argus": "0.12.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"typescript": "^6.0.2",
|