@ory/argus 0.14.0 → 1.0.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.
Files changed (150) hide show
  1. package/README.md +31 -46
  2. package/assets/commands/temporal-up.md +1 -1
  3. package/assets/skills/auth-setup/SKILL.md +1 -1
  4. package/assets/skills/local-dev/SKILL.md +17 -7
  5. package/assets/skills/ory-build-agent/SKILL.md +39 -91
  6. package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -17
  7. package/assets/skills/ory-temporal-worker/SKILL.md +31 -33
  8. package/assets/skills/permissions-onboarding/SKILL.md +131 -104
  9. package/dist/adapters.d.ts +88 -32
  10. package/dist/adapters.js +443 -164
  11. package/dist/agent-auth.d.ts +226 -67
  12. package/dist/agent-auth.js +951 -205
  13. package/dist/auth-store.d.ts +37 -2
  14. package/dist/auth-store.js +37 -3
  15. package/dist/auth.d.ts +33 -4
  16. package/dist/auth.js +163 -20
  17. package/dist/bash-parser.d.ts +98 -0
  18. package/dist/bash-parser.js +396 -0
  19. package/dist/branding.d.ts +77 -16
  20. package/dist/branding.js +93 -23
  21. package/dist/build-info.json +4 -4
  22. package/dist/cli-invocation.d.ts +1 -1
  23. package/dist/cli-invocation.js +2 -1
  24. package/dist/cli.d.ts +20 -29
  25. package/dist/cli.js +271 -239
  26. package/dist/client.d.ts +175 -138
  27. package/dist/client.js +672 -391
  28. package/dist/config.d.ts +217 -54
  29. package/dist/config.js +461 -42
  30. package/dist/context.d.ts +10 -0
  31. package/dist/context.js +21 -0
  32. package/dist/contract-suite.d.ts +3 -5
  33. package/dist/contract-suite.js +75 -47
  34. package/dist/denial.d.ts +36 -3
  35. package/dist/denial.js +79 -10
  36. package/dist/event-reporter.d.ts +77 -0
  37. package/dist/event-reporter.js +776 -0
  38. package/dist/external-registrations-main.d.ts +10 -0
  39. package/dist/external-registrations-main.js +38 -0
  40. package/dist/external-registrations.d.ts +79 -0
  41. package/dist/external-registrations.js +188 -0
  42. package/dist/help-cli.d.ts +39 -0
  43. package/dist/help-cli.js +55 -0
  44. package/dist/hook-timeout.d.ts +64 -0
  45. package/dist/hook-timeout.js +88 -0
  46. package/dist/index.d.ts +28 -23
  47. package/dist/index.js +173 -58
  48. package/dist/lifecycle.d.ts +3 -3
  49. package/dist/lifecycle.js +38 -6
  50. package/dist/local/cli.js +11 -6
  51. package/dist/local/configs.d.ts +74 -18
  52. package/dist/local/configs.js +291 -84
  53. package/dist/local/health.js +7 -7
  54. package/dist/local/index.d.ts +2 -2
  55. package/dist/local/index.js +24 -10
  56. package/dist/local/manager.d.ts +20 -1
  57. package/dist/local/manager.js +159 -36
  58. package/dist/local/ports.d.ts +158 -0
  59. package/dist/local/ports.js +443 -0
  60. package/dist/local/seed.d.ts +13 -5
  61. package/dist/local/seed.js +62 -38
  62. package/dist/logger.d.ts +54 -25
  63. package/dist/logger.js +329 -63
  64. package/dist/mcp.d.ts +2 -2
  65. package/dist/mcp.js +10 -5
  66. package/dist/mirror-bootstrap.d.ts +48 -0
  67. package/dist/mirror-bootstrap.js +254 -0
  68. package/dist/opl.d.ts +289 -0
  69. package/dist/opl.js +446 -0
  70. package/dist/permission-mode.d.ts +87 -0
  71. package/dist/permission-mode.js +307 -0
  72. package/dist/permissions-cli.d.ts +13 -49
  73. package/dist/permissions-cli.js +154 -348
  74. package/dist/permissions.d.ts +148 -38
  75. package/dist/permissions.js +591 -45
  76. package/dist/post-install.d.ts +33 -0
  77. package/dist/post-install.js +127 -0
  78. package/dist/read-credential.d.ts +65 -0
  79. package/dist/read-credential.js +86 -0
  80. package/dist/registry/cli.js +5 -2
  81. package/dist/registry/config.d.ts +0 -17
  82. package/dist/registry/config.js +0 -23
  83. package/dist/registry/index.d.ts +1 -1
  84. package/dist/registry/index.js +2 -2
  85. package/dist/registry/manager.d.ts +4 -21
  86. package/dist/registry/manager.js +21 -37
  87. package/dist/runtime-credential.d.ts +140 -0
  88. package/dist/runtime-credential.js +572 -0
  89. package/dist/runtime.d.ts +413 -0
  90. package/dist/runtime.js +825 -0
  91. package/dist/setup.d.ts +23 -47
  92. package/dist/setup.js +59 -116
  93. package/dist/skills.js +0 -7
  94. package/dist/status-cli.d.ts +27 -11
  95. package/dist/status-cli.js +121 -115
  96. package/dist/status-data.d.ts +116 -17
  97. package/dist/status-data.js +121 -38
  98. package/dist/subject.d.ts +126 -20
  99. package/dist/subject.js +215 -30
  100. package/dist/testing.d.ts +74 -38
  101. package/dist/testing.js +185 -68
  102. package/dist/tool-catalog.d.ts +53 -11
  103. package/dist/tool-catalog.js +164 -13
  104. package/dist/tool-metadata.d.ts +7 -6
  105. package/dist/tool-metadata.js +6 -5
  106. package/dist/types.d.ts +11 -1
  107. package/dist/uninstall.d.ts +71 -34
  108. package/dist/uninstall.js +217 -85
  109. package/dist/user-login.d.ts +9 -10
  110. package/dist/user-login.js +56 -75
  111. package/dist/watch-cli.d.ts +6 -0
  112. package/dist/watch-cli.js +217 -0
  113. package/package.json +4 -27
  114. package/assets/commands/dashboard.md +0 -34
  115. package/dist/dashboard-cli.d.ts +0 -8
  116. package/dist/dashboard-cli.js +0 -70
  117. package/dist/dev.d.ts +0 -103
  118. package/dist/dev.js +0 -583
  119. package/dist/interactive-setup.d.ts +0 -286
  120. package/dist/interactive-setup.js +0 -1734
  121. package/dist/local/jaeger-main.d.ts +0 -13
  122. package/dist/local/jaeger-main.js +0 -85
  123. package/dist/local/jaeger.d.ts +0 -50
  124. package/dist/local/jaeger.js +0 -162
  125. package/dist/otel/exporter.d.ts +0 -17
  126. package/dist/otel/exporter.js +0 -12
  127. package/dist/otel/index.d.ts +0 -2
  128. package/dist/otel/index.js +0 -8
  129. package/dist/otel/otlp.d.ts +0 -103
  130. package/dist/otel/otlp.js +0 -385
  131. package/dist/project-api-key.d.ts +0 -69
  132. package/dist/project-api-key.js +0 -147
  133. package/dist/setup-actions.d.ts +0 -232
  134. package/dist/setup-actions.js +0 -507
  135. package/dist/tracer.d.ts +0 -190
  136. package/dist/tracer.js +0 -481
  137. package/dist/watch-sandbox.d.ts +0 -9
  138. package/dist/watch-sandbox.js +0 -81
  139. package/dist/web/api.d.ts +0 -33
  140. package/dist/web/api.js +0 -294
  141. package/dist/web/launch.d.ts +0 -11
  142. package/dist/web/launch.js +0 -96
  143. package/dist/web/server.d.ts +0 -20
  144. package/dist/web/server.js +0 -233
  145. package/dist/web/types.d.ts +0 -65
  146. package/dist/web/types.js +0 -2
  147. package/dist/webapp/assets/index-Wucl4SZs.css +0 -1
  148. package/dist/webapp/assets/index-m-GtEdq0.js +0 -49
  149. package/dist/webapp/favicon.ico +0 -0
  150. package/dist/webapp/index.html +0 -15
@@ -2,15 +2,18 @@
2
2
  * Shared adapter primitives for Agent SDK integrations (and harness plugins).
3
3
  *
4
4
  * These extract the session-start sequencing and the `tool.invoke` / `tool.block` /
5
- * `tool.complete` span boilerplate that each integration would otherwise re-implement, so
5
+ * `tool.complete` activity boilerplate that each integration would otherwise re-implement, so
6
6
  * an SDK binding is a thin translation between the SDK's hook signature and these calls.
7
7
  * They are the TypeScript twin of `ory_argus.adapters` in the Python core.
8
8
  *
9
+ * - {@link withHookContext} — scope session state to one lifecycle invocation.
9
10
  * - {@link sessionStart} — run the user + agent auth gates and write the user→agent
10
11
  * delegation tuple; returns whether the session may proceed.
11
- * - {@link gate} — resolve the subject, run {@link gateToolCall}, record the spans, and
12
+ * - {@link createSessionStarter} — coalesce concurrent lazy SDK session starts.
13
+ * - {@link decideTool} — normalize native/MCP policy without execution activity.
14
+ * - {@link gate} — resolve the subject, run {@link gateToolCall}, record activity, and
12
15
  * return a normalized {@link GateResult}.
13
- * - {@link complete} — record the `tool.complete` span.
16
+ * - {@link complete} / {@link fail} — record safe terminal tool activity.
14
17
  * - {@link registerSubagent} — resolve a sub-agent identity + agent→subagent tuple.
15
18
  * - {@link wrapTool} — wrap a plain `execute(args)` with gate+complete, for SDKs whose
16
19
  * only veto point is the tool boundary (Vercel AI SDK, etc.).
@@ -20,8 +23,17 @@
20
23
  import type { OryAgentClient } from "./client.js";
21
24
  import { ensureAgentIdentity, ensureSubAgentIdentity } from "./agent-auth.js";
22
25
  import { ensureUserAuthenticated } from "./user-login.js";
23
- import { type PermissionDecision } from "./permissions.js";
26
+ import { type ModeDecision, type PermissionDecision, type PrincipalBlockSubjects } from "./permissions.js";
27
+ import { type DenialContext } from "./denial.js";
28
+ import { type McpToolIdentifier } from "./mcp.js";
29
+ import type { RuntimeCredential } from "./runtime-credential.js";
24
30
  export declare function resolveNamespace(): string;
31
+ export interface HookContextOptions {
32
+ sessionId?: string;
33
+ runtimeCredential?: RuntimeCredential;
34
+ }
35
+ /** Scope ambient session state to one lifecycle invocation. */
36
+ export declare function withHookContext<T>(client: OryAgentClient, opts: HookContextOptions, work: () => T): T;
25
37
  export interface SessionStartResult {
26
38
  proceed: boolean;
27
39
  userMode: string;
@@ -30,68 +42,100 @@ export interface SessionStartResult {
30
42
  }
31
43
  export interface SessionStartOptions {
32
44
  harness: string;
45
+ sessionId?: string;
33
46
  projectUrl?: string;
34
47
  binName?: string;
35
48
  /** Injectable gates (tests). */
36
49
  userLogin?: typeof ensureUserAuthenticated;
37
50
  agentGate?: typeof ensureAgentIdentity;
51
+ /** Small, privacy-safe session metadata supported by the activity API. */
52
+ activityAttributes?: Record<string, unknown>;
38
53
  }
39
54
  /**
40
55
  * Run both auth gates and write the user→agent delegation tuple. The user gate
41
56
  * runs every session to establish/refresh the user identity, records the
42
- * `user.auth` span, and never blocks — enforcement is governed by
57
+ * `user.auth` activity event, and never blocks — enforcement is governed by
43
58
  * `permissionMode` at tool-call time. `SessionStartResult.proceed` is therefore
44
59
  * always `true`; it is retained only for a stable adapter shape.
45
60
  */
46
61
  export declare function sessionStart(client: OryAgentClient, opts: SessionStartOptions): Promise<SessionStartResult>;
62
+ /** Build a concurrency-safe, retryable lazy session-start trigger. */
63
+ export declare function createSessionStarter(client: OryAgentClient, opts: SessionStartOptions): () => Promise<void>;
47
64
  /**
48
- * Write the `user → agent` delegation tuple, at most once per install
49
- * (see {@link writeDelegationOnce}). Exported so harness plugins that run
50
- * their own session-start sequence (rather than {@link sessionStart}) share
51
- * the same write-once semantics instead of re-issuing the write every
52
- * session.
65
+ * Record the `user → agent` delegation edge through the agent-security broker
66
+ * (see {@link OryAgentClient.recordDelegation}). Exported so harness plugins
67
+ * that run their own session-start sequence (rather than {@link sessionStart})
68
+ * record the edge the same way.
53
69
  *
54
- * The tuple is a *derived projection* of the delegation anchor stamped into
55
- * the agent's OAuth2 client metadata at registration: the edge is resolved
56
- * from the live principals when populated, otherwise rebuilt from the persisted
57
- * anchor so a tuple lost out of band can be self-healed from the identity
58
- * layer. No-op only when neither source yields both ends.
70
+ * The plugin supplies only the delegating user identity (resolved from the live
71
+ * principal, else the persisted delegation anchor) plus the harness and host;
72
+ * the broker owns the Keto tuple and its join-key encoding. The node id the
73
+ * broker returns (`agent:<join>`) is persisted so a later sub-agent
74
+ * registration which may run in a separate subprocess with no live principal
75
+ * — can reference it verbatim as `delegated_by`. Best-effort and fail-open:
76
+ * any failure (including a 404 against the local stack, which has no broker) is
77
+ * logged and swallowed. No-op when Agent Security isn't connected (there is no
78
+ * broker to record against) and when no user identity resolves.
59
79
  */
60
- export declare function writeUserDelegatesAgent(client: OryAgentClient): Promise<void>;
80
+ export declare function writeUserDelegatesAgent(client: OryAgentClient, harness?: string, sessionId?: string): Promise<void>;
61
81
  export interface RegisterSubagentOptions {
62
82
  harness: string;
63
83
  subAgentType: string;
64
84
  projectUrl?: string;
65
85
  subAgentGate?: typeof ensureSubAgentIdentity;
86
+ /**
87
+ * Identifier for this individual spawn, where the harness exposes one
88
+ * (Cursor's `subagent_id`, Claude Code's `agent_id`, OpenClaw's `childRunId`).
89
+ * Distinguishes two concurrent sub-agents of the same type; absent on
90
+ * harnesses that expose no such id.
91
+ */
92
+ perSpawnId?: string;
93
+ sessionId?: string;
94
+ signal?: AbortSignal;
66
95
  }
67
96
  export declare function registerSubagent(client: OryAgentClient, opts: RegisterSubagentOptions): Promise<void>;
68
97
  /**
69
- * Write the `agent → subagent` delegation tuple, at most once per install
70
- * (see {@link writeDelegationOnce}). Exported so harness plugins that
71
- * resolve the sub-agent identity through their own event plumbing (rather
72
- * than {@link registerSubagent}) still share the write-once semantics.
73
- * No-op until the agent principal is populated.
98
+ * Record the `agent → subagent` delegation edge through the agent-security
99
+ * broker. Exported so harness plugins that resolve the sub-agent identity
100
+ * through their own event plumbing (rather than {@link registerSubagent})
101
+ * record the edge the same way.
102
+ *
103
+ * The broker builds the sub-agent node from the parent agent's delegation node
104
+ * (`delegated_by`) and the sub-agent type — so the plugin passes the node id
105
+ * the broker assigned to the `user → agent` edge (persisted at session start),
106
+ * echoed verbatim, and never reconstructs the join-key encoding itself.
107
+ * Best-effort and fail-open. No-op when Agent Security isn't connected and until the
108
+ * `user → agent` edge has been
109
+ * recorded (so the parent node id is available).
74
110
  */
75
- export declare function writeAgentDelegatesSubagent(client: OryAgentClient, subAgentSubject: string, subAgentType: string): Promise<void>;
111
+ export declare function writeAgentDelegatesSubagent(client: OryAgentClient, subAgentSubject: string, subAgentType: string, opts?: {
112
+ harness?: string;
113
+ sessionId?: string;
114
+ perSpawnId?: string;
115
+ agentToken?: string;
116
+ runtimeCredential?: RuntimeCredential;
117
+ signal?: AbortSignal;
118
+ }): Promise<void>;
76
119
  export interface GateResult {
77
120
  /** False only when the tool was hard-denied in enforce mode. */
78
121
  proceed: boolean;
79
122
  /** True only for that deny (and only when `canBlock`). */
80
123
  blocked: boolean;
81
- /** Discriminator: allow / observe / deny / fail_open / interactive / audit_only. */
124
+ /** Discriminator: allow / observe / deny / fail_open / interactive / not_connected. */
82
125
  kind: string;
83
126
  decision: ToolGateOutcomeLike;
84
127
  subject: string;
85
128
  namespace: string;
86
129
  denialMessage?: string;
130
+ denialContext?: DenialContext;
87
131
  }
88
132
  type ToolGateOutcomeLike = {
89
- kind: "audit_only";
90
- spanAttributes: Record<string, unknown>;
133
+ kind: "not_connected";
134
+ activityAttributes: Record<string, unknown>;
91
135
  } | {
92
136
  kind: "interactive";
93
- spanAttributes: Record<string, unknown>;
94
- } | PermissionDecision;
137
+ activityAttributes: Record<string, unknown>;
138
+ } | PermissionDecision | ModeDecision;
95
139
  export interface GateOptions {
96
140
  harness: string;
97
141
  toolName: string;
@@ -99,20 +143,32 @@ export interface GateOptions {
99
143
  subjectFallback?: string;
100
144
  /** Whether the calling integration can actually stop the tool. */
101
145
  canBlock?: boolean;
102
- extraSpanAttributes?: Record<string, unknown>;
146
+ extraActivityAttributes?: Record<string, unknown>;
147
+ /** Normalized MCP identity when this invocation targets an MCP server. */
148
+ mcpTool?: McpToolIdentifier;
149
+ /** Acting sub-agent principal context for explicit machine blocks. */
150
+ principals?: PrincipalBlockSubjects;
103
151
  }
104
152
  /**
105
- * Authorize a tool call, record the spans, and return a normalized {@link GateResult}.
106
- * Records `tool.invoke` on allow/observe and `tool.block` on deny/observe — identical span
107
- * semantics to the harness plugins.
153
+ * Authorize a tool call and return a normalized {@link GateResult} without
154
+ * recording execution activity. Permission-ask hooks use this when the harness
155
+ * separately reports actual execution; {@link gate} adds the standard events.
108
156
  */
157
+ export declare function decideTool(client: OryAgentClient, opts: GateOptions): Promise<GateResult>;
109
158
  export declare function gate(client: OryAgentClient, opts: GateOptions): Promise<GateResult>;
110
159
  export declare function complete(client: OryAgentClient, opts: {
111
160
  toolName: string;
161
+ input?: unknown;
112
162
  output?: unknown;
113
- extraSpanAttributes?: Record<string, unknown>;
163
+ extraActivityAttributes?: Record<string, unknown>;
114
164
  status?: "ok" | "error";
115
165
  }): void;
166
+ export declare function fail(client: OryAgentClient, opts: {
167
+ toolName: string;
168
+ input?: unknown;
169
+ error?: unknown;
170
+ extraActivityAttributes?: Record<string, unknown>;
171
+ }): void;
116
172
  export interface WrapToolOptions {
117
173
  harness: string;
118
174
  toolName: string;