qlogicagent 0.5.3 → 1.0.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.
Files changed (104) hide show
  1. package/README.md +24 -23
  2. package/dist/agent.js +13 -13
  3. package/dist/cli.js +218 -184
  4. package/dist/contracts.js +1 -1
  5. package/dist/index.js +391 -20
  6. package/dist/orchestration.js +14 -105
  7. package/dist/types/agent/agent.d.ts +1 -1
  8. package/dist/types/agent/constants.d.ts +2 -2
  9. package/dist/types/agent/tool-access.d.ts +30 -0
  10. package/dist/types/agent/tool-loop.d.ts +2 -4
  11. package/dist/types/agent/types.d.ts +51 -13
  12. package/dist/types/cli/main.d.ts +3 -3
  13. package/dist/types/cli/stdio-server.d.ts +89 -7
  14. package/dist/types/cli/tool-bootstrap.d.ts +16 -5
  15. package/dist/types/cli/transport.d.ts +40 -0
  16. package/dist/types/contracts/index.d.ts +0 -1
  17. package/dist/types/contracts/todo.d.ts +9 -0
  18. package/dist/types/index.d.ts +3 -0
  19. package/dist/types/llm/index.d.ts +7 -1
  20. package/dist/types/llm/media-client.d.ts +43 -0
  21. package/dist/types/llm/media-transport.d.ts +80 -0
  22. package/dist/types/llm/model-catalog.d.ts +5 -5
  23. package/dist/types/llm/provider-def.d.ts +7 -0
  24. package/dist/types/llm/provider-registry.d.ts +1 -1
  25. package/dist/types/llm/transport.d.ts +2 -0
  26. package/dist/types/llm/transports/anthropic-messages.d.ts +34 -11
  27. package/dist/types/llm/transports/gemini-media.d.ts +21 -0
  28. package/dist/types/llm/transports/minimax-media.d.ts +21 -0
  29. package/dist/types/llm/transports/openai-chat.d.ts +1 -1
  30. package/dist/types/llm/transports/openai-media.d.ts +24 -0
  31. package/dist/types/llm/transports/qwen-media.d.ts +25 -0
  32. package/dist/types/llm/transports/volcengine-media.d.ts +34 -0
  33. package/dist/types/orchestration/index.d.ts +14 -112
  34. package/dist/types/orchestration/skill-improvement.d.ts +2 -2
  35. package/dist/types/orchestration/{fork-subagent.d.ts → subagent/fork-subagent.d.ts} +2 -4
  36. package/dist/types/orchestration/{tool-schema.d.ts → tool-loop/tool-schema.d.ts} +1 -2
  37. package/dist/types/protocol/index.d.ts +7 -0
  38. package/dist/types/protocol/methods.d.ts +380 -0
  39. package/dist/types/protocol/notifications.d.ts +296 -0
  40. package/dist/types/runtime/execution/dream-agent.d.ts +1 -1
  41. package/dist/types/runtime/execution/forked-agent.d.ts +1 -3
  42. package/dist/types/runtime/hooks/context-compression.d.ts +1 -1
  43. package/dist/types/runtime/infra/agent-paths.d.ts +57 -0
  44. package/dist/types/runtime/infra/checkpoint-backend.d.ts +8 -0
  45. package/dist/types/runtime/infra/disk-storage.d.ts +36 -0
  46. package/dist/types/runtime/infra/file-watcher.d.ts +2 -2
  47. package/dist/types/runtime/infra/index.d.ts +2 -0
  48. package/dist/types/runtime/infra/secure-storage.d.ts +1 -1
  49. package/dist/types/runtime/infra/task-runtime.d.ts +1 -1
  50. package/dist/types/runtime/prompt/environment-context.d.ts +1 -1
  51. package/dist/types/runtime/prompt/instruction-loader.d.ts +6 -6
  52. package/dist/types/runtime/session/index.d.ts +1 -1
  53. package/dist/types/runtime/session/session-memory.d.ts +0 -1
  54. package/dist/types/runtime/session/session-persistence.d.ts +1 -1
  55. package/dist/types/runtime/session/session-state.d.ts +18 -9
  56. package/dist/types/skills/index.d.ts +20 -26
  57. package/dist/types/skills/mcp/mcp-manager.d.ts +3 -4
  58. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +1 -1
  59. package/dist/types/skills/{memory-store.d.ts → memory/memory-store.d.ts} +20 -0
  60. package/dist/types/skills/{memory-tool.d.ts → memory/memory-tool.d.ts} +20 -0
  61. package/dist/types/skills/{qmemory-adapter.d.ts → memory/qmemory-adapter.d.ts} +1 -0
  62. package/dist/types/skills/permissions/hook-runner.d.ts +1 -1
  63. package/dist/types/skills/permissions/settings-watcher.d.ts +2 -2
  64. package/dist/types/skills/plugins/plugin-api.d.ts +1 -1
  65. package/dist/types/skills/plugins/plugin-loader.d.ts +1 -4
  66. package/dist/types/skills/plugins/plugin-marketplace.d.ts +1 -1
  67. package/dist/types/skills/portable-tool.d.ts +34 -1
  68. package/dist/types/skills/todo-tool.d.ts +51 -42
  69. package/dist/types/skills/tools/instructions-tool.d.ts +20 -58
  70. package/dist/types/skills/tools/shell/shell-exec.d.ts +2 -0
  71. package/dist/types/skills/tools/skill-invoke-tool.d.ts +2 -2
  72. package/dist/types/skills/tools.d.ts +65 -0
  73. package/package.json +2 -2
  74. package/dist/types/contracts/skill-candidate.d.ts +0 -63
  75. package/dist/types/orchestration/curator-scheduler.d.ts +0 -119
  76. package/dist/types/orchestration/memory-provider.d.ts +0 -14
  77. package/dist/types/orchestration/skill-candidate.d.ts +0 -52
  78. package/dist/types/orchestration/skill-consolidation.d.ts +0 -123
  79. package/dist/types/orchestration/skill-similarity.d.ts +0 -98
  80. package/dist/types/orchestration/team-orchestration.d.ts +0 -195
  81. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +0 -92
  82. package/dist/types/skills/memory-query-tool.d.ts +0 -43
  83. package/dist/types/skills/tool-registry.d.ts +0 -29
  84. package/dist/types/skills/tools/memory-tool.d.ts +0 -74
  85. package/dist/types/skills/tools/pdf-tool.d.ts +0 -66
  86. /package/dist/types/orchestration/{context-collapse.d.ts → context/context-collapse.d.ts} +0 -0
  87. /package/dist/types/orchestration/{context-compression.d.ts → context/context-compression.d.ts} +0 -0
  88. /package/dist/types/orchestration/{reactive-compact.d.ts → context/reactive-compact.d.ts} +0 -0
  89. /package/dist/types/orchestration/{turn-loop-guard.d.ts → context/turn-loop-guard.d.ts} +0 -0
  90. /package/dist/types/orchestration/{error-classification.d.ts → error-handling/error-classification.d.ts} +0 -0
  91. /package/dist/types/orchestration/{failover-classification.d.ts → error-handling/failover-classification.d.ts} +0 -0
  92. /package/dist/types/orchestration/{failover-error.d.ts → error-handling/failover-error.d.ts} +0 -0
  93. /package/dist/types/orchestration/{retry-loop.d.ts → error-handling/retry-loop.d.ts} +0 -0
  94. /package/dist/types/orchestration/{agent-registry.d.ts → subagent/agent-registry.d.ts} +0 -0
  95. /package/dist/types/orchestration/{task-types.d.ts → subagent/task-types.d.ts} +0 -0
  96. /package/dist/types/orchestration/{conversation-repair.d.ts → tool-loop/conversation-repair.d.ts} +0 -0
  97. /package/dist/types/orchestration/{tool-choice-policy.d.ts → tool-loop/tool-choice-policy.d.ts} +0 -0
  98. /package/dist/types/orchestration/{tool-loop-state.d.ts → tool-loop/tool-loop-state.d.ts} +0 -0
  99. /package/dist/types/skills/{memory-extractor.d.ts → memory/memory-extractor.d.ts} +0 -0
  100. /package/dist/types/skills/{skill-frontmatter.d.ts → skill-system/skill-frontmatter.d.ts} +0 -0
  101. /package/dist/types/skills/{skill-guard.d.ts → skill-system/skill-guard.d.ts} +0 -0
  102. /package/dist/types/skills/{skill-loader.d.ts → skill-system/skill-loader.d.ts} +0 -0
  103. /package/dist/types/skills/{skill-source.d.ts → skill-system/skill-source.d.ts} +0 -0
  104. /package/dist/types/skills/{skill-types.d.ts → skill-system/skill-types.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "0.5.3",
3
+ "version": "1.0.0",
4
4
  "description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "dev": "tsx watch src/index.ts",
33
33
  "build": "node scripts/build.mjs",
34
34
  "build:tsc": "tsc --noCheck",
35
- "start": "node dist/cli/main.js",
35
+ "start": "node dist/cli.js",
36
36
  "test": "vitest run",
37
37
  "test:watch": "vitest",
38
38
  "lint": "oxlint .",
@@ -1,63 +0,0 @@
1
- export declare const SKILL_CANDIDATE_STATUS_VALUES: readonly ["draft", "in_review", "approved", "rejected", "canary", "published", "stale", "superseded", "rolled_back"];
2
- export declare const SKILL_CANDIDATE_ACTION_VALUES: readonly ["submit-review", "approve", "reject", "start-canary", "record-effectiveness", "promote", "publish", "mark-stale", "mark-superseded", "rollback"];
3
- export declare const SKILL_CANDIDATE_EFFECTIVENESS_PHASE_VALUES: readonly ["canary", "published"];
4
- export type SkillCandidateStatus = (typeof SKILL_CANDIDATE_STATUS_VALUES)[number];
5
- export type SkillCandidateAction = (typeof SKILL_CANDIDATE_ACTION_VALUES)[number];
6
- export type SkillCandidateEffectivenessPhase = (typeof SKILL_CANDIDATE_EFFECTIVENESS_PHASE_VALUES)[number];
7
- export type SkillCandidateArtifactContract = {
8
- uri: string;
9
- sha256?: string;
10
- workspaceDir?: string;
11
- relativePath?: string;
12
- sourceWorkspaceDir?: string;
13
- stagedAt?: string;
14
- };
15
- export type SkillCandidateSourceExecutionContract = {
16
- executionId?: string;
17
- rootExecutionId?: string;
18
- parentExecutionId?: string;
19
- sidechainId?: string;
20
- attemptId?: string;
21
- outcomeId?: string;
22
- sessionId?: string;
23
- turnId?: string;
24
- };
25
- export type SkillCandidateReviewContract = {
26
- action: SkillCandidateAction;
27
- actor?: string | null;
28
- notes?: string | null;
29
- payload?: Record<string, unknown>;
30
- createdAt?: string;
31
- };
32
- export type SkillCandidateEffectivenessContract = {
33
- phase: SkillCandidateEffectivenessPhase;
34
- sampleCount: number;
35
- successCount: number;
36
- failureCount: number;
37
- regressionCount: number;
38
- successRate: number;
39
- regressionRate: number;
40
- avgLatencyMs?: number;
41
- avgCostUsd?: number;
42
- score?: number;
43
- staleReason?: string | null;
44
- notes?: string | null;
45
- summary?: Record<string, unknown>;
46
- lastObservedAt?: string;
47
- updatedAt?: string;
48
- /** ISO-8601 timestamp of last skill invocation/view/patch activity. */
49
- lastActivityAt?: string;
50
- /** Cumulative activity count (use + view + patch). */
51
- activityCount?: number;
52
- };
53
- export declare function coerceSkillCandidateJsonObject(value: unknown): Record<string, unknown>;
54
- export declare function isSkillCandidateStatus(value: unknown): value is SkillCandidateStatus;
55
- export declare function isSkillCandidateAction(value: unknown): value is SkillCandidateAction;
56
- export declare function isSkillCandidateEffectivenessPhase(value: unknown): value is SkillCandidateEffectivenessPhase;
57
- export declare function normalizeSkillCandidateStatus(value: unknown, fallback?: SkillCandidateStatus): SkillCandidateStatus;
58
- export declare function normalizeSkillCandidateAction(value: unknown): SkillCandidateAction | null;
59
- export declare function normalizeSkillCandidateEffectivenessPhase(value: unknown): SkillCandidateEffectivenessPhase | null;
60
- export declare function normalizeSkillCandidateArtifact(value: unknown): SkillCandidateArtifactContract | null;
61
- export declare function normalizeSkillCandidateSourceExecution(value: unknown): SkillCandidateSourceExecutionContract | null;
62
- export declare function normalizeSkillCandidateReview(value: unknown): SkillCandidateReviewContract | null;
63
- export declare function normalizeSkillCandidateEffectiveness(value: unknown): SkillCandidateEffectivenessContract | null;
@@ -1,119 +0,0 @@
1
- /**
2
- * Curator scheduler — pure strategy for autonomous skill library
3
- * maintenance. Decides WHEN to run the curator review cycle and
4
- * computes automatic lifecycle transitions (active → stale → archived).
5
- *
6
- * No I/O — all functions are pure; the caller supplies timestamps and
7
- * skill records, and receives transition instructions back.
8
- */
9
- /** Policy knobs for the curator scheduler. */
10
- export interface CuratorSchedulePolicy {
11
- /** Minimum idle seconds before curator may trigger (default: 7200 = 2 h). */
12
- minIdleSeconds: number;
13
- /** Minimum interval between curator runs in seconds (default: 604800 = 7 days). */
14
- intervalSeconds: number;
15
- /** Days without activity before marking a skill stale (default: 30). */
16
- staleAfterDays: number;
17
- /** Days without activity before archiving a stale skill (default: 90). */
18
- archiveAfterDays: number;
19
- /** Maximum skills to process in one LLM review pass (default: 50). */
20
- maxReviewBatchSize: number;
21
- }
22
- export declare const DEFAULT_CURATOR_SCHEDULE_POLICY: CuratorSchedulePolicy;
23
- /** Persistent curator state (stored by the host runtime). */
24
- export interface CuratorState {
25
- /** ISO-8601 timestamp of last curator run. */
26
- lastRunAt: string | null;
27
- /** Duration of last run in seconds. */
28
- lastRunDurationSeconds: number;
29
- /** Human-readable summary of last run. */
30
- lastRunSummary: string;
31
- /** Whether curator is paused by the user. */
32
- paused: boolean;
33
- /** Cumulative run count. */
34
- runCount: number;
35
- }
36
- export declare const INITIAL_CURATOR_STATE: CuratorState;
37
- /** Lifecycle state of an agent-created skill. */
38
- export type CuratorSkillLifecycleState = "active" | "stale" | "archived";
39
- /** Minimal skill activity record consumed by the scheduler. */
40
- export interface CuratorSkillRecord {
41
- /** Skill name / identifier. */
42
- name: string;
43
- /** Whether this skill was agent-created (only these are curated). */
44
- agentCreated: boolean;
45
- /** Current lifecycle state. */
46
- state: CuratorSkillLifecycleState;
47
- /** Whether the user pinned this skill (immune to auto-transitions). */
48
- pinned: boolean;
49
- /** ISO-8601 timestamp of last activity. */
50
- lastActivityAt: string | null;
51
- /** Cumulative use count. */
52
- useCount: number;
53
- /** ISO-8601 timestamp of creation. */
54
- createdAt: string;
55
- }
56
- /** Input for the gate check. */
57
- export interface CuratorGateInput {
58
- /** Current ISO-8601 timestamp. */
59
- now: string;
60
- /** Seconds the session has been idle. */
61
- idleSeconds: number;
62
- /** Current curator state. */
63
- state: CuratorState;
64
- /** Whether the feature is enabled at all. */
65
- enabled: boolean;
66
- /** Policy overrides. */
67
- policy?: Partial<CuratorSchedulePolicy>;
68
- }
69
- /** Result of the gate check: should the curator run? */
70
- export interface CuratorGateResult {
71
- shouldRun: boolean;
72
- reason: string;
73
- }
74
- /**
75
- * Determine whether the curator should run now.
76
- *
77
- * All gates must pass:
78
- * 1. Feature enabled
79
- * 2. Not paused
80
- * 3. Session idle ≥ minIdleSeconds
81
- * 4. Time since last run ≥ intervalSeconds
82
- */
83
- export declare function shouldRunCurator(input: CuratorGateInput): CuratorGateResult;
84
- /** A single lifecycle transition computed by the scheduler. */
85
- export interface CuratorLifecycleTransition {
86
- skillName: string;
87
- from: CuratorSkillLifecycleState;
88
- to: CuratorSkillLifecycleState;
89
- reason: string;
90
- }
91
- /** Summary of all auto-transitions in one pass. */
92
- export interface CuratorAutoTransitionResult {
93
- checked: number;
94
- transitions: CuratorLifecycleTransition[];
95
- markedStale: number;
96
- archived: number;
97
- reactivated: number;
98
- }
99
- /**
100
- * Compute automatic lifecycle transitions for agent-created skills.
101
- *
102
- * Pure function — no I/O, no mutations. The caller applies the
103
- * returned transitions to its skill storage.
104
- *
105
- * Rules:
106
- * - Pinned skills are never transitioned.
107
- * - Non-agent-created skills are skipped.
108
- * - active → stale: no activity for staleAfterDays.
109
- * - stale → archived: no activity for archiveAfterDays.
110
- * - stale/archived → active: if useCount increased (reactivation).
111
- */
112
- export declare function computeLifecycleTransitions(skills: readonly CuratorSkillRecord[], now: string, policy?: Partial<CuratorSchedulePolicy>): CuratorAutoTransitionResult;
113
- /**
114
- * Select skills that should be reviewed by the LLM curator.
115
- *
116
- * Only non-pinned, agent-created skills in active or stale state
117
- * are eligible for review. Returns at most maxReviewBatchSize names.
118
- */
119
- export declare function selectReviewCandidates(skills: readonly CuratorSkillRecord[], policy?: Partial<CuratorSchedulePolicy>): string[];
@@ -1,14 +0,0 @@
1
- import { MEMORY_OBSERVATION_HOOK_VALUES, type MemoryObservationHook, MEMORY_OBSERVATION_SOURCE_VALUES, type MemoryObservationSource, MEMORY_WRITE_ACCESS_VALUES, type MemoryWriteAccess } from "qlogicagent-runtime-contracts";
2
- export { MEMORY_OBSERVATION_HOOK_VALUES, type MemoryObservationHook, MEMORY_OBSERVATION_SOURCE_VALUES, type MemoryObservationSource, MEMORY_WRITE_ACCESS_VALUES, type MemoryWriteAccess, };
3
- export interface MemoryProviderLifecycleInvocation {
4
- hook: MemoryObservationHook;
5
- source: MemoryObservationSource;
6
- sessionId: string;
7
- turnId?: string;
8
- executionId?: string;
9
- rootExecutionId?: string;
10
- parentExecutionId?: string;
11
- sidechainId?: string;
12
- attemptId?: string;
13
- writeAccess: MemoryWriteAccess;
14
- }
@@ -1,52 +0,0 @@
1
- import { type SkillCandidateAction, type SkillCandidateArtifactContract, type SkillCandidateEffectivenessContract, type SkillCandidateReviewContract, type SkillCandidateSourceExecutionContract } from "../contracts/skill-candidate.js";
2
- export type SkillImprovementPolicyContract = {
3
- reviewRequired: boolean;
4
- canaryRequired: boolean;
5
- autoPromote: boolean;
6
- minCanarySampleCount: number;
7
- minSuccessRate: number;
8
- maxRegressionRate: number;
9
- maxCostIncreaseRate: number;
10
- staleAfterHours: number;
11
- };
12
- export type SkillCandidateImprovementEvidenceBundleContract = {
13
- artifact?: SkillCandidateArtifactContract | null;
14
- sourceExecution?: SkillCandidateSourceExecutionContract | null;
15
- sourceSessionKey?: string | null;
16
- diffSummary?: string | null;
17
- baselineCandidateId?: string | null;
18
- rolloutNotes?: string | null;
19
- validationRefs?: string[];
20
- evidence?: Record<string, unknown>;
21
- };
22
- export declare function createDefaultSkillImprovementPolicy(overrides?: Partial<SkillImprovementPolicyContract>): SkillImprovementPolicyContract;
23
- export declare function normalizeSkillImprovementPolicy(value: unknown, fallback?: SkillImprovementPolicyContract): SkillImprovementPolicyContract;
24
- export declare function buildSkillCandidateEvidencePayload(params: {
25
- evidence?: Record<string, unknown> | null;
26
- artifact?: SkillCandidateArtifactContract | null;
27
- sourceExecution?: SkillCandidateSourceExecutionContract | null;
28
- sourceSessionKey?: string | null;
29
- }): Record<string, unknown>;
30
- export declare function buildSkillCandidateImprovementEvidenceBundle(params: SkillCandidateImprovementEvidenceBundleContract): Record<string, unknown>;
31
- export declare function buildSkillCandidateLatestReview(params: {
32
- action: SkillCandidateAction;
33
- actor?: string | null;
34
- notes?: string | null;
35
- payload?: Record<string, unknown> | null;
36
- createdAt?: string;
37
- }): SkillCandidateReviewContract;
38
- export declare function buildSkillCandidateEffectivenessSummary(params: {
39
- phase: "canary" | "published";
40
- sampleCount?: number;
41
- successCount?: number;
42
- failureCount?: number;
43
- regressionCount?: number;
44
- avgLatencyMs?: number;
45
- avgCostUsd?: number;
46
- score?: number;
47
- staleReason?: string | null;
48
- notes?: string | null;
49
- summary?: Record<string, unknown> | null;
50
- lastObservedAt?: string;
51
- updatedAt?: string;
52
- }): SkillCandidateEffectivenessContract;
@@ -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,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,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;