@agentropy/runtime 0.0.0-stage → 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 +39 -2
- 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 +48 -3
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `workflow.start` / `workflow.status` backed by a WorkflowEngine (ADR-0006, M2-07). The engine owns
|
|
3
|
+
* deterministic execution; Agentropy only starts runs idempotently (the derived step key is the engine's
|
|
4
|
+
* idempotency key) and turns engine completion into an inbound `workflow` event, so the waiting agent task wakes
|
|
5
|
+
* through its ordinary event subscription (filter `{ runId }`). Subscribe before starting so no completion is
|
|
6
|
+
* missed. No workflow semantics (steps, branching, compensation) live in Agentropy.
|
|
7
|
+
*/
|
|
8
|
+
import { AgentropyError, } from '@agentropy/core';
|
|
9
|
+
/** Source of the completion events; subscribe with `{ source: WORKFLOW_SOURCE, filter: { runId } }`. */
|
|
10
|
+
export const WORKFLOW_SOURCE = 'workflow';
|
|
11
|
+
export function workflowOperationHandlers(engine,
|
|
12
|
+
/**
|
|
13
|
+
* With a store, `workflow.start` is journaled by its step key (the `effects` collection, like other external
|
|
14
|
+
* effects): a replayed step returns the run it started instead of asking the engine again, so once-per-key
|
|
15
|
+
* holds even for engines that ignore the idempotency key (Conductor OSS does). A crash between the engine's
|
|
16
|
+
* answer and the journal write can still start a second run; the engine's own idempotency covers that window.
|
|
17
|
+
*/
|
|
18
|
+
journal) {
|
|
19
|
+
return {
|
|
20
|
+
start: async (raw, ctx) => {
|
|
21
|
+
const input = raw;
|
|
22
|
+
if (!input?.workflow || typeof input.workflow !== 'string')
|
|
23
|
+
throw new AgentropyError('SchemaViolation', 'workflow.start needs a workflow name');
|
|
24
|
+
if (!ctx.idempotencyKey)
|
|
25
|
+
throw new AgentropyError('SchemaViolation', 'workflow.start requires a stepKey', {
|
|
26
|
+
details: { reason: 'missingStepKey' },
|
|
27
|
+
});
|
|
28
|
+
const effectId = `effect:${ctx.idempotencyKey}`;
|
|
29
|
+
if (journal) {
|
|
30
|
+
const done = await journal.store.transaction((tx) => tx.get('effects', effectId));
|
|
31
|
+
if (done)
|
|
32
|
+
return done.value.result;
|
|
33
|
+
}
|
|
34
|
+
const run = await engine.start(input.workflow, input.input, {
|
|
35
|
+
tenantId: ctx.tenantId,
|
|
36
|
+
taskId: ctx.taskId,
|
|
37
|
+
idempotencyKey: ctx.idempotencyKey,
|
|
38
|
+
});
|
|
39
|
+
if (journal)
|
|
40
|
+
await journal.store.transaction(async (tx) => {
|
|
41
|
+
if (await tx.get('effects', effectId))
|
|
42
|
+
return;
|
|
43
|
+
await tx.insert('effects', effectId, {
|
|
44
|
+
taskId: ctx.taskId,
|
|
45
|
+
operation: 'workflow.start',
|
|
46
|
+
...(ctx.stepKey ? { stepKey: ctx.stepKey } : {}),
|
|
47
|
+
result: run,
|
|
48
|
+
at: journal.now(),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return run;
|
|
52
|
+
},
|
|
53
|
+
status: async (raw, ctx) => {
|
|
54
|
+
const { runId } = (raw ?? {});
|
|
55
|
+
if (!runId)
|
|
56
|
+
throw new AgentropyError('SchemaViolation', 'workflow.status needs a runId');
|
|
57
|
+
return engine.status(runId, { tenantId: ctx.tenantId });
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bridges engine completions into the trusted event ingress (deduplicated by run ID). A failed publish (a store
|
|
63
|
+
* blip) is retried with doubling backoff; after `attempts` it is handed to `onError`, because the event ID makes a
|
|
64
|
+
* later manual or polled redelivery safe (FEAT-038.2).
|
|
65
|
+
*/
|
|
66
|
+
export function bridgeWorkflowCompletions(engine, publish, options = {}) {
|
|
67
|
+
const attempts = options.attempts ?? 5;
|
|
68
|
+
const send = async (event) => {
|
|
69
|
+
for (let attempt = 1;; attempt++) {
|
|
70
|
+
try {
|
|
71
|
+
await publish(event);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
if (attempt >= attempts) {
|
|
76
|
+
try {
|
|
77
|
+
options.onError?.(err);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// The hook must not turn a reported failure into an unhandled one.
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await new Promise((r) => setTimeout(r, (options.retryMs ?? 100) * 2 ** (attempt - 1)).unref());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
engine.onFinished((run) => {
|
|
89
|
+
void send({
|
|
90
|
+
eventId: `workflow:${run.runId}:${run.state}`,
|
|
91
|
+
source: WORKFLOW_SOURCE,
|
|
92
|
+
tenantId: run.tenantId,
|
|
93
|
+
payload: {
|
|
94
|
+
runId: run.runId,
|
|
95
|
+
state: run.state,
|
|
96
|
+
...(run.output !== undefined ? { output: run.output } : {}),
|
|
97
|
+
...(run.code ? { code: run.code } : {}),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentropy/runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agentropy runtime: registries, task service, scheduler, communication providers (direct, A2A) and the local app facade.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/bassemZohdy/agentropy.git",
|
|
9
|
+
"directory": "packages/runtime"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/bassemZohdy/agentropy/tree/main/packages/runtime#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/bassemZohdy/agentropy/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agents",
|
|
17
|
+
"multi-agent",
|
|
18
|
+
"runtime",
|
|
19
|
+
"durable-execution",
|
|
20
|
+
"a2a",
|
|
21
|
+
"agentropy"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"semver": "^7.8.6",
|
|
39
|
+
"yaml": "^2.9.1",
|
|
40
|
+
"@agentropy/core": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/semver": "^7.8.0",
|
|
44
|
+
"@agentropy/store-sqlite": "0.1.0",
|
|
45
|
+
"@agentropy/testkit": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -b",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
}
|
|
6
51
|
}
|