@cogitator-ai/worker 0.3.20 → 0.5.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 +141 -55
- package/dist/connection.d.ts +29 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +63 -0
- package/dist/connection.js.map +1 -0
- package/dist/distributed-swarm-worker.d.ts +56 -0
- package/dist/distributed-swarm-worker.d.ts.map +1 -0
- package/dist/distributed-swarm-worker.js +151 -0
- package/dist/distributed-swarm-worker.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +22 -15
- package/dist/metrics.js.map +1 -1
- package/dist/processors/agent.d.ts +12 -2
- package/dist/processors/agent.d.ts.map +1 -1
- package/dist/processors/agent.js +25 -23
- package/dist/processors/agent.js.map +1 -1
- package/dist/processors/index.d.ts +3 -3
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +3 -3
- package/dist/processors/index.js.map +1 -1
- package/dist/processors/shared.d.ts +26 -3
- package/dist/processors/shared.d.ts.map +1 -1
- package/dist/processors/shared.js +38 -25
- package/dist/processors/shared.js.map +1 -1
- package/dist/processors/swarm-agent.d.ts +25 -4
- package/dist/processors/swarm-agent.d.ts.map +1 -1
- package/dist/processors/swarm-agent.js +33 -47
- package/dist/processors/swarm-agent.js.map +1 -1
- package/dist/processors/swarm.d.ts +7 -2
- package/dist/processors/swarm.d.ts.map +1 -1
- package/dist/processors/swarm.js +75 -50
- package/dist/processors/swarm.js.map +1 -1
- package/dist/processors/workflow.d.ts +21 -5
- package/dist/processors/workflow.d.ts.map +1 -1
- package/dist/processors/workflow.js +304 -8
- package/dist/processors/workflow.js.map +1 -1
- package/dist/queue.d.ts +6 -5
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +16 -19
- package/dist/queue.js.map +1 -1
- package/dist/types.d.ts +58 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +10 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +62 -24
- package/dist/worker.js.map +1 -1
- package/package.json +16 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distributed-swarm-worker.js","sourceRoot":"","sources":["../src/distributed-swarm-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA2B/C,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,GAAG,GAAG,KAAsC,CAAC;IACnD,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,aAAa;QAC1B,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;QAC7B,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;QACjC,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;QAC7B,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ;QACnC,GAAG,CAAC,WAAW,KAAK,IAAI;QACxB,OAAO,GAAG,CAAC,SAAS,EAAE,OAAO,KAAK,QAAQ,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,sBAAsB;IAChB,MAAM,CAA+B;IACrC,MAAM,CAA+B;IACrC,OAAO,CAA0B;IACjC,QAAQ,CAAS;IAC1B,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,IAAI,CAAiB;IACrB,OAAO,GAAG,KAAK,CAAC;IACP,MAAM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,OAAO;QACT,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAE7D,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,SAAU,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzF,OAAO;QACT,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* - Auto-retry with exponential backoff
|
|
7
7
|
* - Job priorities and delays
|
|
8
8
|
* - Prometheus metrics for HPA
|
|
9
|
+
* - Worker nodes for distributed swarms
|
|
9
10
|
*/
|
|
10
11
|
export { JobQueue } from './queue.js';
|
|
11
12
|
export { WorkerPool, type WorkerPoolEvents } from './worker.js';
|
|
13
|
+
export { DistributedSwarmWorker, type DistributedSwarmWorkerConfig, type DistributedSwarmWorkerEvents, } from './distributed-swarm-worker.js';
|
|
12
14
|
export { formatPrometheusMetrics, DurationHistogram, MetricsCollector } from './metrics.js';
|
|
13
|
-
export { processAgentJob, processWorkflowJob, processSwarmJob, processSwarmAgentJob, } from './processors/index.js';
|
|
14
|
-
export type { SerializedAgent, SerializedWorkflow, SerializedWorkflowNode, SerializedWorkflowEdge, SerializedSwarm, JobPayload, AgentJobPayload, WorkflowJobPayload, SwarmJobPayload, SwarmAgentJobPayload, JobResult, AgentJobResult, WorkflowJobResult, SwarmJobResult, SwarmAgentJobResult, QueueConfig, WorkerConfig, QueueMetrics, } from './types.js';
|
|
15
|
+
export { processAgentJob, processWorkflowJob, processSwarmJob, processSwarmAgentJob, executeSwarmAgentJob, buildSwarmConfig, validateWorkflow, type SwarmAgentJobOptions, type SwarmResultPublisher, } from './processors/index.js';
|
|
16
|
+
export type { SerializedAgent, SerializedWorkflow, SerializedWorkflowNode, SerializedWorkflowEdge, AgentNodeConfig, TransformNodeConfig, TransformOperation, ConditionNodeConfig, ConditionOperator, SerializedSwarm, JobPayload, AgentJobPayload, WorkflowJobPayload, SwarmJobPayload, SwarmAgentJobPayload, JobResult, AgentJobResult, WorkflowJobResult, SwarmJobResult, SwarmAgentJobResult, QueueConfig, WorkerConfig, WorkerRuntime, QueueMetrics, } from './types.js';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEzF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* - Auto-retry with exponential backoff
|
|
7
7
|
* - Job priorities and delays
|
|
8
8
|
* - Prometheus metrics for HPA
|
|
9
|
+
* - Worker nodes for distributed swarms
|
|
9
10
|
*/
|
|
10
11
|
export { JobQueue } from './queue.js';
|
|
11
12
|
export { WorkerPool } from './worker.js';
|
|
13
|
+
export { DistributedSwarmWorker, } from './distributed-swarm-worker.js';
|
|
12
14
|
export { formatPrometheusMetrics, DurationHistogram, MetricsCollector } from './metrics.js';
|
|
13
|
-
export { processAgentJob, processWorkflowJob, processSwarmJob, processSwarmAgentJob, } from './processors/index.js';
|
|
15
|
+
export { processAgentJob, processWorkflowJob, processSwarmJob, processSwarmAgentJob, executeSwarmAgentJob, buildSwarmConfig, validateWorkflow, } from './processors/index.js';
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,sBAAsB,GAGvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEzF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GAGjB,MAAM,oBAAoB,CAAC"}
|
package/dist/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuB5C;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAoCR;AAOD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQtC;;OAEG;IACH,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI;IAWtC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAuB/C;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,OAAO,CAAC,UAAU,CAA6B;;IAS/C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAKjD;;OAEG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;CAe5E"}
|
package/dist/metrics.js
CHANGED
|
@@ -7,15 +7,30 @@
|
|
|
7
7
|
* - Worker count
|
|
8
8
|
* - Processing times
|
|
9
9
|
*/
|
|
10
|
+
const LABEL_NAME = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
11
|
+
function escapeLabelValue(value) {
|
|
12
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render Prometheus label pairs (without braces), escaping values per the exposition format.
|
|
16
|
+
*/
|
|
17
|
+
function renderLabels(labels) {
|
|
18
|
+
if (!labels)
|
|
19
|
+
return '';
|
|
20
|
+
return Object.entries(labels)
|
|
21
|
+
.map(([name, value]) => {
|
|
22
|
+
if (!LABEL_NAME.test(name)) {
|
|
23
|
+
throw new Error(`Invalid Prometheus label name: ${name}`);
|
|
24
|
+
}
|
|
25
|
+
return `${name}="${escapeLabelValue(value)}"`;
|
|
26
|
+
})
|
|
27
|
+
.join(',');
|
|
28
|
+
}
|
|
10
29
|
/**
|
|
11
30
|
* Format queue metrics as Prometheus exposition format
|
|
12
31
|
*/
|
|
13
32
|
export function formatPrometheusMetrics(metrics, labels) {
|
|
14
|
-
const labelStr = labels
|
|
15
|
-
? Object.entries(labels)
|
|
16
|
-
.map(([k, v]) => `${k}="${v}"`)
|
|
17
|
-
.join(',')
|
|
18
|
-
: '';
|
|
33
|
+
const labelStr = renderLabels(labels);
|
|
19
34
|
const labelSuffix = labelStr ? `{${labelStr}}` : '';
|
|
20
35
|
const lines = [
|
|
21
36
|
'# HELP cogitator_queue_depth Total number of jobs waiting to be processed',
|
|
@@ -86,11 +101,7 @@ export class DurationHistogram {
|
|
|
86
101
|
* Format as Prometheus exposition format
|
|
87
102
|
*/
|
|
88
103
|
format(labels) {
|
|
89
|
-
const labelStr = labels
|
|
90
|
-
? Object.entries(labels)
|
|
91
|
-
.map(([k, v]) => `${k}="${v}"`)
|
|
92
|
-
.join(',')
|
|
93
|
-
: '';
|
|
104
|
+
const labelStr = renderLabels(labels);
|
|
94
105
|
const lines = [`# HELP ${this.name} ${this.help}`, `# TYPE ${this.name} histogram`];
|
|
95
106
|
let cumulative = 0;
|
|
96
107
|
for (const bucket of DURATION_BUCKETS) {
|
|
@@ -142,11 +153,7 @@ export class MetricsCollector {
|
|
|
142
153
|
parts.push('# HELP cogitator_jobs_by_type_total Jobs processed by type');
|
|
143
154
|
parts.push('# TYPE cogitator_jobs_by_type_total counter');
|
|
144
155
|
for (const [type, count] of this.jobsByType) {
|
|
145
|
-
const typeLabels = labels
|
|
146
|
-
? `${Object.entries(labels)
|
|
147
|
-
.map(([k, v]) => `${k}="${v}"`)
|
|
148
|
-
.join(',')},type="${type}"`
|
|
149
|
-
: `type="${type}"`;
|
|
156
|
+
const typeLabels = renderLabels({ ...labels, type });
|
|
150
157
|
parts.push(`cogitator_jobs_by_type_total{${typeLabels}} ${count}`);
|
|
151
158
|
}
|
|
152
159
|
parts.push('');
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,MAA0C;IAC9D,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,GAAG,IAAI,KAAK,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAqB,EACrB,MAA+B;IAE/B,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,WAAW,G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C;QAC5C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAA0B,EAAE,MAA+B;QAChE,MAAM,KAAK,GAAG,CAAC,uBAAuB,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAE/F,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;YACzE,KAAK,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;YAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC5C,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrD,KAAK,CAAC,IAAI,CAAC,gCAAgC,UAAU,KAAK,KAAK,EAAE,CAAC,CAAC;YACrE,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Recreates an Agent from serialized config and executes it.
|
|
5
5
|
*/
|
|
6
|
-
import type { AgentJobPayload, AgentJobResult } from '../types.js';
|
|
7
|
-
export declare function processAgentJob(payload: AgentJobPayload): Promise<AgentJobResult>;
|
|
6
|
+
import type { AgentJobPayload, AgentJobResult, WorkerRuntime } from '../types.js';
|
|
7
|
+
export declare function processAgentJob(payload: AgentJobPayload, runtime?: WorkerRuntime): Promise<AgentJobResult>;
|
|
8
|
+
interface ToolMessageLike {
|
|
9
|
+
role: string;
|
|
10
|
+
toolCallId?: string;
|
|
11
|
+
content: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tool results are recorded as `tool` messages; recover the output for a tool call.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findToolOutput(messages: readonly ToolMessageLike[], toolCallId: string): unknown;
|
|
17
|
+
export {};
|
|
8
18
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/processors/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/processors/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG/E,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAoBzB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAShG"}
|
package/dist/processors/agent.js
CHANGED
|
@@ -3,33 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Recreates an Agent from serialized config and executes it.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export async function processAgentJob(payload) {
|
|
6
|
+
import { createAgentFromConfig, resolveCogitator } from './shared.js';
|
|
7
|
+
export async function processAgentJob(payload, runtime = {}) {
|
|
9
8
|
const { agentConfig, input, threadId } = payload;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const agent = new Agent({
|
|
13
|
-
name: agentConfig.name,
|
|
14
|
-
model: `${agentConfig.provider}/${agentConfig.model}`,
|
|
15
|
-
instructions: agentConfig.instructions,
|
|
16
|
-
temperature: agentConfig.temperature,
|
|
17
|
-
maxTokens: agentConfig.maxTokens,
|
|
18
|
-
tools,
|
|
19
|
-
});
|
|
20
|
-
const result = await cogitator.run(agent, {
|
|
21
|
-
input,
|
|
22
|
-
threadId,
|
|
23
|
-
});
|
|
24
|
-
const toolCalls = result.toolCalls.map((tc) => ({
|
|
25
|
-
name: tc.name,
|
|
26
|
-
input: tc.arguments,
|
|
27
|
-
output: undefined,
|
|
28
|
-
}));
|
|
9
|
+
const agent = createAgentFromConfig(agentConfig, runtime);
|
|
10
|
+
const result = await resolveCogitator(runtime).run(agent, { input, threadId });
|
|
29
11
|
return {
|
|
30
12
|
type: 'agent',
|
|
31
13
|
output: result.output,
|
|
32
|
-
toolCalls
|
|
14
|
+
toolCalls: result.toolCalls.map((tc) => ({
|
|
15
|
+
name: tc.name,
|
|
16
|
+
input: tc.arguments,
|
|
17
|
+
output: findToolOutput(result.messages, tc.id),
|
|
18
|
+
})),
|
|
33
19
|
tokenUsage: {
|
|
34
20
|
prompt: result.usage.inputTokens,
|
|
35
21
|
completion: result.usage.outputTokens,
|
|
@@ -37,4 +23,20 @@ export async function processAgentJob(payload) {
|
|
|
37
23
|
},
|
|
38
24
|
};
|
|
39
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool results are recorded as `tool` messages; recover the output for a tool call.
|
|
28
|
+
*/
|
|
29
|
+
export function findToolOutput(messages, toolCallId) {
|
|
30
|
+
const message = messages.find((m) => m.role === 'tool' && m.toolCallId === toolCallId);
|
|
31
|
+
if (!message)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (typeof message.content !== 'string')
|
|
34
|
+
return message.content;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(message.content);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return message.content;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
40
42
|
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/processors/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/processors/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAwB,EACxB,UAAyB,EAAE;IAE3B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEjD,MAAM,KAAK,GAAG,qBAAqB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE/E,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACvC,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,KAAK,EAAE,EAAE,CAAC,SAAS;YACnB,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;SAC/C,CAAC,CAAC;QACH,UAAU,EAAE;YACV,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;YAChC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;SAChC;KACF,CAAC;AACJ,CAAC;AAQD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAAoC,EAAE,UAAkB;IACrF,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;IACvF,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAChE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAY,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { processAgentJob } from './agent.js';
|
|
2
|
-
export { processWorkflowJob } from './workflow.js';
|
|
3
|
-
export { processSwarmJob } from './swarm.js';
|
|
4
|
-
export { processSwarmAgentJob } from './swarm-agent.js';
|
|
2
|
+
export { processWorkflowJob, validateWorkflow } from './workflow.js';
|
|
3
|
+
export { processSwarmJob, buildSwarmConfig } from './swarm.js';
|
|
4
|
+
export { processSwarmAgentJob, executeSwarmAgentJob, type SwarmAgentJobOptions, type SwarmResultPublisher, } from './swarm-agent.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAC"}
|
package/dist/processors/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { processAgentJob } from './agent.js';
|
|
2
|
-
export { processWorkflowJob } from './workflow.js';
|
|
3
|
-
export { processSwarmJob } from './swarm.js';
|
|
4
|
-
export { processSwarmAgentJob } from './swarm-agent.js';
|
|
2
|
+
export { processWorkflowJob, validateWorkflow } from './workflow.js';
|
|
3
|
+
export { processSwarmJob, buildSwarmConfig } from './swarm.js';
|
|
4
|
+
export { processSwarmAgentJob, executeSwarmAgentJob, } from './swarm-agent.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Agent, Cogitator } from '@cogitator-ai/core';
|
|
2
2
|
import type { Tool, ToolSchema } from '@cogitator-ai/types';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import type { WorkerRuntime } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Model string to run: models with a provider prefix are used as-is, otherwise the
|
|
6
|
+
* serialized provider is prepended.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveModelString(model: string, provider: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve serialized tool references against the worker's tool registry.
|
|
11
|
+
* Fails when the agent needs tools this worker does not provide, instead of silently
|
|
12
|
+
* running the agent with fake tools.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveTools(schemas: readonly ToolSchema[], available: readonly Tool[]): Tool[];
|
|
15
|
+
export interface SerializedAgentLike {
|
|
16
|
+
name: string;
|
|
17
|
+
instructions: string;
|
|
18
|
+
model: string;
|
|
19
|
+
provider: string;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
maxIterations?: number;
|
|
23
|
+
tools: readonly ToolSchema[];
|
|
24
|
+
}
|
|
25
|
+
export declare function createAgentFromConfig(config: SerializedAgentLike, runtime: WorkerRuntime): Agent;
|
|
26
|
+
export declare function resolveCogitator(runtime: WorkerRuntime): Cogitator;
|
|
27
|
+
export declare function toErrorMessage(error: unknown): string;
|
|
5
28
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/processors/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/processors/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,EAAE,CAc/F;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;CAC9B;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,CAUhG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAElE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD"}
|
|
@@ -1,29 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Agent, Cogitator, parseModel } from '@cogitator-ai/core';
|
|
2
|
+
/**
|
|
3
|
+
* Model string to run: models with a provider prefix are used as-is, otherwise the
|
|
4
|
+
* serialized provider is prepended.
|
|
5
|
+
*/
|
|
6
|
+
export function resolveModelString(model, provider) {
|
|
7
|
+
return parseModel(model).provider ? model : `${provider}/${model}`;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolve serialized tool references against the worker's tool registry.
|
|
11
|
+
* Fails when the agent needs tools this worker does not provide, instead of silently
|
|
12
|
+
* running the agent with fake tools.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveTools(schemas, available) {
|
|
15
|
+
if (schemas.length === 0)
|
|
16
|
+
return [];
|
|
17
|
+
const registry = new Map(available.map((t) => [t.name, t]));
|
|
18
|
+
const missing = schemas.map((s) => s.name).filter((name) => !registry.has(name));
|
|
19
|
+
if (missing.length > 0) {
|
|
20
|
+
throw new Error(`Tools not registered on this worker: ${missing.join(', ')}. ` +
|
|
21
|
+
'Pass their implementations via the worker `tools` option.');
|
|
12
22
|
}
|
|
13
|
-
return
|
|
23
|
+
return schemas.map((schema) => registry.get(schema.name));
|
|
24
|
+
}
|
|
25
|
+
export function createAgentFromConfig(config, runtime) {
|
|
26
|
+
return new Agent({
|
|
27
|
+
name: config.name,
|
|
28
|
+
model: resolveModelString(config.model, config.provider),
|
|
29
|
+
instructions: config.instructions,
|
|
30
|
+
temperature: config.temperature,
|
|
31
|
+
maxTokens: config.maxTokens,
|
|
32
|
+
maxIterations: config.maxIterations,
|
|
33
|
+
tools: resolveTools(config.tools, runtime.tools ?? []),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function resolveCogitator(runtime) {
|
|
37
|
+
return runtime.cogitator ?? new Cogitator();
|
|
14
38
|
}
|
|
15
|
-
export function
|
|
16
|
-
return
|
|
17
|
-
name: schema.name,
|
|
18
|
-
description: schema.description,
|
|
19
|
-
parameters: jsonSchemaToZod(schema.parameters),
|
|
20
|
-
execute: async (input) => {
|
|
21
|
-
console.warn(`[worker] Tool "${schema.name}" called with input:`, JSON.stringify(input));
|
|
22
|
-
return {
|
|
23
|
-
warning: 'Tool executed in worker with stub implementation',
|
|
24
|
-
input,
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
}));
|
|
39
|
+
export function toErrorMessage(error) {
|
|
40
|
+
return error instanceof Error ? error.message : String(error);
|
|
28
41
|
}
|
|
29
42
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/processors/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/processors/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIlE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,QAAgB;IAChE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAA8B,EAAE,SAA0B;IACrF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,wCAAwC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC5D,2DAA2D,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAE,CAAC,CAAC;AAC7D,CAAC;AAaD,MAAM,UAAU,qBAAqB,CAAC,MAA2B,EAAE,OAAsB;IACvF,OAAO,IAAI,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC;QACxD,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;KACvD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO,OAAO,CAAC,SAAS,IAAI,IAAI,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Swarm Agent job processor
|
|
3
3
|
*
|
|
4
|
-
* Executes a single agent
|
|
5
|
-
*
|
|
4
|
+
* Executes a single agent turn of a distributed swarm. The returned result always carries
|
|
5
|
+
* the job id so the swarm coordinator can match it; failures are reported as results with
|
|
6
|
+
* an `error` field instead of being thrown.
|
|
6
7
|
*/
|
|
7
|
-
import type { SwarmAgentJobPayload, SwarmAgentJobResult } from '../types.js';
|
|
8
|
-
export declare function
|
|
8
|
+
import type { SwarmAgentJobPayload, SwarmAgentJobResult, WorkerRuntime } from '../types.js';
|
|
9
|
+
export declare function executeSwarmAgentJob(payload: SwarmAgentJobPayload, runtime?: WorkerRuntime): Promise<SwarmAgentJobResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Publishes a job result on the channel the swarm coordinator listens to.
|
|
12
|
+
*/
|
|
13
|
+
export interface SwarmResultPublisher {
|
|
14
|
+
publish(channel: string, message: string): Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface SwarmAgentJobOptions extends WorkerRuntime {
|
|
17
|
+
/** Connection used to publish the result back to the coordinator */
|
|
18
|
+
publisher: SwarmResultPublisher;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a failure is final. Non-final failures are rethrown without publishing so the
|
|
21
|
+
* queue can retry the job (default: true).
|
|
22
|
+
*/
|
|
23
|
+
isFinalAttempt?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Execute a swarm agent job and publish its result to `payload.stateKeys.results`.
|
|
27
|
+
* Throws after publishing when the agent failed, so queues mark the job as failed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function processSwarmAgentJob(payload: SwarmAgentJobPayload, options: SwarmAgentJobOptions): Promise<SwarmAgentJobResult>;
|
|
9
30
|
//# sourceMappingURL=swarm-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-agent.d.ts","sourceRoot":"","sources":["../../src/processors/swarm-agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"swarm-agent.d.ts","sourceRoot":"","sources":["../../src/processors/swarm-agent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA2C9B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,oEAAoE;IACpE,SAAS,EAAE,oBAAoB,CAAC;IAChC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Swarm Agent job processor
|
|
3
3
|
*
|
|
4
|
-
* Executes a single agent
|
|
5
|
-
*
|
|
4
|
+
* Executes a single agent turn of a distributed swarm. The returned result always carries
|
|
5
|
+
* the job id so the swarm coordinator can match it; failures are reported as results with
|
|
6
|
+
* an `error` field instead of being thrown.
|
|
6
7
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { swarmId, agentName, agentConfig, input, context, stateKeys } = payload;
|
|
12
|
-
let redis = null;
|
|
8
|
+
import { createAgentFromConfig, resolveCogitator, toErrorMessage } from './shared.js';
|
|
9
|
+
import { findToolOutput } from './agent.js';
|
|
10
|
+
export async function executeSwarmAgentJob(payload, runtime = {}) {
|
|
11
|
+
const { jobId, swarmId, agentName, agentConfig, input, context, runOptions } = payload;
|
|
13
12
|
try {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const agent = new Agent({
|
|
17
|
-
name: agentConfig.name,
|
|
18
|
-
model: `${agentConfig.provider}/${agentConfig.model}`,
|
|
19
|
-
instructions: agentConfig.instructions,
|
|
20
|
-
temperature: agentConfig.temperature,
|
|
21
|
-
maxTokens: agentConfig.maxTokens,
|
|
22
|
-
tools,
|
|
23
|
-
});
|
|
24
|
-
const result = await cogitator.run(agent, {
|
|
13
|
+
const agent = createAgentFromConfig(agentConfig, runtime);
|
|
14
|
+
const result = await resolveCogitator(runtime).run(agent, {
|
|
25
15
|
input,
|
|
26
|
-
context: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
16
|
+
context: { ...context, _distributedSwarm: true },
|
|
17
|
+
...(runOptions?.threadId && { threadId: runOptions.threadId }),
|
|
18
|
+
...(runOptions?.timeout !== undefined && { timeout: runOptions.timeout }),
|
|
19
|
+
...(runOptions?.saveHistory !== undefined && { saveHistory: runOptions.saveHistory }),
|
|
30
20
|
});
|
|
31
|
-
|
|
21
|
+
return {
|
|
32
22
|
type: 'swarm-agent',
|
|
23
|
+
jobId,
|
|
33
24
|
swarmId,
|
|
34
25
|
agentName,
|
|
35
26
|
output: result.output,
|
|
@@ -37,7 +28,7 @@ export async function processSwarmAgentJob(payload) {
|
|
|
37
28
|
toolCalls: result.toolCalls.map((tc) => ({
|
|
38
29
|
name: tc.name,
|
|
39
30
|
input: tc.arguments,
|
|
40
|
-
output:
|
|
31
|
+
output: findToolOutput(result.messages, tc.id),
|
|
41
32
|
})),
|
|
42
33
|
tokenUsage: {
|
|
43
34
|
prompt: result.usage.inputTokens,
|
|
@@ -45,38 +36,33 @@ export async function processSwarmAgentJob(payload) {
|
|
|
45
36
|
total: result.usage.totalTokens,
|
|
46
37
|
},
|
|
47
38
|
};
|
|
48
|
-
redis = new Redis({
|
|
49
|
-
host: process.env.REDIS_HOST ?? 'localhost',
|
|
50
|
-
port: parseInt(process.env.REDIS_PORT ?? '6379', 10),
|
|
51
|
-
password: process.env.REDIS_PASSWORD,
|
|
52
|
-
});
|
|
53
|
-
await redis.publish(stateKeys.results, JSON.stringify(jobResult));
|
|
54
|
-
return jobResult;
|
|
55
39
|
}
|
|
56
40
|
catch (error) {
|
|
57
|
-
|
|
41
|
+
return {
|
|
58
42
|
type: 'swarm-agent',
|
|
43
|
+
jobId,
|
|
59
44
|
swarmId,
|
|
60
45
|
agentName,
|
|
61
46
|
output: '',
|
|
62
47
|
toolCalls: [],
|
|
63
48
|
tokenUsage: { prompt: 0, completion: 0, total: 0 },
|
|
64
|
-
error: error
|
|
49
|
+
error: toErrorMessage(error),
|
|
65
50
|
};
|
|
66
|
-
if (!redis) {
|
|
67
|
-
redis = new Redis({
|
|
68
|
-
host: process.env.REDIS_HOST ?? 'localhost',
|
|
69
|
-
port: parseInt(process.env.REDIS_PORT ?? '6379', 10),
|
|
70
|
-
password: process.env.REDIS_PASSWORD,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
await redis.publish(stateKeys.results, JSON.stringify(errorResult));
|
|
74
|
-
throw error;
|
|
75
51
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Execute a swarm agent job and publish its result to `payload.stateKeys.results`.
|
|
55
|
+
* Throws after publishing when the agent failed, so queues mark the job as failed.
|
|
56
|
+
*/
|
|
57
|
+
export async function processSwarmAgentJob(payload, options) {
|
|
58
|
+
const result = await executeSwarmAgentJob(payload, options);
|
|
59
|
+
const isFinal = options.isFinalAttempt ?? true;
|
|
60
|
+
if (result.error === undefined || isFinal) {
|
|
61
|
+
await options.publisher.publish(payload.stateKeys.results, JSON.stringify(result));
|
|
62
|
+
}
|
|
63
|
+
if (result.error !== undefined) {
|
|
64
|
+
throw new Error(result.error);
|
|
80
65
|
}
|
|
66
|
+
return result;
|
|
81
67
|
}
|
|
82
68
|
//# sourceMappingURL=swarm-agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-agent.js","sourceRoot":"","sources":["../../src/processors/swarm-agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"swarm-agent.js","sourceRoot":"","sources":["../../src/processors/swarm-agent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,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AK,CAAC,WAAW;gBAChC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY;gBACrC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;aAChC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,KAAK;YACL,OAAO;YACP,SAAS;YACT,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;YAClD,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;SAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAmBD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA6B,EAC7B,OAA6B;IAE7B,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC;IAE/C,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,EAAE,CAAC;QAC1C,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Recreates a Swarm from serialized config and executes it.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type { SwarmConfig } from '@cogitator-ai/types';
|
|
7
|
+
import type { SerializedSwarm, SwarmJobPayload, SwarmJobResult, WorkerRuntime } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Translate a serialized swarm topology into a full swarm configuration.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildSwarmConfig(serialized: SerializedSwarm, runtime: WorkerRuntime, name?: string): SwarmConfig;
|
|
12
|
+
export declare function processSwarmJob(payload: SwarmJobPayload, runtime?: WorkerRuntime): Promise<SwarmJobResult>;
|
|
8
13
|
//# sourceMappingURL=swarm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/processors/swarm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/processors/swarm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAEV,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,aAAa,EACtB,IAAI,SAA+B,GAClC,WAAW,CAmDb;AAeD,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAmBzB"}
|