qlogicagent 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -45
- package/package.json +1 -1
- package/dist/agent.js +0 -1
- package/dist/cli.js +0 -9
- package/dist/contracts.js +0 -1
- package/dist/index.js +0 -5
- package/dist/orchestration.js +0 -118
- package/dist/types/agent/agent.d.ts +0 -43
- package/dist/types/agent/tool-loop.d.ts +0 -64
- package/dist/types/agent/types.d.ts +0 -175
- package/dist/types/cli/main.d.ts +0 -11
- package/dist/types/cli/stdio-server.d.ts +0 -45
- package/dist/types/config/config.d.ts +0 -17
- package/dist/types/contracts/hooks.d.ts +0 -120
- package/dist/types/contracts/index.d.ts +0 -10
- package/dist/types/contracts/planner.d.ts +0 -35
- package/dist/types/contracts/skill-candidate.d.ts +0 -63
- package/dist/types/contracts/todo.d.ts +0 -14
- package/dist/types/index.d.ts +0 -13
- package/dist/types/llm/builtin-providers.d.ts +0 -10
- package/dist/types/llm/index.d.ts +0 -15
- package/dist/types/llm/llm-client.d.ts +0 -43
- package/dist/types/llm/model-catalog.d.ts +0 -53
- package/dist/types/llm/provider-def.d.ts +0 -59
- package/dist/types/llm/provider-registry.d.ts +0 -54
- package/dist/types/llm/transport.d.ts +0 -62
- package/dist/types/llm/transports/anthropic-messages.d.ts +0 -31
- package/dist/types/llm/transports/openai-chat.d.ts +0 -36
- package/dist/types/orchestration/agent-registry.d.ts +0 -41
- package/dist/types/orchestration/approval-aware-tool-plan.d.ts +0 -32
- package/dist/types/orchestration/context-compression.d.ts +0 -220
- package/dist/types/orchestration/conversation-repair.d.ts +0 -61
- package/dist/types/orchestration/curator-scheduler.d.ts +0 -119
- package/dist/types/orchestration/embedded-failover-policy.d.ts +0 -110
- package/dist/types/orchestration/error-classification.d.ts +0 -12
- package/dist/types/orchestration/failover-classification.d.ts +0 -8
- package/dist/types/orchestration/failover-error.d.ts +0 -33
- package/dist/types/orchestration/fork-subagent.d.ts +0 -100
- package/dist/types/orchestration/index.d.ts +0 -120
- package/dist/types/orchestration/memory-flush-policy.d.ts +0 -57
- package/dist/types/orchestration/memory-provider.d.ts +0 -14
- package/dist/types/orchestration/parallel-tool-calls.d.ts +0 -41
- package/dist/types/orchestration/prompt-cache-strategy.d.ts +0 -126
- package/dist/types/orchestration/reactive-compact.d.ts +0 -73
- package/dist/types/orchestration/retry-loop.d.ts +0 -22
- package/dist/types/orchestration/skill-candidate.d.ts +0 -52
- package/dist/types/orchestration/skill-consolidation.d.ts +0 -123
- package/dist/types/orchestration/skill-improvement.d.ts +0 -59
- package/dist/types/orchestration/skill-similarity.d.ts +0 -98
- package/dist/types/orchestration/streaming-tool-executor.d.ts +0 -73
- package/dist/types/orchestration/team-orchestration.d.ts +0 -195
- package/dist/types/orchestration/team-tool-loop-wiring.d.ts +0 -92
- package/dist/types/orchestration/tool-choice-policy.d.ts +0 -54
- package/dist/types/orchestration/tool-loop-state.d.ts +0 -50
- package/dist/types/orchestration/tool-schema.d.ts +0 -39
- package/dist/types/orchestration/transcript-repair.d.ts +0 -42
- package/dist/types/orchestration/turn-loop-guard.d.ts +0 -86
- package/dist/types/orchestration/web-browser-policy.d.ts +0 -17
- package/dist/types/runtime/context-compression.d.ts +0 -61
- package/dist/types/runtime/hook-registry.d.ts +0 -12
- package/dist/types/runtime/memory-hooks.d.ts +0 -23
- package/dist/types/runtime/tool-eligibility.d.ts +0 -59
- package/dist/types/skills/index.d.ts +0 -108
- package/dist/types/skills/memory-extractor.d.ts +0 -64
- package/dist/types/skills/memory-query-tool.d.ts +0 -43
- package/dist/types/skills/memory-store.d.ts +0 -66
- package/dist/types/skills/memory-tool.d.ts +0 -67
- package/dist/types/skills/portable-tool.d.ts +0 -71
- package/dist/types/skills/qmemory-adapter.d.ts +0 -52
- package/dist/types/skills/skill-frontmatter.d.ts +0 -19
- package/dist/types/skills/skill-guard.d.ts +0 -23
- package/dist/types/skills/skill-loader.d.ts +0 -16
- package/dist/types/skills/skill-source.d.ts +0 -119
- package/dist/types/skills/skill-types.d.ts +0 -199
- package/dist/types/skills/think-tool.d.ts +0 -16
- package/dist/types/skills/todo-tool.d.ts +0 -63
- package/dist/types/skills/tools/agent-tool.d.ts +0 -91
- package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
- package/dist/types/skills/tools/ask-user-tool.d.ts +0 -80
- package/dist/types/skills/tools/brief-tool.d.ts +0 -74
- package/dist/types/skills/tools/browser-tool.d.ts +0 -114
- package/dist/types/skills/tools/checkpoint-tool.d.ts +0 -66
- package/dist/types/skills/tools/config-tool.d.ts +0 -63
- package/dist/types/skills/tools/cron-tool.d.ts +0 -116
- package/dist/types/skills/tools/edit-tool.d.ts +0 -43
- package/dist/types/skills/tools/exec-tool.d.ts +0 -102
- package/dist/types/skills/tools/image-generate-tool.d.ts +0 -62
- package/dist/types/skills/tools/instructions-tool.d.ts +0 -103
- package/dist/types/skills/tools/lsp-tool.d.ts +0 -153
- package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
- package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
- package/dist/types/skills/tools/memory-tool.d.ts +0 -74
- package/dist/types/skills/tools/monitor-tool.d.ts +0 -113
- package/dist/types/skills/tools/music-generate-tool.d.ts +0 -55
- package/dist/types/skills/tools/notify-tool.d.ts +0 -53
- package/dist/types/skills/tools/patch-tool.d.ts +0 -45
- package/dist/types/skills/tools/pdf-tool.d.ts +0 -66
- package/dist/types/skills/tools/plan-mode-tool.d.ts +0 -59
- package/dist/types/skills/tools/read-tool.d.ts +0 -51
- package/dist/types/skills/tools/repl-tool.d.ts +0 -70
- package/dist/types/skills/tools/search-tool.d.ts +0 -112
- package/dist/types/skills/tools/send-message-tool.d.ts +0 -51
- package/dist/types/skills/tools/skill-list-tool.d.ts +0 -33
- package/dist/types/skills/tools/skill-manage-tool.d.ts +0 -73
- package/dist/types/skills/tools/skill-view-tool.d.ts +0 -37
- package/dist/types/skills/tools/sleep-tool.d.ts +0 -49
- package/dist/types/skills/tools/structured-output-tool.d.ts +0 -116
- package/dist/types/skills/tools/task-tool.d.ts +0 -104
- package/dist/types/skills/tools/team-tool.d.ts +0 -89
- package/dist/types/skills/tools/tool-search-tool.d.ts +0 -51
- package/dist/types/skills/tools/tts-tool.d.ts +0 -38
- package/dist/types/skills/tools/video-edit-tool.d.ts +0 -69
- package/dist/types/skills/tools/video-generate-tool.d.ts +0 -62
- package/dist/types/skills/tools/video-merge-tool.d.ts +0 -105
- package/dist/types/skills/tools/video-upscale-tool.d.ts +0 -45
- package/dist/types/skills/tools/web-fetch-tool.d.ts +0 -78
- package/dist/types/skills/tools/web-search-tool.d.ts +0 -57
- package/dist/types/skills/tools/worktree-tool.d.ts +0 -69
- package/dist/types/skills/tools/write-tool.d.ts +0 -45
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill consolidation strategy — pure decision logic for
|
|
3
|
-
* the Autonomous Curator's LLM-driven skill merging phase.
|
|
4
|
-
*
|
|
5
|
-
* This module:
|
|
6
|
-
* 1. Detects prefix clusters among skill names.
|
|
7
|
-
* 2. Builds the consolidation prompt for the LLM review agent.
|
|
8
|
-
* 3. Parses structured LLM output into actionable merge/prune plans.
|
|
9
|
-
* 4. Reconciles LLM intent against ground truth (existing skills).
|
|
10
|
-
*
|
|
11
|
-
* No I/O — the caller invokes the LLM and applies the results.
|
|
12
|
-
*/
|
|
13
|
-
/** A skill summary fed to the LLM reviewer. */
|
|
14
|
-
export interface ConsolidationSkillSummary {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
/** Comma-separated tool names the skill uses. */
|
|
18
|
-
tools: string;
|
|
19
|
-
useCount: number;
|
|
20
|
-
lastActivityAt: string | null;
|
|
21
|
-
state: "active" | "stale";
|
|
22
|
-
}
|
|
23
|
-
/** A single consolidation action proposed by the LLM. */
|
|
24
|
-
export interface ConsolidationAction {
|
|
25
|
-
/** Source skill to be absorbed. */
|
|
26
|
-
sourceSkill: string;
|
|
27
|
-
/** Target umbrella skill (existing or to-be-created). */
|
|
28
|
-
targetUmbrella: string;
|
|
29
|
-
/** Whether the target umbrella already exists. */
|
|
30
|
-
targetExists: boolean;
|
|
31
|
-
/** LLM's reason for the merge. */
|
|
32
|
-
reason: string;
|
|
33
|
-
}
|
|
34
|
-
/** A single pruning action proposed by the LLM. */
|
|
35
|
-
export interface PruningAction {
|
|
36
|
-
/** Skill to be archived (not deleted). */
|
|
37
|
-
skillName: string;
|
|
38
|
-
/** Reason for pruning. */
|
|
39
|
-
reason: string;
|
|
40
|
-
}
|
|
41
|
-
/** Full consolidation plan produced by parsing LLM output. */
|
|
42
|
-
export interface ConsolidationPlan {
|
|
43
|
-
consolidations: ConsolidationAction[];
|
|
44
|
-
prunings: PruningAction[];
|
|
45
|
-
/** Skills mentioned by LLM but not found in ground truth. */
|
|
46
|
-
hallucinations: string[];
|
|
47
|
-
}
|
|
48
|
-
/** Result of reconciling the LLM plan against ground truth. */
|
|
49
|
-
export interface ReconciledConsolidationPlan {
|
|
50
|
-
/** Validated consolidation actions (targets exist or are marked for creation). */
|
|
51
|
-
validConsolidations: ConsolidationAction[];
|
|
52
|
-
/** Validated pruning actions (skills exist). */
|
|
53
|
-
validPrunings: PruningAction[];
|
|
54
|
-
/** Rejected actions due to ground-truth mismatch. */
|
|
55
|
-
rejected: Array<{
|
|
56
|
-
action: string;
|
|
57
|
-
reason: string;
|
|
58
|
-
}>;
|
|
59
|
-
}
|
|
60
|
-
/** A detected cluster of skills sharing a naming prefix. */
|
|
61
|
-
export interface SkillPrefixCluster {
|
|
62
|
-
prefix: string;
|
|
63
|
-
skills: string[];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Detect prefix clusters among skill names.
|
|
67
|
-
*
|
|
68
|
-
* A cluster is ≥2 skills sharing a common hyphenated prefix of ≥2 chars.
|
|
69
|
-
* E.g. `["pr-review", "pr-merge", "pr-label"]` → cluster `"pr"`.
|
|
70
|
-
*/
|
|
71
|
-
export declare function detectPrefixClusters(skillNames: readonly string[], minClusterSize?: number): SkillPrefixCluster[];
|
|
72
|
-
/**
|
|
73
|
-
* Build the consolidation review prompt for the LLM curator agent.
|
|
74
|
-
*
|
|
75
|
-
* The prompt instructs the model to:
|
|
76
|
-
* 1. Identify prefix clusters and overlapping skills.
|
|
77
|
-
* 2. Propose umbrella consolidations.
|
|
78
|
-
* 3. Mark redundant/trivial skills for pruning (archive, not delete).
|
|
79
|
-
* 4. Output a structured YAML block.
|
|
80
|
-
*/
|
|
81
|
-
export declare function buildConsolidationPrompt(candidates: readonly ConsolidationSkillSummary[], existingUmbrellas: readonly string[], clusters: readonly SkillPrefixCluster[]): string;
|
|
82
|
-
/**
|
|
83
|
-
* Parse the LLM's structured YAML response into a ConsolidationPlan.
|
|
84
|
-
*
|
|
85
|
-
* Tolerant: handles minor formatting variations, ignores unknown fields.
|
|
86
|
-
*/
|
|
87
|
-
export declare function parseConsolidationOutput(llmOutput: string, knownSkills: ReadonlySet<string>): ConsolidationPlan;
|
|
88
|
-
/**
|
|
89
|
-
* Reconcile the LLM's consolidation plan against ground truth.
|
|
90
|
-
*
|
|
91
|
-
* Validates that:
|
|
92
|
-
* - Source skills exist and aren't already consolidated in this plan.
|
|
93
|
-
* - Target umbrellas either exist or are new (will be created).
|
|
94
|
-
* - Pruning targets aren't also being consolidated.
|
|
95
|
-
*/
|
|
96
|
-
export declare function reconcileConsolidationPlan(plan: ConsolidationPlan, knownSkills: ReadonlySet<string>): ReconciledConsolidationPlan;
|
|
97
|
-
/** Summary of a curator review run. */
|
|
98
|
-
export interface CuratorRunReport {
|
|
99
|
-
/** ISO-8601 timestamp of the run. */
|
|
100
|
-
runAt: string;
|
|
101
|
-
/** Duration in seconds. */
|
|
102
|
-
durationSeconds: number;
|
|
103
|
-
/** Number of skills checked for lifecycle transitions. */
|
|
104
|
-
autoTransitionsChecked: number;
|
|
105
|
-
/** Number of skills marked stale. */
|
|
106
|
-
autoMarkedStale: number;
|
|
107
|
-
/** Number of skills archived. */
|
|
108
|
-
autoArchived: number;
|
|
109
|
-
/** Number of skills reactivated. */
|
|
110
|
-
autoReactivated: number;
|
|
111
|
-
/** Number of LLM-proposed consolidations accepted. */
|
|
112
|
-
consolidationsAccepted: number;
|
|
113
|
-
/** Number of LLM-proposed prunings accepted. */
|
|
114
|
-
pruningsAccepted: number;
|
|
115
|
-
/** Number of LLM-proposed actions rejected. */
|
|
116
|
-
actionsRejected: number;
|
|
117
|
-
/** Number of hallucinated skill names. */
|
|
118
|
-
hallucinations: number;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Build a human-readable summary from a curator run report.
|
|
122
|
-
*/
|
|
123
|
-
export declare function buildCuratorRunSummary(report: CuratorRunReport): string;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill self-learning: decides whether a completed turn should
|
|
3
|
-
* trigger skill creation or improvement instructions.
|
|
4
|
-
*/
|
|
5
|
-
export interface SkillTurnResult {
|
|
6
|
-
ok: boolean;
|
|
7
|
-
/** Number of tool invocations in this turn */
|
|
8
|
-
toolCallCount: number;
|
|
9
|
-
/** Number of distinct tool names used */
|
|
10
|
-
distinctToolCount: number;
|
|
11
|
-
/** Was a multi-step orchestration (≥2 rounds) used? */
|
|
12
|
-
multiStep: boolean;
|
|
13
|
-
/** Did the turn involve a sidechain? */
|
|
14
|
-
hasSidechain: boolean;
|
|
15
|
-
/** Optional user feedback signal (positive/negative/none) */
|
|
16
|
-
feedback?: "positive" | "negative" | null;
|
|
17
|
-
/** Skill name if an existing skill was used */
|
|
18
|
-
existingSkillName?: string | null;
|
|
19
|
-
}
|
|
20
|
-
export interface SkillCreateInstruction {
|
|
21
|
-
type: "skill.create";
|
|
22
|
-
/** Suggested skill name derived from tool usage pattern */
|
|
23
|
-
suggestedName: string;
|
|
24
|
-
/** Short description of what the skill does */
|
|
25
|
-
description: string;
|
|
26
|
-
/** Tool names involved */
|
|
27
|
-
tools: string[];
|
|
28
|
-
/** Number of orchestration steps */
|
|
29
|
-
stepCount: number;
|
|
30
|
-
}
|
|
31
|
-
export interface SkillImproveInstruction {
|
|
32
|
-
type: "skill.improve";
|
|
33
|
-
/** Existing skill to improve */
|
|
34
|
-
skillName: string;
|
|
35
|
-
/** Reason for improvement */
|
|
36
|
-
reason: string;
|
|
37
|
-
}
|
|
38
|
-
export type SkillInstruction = SkillCreateInstruction | SkillImproveInstruction;
|
|
39
|
-
/**
|
|
40
|
-
* Determine whether a completed turn should produce a skill instruction.
|
|
41
|
-
*
|
|
42
|
-
* A new skill is suggested when:
|
|
43
|
-
* - The turn succeeded
|
|
44
|
-
* - It involved multi-step orchestration
|
|
45
|
-
* - It used ≥3 tool calls across ≥2 distinct tools
|
|
46
|
-
* - No existing skill was already applied
|
|
47
|
-
*
|
|
48
|
-
* An improvement is suggested when:
|
|
49
|
-
* - The turn used an existing skill but got negative feedback
|
|
50
|
-
*/
|
|
51
|
-
export declare function shouldCreateSkill(result: SkillTurnResult): boolean;
|
|
52
|
-
export declare function shouldImproveSkill(result: SkillTurnResult): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Build a skill instruction from a turn result, or null if none is warranted.
|
|
55
|
-
*/
|
|
56
|
-
export declare function buildSkillInstruction(result: SkillTurnResult, context: {
|
|
57
|
-
tools: string[];
|
|
58
|
-
suggestedName?: string;
|
|
59
|
-
}): SkillInstruction | null;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill similarity — pure strategy for detecting near-duplicate skills
|
|
3
|
-
* before creation and during curator consolidation reviews.
|
|
4
|
-
*
|
|
5
|
-
* Computes multi-signal similarity between skills:
|
|
6
|
-
* 1. Tool-set Jaccard overlap (primary signal for auto-generated skills)
|
|
7
|
-
* 2. Title/description cosine bigram similarity (complementary signal)
|
|
8
|
-
* 3. Step-count proximity (minor signal for workflow complexity)
|
|
9
|
-
*
|
|
10
|
-
* No I/O — all functions are pure.
|
|
11
|
-
*/
|
|
12
|
-
/** Minimal skill profile for similarity comparison. */
|
|
13
|
-
export interface SkillSimilarityProfile {
|
|
14
|
-
skillKey: string;
|
|
15
|
-
title: string;
|
|
16
|
-
tools: readonly string[];
|
|
17
|
-
stepCount?: number;
|
|
18
|
-
}
|
|
19
|
-
/** Result of a pairwise similarity comparison. */
|
|
20
|
-
export interface SimilarityScore {
|
|
21
|
-
/** Overall similarity [0, 1]. */
|
|
22
|
-
overall: number;
|
|
23
|
-
/** Tool-set Jaccard index [0, 1]. */
|
|
24
|
-
toolJaccard: number;
|
|
25
|
-
/** Title bigram similarity [0, 1]. */
|
|
26
|
-
titleSimilarity: number;
|
|
27
|
-
/** Step-count proximity [0, 1]. */
|
|
28
|
-
stepProximity: number;
|
|
29
|
-
}
|
|
30
|
-
/** A candidate detected as similar during pre-creation check. */
|
|
31
|
-
export interface SimilarSkillMatch {
|
|
32
|
-
existingSkillKey: string;
|
|
33
|
-
score: SimilarityScore;
|
|
34
|
-
}
|
|
35
|
-
/** Policy for similarity thresholds. */
|
|
36
|
-
export interface SkillSimilarityPolicy {
|
|
37
|
-
/**
|
|
38
|
-
* Overall similarity threshold to block creation and emit "improve"
|
|
39
|
-
* instead. Default: 0.75.
|
|
40
|
-
*/
|
|
41
|
-
blockCreationThreshold: number;
|
|
42
|
-
/**
|
|
43
|
-
* Overall similarity threshold to flag for curator review.
|
|
44
|
-
* Default: 0.55.
|
|
45
|
-
*/
|
|
46
|
-
curatorReviewThreshold: number;
|
|
47
|
-
/** Weight of toolJaccard in overall score. Default: 0.60. */
|
|
48
|
-
toolWeight: number;
|
|
49
|
-
/** Weight of titleSimilarity in overall score. Default: 0.30. */
|
|
50
|
-
titleWeight: number;
|
|
51
|
-
/** Weight of stepProximity in overall score. Default: 0.10. */
|
|
52
|
-
stepWeight: number;
|
|
53
|
-
}
|
|
54
|
-
export declare const DEFAULT_SKILL_SIMILARITY_POLICY: SkillSimilarityPolicy;
|
|
55
|
-
/**
|
|
56
|
-
* Compute Jaccard index between two tool sets.
|
|
57
|
-
* Returns 0 if both sets are empty.
|
|
58
|
-
*/
|
|
59
|
-
export declare function toolSetJaccard(toolsA: readonly string[], toolsB: readonly string[]): number;
|
|
60
|
-
/**
|
|
61
|
-
* Compute character-bigram similarity between two strings.
|
|
62
|
-
* Uses Dice coefficient of bigram sets.
|
|
63
|
-
*/
|
|
64
|
-
export declare function bigramSimilarity(a: string, b: string): number;
|
|
65
|
-
/**
|
|
66
|
-
* Compute step-count proximity [0, 1].
|
|
67
|
-
* Returns 1 when counts are identical, decreases with difference.
|
|
68
|
-
*/
|
|
69
|
-
export declare function stepCountProximity(stepsA: number | undefined, stepsB: number | undefined): number;
|
|
70
|
-
/**
|
|
71
|
-
* Compute overall similarity between two skill profiles.
|
|
72
|
-
*/
|
|
73
|
-
export declare function computeSimilarity(a: SkillSimilarityProfile, b: SkillSimilarityProfile, policy?: Partial<SkillSimilarityPolicy>): SimilarityScore;
|
|
74
|
-
/**
|
|
75
|
-
* Check a new skill candidate against existing skills for similarity.
|
|
76
|
-
*
|
|
77
|
-
* Returns all existing skills above curatorReviewThreshold, sorted
|
|
78
|
-
* by descending similarity. The caller should:
|
|
79
|
-
* - Block creation if any match ≥ blockCreationThreshold (emit improve instead)
|
|
80
|
-
* - Tag for curator review if match ≥ curatorReviewThreshold
|
|
81
|
-
*/
|
|
82
|
-
export declare function findSimilarSkills(newSkill: SkillSimilarityProfile, existingSkills: readonly SkillSimilarityProfile[], policy?: Partial<SkillSimilarityPolicy>): SimilarSkillMatch[];
|
|
83
|
-
/**
|
|
84
|
-
* Determine creation decision based on similarity matches.
|
|
85
|
-
*/
|
|
86
|
-
export type SimilarityDecision = {
|
|
87
|
-
action: "create";
|
|
88
|
-
reason: string;
|
|
89
|
-
} | {
|
|
90
|
-
action: "improve";
|
|
91
|
-
targetSkillKey: string;
|
|
92
|
-
reason: string;
|
|
93
|
-
} | {
|
|
94
|
-
action: "flag-for-review";
|
|
95
|
-
targetSkillKey: string;
|
|
96
|
-
reason: string;
|
|
97
|
-
};
|
|
98
|
-
export declare function decideSimilarityAction(matches: readonly SimilarSkillMatch[], policy?: Partial<SkillSimilarityPolicy>): SimilarityDecision;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StreamingToolExecutor — Executes tool calls as they arrive during LLM streaming.
|
|
3
|
-
*
|
|
4
|
-
* Aligned with Claude Code's StreamingToolExecutor pattern:
|
|
5
|
-
* - As each complete tool_use block arrives during streaming, immediately dispatch execution
|
|
6
|
-
* - Don't wait for the full LLM response to finish before starting tool execution
|
|
7
|
-
* - Results queue up and can be collected at any time
|
|
8
|
-
*
|
|
9
|
-
* This reduces perceived latency by overlapping LLM generation time with tool execution time.
|
|
10
|
-
*/
|
|
11
|
-
export interface StreamingToolCall {
|
|
12
|
-
id: string;
|
|
13
|
-
function: {
|
|
14
|
-
name: string;
|
|
15
|
-
arguments: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export interface StreamingToolResult<T = unknown> {
|
|
19
|
-
toolCallId: string;
|
|
20
|
-
toolName: string;
|
|
21
|
-
result: T;
|
|
22
|
-
ok: boolean;
|
|
23
|
-
startedAt: number;
|
|
24
|
-
completedAt: number;
|
|
25
|
-
error?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface StreamingToolExecutorConfig {
|
|
28
|
-
/** Maximum concurrent tool executions (default: 8) */
|
|
29
|
-
maxConcurrency: number;
|
|
30
|
-
/** Abort signal for cancellation */
|
|
31
|
-
abortSignal?: AbortSignal;
|
|
32
|
-
}
|
|
33
|
-
export type ToolExecutorFn<T = unknown> = (toolCall: StreamingToolCall, abortSignal?: AbortSignal) => Promise<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Streaming tool executor that dispatches tool calls immediately as they complete
|
|
36
|
-
* during LLM streaming output, rather than waiting for the full response.
|
|
37
|
-
*
|
|
38
|
-
* Usage:
|
|
39
|
-
* ```ts
|
|
40
|
-
* const executor = createStreamingToolExecutor(executeFn, { maxConcurrency: 4 });
|
|
41
|
-
* // During streaming, as each tool block completes:
|
|
42
|
-
* executor.addTool(toolCall);
|
|
43
|
-
* // Periodically collect completed results:
|
|
44
|
-
* const results = executor.getCompletedResults();
|
|
45
|
-
* // After streaming ends, wait for all remaining:
|
|
46
|
-
* const allResults = await executor.flush();
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export interface StreamingToolExecutor<T = unknown> {
|
|
50
|
-
/** Add a tool call for immediate execution. Returns false if at capacity. */
|
|
51
|
-
addTool(toolCall: StreamingToolCall): boolean;
|
|
52
|
-
/** Get results that have completed since last call (non-blocking). */
|
|
53
|
-
getCompletedResults(): StreamingToolResult<T>[];
|
|
54
|
-
/** Wait for all pending tool calls to complete and return all results. */
|
|
55
|
-
flush(): Promise<StreamingToolResult<T>[]>;
|
|
56
|
-
/** Number of currently executing tool calls. */
|
|
57
|
-
readonly pendingCount: number;
|
|
58
|
-
/** Total number of tool calls dispatched. */
|
|
59
|
-
readonly dispatchedCount: number;
|
|
60
|
-
/** Whether the executor has been aborted. */
|
|
61
|
-
readonly aborted: boolean;
|
|
62
|
-
}
|
|
63
|
-
export declare function createStreamingToolExecutor<T = unknown>(executeFn: ToolExecutorFn<T>, config?: Partial<StreamingToolExecutorConfig>): StreamingToolExecutor<T>;
|
|
64
|
-
/**
|
|
65
|
-
* Determine if a tool call can be dispatched immediately during streaming
|
|
66
|
-
* based on its manifest properties.
|
|
67
|
-
*/
|
|
68
|
-
export declare function canDispatchDuringStreaming(toolCall: StreamingToolCall, manifest?: {
|
|
69
|
-
approvalMode?: "user-confirm" | "pre-authorized";
|
|
70
|
-
requiresApproval?: boolean;
|
|
71
|
-
serialOnly?: boolean;
|
|
72
|
-
parallelSafe?: boolean;
|
|
73
|
-
}): boolean;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Team Orchestration Strategy — multi-agent coordination layer.
|
|
3
|
-
*
|
|
4
|
-
* Extends the existing sidechain foundation with team/swarm semantics:
|
|
5
|
-
* - Parallel agent spawning (multiple sidechains at once)
|
|
6
|
-
* - Role-based agent assignment (planner / executor / reviewer)
|
|
7
|
-
* - Shared knowledge pool via merge policies
|
|
8
|
-
* - Budget-aware concurrency limits
|
|
9
|
-
* - Lifecycle state machine for team coordination
|
|
10
|
-
*
|
|
11
|
-
* Architecture:
|
|
12
|
-
* Gateway ─── Hub ─── orchestration (this module, pure strategy)
|
|
13
|
-
* │
|
|
14
|
-
* ┌───────────┼───────────┐
|
|
15
|
-
* │ TeamCoordinator │ ← Hub runtime (multi-sidechain-coordinator.ts)
|
|
16
|
-
* │ │ │
|
|
17
|
-
* │ ├── Agent #1 (planner)
|
|
18
|
-
* │ ├── Agent #2 (executor)
|
|
19
|
-
* │ └── Agent #3 (reviewer)
|
|
20
|
-
* └───────────────────────┘
|
|
21
|
-
*
|
|
22
|
-
* This module provides:
|
|
23
|
-
* 1. Type definitions (TeamPlan, AgentRole, TeamLifecycle)
|
|
24
|
-
* 2. Pure strategy functions (plan resolution, role assignment, budget allocation)
|
|
25
|
-
* 3. Merge/aggregation policies (how agent results combine)
|
|
26
|
-
*
|
|
27
|
-
* Hub consumes these types and strategy functions in its coordinator runtime.
|
|
28
|
-
* Gateway consumes TeamPlan to spawn/manage multiple sidechain executions.
|
|
29
|
-
*/
|
|
30
|
-
import type { SidechainType, SidechainMergePolicy, SidechainBudgetTier, SidechainToolAccessMode } from "./index.js";
|
|
31
|
-
/** Roles an agent can take within a team execution. */
|
|
32
|
-
export type AgentRole = "planner" | "executor" | "reviewer" | "researcher" | "custom";
|
|
33
|
-
/** Execution mode for a team. */
|
|
34
|
-
export type TeamExecutionMode = "parallel" | "sequential" | "pipeline" | "adaptive";
|
|
35
|
-
/** How team results are aggregated into the parent execution. */
|
|
36
|
-
export type TeamAggregationPolicy = "first-success" | "majority-vote" | "merge-all" | "reviewer-gate" | "planner-sync";
|
|
37
|
-
/** Current lifecycle state of a team execution. */
|
|
38
|
-
export type TeamLifecycleState = "planning" | "spawning" | "executing" | "aggregating" | "reviewing" | "completed" | "failed" | "cancelled";
|
|
39
|
-
/** Specification for a single agent within a team. */
|
|
40
|
-
export interface TeamAgentSpec {
|
|
41
|
-
/** Unique ID within the team (e.g., "agent-1", "researcher-a"). */
|
|
42
|
-
agentId: string;
|
|
43
|
-
/** Role this agent plays. */
|
|
44
|
-
role: AgentRole;
|
|
45
|
-
/** Human-readable label for tracing. */
|
|
46
|
-
label: string;
|
|
47
|
-
/** The sidechain type this agent maps to. */
|
|
48
|
-
sidechainType: SidechainType;
|
|
49
|
-
/** Task description / system prompt override for this agent. */
|
|
50
|
-
taskDescription: string;
|
|
51
|
-
/** Tool access mode for this agent's sidechain. */
|
|
52
|
-
toolAccessMode: SidechainToolAccessMode;
|
|
53
|
-
/** Budget tier for this agent. */
|
|
54
|
-
budgetTier: SidechainBudgetTier;
|
|
55
|
-
/** Which agents this one depends on (for sequential/pipeline modes). */
|
|
56
|
-
dependsOn: string[];
|
|
57
|
-
/** Maximum tokens this agent can consume. */
|
|
58
|
-
maxTokenBudget: number;
|
|
59
|
-
/** Maximum tool calls this agent can make. */
|
|
60
|
-
maxToolCalls: number;
|
|
61
|
-
/** Timeout in milliseconds (0 = inherit from team). */
|
|
62
|
-
timeoutMs: number;
|
|
63
|
-
}
|
|
64
|
-
/** A complete team execution plan. */
|
|
65
|
-
export interface TeamPlan {
|
|
66
|
-
/** Unique team execution ID. */
|
|
67
|
-
teamId: string;
|
|
68
|
-
/** Execution mode for this team. */
|
|
69
|
-
mode: TeamExecutionMode;
|
|
70
|
-
/** How results from all agents are aggregated. */
|
|
71
|
-
aggregationPolicy: TeamAggregationPolicy;
|
|
72
|
-
/** All agent specs in this team. */
|
|
73
|
-
agents: TeamAgentSpec[];
|
|
74
|
-
/** Maximum concurrent agent executions (0 = unlimited). */
|
|
75
|
-
maxConcurrency: number;
|
|
76
|
-
/** Team-level timeout in ms (0 = no timeout). */
|
|
77
|
-
timeoutMs: number;
|
|
78
|
-
/** Total token budget across all agents. */
|
|
79
|
-
totalTokenBudget: number;
|
|
80
|
-
/** Whether early termination is allowed when one agent fails. */
|
|
81
|
-
failFast: boolean;
|
|
82
|
-
/** Shared context provided to all agents. */
|
|
83
|
-
sharedContext: string;
|
|
84
|
-
/** Merge policy for the final team output back to parent. */
|
|
85
|
-
mergePolicy: SidechainMergePolicy;
|
|
86
|
-
}
|
|
87
|
-
/** Result from a single agent within a team. */
|
|
88
|
-
export interface TeamAgentResult {
|
|
89
|
-
agentId: string;
|
|
90
|
-
role: AgentRole;
|
|
91
|
-
status: "completed" | "failed" | "cancelled" | "timeout";
|
|
92
|
-
output: string;
|
|
93
|
-
tokenUsage: {
|
|
94
|
-
prompt: number;
|
|
95
|
-
completion: number;
|
|
96
|
-
};
|
|
97
|
-
toolCallCount: number;
|
|
98
|
-
durationMs: number;
|
|
99
|
-
error?: string;
|
|
100
|
-
}
|
|
101
|
-
/** Aggregated result from team execution. */
|
|
102
|
-
export interface TeamResult {
|
|
103
|
-
teamId: string;
|
|
104
|
-
state: TeamLifecycleState;
|
|
105
|
-
agentResults: TeamAgentResult[];
|
|
106
|
-
aggregatedOutput: string;
|
|
107
|
-
totalTokenUsage: {
|
|
108
|
-
prompt: number;
|
|
109
|
-
completion: number;
|
|
110
|
-
};
|
|
111
|
-
totalDurationMs: number;
|
|
112
|
-
}
|
|
113
|
-
/** Maximum agents allowed in a team (safety bound). */
|
|
114
|
-
export declare const TEAM_MAX_AGENTS = 8;
|
|
115
|
-
/** Maximum recursion depth (teams spawning teams). */
|
|
116
|
-
export declare const TEAM_MAX_DEPTH = 2;
|
|
117
|
-
/**
|
|
118
|
-
* Resolve a team plan from a high-level task decomposition.
|
|
119
|
-
*
|
|
120
|
-
* This is the main entry point: given a set of subtasks and constraints,
|
|
121
|
-
* produce a concrete TeamPlan that the coordinator can execute.
|
|
122
|
-
*/
|
|
123
|
-
export declare function resolveTeamPlan(params: {
|
|
124
|
-
teamId: string;
|
|
125
|
-
subtasks: Array<{
|
|
126
|
-
id: string;
|
|
127
|
-
role: AgentRole;
|
|
128
|
-
label: string;
|
|
129
|
-
task: string;
|
|
130
|
-
dependsOn?: string[];
|
|
131
|
-
}>;
|
|
132
|
-
mode?: TeamExecutionMode;
|
|
133
|
-
aggregationPolicy?: TeamAggregationPolicy;
|
|
134
|
-
totalTokenBudget?: number;
|
|
135
|
-
timeoutMs?: number;
|
|
136
|
-
failFast?: boolean;
|
|
137
|
-
sharedContext?: string;
|
|
138
|
-
mergePolicy?: SidechainMergePolicy;
|
|
139
|
-
}): TeamPlan;
|
|
140
|
-
/**
|
|
141
|
-
* Map agent role to sidechain type for existing Hub plumbing compatibility.
|
|
142
|
-
*/
|
|
143
|
-
export declare function mapRoleToSidechainType(role: AgentRole): SidechainType;
|
|
144
|
-
/**
|
|
145
|
-
* Resolve tool access mode for a given role.
|
|
146
|
-
*/
|
|
147
|
-
export declare function resolveAgentToolAccess(role: AgentRole): SidechainToolAccessMode;
|
|
148
|
-
/**
|
|
149
|
-
* Allocate token budgets proportionally by role weight.
|
|
150
|
-
*/
|
|
151
|
-
export declare function allocateTokenBudgets(agents: TeamAgentSpec[], totalBudget: number): TeamAgentSpec[];
|
|
152
|
-
/**
|
|
153
|
-
* Infer execution mode from agent dependency graph.
|
|
154
|
-
*/
|
|
155
|
-
export declare function inferExecutionMode(agents: TeamAgentSpec[]): TeamExecutionMode;
|
|
156
|
-
/**
|
|
157
|
-
* Infer aggregation policy from mode and agent composition.
|
|
158
|
-
*/
|
|
159
|
-
export declare function inferAggregationPolicy(mode: TeamExecutionMode, agents: TeamAgentSpec[]): TeamAggregationPolicy;
|
|
160
|
-
/**
|
|
161
|
-
* Determine the execution order for agents given their dependency graph.
|
|
162
|
-
* Returns groups of agent IDs that can execute concurrently.
|
|
163
|
-
*
|
|
164
|
-
* Example: [[planner], [executor-a, executor-b], [reviewer]]
|
|
165
|
-
*/
|
|
166
|
-
export declare function resolveExecutionOrder(agents: TeamAgentSpec[]): string[][];
|
|
167
|
-
/**
|
|
168
|
-
* Aggregate team results into a single output string.
|
|
169
|
-
*/
|
|
170
|
-
export declare function aggregateTeamResults(results: TeamAgentResult[], policy: TeamAggregationPolicy): string;
|
|
171
|
-
/**
|
|
172
|
-
* Validate a team plan before execution.
|
|
173
|
-
* Returns a list of issues (empty = valid).
|
|
174
|
-
*/
|
|
175
|
-
export declare function validateTeamPlan(plan: TeamPlan): string[];
|
|
176
|
-
/**
|
|
177
|
-
* Determine if a team execution should be cancelled early based on current state.
|
|
178
|
-
*/
|
|
179
|
-
export declare function shouldCancelTeam(params: {
|
|
180
|
-
plan: TeamPlan;
|
|
181
|
-
results: TeamAgentResult[];
|
|
182
|
-
elapsedMs: number;
|
|
183
|
-
}): {
|
|
184
|
-
cancel: boolean;
|
|
185
|
-
reason: string;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Build the task prompt for a specific agent, incorporating shared context
|
|
189
|
-
* and outputs from dependency agents.
|
|
190
|
-
*/
|
|
191
|
-
export declare function buildAgentTaskPrompt(params: {
|
|
192
|
-
agent: TeamAgentSpec;
|
|
193
|
-
plan: TeamPlan;
|
|
194
|
-
dependencyResults: TeamAgentResult[];
|
|
195
|
-
}): string;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Team Tool Loop Wiring — Connects team orchestration to the tool loop.
|
|
3
|
-
*
|
|
4
|
-
* When the LLM invokes `team_create`, this module:
|
|
5
|
-
* 1. Validates the team plan
|
|
6
|
-
* 2. Maps team agents to fork contexts
|
|
7
|
-
* 3. Coordinates execution according to the team execution mode
|
|
8
|
-
* 4. Aggregates results according to the aggregation policy
|
|
9
|
-
* 5. Returns the aggregated result as a tool_result
|
|
10
|
-
*
|
|
11
|
-
* This bridges the gap between the pure strategy layer (team-orchestration.ts)
|
|
12
|
-
* and the Hub's tool loop.
|
|
13
|
-
*/
|
|
14
|
-
import type { AgentRole, TeamExecutionMode, TeamAggregationPolicy, TeamLifecycleState } from "./team-orchestration.js";
|
|
15
|
-
import type { AgentDefinition } from "./agent-registry.js";
|
|
16
|
-
import type { ForkResult } from "./fork-subagent.js";
|
|
17
|
-
export interface TeamToolRequest {
|
|
18
|
-
/** Team name for identification. */
|
|
19
|
-
name: string;
|
|
20
|
-
/** Agent specs for the team. */
|
|
21
|
-
agents: TeamAgentRequest[];
|
|
22
|
-
/** Execution mode. */
|
|
23
|
-
mode: TeamExecutionMode;
|
|
24
|
-
/** How to aggregate results. */
|
|
25
|
-
aggregation: TeamAggregationPolicy;
|
|
26
|
-
}
|
|
27
|
-
export interface TeamAgentRequest {
|
|
28
|
-
/** Role within the team. */
|
|
29
|
-
role: AgentRole;
|
|
30
|
-
/** Agent type from built-in registry. */
|
|
31
|
-
agentType: string;
|
|
32
|
-
/** Task prompt for this agent. */
|
|
33
|
-
prompt: string;
|
|
34
|
-
/** Max turns override. */
|
|
35
|
-
maxTurns?: number;
|
|
36
|
-
/** Dependencies (agent IDs that must complete before this one). */
|
|
37
|
-
dependsOn?: string[];
|
|
38
|
-
}
|
|
39
|
-
export interface TeamExecutionPlan {
|
|
40
|
-
/** Ordered batches for execution. */
|
|
41
|
-
batches: TeamExecutionBatch[];
|
|
42
|
-
/** Total estimated token budget. */
|
|
43
|
-
totalBudget: number;
|
|
44
|
-
/** Lifecycle state. */
|
|
45
|
-
state: TeamLifecycleState;
|
|
46
|
-
}
|
|
47
|
-
export interface TeamExecutionBatch {
|
|
48
|
-
/** Agents in this batch (run in parallel within a batch). */
|
|
49
|
-
agents: TeamAgentRequest[];
|
|
50
|
-
/** Batch mode (parallel or sequential within the batch). */
|
|
51
|
-
mode: "parallel" | "serial";
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Resolve the execution plan for a team request.
|
|
55
|
-
* Validates the request, resolves dependencies into ordered batches,
|
|
56
|
-
* and determines the execution topology.
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolveTeamExecutionPlan(request: TeamToolRequest): TeamExecutionPlan;
|
|
59
|
-
export interface TeamAggregatedResult {
|
|
60
|
-
/** Whether the team execution succeeded overall. */
|
|
61
|
-
ok: boolean;
|
|
62
|
-
/** Aggregated output text. */
|
|
63
|
-
output: string;
|
|
64
|
-
/** Individual agent results. */
|
|
65
|
-
agentResults: Array<{
|
|
66
|
-
agentId: string;
|
|
67
|
-
role: AgentRole;
|
|
68
|
-
result: ForkResult;
|
|
69
|
-
}>;
|
|
70
|
-
/** Total tokens consumed by all agents. */
|
|
71
|
-
totalTokensUsed: number;
|
|
72
|
-
/** Lifecycle state after aggregation. */
|
|
73
|
-
finalState: TeamLifecycleState;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Aggregate results from team agents according to the aggregation policy.
|
|
77
|
-
*/
|
|
78
|
-
export declare function aggregateTeamToolResults(results: Array<{
|
|
79
|
-
agentId: string;
|
|
80
|
-
role: AgentRole;
|
|
81
|
-
result: ForkResult;
|
|
82
|
-
}>, policy: TeamAggregationPolicy): TeamAggregatedResult;
|
|
83
|
-
/**
|
|
84
|
-
* Map a team tool_call into the format needed for the tool loop to dispatch.
|
|
85
|
-
* Returns the list of fork configs the tool loop should execute.
|
|
86
|
-
*/
|
|
87
|
-
export declare function mapTeamRequestToForkConfigs(request: TeamToolRequest, agentRegistry: (name: string) => AgentDefinition | undefined): Array<{
|
|
88
|
-
agentDef: AgentDefinition;
|
|
89
|
-
prompt: string;
|
|
90
|
-
maxTurns?: number;
|
|
91
|
-
role: AgentRole;
|
|
92
|
-
}>;
|