@agentropy/runtime 0.0.0-bootstrap.0 → 0.1.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.
- package/LICENSE +202 -0
- package/README.md +38 -1
- package/dist/a2a-client.d.ts +111 -0
- package/dist/a2a-client.js +386 -0
- package/dist/a2a-history.d.ts +27 -0
- package/dist/a2a-history.js +67 -0
- package/dist/a2a-http.d.ts +46 -0
- package/dist/a2a-http.js +183 -0
- package/dist/a2a-protocol.d.ts +77 -0
- package/dist/a2a-protocol.js +148 -0
- package/dist/a2a-push-receiver.d.ts +24 -0
- package/dist/a2a-push-receiver.js +161 -0
- package/dist/a2a-push.d.ts +85 -0
- package/dist/a2a-push.js +385 -0
- package/dist/a2a-server.d.ts +82 -0
- package/dist/a2a-server.js +523 -0
- package/dist/a2a-sse.d.ts +5 -0
- package/dist/a2a-sse.js +36 -0
- package/dist/a2a.d.ts +41 -0
- package/dist/a2a.js +40 -0
- package/dist/app.d.ts +256 -0
- package/dist/app.js +541 -0
- package/dist/audit.d.ts +229 -0
- package/dist/audit.js +718 -0
- package/dist/bounded-body.d.ts +32 -0
- package/dist/bounded-body.js +124 -0
- package/dist/communication.d.ts +62 -0
- package/dist/communication.js +142 -0
- package/dist/compaction.d.ts +24 -0
- package/dist/compaction.js +202 -0
- package/dist/federation.d.ts +108 -0
- package/dist/federation.js +241 -0
- package/dist/http-path.d.ts +7 -0
- package/dist/http-path.js +14 -0
- package/dist/human-actions.d.ts +62 -0
- package/dist/human-actions.js +359 -0
- package/dist/implementation.d.ts +47 -0
- package/dist/implementation.js +138 -0
- package/dist/inbox.d.ts +101 -0
- package/dist/inbox.js +389 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/ingress.d.ts +35 -0
- package/dist/ingress.js +86 -0
- package/dist/lifecycle.d.ts +45 -0
- package/dist/lifecycle.js +57 -0
- package/dist/limits.d.ts +43 -0
- package/dist/limits.js +71 -0
- package/dist/mcp.d.ts +111 -0
- package/dist/mcp.js +308 -0
- package/dist/memory.d.ts +25 -0
- package/dist/memory.js +134 -0
- package/dist/model-routing.d.ts +66 -0
- package/dist/model-routing.js +80 -0
- package/dist/otel.d.ts +60 -0
- package/dist/otel.js +72 -0
- package/dist/outbox.d.ts +116 -0
- package/dist/outbox.js +327 -0
- package/dist/policy-cache.d.ts +69 -0
- package/dist/policy-cache.js +178 -0
- package/dist/priority.d.ts +27 -0
- package/dist/priority.js +28 -0
- package/dist/quotas.d.ts +19 -0
- package/dist/quotas.js +47 -0
- package/dist/reasoning.d.ts +54 -0
- package/dist/reasoning.js +307 -0
- package/dist/registry.d.ts +101 -0
- package/dist/registry.js +369 -0
- package/dist/remote.d.ts +130 -0
- package/dist/remote.js +473 -0
- package/dist/runtime.d.ts +167 -0
- package/dist/runtime.js +1035 -0
- package/dist/skills.d.ts +86 -0
- package/dist/skills.js +376 -0
- package/dist/task-service.d.ts +239 -0
- package/dist/task-service.js +790 -0
- package/dist/tools.d.ts +140 -0
- package/dist/tools.js +476 -0
- package/dist/wake-index.d.ts +9 -0
- package/dist/wake-index.js +11 -0
- package/dist/wakeups.d.ts +142 -0
- package/dist/wakeups.js +501 -0
- package/dist/workflow.d.ts +36 -0
- package/dist/workflow.js +101 -0
- package/package.json +41 -5
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mandatory audit intent (Security v1 PEP step 4, ADR-0022/0025, SEC-03).
|
|
3
|
+
*
|
|
4
|
+
* An intent row is written in the same Store transaction as the protected change it describes, so the change
|
|
5
|
+
* and its audit intent commit together or not at all. If the intent cannot be written the transaction aborts
|
|
6
|
+
* and the caller receives `AuditCommitUnavailable`: nothing is committed or reported as committed.
|
|
7
|
+
* `AuditForwarder` later hands committed intents to the external `AuditIntentWriter` sink, at least once, with a
|
|
8
|
+
* stable `details.auditId` the sink uses to deduplicate after a crash between delivery and the delivered mark.
|
|
9
|
+
*/
|
|
10
|
+
import { type Telemetry, type PolicyDecisionPoint, type TrustedPrincipal, type AuditEvent, type AuditIntentWriter, type Store, type StoreTx } from '@agentropy/core';
|
|
11
|
+
import type { FaultHook } from './outbox.js';
|
|
12
|
+
export interface AuditIntentRow {
|
|
13
|
+
auditId: string;
|
|
14
|
+
/** Indexed copies of event fields. */
|
|
15
|
+
tenantId: string;
|
|
16
|
+
type: string;
|
|
17
|
+
event: AuditEvent;
|
|
18
|
+
/** Hash chain per tenant (D-21 tamper evidence): hash = digest(prevHash, auditId, event). */
|
|
19
|
+
prevHash: string;
|
|
20
|
+
hash: string;
|
|
21
|
+
forwarded: 0 | 1;
|
|
22
|
+
attempts: number;
|
|
23
|
+
}
|
|
24
|
+
/** Writes one intent row inside `tx`; any failure (including an injected one) is AuditCommitUnavailable. */
|
|
25
|
+
export declare function recordAuditIntent(tx: StoreTx, auditId: string, event: Omit<AuditEvent, 'details'> & {
|
|
26
|
+
details?: Record<string, unknown>;
|
|
27
|
+
}, faults?: FaultHook): Promise<void>;
|
|
28
|
+
export declare class AuditForwarder {
|
|
29
|
+
private readonly o;
|
|
30
|
+
constructor(o: {
|
|
31
|
+
store: Store;
|
|
32
|
+
sink: AuditIntentWriter;
|
|
33
|
+
faults?: FaultHook;
|
|
34
|
+
/** Clock for the drain budget (default: the system clock). */
|
|
35
|
+
now?: () => string;
|
|
36
|
+
/** Counts every refused forward (`agentropy.audit.forward_failures`, FEAT-075). */
|
|
37
|
+
telemetry?: Telemetry;
|
|
38
|
+
/**
|
|
39
|
+
* Longest a drain call keeps forwarding (default 5000 ms): a backlog after an outage is forwarded over several
|
|
40
|
+
* calls, in order. At least one row is forwarded per call.
|
|
41
|
+
*/
|
|
42
|
+
drainBudgetMs?: number;
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Forward committed intents in commit order; stops at the first failure. Returns how many were forwarded. Reads
|
|
46
|
+
* only rows not yet forwarded (indexed), a batch at a time, so a tick costs what is pending, not the whole log.
|
|
47
|
+
*/
|
|
48
|
+
drain(): Promise<number>;
|
|
49
|
+
/**
|
|
50
|
+
* Rows the sink keeps refusing (`attempts` at or above `minAttempts`). Forwarding is in order and stops at the first
|
|
51
|
+
* refused row, so the oldest of them holds back every later one: what an operator or a readiness probe looks at
|
|
52
|
+
* (FEAT-075).
|
|
53
|
+
*/
|
|
54
|
+
stuck(minAttempts?: number): Promise<{
|
|
55
|
+
auditId: string;
|
|
56
|
+
type: string;
|
|
57
|
+
attempts: number;
|
|
58
|
+
at: string;
|
|
59
|
+
}[]>;
|
|
60
|
+
private forward;
|
|
61
|
+
}
|
|
62
|
+
/** Deployment retention (trusted configuration): tenants may lengthen but never shorten below `floorDays`. */
|
|
63
|
+
export interface AuditRetention {
|
|
64
|
+
defaultDays: number;
|
|
65
|
+
floorDays: number;
|
|
66
|
+
/** Per event type, e.g. `{ "task.accept": 3650 }`; each is still raised to the floor. */
|
|
67
|
+
perType?: Record<string, number>;
|
|
68
|
+
}
|
|
69
|
+
export interface AuditHold {
|
|
70
|
+
holdId: string;
|
|
71
|
+
tenantId: string;
|
|
72
|
+
status: 'active' | 'released';
|
|
73
|
+
reason: string;
|
|
74
|
+
/** Matching rows: any type when absent; `at` within [from, to] when given. */
|
|
75
|
+
types?: string[];
|
|
76
|
+
from?: string;
|
|
77
|
+
to?: string;
|
|
78
|
+
placedBy: string;
|
|
79
|
+
placedAt: string;
|
|
80
|
+
releasedBy?: string;
|
|
81
|
+
releasedAt?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Head of a tenant's chain, published to an independently protected sink (ADR-0022 §7). */
|
|
84
|
+
export interface AuditAnchor {
|
|
85
|
+
tenantId: string;
|
|
86
|
+
/** 1-based position of the row in the tenant chain since genesis (disposed rows included). */
|
|
87
|
+
position: number;
|
|
88
|
+
auditId: string;
|
|
89
|
+
hash: string;
|
|
90
|
+
at: string;
|
|
91
|
+
}
|
|
92
|
+
/** WORM storage, a transparency log, a signing service… — anything the store's writers cannot rewrite. */
|
|
93
|
+
export interface AuditAnchorSink {
|
|
94
|
+
publish(anchor: AuditAnchor): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
/** Non-sensitive record of a disposal: counts and hashes, never the disposed payloads. */
|
|
97
|
+
export interface AuditDisposalReceipt {
|
|
98
|
+
receiptId: string;
|
|
99
|
+
tenantId: string;
|
|
100
|
+
/** Chain positions disposed (inclusive). */
|
|
101
|
+
fromPosition: number;
|
|
102
|
+
toPosition: number;
|
|
103
|
+
/** prevHash of the first and hash of the last disposed row: links the receipt into the chain. */
|
|
104
|
+
startHash: string;
|
|
105
|
+
lastHash: string;
|
|
106
|
+
countByType: Record<string, number>;
|
|
107
|
+
oldestAt: string;
|
|
108
|
+
newestAt: string;
|
|
109
|
+
authorizedBy: string;
|
|
110
|
+
at: string;
|
|
111
|
+
}
|
|
112
|
+
export interface AuditExport {
|
|
113
|
+
tenantId: string;
|
|
114
|
+
/** Hash the first exported row links to (genesis or the last disposal receipt). */
|
|
115
|
+
startHash: string;
|
|
116
|
+
startPosition: number;
|
|
117
|
+
rows: {
|
|
118
|
+
auditId: string;
|
|
119
|
+
event: AuditEvent;
|
|
120
|
+
prevHash: string;
|
|
121
|
+
hash: string;
|
|
122
|
+
}[];
|
|
123
|
+
exportedAt: string;
|
|
124
|
+
}
|
|
125
|
+
type VerifyResult = {
|
|
126
|
+
ok: true;
|
|
127
|
+
count: number;
|
|
128
|
+
disposed: number;
|
|
129
|
+
} | {
|
|
130
|
+
ok: false;
|
|
131
|
+
brokenAt: string;
|
|
132
|
+
reason?: 'anchor-mismatch' | 'truncated' | 'receipt-chain';
|
|
133
|
+
};
|
|
134
|
+
/** Pure chain check, usable offline on an export (archive integrity). */
|
|
135
|
+
export declare function verifyAuditChain(rows: {
|
|
136
|
+
auditId: string;
|
|
137
|
+
event: AuditEvent;
|
|
138
|
+
prevHash: string;
|
|
139
|
+
hash: string;
|
|
140
|
+
}[], startHash?: string): {
|
|
141
|
+
ok: true;
|
|
142
|
+
} | {
|
|
143
|
+
ok: false;
|
|
144
|
+
brokenAt: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Audit read, integrity and lifecycle (D-21, D-22, ADR-0022). Every operation is tenant-scoped (another tenant's
|
|
148
|
+
* log is NotFound) and needs its own permission — read, verify, export, retention, hold, release-hold, anchor and
|
|
149
|
+
* dispose are independent actions. Each use is itself audited (`audit.*` events, recorded after the operation so
|
|
150
|
+
* reading the log does not recurse).
|
|
151
|
+
*
|
|
152
|
+
* Lifecycle: rows expire after the tenant's retention (never below the deployment floor). `dispose` removes only
|
|
153
|
+
* the oldest contiguous run of rows that are expired, already forwarded to the audit sink, and not matched by an
|
|
154
|
+
* active legal hold, and leaves a receipt with counts and boundary hashes so `verify` still links the remaining
|
|
155
|
+
* chain to genesis. `anchor` publishes the chain head to an external sink; `verify` checks such anchors, which
|
|
156
|
+
* detects truncation and wholesale rewriting that a hash chain alone cannot.
|
|
157
|
+
*/
|
|
158
|
+
export declare class AuditService {
|
|
159
|
+
private readonly o;
|
|
160
|
+
constructor(o: {
|
|
161
|
+
store: Store;
|
|
162
|
+
pdp: PolicyDecisionPoint;
|
|
163
|
+
now?: () => string;
|
|
164
|
+
newId?: () => string;
|
|
165
|
+
retention?: AuditRetention;
|
|
166
|
+
anchorSink?: AuditAnchorSink;
|
|
167
|
+
/** Rows read per transaction by `verify` and `exportLog` (default 500). */
|
|
168
|
+
pageSize?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Hashes of the most recently checked rows `verify` and `exportLog` keep (default 100 000), to check a disposal
|
|
171
|
+
* receipt that commits during the read and ends at a row already read. One that ends further back than this
|
|
172
|
+
* fails the read with a retryable `StaleRevision`; memory stays bounded however long the log.
|
|
173
|
+
*/
|
|
174
|
+
checkWindow?: number;
|
|
175
|
+
});
|
|
176
|
+
private get page();
|
|
177
|
+
private get checkWindow();
|
|
178
|
+
/**
|
|
179
|
+
* The tenant's chain in pages of `pageSize` rows, each in its own transaction, so a long log is never read in one
|
|
180
|
+
* transaction (under SERIALIZABLE such a read conflicts with every acceptance of the tenant). Every page transaction
|
|
181
|
+
* also reads the disposal receipts committed since the previous one (all of them with the first page), so the
|
|
182
|
+
* receipts a page comes with are consistent with its rows (FIX-082): a disposal that commits between two pages may
|
|
183
|
+
* have removed rows past the reader's cursor, and its receipt, read with the next page, says where the chain goes
|
|
184
|
+
* on. With new receipts after the first page, `oldest` is the oldest row left in the log (`null` when none is),
|
|
185
|
+
* which must be the row right after the newest receipt and link to it; it is `undefined` when it was not read.
|
|
186
|
+
* Nothing is read twice and a read is never abandoned, however many disposals commit while it runs.
|
|
187
|
+
*/
|
|
188
|
+
private pages;
|
|
189
|
+
private now;
|
|
190
|
+
private id;
|
|
191
|
+
private authorize;
|
|
192
|
+
private record;
|
|
193
|
+
private rows;
|
|
194
|
+
query(q: {
|
|
195
|
+
tenantId: string;
|
|
196
|
+
type?: string;
|
|
197
|
+
limit?: number;
|
|
198
|
+
}, caller: TrustedPrincipal): Promise<AuditEvent[]>;
|
|
199
|
+
verify(tenantId: string, caller: TrustedPrincipal, options?: {
|
|
200
|
+
anchors?: AuditAnchor[];
|
|
201
|
+
}): Promise<VerifyResult>;
|
|
202
|
+
/** Archive bundle: rows with their links, verifiable offline with `verifyAuditChain(rows, startHash)`. */
|
|
203
|
+
exportLog(tenantId: string, caller: TrustedPrincipal): Promise<AuditExport>;
|
|
204
|
+
private retention;
|
|
205
|
+
/** Tenant retention override; can only lengthen relative to the deployment floor. */
|
|
206
|
+
setRetention(tenantId: string, policy: {
|
|
207
|
+
days: number;
|
|
208
|
+
perType?: Record<string, number>;
|
|
209
|
+
}, caller: TrustedPrincipal): Promise<void>;
|
|
210
|
+
placeHold(tenantId: string, hold: {
|
|
211
|
+
holdId: string;
|
|
212
|
+
reason: string;
|
|
213
|
+
types?: string[];
|
|
214
|
+
from?: string;
|
|
215
|
+
to?: string;
|
|
216
|
+
}, caller: TrustedPrincipal): Promise<AuditHold>;
|
|
217
|
+
/** Release returns matching rows to normal retention; it never deletes anything by itself. */
|
|
218
|
+
releaseHold(tenantId: string, holdId: string, caller: TrustedPrincipal): Promise<AuditHold>;
|
|
219
|
+
/** Publish the current chain head to the external anchor sink and return it. */
|
|
220
|
+
anchor(tenantId: string, caller: TrustedPrincipal): Promise<AuditAnchor>;
|
|
221
|
+
/**
|
|
222
|
+
* Remove the oldest expired, forwarded, unheld rows (a contiguous prefix of the chain) and record a receipt.
|
|
223
|
+
* Returns undefined when nothing is eligible.
|
|
224
|
+
*/
|
|
225
|
+
dispose(tenantId: string, caller: TrustedPrincipal, options?: {
|
|
226
|
+
maxRows?: number;
|
|
227
|
+
}): Promise<AuditDisposalReceipt | undefined>;
|
|
228
|
+
}
|
|
229
|
+
export {};
|