@autorag/librarian 2.2.0 → 2.3.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 (50) hide show
  1. package/README.md +84 -42
  2. package/dist/agent/agent.d.ts +16 -41
  3. package/dist/agent/bash-tool.d.ts +0 -11
  4. package/dist/agent/dupey-tool.d.ts +15 -0
  5. package/dist/agent/emit-results-tool.d.ts +14 -0
  6. package/dist/agent/index.d.ts +1 -0
  7. package/dist/agent/local-model.d.ts +12 -0
  8. package/dist/agent/search-documents.d.ts +1 -1
  9. package/dist/agent/system-prompt.d.ts +1 -2
  10. package/dist/cli/commands/duplicates.d.ts +4 -0
  11. package/dist/cli/commands/health.d.ts +9 -65
  12. package/dist/cli/commands/init.d.ts +1 -1
  13. package/dist/cli/commands/search.d.ts +2 -2
  14. package/dist/cli/config.d.ts +10 -14
  15. package/dist/cli/index.js +10383 -11845
  16. package/dist/datasource/aliased-skill.d.ts +28 -0
  17. package/dist/datasource/chunk-store.d.ts +2 -0
  18. package/dist/datasource/connector-skill.d.ts +3 -0
  19. package/dist/datasource/connector.d.ts +4 -0
  20. package/dist/datasource/crawler-skill.d.ts +6 -0
  21. package/dist/datasource/index.d.ts +2 -0
  22. package/dist/datasource/skills/cloud-drive/index.d.ts +1 -0
  23. package/dist/datasource/skills/cloud-drive/skill.d.ts +14 -0
  24. package/dist/datasource/skills/discrawl/skill.d.ts +3 -0
  25. package/dist/datasource/skills/factory.d.ts +7 -0
  26. package/dist/datasource/skills/gdrive/rclone-connector.d.ts +16 -24
  27. package/dist/datasource/skills/obsidian/skill.d.ts +1 -0
  28. package/dist/dupey/cli.d.ts +40 -0
  29. package/dist/dupey/filter.d.ts +8 -0
  30. package/dist/dupey/index.d.ts +2 -0
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +5063 -6881
  33. package/dist/memory/check-memory-tool.d.ts +1 -0
  34. package/dist/memory/index.d.ts +2 -2
  35. package/dist/memory/memory.d.ts +33 -3
  36. package/dist/memory/renderer.d.ts +2 -1
  37. package/dist/mirror/sync.d.ts +3 -1
  38. package/dist/observability/run-log.d.ts +1 -26
  39. package/dist/process/portable-spawn.d.ts +10 -0
  40. package/package.json +5 -4
  41. package/skills/autorag/SKILL.md +59 -96
  42. package/skills/autorag-setup/SKILL.md +144 -400
  43. package/dist/subagents/contracts.d.ts +0 -90
  44. package/dist/subagents/dispatch-templates.d.ts +0 -104
  45. package/dist/subagents/dispatch-validation.d.ts +0 -169
  46. package/dist/subagents/explorer-tools-extension.d.ts +0 -4
  47. package/dist/subagents/explorer-tools-extension.js +0 -130
  48. package/dist/subagents/local-models.d.ts +0 -14
  49. package/dist/subagents/model-policy.d.ts +0 -31
  50. package/dist/subagents/runtime.d.ts +0 -52
@@ -1,90 +0,0 @@
1
- export declare const RETRIEVAL_METHODS: readonly ["posix", "bash", "posix/bash", "bm25", "minsync", "vector", "minsync/vector", "datasource"];
2
- export type RetrievalMethod = (typeof RETRIEVAL_METHODS)[number];
3
- export type SourceTemporalStatus = "asOf" | "updatedAt" | "createdAt" | "unknown";
4
- export type SourceTemporal = {
5
- readonly status: "asOf";
6
- readonly asOf: string;
7
- } | {
8
- readonly status: "updatedAt";
9
- readonly updatedAt: string;
10
- } | {
11
- readonly status: "createdAt";
12
- readonly createdAt: string;
13
- } | {
14
- readonly status: "unknown";
15
- };
16
- export interface ExplorerAssignment {
17
- readonly originalQuery: string;
18
- readonly method: RetrievalMethod;
19
- readonly queryVariant: string;
20
- /** Optional set of variants retained when an orchestrator fans out work. */
21
- readonly queryVariants?: readonly string[];
22
- }
23
- export interface EvidenceCandidate {
24
- readonly source: string;
25
- readonly method: RetrievalMethod;
26
- readonly evidence: string;
27
- readonly retrievedAt: string;
28
- readonly sourceTemporal: SourceTemporal;
29
- readonly locator?: string;
30
- }
31
- export interface ExplorerReport {
32
- readonly assignment: ExplorerAssignment;
33
- readonly evidenceCandidates: readonly EvidenceCandidate[];
34
- /** Alias for consumers that use the shorter candidate field name. */
35
- readonly candidates?: readonly EvidenceCandidate[];
36
- readonly summary?: string;
37
- }
38
- export interface FollowUpRequest {
39
- readonly reason: string;
40
- readonly assignments: readonly ExplorerAssignment[];
41
- }
42
- export type JudgeDecision = {
43
- readonly decision: "sufficient";
44
- readonly rationale: string;
45
- readonly followUp?: undefined;
46
- } | {
47
- readonly decision: "follow_up";
48
- readonly rationale: string;
49
- readonly followUp: FollowUpRequest;
50
- };
51
- export interface ExhaustionErrorDetails {
52
- readonly code: "EXPLORER_EXHAUSTED";
53
- readonly originalQuery: string;
54
- readonly iterations: number;
55
- readonly maxIterations: number;
56
- readonly reason: string;
57
- }
58
- export type ContractErrorCode = "INVALID_OBJECT" | "MISSING_ORIGINAL_QUERY" | "INVALID_ORIGINAL_QUERY" | "MISSING_RETRIEVAL_METHOD" | "INVALID_RETRIEVAL_METHOD" | "MISSING_QUERY_VARIANT" | "INVALID_QUERY_VARIANT" | "INVALID_QUERY_VARIANTS" | "QUERY_VARIANT_NOT_INCLUDED" | "MISSING_SOURCE" | "INVALID_SOURCE" | "MISSING_EVIDENCE_METHOD" | "INVALID_EVIDENCE_METHOD" | "MISSING_EVIDENCE" | "INVALID_EVIDENCE" | "MISSING_RETRIEVED_AT" | "INVALID_RETRIEVED_AT" | "MISSING_SOURCE_TEMPORAL" | "INVALID_SOURCE_TEMPORAL" | "MISSING_SOURCE_TEMPORAL_DATE" | "INVALID_SOURCE_TEMPORAL_DATE" | "MISSING_ASSIGNMENT" | "MISSING_EVIDENCE_CANDIDATES" | "INVALID_EVIDENCE_CANDIDATES" | "INVALID_SUMMARY" | "MISSING_FOLLOW_UP_REASON" | "INVALID_FOLLOW_UP_REASON" | "MISSING_FOLLOW_UP_ASSIGNMENTS" | "EMPTY_FOLLOW_UP_ASSIGNMENTS" | "INVALID_FOLLOW_UP_ASSIGNMENTS" | "MISSING_JUDGE_DECISION" | "INVALID_JUDGE_DECISION" | "MISSING_JUDGE_RATIONALE" | "INVALID_JUDGE_RATIONALE" | "MISSING_FOLLOW_UP" | "INVALID_FOLLOW_UP" | "INVALID_EXHAUSTION_ERROR" | "INVALID_EXHAUSTION_CODE" | "MISSING_EXHAUSTION_QUERY" | "INVALID_EXHAUSTION_QUERY" | "INVALID_EXHAUSTION_ITERATIONS" | "INVALID_EXHAUSTION_LIMIT" | "MISSING_EXHAUSTION_REASON" | "INVALID_EXHAUSTION_REASON";
59
- export declare class ContractValidationError extends Error {
60
- readonly code: ContractErrorCode;
61
- readonly path?: string;
62
- constructor(code: ContractErrorCode, message: string, path?: string);
63
- }
64
- export declare class ExplorerExhaustionError extends Error {
65
- readonly code: "EXPLORER_EXHAUSTED";
66
- readonly originalQuery: string;
67
- readonly iterations: number;
68
- readonly maxIterations: number;
69
- readonly reason: string;
70
- constructor(details: Omit<ExhaustionErrorDetails, "code">);
71
- toJSON(): ExhaustionErrorDetails;
72
- }
73
- export declare function parseExplorerAssignment(value: unknown): ExplorerAssignment;
74
- export declare function parseEvidenceCandidate(value: unknown): EvidenceCandidate;
75
- export declare function parseExplorerReport(value: unknown): ExplorerReport;
76
- export declare function parseFollowUpRequest(value: unknown): FollowUpRequest;
77
- export declare function parseJudgeDecision(value: unknown): JudgeDecision;
78
- export declare function parseExhaustionError(value: unknown): ExhaustionErrorDetails;
79
- export declare function isExplorerAssignment(value: unknown): value is ExplorerAssignment;
80
- export declare function isEvidenceCandidate(value: unknown): value is EvidenceCandidate;
81
- export declare function isExplorerReport(value: unknown): value is ExplorerReport;
82
- export declare function isFollowUpRequest(value: unknown): value is FollowUpRequest;
83
- export declare function isJudgeDecision(value: unknown): value is JudgeDecision;
84
- export declare function isExhaustionError(value: unknown): value is ExhaustionErrorDetails;
85
- export declare function safeParseExplorerAssignment(value: unknown): ExplorerAssignment | undefined;
86
- export declare function safeParseEvidenceCandidate(value: unknown): EvidenceCandidate | undefined;
87
- export declare function safeParseExplorerReport(value: unknown): ExplorerReport | undefined;
88
- export declare function safeParseFollowUpRequest(value: unknown): FollowUpRequest | undefined;
89
- export declare function safeParseJudgeDecision(value: unknown): JudgeDecision | undefined;
90
- export declare function safeParseExhaustionError(value: unknown): ExhaustionErrorDetails | undefined;
@@ -1,104 +0,0 @@
1
- /**
2
- * Shared dispatch template builders, skeleton literals, and anti-examples for
3
- * AutoRAG explorer subagent dispatch.
4
- *
5
- * This module is the single source of truth for:
6
- * - Assignment V1 sentinel/role-line constants and block builder
7
- * - Single-root and multi-root success dispatch payload builders
8
- * - Compact skeleton literals consumed by `formatBlockReason`
9
- * - Anti-examples for rejected dispatch patterns
10
- * - Stable coded patch-error reference (single source of truth for the error catalog)
11
- *
12
- * `buildSearchPrompt` and prompt tests reuse these builders so no divergent
13
- * template text exists inside TypeScript.
14
- */
15
- export declare const AUTORAG_ASSIGNMENT_V1_START = "<<<AUTORAG_ASSIGNMENT_V1>>>";
16
- export declare const AUTORAG_ASSIGNMENT_V1_END = "<<<END_AUTORAG_ASSIGNMENT_V1>>>";
17
- export declare const AUTORAG_ROLE_LINE_RETRIEVED_AT = "Required handoff: include retrievedAt.";
18
- export declare const AUTORAG_ROLE_LINE_TEMPORAL_METADATA = "Required handoff: include temporal metadata.";
19
- export declare const AUTORAG_CANONICAL_ROLE_LINES = "Required handoff: include retrievedAt.\nRequired handoff: include temporal metadata.";
20
- export declare const PLACEHOLDER_CONFIGURED_MODEL = "<configured-model>";
21
- export declare const PLACEHOLDER_ALLOWED_ROOT = "<allowed-root>";
22
- export declare const PLACEHOLDER_ASSIGNMENT_V1_BLOCK = "<Assignment V1 block>";
23
- export declare const PLACEHOLDER_CALLER_QUERY = "<caller query verbatim>";
24
- export declare const DISPATCH_ADMIN_SKELETON = "{\"action\":\"list\"}";
25
- export declare const DISPATCH_SINGLE_SKELETON = "{\"agentScope\":\"user\",\"artifacts\":false,\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}";
26
- export declare const DISPATCH_FANOUT_SKELETON = "{\"agentScope\":\"user\",\"artifacts\":false,\"tasks\":[{\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}]}";
27
- export interface AssignmentV1Options {
28
- readonly originalQuery: string;
29
- readonly method: string;
30
- readonly queryVariants: readonly string[];
31
- }
32
- /**
33
- * Build a canonical Assignment V1 block string for use as the `task` field
34
- * value in a subagent dispatch payload.
35
- *
36
- * Output shape (LF-joined):
37
- * ```
38
- * <<<AUTORAG_ASSIGNMENT_V1>>>
39
- * {"originalQuery":"...","method":"...","queryVariants":["..."]}
40
- * <<<END_AUTORAG_ASSIGNMENT_V1>>>
41
- * Required handoff: include retrievedAt.
42
- * Required handoff: include temporal metadata.
43
- * ```
44
- */
45
- export declare function buildAssignmentV1Block(opts: AssignmentV1Options): string;
46
- export interface SingleRootDispatchOptions {
47
- readonly explorerModel: string;
48
- readonly allowedRoot: string;
49
- readonly task: string;
50
- }
51
- /**
52
- * Build a single-root success dispatch payload as pretty-printed JSON.
53
- *
54
- * `agentScope` and `artifacts` are set exactly once at the top level.
55
- * The single leaf carries `agent`, `model`, `cwd`, and `task`.
56
- * Pass `PLACEHOLDER_*` constants for prompt examples or real values for
57
- * actual dispatch payloads.
58
- */
59
- export declare function buildSingleRootDispatchPayload(opts: SingleRootDispatchOptions): string;
60
- export interface MultiRootDispatchTask {
61
- readonly explorerModel: string;
62
- readonly allowedRoot: string;
63
- readonly task: string;
64
- }
65
- /**
66
- * Build a multi-root success dispatch payload as pretty-printed JSON.
67
- *
68
- * `agentScope` and `artifacts` are set exactly once at the top level.
69
- * Each task in `tasks` carries `agent`, `model`, `cwd`, and `task` and
70
- * omits `agentScope`/`artifacts`. Pass one task per configured root.
71
- */
72
- export declare function buildMultiRootDispatchPayload(tasks: readonly MultiRootDispatchTask[]): string;
73
- export interface DispatchAntiExample {
74
- readonly label: string;
75
- readonly body: string;
76
- readonly reason: string;
77
- }
78
- /**
79
- * Brief anti-examples showing dispatch patterns that are rejected.
80
- * Each body is pretty-printed JSON using non-sensitive placeholders only.
81
- */
82
- export declare const DISPATCH_ANTIEXAMPLES: readonly DispatchAntiExample[];
83
- export interface DispatchErrorInfo {
84
- readonly code: string;
85
- readonly exactFix: string;
86
- readonly forceCorrectable: boolean;
87
- }
88
- /**
89
- * Reference table of stable dispatch rejection codes, their exactFix strings,
90
- * and forceCorrectable flags. This is the single source of truth for the error
91
- * catalog — `dispatch-validation.ts` derives its `EXACT_FIX_MAP` and
92
- * `FORCE_CORRECTABLE_MAP` from this table so no dual catalog exists.
93
- *
94
- * `DISPATCH_ROLE_METADATA_INVALID` is intentionally absent: valid tasks are
95
- * normalized by `ensureRoleLines` and no rejection path emits that code.
96
- */
97
- export declare const DISPATCH_ERROR_REFERENCE: readonly DispatchErrorInfo[];
98
- /**
99
- * Build the `### Canonical dispatch templates` subsection text for the system
100
- * prompt. Uses the builders and constants above so no divergent template text
101
- * exists. The `explorerModelId` parameter fills the model field in the example
102
- * payloads.
103
- */
104
- export declare function buildDispatchTemplatesPromptSection(explorerModelId: string): string;
@@ -1,169 +0,0 @@
1
- export type DispatchRejectionCode = "DISPATCH_MALFORMED" | "DISPATCH_ACTION_UNKNOWN" | "DISPATCH_ADMIN_MUTATION_FORBIDDEN" | "DISPATCH_CONTROL_FORBIDDEN" | "DISPATCH_SCHEDULE_FORBIDDEN" | "DISPATCH_ARTIFACTS_INVALID" | "DISPATCH_AGENT_SCOPE_INVALID" | "DISPATCH_AGENT_IDENTITY" | "DISPATCH_MODEL_MISMATCH" | "DISPATCH_ASSIGNMENT_INVALID" | "DISPATCH_QUERY_MISMATCH" | "DISPATCH_CWD_MISSING" | "DISPATCH_CWD_OUTSIDE_ROOTS" | "DISPATCH_NO_ACTIVE_QUERY";
2
- export type DispatchKind = "launch" | "admin" | "control" | "mutation" | "schedule" | "hybrid" | "unknown";
3
- export interface DispatchRejection {
4
- readonly code: DispatchRejectionCode;
5
- readonly field: string;
6
- readonly dispatchKind: DispatchKind;
7
- }
8
- export declare class DispatchRejectionError extends Error {
9
- readonly code: DispatchRejectionCode;
10
- readonly field: string;
11
- readonly exactFix: string;
12
- readonly forceCorrectable: boolean;
13
- readonly skeleton: string;
14
- readonly dispatchKind: DispatchKind;
15
- constructor(rejection: DispatchRejection, exactFix: string, forceCorrectable: boolean, skeleton: string);
16
- }
17
- export declare const EXACT_FIX_MAP: Readonly<Record<DispatchRejectionCode, string>>;
18
- export declare const FORCE_CORRECTABLE_MAP: Readonly<Record<DispatchRejectionCode, boolean>>;
19
- /** Backward-compatible aliases for the shared skeleton literals from dispatch-templates.ts. */
20
- export declare const SKELETON_ADMIN = "{\"action\":\"list\"}";
21
- export declare const SKELETON_SINGLE = "{\"agentScope\":\"user\",\"artifacts\":false,\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}";
22
- export declare const SKELETON_FANOUT = "{\"agentScope\":\"user\",\"artifacts\":false,\"tasks\":[{\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}]}";
23
- export declare function formatBlockReason(code: DispatchRejectionCode, field: string, exactFix: string, skeleton: string): string;
24
- export declare function classifyAction(action: unknown): DispatchKind;
25
- /**
26
- * Classify a full dispatch invocation into a dispatch kind.
27
- *
28
- * Classification happens BEFORE any defaults or autofill.
29
- * - If `action` is present and is a mutation/control/schedule → that kind (forbidden-action precedence).
30
- * - If `action` is present and is a diagnostic (exact lowercase) → admin.
31
- * - If `action` is present and is an explicit execution alias (exact lowercase: single/parallel/tasks) with launch shape → launch.
32
- * - If `action` is present but is non-string, unknown, or a non-exact-lowercase value
33
- * (e.g. "Create", "LIST", "Interrupt", 42) → unknown, regardless of launch fields.
34
- * - If no `action` property but launch shape fields present (agent/task/tasks/chain/parallel) → launch.
35
- * - Otherwise → unknown.
36
- */
37
- export declare function classifyDispatch(args: unknown): DispatchKind;
38
- /**
39
- * Validate a diagnostic invocation against its exact allowed field set.
40
- * Returns a DispatchRejection if invalid, undefined if valid.
41
- * Diagnostics bypass explorer assignment/root/model launch gates.
42
- */
43
- export declare function validateDiagnostic(args: Record<string, unknown>, action: string): DispatchRejection | undefined;
44
- export declare function rejectForbiddenAction(action: string): DispatchRejection;
45
- export interface PrepareContext {
46
- /** Configured explorer model wire id (e.g. "provider/model-id"). */
47
- readonly configuredModel: string | undefined;
48
- }
49
- export interface PrepareResult {
50
- /** Normalized args (defaults filled for launch, null-deleted). */
51
- readonly args: Record<string, unknown>;
52
- /** Whether any field was autofilled. */
53
- readonly autofilled: {
54
- readonly artifacts: boolean;
55
- readonly agentScope: boolean;
56
- readonly leafModelFillCount: number;
57
- };
58
- }
59
- /**
60
- * Composed prepareArguments for the subagent tool.
61
- *
62
- * Classifies first, then applies launch-only normalization (null-delete + missing defaults).
63
- * Diagnostics never receive artifacts/agentScope/model defaults.
64
- * Throws DispatchRejectionError on any validation failure.
65
- */
66
- export declare function autoragPrepare(rawArgs: unknown, ctx: PrepareContext): Record<string, unknown>;
67
- export declare function readAutofilled(args: Record<string, unknown>): {
68
- readonly artifacts: boolean;
69
- readonly agentScope: boolean;
70
- readonly leafModelFillCount: number;
71
- } | undefined;
72
- interface LaunchLeaf {
73
- readonly record: Record<string, unknown>;
74
- readonly path: string;
75
- }
76
- export declare function getLaunchLeaves(args: Record<string, unknown>): readonly LaunchLeaf[];
77
- /**
78
- * Create a DispatchRejectionError from a DispatchRejection with proper
79
- * exactFix, forceCorrectable, and skeleton selection.
80
- * Used by beforeToolCall for post-schema rejections.
81
- *
82
- * When `args` is provided and the rejection is a launch kind, the skeleton is
83
- * selected from the args shape: fanout if `tasks`/`chain`/`parallel` are
84
- * present, single otherwise. When `args` is omitted, launch rejections default
85
- * to the single skeleton. Non-launch kinds always use the admin skeleton.
86
- */
87
- export declare function createDispatchRejectionError(rejection: DispatchRejection, args?: Record<string, unknown>): DispatchRejectionError;
88
- /** Backward-compatible aliases for shared V1 sentinel constants. */
89
- export declare const AUTORAG_ASSIGNMENT_V1_START = "<<<AUTORAG_ASSIGNMENT_V1>>>";
90
- export declare const AUTORAG_ASSIGNMENT_V1_END = "<<<END_AUTORAG_ASSIGNMENT_V1>>>";
91
- export interface ParsedAssignment {
92
- readonly originalQuery: string;
93
- readonly method: string;
94
- readonly queryVariants: readonly string[];
95
- /** Whether V1 (true) or legacy (false) format was used. */
96
- readonly isV1: boolean;
97
- }
98
- /** Backward-compatible aliases for shared role line constants. */
99
- export declare const ROLE_LINE_RETRIEVED_AT = "Required handoff: include retrievedAt.";
100
- export declare const ROLE_LINE_TEMPORAL_METADATA = "Required handoff: include temporal metadata.";
101
- export declare function canonicalRoleLines(): string;
102
- /**
103
- * Parse a task string as an Assignment V1 block.
104
- *
105
- * V1 sentinels:
106
- * - Start line (after stripping single trailing CR) must equal <<<AUTORAG_ASSIGNMENT_V1>>>
107
- * - End line (after stripping single trailing CR) must equal <<<END_AUTORAG_ASSIGNMENT_V1>>>
108
- * - End sentinel at EOF valid
109
- * - Exactly one V1 block; duplicate/malformed/unterminated → reject
110
- * - Body: one JSON object with exactly keys originalQuery, method, queryVariants
111
- * - originalQuery: string, trimmed nonempty
112
- * - method: string, trimmed nonempty
113
- * - queryVariants: nonempty array of nonempty strings
114
- * - Extra/missing keys/wrong types → reject
115
- *
116
- * Returns undefined if no V1 sentinel found (caller should try legacy).
117
- * Returns ParsedAssignment on success.
118
- * Throws DispatchRejectionError on malformed V1.
119
- */
120
- export declare function parseAssignmentV1(task: string): ParsedAssignment | undefined;
121
- /**
122
- * Parse a task string as a legacy prose assignment.
123
- *
124
- * Legacy (n4 retained):
125
- * - Full logical lines; optional leading whitespace; optional `- ` bullet; optional matching `**` around label.
126
- * - Case/space normalize labels; value = remainder of same line only.
127
- * - Labels: Original query; Selected retrieval method | Retrieval method; Query variants | Query variant.
128
- * - Reorder OK; exactly once each; Query variants split on `;`, trim, reject empty segments.
129
- * - Later label-looking line → reject.
130
- * - Prefix/suffix outside three lines preserved.
131
- * - Multiline / special / label-looking content inside values → V1 required, not legacy.
132
- *
133
- * Returns undefined if no legacy labels found.
134
- * Throws DispatchRejectionError on malformed legacy.
135
- */
136
- export declare function parseLegacyAssignment(task: string): ParsedAssignment | undefined;
137
- /**
138
- * Parse a task string as either V1 or legacy assignment.
139
- * Tries V1 first; if no V1 sentinels, tries legacy.
140
- * Returns undefined if neither format is found.
141
- * Throws DispatchRejectionError on malformed input.
142
- */
143
- export declare function parseAssignment(task: string): ParsedAssignment | undefined;
144
- /**
145
- * Insert canonical role lines into a task string, byte-idempotent.
146
- *
147
- * 1. Remove all existing exact canonical role lines (the two literals after CR-strip).
148
- * 2. Insert exactly one of each immediately after end sentinel (V1) or
149
- * immediately after the last of the three recognized legacy label lines.
150
- * 3. Preserve all other suffix bytes and original newline style.
151
- * 4. Repeat rendering is byte-idempotent.
152
- */
153
- export declare function ensureRoleLines(task: string): string;
154
- export interface PostSchemaContext {
155
- readonly configuredModel: string | undefined;
156
- readonly currentQuery: string | undefined;
157
- readonly allowedRoots: readonly string[];
158
- readonly workspaceRoot: string;
159
- }
160
- /**
161
- * Post-schema validation for launch invocations.
162
- * Checks: assignment parse, structural query equality, role lines,
163
- * cwd realpath/allowed roots, model match.
164
- *
165
- * Returns a DispatchRejection if invalid, undefined if valid.
166
- * Also normalizes cwd to canonical realpath on success.
167
- */
168
- export declare function validateLaunchPostSchema(args: Record<string, unknown>, ctx: PostSchemaContext): DispatchRejection | undefined;
169
- export {};
@@ -1,4 +0,0 @@
1
- import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- type ExplorerToolRegistrar = Pick<ExtensionAPI, "registerTool">;
3
- export default function registerExplorerTools(pi: ExplorerToolRegistrar): void;
4
- export {};
@@ -1,130 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
-
19
- // src/subagents/explorer-tools-extension.ts
20
- import { realpath, stat } from "node:fs/promises";
21
- import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
22
- import {
23
- createFindToolDefinition,
24
- createGrepToolDefinition,
25
- createLsToolDefinition,
26
- createReadToolDefinition
27
- } from "@earendil-works/pi-coding-agent";
28
- var PARENT_TRAVERSAL_SEGMENT = /(^|[/\\])\.\.($|[/\\])/;
29
- var TOOL_METADATA_CWD = "/";
30
-
31
- class ExplorerPathContainmentError extends Error {
32
- code;
33
- requestedPath;
34
- root;
35
- constructor(message, requestedPath, root) {
36
- super(message);
37
- this.name = "ExplorerPathContainmentError";
38
- this.code = "EXPLORER_PATH_CONTAINMENT";
39
- this.requestedPath = requestedPath;
40
- this.root = root;
41
- }
42
- }
43
- function isMissingPathError(error) {
44
- return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
45
- }
46
- function isEqualOrDescendant(root, target) {
47
- const pathFromRoot = relative(root, target);
48
- return pathFromRoot === "" || pathFromRoot !== ".." && !pathFromRoot.startsWith(`..${sep}`) && !isAbsolute(pathFromRoot);
49
- }
50
- async function resolveExistingTargetOrNearestParent(target) {
51
- try {
52
- return await realpath(target);
53
- } catch (error) {
54
- if (!isMissingPathError(error))
55
- throw error;
56
- }
57
- let candidateParent = dirname(target);
58
- while (true) {
59
- try {
60
- const realParent = await realpath(candidateParent);
61
- return resolve(realParent, relative(candidateParent, target));
62
- } catch (error) {
63
- if (!isMissingPathError(error))
64
- throw error;
65
- const nextParent = dirname(candidateParent);
66
- if (nextParent === candidateParent)
67
- throw error;
68
- candidateParent = nextParent;
69
- }
70
- }
71
- }
72
- async function resolveExplorerRoot(cwd) {
73
- const root = await realpath(cwd);
74
- if (!(await stat(root)).isDirectory()) {
75
- throw new Error(`Explorer assigned cwd is not a directory: ${cwd}`);
76
- }
77
- return root;
78
- }
79
- async function resolveContainedPath(root, requestedPath) {
80
- if (PARENT_TRAVERSAL_SEGMENT.test(requestedPath)) {
81
- throw new ExplorerPathContainmentError(`Explorer filesystem containment rejected parent traversal path: ${requestedPath}`, requestedPath, root);
82
- }
83
- const target = await resolveExistingTargetOrNearestParent(resolve(root, requestedPath));
84
- if (!isEqualOrDescendant(root, target)) {
85
- throw new ExplorerPathContainmentError(`Explorer filesystem containment rejected path outside assigned cwd: ${requestedPath}`, requestedPath, root);
86
- }
87
- return { root, target };
88
- }
89
- function registerExplorerTools(pi) {
90
- let pinnedRoot;
91
- const getPinnedRoot = (cwd) => {
92
- pinnedRoot ??= resolveExplorerRoot(cwd);
93
- return pinnedRoot;
94
- };
95
- const readTool = createReadToolDefinition(TOOL_METADATA_CWD);
96
- pi.registerTool({
97
- ...readTool,
98
- async execute(toolCallId, params, signal, onUpdate, ctx) {
99
- const { root, target } = await resolveContainedPath(await getPinnedRoot(ctx.cwd), params.path);
100
- return createReadToolDefinition(root).execute(toolCallId, { ...params, path: target }, signal, onUpdate, ctx);
101
- }
102
- });
103
- const grepTool = createGrepToolDefinition(TOOL_METADATA_CWD);
104
- pi.registerTool({
105
- ...grepTool,
106
- async execute(toolCallId, params, signal, onUpdate, ctx) {
107
- const { root, target } = await resolveContainedPath(await getPinnedRoot(ctx.cwd), params.path ?? ".");
108
- return createGrepToolDefinition(root).execute(toolCallId, { ...params, path: target }, signal, onUpdate, ctx);
109
- }
110
- });
111
- const findTool = createFindToolDefinition(TOOL_METADATA_CWD);
112
- pi.registerTool({
113
- ...findTool,
114
- async execute(toolCallId, params, signal, onUpdate, ctx) {
115
- const { root, target } = await resolveContainedPath(await getPinnedRoot(ctx.cwd), params.path ?? ".");
116
- return createFindToolDefinition(root).execute(toolCallId, { ...params, path: target }, signal, onUpdate, ctx);
117
- }
118
- });
119
- const lsTool = createLsToolDefinition(TOOL_METADATA_CWD);
120
- pi.registerTool({
121
- ...lsTool,
122
- async execute(toolCallId, params, signal, onUpdate, ctx) {
123
- const { root, target } = await resolveContainedPath(await getPinnedRoot(ctx.cwd), params.path ?? ".");
124
- return createLsToolDefinition(root).execute(toolCallId, { ...params, path: target }, signal, onUpdate, ctx);
125
- }
126
- });
127
- }
128
- export {
129
- registerExplorerTools as default
130
- };
@@ -1,14 +0,0 @@
1
- import type { Model } from "@earendil-works/pi-ai";
2
- export interface LocalAutoRAGModels {
3
- readonly provider: string;
4
- readonly apiKey: string;
5
- readonly orchestrator: Model<"openai-responses">;
6
- readonly explorer: Model<"openai-responses">;
7
- }
8
- export interface LoadLocalAutoRAGModelsOptions {
9
- readonly configPath?: string;
10
- readonly env?: Readonly<Record<string, string | undefined>>;
11
- readonly orchestratorModelId?: string;
12
- readonly explorerModelId?: string;
13
- }
14
- export declare function loadLocalAutoRAGModels(options?: LoadLocalAutoRAGModelsOptions): LocalAutoRAGModels;
@@ -1,31 +0,0 @@
1
- export declare const ORCHESTRATOR_MODEL_ID: "gpt-5.6-sol";
2
- export declare const EXPLORER_MODEL_ID: "gpt-5.6-luna";
3
- export declare const REQUIRED_MODEL_IDS: Readonly<{
4
- orchestrator: "gpt-5.6-sol";
5
- explorer: "gpt-5.6-luna";
6
- }>;
7
- export type ModelRole = keyof typeof REQUIRED_MODEL_IDS;
8
- export interface ModelReference {
9
- readonly id: string;
10
- readonly provider?: string;
11
- }
12
- export interface ValidatedModelPolicy {
13
- readonly orchestrator: ModelReference;
14
- readonly explorer: ModelReference;
15
- }
16
- export type ModelPolicyErrorCode = "INVALID_POLICY_OBJECT" | "MISSING_REQUIRED_MODEL" | "INVALID_MODEL_REFERENCE";
17
- export declare class ModelPolicyError extends Error {
18
- readonly code: ModelPolicyErrorCode;
19
- readonly role?: ModelRole;
20
- readonly expected?: string;
21
- readonly actual?: string;
22
- constructor(code: ModelPolicyErrorCode, message: string, options?: {
23
- readonly role?: ModelRole;
24
- readonly expected?: string;
25
- readonly actual?: string;
26
- });
27
- }
28
- export declare function validateModelPolicy(value: unknown): ValidatedModelPolicy;
29
- export declare function assertModelPolicy(value: unknown): asserts value is ValidatedModelPolicy;
30
- export declare function isModelPolicy(value: unknown): value is ValidatedModelPolicy;
31
- export declare function requiredModelId(role: ModelRole): string;
@@ -1,52 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { type Api, type Model } from "@earendil-works/pi-ai";
3
- import { type AgentSession } from "@earendil-works/pi-coding-agent";
4
- export declare const EXPLORER_TOOLS_EXTENSION_PATH: string;
5
- export declare const AUTORAG_EXPLORER_AGENT_MANAGED_VERSION = 2;
6
- export declare const AUTORAG_EXPLORER_AGENT_DEFINITION: string;
7
- export interface MandatorySubagentSessionOptions {
8
- readonly cwd: string;
9
- readonly model: Model<Api>;
10
- readonly explorerModel?: Model<Api>;
11
- readonly systemPrompt: string;
12
- readonly tools: readonly AgentTool[];
13
- readonly extensionPath?: string;
14
- readonly apiKey?: string;
15
- readonly providerApiKeys?: Readonly<Record<string, string>>;
16
- readonly agentDir?: string;
17
- readonly sessionDir?: string;
18
- }
19
- export interface MandatorySubagentSession {
20
- readonly session: AgentSession;
21
- readonly extensionPath: string;
22
- }
23
- export interface HealthSubagentProbeSessionOptions {
24
- readonly cwd: string;
25
- readonly model: Model<Api>;
26
- readonly explorerModel?: Model<Api>;
27
- readonly systemPrompt: string;
28
- readonly tools: readonly AgentTool[];
29
- readonly extensionPath?: string;
30
- readonly apiKey?: string;
31
- readonly providerApiKeys?: Readonly<Record<string, string>>;
32
- readonly agentDir: string;
33
- readonly sessionDir: string;
34
- }
35
- export interface HealthSubagentProbeSession {
36
- readonly session: AgentSession;
37
- readonly extensionPath: string;
38
- readonly dispose: () => void;
39
- }
40
- export declare function createMandatorySubagentSession(options: MandatorySubagentSessionOptions): Promise<MandatorySubagentSession>;
41
- /**
42
- * Create a short-lived subagent session for the `autorag health` explorer probe.
43
- *
44
- * Unlike {@link createMandatorySubagentSession}, this requires absolute
45
- * `agentDir` and `sessionDir` (typically under a caller-created temp
46
- * directory) so the probe never touches durable home state. On a lease
47
- * conflict — i.e. when another live session holds a different child
48
- * environment/registry routing — the error is rethrown with a stable
49
- * "concurrent AutoRAG session busy" message so the health command can map
50
- * it to `subagent_failed`.
51
- */
52
- export declare function createHealthSubagentProbeSession(options: HealthSubagentProbeSessionOptions): Promise<HealthSubagentProbeSession>;