@fungi.computer/approvals 0.2.4 → 0.2.6
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/README.md +52 -10
- package/dist/ledger.d.ts +2 -0
- package/dist/ledger.js +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
# Approvals
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Approvals keeps a record of each action an AI agent wants to take that needs a
|
|
4
|
+
person's OK, so any screen can show it and an approved action runs exactly once.
|
|
5
|
+
|
|
6
|
+
```mermaid
|
|
7
|
+
flowchart LR
|
|
8
|
+
Agent[Agent proposes a write] --> Ledger[Approvals ledger]
|
|
9
|
+
Ledger --> Person[A member answers]
|
|
10
|
+
Person --> Ledger
|
|
11
|
+
Ledger -->|rechecks authority| Host[Your host runs the operation]
|
|
12
|
+
```
|
|
6
13
|
|
|
7
|
-
##
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
Install it:
|
|
8
17
|
|
|
9
18
|
```sh
|
|
10
19
|
npm install @fungi.computer/approvals @fungi.computer/watchdog
|
|
11
20
|
```
|
|
12
21
|
|
|
13
|
-
Approvals ships ESM and TypeScript declarations from its root entrypoint. The
|
|
14
|
-
example below uses Node.js 24's native SQLite adapter from Watchdog. Your host
|
|
15
|
-
owns the database, requester identity, current grants and dispatch.
|
|
16
|
-
|
|
17
|
-
## Quick start
|
|
18
|
-
|
|
19
22
|
Stage a proposed write without executing it. This disposable in-memory example
|
|
20
23
|
prints `pending`; use a persistent, host-owned database for real requests.
|
|
21
24
|
|
|
@@ -59,6 +62,45 @@ the same operation. `request` stages a record and records the home's
|
|
|
59
62
|
auto-approve decision without dispatching. `submit` additionally applies a newly
|
|
60
63
|
policy-approved request inline through the authority recheck.
|
|
61
64
|
|
|
65
|
+
## Common tasks
|
|
66
|
+
|
|
67
|
+
### Stage a write for approval
|
|
68
|
+
|
|
69
|
+
`request` stages the record without running it. See the Quick start.
|
|
70
|
+
|
|
71
|
+
### Answer a request and apply it
|
|
72
|
+
|
|
73
|
+
Pass `answer` a freshly resolved member and the expected revision, then supply
|
|
74
|
+
an apply host. See Examples.
|
|
75
|
+
|
|
76
|
+
### Turn on auto-approve
|
|
77
|
+
|
|
78
|
+
Auto-approve matches a module and access class. Read how the host reads it in
|
|
79
|
+
[Host admission policy read](#host-admission-policy-read).
|
|
80
|
+
|
|
81
|
+
### Attach screenshots for the reviewer
|
|
82
|
+
|
|
83
|
+
A record can carry up to four image descriptors. See
|
|
84
|
+
[Capability-attached visual evidence](#capability-attached-visual-evidence).
|
|
85
|
+
|
|
86
|
+
## Reference
|
|
87
|
+
|
|
88
|
+
### Overview
|
|
89
|
+
|
|
90
|
+
One durable approval record, many renderers. Mycelium owns operation admission;
|
|
91
|
+
this package owns the decision lifecycle beside it. Team storage on the Hub and
|
|
92
|
+
the Oyster host supply the homes. Bonsai is not a ledger home.
|
|
93
|
+
|
|
94
|
+
## Install
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npm install @fungi.computer/approvals @fungi.computer/watchdog
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Approvals ships ESM and TypeScript declarations from its root entrypoint. The
|
|
101
|
+
example below uses Node.js 24's native SQLite adapter from Watchdog. Your host
|
|
102
|
+
owns the database, requester identity, current grants and dispatch.
|
|
103
|
+
|
|
62
104
|
## Examples
|
|
63
105
|
|
|
64
106
|
The home example stages one pending write using native SQLite. The packed
|
package/dist/ledger.d.ts
CHANGED
|
@@ -130,6 +130,8 @@ export declare class ApprovalLedger {
|
|
|
130
130
|
record: ApprovalRecord;
|
|
131
131
|
created: boolean;
|
|
132
132
|
}> | ApprovalRefusal>;
|
|
133
|
+
/** A fresh tool identity cannot authorize repeating an uncertain App write. */
|
|
134
|
+
private uncertainAppWrite;
|
|
133
135
|
/** Answering is revision-pinned and never changes the requester's underlying grants. */
|
|
134
136
|
answer(input: ApprovalAnswerInput, actor: ApprovalAnswerer | null): Readonly<{
|
|
135
137
|
kind: "answered";
|
package/dist/ledger.js
CHANGED
|
@@ -214,6 +214,9 @@ export class ApprovalLedger {
|
|
|
214
214
|
return { kind: "refused", reason: "identity-conflict" };
|
|
215
215
|
return { kind: "record", record: existing, created: false };
|
|
216
216
|
}
|
|
217
|
+
const uncertain = this.uncertainAppWrite(request, inputSha256);
|
|
218
|
+
if (uncertain !== null)
|
|
219
|
+
return { kind: "record", record: uncertain, created: false };
|
|
217
220
|
const now = this.options.now();
|
|
218
221
|
const autoApproved = request.prefixPolicyApproved === true ||
|
|
219
222
|
(!request.requireHumanApproval &&
|
|
@@ -255,6 +258,19 @@ export class ApprovalLedger {
|
|
|
255
258
|
return { kind: "record", record, created: true };
|
|
256
259
|
});
|
|
257
260
|
}
|
|
261
|
+
/** A fresh tool identity cannot authorize repeating an uncertain App write. */
|
|
262
|
+
uncertainAppWrite(request, inputSha256) {
|
|
263
|
+
if (this.options.home.kind !== "team" ||
|
|
264
|
+
request.app === undefined ||
|
|
265
|
+
request.requester.sessionId === null)
|
|
266
|
+
return null;
|
|
267
|
+
const previous = this.options.owner.sql
|
|
268
|
+
.exec("SELECT record_json FROM approval_records WHERE home_key = ? AND json_extract(record_json, '$.state') = 'outcome_unknown' AND json_extract(record_json, '$.requester.principalId') = ? AND json_extract(record_json, '$.requester.agentId') IS ? AND json_extract(record_json, '$.requester.sessionId') = ? AND json_extract(record_json, '$.module') = ? AND json_extract(record_json, '$.operation') = ? AND json_extract(record_json, '$.access') = ? AND json_extract(record_json, '$.authorityFence') = ? AND json_extract(record_json, '$.description.inputSha256') = ? LIMIT 1", this.homeKey, request.requester.principalId, request.requester.agentId, request.requester.sessionId, request.module, request.operation, request.access, request.authorityFence, inputSha256)
|
|
269
|
+
.toArray()[0];
|
|
270
|
+
return previous === undefined
|
|
271
|
+
? null
|
|
272
|
+
: decodeRecord(decodeRow(previous).record_json);
|
|
273
|
+
}
|
|
258
274
|
/** Answering is revision-pinned and never changes the requester's underlying grants. */
|
|
259
275
|
answer(input, actor) {
|
|
260
276
|
if (!this.eligible(actor))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/approvals",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Durable principal-bound approval records and auto-approve policy",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"effect": "4.0.2",
|
|
23
|
-
"@fungi.computer/watchdog": "0.1.
|
|
23
|
+
"@fungi.computer/watchdog": "0.1.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "24.13.3",
|