@ory/amp 0.13.7 → 0.13.9
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/dist/plugin.js +3 -39
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -72,8 +72,9 @@ function createSessionStartHandler(client, deps) {
|
|
|
72
72
|
const agentGate = deps.agentGate ?? argus_1.ensureAgentIdentity;
|
|
73
73
|
await agentGate(client, { projectUrl: (0, argus_1.resolveConfig)().projectUrl, harness: "amp" });
|
|
74
74
|
// Once both principals are populated, write the user→agent delegation
|
|
75
|
-
// tuple.
|
|
76
|
-
|
|
75
|
+
// tuple. Written at most once per install + fail-open: audit-trail data
|
|
76
|
+
// only.
|
|
77
|
+
await (0, argus_1.writeUserDelegatesAgent)(client);
|
|
77
78
|
if (decision.mode !== "disabled") {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -172,46 +173,9 @@ function createToolResultHandler(client) {
|
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
175
|
// ─── Helpers ───────────────────────────────────────────────────────
|
|
175
|
-
function resolveNamespace() {
|
|
176
|
-
return process.env.ORY_PERMISSION_NAMESPACE ?? "AgentTools";
|
|
177
|
-
}
|
|
178
176
|
function isOryError(err) {
|
|
179
177
|
return (typeof err === "object" &&
|
|
180
178
|
err !== null &&
|
|
181
179
|
"code" in err &&
|
|
182
180
|
"message" in err);
|
|
183
181
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Write the user→agent delegation tuple. Idempotent and fail-open:
|
|
186
|
-
* requires both principal subjects to be populated; any error (including
|
|
187
|
-
* an unconfigured projectUrl, which manifests as a network_error) is
|
|
188
|
-
* logged and swallowed. Purely audit-trail data — does not affect
|
|
189
|
-
* enforcement.
|
|
190
|
-
*/
|
|
191
|
-
async function recordUserDelegatesAgent(client) {
|
|
192
|
-
const user = client.userPrincipal.subject;
|
|
193
|
-
const agent = client.agentPrincipal.subject;
|
|
194
|
-
if (!user || !agent) {
|
|
195
|
-
client.logger.debug("delegation.skip", {
|
|
196
|
-
reason: "missing principal",
|
|
197
|
-
hasUser: !!user,
|
|
198
|
-
hasAgent: !!agent,
|
|
199
|
-
});
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
await client.createRelationship({
|
|
204
|
-
namespace: resolveNamespace(),
|
|
205
|
-
object: `agent:${agent}`,
|
|
206
|
-
relation: "delegate",
|
|
207
|
-
subjectId: `user:${user}`,
|
|
208
|
-
}, { spanAttributes: { delegation: "user-to-agent" } });
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
const oryErr = err;
|
|
212
|
-
client.logger.warn("delegation.user_to_agent.failed", {
|
|
213
|
-
code: oryErr.code,
|
|
214
|
-
message: oryErr.message,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/amp",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9",
|
|
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",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"reo-census": "^1.2.8",
|
|
71
|
-
"@ory/argus": "0.13.
|
|
71
|
+
"@ory/argus": "0.13.9"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"typescript": "^6.0.2",
|