@ariaflowagents/core 0.8.1 → 0.9.1
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/capabilities/AutoRetrieveCapability.d.ts +30 -0
- package/dist/capabilities/AutoRetrieveCapability.d.ts.map +1 -0
- package/dist/capabilities/AutoRetrieveCapability.js +36 -0
- package/dist/capabilities/AutoRetrieveCapability.js.map +1 -0
- package/dist/capabilities/ExtractionCapability.d.ts +25 -0
- package/dist/capabilities/ExtractionCapability.d.ts.map +1 -0
- package/dist/capabilities/ExtractionCapability.js +74 -0
- package/dist/capabilities/ExtractionCapability.js.map +1 -0
- package/dist/capabilities/FlowCapability.d.ts +81 -0
- package/dist/capabilities/FlowCapability.d.ts.map +1 -0
- package/dist/capabilities/FlowCapability.js +482 -0
- package/dist/capabilities/FlowCapability.js.map +1 -0
- package/dist/capabilities/GuardrailCapability.d.ts +30 -0
- package/dist/capabilities/GuardrailCapability.d.ts.map +1 -0
- package/dist/capabilities/GuardrailCapability.js +38 -0
- package/dist/capabilities/GuardrailCapability.js.map +1 -0
- package/dist/capabilities/HandoffCapability.d.ts +19 -0
- package/dist/capabilities/HandoffCapability.d.ts.map +1 -0
- package/dist/capabilities/HandoffCapability.js +58 -0
- package/dist/capabilities/HandoffCapability.js.map +1 -0
- package/dist/capabilities/LivePromptAssembler.d.ts +108 -0
- package/dist/capabilities/LivePromptAssembler.d.ts.map +1 -0
- package/dist/capabilities/LivePromptAssembler.js +157 -0
- package/dist/capabilities/LivePromptAssembler.js.map +1 -0
- package/dist/capabilities/TriageCapability.d.ts +16 -0
- package/dist/capabilities/TriageCapability.d.ts.map +1 -0
- package/dist/capabilities/TriageCapability.js +61 -0
- package/dist/capabilities/TriageCapability.js.map +1 -0
- package/dist/capabilities/adapters/ai-sdk.d.ts +14 -0
- package/dist/capabilities/adapters/ai-sdk.d.ts.map +1 -0
- package/dist/capabilities/adapters/ai-sdk.js +29 -0
- package/dist/capabilities/adapters/ai-sdk.js.map +1 -0
- package/dist/capabilities/adapters/gemini.d.ts +15 -0
- package/dist/capabilities/adapters/gemini.d.ts.map +1 -0
- package/dist/capabilities/adapters/gemini.js +40 -0
- package/dist/capabilities/adapters/gemini.js.map +1 -0
- package/dist/capabilities/index.d.ts +154 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +128 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/eval/EvalRunner.d.ts +12 -0
- package/dist/eval/EvalRunner.d.ts.map +1 -0
- package/dist/eval/EvalRunner.js +64 -0
- package/dist/eval/EvalRunner.js.map +1 -0
- package/dist/eval/scoring.d.ts +15 -0
- package/dist/eval/scoring.d.ts.map +1 -0
- package/dist/eval/scoring.js +152 -0
- package/dist/eval/scoring.js.map +1 -0
- package/dist/eval/types.d.ts +59 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/flows/FlowGraph.d.ts +3 -1
- package/dist/flows/FlowGraph.d.ts.map +1 -1
- package/dist/flows/FlowGraph.js +5 -0
- package/dist/flows/FlowGraph.js.map +1 -1
- package/dist/flows/FlowManager.d.ts +60 -1
- package/dist/flows/FlowManager.d.ts.map +1 -1
- package/dist/flows/FlowManager.js +467 -34
- package/dist/flows/FlowManager.js.map +1 -1
- package/dist/flows/extraction.d.ts +16 -1
- package/dist/flows/extraction.d.ts.map +1 -1
- package/dist/flows/extraction.js +34 -0
- package/dist/flows/extraction.js.map +1 -1
- package/dist/flows/index.d.ts +2 -0
- package/dist/flows/index.d.ts.map +1 -1
- package/dist/flows/index.js +1 -0
- package/dist/flows/index.js.map +1 -1
- package/dist/flows/validation.d.ts +1 -1
- package/dist/flows/validation.d.ts.map +1 -1
- package/dist/flows/validation.js +13 -1
- package/dist/flows/validation.js.map +1 -1
- package/dist/hooks/HookRunner.d.ts +3 -1
- package/dist/hooks/HookRunner.d.ts.map +1 -1
- package/dist/hooks/HookRunner.js +3 -0
- package/dist/hooks/HookRunner.js.map +1 -1
- package/dist/hooks/builtin/metrics.d.ts.map +1 -1
- package/dist/hooks/builtin/metrics.js +12 -0
- package/dist/hooks/builtin/metrics.js.map +1 -1
- package/dist/hooks/builtin/observability.d.ts +21 -0
- package/dist/hooks/builtin/observability.d.ts.map +1 -0
- package/dist/hooks/builtin/observability.js +535 -0
- package/dist/hooks/builtin/observability.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestration/DefaultOrchestrationAuthority.d.ts +91 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.d.ts.map +1 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.js +786 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.js.map +1 -0
- package/dist/orchestration/OrchestrationAuthority.d.ts +119 -0
- package/dist/orchestration/OrchestrationAuthority.d.ts.map +1 -0
- package/dist/orchestration/OrchestrationAuthority.js +2 -0
- package/dist/orchestration/OrchestrationAuthority.js.map +1 -0
- package/dist/orchestration/RealtimeExtractionRunner.d.ts +25 -0
- package/dist/orchestration/RealtimeExtractionRunner.d.ts.map +1 -0
- package/dist/orchestration/RealtimeExtractionRunner.js +62 -0
- package/dist/orchestration/RealtimeExtractionRunner.js.map +1 -0
- package/dist/orchestration/index.d.ts +5 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +4 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/types.d.ts +134 -0
- package/dist/orchestration/types.d.ts.map +1 -0
- package/dist/orchestration/types.js +2 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/realtime/RealtimeAudioClient.d.ts +105 -0
- package/dist/realtime/RealtimeAudioClient.d.ts.map +1 -0
- package/dist/realtime/RealtimeAudioClient.js +15 -0
- package/dist/realtime/RealtimeAudioClient.js.map +1 -0
- package/dist/realtime/RealtimeRuntime.d.ts +136 -0
- package/dist/realtime/RealtimeRuntime.d.ts.map +1 -0
- package/dist/realtime/RealtimeRuntime.js +270 -0
- package/dist/realtime/RealtimeRuntime.js.map +1 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +2 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/runtime/ExtractionEngine.d.ts +2 -1
- package/dist/runtime/ExtractionEngine.d.ts.map +1 -1
- package/dist/runtime/ExtractionEngine.js +11 -0
- package/dist/runtime/ExtractionEngine.js.map +1 -1
- package/dist/runtime/FlowExecutor.d.ts +7 -5
- package/dist/runtime/FlowExecutor.d.ts.map +1 -1
- package/dist/runtime/FlowExecutor.js +71 -12
- package/dist/runtime/FlowExecutor.js.map +1 -1
- package/dist/runtime/Runtime.d.ts +22 -0
- package/dist/runtime/Runtime.d.ts.map +1 -1
- package/dist/runtime/Runtime.js +47 -0
- package/dist/runtime/Runtime.js.map +1 -1
- package/dist/runtime/pipeline/AgentExecuteStage.d.ts.map +1 -1
- package/dist/runtime/pipeline/AgentExecuteStage.js +94 -25
- package/dist/runtime/pipeline/AgentExecuteStage.js.map +1 -1
- package/dist/runtime/pipeline/ContextAssembleStage.js +1 -1
- package/dist/types/index.d.ts +61 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/telemetry.d.ts +107 -0
- package/dist/types/telemetry.d.ts.map +1 -1
- package/package.json +15 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Simplified retrieval interface for the capability layer.
|
|
4
|
+
* Decoupled from AutoRetrieveProvider's RunContext requirement — the
|
|
5
|
+
* capability system is backend-agnostic and has no RunContext at tool time.
|
|
6
|
+
*/
|
|
7
|
+
export interface RetrieveProvider {
|
|
8
|
+
run: (opts: {
|
|
9
|
+
input: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
text: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AutoRetrieveCapabilityConfig {
|
|
16
|
+
provider: RetrieveProvider;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts auto-retrieve from a pipeline stage to an on-demand
|
|
20
|
+
* `search_knowledge_base` tool. The LLM decides when to call it;
|
|
21
|
+
* the result flows back as a tool result for the LLM to use.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AutoRetrieveCapability implements Capability {
|
|
24
|
+
private provider;
|
|
25
|
+
constructor(config: AutoRetrieveCapabilityConfig);
|
|
26
|
+
getTools(): ToolDeclaration[];
|
|
27
|
+
getPromptSections(): PromptSection[];
|
|
28
|
+
processToolResult(_toolName: string, _args: unknown, _result: unknown): CapabilityAction | null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=AutoRetrieveCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoRetrieveCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/AutoRetrieveCapability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI/F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAID;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,UAAU;IACvD,OAAO,CAAC,QAAQ,CAAmB;gBAEvB,MAAM,EAAE,4BAA4B;IAIhD,QAAQ,IAAI,eAAe,EAAE;IAkB7B,iBAAiB,IAAI,aAAa,EAAE;IAIpC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;CAGhG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ─── AutoRetrieveCapability ──────────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Converts auto-retrieve from a pipeline stage to an on-demand
|
|
5
|
+
* `search_knowledge_base` tool. The LLM decides when to call it;
|
|
6
|
+
* the result flows back as a tool result for the LLM to use.
|
|
7
|
+
*/
|
|
8
|
+
export class AutoRetrieveCapability {
|
|
9
|
+
provider;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.provider = config.provider;
|
|
12
|
+
}
|
|
13
|
+
getTools() {
|
|
14
|
+
const label = this.provider.label ?? 'knowledge base';
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'search_knowledge_base',
|
|
18
|
+
description: `Search the ${label} for relevant information to answer the user's question.`,
|
|
19
|
+
parameters: z.object({
|
|
20
|
+
query: z.string().describe('The search query'),
|
|
21
|
+
}),
|
|
22
|
+
execute: async (args) => {
|
|
23
|
+
const result = await this.provider.run({ input: args.query });
|
|
24
|
+
return result ?? { text: 'No relevant information found.' };
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
getPromptSections() {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
processToolResult(_toolName, _args, _result) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=AutoRetrieveCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoRetrieveCapability.js","sourceRoot":"","sources":["../../src/capabilities/AutoRetrieveCapability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IACzB,QAAQ,CAAmB;IAEnC,YAAY,MAAoC;QAC9C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,gBAAgB,CAAC;QAEtD,OAAO;YACL;gBACE,IAAI,EAAE,uBAAuB;gBAC7B,WAAW,EAAE,cAAc,KAAK,0DAA0D;gBAC1F,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;oBACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;iBAC/C,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,IAAuB,EAAE,EAAE;oBACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;oBAC9D,OAAO,MAAM,IAAI,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC;gBAC9D,CAAC;aACF;SACF,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iBAAiB,CAAC,SAAiB,EAAE,KAAc,EAAE,OAAgB;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ZodTypeAny } from 'zod';
|
|
2
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
3
|
+
export interface ExtractionCapabilityConfig {
|
|
4
|
+
schema: ZodTypeAny;
|
|
5
|
+
/** Fields that must be present to consider extraction complete. */
|
|
6
|
+
requiredFields?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Agent-level extraction: collects structured data across turns using a
|
|
10
|
+
* single `submit_extracted_data` tool. Distinct from FlowCapability's
|
|
11
|
+
* per-node extraction — this is for standalone agents, not flow nodes.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ExtractionCapability implements Capability {
|
|
14
|
+
private schema;
|
|
15
|
+
private requiredFields;
|
|
16
|
+
private collectedData;
|
|
17
|
+
constructor(config: ExtractionCapabilityConfig);
|
|
18
|
+
getTools(): ToolDeclaration[];
|
|
19
|
+
getPromptSections(): PromptSection[];
|
|
20
|
+
processToolResult(toolName: string, args: unknown, result: unknown): CapabilityAction | null;
|
|
21
|
+
/** Read the data collected so far. */
|
|
22
|
+
get data(): Record<string, unknown>;
|
|
23
|
+
private getMissingFields;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ExtractionCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractionCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/ExtractionCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK/F,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,UAAU,CAAC;IACnB,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAID;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,UAAU;IACrD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,aAAa,CAA+B;gBAExC,MAAM,EAAE,0BAA0B;IAK9C,QAAQ,IAAI,eAAe,EAAE;IAqB7B,iBAAiB,IAAI,aAAa,EAAE;IAYpC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;IAe5F,sCAAsC;IACtC,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElC;IAID,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { mergeExtractionData, computeMissingFields, toExtractionSubmissionSchema } from '../flows/extraction.js';
|
|
2
|
+
// ─── ExtractionCapability ────────────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Agent-level extraction: collects structured data across turns using a
|
|
5
|
+
* single `submit_extracted_data` tool. Distinct from FlowCapability's
|
|
6
|
+
* per-node extraction — this is for standalone agents, not flow nodes.
|
|
7
|
+
*/
|
|
8
|
+
export class ExtractionCapability {
|
|
9
|
+
schema;
|
|
10
|
+
requiredFields;
|
|
11
|
+
collectedData = {};
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.schema = config.schema;
|
|
14
|
+
this.requiredFields = config.requiredFields ?? [];
|
|
15
|
+
}
|
|
16
|
+
getTools() {
|
|
17
|
+
const missing = this.getMissingFields();
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
name: 'submit_extracted_data',
|
|
21
|
+
description: [
|
|
22
|
+
'Submit information extracted from the conversation.',
|
|
23
|
+
missing.length > 0
|
|
24
|
+
? `Still needed: ${missing.join(', ')}.`
|
|
25
|
+
: 'All required fields collected.',
|
|
26
|
+
'Only submit values explicitly provided by the user.',
|
|
27
|
+
'Omit fields or use null when the value is still unknown.',
|
|
28
|
+
'Call this tool every time you learn new field values.',
|
|
29
|
+
].join(' '),
|
|
30
|
+
parameters: toExtractionSubmissionSchema(this.schema),
|
|
31
|
+
execute: async (args) => args,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
getPromptSections() {
|
|
36
|
+
const missing = this.getMissingFields();
|
|
37
|
+
if (missing.length === 0)
|
|
38
|
+
return [];
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
role: 'extraction',
|
|
42
|
+
content: `You still need to collect: ${missing.join(', ')}. Ask for these naturally.`,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
processToolResult(toolName, args, result) {
|
|
47
|
+
if (toolName !== 'submit_extracted_data')
|
|
48
|
+
return null;
|
|
49
|
+
this.collectedData = mergeExtractionData(this.collectedData, args);
|
|
50
|
+
const missing = this.getMissingFields();
|
|
51
|
+
if (missing.length === 0) {
|
|
52
|
+
return { type: 'extraction-complete', data: this.collectedData };
|
|
53
|
+
}
|
|
54
|
+
return { type: 'continue' };
|
|
55
|
+
}
|
|
56
|
+
/** Read the data collected so far. */
|
|
57
|
+
get data() {
|
|
58
|
+
return this.collectedData;
|
|
59
|
+
}
|
|
60
|
+
// ─── Private ───────────────────────────────────────────────────────────────
|
|
61
|
+
getMissingFields() {
|
|
62
|
+
if (this.requiredFields.length > 0) {
|
|
63
|
+
return computeMissingFields(this.collectedData, this.requiredFields);
|
|
64
|
+
}
|
|
65
|
+
// Fall back to Zod schema parse to infer missing fields
|
|
66
|
+
const parsed = this.schema.safeParse(this.collectedData);
|
|
67
|
+
if (parsed.success)
|
|
68
|
+
return [];
|
|
69
|
+
return [...new Set((parsed.error.issues ?? [])
|
|
70
|
+
.map((issue) => issue.path.join('.'))
|
|
71
|
+
.filter(Boolean))];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ExtractionCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractionCapability.js","sourceRoot":"","sources":["../../src/capabilities/ExtractionCapability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAUjH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAa;IACnB,cAAc,CAAW;IACzB,aAAa,GAA4B,EAAE,CAAC;IAEpD,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C,EAAE,CAAC;YACzB,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC9B,CAAC;IAED,sCAAsC;IACtC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,8EAA8E;IAEtE,gBAAgB;QACtB,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,oBAAoB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACvE,CAAC;QACD,wDAAwD;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,IAAI,GAAG,CAChB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;iBACxB,GAAG,CAAC,CAAC,KAAoC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACnE,MAAM,CAAC,OAAO,CAAC,CACnB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
2
|
+
import type { FlowConfig, FlowContext, ExtractionNodeConfig } from '../types/index.js';
|
|
3
|
+
export interface FlowCapabilityConfig {
|
|
4
|
+
flow: FlowConfig;
|
|
5
|
+
initialNode: string;
|
|
6
|
+
state?: FlowCapabilityState;
|
|
7
|
+
defaultRolePrompt?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FlowCapabilityState {
|
|
10
|
+
context: FlowContext;
|
|
11
|
+
initialized: boolean;
|
|
12
|
+
flowEnded: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Headless flow state machine that exposes flow behavior as tools.
|
|
16
|
+
*
|
|
17
|
+
* Owns: node graph, transitions, current node, collectedData,
|
|
18
|
+
* oscillation tracking, extraction node handling, contract validation.
|
|
19
|
+
*
|
|
20
|
+
* Does NOT own: LLM calls, streaming, AI SDK imports. The host
|
|
21
|
+
* (Gemini Live, AI SDK, LiveKit) handles inference.
|
|
22
|
+
*/
|
|
23
|
+
export declare class FlowCapability implements Capability {
|
|
24
|
+
private nodes;
|
|
25
|
+
private transitions;
|
|
26
|
+
private context;
|
|
27
|
+
private currentNodeConfig;
|
|
28
|
+
private initialized;
|
|
29
|
+
private flowEnded;
|
|
30
|
+
private _justTransitioned;
|
|
31
|
+
private maxOscillations;
|
|
32
|
+
private defaultRolePrompt?;
|
|
33
|
+
/** Tracks transition edges within a single process() call for oscillation detection. */
|
|
34
|
+
private turnTransitionCounts;
|
|
35
|
+
/** Events emitted during transitions (node-enter, node-exit, flow-transition, etc.). */
|
|
36
|
+
private pendingEvents;
|
|
37
|
+
constructor(config: FlowCapabilityConfig);
|
|
38
|
+
getTools(): ToolDeclaration[];
|
|
39
|
+
getPromptSections(): PromptSection[];
|
|
40
|
+
processToolResult(toolName: string, args: unknown, result: unknown): CapabilityAction | null;
|
|
41
|
+
/** Initialize the flow (transition to initial node). */
|
|
42
|
+
initialize(): FlowEvent[];
|
|
43
|
+
/** Call at the start of each user turn to reset oscillation tracking. */
|
|
44
|
+
resetTurnTracking(): void;
|
|
45
|
+
/** Record a user message in the flow context. */
|
|
46
|
+
appendUserMessage(content: string): void;
|
|
47
|
+
/** Record an assistant message in the flow context. */
|
|
48
|
+
appendAssistantMessage(content: string): void;
|
|
49
|
+
get currentNode(): string | undefined;
|
|
50
|
+
currentNodeIsExtractionNode(): boolean;
|
|
51
|
+
currentExtractionNode(): ExtractionNodeConfig | null;
|
|
52
|
+
get collectedData(): Record<string, unknown>;
|
|
53
|
+
updateCollectedData(verified: Record<string, unknown>): boolean;
|
|
54
|
+
get hasEnded(): boolean;
|
|
55
|
+
get isInitialized(): boolean;
|
|
56
|
+
getState(): FlowCapabilityState;
|
|
57
|
+
/** Drain accumulated flow events (node-enter, node-exit, etc.). */
|
|
58
|
+
drainEvents(): FlowEvent[];
|
|
59
|
+
private executeTransition;
|
|
60
|
+
private mergeExtractedData;
|
|
61
|
+
private checkExtractionComplete;
|
|
62
|
+
private getMissingExtractionFields;
|
|
63
|
+
private applyContextStrategy;
|
|
64
|
+
private getRelevantCollectedData;
|
|
65
|
+
private buildExtractionContinueEnvelope;
|
|
66
|
+
}
|
|
67
|
+
export type FlowEvent = {
|
|
68
|
+
type: 'node-enter';
|
|
69
|
+
nodeName: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'node-exit';
|
|
72
|
+
nodeName: string;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'flow-transition';
|
|
75
|
+
from: string;
|
|
76
|
+
to: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'flow-end';
|
|
79
|
+
reason: string;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=FlowCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/FlowCapability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAGX,oBAAoB,EAGrB,MAAM,mBAAmB,CAAC;AAW3B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAA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