flavor-code 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1081 -0
- package/dist/agent/loop.d.ts +31 -0
- package/dist/agent/message-queue.d.ts +19 -0
- package/dist/agent/planner.d.ts +28 -0
- package/dist/agent/subagents.d.ts +50 -0
- package/dist/agent/task-plan.d.ts +60 -0
- package/dist/agent/task-tools.d.ts +11 -0
- package/dist/agent/types.d.ts +117 -0
- package/dist/app-WC2XXGLM.js +3185 -0
- package/dist/app-WC2XXGLM.js.map +1 -0
- package/dist/auth/oauth-config.d.ts +4 -0
- package/dist/auth/oauth.d.ts +21 -0
- package/dist/auth/store.d.ts +15 -0
- package/dist/auth/types.d.ts +33 -0
- package/dist/chunk-BU64GNXE.js +15771 -0
- package/dist/chunk-BU64GNXE.js.map +1 -0
- package/dist/chunk-DM64TM4Z.js +124 -0
- package/dist/chunk-DM64TM4Z.js.map +1 -0
- package/dist/chunk-JZ322RCJ.js +40 -0
- package/dist/chunk-JZ322RCJ.js.map +1 -0
- package/dist/chunk-M744K7MK.js +246 -0
- package/dist/chunk-M744K7MK.js.map +1 -0
- package/dist/chunk-MVIMQEQT.js +692 -0
- package/dist/chunk-MVIMQEQT.js.map +1 -0
- package/dist/chunk-VOCZVFP7.js +153 -0
- package/dist/chunk-VOCZVFP7.js.map +1 -0
- package/dist/chunk-XS2JU6S3.js +35557 -0
- package/dist/chunk-XS2JU6S3.js.map +1 -0
- package/dist/claude-ink-ZL4UZMFY.js +27 -0
- package/dist/claude-ink-ZL4UZMFY.js.map +1 -0
- package/dist/cli.js +915 -0
- package/dist/cli.js.map +1 -0
- package/dist/codeisland/activate.mjs +74 -0
- package/dist/codeisland/bridge.mjs +97 -0
- package/dist/codeisland/flavor-plugin.json +27 -0
- package/dist/config/load.d.ts +19 -0
- package/dist/config/protected-file.d.ts +15 -0
- package/dist/config/schema.d.ts +176 -0
- package/dist/config/secret-envelope.d.ts +8 -0
- package/dist/context/compaction.d.ts +44 -0
- package/dist/context/manager.d.ts +65 -0
- package/dist/context/summarizer.d.ts +15 -0
- package/dist/desktop/main.js +17778 -0
- package/dist/desktop/main.js.map +1 -0
- package/dist/desktop/preload.cjs +90 -0
- package/dist/desktop/preload.cjs.map +1 -0
- package/dist/desktop-renderer/assets/index-C66pDvHs.js +144 -0
- package/dist/desktop-renderer/assets/index-C66pDvHs.js.map +1 -0
- package/dist/desktop-renderer/assets/index-Cm_ktmXm.css +1 -0
- package/dist/desktop-renderer/index.html +16 -0
- package/dist/devtools-SXJBSV2N.js +3 -0
- package/dist/devtools-SXJBSV2N.js.map +1 -0
- package/dist/execution/docker.d.ts +29 -0
- package/dist/execution/factory.d.ts +3 -0
- package/dist/execution/types.d.ts +18 -0
- package/dist/goal/classifier.d.ts +12 -0
- package/dist/goal/orchestrator.d.ts +34 -0
- package/dist/goal/planner.d.ts +9 -0
- package/dist/goal/store.d.ts +9 -0
- package/dist/goal/types.d.ts +190 -0
- package/dist/hallucination/confidence.d.ts +12 -0
- package/dist/hallucination/evidence-ledger.d.ts +29 -0
- package/dist/hallucination/guard.d.ts +27 -0
- package/dist/hallucination/messages.d.ts +10 -0
- package/dist/hallucination/retry-monitor.d.ts +19 -0
- package/dist/hallucination/sliding-window.d.ts +13 -0
- package/dist/hallucination/types.d.ts +49 -0
- package/dist/harness/local.d.ts +54 -0
- package/dist/hooks/bus.d.ts +9 -0
- package/dist/hooks/types.d.ts +105 -0
- package/dist/ide/client.d.ts +35 -0
- package/dist/incidents/reporter.d.ts +38 -0
- package/dist/init/project.d.ts +25 -0
- package/dist/load-WQGNTCHC.js +20 -0
- package/dist/load-WQGNTCHC.js.map +1 -0
- package/dist/loop/budget.d.ts +11 -0
- package/dist/loop/isolation.d.ts +21 -0
- package/dist/loop/orchestrator.d.ts +82 -0
- package/dist/loop/store.d.ts +13 -0
- package/dist/loop/types.d.ts +142 -0
- package/dist/loop/verifier.d.ts +13 -0
- package/dist/mcp/client.d.ts +66 -0
- package/dist/mcp/sdk.d.ts +27 -0
- package/dist/memory/coordinator.d.ts +32 -0
- package/dist/memory/extractor.d.ts +15 -0
- package/dist/memory/intent.d.ts +2 -0
- package/dist/memory/retrieval.d.ts +13 -0
- package/dist/memory/review.d.ts +36 -0
- package/dist/memory/similarity.d.ts +5 -0
- package/dist/memory/store.d.ts +58 -0
- package/dist/memory/types.d.ts +37 -0
- package/dist/models/anthropic.d.ts +24 -0
- package/dist/models/cache-profile.d.ts +23 -0
- package/dist/models/openai.d.ts +24 -0
- package/dist/models/registry.d.ts +16 -0
- package/dist/models/structured.d.ts +75 -0
- package/dist/models/types.d.ts +93 -0
- package/dist/permissions/classifier.d.ts +9 -0
- package/dist/permissions/engine.d.ts +28 -0
- package/dist/plugins/host.d.ts +15 -0
- package/dist/plugins/types.d.ts +136 -0
- package/dist/production.d.ts +59 -0
- package/dist/prompts/system.d.ts +28 -0
- package/dist/rpc/schema.d.ts +61 -0
- package/dist/rpc/server.d.ts +54 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +53 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/session/checkpoint.d.ts +25 -0
- package/dist/session/store.d.ts +154 -0
- package/dist/session/tree.d.ts +31 -0
- package/dist/skills/builtin-loop.d.ts +12 -0
- package/dist/skills/registry.d.ts +47 -0
- package/dist/skills/tool.d.ts +9 -0
- package/dist/sleep/organizer.d.ts +37 -0
- package/dist/tools/ask-user-question.d.ts +49 -0
- package/dist/tools/file-diff.d.ts +9 -0
- package/dist/tools/files.d.ts +49 -0
- package/dist/tools/lsp.d.ts +77 -0
- package/dist/tools/managed.d.ts +59 -0
- package/dist/tools/runtime.d.ts +58 -0
- package/dist/tools/search.d.ts +76 -0
- package/dist/tools/shell.d.ts +37 -0
- package/dist/tools/task-output.d.ts +53 -0
- package/dist/tools/todo-write.d.ts +35 -0
- package/dist/tools/types.d.ts +56 -0
- package/dist/trace/recorder.d.ts +14 -0
- package/dist/trace/replay.d.ts +3 -0
- package/dist/trace/schema.d.ts +26 -0
- package/dist/ui/commands.d.ts +67 -0
- package/dist/ui/session.d.ts +126 -0
- package/dist/ui/transcript.d.ts +89 -0
- package/dist/utils/async.d.ts +5 -0
- package/dist/utils/envUtils.d.ts +1 -0
- package/dist/utils/error.d.ts +2 -0
- package/dist/utils/execFileNoThrow.d.ts +13 -0
- package/dist/utils/intl.d.ts +18 -0
- package/dist/utils/json.d.ts +44 -0
- package/dist/utils/log.d.ts +28 -0
- package/dist/utils/redact.d.ts +10 -0
- package/dist/utils/usage-summary.d.ts +34 -0
- package/dist/utils/version.d.ts +6 -0
- package/package.json +124 -0
- package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +4797 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FileHandle } from "node:fs/promises";
|
|
2
|
+
export type SkillSource = "global" | "project";
|
|
3
|
+
export interface SkillMetadata {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly source: SkillSource;
|
|
7
|
+
readonly root: string;
|
|
8
|
+
readonly disableModelInvocation: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SkillDiagnostic {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
}
|
|
14
|
+
export type SkillSelector = (query: string, candidates: readonly SkillMetadata[]) => string | undefined | Promise<string | undefined>;
|
|
15
|
+
export type SkillResourceAuthorizer = (path: string, skill: SkillMetadata) => boolean | Promise<boolean>;
|
|
16
|
+
export type SkillFileOpener = (path: string, flags: number) => Promise<FileHandle>;
|
|
17
|
+
export type SkillResourceKind = "asset" | "reference" | "script";
|
|
18
|
+
export interface ResolvedSkillResource {
|
|
19
|
+
readonly displayPath: string;
|
|
20
|
+
readonly kind: SkillResourceKind;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly skill: Readonly<Pick<SkillMetadata, "name" | "source">>;
|
|
23
|
+
}
|
|
24
|
+
export interface SkillRegistryOptions {
|
|
25
|
+
globalRoots?: readonly string[];
|
|
26
|
+
projectRoots?: readonly string[];
|
|
27
|
+
selector?: SkillSelector;
|
|
28
|
+
authorizeResource?: SkillResourceAuthorizer;
|
|
29
|
+
maxMetadataBytes?: number;
|
|
30
|
+
maxBodyBytes?: number;
|
|
31
|
+
maxResourceBytes?: number;
|
|
32
|
+
openFile?: SkillFileOpener;
|
|
33
|
+
disabledNames?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
export declare class SkillRegistry {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(options?: SkillRegistryOptions);
|
|
38
|
+
get diagnostics(): readonly SkillDiagnostic[];
|
|
39
|
+
setDisabledNames(names: readonly string[]): void;
|
|
40
|
+
refresh(): Promise<readonly SkillMetadata[]>;
|
|
41
|
+
discover(): Promise<readonly SkillMetadata[]>;
|
|
42
|
+
match(query: string): Promise<SkillMetadata | undefined>;
|
|
43
|
+
loadBody(skill: SkillMetadata): Promise<string>;
|
|
44
|
+
resolveResource(skill: SkillMetadata, reference: string): Promise<ResolvedSkillResource>;
|
|
45
|
+
readResource(capability: ResolvedSkillResource): Promise<Buffer>;
|
|
46
|
+
readTextResource(capability: ResolvedSkillResource): Promise<string>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "../tools/types.js";
|
|
3
|
+
import type { SkillRegistry } from "./registry.js";
|
|
4
|
+
declare const SkillResourceInput: z.ZodObject<{
|
|
5
|
+
skill: z.ZodString;
|
|
6
|
+
reference: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export declare function createSkillResourceTool(registry: SkillRegistry): ToolDefinition<z.infer<typeof SkillResourceInput>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SessionStore } from "../session/store.js";
|
|
2
|
+
export type SleepOrganizeResult = {
|
|
3
|
+
status: "no-sessions" | "exists" | "locked";
|
|
4
|
+
date: string;
|
|
5
|
+
} | {
|
|
6
|
+
status: "written";
|
|
7
|
+
date: string;
|
|
8
|
+
path: string;
|
|
9
|
+
sessionCount: number;
|
|
10
|
+
};
|
|
11
|
+
export interface ProjectSleepOrganizerOptions {
|
|
12
|
+
workspace: string;
|
|
13
|
+
sessions?: SessionStore;
|
|
14
|
+
generate(prompt: string, signal: AbortSignal): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export interface ProjectSleepSchedulerOptions {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
organize(date: string, signal: AbortSignal): Promise<unknown>;
|
|
19
|
+
catchUpDates?: (signal: AbortSignal) => Promise<readonly string[]>;
|
|
20
|
+
retryDelayMs?: number;
|
|
21
|
+
now?: () => Date;
|
|
22
|
+
onError?: (error: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function localDateKey(date: Date): string;
|
|
25
|
+
export declare function previousLocalDateKey(date: Date): string;
|
|
26
|
+
export declare class ProjectSleepOrganizer {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(options: ProjectSleepOrganizerOptions);
|
|
29
|
+
organize(date: string, signal?: AbortSignal): Promise<SleepOrganizeResult>;
|
|
30
|
+
pendingDates(beforeDate: string): Promise<string[]>;
|
|
31
|
+
}
|
|
32
|
+
export declare class ProjectSleepScheduler {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(options: ProjectSleepSchedulerOptions);
|
|
35
|
+
start(): void;
|
|
36
|
+
dispose(): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
declare const QuestionSchema: z.ZodObject<{
|
|
4
|
+
question: z.ZodString;
|
|
5
|
+
header: z.ZodString;
|
|
6
|
+
options: z.ZodArray<z.ZodObject<{
|
|
7
|
+
label: z.ZodString;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
declare const AskUserQuestionInput: z.ZodObject<{
|
|
12
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
13
|
+
question: z.ZodString;
|
|
14
|
+
header: z.ZodString;
|
|
15
|
+
options: z.ZodArray<z.ZodObject<{
|
|
16
|
+
label: z.ZodString;
|
|
17
|
+
description: z.ZodString;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type AskUserQuestionInput = z.infer<typeof AskUserQuestionInput>;
|
|
22
|
+
export type Question = z.infer<typeof QuestionSchema>;
|
|
23
|
+
export interface AskUserQuestionHandler {
|
|
24
|
+
(questions: readonly Question[], signal: AbortSignal): Promise<Record<number, string>>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extracts answers a hook-relayed UI (e.g. the Flavor Island app) returned for
|
|
28
|
+
* an AskUserQuestion PermissionRequest. The decision's updatedInput carries the
|
|
29
|
+
* re-shaped hook payload, whose `input.answers` is keyed by question text. The
|
|
30
|
+
* result maps question index to answer; anything short of a complete non-empty
|
|
31
|
+
* answer set returns undefined so the terminal prompt remains the fallback.
|
|
32
|
+
*/
|
|
33
|
+
export declare function hookAnswersFromUpdatedInput(updatedInput: unknown, questions: readonly Question[]): Record<number, string> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* A simple bridge that holds pending questions and resolves when answers arrive.
|
|
36
|
+
* The UI layer polls `pending` to render the question prompts and calls `answer()`
|
|
37
|
+
* when the user responds.
|
|
38
|
+
*/
|
|
39
|
+
export declare class QuestionBridge {
|
|
40
|
+
#private;
|
|
41
|
+
constructor(onChange?: () => void);
|
|
42
|
+
get pending(): readonly Question[] | undefined;
|
|
43
|
+
ask(questions: readonly Question[], signal: AbortSignal): Promise<Record<number, string>>;
|
|
44
|
+
answer(answers: Record<number, string>): void;
|
|
45
|
+
cancel(reason?: string): void;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function createAskUserQuestionTool(handler: AskUserQuestionHandler): ToolDefinition<AskUserQuestionInput>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FileChangePresentation } from "./types.js";
|
|
2
|
+
export declare const MAX_DIFF_PREVIEW_LINES = 120;
|
|
3
|
+
export interface DiffHunkInput {
|
|
4
|
+
oldStart: number;
|
|
5
|
+
newStart: number;
|
|
6
|
+
lines: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function buildFileChangePresentation(path: string, before: string, after: string, operation: "create" | "update"): FileChangePresentation;
|
|
9
|
+
export declare function buildPatchPresentation(path: string, created: boolean, hunks: readonly DiffHunkInput[]): FileChangePresentation;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ToolDefinition } from "./types.js";
|
|
3
|
+
export declare const MAX_READ_BYTES = 1048576;
|
|
4
|
+
declare const ReadInput: z.ZodObject<{
|
|
5
|
+
path: z.ZodString;
|
|
6
|
+
maxBytes: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
7
|
+
startLine: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
8
|
+
endLine: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
9
|
+
force: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString & z.ZodType<"false" | "true", string, z.core.$ZodTypeInternals<"false" | "true", string>>]>>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
declare const WriteInput: z.ZodObject<{
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const EditInput: z.ZodObject<{
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
oldText: z.ZodString;
|
|
18
|
+
newText: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
declare const ApplyPatchInput: z.ZodObject<{
|
|
21
|
+
patch: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export interface ReadFileHandle {
|
|
24
|
+
read(buffer: Buffer, offset: number, length: number, position: number | null): Promise<{
|
|
25
|
+
bytesRead: number;
|
|
26
|
+
}>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface ReadToolOptions {
|
|
30
|
+
openFile?: (path: string) => Promise<ReadFileHandle>;
|
|
31
|
+
}
|
|
32
|
+
export interface FileWriteProposal {
|
|
33
|
+
path: string;
|
|
34
|
+
before: string;
|
|
35
|
+
after: string;
|
|
36
|
+
kind: "create" | "update";
|
|
37
|
+
}
|
|
38
|
+
export interface FileMutationOptions {
|
|
39
|
+
beforeCommit?(proposal: FileWriteProposal, signal: AbortSignal): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export declare function createReadTool(workspace: string, options?: ReadToolOptions): ToolDefinition<z.infer<typeof ReadInput>>;
|
|
42
|
+
export declare function createWriteTool(workspace: string, options?: FileMutationOptions): ToolDefinition<z.infer<typeof WriteInput>>;
|
|
43
|
+
export declare function createEditTool(workspace: string, options?: FileMutationOptions): ToolDefinition<z.infer<typeof EditInput>>;
|
|
44
|
+
export declare function createApplyPatchTool(workspace: string, options?: FileMutationOptions): ToolDefinition<z.infer<typeof ApplyPatchInput>>;
|
|
45
|
+
export declare const createRead: typeof createReadTool;
|
|
46
|
+
export declare const createWrite: typeof createWriteTool;
|
|
47
|
+
export declare const createEdit: typeof createEditTool;
|
|
48
|
+
export declare const createApplyPatch: typeof createApplyPatchTool;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ToolDefinition } from "./types.js";
|
|
2
|
+
interface LspLocation {
|
|
3
|
+
uri: string;
|
|
4
|
+
range: {
|
|
5
|
+
start: {
|
|
6
|
+
line: number;
|
|
7
|
+
character: number;
|
|
8
|
+
};
|
|
9
|
+
end: {
|
|
10
|
+
line: number;
|
|
11
|
+
character: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface LspHover {
|
|
16
|
+
contents: {
|
|
17
|
+
kind: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
value: string;
|
|
20
|
+
} | string;
|
|
21
|
+
range?: {
|
|
22
|
+
start: {
|
|
23
|
+
line: number;
|
|
24
|
+
character: number;
|
|
25
|
+
};
|
|
26
|
+
end: {
|
|
27
|
+
line: number;
|
|
28
|
+
character: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface LspDiagnostic {
|
|
33
|
+
range: {
|
|
34
|
+
start: {
|
|
35
|
+
line: number;
|
|
36
|
+
character: number;
|
|
37
|
+
};
|
|
38
|
+
end: {
|
|
39
|
+
line: number;
|
|
40
|
+
character: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
severity: number;
|
|
44
|
+
message: string;
|
|
45
|
+
source?: string;
|
|
46
|
+
}
|
|
47
|
+
interface LanguageServerConfig {
|
|
48
|
+
language: string;
|
|
49
|
+
extensions: string[];
|
|
50
|
+
command: string;
|
|
51
|
+
args: string[];
|
|
52
|
+
rootFiles: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface LspManager {
|
|
55
|
+
findReferences(uri: string, line: number, character: number): Promise<LspLocation[]>;
|
|
56
|
+
hover(uri: string, line: number, character: number): Promise<LspHover | null>;
|
|
57
|
+
diagnostics(uri: string): Promise<LspDiagnostic[]>;
|
|
58
|
+
dispose(): void;
|
|
59
|
+
}
|
|
60
|
+
export declare class RealLspManager implements LspManager {
|
|
61
|
+
#private;
|
|
62
|
+
constructor(options: {
|
|
63
|
+
workspace: string;
|
|
64
|
+
serverConfigs?: LanguageServerConfig[];
|
|
65
|
+
onStatus?: ((message: string) => void) | undefined;
|
|
66
|
+
});
|
|
67
|
+
dispose(): void;
|
|
68
|
+
findReferences(uri: string, line: number, character: number): Promise<LspLocation[]>;
|
|
69
|
+
hover(uri: string, line: number, character: number): Promise<LspHover | null>;
|
|
70
|
+
diagnostics(uri: string): Promise<LspDiagnostic[]>;
|
|
71
|
+
}
|
|
72
|
+
export interface LspToolOptions {
|
|
73
|
+
manager?: LspManager;
|
|
74
|
+
onStatus?: (message: string) => void;
|
|
75
|
+
}
|
|
76
|
+
export declare function createLspTools(workspace: string, options?: LspToolOptions): ToolDefinition<unknown>[];
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
export declare const RegisterManagedToolInputSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
7
|
+
implementation: z.ZodString;
|
|
8
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
9
|
+
global: "global";
|
|
10
|
+
project: "project";
|
|
11
|
+
}>>;
|
|
12
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
13
|
+
main: "main";
|
|
14
|
+
subagent: "subagent";
|
|
15
|
+
}>>>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export declare const RemoveManagedToolInputSchema: z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
global: "global";
|
|
21
|
+
project: "project";
|
|
22
|
+
}>>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type RegisterManagedToolInput = z.input<typeof RegisterManagedToolInputSchema>;
|
|
25
|
+
export type ManagedToolScope = z.output<typeof RegisterManagedToolInputSchema>["scope"];
|
|
26
|
+
export type RemoveManagedToolInput = z.input<typeof RemoveManagedToolInputSchema>;
|
|
27
|
+
export interface ManagedToolSummary {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly scope: ManagedToolScope;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly createdAt: string;
|
|
33
|
+
readonly agents?: readonly ("main" | "subagent")[];
|
|
34
|
+
readonly active: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ManagedToolStoreOptions {
|
|
37
|
+
workspace: string;
|
|
38
|
+
home: string;
|
|
39
|
+
now?: () => string;
|
|
40
|
+
}
|
|
41
|
+
/** Durable store for agent-authored tools. Managed code is trusted in-process code, like plugins. */
|
|
42
|
+
export declare class ManagedToolStore {
|
|
43
|
+
#private;
|
|
44
|
+
constructor(options: ManagedToolStoreOptions);
|
|
45
|
+
get diagnostics(): readonly string[];
|
|
46
|
+
directory(scope: ManagedToolScope): string;
|
|
47
|
+
load(): Promise<void>;
|
|
48
|
+
definitions(): readonly ToolDefinition<unknown>[];
|
|
49
|
+
list(): readonly ManagedToolSummary[];
|
|
50
|
+
register(rawInput: RegisterManagedToolInput): Promise<ManagedToolSummary>;
|
|
51
|
+
remove(rawInput: RemoveManagedToolInput): Promise<ManagedToolSummary>;
|
|
52
|
+
removalPaths(rawInput: RemoveManagedToolInput): string[];
|
|
53
|
+
}
|
|
54
|
+
export interface ManagedToolManagementOptions {
|
|
55
|
+
store: ManagedToolStore;
|
|
56
|
+
conflict(name: string): string | undefined;
|
|
57
|
+
onChanged(): void | Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export declare function createManagedToolManagementTools(options: ManagedToolManagementOptions): readonly ToolDefinition<unknown>[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { HookBus } from "../hooks/bus.js";
|
|
2
|
+
import { type PermissionEngine, type PermissionRequest, type ToolCategory } from "../permissions/engine.js";
|
|
3
|
+
import type { PermissionClassifier } from "../permissions/classifier.js";
|
|
4
|
+
import { type ToolCall, type ToolContext, type ToolDefinition, type ToolResult } from "./types.js";
|
|
5
|
+
export type ApprovalDecision = "once" | "always" | "deny";
|
|
6
|
+
export type ApprovalCallback = (request: PermissionRequest & {
|
|
7
|
+
reason?: string;
|
|
8
|
+
}, signal: AbortSignal) => ApprovalDecision | Promise<ApprovalDecision>;
|
|
9
|
+
export interface ToolRuntimeOptions {
|
|
10
|
+
tools: readonly ToolDefinition<unknown>[];
|
|
11
|
+
hooks: HookBus;
|
|
12
|
+
permissions: PermissionEngine;
|
|
13
|
+
approve?: ApprovalCallback;
|
|
14
|
+
/** Classifies unresolved main-agent calls in auto mode. Failures fall back to approval. */
|
|
15
|
+
classify?: PermissionClassifier;
|
|
16
|
+
/** Categories that should skip the approval callback. Destructive is never added. */
|
|
17
|
+
alwaysAllowed?: ToolCategory[];
|
|
18
|
+
/** Workspace used for durable overflow files. Defaults to process.cwd(). */
|
|
19
|
+
workspace?: string;
|
|
20
|
+
/** Inline tool-result content budgets. */
|
|
21
|
+
outputLimits?: Partial<ToolOutputLimits>;
|
|
22
|
+
}
|
|
23
|
+
export interface ToolOutputLimits {
|
|
24
|
+
perToolChars: number;
|
|
25
|
+
perTurnChars: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ToolOutputOverflow {
|
|
28
|
+
truncated: true;
|
|
29
|
+
reason: "per_tool_limit" | "turn_limit" | "per_tool_and_turn_limit";
|
|
30
|
+
preview: string;
|
|
31
|
+
originalChars: number;
|
|
32
|
+
previewChars: number;
|
|
33
|
+
savedTo: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const DEFAULT_TOOL_OUTPUT_LIMITS: Readonly<ToolOutputLimits>;
|
|
36
|
+
export type ToolInputValidation = {
|
|
37
|
+
ok: true;
|
|
38
|
+
input: unknown;
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
error: {
|
|
42
|
+
code: "unknown_tool" | "invalid_input";
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare class ToolRuntime {
|
|
47
|
+
#private;
|
|
48
|
+
constructor(options: ToolRuntimeOptions);
|
|
49
|
+
dispose(): void;
|
|
50
|
+
definition(name: string): ToolDefinition<unknown> | undefined;
|
|
51
|
+
replaceTools(tools: readonly ToolDefinition<unknown>[]): void;
|
|
52
|
+
/** Starts the aggregate result budget for one model response's tool calls. */
|
|
53
|
+
beginTurn(): void;
|
|
54
|
+
validate(call: ToolCall): ToolInputValidation;
|
|
55
|
+
label(call: ToolCall): string | undefined;
|
|
56
|
+
hint(call: ToolCall): string | undefined;
|
|
57
|
+
execute(call: ToolCall, context: ToolContext): Promise<ToolResult>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
declare const GlobInput: z.ZodObject<{
|
|
4
|
+
pattern: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
declare const GrepInput: z.ZodObject<{
|
|
9
|
+
pattern: z.ZodString;
|
|
10
|
+
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
glob: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
fileType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
13
|
+
c: "c";
|
|
14
|
+
cpp: "cpp";
|
|
15
|
+
cs: "cs";
|
|
16
|
+
css: "css";
|
|
17
|
+
dart: "dart";
|
|
18
|
+
go: "go";
|
|
19
|
+
html: "html";
|
|
20
|
+
java: "java";
|
|
21
|
+
javascript: "javascript";
|
|
22
|
+
js: "js";
|
|
23
|
+
json: "json";
|
|
24
|
+
kotlin: "kotlin";
|
|
25
|
+
lua: "lua";
|
|
26
|
+
markdown: "markdown";
|
|
27
|
+
md: "md";
|
|
28
|
+
php: "php";
|
|
29
|
+
py: "py";
|
|
30
|
+
python: "python";
|
|
31
|
+
ruby: "ruby";
|
|
32
|
+
rust: "rust";
|
|
33
|
+
sh: "sh";
|
|
34
|
+
sql: "sql";
|
|
35
|
+
swift: "swift";
|
|
36
|
+
text: "text";
|
|
37
|
+
toml: "toml";
|
|
38
|
+
ts: "ts";
|
|
39
|
+
typescript: "typescript";
|
|
40
|
+
xml: "xml";
|
|
41
|
+
yaml: "yaml";
|
|
42
|
+
}>>>;
|
|
43
|
+
context: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
44
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export interface SearchToolOptions {
|
|
47
|
+
forceNode?: boolean;
|
|
48
|
+
rgPath?: string;
|
|
49
|
+
rgArgsPrefix?: string[];
|
|
50
|
+
defaultLimit?: number;
|
|
51
|
+
maxFileBytes?: number;
|
|
52
|
+
maxSearchBytes?: number;
|
|
53
|
+
maxEntriesPerDirectory?: number;
|
|
54
|
+
maxDiscoveredFiles?: number;
|
|
55
|
+
maxIgnoreFileBytes?: number;
|
|
56
|
+
maxTotalIgnoreBytes?: number;
|
|
57
|
+
maxIgnoreLayers?: number;
|
|
58
|
+
maxIgnoreRules?: number;
|
|
59
|
+
maxIgnoreTraversedDirectories?: number;
|
|
60
|
+
maxIgnoreTraversedEntries?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface SearchResult<T> {
|
|
63
|
+
matches: T[];
|
|
64
|
+
truncated: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface GrepMatch {
|
|
67
|
+
path: string;
|
|
68
|
+
line: number;
|
|
69
|
+
column: number;
|
|
70
|
+
text: string;
|
|
71
|
+
before: string[];
|
|
72
|
+
after: string[];
|
|
73
|
+
}
|
|
74
|
+
export declare function createGlobTool(workspace: string, options?: SearchToolOptions): ToolDefinition<z.infer<typeof GlobInput>>;
|
|
75
|
+
export declare function createGrepTool(workspace: string, options?: SearchToolOptions): ToolDefinition<z.infer<typeof GrepInput>>;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
import type { ExecutionEnvironment } from "../execution/types.js";
|
|
4
|
+
export declare const DEFAULT_MAX_OUTPUT_BYTES = 1048576;
|
|
5
|
+
declare const ShellInput: z.ZodObject<{
|
|
6
|
+
command: z.ZodString;
|
|
7
|
+
args: z.ZodArray<z.ZodString>;
|
|
8
|
+
cwd: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
timeoutMs: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export interface ShellToolOptions {
|
|
12
|
+
maxOutputBytes?: number;
|
|
13
|
+
executionEnvironment?: ExecutionEnvironment;
|
|
14
|
+
}
|
|
15
|
+
export interface TruncationMetadata {
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
originalBytes: number;
|
|
18
|
+
limitBytes: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ShellResult {
|
|
21
|
+
exitCode: number | null;
|
|
22
|
+
signal: NodeJS.Signals | null;
|
|
23
|
+
stdout: string;
|
|
24
|
+
stderr: string;
|
|
25
|
+
truncated: boolean;
|
|
26
|
+
truncation: {
|
|
27
|
+
stdout: TruncationMetadata;
|
|
28
|
+
stderr: TruncationMetadata;
|
|
29
|
+
};
|
|
30
|
+
terminationReason: "timeout" | "cancelled" | null;
|
|
31
|
+
}
|
|
32
|
+
type ShellTool = Omit<ToolDefinition<z.infer<typeof ShellInput>>, "execute"> & {
|
|
33
|
+
execute(input: z.infer<typeof ShellInput>, signal: AbortSignal): Promise<ShellResult>;
|
|
34
|
+
};
|
|
35
|
+
export declare function createShellTool(workspace: string, options?: ShellToolOptions): ShellTool;
|
|
36
|
+
export declare function executeShell(root: string, input: z.infer<typeof ShellInput>, cancellation: AbortSignal, maxBytes: number): Promise<ShellResult>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
declare const CommandRunSchema: z.ZodObject<{
|
|
4
|
+
command: z.ZodString;
|
|
5
|
+
exitCode: z.ZodNullable<z.ZodCoercedNumber<unknown>>;
|
|
6
|
+
summary: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
declare const VerificationItemSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
passed: z.ZodBoolean;
|
|
11
|
+
details: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
declare const TaskOutputInput: z.ZodObject<{
|
|
14
|
+
summary: z.ZodString;
|
|
15
|
+
filesChanged: z.ZodArray<z.ZodString>;
|
|
16
|
+
commandsRun: z.ZodArray<z.ZodObject<{
|
|
17
|
+
command: z.ZodString;
|
|
18
|
+
exitCode: z.ZodNullable<z.ZodCoercedNumber<unknown>>;
|
|
19
|
+
summary: z.ZodString;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
verification: z.ZodArray<z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
passed: z.ZodBoolean;
|
|
24
|
+
details: z.ZodString;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
artifacts: z.ZodArray<z.ZodString>;
|
|
27
|
+
risks: z.ZodArray<z.ZodString>;
|
|
28
|
+
suggestedNextSteps: z.ZodArray<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export declare const TaskOutputResultSchema: z.ZodObject<{
|
|
31
|
+
summary: z.ZodString;
|
|
32
|
+
filesChanged: z.ZodArray<z.ZodString>;
|
|
33
|
+
commandsRun: z.ZodArray<z.ZodObject<{
|
|
34
|
+
command: z.ZodString;
|
|
35
|
+
exitCode: z.ZodNullable<z.ZodCoercedNumber<unknown>>;
|
|
36
|
+
summary: z.ZodString;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
verification: z.ZodArray<z.ZodObject<{
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
passed: z.ZodBoolean;
|
|
41
|
+
details: z.ZodString;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
artifacts: z.ZodArray<z.ZodString>;
|
|
44
|
+
risks: z.ZodArray<z.ZodString>;
|
|
45
|
+
suggestedNextSteps: z.ZodArray<z.ZodString>;
|
|
46
|
+
taskCompleted: z.ZodLiteral<true>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type TaskOutputInput = z.infer<typeof TaskOutputInput>;
|
|
49
|
+
export type TaskOutputResult = z.infer<typeof TaskOutputResultSchema>;
|
|
50
|
+
export type CommandRun = z.infer<typeof CommandRunSchema>;
|
|
51
|
+
export type VerificationItem = z.infer<typeof VerificationItemSchema>;
|
|
52
|
+
export declare function createTaskOutputTool(): ToolDefinition<TaskOutputInput>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "./types.js";
|
|
3
|
+
export declare const TodoStatusSchema: z.ZodEnum<{
|
|
4
|
+
cancelled: "cancelled";
|
|
5
|
+
completed: "completed";
|
|
6
|
+
in_progress: "in_progress";
|
|
7
|
+
pending: "pending";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const TodoItemSchema: z.ZodObject<{
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
status: z.ZodEnum<{
|
|
12
|
+
cancelled: "cancelled";
|
|
13
|
+
completed: "completed";
|
|
14
|
+
in_progress: "in_progress";
|
|
15
|
+
pending: "pending";
|
|
16
|
+
}>;
|
|
17
|
+
activeForm: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
declare const TodoWriteInput: z.ZodObject<{
|
|
20
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
21
|
+
content: z.ZodString;
|
|
22
|
+
status: z.ZodEnum<{
|
|
23
|
+
cancelled: "cancelled";
|
|
24
|
+
completed: "completed";
|
|
25
|
+
in_progress: "in_progress";
|
|
26
|
+
pending: "pending";
|
|
27
|
+
}>;
|
|
28
|
+
activeForm: z.ZodString;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type TodoStatus = z.infer<typeof TodoStatusSchema>;
|
|
32
|
+
export type TodoItem = z.infer<typeof TodoItemSchema>;
|
|
33
|
+
export type TodoWriteInput = z.infer<typeof TodoWriteInput>;
|
|
34
|
+
export declare function createTodoWriteTool(): ToolDefinition<TodoWriteInput>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { PermissionRequest } from "../permissions/engine.js";
|
|
3
|
+
export type ToolPermissionMetadata = Omit<PermissionRequest, "agent" | "tool">;
|
|
4
|
+
export interface FileDiffLine {
|
|
5
|
+
kind: "context" | "removed" | "added" | "omitted";
|
|
6
|
+
oldLine?: number;
|
|
7
|
+
newLine?: number;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FileChangePresentation {
|
|
11
|
+
kind: "file-change";
|
|
12
|
+
operation: "create" | "update" | "delete";
|
|
13
|
+
path: string;
|
|
14
|
+
added: number;
|
|
15
|
+
removed: number;
|
|
16
|
+
lines: FileDiffLine[];
|
|
17
|
+
}
|
|
18
|
+
export type ToolPresentation = FileChangePresentation;
|
|
19
|
+
export declare function withToolPresentation<T extends object>(output: T, presentation: ToolPresentation): T;
|
|
20
|
+
export declare function getToolPresentation(output: unknown): ToolPresentation | undefined;
|
|
21
|
+
export interface ToolDefinition<T> {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: z.ZodType<T>;
|
|
25
|
+
/** Restrict a tool to selected agent roles. Omit to expose it to both roles. */
|
|
26
|
+
agents?: readonly ToolContext["agent"][];
|
|
27
|
+
/** Optional provider-facing JSON Schema when it must differ from runtime validation. */
|
|
28
|
+
modelInputSchema?: Record<string, unknown>;
|
|
29
|
+
/** Whether providers should enforce strict function arguments. Defaults to true. */
|
|
30
|
+
modelStrict?: boolean;
|
|
31
|
+
paths(input: T): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Optional short human-readable parameter summary, rendered dimmed next to the tool name.
|
|
34
|
+
* Must return plain text (no ANSI escapes). Return undefined or an empty string to omit the hint.
|
|
35
|
+
*/
|
|
36
|
+
summarize?(input: T): string | undefined;
|
|
37
|
+
permissions?(input: T): ToolPermissionMetadata;
|
|
38
|
+
execute(input: T, signal: AbortSignal): Promise<unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolCall {
|
|
41
|
+
name: string;
|
|
42
|
+
input: unknown;
|
|
43
|
+
}
|
|
44
|
+
export interface ToolContext {
|
|
45
|
+
agent: "main" | "subagent";
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
export interface ToolResult {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
output?: unknown;
|
|
51
|
+
presentation?: ToolPresentation;
|
|
52
|
+
error?: {
|
|
53
|
+
code: string;
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type TraceKind } from "./schema.js";
|
|
2
|
+
export interface TraceRecorderOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
secrets?: readonly string[];
|
|
6
|
+
now?: () => Date;
|
|
7
|
+
}
|
|
8
|
+
export declare class TraceRecorder {
|
|
9
|
+
#private;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
constructor(options: TraceRecorderOptions);
|
|
12
|
+
record(kind: TraceKind, payload: unknown): Promise<void>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|