@axiastudio/aioc 0.1.1 → 0.1.2
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 +6 -3
- package/dist/approval-helpers.d.ts +24 -0
- package/dist/approval-helpers.d.ts.map +1 -0
- package/dist/approval-helpers.js +94 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,14 +8,15 @@ Project home and documentation: [https://axiastudio.github.io/aioc](https://axia
|
|
|
8
8
|
|
|
9
9
|
## Release Status
|
|
10
10
|
|
|
11
|
-
Current stable release: `0.1.
|
|
12
|
-
|
|
11
|
+
Current stable release: `0.1.2`.
|
|
12
|
+
The stable `0.1.x` line started with `0.1.0`.
|
|
13
13
|
The core runtime surface is compatibility-managed. Breaking changes to the stable surface should ship only with explicit migration guidance and release notes.
|
|
14
14
|
|
|
15
15
|
### Stable Scope
|
|
16
16
|
|
|
17
17
|
AIOC `0.1.0` stabilized the core runtime surface, public documentation aligned to the exported contract, `RunRecord` and replay/compare workflows, and the governance-first runtime model validated in real applications beyond toy examples.
|
|
18
18
|
AIOC `0.1.1` adds thread-history utilities, the run-output stream adapter, and provider-specific instruction-role documentation without changing the stable governance model.
|
|
19
|
+
AIOC `0.1.2` adds approval evidence helpers for application-owned approval workflows.
|
|
19
20
|
|
|
20
21
|
- Release notes: `CHANGELOG.md`
|
|
21
22
|
- Historical beta contract snapshot: `docs/BETA-CONTRACT.md`
|
|
@@ -96,6 +97,7 @@ console.log(result.finalOutput);
|
|
|
96
97
|
- handoffs via `Agent({ handoffs: [...] })`
|
|
97
98
|
- `run(...)` with streaming support (`stream` defaults to `false`)
|
|
98
99
|
- policy helpers `allow(...)` / `deny(...)` / `requireApproval(...)`
|
|
100
|
+
- approval evidence helpers `createApprovalRequestSeed(...)`, `toApprovedProposalHashes(...)`, `toActiveApprovalGrantMap(...)`
|
|
99
101
|
- provider setup helpers `setupMistral(...)`, `setupOpenAI(...)`, `setupProvider(...)`
|
|
100
102
|
- run logger hook `run(..., { logger })`
|
|
101
103
|
- run record hook `run(..., { record })`
|
|
@@ -264,9 +266,10 @@ AIOC adopts the following non-negotiable principles:
|
|
|
264
266
|
- `docs/RFC-0003-run-record-audit-trail-and-persistence.md` (`Accepted`)
|
|
265
267
|
- `docs/RFC-0004-policy-outcomes-and-approval-model.md` (`Accepted`)
|
|
266
268
|
- `docs/RFC-0005-suspended-proposals-and-approval-lifecycle.md` (`Accepted`)
|
|
267
|
-
- `docs/RFC-0006-approval-evidence-helpers.md` (`
|
|
269
|
+
- `docs/RFC-0006-approval-evidence-helpers.md` (`Accepted`)
|
|
268
270
|
- `docs/RFC-0007-thread-state-utilities.md` (`Accepted`)
|
|
269
271
|
- `docs/RFC-0008-run-stream-consumer-utilities.md` (`Accepted`)
|
|
272
|
+
- `docs/RFC-0010-policy-composition-helpers.md` (`Draft`)
|
|
270
273
|
- `docs/PRIVACY-BASELINE.md`
|
|
271
274
|
|
|
272
275
|
## Historical Snapshots
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SuspendedProposal } from "./run-record";
|
|
2
|
+
export interface ApprovalGrant {
|
|
3
|
+
proposalHash: string;
|
|
4
|
+
approvedAt: string;
|
|
5
|
+
expiresAt?: string;
|
|
6
|
+
revokedAt?: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface ApprovalRequestSeed {
|
|
10
|
+
proposalHash: string;
|
|
11
|
+
kind: "tool" | "handoff";
|
|
12
|
+
reason: string;
|
|
13
|
+
publicReason?: string;
|
|
14
|
+
policyVersion?: string;
|
|
15
|
+
expiresAt?: string;
|
|
16
|
+
resourceName: string;
|
|
17
|
+
canonicalPayloadJson: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function createApprovalRequestSeed(proposal: SuspendedProposal): ApprovalRequestSeed;
|
|
20
|
+
export declare function isApprovalGrantActive(grant: ApprovalGrant, now?: string): boolean;
|
|
21
|
+
export declare function findActiveApprovalGrant(proposalHash: string, grants: readonly ApprovalGrant[], now?: string): ApprovalGrant | null;
|
|
22
|
+
export declare function toActiveApprovalGrantMap(grants: readonly ApprovalGrant[], now?: string): Record<string, ApprovalGrant>;
|
|
23
|
+
export declare function toApprovedProposalHashes(grants: readonly ApprovalGrant[], now?: string): string[];
|
|
24
|
+
//# sourceMappingURL=approval-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-helpers.d.ts","sourceRoot":"","sources":["../src/approval-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAsCD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,iBAAiB,GAC1B,mBAAmB,CAoBrB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAYT;AAED,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,GAAG,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,IAAI,CAgBtB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,GAAG,CAAC,EAAE,MAAM,GACX,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAe/B;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,GAAG,CAAC,EAAE,MAAM,GACX,MAAM,EAAE,CAEV"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createApprovalRequestSeed = createApprovalRequestSeed;
|
|
4
|
+
exports.isApprovalGrantActive = isApprovalGrantActive;
|
|
5
|
+
exports.findActiveApprovalGrant = findActiveApprovalGrant;
|
|
6
|
+
exports.toActiveApprovalGrantMap = toActiveApprovalGrantMap;
|
|
7
|
+
exports.toApprovedProposalHashes = toApprovedProposalHashes;
|
|
8
|
+
function parseTimestamp(value, label) {
|
|
9
|
+
const timestamp = Date.parse(value);
|
|
10
|
+
if (Number.isNaN(timestamp)) {
|
|
11
|
+
throw new Error(`${label} must be a valid timestamp.`);
|
|
12
|
+
}
|
|
13
|
+
return timestamp;
|
|
14
|
+
}
|
|
15
|
+
function getNowTimestamp(now) {
|
|
16
|
+
return parseTimestamp(now ?? new Date().toISOString(), "now");
|
|
17
|
+
}
|
|
18
|
+
function isGrantNewer(candidate, current) {
|
|
19
|
+
return (parseTimestamp(candidate.approvedAt, "grant.approvedAt") >
|
|
20
|
+
parseTimestamp(current.approvedAt, "grant.approvedAt"));
|
|
21
|
+
}
|
|
22
|
+
function getProposalMetadata(proposal) {
|
|
23
|
+
return {
|
|
24
|
+
...(typeof proposal.publicReason !== "undefined"
|
|
25
|
+
? { publicReason: proposal.publicReason }
|
|
26
|
+
: {}),
|
|
27
|
+
...(typeof proposal.policyVersion !== "undefined"
|
|
28
|
+
? { policyVersion: proposal.policyVersion }
|
|
29
|
+
: {}),
|
|
30
|
+
...(typeof proposal.expiresAt !== "undefined"
|
|
31
|
+
? { expiresAt: proposal.expiresAt }
|
|
32
|
+
: {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createApprovalRequestSeed(proposal) {
|
|
36
|
+
if (proposal.kind === "tool") {
|
|
37
|
+
return {
|
|
38
|
+
proposalHash: proposal.proposalHash,
|
|
39
|
+
kind: proposal.kind,
|
|
40
|
+
reason: proposal.reason,
|
|
41
|
+
...getProposalMetadata(proposal),
|
|
42
|
+
resourceName: proposal.toolName,
|
|
43
|
+
canonicalPayloadJson: proposal.argsCanonicalJson,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
proposalHash: proposal.proposalHash,
|
|
48
|
+
kind: proposal.kind,
|
|
49
|
+
reason: proposal.reason,
|
|
50
|
+
...getProposalMetadata(proposal),
|
|
51
|
+
resourceName: proposal.toAgentName,
|
|
52
|
+
canonicalPayloadJson: proposal.payloadCanonicalJson,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isApprovalGrantActive(grant, now) {
|
|
56
|
+
if (typeof grant.revokedAt !== "undefined") {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (typeof grant.expiresAt === "undefined") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return (parseTimestamp(grant.expiresAt, "grant.expiresAt") >= getNowTimestamp(now));
|
|
63
|
+
}
|
|
64
|
+
function findActiveApprovalGrant(proposalHash, grants, now) {
|
|
65
|
+
let match = null;
|
|
66
|
+
for (const grant of grants) {
|
|
67
|
+
if (grant.proposalHash !== proposalHash) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!isApprovalGrantActive(grant, now)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!match || isGrantNewer(grant, match)) {
|
|
74
|
+
match = grant;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return match;
|
|
78
|
+
}
|
|
79
|
+
function toActiveApprovalGrantMap(grants, now) {
|
|
80
|
+
const grantMap = {};
|
|
81
|
+
for (const grant of grants) {
|
|
82
|
+
if (!isApprovalGrantActive(grant, now)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const current = grantMap[grant.proposalHash];
|
|
86
|
+
if (!current || isGrantNewer(grant, current)) {
|
|
87
|
+
grantMap[grant.proposalHash] = grant;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return grantMap;
|
|
91
|
+
}
|
|
92
|
+
function toApprovedProposalHashes(grants, now) {
|
|
93
|
+
return Object.keys(toActiveApprovalGrantMap(grants, now));
|
|
94
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./agent"), exports);
|
|
18
|
+
__exportStar(require("./approval-helpers"), exports);
|
|
18
19
|
__exportStar(require("./config"), exports);
|
|
19
20
|
__exportStar(require("./errors"), exports);
|
|
20
21
|
__exportStar(require("./guardrails"), exports);
|