@nullsquare/agent-authority 0.4.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.
Files changed (58) hide show
  1. package/CONTRIBUTING.md +93 -0
  2. package/LICENSE +201 -0
  3. package/README.md +390 -0
  4. package/ROADMAP.md +149 -0
  5. package/SECURITY.md +116 -0
  6. package/docs/account-connections.md +173 -0
  7. package/docs/announcement-draft.md +13 -0
  8. package/docs/architecture.md +106 -0
  9. package/docs/assets/agent-authority-cover.svg +41 -0
  10. package/docs/clear-path.md +53 -0
  11. package/docs/cli.md +130 -0
  12. package/docs/evidence.md +143 -0
  13. package/docs/harness-bridge-mode.md +136 -0
  14. package/docs/harness-integration.md +223 -0
  15. package/docs/integration-contract.md +132 -0
  16. package/docs/integrations/vercel-ai-sdk.md +161 -0
  17. package/docs/launch-checklist.md +29 -0
  18. package/docs/npm-release.md +19 -0
  19. package/docs/openclaw-integration.md +97 -0
  20. package/docs/package-consumer-validation.md +18 -0
  21. package/docs/release-candidate-status.md +3 -0
  22. package/docs/release-guardrails.md +8 -0
  23. package/docs/release-notes-v0.4.md +26 -0
  24. package/docs/release-scope.md +3 -0
  25. package/docs/ship-criteria.md +3 -0
  26. package/docs/task-leases.md +253 -0
  27. package/docs/validation.md +124 -0
  28. package/examples/demo.js +19 -0
  29. package/examples/direct-guard.js +50 -0
  30. package/examples/harness-managed-connectors.js +72 -0
  31. package/examples/live-github-derived-mutation.js +208 -0
  32. package/examples/live-github-task-lease.js +80 -0
  33. package/examples/mission.json +20 -0
  34. package/examples/missions/chatgpt-web-validation.json +33 -0
  35. package/examples/openclaw-tool-wrapper.js +49 -0
  36. package/examples/task-lease-demo.js +98 -0
  37. package/examples/validation-mcp-upstream.js +112 -0
  38. package/package.json +80 -0
  39. package/src/agent-auth.js +135 -0
  40. package/src/approvals.js +157 -0
  41. package/src/cli.js +335 -0
  42. package/src/connections.js +203 -0
  43. package/src/execution.js +174 -0
  44. package/src/guard.js +79 -0
  45. package/src/harness-bridge.js +131 -0
  46. package/src/idempotency.js +118 -0
  47. package/src/index.js +291 -0
  48. package/src/integrations/ai-sdk.js +59 -0
  49. package/src/keys.js +15 -0
  50. package/src/mcp-gateway.js +142 -0
  51. package/src/mcp-remote.js +102 -0
  52. package/src/mcp-server.js +102 -0
  53. package/src/providers/github.js +149 -0
  54. package/src/runtime-env.js +53 -0
  55. package/src/sdk.js +75 -0
  56. package/src/server.js +146 -0
  57. package/src/storage.js +213 -0
  58. package/src/task-lease.js +266 -0
@@ -0,0 +1,132 @@
1
+ # Integration contract
2
+
3
+ Agent Authority should fit an existing agent stack without becoming its harness, connector catalog, or identity provider.
4
+
5
+ The core contract is intentionally small:
6
+
7
+ ```text
8
+ human task
9
+ |
10
+ v
11
+ Task Lease
12
+ |
13
+ v
14
+ proposed action
15
+ |
16
+ v
17
+ Agent Authority evaluation
18
+ |
19
+ +-- DENY ------------> no side effect
20
+ |
21
+ +-- REQUIRE_APPROVAL -> no side effect until authority expands explicitly
22
+ |
23
+ +-- ALLOW -----------> execute through the host's existing connection
24
+ |
25
+ v
26
+ receipt / derived facts / task completion
27
+ ```
28
+
29
+ The mission remains the static authority ceiling. The Task Lease is the temporary task boundary developers should normally integrate against.
30
+
31
+ ## Action model
32
+
33
+ A proposed action is described semantically:
34
+
35
+ ```json
36
+ {
37
+ "service": "calendar",
38
+ "action": "event.create",
39
+ "context": {
40
+ "attendee": "customer@example.com"
41
+ }
42
+ }
43
+ ```
44
+
45
+ A Task Lease may bind that context value to a fact legitimately discovered earlier in the same task.
46
+
47
+ ```text
48
+ Gmail thread root
49
+ |
50
+ authorized read receipt
51
+ |
52
+ derived sender fact
53
+ |
54
+ Calendar attendee binding
55
+ ```
56
+
57
+ A different attendee is not silently authorized. It becomes an authority delta.
58
+
59
+ ## 1. In-process guard — primary developer path
60
+
61
+ For an application that already owns its SDK/client connection:
62
+
63
+ ```js
64
+ import { AuthorityRuntime } from '@nullsquare/agent-authority';
65
+ import { createTaskLease } from '@nullsquare/agent-authority/task-lease';
66
+ import { createTaskLeaseGuard } from '@nullsquare/agent-authority/guard';
67
+
68
+ const lease = createTaskLease({ mission, roots, bindings });
69
+ const guard = createTaskLeaseGuard({ lease, runtime: new AuthorityRuntime() });
70
+
71
+ await guard.run({
72
+ service: 'calendar',
73
+ action: 'event.create',
74
+ context: { attendee: 'customer@example.com' }
75
+ }, () => calendar.createEvent(...));
76
+ ```
77
+
78
+ The callback is never invoked on `DENY` or `REQUIRE_APPROVAL`. The host retains its provider credentials.
79
+
80
+ This is the clearest adoption path today because it does not require MCP, a daemon, or a new authentication flow.
81
+
82
+ ## 2. MCP gateway — adapter for MCP hosts
83
+
84
+ For ChatGPT, Claude, Codex, OpenClaw, IDEs, or other MCP-capable hosts:
85
+
86
+ ```text
87
+ host -> Agent Authority MCP gateway -> existing MCP server
88
+ ```
89
+
90
+ The gateway should enforce the same Task Lease immediately before forwarding `tools/call`. MCP is an adapter, not Agent Authority's core abstraction.
91
+
92
+ ## 3. Brokered execution — credential isolation
93
+
94
+ When the host should not own the provider credential:
95
+
96
+ ```text
97
+ agent -> Agent Authority -> credential broker -> provider
98
+ ```
99
+
100
+ Agent Authority resolves the connected account internally and returns only sanitized provider output. The same Task Lease semantics must still apply.
101
+
102
+ ## Conformance invariant
103
+
104
+ Regardless of transport, an integration is conformant only if:
105
+
106
+ 1. the side effect cannot occur before an `ALLOW` decision or completed step-up;
107
+ 2. the request evaluated is the request executed;
108
+ 3. the mission remains the authority ceiling;
109
+ 4. derived authority is anchored to an `ALLOW` receipt from the same Task Lease and existing parent facts;
110
+ 5. a different concrete resource cannot silently inherit authority;
111
+ 6. task completion or expiry stops later task actions;
112
+ 7. switching transport cannot broaden authority;
113
+ 8. a receipt can identify the mission, Task Lease, agent, service, action, and request hash.
114
+
115
+ This invariant is more important than any specific protocol.
116
+
117
+ ## What Agent Authority does not require
118
+
119
+ Adopting Agent Authority should not require replacing:
120
+
121
+ - the agent harness;
122
+ - OAuth/OIDC;
123
+ - MCP;
124
+ - provider SDKs;
125
+ - existing secret storage;
126
+ - an organization's IAM system.
127
+
128
+ Those systems can remain in place. Agent Authority adds the temporary task-authority decision immediately before an agent-originated side effect.
129
+
130
+ ## Current trust boundary
131
+
132
+ The v0.4 prototype records provenance for derived facts, including source receipt and selector. The trusted host/adapter still supplies the extracted value. This is an explicit validation-stage trust assumption, not a cryptographic guarantee.
@@ -0,0 +1,161 @@
1
+ # Vercel AI SDK integration
2
+
3
+ Agent Authority can protect existing Vercel AI SDK tools without replacing `ToolLoopAgent`, changing the model provider, or moving credentials into Agent Authority.
4
+
5
+ The integration wraps each executable AI SDK tool at its `execute(input, options)` boundary. The tool keeps its existing description, input schema, approval metadata, and execution implementation.
6
+
7
+ ```text
8
+ ToolLoopAgent
9
+ |
10
+ | model selects tool
11
+ v
12
+ AI SDK tool.execute(input)
13
+ |
14
+ v
15
+ Agent Authority Task Lease
16
+ |
17
+ ALLOW / DENY / STEP-UP
18
+ |
19
+ v
20
+ existing tool effect / provider SDK
21
+ ```
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @nullsquare/agent-authority ai
27
+ ```
28
+
29
+ Current AI SDK 7 requires Node.js 22+. Agent Authority itself remains Node.js 20+ and does not depend on `ai` at runtime.
30
+
31
+ ## Wrap existing tools
32
+
33
+ Start with normal AI SDK tools:
34
+
35
+ ```js
36
+ import { ToolLoopAgent, tool } from 'ai';
37
+ import { z } from 'zod';
38
+
39
+ const tools = {
40
+ commentIssue: tool({
41
+ description: 'Comment on a GitHub issue',
42
+ inputSchema: z.object({
43
+ repository: z.string(),
44
+ issue_number: z.number(),
45
+ body: z.string()
46
+ }),
47
+ execute: ({ repository, issue_number, body }) =>
48
+ github.issues.createComment({
49
+ owner: repository.split('/')[0],
50
+ repo: repository.split('/')[1],
51
+ issue_number,
52
+ body
53
+ })
54
+ })
55
+ };
56
+ ```
57
+
58
+ Create a Task Lease and guard as usual, then wrap the tools:
59
+
60
+ ```js
61
+ import { AuthorityRuntime } from '@nullsquare/agent-authority';
62
+ import { createTaskLeaseGuard } from '@nullsquare/agent-authority/guard';
63
+ import { protectAiSdkTools } from '@nullsquare/agent-authority/integrations/ai-sdk';
64
+
65
+ const guard = createTaskLeaseGuard({
66
+ lease,
67
+ runtime: new AuthorityRuntime()
68
+ });
69
+
70
+ const protectedTools = protectAiSdkTools({
71
+ tools,
72
+ guard,
73
+ requests: {
74
+ commentIssue: ({ repository, issue_number }) => ({
75
+ service: 'github',
76
+ action: 'issue.comment',
77
+ context: { repository, issue_number }
78
+ })
79
+ }
80
+ });
81
+
82
+ const agent = new ToolLoopAgent({
83
+ model,
84
+ tools: protectedTools
85
+ });
86
+ ```
87
+
88
+ The rest of the AI SDK application remains unchanged.
89
+
90
+ ## Fail-closed behavior
91
+
92
+ Every tool with an `execute` function must have an authority request mapper.
93
+
94
+ If a developer forgets to map an executable tool, Agent Authority replaces its execution path with a failure:
95
+
96
+ ```text
97
+ ai_sdk_tool_unmapped
98
+ ```
99
+
100
+ The original tool effect is not called.
101
+
102
+ Tools without an `execute` function are preserved because AI SDK does not automatically execute them in-process.
103
+
104
+ ## Resource expansion
105
+
106
+ Suppose the Task Lease binds `issue_number` to issue `9`.
107
+
108
+ The model may call:
109
+
110
+ ```json
111
+ {
112
+ "repository": "Null-Square/agent-authority",
113
+ "issue_number": 9,
114
+ "body": "hello"
115
+ }
116
+ ```
117
+
118
+ and the existing tool effect can run.
119
+
120
+ If the model changes only the issue number:
121
+
122
+ ```json
123
+ {
124
+ "repository": "Null-Square/agent-authority",
125
+ "issue_number": 1,
126
+ "body": "hello"
127
+ }
128
+ ```
129
+
130
+ Agent Authority returns `authority_delta_required` before the tool's original `execute` function is invoked.
131
+
132
+ ## What CI proves
133
+
134
+ The repository has a dedicated Node 22 integration job using the current `ai@7` package, the real `ToolLoopAgent`, the real `tool()` helper, and AI SDK's deterministic mock language model.
135
+
136
+ It proves:
137
+
138
+ 1. `ToolLoopAgent` selects and automatically executes a protected tool through Agent Authority.
139
+ 2. The authorized effect executes exactly once.
140
+ 3. A different task resource executes zero effects.
141
+ 4. An executable tool without a request mapping executes zero effects.
142
+
143
+ No model API key is needed for this validation.
144
+
145
+ ## Security boundary
146
+
147
+ This wrapper protects the tool execution path that is actually passed to the agent. It cannot protect a separate provider client or unwrapped tool that the agent can reach through another path.
148
+
149
+ ```text
150
+ GOOD
151
+
152
+ ToolLoopAgent -> protectedTools -> Agent Authority -> provider
153
+
154
+ BYPASSABLE
155
+
156
+ ToolLoopAgent -> protectedTools -> Agent Authority -> provider
157
+ \
158
+ -> separate unwrapped provider/tool path
159
+ ```
160
+
161
+ Use the wrapper as the only executable path for the protected capability.
@@ -0,0 +1,29 @@
1
+ # Developer-preview launch checklist
2
+
3
+ Agent Authority should not be announced as a production-ready security product. The first public release is a developer preview, and the announcement is gated on executable evidence.
4
+
5
+ ## Required evidence
6
+
7
+ - [x] Task Lease cannot exceed its mission ceiling.
8
+ - [x] Derived authority requires same-lease provenance, a parent lineage, and an extraction selector.
9
+ - [x] A real GitHub resource can be discovered dynamically and become derived task authority.
10
+ - [x] A real GitHub mutation can execute against that derived resource.
11
+ - [x] An unrelated mutation is blocked before the provider call.
12
+ - [x] Task completion blocks later provider calls even while the underlying credential remains available.
13
+ - [x] Current Vercel AI SDK `ToolLoopAgent` executes protected tools through Agent Authority.
14
+ - [x] Unmapped executable AI SDK tools fail closed.
15
+ - [x] The packed npm artifact installs in a clean consumer project using only public exports.
16
+ - [x] Optional framework integrations do not become production dependencies of the core package.
17
+ - [ ] Release-candidate CI and CodeQL are green on the exact commit to be published.
18
+ - [ ] npm registry publication is verified from a clean install.
19
+
20
+ ## Claims we can make
21
+
22
+ For execution paths that are actually placed behind Agent Authority, the runtime can enforce task-bound resource constraints immediately before a side effect, including resources derived from authorized earlier execution.
23
+
24
+ ## Claims we must not make
25
+
26
+ - Agent Authority is not a complete sandbox for an agent that also has an unguarded route to the same provider.
27
+ - Recorded derivation provenance is not yet cryptographic proof that a provider response contained the extracted value.
28
+ - The project is not production-ready and has not yet proven durable multi-process Task Lease state.
29
+ - Task-scoped agent authorization as a research concept was not invented by NullSquare.
@@ -0,0 +1,19 @@
1
+ # npm release contract
2
+
3
+ The public package name is `@nullsquare/agent-authority`.
4
+
5
+ Before any publication:
6
+
7
+ 1. the release commit must pass CI, CodeQL, live GitHub validation, current AI SDK integration validation, and packed-consumer validation;
8
+ 2. `npm pack` must contain the documented public exports;
9
+ 3. a fresh Node.js 20 consumer must install the tarball and run the core Task Lease smoke test;
10
+ 4. the optional AI SDK integration must import without making `ai` a production dependency;
11
+ 5. the registry package must be public and its repository metadata must point to `https://github.com/Null-Square/agent-authority`.
12
+
13
+ After publication, verify from a fresh project with:
14
+
15
+ ```bash
16
+ npm install @nullsquare/agent-authority@0.4.0
17
+ ```
18
+
19
+ Then run the same consumer smoke flow through the registry-installed package. Registry verification is part of the release gate; a successful `npm publish` command alone is not sufficient.
@@ -0,0 +1,97 @@
1
+ # OpenClaw Integration Blueprint
2
+
3
+ Agent Authority should integrate with OpenClaw as a **tool/service authority layer**, not as a replacement agent harness.
4
+
5
+ ## Why
6
+
7
+ OpenClaw's agent harness abstraction owns execution of an agent turn. Agent Authority owns a different concern: whether a human-authorized agent may perform a sensitive external action and which connected credential may be used to perform it.
8
+
9
+ ## Recommended v1
10
+
11
+ ```text
12
+ OpenClaw agent/runtime
13
+ |
14
+ | proposed sensitive action
15
+ v
16
+ Agent Authority OpenClaw tool/plugin
17
+ |
18
+ v
19
+ Agent Authority sidecar
20
+ |
21
+ +-- mission policy
22
+ +-- resource constraints
23
+ +-- approval
24
+ +-- account connection
25
+ +-- credential broker
26
+ +-- receipt
27
+ |
28
+ v
29
+ provider adapter / MCP / connector
30
+ |
31
+ v
32
+ external service
33
+ ```
34
+
35
+ ### Installation shape
36
+
37
+ 1. User installs Agent Authority once on the OpenClaw host or points OpenClaw to a hosted Agent Authority endpoint.
38
+ 2. User connects GitHub/Google/etc. once to Agent Authority.
39
+ 3. OpenClaw installs/enables a small trusted Agent Authority plugin.
40
+ 4. The plugin exposes authority-aware tools or wraps sensitive tool execution.
41
+ 5. Codex, Claude Code, ACP agents, or embedded OpenClaw runtimes can all reuse the same connected accounts.
42
+
43
+ ## v1 plugin responsibilities
44
+
45
+ The OpenClaw plugin should remain intentionally thin:
46
+
47
+ - resolve the current Agent Authority endpoint
48
+ - attach the current mission id / agent session identity
49
+ - translate OpenClaw tool calls into normalized service/action/context requests
50
+ - call `/v1/execute`
51
+ - surface `deny` and `require_approval` outcomes cleanly
52
+ - return sanitized provider output
53
+
54
+ It should **not** store OAuth refresh tokens, duplicate the connection registry, or implement provider-specific credentials itself.
55
+
56
+ ## Example mapping
57
+
58
+ ```text
59
+ OpenClaw tool: github_read_file
60
+ repository: Null-Square/agent-authority
61
+ path: src/index.js
62
+
63
+ =>
64
+
65
+ service: github
66
+ action: repo.contents.read
67
+ context.repository: Null-Square/agent-authority
68
+ params.path: src/index.js
69
+ ```
70
+
71
+ The authority runtime then checks mission policy and repository constraints before the GitHub adapter is allowed to use the connected credential.
72
+
73
+ ## Native Codex vs ACP
74
+
75
+ The integration should work identically whether OpenClaw is using its native Codex harness or an external ACP harness such as Claude Code. Harness identity is metadata supplied to Agent Authority; it is not where the provider credentials live.
76
+
77
+ ```text
78
+ OpenClaw native Codex ----\
79
+ \
80
+ OpenClaw Claude ACP --------> Agent Authority ----> GitHub
81
+ /
82
+ OpenClaw Gemini ACP ------/
83
+ ```
84
+
85
+ This is an important interoperability proof: switching harnesses must not require reconnecting GitHub.
86
+
87
+ ## Security properties
88
+
89
+ - Provider secrets never enter the LLM prompt or OpenClaw transcript.
90
+ - A denied tool call causes no provider dispatch.
91
+ - Mission resource constraints bind access to the intended repo/account/project.
92
+ - Revocation applies across all OpenClaw harnesses using the mission.
93
+ - Provider responses are sanitized before returning to the model.
94
+
95
+ ## Future deeper integration
96
+
97
+ If OpenClaw exposes a stable trusted pre-tool execution/policy hook, Agent Authority can integrate there so existing tools are governed transparently. This should remain a plugin integration over the same sidecar/control-plane API rather than moving the authority database or credential vault into the harness.
@@ -0,0 +1,18 @@
1
+ # Packed consumer validation
2
+
3
+ Before publishing Agent Authority, CI validates the exact npm artifact from a completely separate temporary project.
4
+
5
+ The validation does not import repository-relative source files. It:
6
+
7
+ 1. runs `npm pack`;
8
+ 2. creates a fresh project outside the package source tree;
9
+ 3. installs the generated tarball with production dependencies only;
10
+ 4. imports Agent Authority through documented package exports;
11
+ 5. runs an allowed Task Lease effect;
12
+ 6. verifies a different bound resource cannot execute the effect;
13
+ 7. completes the Task Lease and verifies the previously allowed effect can no longer execute;
14
+ 8. imports the optional Vercel AI SDK integration wrapper without installing `ai`.
15
+
16
+ This catches missing files, bad `exports`, accidental repository-relative imports, undeclared production dependencies, and accidental coupling between the framework-neutral package and optional framework integrations.
17
+
18
+ The CI job runs on Node.js 20 so the package-consumer contract remains independent of current AI SDK runtime requirements.
@@ -0,0 +1,3 @@
1
+ # v0.4 release candidate status
2
+
3
+ This file exists to make the release-candidate boundary explicit in the repository. The candidate is ready to merge only after all required CI jobs and CodeQL are green on the final head commit.
@@ -0,0 +1,8 @@
1
+ # Release guardrails
2
+
3
+ - Do not publish if packed-consumer validation fails.
4
+ - Do not publish if live derived GitHub mutation validation fails.
5
+ - Do not publish if current AI SDK integration validation fails.
6
+ - Do not describe the release as production-ready.
7
+ - Do not claim NullSquare invented task-scoped agent authorization.
8
+ - Do not hide the unguarded-path bypass limitation or trusted-extraction limitation.
@@ -0,0 +1,26 @@
1
+ # Agent Authority v0.4 — Developer Preview
2
+
3
+ **Give your agent a task, not your account.**
4
+
5
+ v0.4 is the first developer-preview milestone centered on Task Leases and task-bounded side effects.
6
+
7
+ ## What is new
8
+
9
+ - Task Lease runtime layered under the existing mission ceiling.
10
+ - Same-lease derived authority with explicit parent lineage and extraction selectors.
11
+ - Exact resource/context bindings and `authority_delta_required` step-up signals.
12
+ - Immediate completion and expiry enforcement independent of credential lifetime.
13
+ - Real GitHub validation: discover a live issue, derive its issue number as authority, mutate exactly that issue, block an unrelated issue before the provider call, then block the previously authorized issue after task completion.
14
+ - Vercel AI SDK integration for wrapping existing `ToolLoopAgent` tools at the `execute` boundary.
15
+ - Fail-closed behavior for unmapped executable AI SDK tools.
16
+ - Packed-package consumer validation using only public npm exports.
17
+
18
+ ## Security boundary
19
+
20
+ Agent Authority only protects execution paths routed through its enforcement boundary. If an agent can reach the same provider through an unguarded tool, SDK client, shell command, or credential path, that route is outside the guarantee.
21
+
22
+ Derived-value extraction is currently trusted to the host/adapter. v0.4 records provenance and lineage but does not cryptographically prove that the selected provider-output field contained the claimed value.
23
+
24
+ ## Status
25
+
26
+ This is a developer preview, not a production-ready security control. The goal of v0.4 is to make task-bounded, provenance-aware least privilege executable and easy to test inside ordinary agent stacks.
@@ -0,0 +1,3 @@
1
+ # v0.4 release scope
2
+
3
+ The v0.4 developer preview release includes only the task-bounded runtime, public evidence, Vercel AI SDK wrapper, and package-consumer validation. Persistent leases, automatic approved-delta application, cryptographic extraction proof, hosted UI, additional frameworks, and broader connector work remain outside this release.
@@ -0,0 +1,3 @@
1
+ # Ship criteria
2
+
3
+ The release is shippable only when the final release-candidate commit has green CI and CodeQL, the packed artifact works in a clean consumer project, and registry publication can be authenticated under the NullSquare npm scope.