@ory/claude-code 0.13.8 → 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.
Files changed (2) hide show
  1. package/dist/handlers.js +9 -66
  2. package/package.json +2 -2
package/dist/handlers.js CHANGED
@@ -76,11 +76,11 @@ async function handleSessionStart(input, client, deps) {
76
76
  const agentGate = deps.agentGate ?? argus_1.ensureAgentIdentity;
77
77
  await agentGate(client, { projectUrl: (0, argus_1.resolveConfig)().projectUrl, harness: "claude-code" });
78
78
  // Record the user→agent delegation so the audit trail captures that
79
- // this user authorized this agent for this session. Best-effort:
80
- // requires both principals to be populated, and any failure is logged
81
- // and swallowed (fail-open — delegation tracking is for audit, not
82
- // enforcement).
83
- await recordUserDelegatesAgent(client);
79
+ // this user authorized this agent for this session. Best-effort and
80
+ // written at most once per install: requires both principals to be
81
+ // populated, and any failure is logged and swallowed (fail-open —
82
+ // delegation tracking is for audit, not enforcement).
83
+ await (0, argus_1.writeUserDelegatesAgent)(client);
84
84
  if (!decision.proceed) {
85
85
  return { decision: "block", reason: decision.reason };
86
86
  }
@@ -478,45 +478,11 @@ function permissionRequestFallback(reason) {
478
478
  function resolveNamespace() {
479
479
  return process.env.ORY_PERMISSION_NAMESPACE ?? "AgentTools";
480
480
  }
481
- /**
482
- * Write the user→agent delegation tuple. Idempotent and fail-open:
483
- * requires both principal subjects to be populated; any error (including
484
- * unconfigured projectUrl, which manifests as a network_error) is logged
485
- * and swallowed. The actual permission enforcement is unchanged — this
486
- * tuple is purely audit-trail data.
487
- */
488
- async function recordUserDelegatesAgent(client) {
489
- const user = client.userPrincipal.subject;
490
- const agent = client.agentPrincipal.subject;
491
- if (!user || !agent) {
492
- client.logger.debug("delegation.skip", {
493
- reason: "missing principal",
494
- hasUser: !!user,
495
- hasAgent: !!agent,
496
- });
497
- return;
498
- }
499
- try {
500
- await client.createRelationship({
501
- namespace: resolveNamespace(),
502
- object: `agent:${agent}`,
503
- relation: "delegate",
504
- subjectId: `user:${user}`,
505
- }, { spanAttributes: { delegation: "user-to-agent" } });
506
- }
507
- catch (err) {
508
- const oryErr = err;
509
- client.logger.warn("delegation.user_to_agent.failed", {
510
- code: oryErr.code,
511
- message: oryErr.message,
512
- });
513
- }
514
- }
515
481
  /**
516
482
  * Register an OAuth2 identity for a sub-agent and write the
517
- * `agent → subagent` delegation tuple. Fail-open and idempotent:
518
- * `createRelationship` absorbs 409s, so multiple call paths
519
- * (SubagentStart event + Task-tool fallback) won't duplicate state.
483
+ * `agent → subagent` delegation tuple. Fail-open and written at most once
484
+ * per install, so the multiple call paths (SubagentStart event + Task-tool
485
+ * fallback) won't duplicate state.
520
486
  */
521
487
  async function registerSubAgent(subAgentType, client, deps) {
522
488
  const subAgentGate = deps.subAgentGate ?? argus_1.ensureSubAgentIdentity;
@@ -537,30 +503,7 @@ async function registerSubAgent(subAgentType, client, deps) {
537
503
  }
538
504
  if (identity.kind !== "dynamic" || !identity.subject)
539
505
  return;
540
- const agent = client.agentPrincipal.subject;
541
- if (!agent) {
542
- client.logger.debug("delegation.skip", {
543
- reason: "agent principal not populated",
544
- subAgentType,
545
- });
546
- return;
547
- }
548
- try {
549
- await client.createRelationship({
550
- namespace: resolveNamespace(),
551
- object: `subagent:${identity.subject}`,
552
- relation: "delegate",
553
- subjectId: `agent:${agent}`,
554
- }, { spanAttributes: { delegation: "agent-to-subagent", subAgentType } });
555
- }
556
- catch (err) {
557
- const oryErr = err;
558
- client.logger.warn("delegation.agent_to_subagent.failed", {
559
- subAgentType,
560
- code: oryErr.code,
561
- message: oryErr.message,
562
- });
563
- }
506
+ await (0, argus_1.writeAgentDelegatesSubagent)(client, identity.subject, subAgentType);
564
507
  }
565
508
  /**
566
509
  * Legacy fallback for older Claude Code versions that don't fire
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/claude-code",
3
- "version": "0.13.8",
3
+ "version": "0.13.9",
4
4
  "description": "Ory plugin for Claude Code: 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://github.com/ory/claude-plugins/tree/master/plugins/ory-agent-plugin",
@@ -76,7 +76,7 @@
76
76
  ],
77
77
  "dependencies": {
78
78
  "reo-census": "^1.2.8",
79
- "@ory/argus": "0.13.8"
79
+ "@ory/argus": "0.13.9"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=22"