@nbt-dev/devtools 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/devtools/agent/agent-empty-state.d.ts +5 -0
- package/dist/components/devtools/agent/agent-markdown.d.ts +4 -0
- package/dist/components/devtools/agent/agent-runtime.d.ts +46 -0
- package/dist/components/devtools/agent/agent-tab.d.ts +3 -0
- package/dist/components/devtools/agent/chat-pane.d.ts +25 -0
- package/dist/components/devtools/agent/code-view.d.ts +4 -0
- package/dist/components/devtools/agent/console-tools.d.ts +4 -0
- package/dist/components/devtools/agent/display-director.d.ts +43 -0
- package/dist/components/devtools/agent/display-pane.d.ts +30 -0
- package/dist/components/devtools/{sources → agent}/file-tree.d.ts +2 -6
- package/dist/components/devtools/agent/http-operations.d.ts +20 -0
- package/dist/components/devtools/agent/nbt-tool.d.ts +12 -0
- package/dist/components/devtools/agent/tool-call-card.d.ts +12 -0
- package/dist/components/devtools/agent/use-workspace-files.d.ts +42 -0
- package/dist/components/devtools/agent/workbench.d.ts +16 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/index.js +485 -48
- package/dist/index.js.map +4 -4
- package/dist/styles.css +1 -1
- package/package.json +4 -1
- package/dist/components/devtools/sources/sources-tab.d.ts +0 -3
- package/dist/components/devtools/sources/use-dev-files.d.ts +0 -41
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Agent } from "@earendil-works/pi-agent-core/base";
|
|
2
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core/base";
|
|
3
|
+
import type { Model } from "@earendil-works/pi-ai/base";
|
|
4
|
+
import { createConsoleClient } from "./console-tools";
|
|
5
|
+
import { type HttpOperationsHooks } from "./http-operations";
|
|
6
|
+
export declare const NBT_DEFAULT_MODEL_ID = "gemma-4-26b-a4b";
|
|
7
|
+
/** Models offered in the Agent tab picker. id is forwarded verbatim to the gateway upstream. */
|
|
8
|
+
export declare const NBT_MODEL_CHOICES: ReadonlyArray<{
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type ThinkingLevel = "off" | "low" | "medium" | "high";
|
|
13
|
+
export declare const TRIAGE_MODEL_ID = "gemma-4-26b-a4b";
|
|
14
|
+
/** Build the triage model used by the display director (registers the provider). */
|
|
15
|
+
export declare function createTriageModel(apiBaseUrl: string): Model<"openai-completions">;
|
|
16
|
+
/** Absolute console origin for a (possibly empty = same-origin) apiBaseUrl. */
|
|
17
|
+
export declare function resolveConsoleOrigin(apiBaseUrl: string): string;
|
|
18
|
+
export declare function nbtModel(apiBaseUrl: string, modelId: string): Model<"openai-completions">;
|
|
19
|
+
export interface ConsoleAgent {
|
|
20
|
+
agent: Agent;
|
|
21
|
+
/** The data-plane client backing the tools; its active branch is mutable. */
|
|
22
|
+
client: ReturnType<typeof createConsoleClient>;
|
|
23
|
+
}
|
|
24
|
+
export interface ConsoleAgentOptions {
|
|
25
|
+
/** Approve/deny a mutating tool call. Resolves true to proceed, false to block. */
|
|
26
|
+
confirmMutation?: (toolName: string, args: Record<string, unknown>) => Promise<boolean>;
|
|
27
|
+
/** Called when the active branch changes (via the branch tool). */
|
|
28
|
+
onBranchChange?: () => void;
|
|
29
|
+
/** Restored transcript to seed the agent with (from localStorage). */
|
|
30
|
+
initialMessages?: AgentMessage[];
|
|
31
|
+
/** Upstream model id (forwarded to the gateway). Default: NBT_DEFAULT_MODEL_ID. */
|
|
32
|
+
modelId?: string;
|
|
33
|
+
/** Reasoning level. Default: "off". */
|
|
34
|
+
thinkingLevel?: ThinkingLevel;
|
|
35
|
+
/** Run the lean orchestrator + sub-agents instead of the flat toolset. Default: false. */
|
|
36
|
+
orchestrator?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The data-plane client backing the tools. The Studio tab injects ONE long-lived
|
|
39
|
+
* client it ALSO uses for the editor, so a human Save and an agent edit share the
|
|
40
|
+
* same branch context + cache-invalidation domain. Omitted → a fresh client is made.
|
|
41
|
+
*/
|
|
42
|
+
client?: ReturnType<typeof createConsoleClient>;
|
|
43
|
+
/** Workspace hooks so the editor follows file/tree changes the agent makes. */
|
|
44
|
+
fileHooks?: HttpOperationsHooks;
|
|
45
|
+
}
|
|
46
|
+
export declare function createConsoleAgent(apiBaseUrl: string, opts?: ConsoleAgentOptions): ConsoleAgent;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core/base";
|
|
3
|
+
import { type ThinkingLevel } from "./agent-runtime";
|
|
4
|
+
import { type ToolResultView } from "./tool-call-card";
|
|
5
|
+
export interface ChatSnapshot {
|
|
6
|
+
messages: AgentMessage[];
|
|
7
|
+
streaming?: AgentMessage;
|
|
8
|
+
isStreaming: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ChatPaneProps {
|
|
11
|
+
snap: ChatSnapshot;
|
|
12
|
+
results: Map<string, ToolResultView>;
|
|
13
|
+
showWorking: boolean;
|
|
14
|
+
branch?: string;
|
|
15
|
+
modelId: string;
|
|
16
|
+
thinkingLevel: ThinkingLevel;
|
|
17
|
+
onModel: (id: string) => void;
|
|
18
|
+
onThinking: (l: ThinkingLevel) => void;
|
|
19
|
+
onClear: () => void;
|
|
20
|
+
onSubmit: (text: string) => void;
|
|
21
|
+
onStop: () => void;
|
|
22
|
+
/** Click a tool chip → focus that call's artifact in the display pane. */
|
|
23
|
+
onFocusTool: (name: string, args: Record<string, unknown>, resultText?: string) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const ChatPane: React.FC<ChatPaneProps>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core/base";
|
|
2
|
+
import { ConsoleClient } from "@nbt-dev/agent/console-client";
|
|
3
|
+
export declare function createConsoleClient(baseUrl: string, sessionToken?: string, branchId?: string): ConsoleClient;
|
|
4
|
+
export declare function createConsoleTools(client: ConsoleClient, onBranchChange?: () => void): AgentTool[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core/base";
|
|
2
|
+
export type DisplayDirective = {
|
|
3
|
+
kind: "file";
|
|
4
|
+
cart: string;
|
|
5
|
+
path: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "entity";
|
|
8
|
+
cart: string;
|
|
9
|
+
entity: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "schema";
|
|
12
|
+
cart: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "migration";
|
|
15
|
+
cart?: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "build";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "branch";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "output";
|
|
22
|
+
title: string;
|
|
23
|
+
text: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "none";
|
|
26
|
+
};
|
|
27
|
+
export declare function sameDirective(a: DisplayDirective | null, b: DisplayDirective | null): boolean;
|
|
28
|
+
/** Map a single tool call to the artifact it concerns. null = no domain artifact. */
|
|
29
|
+
export declare function directiveForCall(name: string, args: Record<string, unknown>): DisplayDirective | null;
|
|
30
|
+
/** Instant, model-free directive from the latest tool action. null = nothing to show. */
|
|
31
|
+
export declare function heuristicDirective(messages: AgentMessage[]): DisplayDirective | null;
|
|
32
|
+
export interface TriageContext {
|
|
33
|
+
apiBaseUrl: string;
|
|
34
|
+
apiKey: string;
|
|
35
|
+
/** cart slug → entity names (from the live registry) to constrain the model. */
|
|
36
|
+
carts: Record<string, string[]>;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Refine the directive with a cheap parallel model call. Returns the refined
|
|
41
|
+
* directive, or null to keep whatever the caller already has. Never throws.
|
|
42
|
+
*/
|
|
43
|
+
export declare function triageDirective(messages: AgentMessage[], ctx: TriageContext): Promise<DisplayDirective | null>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type BulkRegistry } from "@nbt-dev/components";
|
|
3
|
+
import type { ConsoleClient } from "@nbt-dev/agent/console-client";
|
|
4
|
+
export declare const EntityView: React.FC<{
|
|
5
|
+
cart: string;
|
|
6
|
+
entity: string;
|
|
7
|
+
registry: BulkRegistry;
|
|
8
|
+
branch?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function useAsync<T>(fn: () => Promise<T>, deps: React.DependencyList): {
|
|
11
|
+
data?: T;
|
|
12
|
+
error?: string;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const MigrationView: React.FC<{
|
|
16
|
+
client: ConsoleClient;
|
|
17
|
+
cart?: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const BuildView: React.FC<{
|
|
20
|
+
text?: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const BranchView: React.FC<{
|
|
23
|
+
client: ConsoleClient;
|
|
24
|
+
active?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const Loading: React.FC;
|
|
27
|
+
export declare const ErrText: React.FC<{
|
|
28
|
+
msg: string;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const EmptyView: React.FC;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { DevCart } from "
|
|
3
|
-
|
|
4
|
-
cart: string;
|
|
5
|
-
path: string;
|
|
6
|
-
};
|
|
2
|
+
import type { DevCart } from "@nbt-dev/agent/console-client";
|
|
3
|
+
import type { FileSel } from "./use-workspace-files";
|
|
7
4
|
type Props = {
|
|
8
5
|
carts: DevCart[];
|
|
9
6
|
selected: FileSel | null;
|
|
10
7
|
dirtyKeys: Set<string>;
|
|
11
8
|
onSelect: (sel: FileSel) => void;
|
|
12
9
|
onNewCart: (name: string) => void;
|
|
13
|
-
onNewMigration: (cart: string) => void;
|
|
14
10
|
};
|
|
15
11
|
export declare const FileTree: React.FC<Props>;
|
|
16
12
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ConsoleClient } from "@nbt-dev/agent/console-client";
|
|
2
|
+
import type { EditOperations, FindOperations, GrepOperations, LsOperations, ReadOperations, WriteOperations } from "@nbt-dev/agent/tools";
|
|
3
|
+
export interface HttpOperations {
|
|
4
|
+
read: ReadOperations;
|
|
5
|
+
edit: EditOperations;
|
|
6
|
+
write: WriteOperations;
|
|
7
|
+
ls: LsOperations;
|
|
8
|
+
grep: GrepOperations;
|
|
9
|
+
find: FindOperations;
|
|
10
|
+
/** Drop the cached cart/file tree (call after a write/migrate/build/apply). */
|
|
11
|
+
invalidate: () => void;
|
|
12
|
+
}
|
|
13
|
+
/** Hooks so the workspace UI can follow file/tree changes the agent makes. */
|
|
14
|
+
export interface HttpOperationsHooks {
|
|
15
|
+
/** A specific cart file was written by the agent (so an open editor can refresh it). */
|
|
16
|
+
onFileWritten?: (cart: string, rel: string) => void;
|
|
17
|
+
/** The cart/file tree changed (write/migrate/build/apply) — re-list carts. */
|
|
18
|
+
onTreeChanged?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createHttpOperations(client: ConsoleClient, hooks?: HttpOperationsHooks): HttpOperations;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core/base";
|
|
2
|
+
import { Type } from "@earendil-works/pi-ai/base";
|
|
3
|
+
import { ConsoleClient } from "@nbt-dev/agent/console-client";
|
|
4
|
+
declare const nbtSchema: Type.TObject<{
|
|
5
|
+
op: Type.TUnion<[Type.TLiteral<"status">, Type.TLiteral<"history">, Type.TLiteral<"validate">, Type.TLiteral<"scaffold">, Type.TLiteral<"migrate">, Type.TLiteral<"build">, Type.TLiteral<"apply">]>;
|
|
6
|
+
cart: Type.TOptional<Type.TString>;
|
|
7
|
+
name: Type.TOptional<Type.TString>;
|
|
8
|
+
message: Type.TOptional<Type.TString>;
|
|
9
|
+
dir: Type.TOptional<Type.TString>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function createNbtTool(client: ConsoleClient, onMutate?: () => void): AgentTool<typeof nbtSchema>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ToolResultView {
|
|
3
|
+
isError: boolean;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function friendlyToolLabel(name: string, args: Record<string, unknown> | undefined): string;
|
|
7
|
+
export declare const ToolCallCard: React.FC<{
|
|
8
|
+
name: string;
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
result?: ToolResultView;
|
|
11
|
+
running: boolean;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NbtLspClient } from "@nbt-dev/components/editor";
|
|
2
|
+
import type { ConsoleClient, DevCart, DevDiagnostic, DevStatus } from "@nbt-dev/agent/console-client";
|
|
3
|
+
import type { HttpOperationsHooks } from "./http-operations";
|
|
4
|
+
export type FileSel = {
|
|
5
|
+
cart: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
export type FileBuffer = {
|
|
9
|
+
saved: string;
|
|
10
|
+
current: string;
|
|
11
|
+
writable: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const isGeneratedPath: (path: string) => boolean;
|
|
14
|
+
export interface WorkspaceFiles {
|
|
15
|
+
devStatus: DevStatus | null;
|
|
16
|
+
carts: DevCart[];
|
|
17
|
+
refreshCarts: () => void;
|
|
18
|
+
selected: FileSel | null;
|
|
19
|
+
openFile: (sel: FileSel) => void;
|
|
20
|
+
activeBuffer: FileBuffer | undefined;
|
|
21
|
+
dirtyKeys: Set<string>;
|
|
22
|
+
conflictKeys: Set<string>;
|
|
23
|
+
onChange: (text: string) => void;
|
|
24
|
+
onSave: (text: string) => void;
|
|
25
|
+
reloadFromDisk: (sel: FileSel) => void;
|
|
26
|
+
keepMine: (sel: FileSel) => void;
|
|
27
|
+
diagnostics: DevDiagnostic[];
|
|
28
|
+
statusMsg: string;
|
|
29
|
+
setStatusMsg: (s: string) => void;
|
|
30
|
+
lsp: NbtLspClient | null;
|
|
31
|
+
/** Stable hooks the agent runtime calls so the editor follows agent edits. */
|
|
32
|
+
agentFileHooks: HttpOperationsHooks;
|
|
33
|
+
editor: {
|
|
34
|
+
theme: string;
|
|
35
|
+
fontSize: number;
|
|
36
|
+
lineWrap: boolean;
|
|
37
|
+
tabSize: number;
|
|
38
|
+
};
|
|
39
|
+
treeWidth: number;
|
|
40
|
+
setTreeWidth: (n: number) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare function useWorkspaceFiles(client: ConsoleClient, apiBaseUrl: string): WorkspaceFiles;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { BulkRegistry } from "@nbt-dev/components";
|
|
3
|
+
import type { ConsoleClient } from "@nbt-dev/agent/console-client";
|
|
4
|
+
import type { DisplayDirective } from "./display-director";
|
|
5
|
+
import { type WorkspaceFiles, type FileSel } from "./use-workspace-files";
|
|
6
|
+
export interface WorkbenchProps {
|
|
7
|
+
ws: WorkspaceFiles;
|
|
8
|
+
client: ConsoleClient;
|
|
9
|
+
registry: BulkRegistry;
|
|
10
|
+
directive: DisplayDirective;
|
|
11
|
+
branch?: string;
|
|
12
|
+
/** Most recent agent `nbt build` output (drives the Build panel when present). */
|
|
13
|
+
lastBuildText?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const Workbench: React.FC<WorkbenchProps>;
|
|
16
|
+
export type { FileSel };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
|
|
5
5
|
size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|