@novalabai/adk 1.0.0 → 1.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/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestration/index.d.ts +95 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +318 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/types.d.ts +128 -0
- package/dist/orchestration/types.d.ts.map +1 -0
- package/dist/orchestration/types.js +3 -0
- package/dist/orchestration/types.js.map +1 -0
- package/package.json +8 -3
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { DataResource } from './resources/data.js';
|
|
|
7
7
|
import { HistoryResource } from './resources/history.js';
|
|
8
8
|
import { TrustResource } from './resources/trust.js';
|
|
9
9
|
import { WebhooksResource } from './resources/webhooks.js';
|
|
10
|
+
import { OrchestrationResource } from './orchestration/index.js';
|
|
10
11
|
export interface NovaClientOptions {
|
|
11
12
|
apiKey: string;
|
|
12
13
|
region?: string;
|
|
@@ -23,6 +24,15 @@ export declare class NovaClient {
|
|
|
23
24
|
readonly history: HistoryResource;
|
|
24
25
|
readonly trust: TrustResource;
|
|
25
26
|
readonly webhooks: WebhooksResource;
|
|
27
|
+
/**
|
|
28
|
+
* Multi-agent orchestration engine.
|
|
29
|
+
*
|
|
30
|
+
* → route(intent) — classify & dispatch to the best agent
|
|
31
|
+
* → parallel([agent₁, agent₂]) — fan-out to N agents concurrently
|
|
32
|
+
* → verify(output) ✓ — trust-layer verification gate
|
|
33
|
+
* → pipeline(steps) — compose route → parallel → verify
|
|
34
|
+
*/
|
|
35
|
+
readonly orchestrate: OrchestrationResource;
|
|
26
36
|
private readonly http;
|
|
27
37
|
constructor(options: NovaClientOptions);
|
|
28
38
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,qBAAa,UAAU;IACrB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,OAAO,EAAE,iBAAiB;CAsBvC"}
|
package/dist/client.js
CHANGED
|
@@ -11,6 +11,7 @@ const data_js_1 = require("./resources/data.js");
|
|
|
11
11
|
const history_js_1 = require("./resources/history.js");
|
|
12
12
|
const trust_js_1 = require("./resources/trust.js");
|
|
13
13
|
const webhooks_js_1 = require("./resources/webhooks.js");
|
|
14
|
+
const index_js_1 = require("./orchestration/index.js");
|
|
14
15
|
const DEFAULT_REGION = 'eu-west-1';
|
|
15
16
|
class NovaClient {
|
|
16
17
|
agents;
|
|
@@ -22,6 +23,15 @@ class NovaClient {
|
|
|
22
23
|
history;
|
|
23
24
|
trust;
|
|
24
25
|
webhooks;
|
|
26
|
+
/**
|
|
27
|
+
* Multi-agent orchestration engine.
|
|
28
|
+
*
|
|
29
|
+
* → route(intent) — classify & dispatch to the best agent
|
|
30
|
+
* → parallel([agent₁, agent₂]) — fan-out to N agents concurrently
|
|
31
|
+
* → verify(output) ✓ — trust-layer verification gate
|
|
32
|
+
* → pipeline(steps) — compose route → parallel → verify
|
|
33
|
+
*/
|
|
34
|
+
orchestrate;
|
|
25
35
|
http;
|
|
26
36
|
constructor(options) {
|
|
27
37
|
const region = options.region ?? DEFAULT_REGION;
|
|
@@ -41,6 +51,7 @@ class NovaClient {
|
|
|
41
51
|
this.history = new history_js_1.HistoryResource(this.http);
|
|
42
52
|
this.trust = new trust_js_1.TrustResource(this.http);
|
|
43
53
|
this.webhooks = new webhooks_js_1.WebhooksResource(this.http);
|
|
54
|
+
this.orchestrate = new index_js_1.OrchestrationResource(this.http);
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
exports.NovaClient = NovaClient;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,qDAAuD;AACvD,2DAA6D;AAC7D,uDAAyD;AACzD,+DAAiE;AACjE,+DAAiE;AACjE,iDAAmD;AACnD,uDAAyD;AACzD,mDAAqD;AACrD,yDAA2D;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,qDAAuD;AACvD,2DAA6D;AAC7D,uDAAyD;AACzD,+DAAiE;AACjE,+DAAiE;AACjE,iDAAmD;AACnD,uDAAyD;AACzD,mDAAqD;AACrD,yDAA2D;AAC3D,uDAAiE;AASjE,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC,MAAa,UAAU;IACZ,MAAM,CAAiB;IACvB,SAAS,CAAoB;IAC7B,OAAO,CAAkB;IACzB,WAAW,CAAsB;IACjC,WAAW,CAAsB;IACjC,IAAI,CAAe;IACnB,OAAO,CAAkB;IACzB,KAAK,CAAgB;IACrB,QAAQ,CAAmB;IAEpC;;;;;;;OAOG;IACM,WAAW,CA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ataResource } from './resources/data.js';
|
|
|
16
16
|
export { HistoryResource } from './resources/history.js';
|
|
17
17
|
export { TrustResource } from './resources/trust.js';
|
|
18
18
|
export { WebhooksResource } from './resources/webhooks.js';
|
|
19
|
+
export { OrchestrationResource } from './orchestration/index.js';
|
|
20
|
+
export type { RouteParams, RouteResult, RouteTarget, ParallelParams, ParallelResult, ParallelTask, ParallelTaskResult, ParallelMergeStrategy, VerifyParams, VerifyResult, PipelineParams, PipelineResult, PipelineContext, PipelineStep, PipelineStepKind, } from './orchestration/index.js';
|
|
19
21
|
export type { Agent, AgentStatus, AgentCreateParams, AgentUpdateParams, AgentDeployParams, AgentRunParams, AgentRunResult, AgentTool, AgentTrigger, MemoryScope, RiskLevel, HumanApprovalConfig, } from './types/agents.js';
|
|
20
22
|
export type { Workflow, WorkflowStep, WorkflowCreateParams, WorkflowUpdateParams, WorkflowRunParams, WorkflowRunResult, WorkflowStepResult, WorkflowCondition, WorkflowTrigger, } from './types/workflows.js';
|
|
21
23
|
export type { Signal, SignalSystem, SignalAnomaly, SignalStreamOptions, SignalIngestParams, SignalHistoryParams, SignalSystemCreateParams, } from './types/signals.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EACL,SAAS,EACT,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,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,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhooksResource = exports.TrustResource = exports.HistoryResource = exports.DataResource = exports.ConnectionsResource = exports.AutomationsResource = exports.SignalsResource = exports.WorkflowsResource = exports.AgentsResource = exports.NovaStream = exports.verifyWebhookSignature = exports.signPayload = exports.HttpClient = exports.ConfidenceGate = exports.evaluateConfidence = exports.ConfidenceLevel = exports.NovaConfidenceError = exports.NovaTimeoutError = exports.NovaValidationError = exports.NovaRateLimitError = exports.NovaAuthError = exports.NovaAPIError = exports.NovaError = exports.NovaClient = void 0;
|
|
3
|
+
exports.OrchestrationResource = exports.WebhooksResource = exports.TrustResource = exports.HistoryResource = exports.DataResource = exports.ConnectionsResource = exports.AutomationsResource = exports.SignalsResource = exports.WorkflowsResource = exports.AgentsResource = exports.NovaStream = exports.verifyWebhookSignature = exports.signPayload = exports.HttpClient = exports.ConfidenceGate = exports.evaluateConfidence = exports.ConfidenceLevel = exports.NovaConfidenceError = exports.NovaTimeoutError = exports.NovaValidationError = exports.NovaRateLimitError = exports.NovaAuthError = exports.NovaAPIError = exports.NovaError = exports.NovaClient = void 0;
|
|
4
4
|
var client_js_1 = require("./client.js");
|
|
5
5
|
Object.defineProperty(exports, "NovaClient", { enumerable: true, get: function () { return client_js_1.NovaClient; } });
|
|
6
6
|
var errors_js_1 = require("./core/errors.js");
|
|
@@ -40,4 +40,6 @@ var trust_js_1 = require("./resources/trust.js");
|
|
|
40
40
|
Object.defineProperty(exports, "TrustResource", { enumerable: true, get: function () { return trust_js_1.TrustResource; } });
|
|
41
41
|
var webhooks_js_1 = require("./resources/webhooks.js");
|
|
42
42
|
Object.defineProperty(exports, "WebhooksResource", { enumerable: true, get: function () { return webhooks_js_1.WebhooksResource; } });
|
|
43
|
+
var index_js_1 = require("./orchestration/index.js");
|
|
44
|
+
Object.defineProperty(exports, "OrchestrationResource", { enumerable: true, get: function () { return index_js_1.OrchestrationResource; } });
|
|
43
45
|
//# 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,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AAGnB,8CAQ0B;AAPxB,sGAAA,SAAS,OAAA;AACT,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AACnB,6GAAA,gBAAgB,OAAA;AAChB,gHAAA,mBAAmB,OAAA;AAGrB,sDAI8B;AAH5B,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,+GAAA,cAAc,OAAA;AAIhB,0CAA4C;AAAnC,qGAAA,UAAU,OAAA;AAGnB,2CAAsE;AAA7D,sGAAA,WAAW,OAAA;AAAE,iHAAA,sBAAsB,OAAA;AAC5C,qDAAkD;AAAzC,0GAAA,UAAU,OAAA;AA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e,OAAA;AACxB,iDAAqD;AAA5C,yGAAA,aAAa,OAAA;AACtB,uDAA2D;AAAlD,+GAAA,gBAAgB,OAAA;AAEzB,qDAAiE;AAAxD,iHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { HttpClient } from '../core/http.js';
|
|
2
|
+
import type { RouteParams, RouteResult, ParallelParams, ParallelResult, VerifyParams, VerifyResult, PipelineParams, PipelineResult } from './types.js';
|
|
3
|
+
export type { RouteParams, RouteResult, RouteTarget, ParallelParams, ParallelResult, ParallelTask, ParallelTaskResult, ParallelMergeStrategy, VerifyParams, VerifyResult, PipelineParams, PipelineResult, PipelineContext, PipelineStep, PipelineStepKind, } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Orchestration engine for Nova multi-agent pipelines.
|
|
6
|
+
*
|
|
7
|
+
* Provides three composable primitives that match the Nova architecture:
|
|
8
|
+
*
|
|
9
|
+
* → route(intent) — classify & dispatch to the best agent
|
|
10
|
+
* → parallel([agent₁, agent₂]) — fan-out to N agents concurrently
|
|
11
|
+
* → verify(output) ✓ — trust-layer verification gate
|
|
12
|
+
*
|
|
13
|
+
* These can be used standalone or chained via `pipeline()`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class OrchestrationResource {
|
|
16
|
+
private readonly http;
|
|
17
|
+
constructor(http: HttpClient);
|
|
18
|
+
/**
|
|
19
|
+
* Classify the user's intent and route to the best-matching agent.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const routed = await nova.orchestrate.route({
|
|
23
|
+
* input: "Analyse customer churn",
|
|
24
|
+
* targets: [
|
|
25
|
+
* { agentId: "support-agent", intents: ["support", "help"] },
|
|
26
|
+
* { agentId: "data-agent", intents: ["analyse", "data", "metrics"] },
|
|
27
|
+
* ],
|
|
28
|
+
* });
|
|
29
|
+
* console.log(routed.selectedAgentId); // "data-agent"
|
|
30
|
+
* console.log(routed.result?.output);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
route(params: RouteParams): Promise<RouteResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute multiple agents concurrently and merge their results.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* const results = await nova.orchestrate.parallel({
|
|
39
|
+
* tasks: [
|
|
40
|
+
* { agentId: "support-agent", input: "Summarise ticket #1234" },
|
|
41
|
+
* { agentId: "crm-agent", input: "Get customer profile for ticket #1234" },
|
|
42
|
+
* ],
|
|
43
|
+
* merge: "all", // "all" | "best" | "first" | "custom"
|
|
44
|
+
* timeout: 30_000, // 30s max
|
|
45
|
+
* confidenceFloor: 50, // drop results below 50% confidence
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* for (const t of results.tasks) {
|
|
49
|
+
* console.log(`${t.agentId}: ${t.status} (${t.duration}ms)`);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
parallel(params: ParallelParams): Promise<ParallelResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Verify an agent's output through the Nova trust layer.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* const v = await nova.orchestrate.verify({
|
|
59
|
+
* input: "Summarise Q4 revenue",
|
|
60
|
+
* output: agentResult.output,
|
|
61
|
+
* agentId: "data-agent",
|
|
62
|
+
* threshold: 80, // must score ≥ 80 to pass
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* if (v.passed) {
|
|
66
|
+
* console.log("Verified ✓", v.trust.overallScore);
|
|
67
|
+
* } else {
|
|
68
|
+
* console.log("Failed verification:", v.trust.concerns);
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
verify(params: VerifyParams): Promise<VerifyResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Execute a composable multi-step pipeline.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const result = await nova.orchestrate.pipeline({
|
|
78
|
+
* input: "Analyse customer churn for Q4",
|
|
79
|
+
* steps: [
|
|
80
|
+
* { kind: "route", params: { input: "", targets: [...] } },
|
|
81
|
+
* { kind: "parallel", params: { tasks: [...] } },
|
|
82
|
+
* { kind: "verify", params: { input: "", output: "" } },
|
|
83
|
+
* ],
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
pipeline(params: PipelineParams): Promise<PipelineResult>;
|
|
88
|
+
/** Run a single agent task with optional timeout. */
|
|
89
|
+
private runTask;
|
|
90
|
+
/** Score targets against input using keyword / intent matching. */
|
|
91
|
+
private scoreTargets;
|
|
92
|
+
/** Extract a simple intent label from input. */
|
|
93
|
+
private classifyIntent;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,cAAc,EACd,cAAc,EAGd,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAM5B;;;;;;;;;;;;;;OAcG;IACG,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAiCtD;;;;;;;;;;;;;;;;;;OAkBG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAwE/D;;;;;;;;;;;;;;;;;OAiBG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAuBzD;;;;;;;;;;;;;OAaG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAsF/D,qDAAqD;YACvC,OAAO;IAoCrB,mEAAmE;IACnE,OAAO,CAAC,YAAY;IA8BpB,gDAAgD;IAChD,OAAO,CAAC,cAAc;CAwBvB"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrchestrationResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Orchestration engine for Nova multi-agent pipelines.
|
|
6
|
+
*
|
|
7
|
+
* Provides three composable primitives that match the Nova architecture:
|
|
8
|
+
*
|
|
9
|
+
* → route(intent) — classify & dispatch to the best agent
|
|
10
|
+
* → parallel([agent₁, agent₂]) — fan-out to N agents concurrently
|
|
11
|
+
* → verify(output) ✓ — trust-layer verification gate
|
|
12
|
+
*
|
|
13
|
+
* These can be used standalone or chained via `pipeline()`.
|
|
14
|
+
*/
|
|
15
|
+
class OrchestrationResource {
|
|
16
|
+
http;
|
|
17
|
+
constructor(http) {
|
|
18
|
+
this.http = http;
|
|
19
|
+
}
|
|
20
|
+
// ── route(intent) ──────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Classify the user's intent and route to the best-matching agent.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const routed = await nova.orchestrate.route({
|
|
26
|
+
* input: "Analyse customer churn",
|
|
27
|
+
* targets: [
|
|
28
|
+
* { agentId: "support-agent", intents: ["support", "help"] },
|
|
29
|
+
* { agentId: "data-agent", intents: ["analyse", "data", "metrics"] },
|
|
30
|
+
* ],
|
|
31
|
+
* });
|
|
32
|
+
* console.log(routed.selectedAgentId); // "data-agent"
|
|
33
|
+
* console.log(routed.result?.output);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async route(params) {
|
|
37
|
+
const { input, targets, context, dryRun } = params;
|
|
38
|
+
// Score each candidate
|
|
39
|
+
const scores = this.scoreTargets(input, targets);
|
|
40
|
+
const sorted = Object.entries(scores).sort((a, b) => b[1] - a[1]);
|
|
41
|
+
const [selectedAgentId, topScore] = sorted[0];
|
|
42
|
+
// Classify intent from input
|
|
43
|
+
const intent = this.classifyIntent(input);
|
|
44
|
+
const routeConfidence = Math.round(topScore * 100);
|
|
45
|
+
let result;
|
|
46
|
+
if (!dryRun) {
|
|
47
|
+
result = await this.http.post(`/agents/${selectedAgentId}/run`, { input, context, stream: false });
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
selectedAgentId,
|
|
51
|
+
intent,
|
|
52
|
+
routeConfidence,
|
|
53
|
+
scores: Object.fromEntries(Object.entries(scores).map(([k, v]) => [k, Math.round(v * 100)])),
|
|
54
|
+
result,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// ── parallel([agent₁, agent₂]) ────────────────────────────────
|
|
58
|
+
/**
|
|
59
|
+
* Execute multiple agents concurrently and merge their results.
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* const results = await nova.orchestrate.parallel({
|
|
63
|
+
* tasks: [
|
|
64
|
+
* { agentId: "support-agent", input: "Summarise ticket #1234" },
|
|
65
|
+
* { agentId: "crm-agent", input: "Get customer profile for ticket #1234" },
|
|
66
|
+
* ],
|
|
67
|
+
* merge: "all", // "all" | "best" | "first" | "custom"
|
|
68
|
+
* timeout: 30_000, // 30s max
|
|
69
|
+
* confidenceFloor: 50, // drop results below 50% confidence
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* for (const t of results.tasks) {
|
|
73
|
+
* console.log(`${t.agentId}: ${t.status} (${t.duration}ms)`);
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async parallel(params) {
|
|
78
|
+
const { tasks, merge = 'all', mergeFn, timeout = 0, confidenceFloor = 0, } = params;
|
|
79
|
+
const wallStart = Date.now();
|
|
80
|
+
// Fan-out: launch all tasks concurrently
|
|
81
|
+
const promises = tasks.map((task) => this.runTask(task, timeout));
|
|
82
|
+
const taskResults = await Promise.all(promises);
|
|
83
|
+
// Apply confidence floor
|
|
84
|
+
for (const tr of taskResults) {
|
|
85
|
+
if (tr.status === 'completed' &&
|
|
86
|
+
tr.result &&
|
|
87
|
+
tr.result.confidence < confidenceFloor) {
|
|
88
|
+
tr.status = 'skipped';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const completed = taskResults.filter((t) => t.status === 'completed');
|
|
92
|
+
const successCount = completed.length;
|
|
93
|
+
const failureCount = taskResults.length - successCount;
|
|
94
|
+
// Merge strategy
|
|
95
|
+
let merged = null;
|
|
96
|
+
switch (merge) {
|
|
97
|
+
case 'best':
|
|
98
|
+
merged =
|
|
99
|
+
completed.sort((a, b) => (b.result?.confidence ?? 0) - (a.result?.confidence ?? 0))[0] ?? null;
|
|
100
|
+
break;
|
|
101
|
+
case 'first':
|
|
102
|
+
merged = completed[0] ?? null;
|
|
103
|
+
break;
|
|
104
|
+
case 'custom':
|
|
105
|
+
if (mergeFn && completed.length > 0) {
|
|
106
|
+
merged = mergeFn(completed);
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case 'all':
|
|
110
|
+
default:
|
|
111
|
+
// For 'all', merged is the highest-confidence result; full list is in tasks[]
|
|
112
|
+
merged =
|
|
113
|
+
completed.sort((a, b) => (b.result?.confidence ?? 0) - (a.result?.confidence ?? 0))[0] ?? null;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
tasks: taskResults,
|
|
118
|
+
merged,
|
|
119
|
+
duration: Date.now() - wallStart,
|
|
120
|
+
successCount,
|
|
121
|
+
failureCount,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// ── verify(output) ✓ ──────────────────────────────────────────
|
|
125
|
+
/**
|
|
126
|
+
* Verify an agent's output through the Nova trust layer.
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* const v = await nova.orchestrate.verify({
|
|
130
|
+
* input: "Summarise Q4 revenue",
|
|
131
|
+
* output: agentResult.output,
|
|
132
|
+
* agentId: "data-agent",
|
|
133
|
+
* threshold: 80, // must score ≥ 80 to pass
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* if (v.passed) {
|
|
137
|
+
* console.log("Verified ✓", v.trust.overallScore);
|
|
138
|
+
* } else {
|
|
139
|
+
* console.log("Failed verification:", v.trust.concerns);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
async verify(params) {
|
|
144
|
+
const { input, output, agentId, threshold = 70, context } = params;
|
|
145
|
+
const evaluation = await this.http.post('/trust', { input, output, model: agentId ?? 'unknown', context });
|
|
146
|
+
const trust = evaluation.trust;
|
|
147
|
+
const passed = trust.overallScore >= threshold;
|
|
148
|
+
const concerns = trust.concerns.length > 0
|
|
149
|
+
? `Concerns: ${trust.concerns.join(', ')}`
|
|
150
|
+
: 'No concerns';
|
|
151
|
+
const summary = passed
|
|
152
|
+
? `Passed (${trust.overallScore}/100). ${concerns}`
|
|
153
|
+
: `Failed (${trust.overallScore}/100, threshold: ${threshold}). ${concerns}`;
|
|
154
|
+
return { passed, trust, output, summary };
|
|
155
|
+
}
|
|
156
|
+
// ── pipeline(route → parallel → verify) ───────────────────────
|
|
157
|
+
/**
|
|
158
|
+
* Execute a composable multi-step pipeline.
|
|
159
|
+
*
|
|
160
|
+
* ```ts
|
|
161
|
+
* const result = await nova.orchestrate.pipeline({
|
|
162
|
+
* input: "Analyse customer churn for Q4",
|
|
163
|
+
* steps: [
|
|
164
|
+
* { kind: "route", params: { input: "", targets: [...] } },
|
|
165
|
+
* { kind: "parallel", params: { tasks: [...] } },
|
|
166
|
+
* { kind: "verify", params: { input: "", output: "" } },
|
|
167
|
+
* ],
|
|
168
|
+
* });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
async pipeline(params) {
|
|
172
|
+
const pipeStart = Date.now();
|
|
173
|
+
let ctx = {
|
|
174
|
+
input: params.input,
|
|
175
|
+
output: undefined,
|
|
176
|
+
confidence: undefined,
|
|
177
|
+
agentsInvolved: [],
|
|
178
|
+
stepResults: [],
|
|
179
|
+
metadata: params.context ?? {},
|
|
180
|
+
};
|
|
181
|
+
for (const step of params.steps) {
|
|
182
|
+
switch (step.kind) {
|
|
183
|
+
case 'route': {
|
|
184
|
+
const routeParams = {
|
|
185
|
+
...step.params,
|
|
186
|
+
input: ctx.input,
|
|
187
|
+
};
|
|
188
|
+
const routeResult = await this.route(routeParams);
|
|
189
|
+
ctx.output = routeResult.result?.output ?? ctx.output;
|
|
190
|
+
ctx.confidence = routeResult.routeConfidence;
|
|
191
|
+
ctx.agentsInvolved.push(routeResult.selectedAgentId);
|
|
192
|
+
ctx.stepResults.push(routeResult);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 'parallel': {
|
|
196
|
+
const parallelParams = step.params;
|
|
197
|
+
// Inject current output as input for tasks that have empty input
|
|
198
|
+
const tasks = parallelParams.tasks.map((t) => ({
|
|
199
|
+
...t,
|
|
200
|
+
input: t.input || ctx.output || ctx.input,
|
|
201
|
+
}));
|
|
202
|
+
const parallelResult = await this.parallel({ ...parallelParams, tasks });
|
|
203
|
+
// Collect all involved agents
|
|
204
|
+
for (const t of parallelResult.tasks) {
|
|
205
|
+
if (!ctx.agentsInvolved.includes(t.agentId)) {
|
|
206
|
+
ctx.agentsInvolved.push(t.agentId);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Use merged result as output
|
|
210
|
+
if (parallelResult.merged?.result) {
|
|
211
|
+
ctx.output = parallelResult.merged.result.output;
|
|
212
|
+
ctx.confidence = parallelResult.merged.result.confidence;
|
|
213
|
+
}
|
|
214
|
+
ctx.stepResults.push(parallelResult);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case 'verify': {
|
|
218
|
+
const verifyParams = {
|
|
219
|
+
...step.params,
|
|
220
|
+
input: ctx.input,
|
|
221
|
+
output: ctx.output ?? '',
|
|
222
|
+
};
|
|
223
|
+
const verifyResult = await this.verify(verifyParams);
|
|
224
|
+
ctx.confidence = verifyResult.trust.overallScore;
|
|
225
|
+
ctx.stepResults.push(verifyResult);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'custom': {
|
|
229
|
+
if (step.handler) {
|
|
230
|
+
ctx = await step.handler(ctx);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const lastVerify = ctx.stepResults.find((r) => 'passed' in r);
|
|
237
|
+
return {
|
|
238
|
+
output: ctx.output ?? '',
|
|
239
|
+
confidence: ctx.confidence ?? 0,
|
|
240
|
+
verified: lastVerify?.passed ?? false,
|
|
241
|
+
agentsInvolved: ctx.agentsInvolved,
|
|
242
|
+
stepResults: ctx.stepResults,
|
|
243
|
+
duration: Date.now() - pipeStart,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
// ── Private helpers ───────────────────────────────────────────
|
|
247
|
+
/** Run a single agent task with optional timeout. */
|
|
248
|
+
async runTask(task, timeout) {
|
|
249
|
+
const start = Date.now();
|
|
250
|
+
const base = {
|
|
251
|
+
agentId: task.agentId,
|
|
252
|
+
label: task.label,
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
const runPromise = this.http.post(`/agents/${task.agentId}/run`, { input: task.input, context: task.context, stream: false });
|
|
256
|
+
let result;
|
|
257
|
+
if (timeout > 0) {
|
|
258
|
+
result = await Promise.race([
|
|
259
|
+
runPromise,
|
|
260
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeout)),
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
result = await runPromise;
|
|
265
|
+
}
|
|
266
|
+
return { ...base, result, status: 'completed', duration: Date.now() - start };
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
270
|
+
const status = message === 'timeout' ? 'timeout' : 'failed';
|
|
271
|
+
return { ...base, error: message, status, duration: Date.now() - start };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** Score targets against input using keyword / intent matching. */
|
|
275
|
+
scoreTargets(input, targets) {
|
|
276
|
+
const lower = input.toLowerCase();
|
|
277
|
+
const words = lower.split(/\s+/);
|
|
278
|
+
const scores = {};
|
|
279
|
+
for (const target of targets) {
|
|
280
|
+
let score = target.weight ?? 0.5;
|
|
281
|
+
if (target.intents && target.intents.length > 0) {
|
|
282
|
+
const matches = target.intents.filter((intent) => lower.includes(intent.toLowerCase()) ||
|
|
283
|
+
words.some((w) => w === intent.toLowerCase()));
|
|
284
|
+
score = matches.length / target.intents.length;
|
|
285
|
+
// Apply weight bias
|
|
286
|
+
if (target.weight !== undefined) {
|
|
287
|
+
score = score * 0.8 + target.weight * 0.2;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
scores[target.agentId] = Math.max(0, Math.min(1, score));
|
|
291
|
+
}
|
|
292
|
+
return scores;
|
|
293
|
+
}
|
|
294
|
+
/** Extract a simple intent label from input. */
|
|
295
|
+
classifyIntent(input) {
|
|
296
|
+
const lower = input.toLowerCase();
|
|
297
|
+
const intentMap = {
|
|
298
|
+
'analytics': ['analyse', 'analyze', 'metrics', 'data', 'report', 'dashboard', 'chart'],
|
|
299
|
+
'support': ['help', 'support', 'issue', 'ticket', 'problem', 'bug', 'fix'],
|
|
300
|
+
'sales': ['customer', 'crm', 'lead', 'deal', 'pipeline', 'revenue', 'sales'],
|
|
301
|
+
'risk': ['risk', 'compliance', 'audit', 'security', 'threat', 'fraud'],
|
|
302
|
+
'creative': ['write', 'create', 'draft', 'design', 'brainstorm', 'generate'],
|
|
303
|
+
'research': ['research', 'find', 'search', 'look up', 'investigate'],
|
|
304
|
+
};
|
|
305
|
+
let bestIntent = 'general';
|
|
306
|
+
let bestScore = 0;
|
|
307
|
+
for (const [intent, keywords] of Object.entries(intentMap)) {
|
|
308
|
+
const matches = keywords.filter((kw) => lower.includes(kw));
|
|
309
|
+
if (matches.length > bestScore) {
|
|
310
|
+
bestScore = matches.length;
|
|
311
|
+
bestIntent = intent;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return bestIntent;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
exports.OrchestrationResource = OrchestrationResource;
|
|
318
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":";;;AAoCA;;;;;;;;;;GAUG;AACH,MAAa,qBAAqB;IACf,IAAI,CAAa;IAElC,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,kEAAkE;IAElE;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,KAAK,CAAC,MAAmB;QAC7B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAEnD,uBAAuB;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG,MAA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AU,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC;YAC5E,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC;SACrE,CAAC;QAEF,IAAI,UAAU,GAAG,SAAS,CAAC;QAC3B,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5D,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;gBAC/B,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC3B,UAAU,GAAG,MAAM,CAAC;YACtB,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA9XD,sDA8XC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { AgentRunResult } from '../types/agents.js';
|
|
2
|
+
import type { TrustEvaluation } from '../types/trust.js';
|
|
3
|
+
export interface RouteTarget {
|
|
4
|
+
agentId: string;
|
|
5
|
+
/** Keywords / intents this agent handles. Used for local matching. */
|
|
6
|
+
intents?: string[];
|
|
7
|
+
/** Optional weight bias (0-1). Higher = preferred when scores tie. */
|
|
8
|
+
weight?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RouteParams {
|
|
11
|
+
/** The user input to classify. */
|
|
12
|
+
input: string;
|
|
13
|
+
/** Candidate agents to route to. */
|
|
14
|
+
targets: RouteTarget[];
|
|
15
|
+
/** Optional context forwarded to the selected agent. */
|
|
16
|
+
context?: Record<string, unknown>;
|
|
17
|
+
/** When true, returns the classification without executing the agent. */
|
|
18
|
+
dryRun?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface RouteResult {
|
|
21
|
+
/** The agent that was selected. */
|
|
22
|
+
selectedAgentId: string;
|
|
23
|
+
/** Intent label extracted from classification. */
|
|
24
|
+
intent: string;
|
|
25
|
+
/** Confidence in the routing decision (0-100). */
|
|
26
|
+
routeConfidence: number;
|
|
27
|
+
/** Scores for every candidate (agentId → score). */
|
|
28
|
+
scores: Record<string, number>;
|
|
29
|
+
/** The agent's output (undefined if dryRun). */
|
|
30
|
+
result?: AgentRunResult;
|
|
31
|
+
}
|
|
32
|
+
export interface ParallelTask {
|
|
33
|
+
agentId: string;
|
|
34
|
+
input: string;
|
|
35
|
+
context?: Record<string, unknown>;
|
|
36
|
+
/** Optional label to identify this task in results. */
|
|
37
|
+
label?: string;
|
|
38
|
+
}
|
|
39
|
+
export type ParallelMergeStrategy = 'all' | 'best' | 'first' | 'custom';
|
|
40
|
+
export interface ParallelParams {
|
|
41
|
+
/** Tasks to execute concurrently. */
|
|
42
|
+
tasks: ParallelTask[];
|
|
43
|
+
/** How to merge results. Default: 'all'. */
|
|
44
|
+
merge?: ParallelMergeStrategy;
|
|
45
|
+
/** Custom merge function (required when merge = 'custom'). */
|
|
46
|
+
mergeFn?: (results: ParallelTaskResult[]) => ParallelTaskResult;
|
|
47
|
+
/** Stop remaining tasks when the first one succeeds. Only for merge='first'. */
|
|
48
|
+
raceMode?: boolean;
|
|
49
|
+
/** Max time (ms) to wait for all tasks. 0 = no timeout. Default: 0. */
|
|
50
|
+
timeout?: number;
|
|
51
|
+
/** Minimum confidence required to include a result. Default: 0. */
|
|
52
|
+
confidenceFloor?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ParallelTaskResult {
|
|
55
|
+
agentId: string;
|
|
56
|
+
label?: string;
|
|
57
|
+
result?: AgentRunResult;
|
|
58
|
+
error?: string;
|
|
59
|
+
status: 'completed' | 'failed' | 'timeout' | 'skipped';
|
|
60
|
+
duration: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ParallelResult {
|
|
63
|
+
/** All individual task outcomes. */
|
|
64
|
+
tasks: ParallelTaskResult[];
|
|
65
|
+
/** The merged / winning result (depends on merge strategy). */
|
|
66
|
+
merged: ParallelTaskResult | null;
|
|
67
|
+
/** Total wall-clock time. */
|
|
68
|
+
duration: number;
|
|
69
|
+
/** Number of tasks that completed successfully. */
|
|
70
|
+
successCount: number;
|
|
71
|
+
/** Number of tasks that failed. */
|
|
72
|
+
failureCount: number;
|
|
73
|
+
}
|
|
74
|
+
export interface VerifyParams {
|
|
75
|
+
/** Original task / prompt that was given to the agent. */
|
|
76
|
+
input: string;
|
|
77
|
+
/** The agent's output to verify. */
|
|
78
|
+
output: string;
|
|
79
|
+
/** Agent that produced the output (for audit trail). */
|
|
80
|
+
agentId?: string;
|
|
81
|
+
/** Minimum overall trust score to pass (0-100). Default: 70. */
|
|
82
|
+
threshold?: number;
|
|
83
|
+
/** Additional context for the verifier. */
|
|
84
|
+
context?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export interface VerifyResult {
|
|
87
|
+
/** Whether the output passed verification. */
|
|
88
|
+
passed: boolean;
|
|
89
|
+
/** Full trust evaluation breakdown. */
|
|
90
|
+
trust: TrustEvaluation;
|
|
91
|
+
/** The original output (unchanged). */
|
|
92
|
+
output: string;
|
|
93
|
+
/** Human-readable summary of the verification. */
|
|
94
|
+
summary: string;
|
|
95
|
+
}
|
|
96
|
+
export type PipelineStepKind = 'route' | 'parallel' | 'verify' | 'custom';
|
|
97
|
+
export interface PipelineStep {
|
|
98
|
+
kind: PipelineStepKind;
|
|
99
|
+
/** Params for built-in steps. Ignored when kind='custom'. */
|
|
100
|
+
params?: RouteParams | ParallelParams | VerifyParams;
|
|
101
|
+
/** Custom async handler. Receives previous step output, returns next input. */
|
|
102
|
+
handler?: (input: PipelineContext) => Promise<PipelineContext>;
|
|
103
|
+
}
|
|
104
|
+
export interface PipelineContext {
|
|
105
|
+
input: string;
|
|
106
|
+
output?: string;
|
|
107
|
+
confidence?: number;
|
|
108
|
+
agentsInvolved: string[];
|
|
109
|
+
stepResults: Array<RouteResult | ParallelResult | VerifyResult>;
|
|
110
|
+
metadata: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
export interface PipelineParams {
|
|
113
|
+
/** Initial input to the pipeline. */
|
|
114
|
+
input: string;
|
|
115
|
+
/** Ordered list of steps to execute. */
|
|
116
|
+
steps: PipelineStep[];
|
|
117
|
+
/** Optional context shared across all steps. */
|
|
118
|
+
context?: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
export interface PipelineResult {
|
|
121
|
+
output: string;
|
|
122
|
+
confidence: number;
|
|
123
|
+
verified: boolean;
|
|
124
|
+
agentsInvolved: string[];
|
|
125
|
+
stepResults: Array<RouteResult | ParallelResult | VerifyResult>;
|
|
126
|
+
duration: number;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/orchestration/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,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AAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,cAAc,GAAG,YAAY,CAAC,CAAC;IAChE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,cAAc,GAAG,YAAY,CAAC,CAAC;IAChE,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestration/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novalabai/adk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "NovaLab Agent Development Kit — Build, test, and deploy Nova AI agents with smart model routing, trust layer, and confidence scoring",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "NovaLab Agent Development Kit — Build, test, and deploy Nova AI agents with multi-agent orchestration, smart model routing, trust layer, and confidence scoring",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -30,11 +30,16 @@
|
|
|
30
30
|
"agents",
|
|
31
31
|
"adk",
|
|
32
32
|
"orchestration",
|
|
33
|
+
"multi-agent",
|
|
34
|
+
"parallel",
|
|
33
35
|
"workflows",
|
|
34
36
|
"confidence",
|
|
35
37
|
"trust",
|
|
36
38
|
"ai-agents",
|
|
37
|
-
"agent-development-kit"
|
|
39
|
+
"agent-development-kit",
|
|
40
|
+
"pipeline",
|
|
41
|
+
"routing",
|
|
42
|
+
"intent-classification"
|
|
38
43
|
],
|
|
39
44
|
"author": "NovaLab",
|
|
40
45
|
"license": "MIT",
|