@mcp-abap-adt/llm-agent-libs 12.0.4 → 12.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/builder.d.ts +27 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +67 -1
- package/dist/builder.js.map +1 -1
- package/dist/coordinator/activation/auto.d.ts +13 -0
- package/dist/coordinator/activation/auto.d.ts.map +1 -0
- package/dist/coordinator/activation/auto.js +11 -0
- package/dist/coordinator/activation/auto.js.map +1 -0
- package/dist/coordinator/activation/explicit.d.ts +14 -0
- package/dist/coordinator/activation/explicit.d.ts.map +1 -0
- package/dist/coordinator/activation/explicit.js +12 -0
- package/dist/coordinator/activation/explicit.js.map +1 -0
- package/dist/coordinator/dispatch/hybrid.d.ts +13 -0
- package/dist/coordinator/dispatch/hybrid.d.ts.map +1 -0
- package/dist/coordinator/dispatch/hybrid.js +20 -0
- package/dist/coordinator/dispatch/hybrid.js.map +1 -0
- package/dist/coordinator/dispatch/self.d.ts +13 -0
- package/dist/coordinator/dispatch/self.d.ts.map +1 -0
- package/dist/coordinator/dispatch/self.js +48 -0
- package/dist/coordinator/dispatch/self.js.map +1 -0
- package/dist/coordinator/dispatch/subagent.d.ts +11 -0
- package/dist/coordinator/dispatch/subagent.d.ts.map +1 -0
- package/dist/coordinator/dispatch/subagent.js +66 -0
- package/dist/coordinator/dispatch/subagent.js.map +1 -0
- package/dist/coordinator/index.d.ts +9 -0
- package/dist/coordinator/index.d.ts.map +1 -0
- package/dist/coordinator/index.js +9 -0
- package/dist/coordinator/index.js.map +1 -0
- package/dist/coordinator/planning/one-shot.d.ts +14 -0
- package/dist/coordinator/planning/one-shot.d.ts.map +1 -0
- package/dist/coordinator/planning/one-shot.js +64 -0
- package/dist/coordinator/planning/one-shot.js.map +1 -0
- package/dist/coordinator/planning/replan-on-error.d.ts +15 -0
- package/dist/coordinator/planning/replan-on-error.d.ts.map +1 -0
- package/dist/coordinator/planning/replan-on-error.js +75 -0
- package/dist/coordinator/planning/replan-on-error.js.map +1 -0
- package/dist/coordinator/planning/skill-steps.d.ts +25 -0
- package/dist/coordinator/planning/skill-steps.d.ts.map +1 -0
- package/dist/coordinator/planning/skill-steps.js +54 -0
- package/dist/coordinator/planning/skill-steps.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/context.d.ts +18 -1
- package/dist/pipeline/context.d.ts.map +1 -1
- package/dist/pipeline/default-pipeline.d.ts +21 -1
- package/dist/pipeline/default-pipeline.d.ts.map +1 -1
- package/dist/pipeline/default-pipeline.js +54 -16
- package/dist/pipeline/default-pipeline.js.map +1 -1
- package/dist/pipeline/handlers/coordinator-activate.d.ts +24 -0
- package/dist/pipeline/handlers/coordinator-activate.d.ts.map +1 -0
- package/dist/pipeline/handlers/coordinator-activate.js +37 -0
- package/dist/pipeline/handlers/coordinator-activate.js.map +1 -0
- package/dist/pipeline/handlers/coordinator.d.ts +38 -0
- package/dist/pipeline/handlers/coordinator.d.ts.map +1 -0
- package/dist/pipeline/handlers/coordinator.js +184 -0
- package/dist/pipeline/handlers/coordinator.js.map +1 -0
- package/dist/pipeline/handlers/index.d.ts +13 -1
- package/dist/pipeline/handlers/index.d.ts.map +1 -1
- package/dist/pipeline/handlers/index.js +15 -9
- package/dist/pipeline/handlers/index.js.map +1 -1
- package/dist/pipeline/handlers/subagent.d.ts +21 -0
- package/dist/pipeline/handlers/subagent.d.ts.map +1 -0
- package/dist/pipeline/handlers/subagent.js +58 -0
- package/dist/pipeline/handlers/subagent.js.map +1 -0
- package/dist/subagent/smart-agent-subagent.d.ts +12 -0
- package/dist/subagent/smart-agent-subagent.d.ts.map +1 -0
- package/dist/subagent/smart-agent-subagent.js +38 -0
- package/dist/subagent/smart-agent-subagent.js.map +1 -0
- package/dist/util/template.d.ts +8 -0
- package/dist/util/template.d.ts.map +1 -0
- package/dist/util/template.js +36 -0
- package/dist/util/template.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator-activate.d.ts","sourceRoot":"","sources":["../../../src/pipeline/handlers/coordinator-activate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,0BAA2B,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,mBAAmB;IAEtD,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,OAAO,CAAC;CAkBpB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoordinatorActivateHandler — runtime activation decision for the
|
|
3
|
+
* coordinator stage.
|
|
4
|
+
*
|
|
5
|
+
* Built-time stage selection cannot see runtime ctx (selectedSkills are
|
|
6
|
+
* populated only after `skill-select` runs). This handler evaluates the
|
|
7
|
+
* configured `IActivationStrategy` against REAL ctx state and writes
|
|
8
|
+
* `ctx.coordinatorActive`. Coordinator and tool-loop stages gate on this
|
|
9
|
+
* flag via `when:` predicates so the activation decision honours runtime
|
|
10
|
+
* skill selection.
|
|
11
|
+
*
|
|
12
|
+
* Reads: `ctx.subAgents`, `ctx.selectedSkills`.
|
|
13
|
+
* Writes: `ctx.coordinatorActive`.
|
|
14
|
+
*/
|
|
15
|
+
export class CoordinatorActivateHandler {
|
|
16
|
+
activation;
|
|
17
|
+
constructor(activation) {
|
|
18
|
+
this.activation = activation;
|
|
19
|
+
}
|
|
20
|
+
async execute(ctx, _rawConfig, _span) {
|
|
21
|
+
const hasSubAgents = (ctx.subAgents?.size ?? 0) > 0;
|
|
22
|
+
const hasStructuredSkill = ctx.selectedSkills.some((s) => (s.meta?.steps?.length ?? 0) > 0);
|
|
23
|
+
const active = this.activation.shouldActivate({
|
|
24
|
+
hasSubAgents,
|
|
25
|
+
hasStructuredSkill,
|
|
26
|
+
});
|
|
27
|
+
ctx.coordinatorActive = active;
|
|
28
|
+
ctx.options?.sessionLogger?.logStep('coordinator_activate', {
|
|
29
|
+
strategy: this.activation.name,
|
|
30
|
+
active,
|
|
31
|
+
hasSubAgents,
|
|
32
|
+
hasStructuredSkill,
|
|
33
|
+
});
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=coordinator-activate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator-activate.js","sourceRoot":"","sources":["../../../src/pipeline/handlers/coordinator-activate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,MAAM,OAAO,0BAA0B;IACR;IAA7B,YAA6B,UAA+B;QAA/B,eAAU,GAAV,UAAU,CAAqB;IAAG,CAAC;IAEhE,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,UAAmC,EACnC,KAAY;QAEZ,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,kBAAkB,GAAG,GAAG,CAAC,cAAc,CAAC,IAAI,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CACxC,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;YAC5C,YAAY;YACZ,kBAAkB;SACnB,CAAC,CAAC;QACH,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC;QAC/B,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,sBAAsB,EAAE;YAC1D,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;YAC9B,MAAM;YACN,YAAY;YACZ,kBAAkB;SACnB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoordinatorHandler — plan-execute-replan loop driving autonomous
|
|
3
|
+
* multi-step orchestration over the SubAgent registry.
|
|
4
|
+
*
|
|
5
|
+
* Reads: `ctx.subAgents`, `ctx.inputText`, `ctx.selectedSkills`,
|
|
6
|
+
* `ctx.skillContent`, `ctx.assembledMessages` (for system prompt).
|
|
7
|
+
* Writes: `ctx.plan`, `ctx.currentStepIdx`, `ctx.stepResults`, and emits the
|
|
8
|
+
* final concatenated output via `ctx.yield()` as the assistant
|
|
9
|
+
* response (followed by a `stop` chunk), since the pipeline streams
|
|
10
|
+
* results to consumers rather than buffering a final string field.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: Coordinator replaces the tool-loop stage when activated. The
|
|
13
|
+
* `ctx.yield`-based streaming contract is preserved so downstream SSE
|
|
14
|
+
* consumers see the response as a normal stream.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDispatchStrategy, IPlanningStrategy } from '@mcp-abap-adt/llm-agent';
|
|
17
|
+
import type { ISpan } from '../../tracer/types.js';
|
|
18
|
+
import type { PipelineContext } from '../context.js';
|
|
19
|
+
import type { IStageHandler } from '../stage-handler.js';
|
|
20
|
+
export interface CoordinatorHandlerDeps {
|
|
21
|
+
planning: IPlanningStrategy;
|
|
22
|
+
dispatch: IDispatchStrategy;
|
|
23
|
+
maxSteps: number;
|
|
24
|
+
maxRetriesPerStep: number;
|
|
25
|
+
failPolicy: 'abort' | 'continue';
|
|
26
|
+
}
|
|
27
|
+
export declare class CoordinatorHandler implements IStageHandler {
|
|
28
|
+
private readonly deps;
|
|
29
|
+
constructor(deps: CoordinatorHandlerDeps);
|
|
30
|
+
execute(ctx: PipelineContext, _rawConfig: Record<string, unknown>, _span: ISpan): Promise<boolean>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Helper used by DefaultPipeline / activation strategies to detect whether
|
|
34
|
+
* the active skill carries a structured `steps` block — a strong signal for
|
|
35
|
+
* Coordinator activation.
|
|
36
|
+
*/
|
|
37
|
+
export declare function activeSkillHasSteps(ctx: PipelineContext): boolean;
|
|
38
|
+
//# sourceMappingURL=coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/pipeline/handlers/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,EAIlB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC;CAClC;AAED,qBAAa,kBAAmB,YAAW,aAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,sBAAsB;IAEnD,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,OAAO,CAAC;CAkJpB;AAkCD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAEjE"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoordinatorHandler — plan-execute-replan loop driving autonomous
|
|
3
|
+
* multi-step orchestration over the SubAgent registry.
|
|
4
|
+
*
|
|
5
|
+
* Reads: `ctx.subAgents`, `ctx.inputText`, `ctx.selectedSkills`,
|
|
6
|
+
* `ctx.skillContent`, `ctx.assembledMessages` (for system prompt).
|
|
7
|
+
* Writes: `ctx.plan`, `ctx.currentStepIdx`, `ctx.stepResults`, and emits the
|
|
8
|
+
* final concatenated output via `ctx.yield()` as the assistant
|
|
9
|
+
* response (followed by a `stop` chunk), since the pipeline streams
|
|
10
|
+
* results to consumers rather than buffering a final string field.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: Coordinator replaces the tool-loop stage when activated. The
|
|
13
|
+
* `ctx.yield`-based streaming contract is preserved so downstream SSE
|
|
14
|
+
* consumers see the response as a normal stream.
|
|
15
|
+
*/
|
|
16
|
+
import { OrchestratorError } from '../../agent.js';
|
|
17
|
+
export class CoordinatorHandler {
|
|
18
|
+
deps;
|
|
19
|
+
constructor(deps) {
|
|
20
|
+
this.deps = deps;
|
|
21
|
+
}
|
|
22
|
+
async execute(ctx, _rawConfig, _span) {
|
|
23
|
+
// Normalise registry to an empty Map when no subagents are registered.
|
|
24
|
+
// SelfDispatch and other registry-free strategies must still run; the
|
|
25
|
+
// SubAgentDispatch strategy itself reports a clean StepResult when an
|
|
26
|
+
// unknown agent is requested, so we don't need a global gate here.
|
|
27
|
+
const registry = ctx.subAgents ?? new Map();
|
|
28
|
+
const coordCtx = {
|
|
29
|
+
inputText: ctx.inputText,
|
|
30
|
+
systemPrompt: collectSystemPrompt(ctx),
|
|
31
|
+
skillContent: collectSkillContent(ctx),
|
|
32
|
+
activeSkillMeta: collectActiveSkillMeta(ctx),
|
|
33
|
+
registry,
|
|
34
|
+
stepResults: {},
|
|
35
|
+
signal: ctx.options?.signal,
|
|
36
|
+
sessionId: ctx.sessionId,
|
|
37
|
+
};
|
|
38
|
+
let plan;
|
|
39
|
+
try {
|
|
40
|
+
plan = await this.deps.planning.buildInitialPlan(coordCtx);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
ctx.error = wrapError(err, 'COORDINATOR_PLAN_FAILED');
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
coordCtx.plan = plan;
|
|
47
|
+
ctx.plan = plan;
|
|
48
|
+
ctx.stepResults = coordCtx.stepResults;
|
|
49
|
+
ctx.options?.sessionLogger?.logStep('coordinator_plan', {
|
|
50
|
+
stepCount: plan.steps.length,
|
|
51
|
+
source: plan.source,
|
|
52
|
+
rationale: plan.rationale,
|
|
53
|
+
});
|
|
54
|
+
let totalSteps = 0;
|
|
55
|
+
while (totalSteps < this.deps.maxSteps) {
|
|
56
|
+
const idx = plan.steps.findIndex((s) => s.status === 'pending');
|
|
57
|
+
if (idx === -1)
|
|
58
|
+
break;
|
|
59
|
+
const step = plan.steps[idx];
|
|
60
|
+
step.status = 'in_progress';
|
|
61
|
+
ctx.currentStepIdx = idx;
|
|
62
|
+
ctx.options?.sessionLogger?.logStep('coordinator_step_start', {
|
|
63
|
+
stepId: step.id,
|
|
64
|
+
goal: step.goal,
|
|
65
|
+
agent: step.agent,
|
|
66
|
+
});
|
|
67
|
+
let result;
|
|
68
|
+
for (let attempt = 0; attempt <= this.deps.maxRetriesPerStep; attempt++) {
|
|
69
|
+
result = await this.deps.dispatch.dispatch(step, coordCtx);
|
|
70
|
+
if (result.ok)
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (!result) {
|
|
74
|
+
ctx.error = new OrchestratorError(`coordinator: dispatch returned no result for step ${step.id}`, 'COORDINATOR_NO_RESULT');
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
coordCtx.stepResults[step.id] = result;
|
|
78
|
+
step.status = result.ok ? 'done' : 'failed';
|
|
79
|
+
ctx.options?.sessionLogger?.logStep('coordinator_step_done', {
|
|
80
|
+
stepId: step.id,
|
|
81
|
+
ok: result.ok,
|
|
82
|
+
durationMs: result.durationMs,
|
|
83
|
+
outputLength: result.output.length,
|
|
84
|
+
error: result.error,
|
|
85
|
+
});
|
|
86
|
+
if (!result.ok) {
|
|
87
|
+
if (this.deps.planning.shouldReplan(coordCtx, result)) {
|
|
88
|
+
const remaining = plan.steps.filter((s) => s.status === 'pending');
|
|
89
|
+
try {
|
|
90
|
+
plan = await this.deps.planning.rebuildPlan(coordCtx, remaining);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
ctx.error = wrapError(err, 'COORDINATOR_REPLAN_FAILED');
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
coordCtx.plan = plan;
|
|
97
|
+
ctx.plan = plan;
|
|
98
|
+
ctx.options?.sessionLogger?.logStep('coordinator_replan', {
|
|
99
|
+
stepCount: plan.steps.length,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (this.deps.failPolicy === 'abort') {
|
|
103
|
+
ctx.error = new OrchestratorError(`coordinator: step ${step.id} failed and failPolicy=abort: ${result.error}`, 'COORDINATOR_STEP_FAILED');
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
totalSteps++;
|
|
108
|
+
}
|
|
109
|
+
const hasPending = plan.steps.some((s) => s.status === 'pending');
|
|
110
|
+
const truncatedByLimit = totalSteps >= this.deps.maxSteps && hasPending;
|
|
111
|
+
const failedSteps = plan.steps.filter((s) => s.status === 'failed');
|
|
112
|
+
if (truncatedByLimit) {
|
|
113
|
+
ctx.options?.sessionLogger?.logStep('coordinator_max_steps', {
|
|
114
|
+
maxSteps: this.deps.maxSteps,
|
|
115
|
+
pendingCount: plan.steps.filter((s) => s.status === 'pending').length,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const stepBlocks = Object.values(coordCtx.stepResults)
|
|
119
|
+
.map((r) => `### ${r.stepId}\n${r.output}`)
|
|
120
|
+
.join('\n\n');
|
|
121
|
+
const completionNote = (() => {
|
|
122
|
+
if (truncatedByLimit) {
|
|
123
|
+
const pending = plan.steps.filter((s) => s.status === 'pending').length;
|
|
124
|
+
return `\n\n_[Coordinator: max steps (${this.deps.maxSteps}) reached, ${pending} step(s) still pending.]_`;
|
|
125
|
+
}
|
|
126
|
+
if (failedSteps.length > 0 && this.deps.failPolicy === 'continue') {
|
|
127
|
+
return `\n\n_[Coordinator: ${failedSteps.length} step(s) failed under failPolicy=continue.]_`;
|
|
128
|
+
}
|
|
129
|
+
return '';
|
|
130
|
+
})();
|
|
131
|
+
const finalOutput = stepBlocks + completionNote;
|
|
132
|
+
ctx.options?.sessionLogger?.logStep('coordinator_final', {
|
|
133
|
+
stepCount: Object.keys(coordCtx.stepResults).length,
|
|
134
|
+
outputLength: finalOutput.length,
|
|
135
|
+
truncated: truncatedByLimit,
|
|
136
|
+
failedSteps: failedSteps.length,
|
|
137
|
+
});
|
|
138
|
+
// Stream the final output as a single content chunk followed by a finish
|
|
139
|
+
// chunk. Mirrors tool-loop's contract so SSE consumers see a normal
|
|
140
|
+
// assistant response, but uses finishReason: 'length' when the plan was
|
|
141
|
+
// truncated by maxSteps — matching OpenAI's convention for limit-cut
|
|
142
|
+
// responses so clients can detect incompleteness.
|
|
143
|
+
ctx.yield({ ok: true, value: { content: finalOutput } });
|
|
144
|
+
ctx.yield({
|
|
145
|
+
ok: true,
|
|
146
|
+
value: {
|
|
147
|
+
content: '',
|
|
148
|
+
finishReason: truncatedByLimit ? 'length' : 'stop',
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function collectSystemPrompt(ctx) {
|
|
155
|
+
const first = ctx.assembledMessages?.[0];
|
|
156
|
+
if (first && first.role === 'system' && typeof first.content === 'string') {
|
|
157
|
+
return first.content;
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
function collectSkillContent(ctx) {
|
|
162
|
+
if (typeof ctx.skillContent === 'string' && ctx.skillContent.length > 0) {
|
|
163
|
+
return ctx.skillContent;
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
function collectActiveSkillMeta(ctx) {
|
|
168
|
+
const withSteps = ctx.selectedSkills?.find((s) => (s.meta?.steps?.length ?? 0) > 0);
|
|
169
|
+
return withSteps?.meta;
|
|
170
|
+
}
|
|
171
|
+
function wrapError(err, code) {
|
|
172
|
+
if (err instanceof OrchestratorError)
|
|
173
|
+
return err;
|
|
174
|
+
return new OrchestratorError(err instanceof Error ? err.message : String(err), code);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Helper used by DefaultPipeline / activation strategies to detect whether
|
|
178
|
+
* the active skill carries a structured `steps` block — a strong signal for
|
|
179
|
+
* Coordinator activation.
|
|
180
|
+
*/
|
|
181
|
+
export function activeSkillHasSteps(ctx) {
|
|
182
|
+
return !!ctx.selectedSkills?.some((s) => (s.meta?.steps?.length ?? 0) > 0);
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/pipeline/handlers/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAanD,MAAM,OAAO,kBAAkB;IACA;IAA7B,YAA6B,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;IAAG,CAAC;IAE7D,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,UAAmC,EACnC,KAAY;QAEZ,uEAAuE;QACvE,sEAAsE;QACtE,sEAAsE;QACtE,mEAAmE;QACnE,MAAM,QAAQ,GAAqB,GAAG,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S,mBAAmB,CAAC,GAAoB;IAC/C,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxE,OAAO,GAAG,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,sBAAsB,CAC7B,GAAoB;IAEpB,MAAM,SAAS,GAAG,GAAG,CAAC,cAAc,EAAE,IAAI,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CACxC,CAAC;IACF,OAAO,SAAS,EAAE,IAAI,CAAC;AACzB,CAAC;AAED,SAAS,SAAS,CAAC,GAAY,EAAE,IAAY;IAC3C,IAAI,GAAG,YAAY,iBAAiB;QAAE,OAAO,GAAG,CAAC;IACjD,OAAO,IAAI,iBAAiB,CAC1B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAChD,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* Maps built-in stage type names to their handler implementations.
|
|
5
5
|
* Custom handlers can be registered by supplying a custom `IPipeline` implementation.
|
|
6
6
|
*/
|
|
7
|
+
import type { IActivationStrategy, SubAgentRegistry } from '@mcp-abap-adt/llm-agent';
|
|
7
8
|
import type { IStageHandler } from '../stage-handler.js';
|
|
8
9
|
import { AssembleHandler } from './assemble.js';
|
|
9
10
|
import { BuildToolQueryHandler } from './build-tool-query.js';
|
|
10
11
|
import { ClassifyHandler } from './classify.js';
|
|
12
|
+
import { type CoordinatorHandlerDeps } from './coordinator.js';
|
|
11
13
|
import { ExpandHandler } from './expand.js';
|
|
12
14
|
import { HistoryUpsertHandler } from './history-upsert.js';
|
|
13
15
|
import { RagQueryHandler } from './rag-query.js';
|
|
@@ -25,7 +27,17 @@ export type StageHandlerRegistry = Map<string, IStageHandler>;
|
|
|
25
27
|
* instances. All handlers are stateless — they read/write through the
|
|
26
28
|
* {@link PipelineContext}.
|
|
27
29
|
*/
|
|
28
|
-
export
|
|
30
|
+
export interface BuildHandlerRegistryOptions {
|
|
31
|
+
subAgents?: SubAgentRegistry;
|
|
32
|
+
coordinator?: CoordinatorHandlerDeps;
|
|
33
|
+
/**
|
|
34
|
+
* Activation strategy used by the `coordinator-activate` runtime stage to
|
|
35
|
+
* compute `ctx.coordinatorActive`. Required when `coordinator` is set —
|
|
36
|
+
* without it, coordinator activation cannot honour runtime skill state.
|
|
37
|
+
*/
|
|
38
|
+
coordinatorActivation?: IActivationStrategy;
|
|
39
|
+
}
|
|
40
|
+
export declare function buildDefaultHandlerRegistry(opts?: BuildHandlerRegistryOptions): StageHandlerRegistry;
|
|
29
41
|
export { summarizeAndStore } from './history-upsert.js';
|
|
30
42
|
export { AssembleHandler, BuildToolQueryHandler, ClassifyHandler, ExpandHandler, HistoryUpsertHandler, RagQueryHandler, RerankHandler, SkillSelectHandler, SummarizeHandler, ToolLoopHandler, ToolSelectHandler, TranslateHandler, };
|
|
31
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipeline/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe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kB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,mBAAmB,CAAC;CAC7C;AAED,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,2BAAgC,GACrC,oBAAoB,CA4BtB;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,CAAC"}
|
|
@@ -7,24 +7,20 @@
|
|
|
7
7
|
import { AssembleHandler } from './assemble.js';
|
|
8
8
|
import { BuildToolQueryHandler } from './build-tool-query.js';
|
|
9
9
|
import { ClassifyHandler } from './classify.js';
|
|
10
|
+
import { CoordinatorHandler, } from './coordinator.js';
|
|
11
|
+
import { CoordinatorActivateHandler } from './coordinator-activate.js';
|
|
10
12
|
import { ExpandHandler } from './expand.js';
|
|
11
13
|
import { HistoryUpsertHandler } from './history-upsert.js';
|
|
12
14
|
import { RagQueryHandler } from './rag-query.js';
|
|
13
15
|
import { RerankHandler } from './rerank.js';
|
|
14
16
|
import { SkillSelectHandler } from './skill-select.js';
|
|
17
|
+
import { SubAgentHandler } from './subagent.js';
|
|
15
18
|
import { SummarizeHandler } from './summarize.js';
|
|
16
19
|
import { ToolLoopHandler } from './tool-loop.js';
|
|
17
20
|
import { ToolSelectHandler } from './tool-select.js';
|
|
18
21
|
import { TranslateHandler } from './translate.js';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* The registry maps stage type names (as used in YAML) to their handler
|
|
23
|
-
* instances. All handlers are stateless — they read/write through the
|
|
24
|
-
* {@link PipelineContext}.
|
|
25
|
-
*/
|
|
26
|
-
export function buildDefaultHandlerRegistry() {
|
|
27
|
-
return new Map([
|
|
22
|
+
export function buildDefaultHandlerRegistry(opts = {}) {
|
|
23
|
+
const registry = new Map([
|
|
28
24
|
['classify', new ClassifyHandler()],
|
|
29
25
|
['summarize', new SummarizeHandler()],
|
|
30
26
|
['translate', new TranslateHandler()],
|
|
@@ -38,6 +34,16 @@ export function buildDefaultHandlerRegistry() {
|
|
|
38
34
|
['tool-loop', new ToolLoopHandler()],
|
|
39
35
|
['history-upsert', new HistoryUpsertHandler()],
|
|
40
36
|
]);
|
|
37
|
+
if (opts.subAgents && opts.subAgents.size > 0) {
|
|
38
|
+
registry.set('subagent', new SubAgentHandler(opts.subAgents));
|
|
39
|
+
}
|
|
40
|
+
if (opts.coordinator) {
|
|
41
|
+
registry.set('coordinator', new CoordinatorHandler(opts.coordinator));
|
|
42
|
+
}
|
|
43
|
+
if (opts.coordinatorActivation) {
|
|
44
|
+
registry.set('coordinator-activate', new CoordinatorActivateHandler(opts.coordinatorActivation));
|
|
45
|
+
}
|
|
46
|
+
return registry;
|
|
41
47
|
}
|
|
42
48
|
export { summarizeAndStore } from './history-upsert.js';
|
|
43
49
|
export { AssembleHandler, BuildToolQueryHandler, ClassifyHandler, ExpandHandler, HistoryUpsertHandler, RagQueryHandler, RerankHandler, SkillSelectHandler, SummarizeHandler, ToolLoopHandler, ToolSelectHandler, TranslateHandler, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipeline/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipeline/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;GA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kBAAkB,EAAE,IAAI,qBAAqB,EAAE,CAAC;QACjD,CAAC,aAAa,EAAE,IAAI,iBAAiB,EAAE,CAAC;QACxC,CAAC,UAAU,EAAE,IAAI,eAAe,EAAE,CAAC;QACnC,CAAC,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC;QACpC,CAAC,gBAAgB,EAAE,IAAI,oBAAoB,EAAE,CAAC;KAC/C,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC9C,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC/B,QAAQ,CAAC,GAAG,CACV,sBAAsB,EACtB,IAAI,0BAA0B,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubAgentHandler — delegates a task to a named sub-agent from the registry.
|
|
3
|
+
*
|
|
4
|
+
* Reads: `ctx.inputText` (default task template), `ctx.sessionId`, `ctx.options`
|
|
5
|
+
* Writes: `ctx.subResults.<agent>` (or custom path via `config.outputTo`)
|
|
6
|
+
*
|
|
7
|
+
* Stage config:
|
|
8
|
+
* agent: string — registry key (required)
|
|
9
|
+
* task: string — Handlebars-style template for the task; defaults to '{{inputText}}'
|
|
10
|
+
* outputTo: string — dot-path to write result output; defaults to `subResults.<agent>`
|
|
11
|
+
*/
|
|
12
|
+
import type { SubAgentRegistry } from '@mcp-abap-adt/llm-agent';
|
|
13
|
+
import type { ISpan } from '../../tracer/types.js';
|
|
14
|
+
import type { PipelineContext } from '../context.js';
|
|
15
|
+
import type { IStageHandler } from '../stage-handler.js';
|
|
16
|
+
export declare class SubAgentHandler implements IStageHandler {
|
|
17
|
+
private readonly registry;
|
|
18
|
+
constructor(registry: SubAgentRegistry);
|
|
19
|
+
execute(ctx: PipelineContext, rawConfig: Record<string, unknown>, _span: ISpan): Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=subagent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../src/pipeline/handlers/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQzD,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,gBAAgB;IAEjD,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,OAAO,CAAC;CAyDpB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubAgentHandler — delegates a task to a named sub-agent from the registry.
|
|
3
|
+
*
|
|
4
|
+
* Reads: `ctx.inputText` (default task template), `ctx.sessionId`, `ctx.options`
|
|
5
|
+
* Writes: `ctx.subResults.<agent>` (or custom path via `config.outputTo`)
|
|
6
|
+
*
|
|
7
|
+
* Stage config:
|
|
8
|
+
* agent: string — registry key (required)
|
|
9
|
+
* task: string — Handlebars-style template for the task; defaults to '{{inputText}}'
|
|
10
|
+
* outputTo: string — dot-path to write result output; defaults to `subResults.<agent>`
|
|
11
|
+
*/
|
|
12
|
+
import { OrchestratorError } from '../../agent.js';
|
|
13
|
+
import { resolveTemplate, setPath } from '../../util/template.js';
|
|
14
|
+
export class SubAgentHandler {
|
|
15
|
+
registry;
|
|
16
|
+
constructor(registry) {
|
|
17
|
+
this.registry = registry;
|
|
18
|
+
}
|
|
19
|
+
async execute(ctx, rawConfig, _span) {
|
|
20
|
+
const config = rawConfig;
|
|
21
|
+
if (!config.agent || typeof config.agent !== 'string') {
|
|
22
|
+
ctx.error = new OrchestratorError("subagent stage: 'agent' is required", 'SUBAGENT_CONFIG_ERROR');
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const sub = this.registry.get(config.agent);
|
|
26
|
+
if (!sub) {
|
|
27
|
+
ctx.error = new OrchestratorError(`subagent '${config.agent}' not found. Registered: ${[...this.registry.keys()].join(', ') || '(none)'}`, 'SUBAGENT_NOT_FOUND');
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const taskTemplate = config.task ?? '{{inputText}}';
|
|
31
|
+
const task = resolveTemplate(taskTemplate, ctx);
|
|
32
|
+
const signal = ctx.options?.signal;
|
|
33
|
+
let result;
|
|
34
|
+
try {
|
|
35
|
+
result = await sub.run({
|
|
36
|
+
task,
|
|
37
|
+
sessionId: ctx.sessionId,
|
|
38
|
+
signal,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
ctx.error = new OrchestratorError(err instanceof Error ? err.message : String(err), 'SUBAGENT_RUNTIME_ERROR');
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const outputPath = config.outputTo ?? `subResults.${config.agent}`;
|
|
46
|
+
const ctxRecord = ctx;
|
|
47
|
+
if (!ctxRecord.subResults)
|
|
48
|
+
ctxRecord.subResults = {};
|
|
49
|
+
setPath(ctxRecord, outputPath, result.output);
|
|
50
|
+
ctx.options?.sessionLogger?.logStep(`subagent_${config.agent}`, {
|
|
51
|
+
task: task.slice(0, 200),
|
|
52
|
+
outputLength: result.output.length,
|
|
53
|
+
usage: result.usage,
|
|
54
|
+
});
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=subagent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../../src/pipeline/handlers/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAUlE,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,QAA0B;QAA1B,aAAQ,GAAR,QAAQ,CAAkB;IAAG,CAAC;IAE3D,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,SAAkC,EAClC,KAAY;QAEZ,MAAM,MAAM,GAAG,SAA2C,CAAC;QAE3D,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACtD,GAAG,CAAC,KAAK,GAAG,IAAI,iBAAiB,CAC/B,qCAAqC,EACrC,uBAAuB,CACxB,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,GAAG,GAA0B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK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YAAY,MAAM,CAAC,KAAK,EAAE,EAAE;YAC9D,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;YACxB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;YAClC,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ISubAgent, ISubAgentInput, ISubAgentResult } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import type { SmartAgent } from '../agent.js';
|
|
3
|
+
export declare class SmartAgentSubAgent implements ISubAgent {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
private readonly agent;
|
|
6
|
+
readonly description?: string;
|
|
7
|
+
constructor(name: string, agent: SmartAgent, opts?: {
|
|
8
|
+
description?: string;
|
|
9
|
+
});
|
|
10
|
+
run(input: ISubAgentInput): Promise<ISubAgentResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=smart-agent-subagent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-agent-subagent.d.ts","sourceRoot":"","sources":["../../src/subagent/smart-agent-subagent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,kBAAmB,YAAW,SAAS;aAIhC,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAGnB,IAAI,EAAE,MAAM,EACX,KAAK,EAAE,UAAU,EAClC,IAAI,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAK3B,GAAG,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CA+B3D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class SmartAgentSubAgent {
|
|
2
|
+
name;
|
|
3
|
+
agent;
|
|
4
|
+
description;
|
|
5
|
+
constructor(name, agent, opts) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.agent = agent;
|
|
8
|
+
this.description = opts?.description;
|
|
9
|
+
}
|
|
10
|
+
async run(input) {
|
|
11
|
+
const res = await this.agent.process(input.task, {
|
|
12
|
+
sessionId: input.sessionId,
|
|
13
|
+
signal: input.signal,
|
|
14
|
+
});
|
|
15
|
+
if (!res.ok) {
|
|
16
|
+
throw res.error;
|
|
17
|
+
}
|
|
18
|
+
const { content, toolCalls, usage } = res.value;
|
|
19
|
+
// Map SmartAgentResponse toolCalls (OpenAI wire format) → LlmToolCall[]
|
|
20
|
+
const mappedToolCalls = toolCalls?.map((tc) => ({
|
|
21
|
+
id: tc.id,
|
|
22
|
+
name: tc.function.name,
|
|
23
|
+
arguments: JSON.parse(tc.function.arguments),
|
|
24
|
+
}));
|
|
25
|
+
return {
|
|
26
|
+
output: content,
|
|
27
|
+
toolCalls: mappedToolCalls,
|
|
28
|
+
usage: usage
|
|
29
|
+
? {
|
|
30
|
+
promptTokens: usage.promptTokens,
|
|
31
|
+
completionTokens: usage.completionTokens,
|
|
32
|
+
totalTokens: usage.totalTokens,
|
|
33
|
+
}
|
|
34
|
+
: undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=smart-agent-subagent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-agent-subagent.js","sourceRoot":"","sources":["../../src/subagent/smart-agent-subagent.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,kBAAkB;IAIX;IACC;IAJH,WAAW,CAAU;IAErC,YACkB,IAAY,EACX,KAAiB,EAClC,IAA+B;QAFf,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAY;QAGlC,IAAI,CAAC,WAAW,GAAG,IAAI,EAAE,WAAW,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAqB;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YAC/C,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,GAAG,CAAC,KAAK,CAAC;QAClB,CAAC;QAED,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;QAEhD,wEAAwE;QACxE,MAAM,eAAe,GAA8B,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACzE,EAAE,EAAE,EAAE,CAAC,EAAE;YACT,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI;YACtB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAA4B;SACxE,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,KAAK;gBACV,CAAC,CAAC;oBACE,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;oBACxC,WAAW,EAAE,KAAK,CAAC,WAAW;iBAC/B;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `{{path.to.value}}` placeholders against a context object.
|
|
3
|
+
* Missing paths render as empty string. Non-string values are JSON-stringified.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveTemplate(template: string, ctx: Record<string, unknown>): string;
|
|
6
|
+
export declare function getPath(obj: unknown, path: string): unknown;
|
|
7
|
+
export declare function setPath(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
8
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/util/template.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAMR;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ3D;AAED,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,IAAI,CAYN"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `{{path.to.value}}` placeholders against a context object.
|
|
3
|
+
* Missing paths render as empty string. Non-string values are JSON-stringified.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveTemplate(template, ctx) {
|
|
6
|
+
return template.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (_, path) => {
|
|
7
|
+
const v = getPath(ctx, path);
|
|
8
|
+
if (v == null)
|
|
9
|
+
return '';
|
|
10
|
+
return typeof v === 'string' ? v : JSON.stringify(v);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function getPath(obj, path) {
|
|
14
|
+
const parts = path.split('.');
|
|
15
|
+
let cur = obj;
|
|
16
|
+
for (const p of parts) {
|
|
17
|
+
if (cur == null || typeof cur !== 'object')
|
|
18
|
+
return undefined;
|
|
19
|
+
cur = cur[p];
|
|
20
|
+
}
|
|
21
|
+
return cur;
|
|
22
|
+
}
|
|
23
|
+
export function setPath(obj, path, value) {
|
|
24
|
+
const parts = path.split('.');
|
|
25
|
+
let cur = obj;
|
|
26
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
27
|
+
const key = parts[i];
|
|
28
|
+
const next = cur[key];
|
|
29
|
+
if (next == null || typeof next !== 'object') {
|
|
30
|
+
cur[key] = {};
|
|
31
|
+
}
|
|
32
|
+
cur = cur[key];
|
|
33
|
+
}
|
|
34
|
+
cur[parts[parts.length - 1]] = value;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/util/template.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,GAA4B;IAE5B,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QACrE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,IAAI;YAAE,OAAO,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAY,EAAE,IAAY;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,GAAG,GAAY,GAAG,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC7D,GAAG,GAAI,GAA+B,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,GAA4B,EAC5B,IAAY,EACZ,KAAc;IAEd,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,GAAG,GAA4B,GAAG,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;QACD,GAAG,GAAG,GAAG,CAAC,GAAG,CAA4B,CAAC;IAC5C,CAAC;IACD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/llm-agent-libs",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"test": "node --import tsx/esm --test --test-reporter=spec 'src/**/*.test.ts'"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mcp-abap-adt/llm-agent": "^12.0
|
|
35
|
-
"@mcp-abap-adt/llm-agent-mcp": "^12.0
|
|
36
|
-
"@mcp-abap-adt/llm-agent-rag": "^12.0
|
|
34
|
+
"@mcp-abap-adt/llm-agent": "^12.1.0",
|
|
35
|
+
"@mcp-abap-adt/llm-agent-mcp": "^12.1.0",
|
|
36
|
+
"@mcp-abap-adt/llm-agent-rag": "^12.1.0",
|
|
37
37
|
"@opentelemetry/api": "^1.9.1",
|
|
38
38
|
"dotenv": "^17.3.1",
|
|
39
39
|
"yaml": "^2.8.3",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@mcp-abap-adt/openai-llm": "^12.0
|
|
64
|
-
"@mcp-abap-adt/anthropic-llm": "^12.0
|
|
65
|
-
"@mcp-abap-adt/deepseek-llm": "^12.0
|
|
66
|
-
"@mcp-abap-adt/sap-aicore-llm": "^12.0
|
|
63
|
+
"@mcp-abap-adt/openai-llm": "^12.1.0",
|
|
64
|
+
"@mcp-abap-adt/anthropic-llm": "^12.1.0",
|
|
65
|
+
"@mcp-abap-adt/deepseek-llm": "^12.1.0",
|
|
66
|
+
"@mcp-abap-adt/sap-aicore-llm": "^12.1.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|