@agen-ai/agent-runtime 0.3.1 → 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.
- package/README.md +176 -25
- package/dist/adapterValidation.d.ts +1 -1
- package/dist/adapterValidation.js +162 -95
- package/dist/contractErrors.d.ts +15 -2
- package/dist/contractErrors.js +39 -1
- package/dist/hostBindings/index.d.ts +4 -0
- package/dist/hostBindings/index.js +9 -0
- package/dist/hostBindings/lifetime.d.ts +25 -0
- package/dist/hostBindings/lifetime.js +147 -0
- package/dist/hostBindings/opening.d.ts +12 -0
- package/dist/hostBindings/opening.js +24 -0
- package/dist/hostBindings/schema.d.ts +9 -0
- package/dist/hostBindings/schema.js +169 -0
- package/dist/hostBindings/types.d.ts +71 -0
- package/dist/hostBindings/types.js +0 -0
- package/dist/hostBindings/validation.d.ts +14 -0
- package/dist/hostBindings/validation.js +107 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/internal/objectShape.d.ts +2 -0
- package/dist/internal/objectShape.js +7 -0
- package/dist/outputValidation.js +1 -0
- package/dist/sessionCleanup.d.ts +9 -0
- package/dist/sessionCleanup.js +17 -0
- package/dist/sessionValidation.d.ts +12 -2
- package/dist/sessionValidation.js +134 -305
- package/dist/sessions.d.ts +28 -4
- package/dist/testing/conformance.d.ts +3 -3
- package/dist/testing/conformance.js +24 -30
- package/dist/testing/fakeProvider.js +56 -45
- package/dist/turnExecution/execution.d.ts +26 -0
- package/dist/turnExecution/execution.js +214 -0
- package/dist/turnExecution/receipts.d.ts +6 -0
- package/dist/turnExecution/receipts.js +39 -0
- package/dist/turnExecution/requests.d.ts +19 -0
- package/dist/turnExecution/requests.js +56 -0
- package/package.json +2 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentRequest, AgentTurnId } from "@agen-ai/agent-protocol";
|
|
2
|
+
export interface PendingAgentRequest {
|
|
3
|
+
readonly request: AgentRequest;
|
|
4
|
+
readonly turnId: AgentTurnId;
|
|
5
|
+
}
|
|
6
|
+
export interface SuspendedAgentTurnRequests {
|
|
7
|
+
readonly restore: () => void;
|
|
8
|
+
readonly withdraw: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createAgentTurnRequestAdmission(input: Readonly<{
|
|
11
|
+
pendingRequests: Map<string, PendingAgentRequest>;
|
|
12
|
+
canRestore: () => boolean;
|
|
13
|
+
}>): {
|
|
14
|
+
claim: (requestId: string, pending: PendingAgentRequest) => (() => void);
|
|
15
|
+
suspend: () => SuspendedAgentTurnRequests;
|
|
16
|
+
withdraw: () => void;
|
|
17
|
+
observeRequest(): void;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function createRequestAdmissionGeneration() {
|
|
2
|
+
return { suspensions: /* @__PURE__ */ new Set(), withheldRequests: /* @__PURE__ */ new Map() };
|
|
3
|
+
}
|
|
4
|
+
function createAgentTurnRequestAdmission(input) {
|
|
5
|
+
let generation = createRequestAdmissionGeneration();
|
|
6
|
+
const withdraw = () => {
|
|
7
|
+
generation = createRequestAdmissionGeneration();
|
|
8
|
+
input.pendingRequests.clear();
|
|
9
|
+
};
|
|
10
|
+
const restoreReadyRequests = (requestGeneration) => {
|
|
11
|
+
if (requestGeneration !== generation || !input.canRestore() || requestGeneration.suspensions.size > 0 || input.pendingRequests.size > 0) return;
|
|
12
|
+
for (const [requestId, pending] of requestGeneration.withheldRequests) {
|
|
13
|
+
input.pendingRequests.set(requestId, pending);
|
|
14
|
+
}
|
|
15
|
+
requestGeneration.withheldRequests.clear();
|
|
16
|
+
};
|
|
17
|
+
const claim = (requestId, pending) => {
|
|
18
|
+
const claimedGeneration = generation;
|
|
19
|
+
input.pendingRequests.delete(requestId);
|
|
20
|
+
return () => {
|
|
21
|
+
if (claimedGeneration !== generation || !input.canRestore()) return;
|
|
22
|
+
claimedGeneration.withheldRequests.set(requestId, pending);
|
|
23
|
+
restoreReadyRequests(claimedGeneration);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const suspend = () => {
|
|
27
|
+
const suspendedGeneration = generation;
|
|
28
|
+
const suspension = /* @__PURE__ */ Symbol("interruption");
|
|
29
|
+
suspendedGeneration.suspensions.add(suspension);
|
|
30
|
+
for (const [requestId, pending] of input.pendingRequests) {
|
|
31
|
+
suspendedGeneration.withheldRequests.set(requestId, pending);
|
|
32
|
+
}
|
|
33
|
+
input.pendingRequests.clear();
|
|
34
|
+
return {
|
|
35
|
+
restore() {
|
|
36
|
+
if (!suspendedGeneration.suspensions.delete(suspension)) return;
|
|
37
|
+
restoreReadyRequests(suspendedGeneration);
|
|
38
|
+
},
|
|
39
|
+
withdraw() {
|
|
40
|
+
if (!suspendedGeneration.suspensions.delete(suspension)) return;
|
|
41
|
+
if (suspendedGeneration === generation) withdraw();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
claim,
|
|
47
|
+
suspend,
|
|
48
|
+
withdraw,
|
|
49
|
+
observeRequest() {
|
|
50
|
+
generation = createRequestAdmissionGeneration();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
createAgentTurnRequestAdmission
|
|
56
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agen-ai/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provider-neutral driver, instance, adapter, session, output, and conformance contracts for coding-agent runtimes.",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agen-ai/agent-protocol": "^0.
|
|
34
|
+
"@agen-ai/agent-protocol": "^0.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsup": "^8.5.0"
|