@ory/openclaw 0.10.0 → 0.11.1
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 +40 -0
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -67,6 +67,12 @@ function createSessionStartHandler(client, deps) {
|
|
|
67
67
|
// attaches the agent's bearer token to outgoing Ory API calls.
|
|
68
68
|
const agentGate = deps.agentGate ?? argus_1.ensureAgentIdentity;
|
|
69
69
|
await agentGate(client, { projectUrl: (0, argus_1.resolveConfig)().projectUrl, harness: "openclaw" });
|
|
70
|
+
// Record the user→agent delegation so the audit trail captures that
|
|
71
|
+
// this user authorized this agent for this session. Best-effort:
|
|
72
|
+
// requires both principals to be populated, and any failure is logged
|
|
73
|
+
// and swallowed (fail-open — delegation tracking is for audit, not
|
|
74
|
+
// enforcement).
|
|
75
|
+
await recordUserDelegatesAgent(client);
|
|
70
76
|
if (decision.mode !== "disabled") {
|
|
71
77
|
return;
|
|
72
78
|
}
|
|
@@ -508,6 +514,40 @@ function createSubagentEndedHandler(client) {
|
|
|
508
514
|
function resolveNamespace() {
|
|
509
515
|
return process.env.ORY_PERMISSION_NAMESPACE ?? "AgentTools";
|
|
510
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Write the user→agent delegation tuple. Idempotent and fail-open:
|
|
519
|
+
* requires both principal subjects to be populated; any error (including
|
|
520
|
+
* an unconfigured projectUrl, which manifests as a network_error) is
|
|
521
|
+
* logged and swallowed. Purely audit-trail data — does not affect
|
|
522
|
+
* enforcement.
|
|
523
|
+
*/
|
|
524
|
+
async function recordUserDelegatesAgent(client) {
|
|
525
|
+
const user = client.userPrincipal.subject;
|
|
526
|
+
const agent = client.agentPrincipal.subject;
|
|
527
|
+
if (!user || !agent) {
|
|
528
|
+
client.logger.debug("delegation.skip", {
|
|
529
|
+
reason: "missing principal",
|
|
530
|
+
hasUser: !!user,
|
|
531
|
+
hasAgent: !!agent,
|
|
532
|
+
});
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
try {
|
|
536
|
+
await client.createRelationship({
|
|
537
|
+
namespace: resolveNamespace(),
|
|
538
|
+
object: `agent:${agent}`,
|
|
539
|
+
relation: "delegate",
|
|
540
|
+
subjectId: `user:${user}`,
|
|
541
|
+
}, { spanAttributes: { delegation: "user-to-agent" } });
|
|
542
|
+
}
|
|
543
|
+
catch (err) {
|
|
544
|
+
const oryErr = err;
|
|
545
|
+
client.logger.warn("delegation.user_to_agent.failed", {
|
|
546
|
+
code: oryErr.code,
|
|
547
|
+
message: oryErr.message,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
511
551
|
function isOryError(err) {
|
|
512
552
|
return (typeof err === "object" &&
|
|
513
553
|
err !== null &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/openclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Ory plugin for OpenClaw: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://ory.com",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"!dist/**/*.tsbuildinfo"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@ory/argus": "0.
|
|
68
|
+
"@ory/argus": "0.11.1"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22"
|